:root {
  --bg: #f4f7f5; --bg2: #ffffff; --card: #ffffff; --line: #dfe7e3; --text: #14201c; --muted: #54655e; --accent: #0c8a6a; --accent-ink: #ffffff; --accent-soft: #dff3ec;
  --callout: #eaf6f1; --refer: #fdecec; --refer-ink: #8a1c1c; --watch: #fff6e0; --watch-ink: #7a5200;
  --ev-strong: #0c7a5a; --ev-moderate: #1d6fb8; --ev-limited: #a86400; --ev-mixed: #8a4fb0; --ev-consensus: #4a5a66;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 14px rgba(16, 40, 30, .05);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0c1411; --bg2: #121c18; --card: #15201c; --line: #25352f; --text: #e8f1ed; --muted: #95a8a0; --accent: #3fcf9f; --accent-ink: #052018; --accent-soft: #123a2e;
  --callout: #12332a; --refer: #3a1b1b; --refer-ink: #ffb3b3; --watch: #3a2f12; --watch-ink: #ffd88a;
  --ev-strong: #3fcf9f; --ev-moderate: #6db4f2; --ev-limited: #f0b24d; --ev-mixed: #c79bea; --ev-consensus: #a9bac6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* header */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg2); border-bottom: 1px solid var(--line); padding: calc(var(--safe-t) + 10px) 0 10px; }
.topbar .wrap { display: flex; flex-direction: column; gap: 8px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; stroke: var(--accent-ink); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; stroke: var(--text); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search { position: relative; }
.search input { width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); padding: 0 44px 0 42px; font-size: 16px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg.mag { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; }
.search .clear { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border: 0; background: transparent; font-size: 22px; color: var(--muted); }

main { padding: 14px 0 calc(var(--safe-b) + 96px); min-height: 70vh; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 6px 0 8px; }
h2 { font-size: 18px; margin: 0 0 8px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 4px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--muted); margin: 6px 0 0; }
.sub, .topic-sub { color: var(--muted); margin: 0 0 12px; font-size: 16px; }
.small { font-size: 13px; color: var(--muted); }

/* cards */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 15px; margin-bottom: 10px; box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
a.card:active { transform: scale(.995); }
.card h3 { margin: 0 0 4px; font-size: 16.5px; }
.card p { margin: 0 0 8px; color: var(--muted); font-size: 14.5px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid .card { margin: 0; }
@media (min-width: 560px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.sec-card { display: flex; gap: 12px; align-items: flex-start; }
.sec-ico { flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; }
.sec-ico svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sec-card .count { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hero { padding: 6px 0 12px; }
.hero p { color: var(--muted); margin: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; }
.section-head h2 { margin: 0; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.chip.ev-strong { color: var(--ev-strong); } .chip.ev-moderate { color: var(--ev-moderate); } .chip.ev-limited { color: var(--ev-limited); } .chip.ev-mixed { color: var(--ev-mixed); } .chip.ev-consensus { color: var(--ev-consensus); }
.chip.vd-backed { color: var(--ev-strong); } .chip.vd-situational { color: var(--ev-moderate); } .chip.vd-weak { color: var(--ev-limited); } .chip.vd-avoid { color: var(--refer-ink); } .chip.vd-rx { color: var(--refer-ink); }
.chip.plain { color: var(--muted); border-color: var(--line); font-weight: 600; }

/* topic */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 14px; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 15px; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled { opacity: .5; }
.callout { border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.callout h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 4px; }
.callout p { margin: 0; }
.callout.bottom { background: var(--callout); border-left: 4px solid var(--accent); }
.callout.refer { background: var(--refer); color: var(--refer-ink); border-left: 4px solid var(--refer-ink); }
.callout.watch { background: var(--watch); color: var(--watch-ink); border-left: 4px solid var(--watch-ink); }
.block { margin: 16px 0; }
.pts { margin: 0; padding-left: 20px; } .pts li { margin: 0 0 7px; }
.pts.tick { list-style: none; padding-left: 0; }
.pts.tick li { position: relative; padding-left: 26px; }
.pts.tick li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 12px; height: 7px; border-left: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); transform: rotate(-45deg); }
.srcs { padding-left: 20px; margin: 0 0 6px; }
.srcs li { margin-bottom: 8px; }
.srcs a { font-weight: 600; word-break: break-word; }
.src-meta { display: block; font-size: 12.5px; color: var(--muted); }
.rels { display: flex; flex-wrap: wrap; gap: 8px; }
.rel { display: inline-block; padding: 8px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
.supp h3 { margin-top: 10px; }
.disclaimer { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin: 18px 0 0; }
.disclaimer.small { border: 0; padding-top: 6px; margin-top: 0; }
.crumbs { font-size: 14px; margin: 2px 0 0; } .crumbs a { text-decoration: none; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 84px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 50; box-shadow: var(--shadow); }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bg2); border-top: 1px solid var(--line); display: flex; padding-bottom: var(--safe-b); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabbar a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--accent); }

/* forms + tools */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 0; }
.field { margin: 0 0 12px; }
.field label, .field .lbl { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field select, .field textarea { width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 8px 12px; font-size: 16px; }
.field textarea { min-height: 84px; resize: vertical; }
.field .row { display: flex; gap: 8px; } .field .row > * { flex: 1; min-width: 0; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; height: 42px; border: 0; background: var(--bg); font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.checks label { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 0 0 6px; }
.checks input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.result { background: var(--callout); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 12px 0; }
.big-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.big-nums div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.big-nums b { display: block; font-size: 24px; letter-spacing: -.02em; }
.big-nums span { font-size: 12.5px; color: var(--muted); }
.warn { background: var(--watch); color: var(--watch-ink); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14.5px; }
.err { background: var(--refer); color: var(--refer-ink); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14.5px; }
.sheet h2.q-sec { font-size: 16px; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--accent); }
.print-only { display: none; }

/* handout + static pages */
.page-top { background: var(--bg2); border-bottom: 1px solid var(--line); padding: calc(var(--safe-t) + 10px) 0; }
.page-top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.handout { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 14px 0; }
.h-head h1 { font-size: 24px; margin: 2px 0 4px; }
.h-sub { margin: 0 0 6px; color: var(--muted); }
.h-cols { display: block; }
.h-cols section { margin: 12px 0; }
.h-src ul { margin: 0; padding-left: 18px; font-size: 13px; } .h-src li { margin-bottom: 5px; } .url { color: var(--muted); word-break: break-all; font-size: 11.5px; }
.prepared { margin: 16px 0 6px; font-size: 13px; }

@media print {
  @page { size: A4; margin: 10mm 12mm; }
  html, body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  :root, html[data-theme="dark"] { --bg: #fff; --bg2: #fff; --card: #fff; --line: #bbb; --text: #000; --muted: #333; --accent: #0a6e54; --accent-soft: #e7f3ee; --callout: #eef7f3; --refer: #fdeeee; --refer-ink: #7a1414; --watch: #fff7e3; --watch-ink: #5e4100; --ev-strong: #0a6e54; --ev-moderate: #174f86; --ev-limited: #7a4800; --ev-mixed: #5e3380; --ev-consensus: #333; --shadow: none; }
  .topbar, .tabbar, .actions, .toast, .page-top, .no-print, .rels, .btn, .search { display: none !important; }
  main { padding: 0; min-height: 0; }
  .wrap { max-width: none; padding: 0; }
  .callout, .card, .block, .handout, .form-card, .result { break-inside: avoid; box-shadow: none; }
  .handout { border: 0; padding: 0; margin: 0; }
  .h-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .handout h1 { font-size: 20pt; } .handout h2 { font-size: 11pt; }
  a { color: #000; text-decoration: none; }
  .srcs a::after { content: " (" attr(href) ")"; font-weight: 400; font-size: 8pt; word-break: break-all; }
  .field input, .field textarea, .field select { border: 0; border-bottom: 1px solid #888; border-radius: 0; background: transparent; padding: 2px 0; min-height: 0; }
  .field textarea { min-height: 40px; }
  .print-only { display: block; }
}

.search input::-webkit-search-cancel-button, .search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }

@media print {
  .handout { font-size: 9.5pt; line-height: 1.36; }
  .handout p, .handout li { font-size: 9.5pt; line-height: 1.36; margin-top: 0; margin-bottom: 3px; }
  .handout h1 { font-size: 18pt; margin: 0 0 2px; }
  .handout h2 { font-size: 10.5pt; margin: 8px 0 3px; }
  .handout .h-sub { font-size: 10pt; margin: 2px 0 4px; }
  .handout .callout { padding: 6px 10px; margin: 6px 0; }
  .handout .h-cols { gap: 12px; }
  .handout .h-src li { font-size: 8pt; line-height: 1.25; margin-bottom: 2px; }
  .handout .h-src .url { font-size: 7pt; }
  .handout .h-foot p { font-size: 7.5pt; line-height: 1.25; margin: 3px 0; }
  .handout .prepared { margin-top: 6px; }
}
