:root {
  color-scheme: light dark;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --text: #14202b;
  --muted: #5e6b76;
  --line: #d8e0e6;
  --accent: #16324f;
  --accent-2: #245c83;
  --accent-soft: #e4eef6;
  --good: #23683b;
  --warn: #8a5200;
  --danger: #9a2c2c;
  --shadow: 0 8px 28px rgba(24, 43, 60, 0.08);
  --radius: 16px;
  --nav-h: 72px;
}

:root[data-theme="dark"] {
  --bg: #0f151a;
  --surface: #182129;
  --surface-2: #202c35;
  --text: #edf3f7;
  --muted: #aab8c2;
  --line: #33424d;
  --accent: #8dc1e6;
  --accent-2: #b8d9ee;
  --accent-soft: #1d3444;
  --good: #88c89b;
  --warn: #e1b46e;
  --danger: #f1a2a2;
  --shadow: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button, input, select { min-height: 44px; }
button, .button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent-2); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-2) 45%, transparent);
  outline-offset: 2px;
}
button.primary, .button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700; }
:root[data-theme="dark"] button.primary, :root[data-theme="dark"] .button.primary { color: #081117; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }

.skip-link { position: fixed; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 10px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.app-shell { max-width: 760px; margin: 0 auto; min-height: 100dvh; background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--bg); font-weight: 800; letter-spacing: -0.04em; }
:root[data-theme="dark"] .brand-mark { color: #081117; }
.brand strong { display: block; line-height: 1.05; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.status-pill { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; white-space: nowrap; }
.status-pill.offline { color: var(--warn); }
.main { padding: 18px 14px calc(var(--nav-h) + 56px + env(safe-area-inset-bottom)); }

.bottom-nav {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 0;
  width: min(760px, 100%); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bottom-nav a { display: grid; place-content: center; justify-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; min-width: 0; }
.bottom-nav a span:first-child { font-size: 22px; line-height: 1; }
.bottom-nav a.active { color: var(--accent-2); font-weight: 700; }

.hero { padding: 8px 0 12px; }
.eyebrow { margin: 0 0 6px; color: var(--accent-2); font-weight: 800; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.2; margin-top: 0; }
h1 { font-size: clamp(26px, 7vw, 38px); margin-bottom: 10px; letter-spacing: -0.025em; }
h2 { font-size: 20px; margin-bottom: 10px; }
h3 { font-size: 16px; margin-bottom: 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.micro { font-size: 12px; color: var(--muted); }

.search-form { display: flex; gap: 8px; margin: 14px 0; }
.search-form input { flex: 1; width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: 10px 13px; background: var(--surface); color: var(--text); }
.search-form button { flex: 0 0 auto; }

.mission-row, .chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.mission-row::-webkit-scrollbar, .chip-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 10px; font-size: 12px; text-decoration: none; }
.chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
:root[data-theme="dark"] .chip.active { color: #081117; }

.card, .list-item, details, .formula-panel, .notice, .compare-card, .source-card {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card { padding: 15px; }
.grid { display: grid; gap: 12px; }
.category-grid { grid-template-columns: 1fr 1fr; }
.category-card { text-decoration: none; min-height: 124px; display: flex; flex-direction: column; justify-content: space-between; }
.category-card strong { font-size: 15px; }
.category-card small { color: var(--muted); }
.stat { font-size: 26px; font-weight: 800; color: var(--accent-2); }
.section { margin: 22px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head a { font-size: 12px; color: var(--accent-2); }

.list { display: grid; gap: 10px; }
.list-item { padding: 13px; text-decoration: none; display: block; }
.list-item-top { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.list-item h3 { margin-bottom: 4px; }
.list-item p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 0; }
.badge { font-size: 10px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; color: var(--muted); }
.badge.tier-a { color: var(--good); }
.badge.formula { color: var(--accent-2); }

.detail-title .zh { display: block; margin-top: 4px; font-size: 0.62em; color: var(--muted); font-weight: 600; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.action-row button { flex: 1 1 130px; }
.notice { padding: 13px; }
.notice.caution { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.notice strong { display: block; margin-bottom: 5px; }

.formula-panel { overflow: hidden; }
.diagram { min-height: 180px; display: grid; place-items: center; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.diagram svg { width: 100%; max-width: 480px; height: 180px; color: var(--accent-2); }
.formula-box { padding: 16px; }
.formula { display: block; padding: 12px; border-radius: 12px; background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(18px, 5vw, 24px); text-align: center; overflow-wrap: anywhere; }
.variable-list { display: grid; gap: 8px; margin-top: 12px; }
.variable { display: grid; grid-template-columns: minmax(50px, 74px) 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.variable code { font-weight: 800; color: var(--accent-2); }
.example { margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.example ol { margin: 8px 0 0 20px; padding: 0; }
.result { font-weight: 800; color: var(--good); }

.calculator { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calc-field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.calc-field input { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px; }
.calc-output { margin-top: 10px; padding: 10px; background: var(--accent-soft); border-radius: 10px; font-weight: 800; }

details { padding: 0; margin: 10px 0; overflow: hidden; }
summary { cursor: pointer; list-style: none; padding: 13px 15px; font-weight: 750; }
summary::-webkit-details-marker { display:none; }
summary::after { content: "+"; float: right; color: var(--muted); }
details[open] summary::after { content: "−"; }
.details-body { padding: 0 15px 14px; border-top: 1px solid var(--line); }
.details-body ul { padding-left: 20px; margin-bottom: 0; }
.details-body li { margin: 7px 0; }
.key-data { display: grid; gap: 8px; }
.key-row { display: grid; grid-template-columns: minmax(92px, 130px) 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.key-row:last-child { border-bottom: 0; }
.key-row strong { color: var(--muted); font-size: 12px; }

.note-box textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface); color: var(--text); }
.source-link { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.source-link:last-child { border-bottom: 0; }
.source-link strong { display: block; font-size: 13px; }
.source-link small { color: var(--muted); }

.compare-tray {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  width: min(732px, calc(100% - 28px)); border: 1px solid var(--line); background: var(--surface); box-shadow: 0 12px 40px rgba(0,0,0,.18); border-radius: 14px; padding: 10px;
}
.compare-tray-inner { display:flex; gap:8px; align-items:center; }
.compare-tray .names { flex:1; min-width:0; font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.compare-grid { display: grid; gap: 12px; }
.compare-card { padding: 14px; }
.compare-card .compare-field { padding: 10px 0; border-top: 1px solid var(--line); }
.compare-card .compare-field strong { display:block; color: var(--muted); font-size:11px; margin-bottom:3px; }

.more-actions { display: grid; gap: 10px; }
.file-input { position: relative; overflow: hidden; display: inline-grid; place-items: center; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.file-input input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.setting-row { display:flex; gap:10px; align-items:center; justify-content:space-between; padding:10px 0; border-top:1px solid var(--line); }
.setting-row select { border:1px solid var(--line); background:var(--surface); color:var(--text); border-radius:10px; padding:6px 8px; }

.toast { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 90px); max-width: calc(100% - 28px); background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow); }
.empty { text-align: center; padding: 30px 12px; color: var(--muted); }
hr { border:0; border-top:1px solid var(--line); margin: 20px 0; }

@media (max-width: 390px) {
  .category-grid { grid-template-columns: 1fr; }
  .brand small { max-width: 150px; }
  .calc-grid { grid-template-columns: 1fr; }
}
@media (min-width: 650px) {
  .main { padding-left: 24px; padding-right: 24px; }
  .category-grid { grid-template-columns: repeat(4, 1fr); }
  .compare-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }

/* V1.1 practical quick-reference layer */
.hero-lead { font-size: 16px; line-height: 1.65; margin: 8px 0 16px; max-width: 620px; }
.quick-first { margin-top: 14px; }
.quick-entry-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.quick-entry { min-height:82px; display:flex; align-items:center; gap:11px; border:1px solid var(--line); border-radius:14px; background:var(--surface); padding:12px; text-decoration:none; box-shadow:0 3px 12px rgba(0,0,0,.035); }
.quick-entry-icon { flex:0 0 34px; width:34px; height:34px; display:grid; place-items:center; border-radius:10px; background:var(--accent-soft); color:var(--accent-2); font-size:20px; font-weight:800; }
.quick-entry strong { display:block; font-size:15px; color:var(--text); }
.quick-entry small { display:block; color:var(--muted); font-size:11px; line-height:1.35; margin-top:3px; }
.scenario-row { display:flex; gap:8px; flex-wrap:wrap; }
.scenario-chip { display:inline-flex; min-height:38px; align-items:center; border:1px solid var(--line); border-radius:999px; padding:7px 11px; text-decoration:none; background:var(--surface); font-size:13px; }
.secondary-browse { padding-top:4px; }
.filter-block { margin:14px 0; }
.filter-label { display:block; font-size:12px; color:var(--muted); margin-bottom:7px; }
.back-link { display:inline-block; margin:0 0 12px; font-size:13px; text-decoration:none; }
.detail-summary { font-size:15px; line-height:1.65; }
.quick-sheet { border:1px solid var(--line); border-radius:16px; background:var(--surface); overflow:hidden; padding:0; }
.quick-sheet-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:14px 15px; background:var(--accent-soft); border-bottom:1px solid var(--line); }
.quick-sheet-head h2 { margin:0; font-size:17px; }
.quick-hint { font-size:11px; color:var(--muted); white-space:nowrap; }
.quick-section { padding:14px 15px; border-bottom:1px solid var(--line); }
.quick-section:last-child { border-bottom:0; }
.quick-section h3 { margin:0 0 10px; font-size:15px; }
.quick-table-wrap { width:100%; max-width:100%; overflow-x:auto; overscroll-behavior-inline:contain; border:1px solid var(--line); border-radius:11px; }
.quick-table { border-collapse:collapse; width:100%; min-width:420px; font-size:12px; background:var(--surface); }
.quick-table th,.quick-table td { padding:9px 10px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; white-space:nowrap; }
.quick-table thead th { background:var(--surface-2); color:var(--muted); font-size:11px; position:sticky; top:0; }
.quick-table tbody th { font-weight:700; background:color-mix(in srgb,var(--surface-2) 58%,var(--surface)); }
.quick-table tr:last-child th,.quick-table tr:last-child td { border-bottom:0; }
.row-note { display:block; margin-top:3px; color:var(--muted); }
.explanation { margin-top:18px; }
.list-item h3 { line-height:1.35; }
.list-item p { line-height:1.48; }

@media (max-width:390px){
  .quick-entry-grid { grid-template-columns:1fr 1fr; gap:8px; }
  .quick-entry { padding:10px; gap:8px; min-height:76px; }
  .quick-entry-icon { width:30px; height:30px; flex-basis:30px; }
  .quick-table { min-width:390px; }
}
@media (min-width:650px){
  .quick-entry-grid { grid-template-columns:repeat(4,1fr); }
}
html, body { max-width: 100%; overflow-x: hidden; }

/* V1.1 Chinese-first scan hierarchy; exact English（中文） identity is retained on detail. */
.english-name { display:block; margin-top:2px; color:var(--muted); font-size:.78rem; font-weight:500; }
.term-identity { margin:.15rem 0 .75rem; color:var(--muted); font-size:.88rem; }

/* V1.2: unmistakable Chinese-first practical handbook layout */
.version-line { display:flex; align-items:center; gap:8px; margin:0 0 9px; }
.version-badge { display:inline-flex; align-items:center; min-height:24px; padding:3px 8px; border-radius:999px; background:var(--accent); color:var(--bg); font-size:11px; font-weight:800; letter-spacing:.04em; }
:root[data-theme="dark"] .version-badge { color:#081117; }
.v12-hero { padding-top:4px; }
.hero-shortcuts { display:flex; flex-wrap:wrap; gap:7px; margin-top:4px; }
.strong-chip { font-weight:750; border-color:color-mix(in srgb,var(--accent-2) 38%,var(--line)); }
.direct-need { margin-top:15px; padding:14px; border-radius:18px; background:var(--surface); border:1px solid var(--line); box-shadow:var(--shadow); }
.direct-need h2 { font-size:18px; margin-bottom:10px; }
.direct-grid { display:grid; grid-template-columns:1fr 1fr; gap:9px; }
.work-tile { display:flex; flex-direction:column; justify-content:center; min-height:70px; padding:10px 11px; border:1px solid var(--line); border-radius:13px; background:var(--surface-2); text-decoration:none; }
.work-tile strong { font-size:14px; line-height:1.32; }
.work-tile small { display:block; margin-top:3px; color:var(--muted); font-size:11px; line-height:1.3; }
.quick-directory { display:grid; gap:10px; }
.directory-group { margin:0; box-shadow:none; background:var(--surface); }
.directory-summary { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.directory-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:0 12px 12px; }
.directory-grid .work-tile { min-height:58px; background:var(--surface); }
.jump-to-quick { margin:14px 0; padding:12px; border:1px solid color-mix(in srgb,var(--accent-2) 38%,var(--line)); border-radius:14px; background:var(--accent-soft); }
.jump-title { display:block; font-size:13px; margin-bottom:8px; }
.jump-grid { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.jump-grid .work-tile { min-height:58px; background:var(--surface); }
.result-priority { padding:12px; border-radius:16px; background:color-mix(in srgb,var(--accent-soft) 60%,transparent); }
.secondary-results { opacity:.92; }
.mini-tool { padding:13px 15px; border-bottom:1px solid var(--line); background:color-mix(in srgb,var(--accent-soft) 55%,var(--surface)); }
.mini-tool h3 { margin-bottom:8px; }
.mini-tool-row { display:flex; gap:8px; }
.mini-tool-row input { flex:1; min-width:0; border:1px solid var(--line); border-radius:11px; background:var(--surface); color:var(--text); padding:9px 10px; }
.mini-tool-output { margin-top:8px; padding:9px 10px; border-radius:10px; background:var(--surface); font-weight:750; font-size:13px; overflow-wrap:anywhere; }
.quick-table tbody th { position:sticky; left:0; z-index:1; }
.term-identity { font-size:.8rem; }
@media (max-width:390px){
  .direct-grid,.directory-grid,.jump-grid { grid-template-columns:1fr; }
  .direct-grid { gap:7px; }
  .work-tile { min-height:58px; }
}
