/* Global Ledger app - work package C.
   A warm editorial shell, deliberately different from the prototype CSS. */

:root {
  --bg: #f6f3ec;
  --bg-deep: #efeae0;
  --surface: #fffdf8;
  --surface-2: #f0ebe1;
  --ink: #16211f;
  --ink-2: #33433f;
  --muted: #55665f;
  --line: #ded8cb;
  --line-strong: #c9c1b1;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d9efe9;
  --accent-deep: #0b5c56;
  --warm: #a64b0a;
  --warm-soft: #f6e3cc;
  --danger: #9f2f2f;
  --danger-soft: #f6dede;
  --ok: #1d6a45;
  --ok-soft: #dcefe3;
  --shadow: 0 1px 0 rgba(22, 33, 31, .04), 0 18px 40px -28px rgba(22, 33, 31, .35);
  --shadow-soft: 0 1px 0 rgba(22, 33, 31, .03), 0 8px 24px -20px rgba(22, 33, 31, .3);
  --radius: 18px;
  --radius-sm: 11px;
  --max: 1180px;
  --header: 74px;
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0e1715;
  --bg-deep: #0a1210;
  --surface: #15211e;
  --surface-2: #1c2b27;
  --ink: #e9f0ec;
  --ink-2: #cbdad4;
  --muted: #9fb3ac;
  --line: #283a34;
  --line-strong: #38514a;
  --accent: #5eead4;
  --accent-ink: #062a26;
  --accent-soft: #173d37;
  --accent-deep: #8bf3e2;
  --warm: #f0a35e;
  --warm-soft: #3a2a1c;
  --danger: #f19a9a;
  --danger-soft: #3a1f1f;
  --ok: #8fe0b3;
  --ok-soft: #173528;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 18px 44px -26px rgba(0, 0, 0, .8);
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, .03), 0 8px 24px -18px rgba(0, 0, 0, .7);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }
svg { display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-deep); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
li { list-style: none; }
[hidden] { display: none !important; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { width: min(calc(100% - 40px), var(--max)); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 16px; top: -80px; z-index: 1000;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 16px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: var(--header);
  display: flex; align-items: center; gap: 26px;
}
.brand {
  display: inline-flex; align-items: center; gap: 11px;
  color: var(--ink); text-decoration: none; flex: 0 0 auto;
}
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 13px; letter-spacing: .04em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: -.02em; }
.brand-text small { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.primary-nav { display: flex; align-items: center; gap: 4px; margin-inline-start: 12px; }
.primary-nav a {
  color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 600;
  padding: 9px 12px; border-radius: 9px; position: relative;
}
.primary-nav a:hover { background: var(--surface-2); color: var(--ink); }
.primary-nav a[aria-current="page"] { color: var(--accent-deep); }
.primary-nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.header-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 9px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
.menu-btn { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-weight: 650; font-size: 14px; text-decoration: none;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); color: var(--ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ai { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-ai:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.mobile-nav {
  border-top: 1px solid var(--line); padding: 14px 0 18px;
  background: var(--bg);
}
.mobile-nav nav { display: grid; gap: 4px; margin-bottom: 12px; }
.mobile-nav a {
  display: block; padding: 11px 12px; border-radius: 9px;
  color: var(--ink); text-decoration: none; font-weight: 650;
}
.mobile-nav a:hover { background: var(--surface-2); }

/* ---------- generic ---------- */
.kicker {
  font-size: 10.5px; font-weight: 800; letter-spacing: .17em;
  text-transform: uppercase; color: var(--accent-deep);
}
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 26px; height: 1px; background: var(--accent); }
.lead { color: var(--ink-2); font-size: clamp(1.02rem, 1.4vw, 1.18rem); line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.serif { font-family: var(--font-serif); }
.display {
  font-family: var(--font-serif); font-weight: 600;
  font-size: clamp(2.5rem, 5.4vw, 4.8rem); line-height: 1.02;
  letter-spacing: -.035em; text-wrap: balance;
}
.display em { font-style: italic; color: var(--accent-deep); }
.section-title {
  font-family: var(--font-serif); font-weight: 600;
  font-size: clamp(1.45rem, 2.3vw, 2.05rem); line-height: 1.12;
  letter-spacing: -.02em;
}
.section-lead { color: var(--muted); margin-top: 8px; max-width: 62ch; }
.stack-sm > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 18px; }
.stack-lg > * + * { margin-top: 34px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-soft);
}
.card-soft { background: var(--surface-2); border: 1px solid transparent; box-shadow: none; }
.card h3 { font-size: 15px; letter-spacing: -.01em; }
.card p { color: var(--ink-2); }
.notice {
  border: 1px solid var(--line); background: var(--surface);
  border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
  padding: 16px 18px; color: var(--ink-2);
}
.notice-warm { border-left-color: var(--warm); background: var(--warm-soft); }
.notice-danger { border-left-color: var(--danger); background: var(--danger-soft); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  font-size: 11.5px; font-weight: 750; letter-spacing: .02em; white-space: nowrap;
}
.badge-accent { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); color: var(--accent-deep); }
.badge-warm { border-color: color-mix(in srgb, var(--warm) 35%, var(--line)); background: var(--warm-soft); color: var(--warm); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 750; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.status[data-status="ok"], .status[data-status="ready"] { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, var(--line)); }
.status[data-status="degraded"], .status[data-status="draft"] { color: var(--warm); background: var(--warm-soft); border-color: color-mix(in srgb, var(--warm) 25%, var(--line)); }
.status[data-status="failed"], .status[data-status="blocked"] { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, var(--line)); }
.status[data-status="not_built"], .status[data-status="building"] { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.locator {
  display: inline-flex; align-items: center; padding: 1px 6px; margin: 1px 2px 1px 0;
  border-radius: 5px; background: var(--accent-soft); color: var(--accent-deep);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.rule { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--muted); font-size: 13px; }
.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; color: var(--muted);
}
.view-enter { animation: view-in .26s ease both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.error-box {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-sm); padding: 16px 18px;
}
.error-box h3 { color: var(--danger); margin-bottom: 6px; }
.error-box p { color: var(--ink-2); }
.success-box { border: 1px solid color-mix(in srgb, var(--ok) 30%, var(--line)); background: var(--ok-soft); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--ok); }
.loading { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 7px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--surface) 65%, transparent) 50%, transparent 80%);
  animation: shimmer 1.5s infinite;
}
.skeleton-line { height: 11px; margin: 8px 0; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-35 { width: 35%; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- home ---------- */
.home-hero { padding: clamp(38px, 6vw, 82px) 0 34px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(300px, .88fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.hero-copy .display { margin: 14px 0 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-footnote { margin-top: 18px; color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-art {
  position: relative; border: 1px solid var(--line); border-radius: 22px;
  background:
    radial-gradient(120% 100% at 10% 0%, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 60%),
    var(--surface);
  padding: 22px; box-shadow: var(--shadow); overflow: hidden;
}
.hero-art::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px; opacity: .22;
}
.art-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.art-term { position: relative; margin: 18px 0 16px; }
.art-term strong { display: block; font-family: var(--font-serif); font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.05; letter-spacing: -.03em; }
.art-term span { color: var(--muted); font-size: 12.5px; }
.art-grid { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.art-node {
  min-height: 46px; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 6px; border-radius: 9px;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; color: var(--ink-2);
}
.art-node.is-core { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.art-foot { position: relative; margin-top: 14px; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; }

.home-section { padding: clamp(34px, 5vw, 64px) 0; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head .section-lead { margin-top: 6px; }
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.method-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-height: 190px; }
.method-card .n { font-family: var(--font-serif); font-size: 32px; line-height: 1; color: var(--accent); }
.method-card .kicker { margin: 16px 0 6px; }
.method-card h3 { font-size: 15px; margin-bottom: 7px; }
.method-card p { color: var(--muted); font-size: 13.5px; }
.method-card::after { content: ""; position: absolute; top: 24px; right: -9px; width: 8px; height: 1px; background: var(--line-strong); }
.method-card:last-child::after { display: none; }

.route-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.route-card { display: flex; flex-direction: column; gap: 10px; padding: 26px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.route-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.route-card .arrow { margin-top: auto; color: var(--accent); font-weight: 800; }
.route-card h3 { font-family: var(--font-serif); font-size: 26px; letter-spacing: -.02em; }
.route-card p { color: var(--muted); font-size: 14px; }
.guided-card { grid-column: 1 / -1; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.guided-card h3 { color: var(--bg); }
.guided-card p { color: color-mix(in srgb, var(--bg) 72%, transparent); }
.guided-card .kicker { color: var(--accent); }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.starter {
  border: 1px solid color-mix(in srgb, var(--bg) 24%, transparent); background: transparent;
  color: var(--bg); border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 650;
}
.starter:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.term-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: thin; }
.term-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); text-decoration: none; font-size: 12.5px; font-weight: 650;
}
.term-pill:hover { border-color: var(--accent); color: var(--accent-deep); }
.term-pill small { color: var(--muted); font-weight: 600; }

/* ---------- index pages ---------- */
.page-head { padding: clamp(34px, 5vw, 58px) 0 22px; }
.page-head .display { font-size: clamp(2rem, 4.2vw, 3.6rem); margin: 10px 0 12px; }
.index-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0 8px; border-bottom: 1px solid var(--line); }
.search-box { position: relative; flex: 1 1 320px; max-width: 460px; }
.search-box svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.search-box input {
  width: 100%; min-height: 44px; padding: 10px 14px 10px 40px;
  border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface);
}
.search-box input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 7px 12px; font-size: 12px; font-weight: 700;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.filter-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.result-count { color: var(--muted); font-size: 12.5px; margin-inline-start: auto; }
.term-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 22px 0 40px; }
.term-card {
  display: flex; flex-direction: column; gap: 10px; min-height: 190px;
  padding: 19px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.term-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.term-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.term-card h3 { font-family: var(--font-serif); font-size: 22px; line-height: 1.12; letter-spacing: -.02em; }
.term-card p { color: var(--muted); font-size: 13.5px; }
.term-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; }
.term-card .arrow { color: var(--accent); font-weight: 900; }
.category-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 800; }

/* ---------- detail ---------- */
.detail-head { padding: clamp(26px, 4vw, 46px) 0 22px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-deep); }
.breadcrumb span { color: var(--line-strong); }
.breadcrumb span[aria-current="page"] { color: var(--ink-2); }
.detail-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.detail-title h1 { font-family: var(--font-serif); font-size: clamp(2.1rem, 4vw, 3.4rem); line-height: 1.02; letter-spacing: -.035em; margin: 8px 0 10px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.detail-desc { max-width: 68ch; color: var(--ink-2); margin-top: 12px; }
.detail-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: clamp(24px, 4vw, 52px); padding-bottom: 46px; align-items: start; }
.toc { position: sticky; top: calc(var(--header) + 20px); border-left: 1px solid var(--line); padding-left: 18px; }
.toc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toc h2 { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.toc ol { display: grid; gap: 2px; counter-reset: toc; }
.toc a {
  display: grid; grid-template-columns: 22px 1fr; gap: 7px; align-items: baseline;
  padding: 7px 8px; border-radius: 7px; color: var(--muted); text-decoration: none;
  font-size: 12.5px; line-height: 1.35;
}
.toc a .num { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }
.toc a[aria-current="true"] .num { color: var(--accent-deep); }
.toc-mobile-btn { display: none; }
.sections { min-width: 0; display: grid; gap: 18px; }
.section-card { scroll-margin-top: calc(var(--header) + 18px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow-soft); }
.section-head { display: flex; align-items: start; gap: 14px; margin-bottom: 18px; }
.section-no { flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2); color: var(--accent-deep); font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
.section-head-copy { min-width: 0; flex: 1; }
.section-head-copy h2 { font-family: var(--font-serif); font-size: clamp(1.35rem, 2.2vw, 1.75rem); line-height: 1.1; letter-spacing: -.02em; }
.section-head-copy p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.section-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.section-body > * + * { margin-top: 16px; }
.section-body h3 { font-size: 14px; letter-spacing: -.01em; margin-bottom: 7px; }
.section-body h4 { font-size: 12.5px; letter-spacing: .02em; margin-bottom: 5px; }
.section-body p { color: var(--ink-2); }
.section-body ul.bullets { display: grid; gap: 7px; }
.section-body ul.bullets li { position: relative; padding-left: 17px; color: var(--ink-2); font-size: 14px; }
.section-body ul.bullets li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.definition { font-family: var(--font-serif); font-size: clamp(1.2rem, 2vw, 1.5rem); line-height: 1.35; letter-spacing: -.01em; }
.scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.scope-list { display: grid; gap: 12px; }
.scope-item { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.scope-item strong { display: block; font-size: 13.5px; }
.scope-item p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.scope-item .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.key-distinction { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; font-size: 14.5px; color: var(--ink-2); }
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: var(--surface); }
.slot-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.slot-card .n { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.slot-card strong { font-size: 12.5px; }
.slot-card p { font-size: 12.5px; color: var(--ink-2); }
.slot-card .not-applies { color: var(--muted); font-size: 11.5px; font-style: italic; }
.flow-strip { display: flex; gap: 0; overflow-x: auto; padding: 4px 0 8px; }
.flow-step { position: relative; min-width: 132px; flex: 1; padding: 11px 12px; border: 1px solid var(--line); background: var(--surface); font-size: 11.5px; font-weight: 650; }
.flow-step:first-child { border-radius: 9px 0 0 9px; }
.flow-step:last-child { border-radius: 0 9px 9px 0; }
.flow-step + .flow-step { border-left: 0; }
.flow-step .n { display: block; font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); margin-bottom: 3px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 9px 11px; color: var(--muted); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent-deep); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }
.business-flow { display: grid; gap: 6px; margin: 10px 0 14px; }
.business-flow li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: baseline; font-size: 13px; color: var(--ink-2); }
.business-flow .n { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--accent-soft); color: var(--accent-deep); font-family: var(--font-mono); font-size: 10px; }
.business-lists { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.business-lists h3 { color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.business-lists li { font-size: 12.5px; padding: 3px 0; color: var(--ink-2); }
.related-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.related-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--surface); }
.related-card .relation { display: block; color: var(--accent-deep); font-size: 11.5px; font-weight: 750; margin: 4px 0 6px; }
.related-card h3 { font-size: 14px; }
.related-card p { font-size: 12.5px; color: var(--muted); }
.related-card a { font-size: 11.5px; font-weight: 700; }
.case-top { display: flex; align-items: start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.case-top h3 { font-family: var(--font-serif); font-size: 22px; }
.case-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.case-question { font-size: 15px; font-weight: 650; color: var(--ink); margin: 12px 0; }
.timeline { display: grid; gap: 0; margin: 6px 0 14px; }
.timeline-item { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 15px; top: 28px; bottom: 0; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-deep); font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line)); }
.timeline-body strong { display: block; font-size: 12.5px; }
.timeline-body p { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.derived-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.derived-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); }
.derived-card strong { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.derived-card p { font-size: 12.5px; margin-top: 4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th, .data-table td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.numeric { text-align: right; font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.topic-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--surface); }
.topic-card h4 { font-size: 13px; }
.topic-card p { font-size: 12.5px; color: var(--ink-2); margin: 5px 0 7px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 14px 16px; }
.stat strong { display: block; font-family: var(--font-serif); font-size: 1.55rem; line-height: 1.1; }
.stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.meta-item { border-top: 1px solid var(--line); padding-top: 8px; }
.meta-item strong { display: block; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.meta-item span { font-size: 12.5px; }
.lens-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lens-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: var(--surface); }
.lens-card h3 { font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lens-card .q { font-size: 12.5px; color: var(--ink-2); margin: 5px 0; }
.lens-card .meta { font-size: 11.5px; color: var(--muted); }
.lens-card .meta b { color: var(--ink-2); font-weight: 700; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: var(--surface); }
.role-card h3 { font-size: 12.5px; }
.role-card dl { display: grid; gap: 5px; margin: 7px 0 0; }
.role-card dt { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.role-card dd { margin: 0; font-size: 11.5px; color: var(--ink-2); }
.role-card .handoff { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.role-card .handoff span { font-size: 10px; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.prompt-list { display: grid; gap: 9px; counter-reset: prompt; }
.prompt-card { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: var(--surface); }
.prompt-card .n { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-deep); font-family: var(--font-mono); font-size: 11px; }
.prompt-card p { font-size: 13px; }
.prompt-card small { color: var(--muted); font-size: 10.5px; }

/* section states */
.section-state { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 18px; background: var(--surface-2); }
.section-state h3 { font-size: 13px; margin-bottom: 4px; }
.section-state p { font-size: 12.5px; color: var(--muted); }
.section-state .actions { margin-top: 10px; }
.section-state.is-error { border-style: solid; border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); }
.section-state.is-error h3 { color: var(--danger); }
.section-state.is-degraded { border-color: color-mix(in srgb, var(--warm) 35%, var(--line)); background: var(--warm-soft); }

/* cross + chat entry */
.mode-cross { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-top: 18px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.mode-cross h3 { font-family: var(--font-serif); font-size: 20px; }
.mode-cross p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.chat-entry { margin-top: 18px; padding: clamp(22px, 4vw, 34px); border-radius: var(--radius); background: var(--ink); color: var(--bg); position: relative; overflow: hidden; }
.chat-entry::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent), transparent 70%); }
.chat-entry .kicker { color: var(--accent); }
.chat-entry h2 { font-family: var(--font-serif); font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin: 8px 0 8px; color: var(--bg); position: relative; }
.chat-entry p { color: color-mix(in srgb, var(--bg) 72%, transparent); max-width: 60ch; position: relative; }
.chat-entry .actions { margin-top: 18px; position: relative; }
.chat-entry .btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chat-entry .btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.context-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; position: relative; }
.context-chip { border: 1px solid color-mix(in srgb, var(--bg) 22%, transparent); color: color-mix(in srgb, var(--bg) 82%, transparent); border-radius: 999px; padding: 4px 9px; font-size: 10.5px; font-weight: 650; }

