@font-face {
  font-family: 'Source Serif 4';
  src: url('./fonts/SourceSerif4Variable-Roman.woff2') format('woff2');
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: Pretendard;
  src: url('./fonts/PretendardVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #f6f3eb;
  --surface: #fffdf8;
  --ink: #141413;
  --ink-2: #3d3d3a;
  --ink-3: #5e5d59;
  --line: #d9d4ca;
  --line-2: #b0aa9e;
  --clay: #d97757;
  --manilla: #f9ead0;
  --night: #141413;
  --footer-ink: #f6f3eb;
  --sans: Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  --serif: 'Source Serif 4', 'Iowan Old Style', Georgia, Pretendard, serif;
  --wide: 1280px;
  --gutter: 32px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --ground: #1a1917;
  --surface: #24221f;
  --ink: #faf9f5;
  --ink-2: #dedad1;
  --ink-3: #b0aa9e;
  --line: #413e38;
  --line-2: #6f695f;
  --manilla: #302821;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='system'] {
    color-scheme: dark;
    --ground: #1a1917;
    --surface: #24221f;
    --ink: #faf9f5;
    --ink-2: #dedad1;
    --ink-3: #b0aa9e;
    --line: #413e38;
    --line-2: #6f695f;
    --manilla: #302821;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: var(--clay); color: var(--night); }
html { scrollbar-color: var(--line-2) var(--ground); }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.6 var(--sans); word-break: keep-all; overflow-wrap: break-word; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
svg { width: 1em; height: 1em; vertical-align: -.12em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
a svg { margin-inline-start: .38em; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .23em; text-decoration-color: color-mix(in srgb, currentColor 55%, transparent); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
main:focus { outline: none; }
[id] { scroll-margin-top: 135px; }

h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 400; }
h1 { font-size: clamp(34px, 5vw, 60px); line-height: 1.1; text-wrap: balance; }
h2 { font-size: clamp(24px, 2.8vw, 32px); line-height: 1.2; }
h3 { font-size: 19px; line-height: 1.35; }
p { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }

.skip { position: fixed; left: 12px; top: 10px; z-index: 8; padding: 10px 15px; background: var(--surface); transform: translateY(-180%); }
.skip:focus { transform: translateY(0); }
.top { position: sticky; top: 0; z-index: 5; background: var(--ground); border-bottom: 1px solid var(--line); }
.top-in, .sub, main, .fin { max-width: var(--wide); margin-inline: auto; padding-inline: var(--gutter); }
.top-in { min-height: 71px; padding-block: 16px; display: flex; align-items: center; gap: 16px; }
.brand { margin-right: auto; display: inline-flex; align-items: center; gap: 12px; font: 700 14px/1 var(--sans); letter-spacing: .16em; text-decoration: none; white-space: nowrap; }
.brand span { width: 1px; height: .82em; background: currentColor; opacity: .42; }
.top-actions, .locale { display: flex; align-items: center; }
.top-actions { gap: 10px; }
.locale a { padding: 6px 5px; text-decoration: none; font-size: 12px; color: var(--ink-3); }
.locale a[aria-current='page'] { color: var(--ink); font-weight: 700; box-shadow: inset 0 -1px var(--ink); }
.nav, .sub { display: flex; align-items: center; }
.nav { gap: 4px; }
.nav a, .sub a { text-decoration: none; white-space: nowrap; color: var(--ink-3); font-size: 13px; }
.nav a { padding: 6px 10px; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--ink); box-shadow: inset 0 -1px var(--ink); }
.subbar { min-width: 0; }
.sub { gap: 28px; overflow-x: auto; scrollbar-width: none; }
.sub a { flex: 0 0 auto; padding: 12px 0; }
.sub a:focus-visible { outline-offset: -2px; }
.sub a:hover { color: var(--ink); }
.sub a[aria-current='location'] { font-weight: 600; color: var(--ink); box-shadow: inset 0 -2px var(--clay); }

main { min-height: 58vh; padding-block: 42px 96px; }
section { margin-top: 64px; }
section > h2 { padding-top: 22px; margin-bottom: 8px; border-top: 1px solid var(--line); }
.lede { margin-top: clamp(18px, 2.4vw, 28px); font-size: 18px; line-height: 1.7; color: var(--ink-2); max-width: 40em; }
.note { color: var(--ink-3); font-size: 14px; line-height: 1.6; }

.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .9fr); gap: 40px; padding-bottom: 8px; }
.hero h1 { text-wrap: initial; max-width: 18ch; }
.cover-lead { border-top: 1px solid var(--line-2); margin-top: 30px; padding-top: 17px; max-width: 60ch; }
.cover-lead h2 { margin-bottom: 7px; font-size: clamp(21px, 2.4vw, 28px); }
.cover-lead p, .cover-ledger p { color: var(--ink-2); }
.cover-index { display: flex; flex-wrap: wrap; gap: 5px 18px; margin-top: 23px; font-size: 14px; color: var(--ink-3); }
.cover-section { margin-top: 46px; }
.cover-ledger { max-width: 760px; }
.cover-ledger h3 { margin-bottom: 5px; }
.row-links, .citations { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill, .menu-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; width: fit-content; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 13px; line-height: 1.5; white-space: nowrap; }
.pill svg { margin-inline-start: 0; }
.pill:hover { border-color: var(--ink); }
.menu-btn { border-color: var(--line); border-radius: 0 0 8px 8px; padding: 10px 18px 11px; font-weight: 600; line-height: 1.15; min-height: 39px; }
.menu-btn:hover { color: var(--surface); background: var(--ink); border-color: var(--ink); }

