/* ============================================================
   RedSugarTree 工具站 · 共享样式
   依据 red-sugar-tree-brand/design-system.md：
   单一强调色红 + navy、系统字体、大留白、软阴影、零外链。
   ============================================================ */

:root {
  /* 品牌色（唯一权威源） */
  --red: #C0392B;
  --red-dark: #A93226;
  --red-soft: #FBEAE8;
  --accent: #C0392B;          /* 文字/图标用强调色；暗色模式下单独覆盖 */
  --navy: #0F2440;
  --navy-2: #16305A;
  --navy-ink: #0B1A30;

  /* 中性色 */
  --ink: #1B2433;
  --slate: #46536B;
  --muted: #6B7686;
  --line: #E4E8EF;
  --line-soft: #EDF0F5;
  --bg: #FFFFFF;
  --bg-soft: #F7F8FA;

  /* 状态色（只做圆点、勾、13px 徽章） */
  --ok: #1A8F5B;
  --warn: #C98A06;

  /* 形状与深度 */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 36, 64, .04), 0 6px 18px rgba(15, 36, 64, .05);
  --shadow-md: 0 10px 34px rgba(15, 36, 64, .10);
  --toast-bg: #0F2440;

  --header-h: 68px;
  --container: 1120px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* 暗色模式：强调文字提亮以保证 ≥4.5:1；按钮底色仍用品牌红 */
