/* ==========================================================================
   技术卡片页样式：三主题阅读模式 + 目录锚点 + 沉浸式编辑器
   ========================================================================== */

/* ---------------------------------------------------------------- 设计令牌 */
:root {
  --bg-page: #FFFFFF;
  --bg-surface: #F8FAFC;
  --bg-subtle: #F1F5F9;
  --bg-muted: #E2E8F0;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-light: #E2E8F0;
  --border-strong: #CBD5E1;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-inverse: #FFFFFF;

  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-soft: #EEF2FF;
  --accent-border: #C7D2FE;

  --accent-emerald: #059669;
  --accent-emerald-soft: #ECFDF5;
  --accent-emerald-border: #A7F3D0;

  --accent-amber: #B45309;
  --accent-amber-soft: #FFFBEB;
  --accent-amber-border: #FDE68A;

  --accent-rose: #BE123C;
  --accent-rose-soft: #FFF1F2;
  --accent-rose-border: #FECDD3;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.12), 0 6px 14px rgba(15, 23, 42, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --header-height: 62px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
}

[data-theme='green'] {
  --bg-page: #E9F3EC;
  --bg-surface: #F4FAF6;
  --bg-subtle: #DDEEE3;
  --bg-muted: #CFE5D7;
  --bg-glass: rgba(233, 243, 236, 0.9);
  --border-light: #C3DFCE;
  --border-strong: #A9CFB9;

  --text-primary: #1A2E23;
  --text-secondary: #355243;
  --text-muted: #5A7566;
  --text-inverse: #FFFFFF;

  --accent: #247A52;
  --accent-hover: #1C6242;
  --accent-soft: #DCF0E5;
  --accent-border: #B3DCC7;

  --accent-emerald: #1F6F4B;
  --accent-emerald-soft: #D8EFE1;
  --accent-emerald-border: #A9D8BF;

  --accent-amber: #7A5A16;
  --accent-amber-soft: #F7EFD8;
  --accent-amber-border: #E3D3A8;

  --accent-rose: #9B3542;
  --accent-rose-soft: #F8E3E5;
  --accent-rose-border: #E9C3C8;

  --shadow-xs: 0 1px 2px rgba(26, 46, 35, 0.05);
  --shadow-sm: 0 1px 3px rgba(26, 46, 35, 0.07);
  --shadow-md: 0 4px 12px rgba(26, 46, 35, 0.08);
  --shadow-lg: 0 18px 40px rgba(26, 46, 35, 0.14);
}

[data-theme='dark'] {
  --bg-page: #0B1120;
  --bg-surface: #111827;
  --bg-subtle: #1E293B;
  --bg-muted: #334155;
  --bg-glass: rgba(11, 17, 32, 0.88);
  --border-light: #1F2937;
  --border-strong: #334155;

  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-inverse: #0F172A;

  --accent: #818CF8;
  --accent-hover: #A5B4FC;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-border: rgba(129, 140, 248, 0.35);

  --accent-emerald: #34D399;
  --accent-emerald-soft: rgba(16, 185, 129, 0.14);
  --accent-emerald-border: rgba(52, 211, 153, 0.32);

  --accent-amber: #FBBF24;
  --accent-amber-soft: rgba(245, 158, 11, 0.14);
  --accent-amber-border: rgba(251, 191, 36, 0.32);

  --accent-rose: #FB7185;
  --accent-rose-soft: rgba(244, 63, 94, 0.14);
  --accent-rose-border: rgba(251, 113, 133, 0.32);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------------- 基础 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text-secondary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* ---------------------------------------------------------------- 顶栏 */
.card-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.back-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  transform: translateX(-2px);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}

.layer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
}

.status-badge {
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-amber);
  background: var(--accent-amber-soft);
  border: 1px solid var(--accent-amber-border);
  white-space: nowrap;
}

.status-badge.published {
  color: var(--accent-emerald);
  background: var(--accent-emerald-soft);
  border-color: var(--accent-emerald-border);
}

.header-spacer {
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12.8px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease,
    transform 0.16s ease;
}

.btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

