/* ============================================
   Markdown 文章生成器 - 样式表
   ============================================ */

/* CSS 变量 - 浅色主题 */
:root {
  --background: hsl(210 40% 98%);
  --foreground: hsl(222 47% 11%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(222 47% 11%);
  --muted: hsl(214 32% 91%);
  --muted-foreground: hsl(215 16% 47%);
  --primary: hsl(221 83% 53%);
  --primary-foreground: hsl(0 0% 100%);
  --secondary: hsl(214 32% 91%);
  --secondary-foreground: hsl(222 47% 11%);
  --accent: hsl(214 32% 91%);
  --accent-foreground: hsl(222 47% 11%);
  --border: hsl(214 32% 84%);
  --input: hsl(214 32% 84%);
  --ring: hsl(221 83% 53%);
  --destructive: hsl(0 84% 60%);
  --destructive-foreground: hsl(0 0% 100%);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);

  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
}

/* 深色主题 */
.dark {
  --background: hsl(222 47% 8%);
  --foreground: hsl(210 40% 98%);
  --card: hsl(222 47% 11%);
  --card-foreground: hsl(210 40% 98%);
  --muted: hsl(217 33% 17%);
  --muted-foreground: hsl(215 20% 65%);
  --primary: hsl(221 83% 65%);
  --primary-foreground: hsl(222 47% 8%);
  --secondary: hsl(217 33% 17%);
  --secondary-foreground: hsl(210 40% 98%);
  --accent: hsl(217 33% 17%);
  --accent-foreground: hsl(210 40% 98%);
  --border: hsl(217 33% 25%);
  --input: hsl(217 33% 25%);
  --ring: hsl(221 83% 65%);
}

/* 重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* 工具类 */
.hidden {
  display: none !important;
}

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.icon-xs {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================
   Toast 提示
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.25s ease-out;
  pointer-events: auto;
  min-width: 160px;
}

.toast.success {
  border-left: 3px solid #22c55e;
}

.toast.error {
  border-left: 3px solid var(--destructive);
}

.toast.info {
  border-left: 3px solid var(--primary);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ============================================
   顶部工具栏
   ============================================ */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background-color: color-mix(in srgb, var(--background) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.toolbar-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-right a.btn {
  text-decoration: none;
}
/* 鼠标悬浮也不要额外下划线 */
.toolbar-right a.btn:hover {
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background-color: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

.toolbar-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
  line-height: 1.2;
}

.toolbar-title p {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   按钮组件
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  white-space: nowrap;
  position: relative;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.btn-xs {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-icon {
  width: 36px;
  padding: 0;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background-color: color-mix(in srgb, var(--primary) 88%, black);
}

.btn-outline {
  background-color: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background-color: var(--accent);
}

.btn-ghost {
  background-color: transparent;
  color: var(--muted-foreground);
}

.btn-ghost:hover {
  background-color: var(--accent);
  color: var(--foreground);
}

/* ============================================
   主内容区
   ============================================ */
.main-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

/* 桌面端三栏布局 */
.layout-desktop {
  display: grid;
  grid-template-columns: minmax(0, 380px) 1fr 1fr;
  grid-template-rows: 1fr;
  gap: 24px;
  height: calc(100vh - 88px);
  min-height: 500px;
  overflow: hidden;
}

/* 平板端两栏 */
.layout-tablet,
.layout-mobile {
  display: none;
}

/* ============================================
   面板通用样式
   ============================================ */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-2xl);
  border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  background-color: var(--card);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  flex-shrink: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

.panel-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.panel-meta {
  font-size: 12px;
  color: var(--muted-foreground);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 表单面板 */
.form-panel {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding-right: 4px;
  min-height: 0;
  height: 100%;
}

.form-panel::-webkit-scrollbar {
  width: 6px;
}

.form-panel::-webkit-scrollbar-track {
  background: transparent;
}

.form-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ============================================
   卡片
   ============================================ */
.card {
  background-color: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.card:last-child {
  margin-bottom: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
}

.card-icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
}

.card-body {
  padding: 20px;
}

/* ============================================
   表单
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 6px;
}

.form-hint {
  color: var(--muted-foreground);
  font-weight: 400;
}

.required {
  color: var(--destructive);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--foreground);
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 60px;
  font-family: var(--font-sans);
  line-height: 1.5;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 0.8;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 15%, transparent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 下拉选择 */
.select-wrapper {
  position: relative;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  cursor: pointer;
  background-color: var(--card);
}

.select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-foreground);
  pointer-events: none;
}

/* 预设 URL 展示 */
.preset-url {
  background-color: var(--muted);
  color: var(--muted-foreground);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   标签输入
   ============================================ */
.tags-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tags-input-wrapper:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 15%, transparent);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 10px;
  background-color: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: transparent;
  color: var(--primary);
  opacity: 0.7;
  transition: all 0.15s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.tag-remove:hover {
  background-color: color-mix(in srgb, var(--primary) 20%, transparent);
  opacity: 1;
}

.tag-remove svg {
  width: 12px;
  height: 12px;
}

.tags-input {
  flex: 1;
  min-width: 100px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--foreground);
  font-size: 13px;
  padding: 4px 2px;
}

.tags-input::placeholder {
  color: var(--muted-foreground);
  opacity: 0.8;
}

/* ============================================
   开关组件
   ============================================ */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background-color: color-mix(in srgb, var(--muted) 50%, transparent);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}