html[data-theme="dark"] {
  --accent: #FF8A7A;
  --navy: #EDF2FA;
  --ink: #E8EDF5;
  --slate: #B2BECE;
  --muted: #8A98AC;
  --line: #2B3C57;
  --line-soft: #22324B;
  --bg: #0F1B2E;
  --bg-soft: #132239;
  --red-soft: #3A211E;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 18px rgba(0, 0, 0, .22);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); }
h1, h2, h3, h4 { color: var(--navy); line-height: 1.2; }
p { margin: 0 0 16px; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
html[data-theme="dark"] .site-header { background: rgba(15, 27, 46, .9); }

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* 字标已含品牌名，不叠站名文字 */
.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  flex: none;
}
html[data-theme="dark"] .brand-logo {
  background: #F7F8FA;             /* 暗色下给浅底，保证 navy 字标可读 */
  padding: 3px 9px;
  border-radius: 9px;
}

.nav { display: flex; align-items: center; gap: 26px; }
.nav a {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  transition: color .18s;
}
.nav a:hover, .nav a.active { color: var(--accent); }

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

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--slate);
  cursor: pointer;
  transition: border-color .18s, color .18s, transform .12s;
}
.icon-btn:hover { border-color: #C9D1DD; color: var(--accent); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-sun { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1;
  padding: 13px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s, border-color .18s, box-shadow .18s, transform .12s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.loading { opacity: .65; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(192, 57, 43, .25);
}
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost {
  background: var(--bg);
  color: var(--navy);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { border-color: #C9D1DD; }
.btn-sm { font-size: 14px; padding: 10px 16px; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Eyebrow / Hero ---------- */
.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .08em;
  color: var(--accent);
}

.hero { padding: 92px 0 64px; text-align: center; }
.hero h1 {
  font-size: clamp(38px, 5.2vw, 58px);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin: 16px 0 0;
}
.hero .lede {
  max-width: 660px;
  margin: 22px auto 0;
  font-size: 19.5px;
  line-height: 1.6;
  color: var(--slate);
}
.hero-actions { margin-top: 32px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.section { padding: 72px 0; }
.section-soft { background: var(--bg-soft); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.section-head { max-width: 660px; margin-bottom: 40px; }
.section-head h2 {
  font-size: clamp(28px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 12px 0 0;
}
.section-head p { margin: 14px 0 0; font-size: 15.5px; color: var(--slate); }

/* ---------- Tool cards ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.tool-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #D8DEE9;
}
.tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--red-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}
.tool-icon svg { width: 24px; height: 24px; }
.tool-card h3 { font-size: 20px; margin: 0 0 8px; font-weight: 650; letter-spacing: -.01em; }
.tool-card p { font-size: 15.5px; color: var(--slate); line-height: 1.6; margin: 0 0 22px; }
.tool-card .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-link { font-size: 14.5px; font-weight: 600; color: var(--accent); }
.card-link span { display: inline-block; transition: transform .18s; }
.tool-card:hover .card-link span { transform: translateX(3px); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--slate);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.warn .dot { background: var(--warn); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--navy-ink);
  color: #C6D0E0;
  padding: 56px 0 32px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 40px;
}
.footer-brand img { height: 30px; width: auto; filter: brightness(0) invert(1); opacity: .92; }
.footer-brand p { margin: 16px 0 0; font-size: 14.5px; line-height: 1.7; color: #9AA9BF; max-width: 420px; }
.footer-col h4 {
  color: #fff;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 0 0 16px;
}
.footer-col a { display: block; color: #9AA9BF; text-decoration: none; font-size: 14.5px; margin-bottom: 10px; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: 13.5px;
  color: #8494AB;
  line-height: 1.7;
}

/* ---------- Tool page header ---------- */
.tool-head { padding: 48px 0 32px; }
.crumb { font-size: 14px; color: var(--muted); }
.crumb a { color: var(--slate); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.tool-head h1 {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 14px 0 0;
}
.tool-head .lede { margin: 12px 0 0; max-width: 720px; font-size: 17.5px; color: var(--slate); line-height: 1.6; }

/* ---------- Workspace ---------- */
.tool-main { padding-bottom: 24px; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: border-color .18s, box-shadow .18s;
}
.panel.dragover { border-color: var(--red); box-shadow: 0 0 0 3px rgba(192, 57, 43, .12); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-soft);
}
.panel-title { font-size: 14px; font-weight: 650; color: var(--navy); }
.panel-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

textarea.editor {
  width: 100%;
  min-height: 480px;
  flex: 1;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 20px 22px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  tab-size: 2;
}
textarea.editor::placeholder { color: var(--muted); }

.dropzone {
  margin: 0 16px 16px;
  padding: 18px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--red); background: var(--red-soft); color: var(--accent); }
.dropzone strong { color: var(--slate); font-weight: 600; }
.dropzone input[type="file"] { display: none; }

/* ---------- Preview (Markdown 渲染) ---------- */
.preview {
  padding: 26px 30px;
  overflow: auto;
  flex: 1;
  min-height: 480px;
  max-height: 680px;
  font-size: 16px;
  line-height: 1.78;
  color: var(--ink);
  word-wrap: break-word;
}
.preview > :first-child { margin-top: 0; }
.preview h1, .preview h2, .preview h3,
.preview h4, .preview h5, .preview h6 {
  color: var(--navy);
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 1.5em 0 .6em;
}
.preview h1 { font-size: 1.9em; }
.preview h2 { font-size: 1.5em; }
.preview h3 { font-size: 1.24em; }
.preview h4, .preview h5, .preview h6 { font-size: 1.05em; }
.preview p { margin: 0 0 1em; }
.preview ul, .preview ol { padding-left: 1.6em; margin: 0 0 1em; }
.preview li { margin: .25em 0; }
.preview blockquote {
  margin: 0 0 1em;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--red);
  color: var(--slate);
}
.preview code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 2px 6px;
}
.preview pre {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 16px 18px;
  overflow: auto;
  margin: 0 0 1em;
  line-height: 1.6;
}
.preview pre code { background: transparent; border: 0; padding: 0; font-size: 13.5px; }
.preview table { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: .94em; }
.preview th, .preview td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.preview th { background: var(--bg-soft); font-weight: 650; color: var(--navy); }
.preview img { max-width: 100%; height: auto; border-radius: 8px; }
.preview a { text-underline-offset: 3px; }
.preview hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  height: 100%;
  min-height: 320px;
  padding: 32px;
  color: var(--muted);
}
.empty-state svg { width: 44px; height: 44px; color: var(--line); margin-bottom: 14px; }
.empty-state p { margin: 0; font-size: 15px; }

/* 黄色警告条：公式/脚注不可保真 */
.warn-banner {
  background: #FFF4D6;
  border: 1px solid #F0CE7A;
  color: #7A5600;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 20px;
}
.warn-banner strong { display: block; margin-bottom: 2px; }
html[data-theme="dark"] .warn-banner { background: #3A2E10; border-color: #6B5410; color: #FFD98A; }

/* ---------- Action bar ---------- */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding: 18px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.action-bar .left, .action-bar .right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.action-hint { font-size: 14px; color: var(--muted); }

/* 选项开关 */
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--slate); cursor: pointer; user-select: none; }
.switch-row input { width: 17px; height: 17px; accent-color: var(--red); cursor: pointer; }

/* ---------- Limits (published limits) ---------- */
.limits {
  margin: 40px 0 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.limits summary {
  cursor: pointer;
  list-style: none;
  padding: 18px 22px;
  font-weight: 650;
  font-size: 16px;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
}
.limits summary::-webkit-details-marker { display: none; }
.limits summary::after { content: "+"; margin-left: auto; color: var(--accent); font-size: 20px; line-height: 1; }
.limits[open] summary::after { content: "−"; }
.limits-body { padding: 0 22px 20px; border-top: 1px solid var(--line-soft); }
.limits-body > p { font-size: 14.5px; color: var(--slate); margin: 16px 0 8px; }
.limits ul { margin: 0; padding-left: 20px; }
.limits li { font-size: 14.5px; color: var(--slate); line-height: 1.8; }

/* ---------- Diff 高亮（text-clean） ---------- */
.diff-ins { background: rgba(26, 143, 91, .14); color: #12623F; border-radius: 3px; padding: 0 1px; }
.diff-del { background: rgba(192, 57, 43, .13); color: var(--red); text-decoration: line-through; border-radius: 3px; padding: 0 1px; }
html[data-theme="dark"] .diff-ins { color: #7FE0B0; background: rgba(26, 143, 91, .25); }
html[data-theme="dark"] .diff-del { color: #FF8A7A; background: rgba(192, 57, 43, .28); }

.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-bottom: 18px; }
@media (max-width: 560px) { .check-grid { grid-template-columns: 1fr; } }

.info-list { font-size: 14px; color: var(--slate); line-height: 1.8; }
.info-list b { color: var(--navy); font-weight: 600; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  top: 84px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  background: var(--toast-bg);
  color: #fff;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in .22s ease-out;
}
.toast .badge { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.toast.ok .badge { background: #1A8F5B; }
.toast.error .badge { background: #C0392B; }
.toast.info .badge { background: #46536B; }
.toast.fade { opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .preview, textarea.editor { min-height: 380px; max-height: none; }
}
@media (max-width: 760px) {
  .tool-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .nav { gap: 16px; }
  .nav a { font-size: 14px; }
  .hero { padding: 64px 0 48px; }
  .section { padding: 56px 0; }
}
@media (max-width: 640px) {
  .brand-logo { height: 38px; }
  .header-inner { padding: 0 16px; }
  .nav a { display: none; }
  .action-bar { flex-direction: column; align-items: stretch; }
  .action-bar .right { justify-content: stretch; }
  .action-bar .right .btn { flex: 1; }
}

/* ---------- Print：浏览器打印生成 PDF ----------
   设计决策：中文字体与排版交给浏览器原生处理，质量最高、零额外依赖。
   打印时隐藏整套工具站 UI，只展开右侧预览正文。 */
@media print {
  @page { size: A4; margin: 18mm 16mm; }
  .site-header, .site-footer, .no-print, .tool-head,
  .editor-panel, .panel-head, .dropzone, .action-bar,
  .limits, .warn-banner, .toast-wrap { display: none !important; }
  body { background: #fff !important; color: #111 !important; font-size: 12pt; }
  .container { max-width: none !important; padding: 0 !important; }
  .tool-main { padding: 0 !important; }
  .workspace { display: block !important; }
  .preview-panel, .preview-panel .panel-body, .preview-panel .preview {
    display: block !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }
  .preview h1, .preview h2, .preview h3, .preview h4 { color: #111 !important; }
  .preview pre, .preview code { background: #F4F5F7 !important; border-color: #DDD !important; }
  .preview th { background: #F4F5F7 !important; }
  .preview a { color: #111 !important; text-decoration: none !important; }
}

/* ============================================================
   第二批追加：工具箱下拉 / 代码高亮 / 统计卡片 / 分段控件
   只复用现有变量，不改变第一批页面的既有表现。
   ============================================================ */

/* ---------- 工具箱下拉：纯 CSS hover + :focus-within，无 JS ---------- */
/* 把导航推到右侧，菜单右对齐时不会盖住左侧字标 */
.nav { margin-left: auto; }
.nav-dropdown { position: relative; }

.nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--slate);
  background: transparent;
  border: 0;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: color .18s, background .18s;
}
.nav-trigger:hover,
.nav-dropdown:hover .nav-trigger,
.nav-dropdown:focus-within .nav-trigger {
  color: var(--accent);
  background: var(--red-soft);
}
.nav-trigger:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.nav-trigger .caret { width: 14px; height: 14px; transition: transform .18s; }
.nav-dropdown:hover .caret,
.nav-dropdown:focus-within .caret { transform: rotate(180deg); }

.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 640px;
  max-width: calc(100vw - 32px);
  padding: 20px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 26px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  z-index: 60;
}
/* 透明桥：填补按钮与菜单之间的空隙，避免鼠标移入时菜单闪退 */
.nav-menu::before { content: ""; position: absolute; top: -10px; left: 0; right: 0; height: 10px; }
.nav-dropdown:hover .nav-menu,
.nav-dropdown:focus-within .nav-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.nav-group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 7px;
  padding-left: 10px;
}
.nav-group a {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--slate);
  text-decoration: none;
  transition: background .14s, color .14s;
}
.nav-group a:hover { background: var(--red-soft); color: var(--accent); }
.nav-group a.active { color: var(--accent); font-weight: 650; }
.nav-menu-foot { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.nav-menu-foot a { font-size: 13.5px; color: var(--muted); text-decoration: none; }
.nav-menu-foot a:hover { color: var(--accent); }
@media (max-width: 760px) {
  .nav-menu { grid-template-columns: 1fr; gap: 14px; width: 300px; padding: 16px; }
}
@media (max-width: 640px) {
  .nav-trigger { font-size: 14.5px; padding: 8px 10px; }
  .nav-menu { width: 280px; }
  /* 关键：覆盖基础样式里 .nav a{display:none}，保证窄屏菜单可点 */
  .nav-menu a { display: block; }
}

/* ---------- 代码视图 + JSON 语法高亮 ---------- */
.code-view {
  margin: 0;
  padding: 20px 22px;
  flex: 1;
  min-height: 480px;
  max-height: 680px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  white-space: pre;
  tab-size: 2;
}
.code-view.wrap { white-space: pre-wrap; word-break: break-word; }
.tok-key  { color: var(--accent); font-weight: 600; }
.tok-str  { color: #1A8F5B; }
.tok-num  { color: var(--warn); }
.tok-bool { color: var(--navy); font-weight: 600; }
.tok-null { color: var(--muted); font-style: italic; }
html[data-theme="dark"] .tok-str { color: #7FE0B0; }
html[data-theme="dark"] .tok-num { color: #E5B75E; }
html[data-theme="dark"] .tok-bool { color: #BCD0EA; }

.error-box {
  margin: 20px;
  padding: 16px 18px;
  border: 1px solid rgba(192, 57, 43, .35);
  background: var(--red-soft);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.error-box strong { color: var(--red); display: block; margin-bottom: 6px; font-size: 15px; }
.error-box code { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.error-snippet {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}
.error-snippet b { color: var(--red); }

/* ---------- 分段控件：方向 / 模式切换 ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.seg button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.seg button:hover { color: var(--accent); }
.seg button.on { background: var(--red); color: #fff; box-shadow: 0 2px 8px rgba(192, 57, 43, .22); }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .val {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.stat-card .lab { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

/* ---------- 差异对比视图 ---------- */
.diff-view {
  padding: 14px 0;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  overflow: auto;
  flex: 1;
  min-height: 380px;
  max-height: 640px;
}
.diff-line {
  display: flex;
  gap: 10px;
  min-height: 1.7em;
  padding: 0 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-line .sign { flex: none; width: 12px; color: var(--muted); user-select: none; }
.diff-line .txt { flex: 1; min-width: 0; }
.diff-line.del { background: rgba(192, 57, 43, .07); }
.diff-line.ins { background: rgba(26, 143, 91, .08); }
.diff-line.mod { background: rgba(201, 138, 6, .08); }
.diff-line.del .sign { color: var(--red); }
.diff-line.ins .sign { color: #1A8F5B; }
.diff-line.mod .sign { color: var(--warn); }
.diff-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--slate);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}
.diff-stat b { font-variant-numeric: tabular-nums; color: var(--navy); }
.diff-stat.ins b { color: #1A8F5B; }
.diff-stat.del b { color: var(--red); }

/* ---------- 表单小件 / 图片预览 ---------- */
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--slate);
  padding: 0 16px 14px;
}
.field-row input[type="number"], .field-row input[type="text"],
.field-row select, .field-row input[type="color"] {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}
.field-row input[type="number"] { width: 92px; }
.field-row input[type="text"] { min-width: 150px; flex: 1; }
.field-row input[type="color"] { width: 40px; height: 34px; padding: 3px; cursor: pointer; }
.field-row input[type="range"] { accent-color: var(--red); width: 140px; }
.img-wrap {
  flex: 1;
  min-height: 380px;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
}
.img-wrap img { max-width: 100%; max-height: 440px; object-fit: contain; border-radius: 8px; }
.hidden { display: none !important; }
.note { font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 8px; }
.size-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.size-table td { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.size-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--navy); font-weight: 600; }
.size-table tr:last-child td { border-bottom: 0; }

/* ---------- 首页分组标题 / 页脚双列链接 ---------- */
.tool-group + .tool-group { margin-top: 48px; }
.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 650;
  margin: 0 0 18px;
}
.group-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--red); }
.group-title span { font-size: 13px; font-weight: 500; color: var(--muted); }
.footer-links { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
@media (max-width: 480px) { .footer-links { grid-template-columns: 1fr; } }

/* ---------- 时间戳双栏结果 ---------- */
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kv-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: var(--bg); }
.kv-card h4 { margin: 0 0 10px; font-size: 14px; font-weight: 650; color: var(--navy); }
.kv-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.kv-row:first-of-type { border-top: 0; }
.kv-row span { color: var(--muted); flex: none; }
.kv-row b { color: var(--ink); font-weight: 600; font-family: var(--mono); word-break: break-all; text-align: right; }
@media (max-width: 760px) { .kv-grid { grid-template-columns: 1fr; } }