.plate { display: flex; flex-direction: column; margin: 0; border-radius: 24px; overflow: hidden; background: var(--manilla); }
.evidence-map { display: block; width: 100%; height: 0; min-height: 320px; flex: 1 1 0; }
.plate figcaption { border-top: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); padding: 12px 24px 16px; font: 400 14px/1.5 var(--serif); color: var(--ink-2); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
.card h3 { margin-bottom: 8px; }
.card p, .reading p:not(.lede, .note) { color: var(--ink-2); }
.topic-card { display: flex; flex-direction: column; align-items: flex-start; }
.topic-card .read { margin-top: auto; }
.card-meta { display: flex; flex-wrap: wrap; gap: .5em 1em; color: var(--ink-3); font-size: 13px; margin-bottom: 8px; }
.topic-card { text-decoration: none; transition: background-color .2s ease, border-color .2s ease; }
.topic-card:hover { border-color: var(--line-2); background: var(--manilla); }
.topic-card .card-meta { justify-content: space-between; width: 100%; }
.topic-card .read { font-size: 13px; text-decoration: underline; text-underline-offset: .23em; }
.feature { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; }

.reading { max-width: 780px; }
.reading section { margin-top: 46px; }
.breadcrumb { display: flex; gap: .6em; color: var(--ink-3); font-size: 13px; margin-bottom: 16px; }
.english-title { color: var(--ink-3); margin-top: 12px; font-size: 16px; }
.reading .lede { margin-top: 16px; }
.research-question { font-family: var(--serif); font-size: 22px; line-height: 1.5; }
.finding { margin-top: 14px; }
.citations { font-size: 14px; gap: 8px 16px; color: var(--ink-3); }
.related { padding-left: 1.3em; }
.related li { margin-block: 6px; }
.related span { margin-left: .5em; }
.source-list { font-size: 14px; }
.source-list span { margin-inline: 0 5px; }
.source-list p { margin-top: 4px; }
.ledger { margin-top: 14px; border-top: 1px solid var(--line-2); }
.ledger article { padding: 18px 0; border-bottom: 1px solid var(--line); }
.ledger article:target { background: color-mix(in srgb, var(--manilla) 52%, transparent); }
.ledger h2 { font-size: 22px; margin-bottom: 8px; }
.ledger p:not(.card-meta) { max-width: 72ch; }
.row-links { gap: 8px 16px; }
.row-links a { font-size: 14px; }
.row-links:empty { display: none; }
.topic-links { margin-top: 10px; color: var(--ink-3); }
.section-link, .experiment { margin-top: 18px; }