.switch-row:last-child {
  margin-bottom: 0;
}

.switch-info {
  flex: 1;
  min-width: 0;
}

.switch-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}

.switch-desc {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-left: 12px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--muted);
  border-radius: 9999px;
  transition: background-color 0.2s ease;
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
  background-color: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch input:focus + .switch-slider {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* ============================================
   编辑器
   ============================================ */
.editor-panel {
  height: 100%;
}

.editor-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.markdown-editor {
  width: 100%;
  height: 100%;
  padding: 20px;
  border: none;
  outline: none;
  resize: none;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  tab-size: 2;
}

.markdown-editor::placeholder {
  color: var(--muted-foreground);
}

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background-color: var(--card);
}
.md-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  transition: 0.15s;
}
.md-btn:hover {
  background-color: var(--accent);
}

/* ============================================
   预览区
   ============================================ */
.preview-panel {
  height: 100%;
}

/* Tabs */
.tabs {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs-list {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  flex-shrink: 0;
}

.tab-trigger {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.tab-trigger:hover {
  color: var(--foreground);
}

.tab-trigger.active {
  color: var(--foreground);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-content.active {
  display: block;
}

/* 渲染预览 */
.preview-render {
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  background-color: var(--background);
}

.preview-render::-webkit-scrollbar,
.code-preview::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.preview-render::-webkit-scrollbar-track,
.code-preview::-webkit-scrollbar-track {
  background: transparent;
}

.preview-render::-webkit-scrollbar-thumb,
.code-preview::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Prose 样式 */
.prose {
  max-width: none;
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.75;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-weight: 700;
  color: var(--foreground);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.prose h1 { font-size: 2em; }
.prose h2 { font-size: 1.5em; }
.prose h3 { font-size: 1.25em; }

.prose p {
  margin-top: 1em;
  margin-bottom: 1em;
}

.prose a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose strong {
  font-weight: 600;
}

.prose em {
  font-style: italic;
}

.prose ul,
.prose ol {
  margin-top: 1em;
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.prose li {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--primary);
  background-color: color-mix(in srgb, var(--primary) 8%, transparent);
  color: var(--muted-foreground);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.prose code {
  background-color: var(--muted);
  color: var(--foreground);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.prose pre {
  background-color: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 1.5em 0;
}

.prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.6;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 13px;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.prose th {
  background-color: var(--muted);
  font-weight: 600;
}

.prose img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

/* 代码预览 */
.code-preview {
  height: 100%;
  overflow: auto;
  background-color: #0f172a;
  padding: 20px;
}

.code-block {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-block .yaml-key {
  color: #38bdf8;
}

.code-block .yaml-colon {
  color: #64748b;
}

.code-block .yaml-string {
  color: #4ade80;
}

.code-block .yaml-bool,
.code-block .yaml-date,
.code-block .yaml-number {
  color: #fbbf24;
}

.code-block .yaml-separator {
  color: #475569;
}

.code-block .yaml-array {
  color: #a78bfa;
}

/* ============================================
   移动端布局
   ============================================ */
.mobile-tabs {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  background-color: var(--muted);
  padding: 4px;
  border-radius: var(--radius-lg);
}

.mobile-tab {
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  cursor: pointer;
}

.mobile-tab.active {
  background-color: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

.mobile-tab-content {
  display: none;
}

.mobile-tab-content.active {
  display: block;
}

/* ============================================
   响应式
   ============================================ */

/* ========== 重写响应式布局核心 ========== */
/* 桌面端默认显示 */
.layout-desktop {
  display: grid;
  grid-template-columns: minmax(0, 380px) 1fr 1fr;
  grid-template-rows: 1fr;
  gap: 24px;
  height: calc(100vh - 88px);
  min-height: 500px;
  overflow: hidden;
}
.layout-tablet, .layout-mobile { display: none; }

/* 平板端 769px ~ 1024px */
@media (max-width: 1024px) and (min-width: 769px) {
  .layout-desktop { display: none; }
  .layout-tablet {
    display: grid;
    grid-template-columns: minmax(0, 360px) 1fr;
    gap: 24px;
    height: calc(100vh - 88px);
    overflow: hidden;
  }
  .tablet-left { height: 100%; overflow: hidden; }
  .tablet-form-mirror {
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
  }
  .tablet-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
  }
  .tablet-editor, .tablet-preview {
    flex: 1;
    min-height: 320px;
    height: auto;
    overflow: hidden;
  }
}

/* 移动端 ≤768px */
@media (max-width: 768px) {
  /* 顶部工具栏适配 */
  .toolbar-inner { padding: 0 12px; height: 56px; }
  .toolbar-title p { display: none; }
  .btn-text { display: none; }
  .btn-sm { width: 36px; padding: 0; }
  .toolbar-right { gap: 4px; }

  /* 切换布局 */
  .layout-desktop, .layout-tablet { display: none; }
  .layout-mobile { display: block; }
  .main-container { padding: 12px; }

  /* 移动端Tab栏 */
  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 12px;
    background-color: var(--muted);
    padding: 4px;
    border-radius: var(--radius-lg);
  }
  .mobile-tab {
    padding: 8px 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted-foreground);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    cursor: pointer;
  }
  .mobile-tab.active {
    background-color: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
  }
  .mobile-tab-content {
    display: none;
    height: calc(100vh - 140px);
    overflow: hidden;
  }
  .mobile-tab-content.active { display: block; }

  /* 移动端各面板高度自适应 */
  .mobile-form-mirror {
    height: 100%;
    overflow-y: auto;
    padding-right: 2px;
  }
  .mobile-editor-mirror, .mobile-preview-mirror {
    height: 100%;
    overflow: hidden;
  }

  /* 表单单行铺满 */
  .form-row { grid-template-columns: 1fr; }

  /* 编辑器工具栏缩小，自动换行 */
  .md-toolbar { gap: 2px; padding: 6px 8px; }
  .md-btn { height: 28px; padding: 0 6px; font-size: 11px; }
  .md-dropdown-btn { height:28px; padding:0 6px; font-size:11px; }

  /* 预览区域内边距缩小 */
  .preview-render { padding: 16px; }
  .code-preview { padding: 16px; }

  /* Toast弹窗适配手机右侧不溢出 */
  .toast-container { right: 12px; left: 12px; }
  .toast { width: 100%; max-width: unset; }
}

/* 超小屏 ≤480px */
@media (max-width: 480px) {
  .card-header { padding: 16px 16px 12px; }
  .card-body { padding: 16px; }
  .panel-header { padding: 10px 14px; }
  .tags-input-wrapper { flex-wrap: wrap; }
  .switch-row { padding: 10px; }
}

/* ========== 新增镜像面板通用样式（JS克隆DOM专用） ========== */
/* 隐藏原始桌面面板，平板/手机只使用克隆镜像，避免双渲染冲突 */
.layout-desktop .form-panel,
.layout-desktop .editor-panel,
.layout-desktop .preview-panel {
  visibility: visible;
}
.tablet-form-mirror, .mobile-form-mirror,
.tablet-editor-mirror, .mobile-editor-mirror,
.tablet-preview-mirror, .mobile-preview-mirror {
  width: 100%;
  height: 100%;
}
/* 克隆后的滚动条统一 */
.tablet-form-mirror::-webkit-scrollbar,
.mobile-form-mirror::-webkit-scrollbar {
  width: 4px;
}
.tablet-form-mirror::-webkit-scrollbar-thumb,
.mobile-form-mirror::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ========== 修复移动端下拉菜单溢出屏幕 ========== */
.md-dropdown-menu {
  left: auto !important;
  right: 0;
  min-width: 140px;
}

/* ========== Markdown工具栏下拉扩展菜单 ========== */
.md-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.md-dropdown-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.md-dropdown-btn:hover {
  background-color: var(--accent);
}

.md-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 160px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: none;
}
.md-dropdown-menu.open {
  display: block;
}

.md-dropdown-item {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: transparent;
}
.md-dropdown-item:hover {
  background-color: var(--accent);
}

/* Spoiler 预览样式 */
.spoiler-block {
  position: relative;
  cursor: pointer;
  display: inline;
}
.spoiler-mask {
  position: absolute;
  inset: 0;
  background: var(--muted);
  border-radius: 4px;
  transition: opacity 0.2s ease;
}
.spoiler-block.open .spoiler-mask {
  opacity: 0;
  pointer-events: none;
}
.spoiler-content {
  visibility: hidden;
}
.spoiler-block.open .spoiler-content {
  visibility: visible;
}

iframe[src*="youtube.com/embed"] {
  height: auto !important;
  aspect-ratio: 16 / 9;
}

iframe[src*="player.bilibili.com"] {
  height: auto !important;
  aspect-ratio: 16 / 9;
}

/* Github卡片基础样式 */
.github-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 12px 0;
  background: var(--card);
}
.github-card-loading {
  color: var(--muted-foreground);
  font-size:13px;
}

.github-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
}
.github-card-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: inherit;
}
.github-card-loading {
    color:#888;
    padding:12px;
}
.github-card-error {
    color:#f56c6c;
    padding:12px;
}
.gh-left h4 {margin:0 0 4px}
.gh-left p {margin:0; color:#666; font-size:14px}
.gh-right {display:flex; gap:16px; color:#666}