:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #66706b;
  --paper: #f4f3ee;
  --surface: #fffef9;
  --line: #d9ddd7;
  --accent: #176b52;
  --accent-dark: #0d4c3a;
  --accent-soft: #dff1e9;
  --danger: #9d2f2f;
  --danger-soft: #f9e4e1;
  --shadow: 0 18px 50px rgb(29 44 37 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); line-height: 1.5; }
a { color: var(--accent-dark); text-underline-offset: .2em; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 18ch; font-size: clamp(2rem, 5vw, 4.25rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { font-size: 1.25rem; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 100; padding: .75rem; background: white; }
.topbar { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2rem; padding: 1rem max(1.25rem, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--line); background: rgb(244 243 238 / 94%); backdrop-filter: blur(16px); }
.brand { font-weight: 850; font-size: 1.2rem; letter-spacing: -.05em; text-decoration: none; }
nav, .account { display: flex; align-items: center; gap: 1.25rem; }
nav a { text-decoration: none; font-weight: 650; }
.account { justify-self: end; font-size: .9rem; }
.account form { margin: 0; }
.page-shell { width: min(1180px, calc(100% - 2.5rem)); margin: 0 auto; padding: 4rem 0 6rem; }
.footer { padding: 2rem; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .85rem; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 3rem; margin-bottom: 2rem; padding: 3rem; border-radius: 1.5rem; background: var(--ink); color: white; box-shadow: var(--shadow); }
.hero p:not(.eyebrow) { max-width: 58ch; color: #cbd3cf; }
.eyebrow { margin-bottom: .6rem; color: #368a6f; font-size: .75rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.hero .eyebrow { color: #77d5b5; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 2rem; margin-bottom: 1.5rem; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; }
.section-heading h1 { font-size: clamp(2rem, 4vw, 3.4rem); }
.card, .auth-card { padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem; }
.metric-card { display: flex; flex-direction: column; padding: 1.5rem; border-radius: 1rem; background: var(--accent-soft); }
.metric-card strong { font-size: 2.3rem; line-height: 1; }
.metric-card span, .muted, small { color: var(--muted); }
.two-column { display: grid; grid-template-columns: .8fr 1.2fr; gap: 1.25rem; align-items: start; }
.stack { display: grid; gap: 1.15rem; }
.field { display: grid; gap: .4rem; }
label { font-weight: 700; }
input, select, textarea { width: 100%; padding: .82rem .9rem; border: 1px solid #bfc7c2; border-radius: .55rem; background: white; color: var(--ink); font: inherit; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #7acdb1; outline-offset: 2px; }
.check-field { display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: start; font-weight: 500; }
.check-field input { width: 1.1rem; margin-top: .2rem; }
.button { display: inline-flex; justify-content: center; align-items: center; width: fit-content; min-height: 2.7rem; padding: .75rem 1.1rem; border: 0; border-radius: .55rem; background: var(--accent); color: white; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--accent-dark); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-secondary { background: #e7ece9; color: var(--ink); }
.button-small { min-height: 2.25rem; padding: .5rem .8rem; }
.link-button { border: 0; background: none; color: var(--accent-dark); font: inherit; text-decoration: underline; cursor: pointer; }
.alert { margin-bottom: 1.2rem; padding: 1rem 1.2rem; border-radius: .65rem; }
.alert-success { background: var(--accent-soft); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: #fff3cd; color: #684f00; }
.auth-card { display: grid; grid-template-columns: 1.15fr .85fr; gap: 4rem; width: min(880px, 100%); margin: 8vh auto; padding: clamp(2rem, 6vw, 5rem); }
.auth-card h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.usage-tokens { display: grid; gap: .1rem; min-width: 9rem; font-size: .8rem; white-space: nowrap; }
.usage-tokens > span { color: var(--muted); }
.status { display: inline-flex; padding: .28rem .55rem; border-radius: 999px; background: #e8ece9; font-size: .75rem; font-weight: 800; }
.status-import_preview, .status-preview { background: #fff1bd; }
.status-transcribed, .status-confirmed { background: var(--accent-soft); color: var(--accent-dark); }
.status-failed { background: var(--danger-soft); color: var(--danger); }
.empty-state, .error-page { padding: 4rem 1rem; text-align: center; }
.empty-state h2, .error-page h1 { max-width: none; }
.status-panel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; margin-bottom: 1.25rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--line); }
.status-panel div { display: grid; gap: .25rem; min-width: 0; padding: 1rem; background: var(--surface); }
.status-panel span { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.status-panel strong, .status-panel code { overflow: hidden; text-overflow: ellipsis; }
.processing { display: flex; align-items: center; gap: 1rem; }
.processing p { margin: 0; }
.pulse { width: .8rem; height: .8rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgb(23 107 82 / 45%); animation: pulse 1.5s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgb(23 107 82 / 0%); } 100% { box-shadow: 0 0 0 0 rgb(23 107 82 / 0%); } }
.transcript { display: grid; gap: .8rem; padding: 0; list-style: none; counter-reset: segment; }
.transcript li { display: grid; grid-template-columns: 10rem 1fr; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.transcript p { margin: 0; white-space: pre-wrap; }
.segment-meta { display: flex; flex-direction: column; color: var(--muted); font-size: .82rem; }
code { font-size: .82em; }
.review-compact-list { display: grid; gap: .65rem; }
.review-compact-list a { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .75rem; text-decoration: none; }
.review-compact-list span { color: var(--muted); }
.review-heading, .field-heading, .action-card, .confirm-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.interview-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; }
.interview-heading-actions form { margin: 0; }
.status-stack { display: grid; justify-items: end; gap: .5rem; }
.result-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.result-meta div { display: grid; gap: .25rem; min-width: 0; }
.result-meta span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.result-meta code { overflow: hidden; text-overflow: ellipsis; }
.questionnaire { display: grid; gap: 1rem; margin: 1rem 0; }
.questionnaire-field { display: grid; gap: 1rem; }
.confidence { border-radius: 999px; background: #e8f3ec; color: #21623b; padding: .35rem .65rem; font-size: .82rem; white-space: nowrap; }
.confidence-low { background: #fff0d8; color: #8a4b08; }
.ai-value { border-radius: .75rem; background: #f6f7f5; padding: 1rem; }
.ai-value span { color: var(--muted); font-size: .82rem; }
.ai-value p { margin: .35rem 0 0; white-space: pre-wrap; }
.evidence { margin: 0; padding: .9rem 1rem; border-left: 3px solid var(--accent); background: #fbfaf5; }
.evidence div { display: flex; gap: .65rem; font-size: .8rem; color: var(--muted); }
.evidence p { margin: .35rem 0 0; }
.review-form { border-top: 1px solid var(--line); padding-top: 1rem; display: grid; gap: 1rem; }
.review-form fieldset { display: flex; flex-wrap: wrap; gap: .75rem; border: 0; padding: 0; margin: 0; }
.review-form legend { width: 100%; margin-bottom: .5rem; font-weight: 700; }
.radio-option { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); border-radius: 999px; padding: .45rem .7rem; cursor: pointer; }
.radio-option input { width: auto; }
.saved-decision { border-radius: .65rem; background: #eef4ff; padding: .75rem 1rem; }
.t1-heading h1 { max-width: 30ch; font-size: clamp(2rem, 4vw, 3.25rem); }
.confidential-notice { margin-bottom: 1rem; padding: 1rem 1.25rem; border-left: 4px solid #2b6f9e; border-radius: .4rem; background: #eef5f9; color: #183b56; }
.document-with-toc { display: grid; grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.document-toc { position: sticky; top: 5.5rem; display: block; max-height: calc(100vh - 7rem); overflow-y: auto; padding: 1.25rem; scrollbar-gutter: stable; }
.document-toc ol { margin: 0; padding-left: 1.35rem; font-size: .86rem; line-height: 1.35; }
.document-toc li { margin-bottom: .45rem; }
.t1-toc { margin: 0; }
.t1-toc ol { display: grid; grid-template-columns: 1fr; gap: .1rem; }
.t1-toc a { text-decoration-thickness: 1px; }
.t1-document { display: grid; min-width: 0; gap: 1rem; margin: 0; }
.t1-section { scroll-margin-top: 6rem; padding: clamp(1.25rem, 3vw, 2rem); }
.t1-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; padding-bottom: .8rem; border-bottom: 2px solid #d8e0e6; }
.t1-section-heading h2 { margin: 0; color: #183b56; font-size: 1.35rem; }
.edited-badge { flex: none; padding: .3rem .6rem; border-radius: 999px; background: #e8f3ec; color: #21623b; font-size: .75rem; font-weight: 800; }
.t1-markdown { overflow-x: auto; color: #263946; }
.t1-markdown h3, .t1-markdown h4 { margin: 1.5rem 0 .65rem; color: #2b6f9e; }
.t1-markdown p:last-child, .t1-markdown ul:last-child, .t1-markdown ol:last-child { margin-bottom: 0; }
.t1-markdown table { min-width: 680px; margin: .75rem 0 1.25rem; border: 1px solid #d8e0e6; }
.t1-markdown th { background: #183b56; color: white; font-size: .76rem; }
.t1-markdown th, .t1-markdown td { padding: .7rem .8rem; border: 1px solid #d8e0e6; vertical-align: top; }
.t1-markdown tbody tr:nth-child(even) { background: #f5f8fa; }
.t1-markdown blockquote { margin: 1rem 0; padding: .75rem 1rem; border-left: 3px solid #2b6f9e; background: #eef5f9; }
.t1-markdown blockquote p { margin: 0; }
.section-editor { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.section-editor summary, .profile-projection > summary { color: var(--accent-dark); font-weight: 800; cursor: pointer; }
.section-editor form { display: grid; gap: .8rem; margin-top: 1rem; }
.section-editor textarea { min-height: 22rem; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .88rem; line-height: 1.5; }
.profile-projection { margin: 1rem 0; }
.profile-projection[open] > summary { margin-bottom: 1rem; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.profile-attribute p:last-child { white-space: pre-wrap; line-height: 1.6; }
.confirmed-profile-heading h1 { max-width: 24ch; }
.profile-intro { display: grid; grid-template-columns: minmax(16rem, .65fr) minmax(20rem, 1.35fr); gap: 2rem; align-items: center; margin-bottom: 1rem; }
.profile-intro h2, .profile-intro p { margin-bottom: 0; }
.confirmed-profile-toc { margin: 0; }
.confirmed-profile-document { display: grid; min-width: 0; gap: 1rem; }
.confirmed-profile-section { scroll-margin-top: 6rem; padding: clamp(1.25rem, 3vw, 2rem); }
.confirmed-profile-section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; padding-bottom: .8rem; border-bottom: 2px solid var(--line); }
.confirmed-profile-section-heading h2 { margin-bottom: 0; color: #183b56; font-size: 1.35rem; }
.confirmed-profile-section-heading > a { flex: none; font-size: .85rem; }
.confirmed-profile-markdown { color: var(--ink); }
.profile-sources { margin-top: 2rem; }
.compact-heading { margin-bottom: .8rem; }
.compact-heading h2 { font-size: 1.6rem; }
.matching-query-cell { max-width: 34rem; white-space: normal; }
.matching-create-layout { grid-template-columns: minmax(0, 1.35fr) minmax(18rem, .65fr); }
.matching-safety-note { position: sticky; top: 6rem; }
.matching-safety-note li { margin-bottom: .7rem; }
.matching-heading, .matching-results-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; margin-bottom: 1.5rem; }
.matching-heading h1 { margin-bottom: .35rem; font-size: clamp(2rem, 4vw, 3.4rem); }
.matching-original-query { margin-bottom: 1rem; }
.matching-original-query blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--accent); white-space: pre-wrap; }
.matching-interpretation { margin: 1rem 0; }
.matching-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.matching-wide { grid-column: 1 / -1; }
.matching-confirm-form { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-top: 1.5rem; padding: 1.25rem; border: 1px solid #b9d9cc; border-radius: .8rem; background: var(--accent-soft); }
.matching-confirm-form p { margin: .25rem 0 0; }
.matching-query-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.matching-query-summary div { padding: 1rem; border-radius: .7rem; background: #f6f7f5; }
.matching-query-summary dt { color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.matching-query-summary dd { margin: .35rem 0 0; white-space: pre-wrap; }
.matching-run-meta { margin-top: 1rem; }
.matching-results-heading { margin-top: 2.5rem; }
.matching-results-heading h2 { margin-bottom: 0; font-size: 1.8rem; }
.matching-results-heading p { max-width: 34rem; margin-bottom: 0; }
.matching-results { display: grid; gap: 1rem; }
.match-card { scroll-margin-top: 6rem; }
.match-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; }
.match-card-heading h2 { margin-bottom: .35rem; font-size: 1.65rem; }
.match-score { display: grid; justify-items: end; flex: none; }
.match-score strong { color: var(--accent-dark); font-size: 2.8rem; line-height: .9; }
.match-score span { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.match-badges { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 1.3rem; }
.match-copy { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.match-copy > div { padding: 1rem; border-radius: .7rem; background: #f6f7f5; }
.match-copy h3 { margin: 0 0 .5rem; font-size: .9rem; }
.match-copy p { margin: 0; white-space: pre-wrap; }
.match-evidence { margin-top: 1rem; }
.match-evidence summary { color: var(--accent-dark); font-weight: 800; cursor: pointer; }
.match-evidence > div { margin-top: 1rem; }
.match-decision-form { display: grid; grid-template-columns: minmax(12rem, .65fr) minmax(16rem, 1.35fr) auto; gap: 1rem; align-items: end; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.status-needs_confirmation { background: #fff1bd; color: #745900; }
.status-interpreting, .status-matching { background: #e7ecf8; color: #294b82; }
.status-completed, .status-accepted { background: var(--accent-soft); color: var(--accent-dark); }
.status-rejected { background: var(--danger-soft); color: var(--danger); }
.status-deferred { background: #fff1bd; color: #745900; }
@media (max-width: 980px) {
  .document-with-toc { grid-template-columns: 1fr; }
  .document-toc { position: static; max-height: none; overflow-y: visible; }
  .t1-toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem 2rem; }
  .confirmed-profile-toc ol { columns: 2; column-gap: 3rem; }
  .confirmed-profile-toc li { break-inside: avoid; }
  .matching-create-layout { grid-template-columns: 1fr; }
  .matching-safety-note { position: static; }
  .match-copy { grid-template-columns: 1fr; }
  .match-decision-form { grid-template-columns: 1fr 1fr; }
  .match-decision-form .button { grid-column: 1 / -1; }
}
@media (max-width: 780px) {
  .topbar { grid-template-columns: auto 1fr; gap: 1rem; }
  .topbar nav { display: none; }
  .account { grid-column: 2; grid-row: 1; }
  .hero, .section-heading { align-items: start; flex-direction: column; }
  .card-grid, .two-column, .auth-card, .status-panel { grid-template-columns: 1fr; }
  .auth-card { gap: 2rem; margin-top: 2rem; }
  .transcript li { grid-template-columns: 1fr; gap: .35rem; }
  .review-heading, .field-heading, .action-card, .confirm-card { display: grid; }
  .interview-heading-actions { justify-items: end; }
  .status-stack { justify-items: start; }
  .result-meta, .profile-grid { grid-template-columns: 1fr; }
  .review-compact-list a { display: grid; }
  .t1-section-heading { display: grid; }
  .profile-intro { grid-template-columns: 1fr; gap: 1rem; }
  .t1-toc ol { grid-template-columns: 1fr; }
  .confirmed-profile-toc ol { columns: 1; }
  .confirmed-profile-section-heading { display: grid; }
  .matching-heading, .matching-results-heading, .matching-confirm-form { display: grid; align-items: start; }
  .matching-form-grid, .matching-query-summary, .match-decision-form { grid-template-columns: 1fr; }
  .matching-wide, .match-decision-form .button { grid-column: auto; }
  .match-card-heading { display: grid; }
  .match-score { justify-items: start; }
}