.structure-page { max-width: 1000px; }
.structure-page .lede { margin-top: 12px; }
.model-view { margin-top: 32px; }
.structure-figure { margin: 14px 0; }
.structure-figure canvas { display: block; width: 100%; height: clamp(270px, 55vw, 520px); background: #171915; border: 1px solid var(--line); border-radius: 20px; cursor: grab; touch-action: pan-y; }
.structure-figure canvas:active { cursor: grabbing; }
.structure-figure figcaption { margin-top: 8px; color: var(--ink-3); font-size: 14px; }
.model-tools, .confidence-key { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.model-tools { margin-block: 12px; }
.model-tools input { width: 6em; padding: 5px 8px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; }
.model-tools output { min-width: 9em; font-variant-numeric: tabular-nums; }
.confidence-key { font-size: 13px; color: var(--ink-3); }
.confidence-key span { display: inline-flex; gap: 6px; align-items: center; }
.confidence-key i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line-2); }
.confidence-0 { background: #2677e3; }
.confidence-1 { background: #69c4e8; }
.confidence-2 { background: #f4cd53; }
.confidence-3 { background: #e99159; }
.experiment { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.experiment h3 { margin-bottom: 8px; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-top: 24px; }
.filters label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); }
.filters label:first-child { flex: 1 1 250px; max-width: 440px; }
.filters input, .filters select { border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 8px 12px; min-height: 44px; }
.filters input { width: 100%; caret-color: var(--ink); }
.filters input::placeholder { color: var(--ink-3); opacity: 1; }
.filters .pill { min-height: 44px; }
.result-count { margin-top: 15px; }
.empty { padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

table { width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th:first-child { font-weight: 500; }
th:last-child:not(:first-child), td:last-child { text-align: right; }
tfoot { font-weight: 650; }
.audit-subhead { margin-block: 20px 8px; }
.key-values { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin-block: 18px; font-size: 14px; }
.key-values dt { font-weight: 600; }
.key-values dd { margin: 0; }
code { overflow-wrap: anywhere; }
pre { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 12px 16px; overflow: auto; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.fullmenu { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(420px, 100%); height: 100%; max-height: none; max-width: none; overflow: auto; background: var(--ground); color: var(--ink); border: 0; border-left: 1px solid var(--line-2); padding: 28px; }
.fullmenu::backdrop { background: rgb(20 20 19 / 38%); }
.menu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.fullmenu nav { display: grid; }
.fullmenu nav a { border-top: 1px solid var(--line); padding: 11px 9px; text-decoration: none; }
.fullmenu nav a:hover, .fullmenu nav a[aria-current='page'] { background: var(--manilla); }
.appearance { margin: 24px 0 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 15px; display: flex; gap: 8px 16px; flex-wrap: wrap; font-size: 14px; }
.appearance input { accent-color: var(--ink); }

footer { background: var(--night); color: var(--footer-ink); padding-block: 40px 46px; }
.fin { font-size: 13px; }
.footer-brand { display: inline-block; letter-spacing: .12em; font-weight: 650; text-decoration: none; margin-bottom: 8px; }
.fin nav { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 18px; }
footer :focus-visible { outline-color: var(--footer-ink); }
.riscon-pill { position: fixed; z-index: 4; right: 22px; bottom: 22px; display: inline-flex; align-items: center; gap: 7px; padding: 5px 13px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600; text-decoration: none; }
.riscon-pill:hover { border-color: var(--ink); }
.riscon-pill span { font-weight: 400; }
.riscon-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--clay); }

@media (max-width: 1050px) {
  .js .nav { display: none; }
  .top-in:has(.nav:not(:empty)) { flex-wrap: wrap; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .top-in { min-height: 64px; padding-block: 12px; }
  .nav { flex-wrap: wrap; }
  .sub { gap: 24px; }
  main { padding-block: 24px 72px; }
  section { margin-top: 48px; }
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .evidence-map { min-height: 240px; }
  .card { border-radius: 16px; padding: 20px; }
  .riscon-pill { right: 12px; bottom: 12px; }
  .riscon-pill span { display: none; }
  footer { padding-block: 32px 52px; }
}

@media (max-width: 520px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .filters label:first-child { max-width: none; flex-basis: 100%; }
  .filters select { max-width: 100%; }
  .brand { font-size: 12px; gap: 8px; }
  .top-actions { gap: 6px; }
  .menu-btn { padding-inline: 11px; }
  .menu-btn span { display: none; }
  .key-values { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .key-values dd + dt { margin-top: 7px; }
}

.tool-page { max-width: 1050px; }
.tool-page > .note { max-width: 72ch; }
.tool-sheet { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 32px; }
.tool-inputs, .tool-results, .paper-card { margin-top: 32px; }
.tool-sheet .note { margin-bottom: 12px; }
.tool-inputs input, .tool-inputs select, .card-prompts input { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); border-radius: 6px; padding: 8px; min-width: 0; width: 100%; min-height: 44px; }
.shared-input { display: grid; gap: 4px 16px; align-items: center; grid-template-columns: minmax(0, 1fr) 7rem; margin-bottom: 8px; }
.assumptions-table { table-layout: fixed; font-size: 14px; margin-bottom: 16px; }
.assumptions-table th:first-child { width: 52%; }
.assumptions-table th, .assumptions-table td { padding: 8px 4px; text-align: start; }
.assumptions-table thead th { color: var(--ink-3); }
.assumptions-table input { font-variant-numeric: tabular-nums; }
.result-ledger { margin: 0; border-top: 1px solid var(--line-2); }
.result-ledger > div { padding: 8px 0 12px; border-bottom: 1px solid var(--line); }
.result-ledger dt { font-size: 14px; }
.result-ledger dd { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 0; }
.result-ledger small { display: block; color: var(--ink-3); font-size: 12px; }
.result-ledger output { font-size: 19px; font-variant-numeric: tabular-nums; }
.result-criterion { margin-top: 16px; background: var(--manilla); border-radius: 10px; padding: 12px 16px; }
.observation-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: start; max-width: 640px; }
.observation-form label { display: grid; gap: 4px; font-size: 14px; }
.observation-form .primary-tool { grid-column: 1 / -1; margin-block: 4px 12px; background: var(--ink); border-color: var(--ink); color: var(--ground); }
.observation-form .primary-tool:hover { background: var(--ink-2); }
.pill:disabled { cursor: not-allowed; background: var(--ground); color: var(--ink-3); border-color: var(--line); }
.observation-log { max-width: 640px; padding-left: 24px; margin-bottom: 12px; }
.observation-log:empty { display: none; }
.observation-log li { padding-block: 8px; border-bottom: 1px solid var(--line); }
.observation-log button { margin-inline-start: 12px; }
.record-import { max-width: 640px; margin-top: 16px; }
.record-import label { display: block; margin-block: 8px; font-size: 14px; }
.record-import input { width: auto; max-width: 100%; }
.print-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-2); padding-top: 16px; margin-bottom: 8px; }
.card-prompts { border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); margin-top: 16px; padding: 20px 24px; max-width: 500px; }
.card-prompts div + div { margin-top: 12px; }
.card-prompts dt { font-weight: 550; }
.card-prompts dd { margin: 4px 0 0; }
.card-prompts [data-cue-print] { display: none; }

@media (max-width: 760px) {
  .tool-sheet { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (max-width: 480px) {
  .observation-form { grid-template-columns: minmax(0, 1fr); }
  .assumptions-table th:first-child { width: 48%; }
}

@media print {
  body:has(.paper-card) { background: #fffdf8; color: #141413; }
  body:has(.paper-card) :is(.top, footer, .riscon-pill, .tool-page > :not(.paper-card), [data-print-card], .cue-privacy, [data-cue]) { display: none; }
  body:has(.paper-card) main { padding: 0; }
  .paper-card { margin: 0; }
  .paper-card, .paper-card p { color: #141413 !important; }
  .paper-card .print-head { border: 0; padding-top: 0; }
  .card-prompts { background: transparent; border-color: #3d3d3a; break-inside: avoid; }
  .card-prompts dd { border-bottom: 1px solid #3d3d3a; min-height: 1.65em; }
  .card-prompts [data-cue-print] { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .topic-card { transition: none; }
}