[data-theme='dark'] .btn.primary {
  color: var(--text-inverse);
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.danger {
  color: var(--accent-rose);
  border-color: var(--accent-rose-border);
  background: var(--accent-rose-soft);
}

.btn.danger:hover {
  background: var(--accent-rose);
  color: #fff;
  border-color: var(--accent-rose);
}

.btn.ghost {
  background: transparent;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 主题切换 */
.theme-switch {
  position: relative;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
}

.theme-toggle:hover {
  background: var(--bg-subtle);
}

.theme-swatch {
  width: 15px;
  height: 15px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: #fff;
  flex-shrink: 0;
}

.swatch-white {
  background: #ffffff;
  border-color: #cbd5e1;
}

.swatch-green {
  background: #e9f3ec;
  border-color: #a9cfb9;
}

.swatch-dark {
  background: #111827;
  border-color: #334155;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 206px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
}

.theme-menu.open {
  display: block;
  animation: menuIn 0.16s ease both;
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.theme-option em {
  margin-left: auto;
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-muted);
}

.theme-option:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.theme-option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-option.is-active em {
  color: var(--accent);
  opacity: 0.75;
}

/* ---------------------------------------------------------------- 布局 */
.card-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 28px) 24px 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

/* 正文卡片（单列布局，控制阅读宽度） */
.card-main {
  min-width: 0;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
}

.card-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.card-summary {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-muted);
}

.card-alias-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.alias-chip {
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.pending-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 22px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--accent-amber-border);
  background: var(--accent-amber-soft);
  color: var(--text-primary);
  font-size: 13.5px;
}

.pending-banner strong {
  color: var(--accent-amber);
}

.pending-banner[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- 已阅读打卡 */
.read-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.read-bar[hidden] {
  display: none;
}

.read-btn {
  height: 38px;
  padding: 0 16px;
  font-weight: 600;
}

.read-btn.is-read {
  color: var(--accent-emerald);
  border-color: var(--accent-emerald-border);
  background: var(--accent-emerald-soft);
}

.read-btn.is-read:hover {
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
  background: var(--accent-emerald-soft);
}

.read-btn:active {
  transform: translateY(1px);
}

.read-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 重点技术：默认置灰，开启后高亮发光 */
.key-btn {
  height: 38px;
  padding: 0 16px;
  color: var(--text-muted);
  border-color: var(--border-light);
  background: var(--bg-page);
}

.key-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.key-btn.is-key {
  color: #7C4A03;
  border-color: #F2C94C;
  background: linear-gradient(180deg, #FFF8DC, #FDE68A);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.18), var(--shadow-sm);
}

.key-btn.is-key:hover {
  color: #6B3D02;
  border-color: #EAB308;
  background: linear-gradient(180deg, #FFF9C4, #FCD34D);
}

.key-btn:active {
  transform: translateY(1px);
}

[data-theme='dark'] .key-btn.is-key {
  color: #FDE68A;
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.16);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.12);
}

[data-theme='dark'] .key-btn.is-key:hover {
  color: #FEF3C7;
  background: rgba(250, 204, 21, 0.26);
}

/* ---------------------------------------------------------------- Markdown 正文 */
.markdown-body {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 34px 38px 40px;
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: 15.5px;
  line-height: 1.78;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  display: none;
}

.markdown-body h2 {
  position: relative;
  margin: 44px 0 16px;
  padding: 0 0 0 14px;
  font-size: 22px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  border-left: 4px solid var(--accent);
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.markdown-body h2:first-of-type {
  margin-top: 8px;
}

.markdown-body h2.h2-warn {
  border-left-color: var(--accent-rose);
  color: var(--accent-rose);
}

.markdown-body h2.h2-decision {
  border-left-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.markdown-body h2.h2-analogy {
  border-left-color: var(--accent-amber);
}

.markdown-body h3 {
  margin: 30px 0 12px;
  font-size: 17.5px;
  font-weight: 700;
  color: var(--text-primary);
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.markdown-body h4 {
  margin: 22px 0 10px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-body p {
  margin: 0 0 14px;
}

.markdown-body strong {
  color: var(--text-primary);
  font-weight: 650;
}

.markdown-body em {
  color: var(--text-secondary);
}

.markdown-body a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline dotted var(--accent-border);
  text-underline-offset: 3px;
}

.markdown-body a:hover {
  background: var(--accent-soft);
  text-decoration-style: solid;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.markdown-body li {
  margin: 7px 0;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin: 7px 0 7px;
}

.markdown-body li::marker {
  color: var(--accent);
}

.markdown-body hr {
  border: 0;
  height: 1px;
  background: var(--border-light);
  margin: 28px 0;
}

/* 引用块：通俗类比 / 劝退红线 / 决策口诀 */
.markdown-body blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 14.8px;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body blockquote.quote-warn {
  border-left-color: var(--accent-rose);
  background: var(--accent-rose-soft);
}

.markdown-body blockquote.quote-decision {
  border-left-color: var(--accent-emerald);
  background: var(--accent-emerald-soft);
  font-weight: 500;
}

.markdown-body blockquote.quote-analogy {
  border-left-color: var(--accent-amber);
  background: var(--accent-amber-soft);
}

.markdown-body blockquote.quote-analogy::before {
  content: '类比';
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
  margin-right: 8px;
}

/* 表格：横向滚动容器，绝不撑破移动端 */
.table-scroll {
  margin: 18px 0 22px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
}

.table-scroll::-webkit-scrollbar {
  height: 8px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

.markdown-body table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13.8px;
  line-height: 1.65;
}

.markdown-body thead th {
  position: sticky;
  top: 0;
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.markdown-body tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.markdown-body tbody tr:last-child td {
  border-bottom: 0;
}

.markdown-body tbody tr:nth-child(even) {
  background: var(--bg-page);
}

[data-theme='green'] .markdown-body tbody tr:nth-child(even) {
  background: #EFF7F1;
}

.markdown-body tbody tr:hover {
  background: var(--accent-soft);
}

/* 行内代码与代码块 */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--accent);
}

.markdown-body pre {
  margin: 16px 0 20px;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  line-height: 1.6;
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
}

/* ---------------------------------------------------------------- 编辑模式 */
.editor-shell {
  display: none;
}

body.is-editing .reader-shell {
  display: none;
}

body.is-editing .editor-shell {
  display: block;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 10px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  margin: 0 3px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
}

.tool-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.editor-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field .hint {
  font-size: 11px;
  color: var(--text-muted);
}

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  overflow: hidden;
  min-height: 480px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-light);
}

.editor-textarea {
  flex: 1;
  width: 100%;
  min-height: 460px;
  padding: 16px;
  border: 0;
  outline: none;
  resize: vertical;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  tab-size: 2;
}

.editor-preview {
  flex: 1;
  padding: 18px 20px;
  overflow-y: auto;
  max-height: 72vh;
}

.editor-preview.markdown-body {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 18px 20px;
}

.editor-preview.markdown-body h2 {
  font-size: 19px;
  margin: 20px 0 10px;
}

.editor-preview.markdown-body h3 {
  font-size: 16px;
  margin: 16px 0 8px;
}

.editor-tabs {
  display: none;
}

.editor-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.editor-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ---------------------------------------------------------------- 弹层 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: min(440px, 100%);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transform: translateY(-8px) scale(0.99);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--text-primary);
}

