:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #eeeee8;
  --ink: #17201b;
  --muted: #57635c;
  --line: #cdd3cd;
  --green: #214d3a;
  --green-soft: #e3eee8;
  --amber: #8a5a09;
  --amber-soft: #fff1cb;
  --red: #9a2f2a;
  --red-soft: #fbe7e4;
  --blue-soft: #e8eff5;
  --focus: #c77800;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
::selection { background: var(--amber-soft); color: var(--ink); }
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-thumb { border: 3px solid var(--paper); border-radius: 10px; background: #9ba69f; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.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; top: -5rem; left: 1rem; z-index: 100; padding: 0.8rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 64px; padding: 0.7rem max(1.25rem, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line); background: rgba(247, 245, 239, 0.96);
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--ink); font-weight: 800; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--green); color: white; font-size: 0.76rem; letter-spacing: 0.04em; }
.header-status { display: flex; gap: 0.45rem; color: var(--muted); font-size: 0.82rem; }
.header-action { border: 0; padding: 0; background: transparent; color: var(--green); font-weight: 800; text-decoration: underline; text-underline-offset: 0.2em; }

#workspace { width: min(1180px, calc(100% - 2.5rem)); margin: 0 auto; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Charter, "Iowan Old Style", Georgia, serif; }
h1 { font-size: clamp(2.2rem, 4.4vw, 4rem); line-height: 1; letter-spacing: -0.035em; text-wrap: balance; }
h2 { font-size: clamp(1.45rem, 2.5vw, 2.1rem); line-height: 1.12; letter-spacing: -0.02em; }
h3 { font-size: 0.95rem; }
p, li { line-height: 1.55; }

.access-screen { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.75fr); gap: clamp(2.5rem, 7vw, 7rem); align-items: start; padding: clamp(3rem, 7vw, 6rem) 0; }
.access-copy { max-width: 720px; }
.beta-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 2.5rem 0 0; }
.beta-facts div { padding-top: 0.9rem; border-top: 1px solid var(--line); }
.beta-facts dt { color: var(--muted); font-size: 0.75rem; }
.beta-facts dd { margin: 0.3rem 0 0; font-weight: 800; }
.access-form { padding: clamp(1.3rem, 3vw, 2rem); border-radius: 16px; background: var(--surface); box-shadow: 0 16px 38px rgba(23, 32, 27, 0.12); }
.access-form h2 { margin-bottom: 0.45rem; }
.access-form > p { color: var(--muted); }
.consent-list { display: grid; gap: 0.8rem; margin: 1.35rem 0; padding: 1.1rem 0 0; border: 0; border-top: 1px solid var(--line); }
.consent-list legend { padding-top: 1.35rem; font-weight: 800; }
.consent-list label, .consent-inline { display: grid; grid-template-columns: 1.15rem 1fr; gap: 0.65rem; align-items: start; color: var(--ink); font-size: 0.88rem; line-height: 1.45; }
.consent-list input, .consent-inline input { width: 1.05rem; height: 1.05rem; margin-top: 0.15rem; accent-color: var(--green); }
.privacy-note { font-size: 0.78rem; }
.access-form .button { width: 100%; }
.request-link { display: block; margin-top: 1rem; color: var(--green); text-align: center; text-underline-offset: 0.22em; }