/* ---------- lab ---------- */
.lab-stack { display: grid; gap: 18px; padding-bottom: 46px; }
.outcome-board { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: center; padding: clamp(18px, 3vw, 26px); }
.score-big { font-family: var(--font-serif); font-size: clamp(3rem, 5vw, 4.2rem); line-height: 1; letter-spacing: -.04em; }
.score-big small { font-family: var(--font-sans); font-size: 13px; color: var(--muted); letter-spacing: 0; font-weight: 600; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.outcome-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 12px; }
.outcome-meta strong { color: var(--ink); }
.role-picker { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.role-chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 7px 11px; font-size: 11.5px; font-weight: 700; }
.role-chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.role-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.role-focus { margin-top: 12px; border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; color: var(--ink-2); font-size: 13px; }
.case-facts { display: grid; gap: 12px; }
.case-facts .events { display: grid; gap: 8px; }
.event-row { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: baseline; }
.event-row .n { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent-deep); font-family: var(--font-mono); font-size: 10px; font-weight: 700; }
.event-row p { font-size: 13px; color: var(--ink-2); }
.task-card { scroll-margin-top: calc(var(--header) + 18px); }
.task-head { display: flex; align-items: start; gap: 12px; margin-bottom: 14px; }
.task-no { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-family: var(--font-mono); font-size: 11px; font-weight: 700; }
.task-head h2 { font-family: var(--font-serif); font-size: 1.4rem; line-height: 1.1; }
.task-head p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.task-points { margin-inline-start: auto; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; }
.option-list { display: grid; gap: 8px; }
.option {
  display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.option:hover { border-color: var(--accent); }
.option input { margin-top: 3px; accent-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.hints { margin-top: 10px; }
.hints summary { cursor: pointer; color: var(--accent-deep); font-size: 12px; font-weight: 700; }
.hints ol { margin: 8px 0 0 18px; display: grid; gap: 5px; }
.hints li { list-style: decimal; color: var(--muted); font-size: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field label { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 750; margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); padding: 9px 10px; font-size: 13px;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field .unit { color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.entry-builder { display: grid; gap: 8px; }
.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px 34px; gap: 7px; align-items: center; }
.entry-row input { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); padding: 8px 9px; font-size: 12.5px; }
.entry-row input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.entry-head { font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 750; }
.entry-remove { border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.entry-remove:hover { color: var(--danger); }
.task-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.grading-note { color: var(--muted); font-size: 11.5px; }
.report-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.report-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12.5px; }
.report-row strong { font-weight: 650; }
.report-row span { color: var(--muted); font-size: 11.5px; }
.next-step { margin-top: 14px; border-radius: 9px; background: var(--accent-soft); padding: 12px 14px; color: var(--accent-deep); font-size: 12.5px; }
.next-step a, .next-step .node { color: var(--accent-deep); font-weight: 700; }
.section-chat-entry { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; justify-content: flex-end; }
.section-chat-entry .btn { font-size: 11.5px; }
.task-feedback { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0 14px; }
.task-feedback:not(:empty) { padding: 14px; }
.task-feedback > p { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.feedback-score { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.feedback-score strong { font-family: var(--font-serif); font-size: 1.6rem; line-height: 1; }
.feedback-list { display: grid; gap: 6px; margin-top: 10px; }
.feedback-list li { display: grid; grid-template-columns: 18px 1fr; gap: 7px; align-items: start; font-size: 12.5px; color: var(--ink-2); }
.feedback-list li > span:first-child { font-weight: 800; }
.feedback-list li.ok > span:first-child { color: var(--ok); }
.feedback-list li.bad > span:first-child { color: var(--danger); }
.feedback-list em { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.worked-chain { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.worked-chain summary { cursor: pointer; color: var(--accent-deep); font-size: 12px; font-weight: 750; }
.worked-chain .table-wrap { margin-top: 8px; }
.hint-box { margin-top: 10px; border-left: 3px solid var(--warm); background: var(--warm-soft); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); }
.hint-box[hidden] { display: none; }
.coach-panel { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; }
.coach-panel h3 { font-family: var(--font-serif); font-size: 1.35rem; margin: 4px 0 6px; }
.coach-panel textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); padding: 10px; font-size: 13px; resize: vertical; }
.coach-panel textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.coach-result:not(:empty) { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.coach-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.coach-item { border: 1px solid var(--line); border-radius: 9px; background: var(--bg); padding: 11px 12px; }
.coach-item strong { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.coach-item p { font-size: 12.5px; color: var(--ink-2); }
.coach-item .locator { display: inline-block; margin: 4px 4px 0 0; border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.report-row span.is-ok { color: var(--ok); font-weight: 700; }
.report-row span.is-pending { color: var(--muted); }
@media (max-width: 720px) {
  .coach-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
}

/* ---------- drawers ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(8, 16, 14, .45); backdrop-filter: blur(2px); }
.drawer {
  position: fixed; z-index: 90; top: 0; bottom: 0; width: min(460px, 100%);
  display: flex; flex-direction: column; background: var(--bg);
  border-left: 1px solid var(--line); box-shadow: -20px 0 60px -30px rgba(0, 0, 0, .5);
  animation: slide-in .22s ease;
}
.chat-drawer { right: 0; }
.toc-drawer { left: 0; width: min(320px, 92%); border-left: 0; border-right: 1px solid var(--line); animation-name: slide-in-left; }
@keyframes slide-in { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes slide-in-left { from { transform: translateX(-24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 20px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--font-serif); font-size: 1.45rem; line-height: 1.1; margin-top: 3px; }
.drawer-subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; }
.chat-context { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-context .context-chip { border-color: var(--line); color: var(--muted); background: var(--surface); }
.chat-context a.context-chip, .chat-context button.context-chip { text-decoration: none; font: inherit; font-size: 10.5px; font-weight: 650; cursor: pointer; }
.chat-context a.context-chip:hover, .chat-context button.context-chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.chat-context .context-chip strong { color: var(--ink); font-weight: 700; }
.chat-stream { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; border-radius: 13px; padding: 11px 13px; font-size: 13px; line-height: 1.55; }
.msg-user { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); border-bottom-left-radius: 4px; }
.msg-assistant h2, .msg-assistant h3 { font-family: var(--font-sans); font-size: 13px; margin: 8px 0 4px; color: var(--ink); }
.msg-assistant p { margin: 0 0 6px; }
.msg-assistant ul { margin: 4px 0 8px 16px; }
.msg-assistant li { list-style: disc; margin: 2px 0; }
.msg-assistant table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 8px 0; }
.msg-assistant th, .msg-assistant td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.msg-assistant pre { background: var(--surface-2); border-radius: 7px; padding: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 11px; }
.msg-assistant code { font-family: var(--font-mono); font-size: .92em; }
.msg-meta { margin-top: 6px; font-size: 10.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.thinking { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.thinking .dots span { animation: blink 1.2s infinite; }
.thinking .dots span:nth-child(2) { animation-delay: .2s; }
.thinking .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-suggestions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 10px; }
.suggestion { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 9px; font-size: 10.5px; }
.suggestion:hover { border-color: var(--accent); color: var(--accent-deep); }
.suggested-terms { display: grid; gap: 7px; margin-top: 10px; }
.chat-term-card { display: block; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); text-decoration: none; }
.chat-term-card:hover { border-color: var(--accent); color: var(--ink); }
.chat-term-card strong { display: block; font-size: 12.5px; font-weight: 700; }
.chat-term-card span { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.suggested-questions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.suggested-questions .suggestion { text-align: left; }
.chat-composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-composer textarea { resize: none; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); padding: 9px 10px; font-size: 13px; min-height: 44px; }
.chat-composer textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.toc-drawer-nav { padding: 14px 20px; overflow-y: auto; display: grid; gap: 2px; }
.toc-drawer-nav a { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 9px 8px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 13px; }
.toc-drawer-nav a .num { font-family: var(--font-mono); font-size: 10.5px; }
.toc-drawer-nav a:hover { background: var(--surface-2); color: var(--ink); }
.toc-drawer-nav a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 120; max-width: min(560px, calc(100% - 32px));
  background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 11px 15px; font-size: 12.5px; box-shadow: var(--shadow);
}
.toast.is-error { background: var(--danger); color: #fff; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 34px 0 20px; background: var(--bg-deep); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 30px; }
.brand-footer { margin-bottom: 10px; }
.footer-grid p { color: var(--muted); font-size: 12.5px; max-width: 48ch; }
.footer-heading { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.footer-links { display: grid; gap: 5px; }
.footer-links a { color: var(--ink-2); text-decoration: none; font-size: 12.5px; }
.footer-links a:hover { color: var(--accent-deep); }
.footer-status { color: var(--ink-2); }
.footer-meta { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .primary-nav { display: none; }
  .menu-btn { display: inline-grid; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 620px; }
  .method-grid { grid-template-columns: repeat(2, 1fr); }
  .method-card:nth-child(2)::after { display: none; }
  .term-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .toc-mobile-btn { display: inline-flex; }
  .scope-grid, .topic-grid, .related-grid, .lens-grid, .role-grid { grid-template-columns: 1fr; }
  .derived-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .wrap { width: min(calc(100% - 26px), var(--max)); }
  .header-inner { gap: 10px; min-height: 66px; }
  .brand-text small { display: none; }
  .btn-ai { padding: 8px 11px; font-size: 12.5px; }
  .home-hero { padding-top: 28px; }
  .hero-actions .btn { flex: 1 1 auto; }
  .method-grid { grid-template-columns: 1fr; }
  .method-card::after { display: none; }
  .route-grid { grid-template-columns: 1fr; }
  .term-grid { grid-template-columns: 1fr; }
  .section-head { flex-wrap: wrap; }
  .section-tools { justify-content: flex-start; width: 100%; }
  .slot-grid { grid-template-columns: 1fr; }
  .business-lists { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .entry-row { grid-template-columns: 1fr 80px 80px 30px; }
  .detail-title { align-items: start; }
  .lab-stack { gap: 14px; }
  .outcome-board { grid-template-columns: 1fr; }
  .chat-drawer { width: 100%; border-left: 0; }
  .toc-drawer { width: 92%; }
  .footer-grid { grid-template-columns: 1fr; gap: 18px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .case-top h3 { font-size: 19px; }
  .display { font-size: clamp(2.2rem, 11vw, 3.2rem); }
}

@media (max-width: 460px) {
  .header-actions { gap: 4px; }
  .icon-btn { width: 34px; height: 34px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-text strong { font-size: 14px; }
  .hero-art { padding: 16px; }
  .art-node { min-height: 40px; font-size: 9.5px; }
  .search-box { flex-basis: 100%; max-width: none; }
  .result-count { margin-inline-start: 0; }
  .section-card { padding: 16px; }
  .section-no { width: 32px; height: 32px; font-size: 10.5px; }
  .entry-row { grid-template-columns: 1fr 66px 66px 26px; gap: 4px; }
  .entry-row input { padding: 7px 6px; font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .skeleton::after { animation: none; }
}

@media print {
  .site-header, .site-footer, .toc, .chat-entry, .mode-cross, .drawer, .scrim, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .section-card { break-inside: avoid; box-shadow: none; border-color: #ccc; }
}