.modal p {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

.modal .field + .field {
  margin-top: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-error {
  display: none;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-rose-soft);
  border: 1px solid var(--accent-rose-border);
  color: var(--accent-rose);
  font-size: 12.5px;
}

.modal-error.show {
  display: block;
}

/* 轻提示 */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--bg-page);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease both;
  max-width: 320px;
}

.toast.error {
  background: var(--accent-rose);
  color: #fff;
}

.toast.success {
  background: var(--accent-emerald);
  color: #fff;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 加载骨架 */
.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-surface) 37%, var(--bg-subtle) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}

@keyframes shimmer {
  from {
    background-position: 100% 50%;
  }
  to {
    background-position: 0 50%;
  }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 12px;
}

.loading-wrap {
  padding: 28px;
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 1080px) {
  .card-shell {
    grid-template-columns: 1fr;
    padding: calc(var(--header-height) + 20px) 18px 96px;
    gap: 18px;
  }

  .markdown-body {
    padding: 26px 20px 32px;
    font-size: 15px;
  }

  .markdown-body h2 {
    font-size: 19.5px;
  }

  .markdown-body h3 {
    font-size: 16.5px;
  }

  .card-hero {
    padding: 22px 20px;
  }

  .card-title {
    font-size: 24px;
  }

  .editor-split {
    grid-template-columns: 1fr;
  }

  .editor-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
  }

  .editor-tab {
    flex: 1;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
  }

  .editor-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .editor-pane.preview-pane {
    display: none;
  }

  body.show-preview .editor-pane.editor-pane-text {
    display: none;
  }

  body.show-preview .editor-pane.preview-pane {
    display: flex;
  }

  .editor-pane {
    min-height: 380px;
  }

  .editor-textarea {
    min-height: 360px;
  }
}

@media (max-width: 720px) {
  .card-header {
    padding: 0 12px;
    gap: 8px;
    height: 58px;
  }

  :root {
    --header-height: 58px;
  }

  .header-badges {
    display: none;
  }

  .header-actions .btn-text {
    display: none;
  }

  .header-actions .btn {
    width: 36px;
    padding: 0;
  }

  .theme-toggle span:not(.theme-swatch) {
    display: none;
  }

  .theme-toggle {
    padding: 0 10px;
  }

  .back-btn span {
    display: none;
  }

  .back-btn {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .card-title {
    font-size: 22px;
  }

  .markdown-body table {
    min-width: 520px;
    font-size: 13px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 76px;
  }

  .toast {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