.scenario-label, .scene-time, .role-caption { color: var(--green); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.intro-screen { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.75fr); gap: clamp(2.5rem, 7vw, 7rem); padding: clamp(2.5rem, 5vw, 4.5rem) 0 4rem; }
.intro-copy { max-width: 760px; }
.intro-lead { max-width: 65ch; margin-bottom: 2.25rem; color: var(--muted); font-size: clamp(1.05rem, 1.7vw, 1.32rem); }
.scenario-picker { margin: 0 0 2rem; padding: 0; border: 0; }
.scenario-picker legend { margin-bottom: 0.8rem; font-weight: 800; }
.scenario-options { display: grid; gap: 0.65rem; }
.scenario-option { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 0.8rem; align-items: start; padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.scenario-option:has(input:checked) { border-color: var(--green); background: var(--green-soft); box-shadow: 0 8px 22px rgba(33, 77, 58, 0.1); }
.scenario-option input { width: 1.1rem; height: 1.1rem; margin-top: 0.15rem; accent-color: var(--green); }
.scenario-option strong, .scenario-option small { display: block; }
.scenario-option small { margin-top: 0.2rem; color: var(--muted); }
.mission { margin: 2rem 0; padding: 1.5rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mission h2 { margin-bottom: 1rem; font-size: 1.3rem; }
.mission p { margin-bottom: 0; }
.mission ol { display: grid; gap: 0.75rem; margin: 0; padding-left: 1.6rem; }
.mission li::marker { color: var(--green); font-weight: 900; }
.source-basis { margin: -0.8rem 0 1.5rem; color: var(--muted); font-size: 0.86rem; }
.source-basis ul { display: grid; gap: 0.55rem; margin: 0.8rem 0 0; padding-left: 1.25rem; }
.source-basis strong { color: var(--ink); }
.start-row { display: flex; align-items: center; gap: 1.25rem; margin-top: 2rem; }
.start-row p { max-width: 38ch; margin: 0; color: var(--muted); font-size: 0.85rem; }

.cast { align-self: start; padding-top: 1.9rem; }
.you-card { display: grid; grid-template-columns: 58px 1fr; gap: 1rem; padding: 1.25rem; border-radius: 16px; background: var(--green); color: white; box-shadow: 0 14px 36px rgba(33, 77, 58, 0.2); }
.you-card h2 { margin-bottom: 0.4rem; font-size: 1.35rem; }
.you-card p:last-child { margin: 0; color: #dce9e2; font-size: 0.88rem; }
.you-card .role-caption { margin-bottom: 0.3rem; color: #bcd8c9; font-size: 0.67rem; }
.cast-title { margin: 2rem 0 0.85rem; font-size: 1rem; }
.cast-list { margin: 0; padding: 0; list-style: none; }
.cast-list li { display: grid; grid-template-columns: 42px 1fr; gap: 0.8rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.cast-list strong, .cast-list small { display: block; }
.cast-list small { margin-top: 0.2rem; color: var(--muted); }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; background: var(--blue-soft); color: #304c62; font-size: 0.72rem; font-weight: 900; }
.avatar-you { width: 58px; height: 58px; background: white; color: var(--green); }
.what-you-produce { margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }

.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; border-radius: 10px; padding: 0.75rem 1.1rem; font-weight: 800; }
.button.primary { border: 1px solid var(--green); background: var(--green); color: white; box-shadow: 0 8px 22px rgba(33, 77, 58, 0.18); }
.button.primary:hover { background: #173d2c; }
.button.secondary { border: 1px solid var(--green); background: transparent; color: var(--green); }
.button.danger { border: 1px solid #f3b6b0; background: transparent; color: #ffd9d4; }

.session-screen { padding: 1.5rem 0 5rem; }
.progress { display: flex; align-items: center; max-width: 740px; margin: 0 0 2rem; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.progress span { display: flex; flex: 1; align-items: center; gap: 0.45rem; }
.progress span:not(:last-child)::after { content: ""; height: 1px; flex: 1; margin: 0 0.8rem; background: var(--line); }
.progress b { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); }
.progress .active { color: var(--green); }
.progress .active b { border-color: var(--green); background: var(--green); color: white; }

.session-layout { display: grid; grid-template-columns: minmax(0, 760px) minmax(260px, 320px); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.case-opening { padding: 1.5rem 0 2.5rem; border-bottom: 1px solid var(--line); }
.case-opening h1 { margin-bottom: 1rem; font-size: clamp(2rem, 4vw, 3.7rem); }
.case-opening p:last-child { max-width: 65ch; margin-bottom: 0; color: var(--muted); font-size: 1.08rem; }
.conversation { padding: 2rem 0; }
.message { display: grid; grid-template-columns: 42px 1fr; gap: 0.8rem; margin-bottom: 1.15rem; }
.message-body { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; background: var(--surface); box-shadow: 0 8px 22px rgba(23, 32, 27, 0.05); }
.message-body header { display: flex; justify-content: space-between; gap: 1rem; }
.message-body time { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.message-body p { margin: 0.55rem 0 0; }
.system-event { display: grid; grid-template-columns: 42px 1fr; gap: 0.8rem; margin: 1.5rem 0; padding: 1rem; border-radius: 14px; background: var(--amber-soft); color: #5f410d; }
.system-event p { margin: 0.2rem 0 0; }
.event-symbol { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--amber); color: white; font-weight: 900; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline-item { display: grid; grid-template-columns: 42px 1fr; gap: 0.8rem; margin: 1.2rem 0; }
.event-index { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 0.72rem; font-weight: 900; }
.event-card { padding: 1rem 1.1rem; border-radius: 4px 16px 16px 16px; background: var(--green-soft); }
.event-card header { display: flex; justify-content: space-between; gap: 1rem; }
.event-card time { color: var(--muted); font-size: 0.75rem; }
.event-card dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin: 0.8rem 0 0; }
.event-card dt { color: var(--muted); font-size: 0.72rem; }
.event-card dd { margin: 0.15rem 0 0; font-size: 0.82rem; font-weight: 700; overflow-wrap: anywhere; }
.timeline-prompt { margin: 1.25rem 0 0 3.1rem; color: var(--muted); font-style: italic; }

.decision-block { margin-top: 1rem; padding: clamp(1.3rem, 4vw, 2rem); border-radius: 16px; background: var(--surface); box-shadow: 0 14px 36px rgba(23, 32, 27, 0.09); }
.decision-heading h2 { margin-bottom: 0.55rem; }
.decision-heading p:last-child { color: var(--muted); }
.action-list { display: grid; gap: 0.75rem; margin-top: 1.4rem; }
.action-choice { width: 100%; min-height: 68px; padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); text-align: left; transition: border-color 140ms ease, background 140ms ease, transform 140ms ease; }
.action-choice:hover { transform: translateY(-1px); border-color: var(--green); background: var(--green-soft); }
.action-choice strong, .action-choice small { display: block; }
.action-choice small { margin-top: 0.25rem; color: var(--muted); }
.action-form { margin-top: 1.35rem; }
.action-form fieldset { margin: 0; padding: 0; border: 0; }
.action-form legend { font-size: 1.05rem; font-weight: 800; }
.field-help, .empty-copy { color: var(--muted); }
.field { display: grid; gap: 0.4rem; margin-top: 0.9rem; }
.field label { font-size: 0.84rem; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 9px; padding: 0.7rem; background: white; color: var(--ink); }
.field textarea { min-height: 96px; resize: vertical; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1rem; }
.button.finish { margin-top: 1rem; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.stop-note { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.78rem; }

.case-notes-sticky { position: sticky; top: 92px; padding: 1.25rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.78); }
.case-notes h2 { font-size: 1.15rem; }
.fact-list { margin: 0; }
.fact-list div { display: grid; grid-template-columns: minmax(86px, 0.8fr) 1.2fr; gap: 0.5rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.fact-list dt { color: var(--muted); font-size: 0.75rem; }
.fact-list dd { margin: 0; font-size: 0.8rem; font-weight: 700; overflow-wrap: anywhere; }
.callout { margin: 1rem 0; padding: 0.85rem; border-radius: 10px; font-size: 0.84rem; line-height: 1.45; }
.callout.warning { background: var(--amber-soft); color: #5f410d; }
.callout.error { background: var(--red-soft); color: var(--red); }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.section-title-row h3 { margin: 0; }
.count-badge { display: grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 0.74rem; font-weight: 900; }
.evidence-list { margin: 0; padding: 0; list-style: none; }
.evidence-list li { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.evidence-list strong, .evidence-list small { display: block; }
.evidence-list small { color: var(--muted); }
.technical-details { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
.run-meta { margin: 0.8rem 0 0; }
.run-meta div { display: grid; grid-template-columns: 70px 1fr; gap: 0.5rem; padding: 0.35rem 0; }
.run-meta dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.review-panel { margin-top: 2rem; padding: clamp(1.5rem, 4vw, 2.5rem); border-radius: 16px; background: var(--green); color: white; }
.review-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 0.8rem; margin: 1.5rem 0; }
.review-card { padding: 1rem; border-radius: 12px; background: rgba(255, 255, 255, 0.12); }
.review-card h3 { color: #cce0d5; font-size: 0.75rem; text-transform: uppercase; }
.review-card p { margin: 0; font-weight: 800; }
.review-explanation { max-width: 65ch; margin: 1.25rem 0; padding: 1rem 1.1rem; border-radius: 12px; background: rgba(255, 255, 255, 0.12); }
.review-explanation h3 { margin-bottom: 0.4rem; font-size: 1rem; }
.review-explanation p { margin: 0; color: #e1eee6; }
.review-panel details { margin: 1rem 0; }
.review-panel pre { overflow: auto; padding: 1rem; border-radius: 10px; background: #10281d; color: #edf5f0; white-space: pre-wrap; font: 0.75rem/1.5 ui-monospace, monospace; }
.review-panel .button.secondary { border-color: white; color: white; }
.feedback-form { display: grid; gap: 0.4rem; margin: 1.5rem 0; padding: 1.25rem; border-radius: 14px; background: rgba(255, 255, 255, 0.1); }
.feedback-form h3 { margin-bottom: 0.2rem; font-family: Charter, "Iowan Old Style", Georgia, serif; font-size: 1.25rem; }
.feedback-form input, .feedback-form textarea { border-color: rgba(255,255,255,0.4); }
.feedback-form .consent-inline { margin: 0.7rem 0; color: #e1eee6; }
.feedback-form #feedback-status { margin: 0; color: #e1eee6; font-size: 0.84rem; }

.loading-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; gap: 0.9rem; background: rgba(247, 245, 239, 0.9); color: var(--green); font-weight: 800; text-align: center; }
.spinner { width: 40px; height: 40px; margin: auto; border: 4px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; } }

@media (max-width: 900px) {
  .access-screen, .intro-screen, .session-layout { grid-template-columns: 1fr; }
  .cast { max-width: 680px; padding-top: 0; }
  .case-notes { grid-row: 1; }
  .case-notes-sticky { position: static; }
}
@media (max-width: 620px) {
  #workspace { width: min(100% - 1.25rem, 580px); }
  .app-header { position: static; }
  .header-status { display: none; }
  .intro-screen { padding-top: 2.5rem; }
  .start-row { align-items: stretch; flex-direction: column; }
  .start-row .button { width: 100%; }
  .progress span { font-size: 0; }
  .progress b { font-size: 0.78rem; }
  .beta-facts { grid-template-columns: 1fr; }
}
