/* A legal pad on a green desk. The page is the desk (forest); every working sheet is a butter-yellow
   pad with a sage binding strip across the top. Anything written on a pad (headings, questions, your
   words) is set in Newsreader; controls and measures are Public Sans. Wheat is the one accent: a
   highlighter mark that only ever means "you, now". */
:root {
  --desk: #15370d;
  --desk-raised: #1f4a15;
  --sage: #728e6d;
  --wheat: #e5cd82;
  --pad: #fff2b4;
  --ink: #15370d;          /* green ink on the pad, 11.7:1 */
  --ink-soft: #44593a;     /* secondary text on the pad, 6.8:1 */
  --on-desk: #fff2b4;
  --on-desk-soft: #e5cd82; /* secondary text on the desk, 8.4:1 */
  --desk-line: rgb(114 142 109 / 0.55);
  --error: #8a1c12;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--sage) var(--desk); }

body {
  margin: 0;
  background: var(--desk);
  color: var(--on-desk);
  font: 1rem/1.55 var(--sans);
  -webkit-tap-highlight-color: transparent;
}

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

a { color: inherit; text-underline-offset: 0.2em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

:focus-visible { outline: 3px solid var(--pad); outline-offset: 2px; }
.sheet :focus-visible { outline-color: var(--desk); }

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 10;
  padding: 10px 14px; border-radius: 4px;
  background: var(--pad); color: var(--ink); font-weight: 600;
}
.skip:focus { top: 12px; }

/* -- the desk edge ---------------------------------------------------------------------------- */

.band { border-bottom: 1px solid var(--desk-line); }
.band-inner, .page {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.band-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 2px 24px; padding-top: 10px; padding-bottom: 10px;
}
.brand { margin: 0; font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.band nav { display: flex; flex-wrap: wrap; gap: 0 22px; }
.band nav a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; }
.band nav a:hover { text-decoration-color: var(--wheat); text-decoration-thickness: 2px; }

.page { padding-top: 24px; padding-bottom: max(64px, env(safe-area-inset-bottom)); }
.page:focus { outline: none; }

/* -- stages: a real sequence, so it's numbered; the current one is highlighted ----------------- */

.stages {
  list-style: none; counter-reset: stage;
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin: 0 0 28px; padding: 0 0 14px;
  border-bottom: 1px solid var(--desk-line);
}
.stages li {
  counter-increment: stage;
  padding: 3px 10px; border-radius: 2px;
  color: var(--on-desk-soft); font-weight: 500;
}
.stages li:first-child { margin-left: -10px; }
.stages li::before { content: counter(stage) ". "; font-variant-numeric: tabular-nums; }
.stages li[aria-current="step"] { background: var(--wheat); color: var(--ink); font-weight: 600; }

/* -- shared parts ----------------------------------------------------------------------------- */

h1 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.75rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* A pad: square paper corners, the binding strip on top, green ink. */
.sheet {
  background: var(--pad);
  color: var(--ink);
  border-top: 10px solid var(--sage);
  border-radius: 2px;
}
/* Only the sheet you're working on lifts off the desk. */
.letter, .question { box-shadow: 0 2px 3px rgb(0 0 0 / 0.22), 0 18px 34px -16px rgb(0 0 0 / 0.55); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 4px;
  font-weight: 600; white-space: nowrap;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
/* On a pad */
.btn-primary { background: var(--desk); color: var(--pad); }
.btn-primary:hover:not(:disabled) { background: var(--desk-raised); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--sage); }
.btn-quiet:hover:not(:disabled) { background: rgb(229 205 130 / 0.5); }
/* On the desk */
.on-desk .btn-primary { background: var(--pad); color: var(--ink); }
.on-desk .btn-primary:hover:not(:disabled) { background: var(--wheat); }
.on-desk .btn-quiet { color: var(--on-desk); }
.on-desk .btn-quiet:hover:not(:disabled) { background: rgb(255 242 180 / 0.1); border-color: var(--wheat); }

/* -- 1. set up -------------------------------------------------------------------------------- */

.setup { display: grid; gap: 28px; }
.letter { padding: clamp(20px, 3vw, 36px); }
.lede { margin: 0 0 26px; max-width: 56ch; color: var(--ink-soft); font-size: 1.05rem; }

.fields { display: grid; gap: 20px; }
.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { display: block; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.95rem; }

select {
  width: 100%; min-height: 48px; padding: 0 40px 0 12px;
  border: 1px solid var(--sage); border-radius: 4px;
  background: var(--pad) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2315370d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink);
  appearance: none;
}
select:hover { border-color: var(--desk); }

.segments {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  border: 1px solid var(--sage); border-radius: 4px; overflow: hidden;
}
.segments label { position: relative; }
.segments input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segments span {
  display: flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 10px;
  border-left: 1px solid var(--sage);
  font-weight: 500; text-align: center;
  transition: background-color 120ms ease-out;
}
.segments label:first-child span { border-left: 0; }
.segments label:hover span { background: rgb(229 205 130 / 0.5); }
.segments input:checked + span { background: var(--desk); color: var(--pad); font-weight: 600; }
.segments input:focus-visible + span { box-shadow: inset 0 0 0 3px var(--desk), inset 0 0 0 5px var(--pad); }

.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--desk); }

.alert {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 12px 14px; border: 1px solid var(--error); border-radius: 4px;
  color: var(--error); font-weight: 500;
}
.alert p { margin: 0; }

.brief h2 { margin: 6px 0 4px; font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.measures { margin: 0; }
.measures dt { margin-top: 14px; font-weight: 600; }
.measures dd { margin: 2px 0 0; color: var(--on-desk-soft); max-width: 46ch; }
.aside-note { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--desk-line); color: var(--on-desk-soft); font-size: 0.92rem; max-width: 52ch; }

/* -- 2. the interview room -------------------------------------------------------------------- */

.room { display: grid; gap: 28px; max-width: 820px; }
.question { padding: clamp(22px, 3.4vw, 40px); }
.question-meta { margin: 0 0 14px; color: var(--ink-soft); font-weight: 600; font-size: 0.95rem; }
.question-text {
  margin: 0 0 18px; max-width: 34ch;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.55rem, 1.05rem + 2vw, 2.4rem);
  line-height: 1.24; letter-spacing: -0.005em; text-wrap: pretty;
}
.question-text:focus { outline: none; }
.room-status { width: fit-content; margin: 0; font-weight: 600; color: var(--ink-soft); }
.room-status[data-live="true"] { margin-left: -8px; padding: 2px 8px; border-radius: 2px; background: var(--wheat); color: var(--ink); }

.answer h2 { margin: 0 0 8px; font-size: 1rem; font-weight: 700; }
/* Your words land on a ruled sheet: one rule under every line of text. */
.answer-text {
  --lh: 1.76rem;
  min-height: calc(var(--lh) * 3 + 32px); margin: 0 0 14px; padding: 16px 18px;
  background: var(--pad) repeating-linear-gradient(to bottom,
    transparent 0 calc(var(--lh) - 1px), var(--wheat) calc(var(--lh) - 1px) var(--lh));
  background-origin: content-box;
  color: var(--ink);
  border-radius: 2px;
  font-family: var(--serif); font-size: 1.1rem; line-height: var(--lh); overflow-wrap: anywhere;
}
.answer-text.is-empty { color: var(--ink-soft); font-family: var(--sans); font-size: 1rem; }

.patience { margin: 0 0 22px; }
.meter { height: 6px; border-radius: 3px; background: rgb(255 242 180 / 0.18); overflow: hidden; }
.meter-fill {
  display: block; width: 100%; height: 100%;
  background: var(--wheat);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 100ms linear;
}
.patience-text { min-height: 1.55em; margin: 8px 0 0; color: var(--on-desk-soft); font-size: 0.95rem; font-variant-numeric: tabular-nums; }

.room-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }

.typed { display: grid; gap: 8px; }
.typed label { font-weight: 600; }
.typed textarea {
  width: 100%; min-height: 96px; padding: 12px 14px;
  border: 1px solid var(--sage); border-radius: 4px;
  background: var(--pad); color: var(--ink); resize: vertical;
}
.typed textarea::placeholder { color: var(--ink-soft); }
.typed textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.typed .btn { justify-self: start; }
.notice { margin: 16px 0 0; font-weight: 600; }
.notice:empty { display: none; }

/* -- 3. report -------------------------------------------------------------------------------- */

.report { display: grid; gap: 28px; max-width: 900px; }
.report-head h1:focus { outline: none; }
.report-meta { margin: 0; color: var(--on-desk-soft); }
#answers { display: grid; gap: 24px; }

.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 1px; margin: 0; overflow: hidden;
  background: var(--wheat);
}
.summary > div { padding: 16px 20px 18px; background: var(--pad); }
.summary dt { color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; }
.summary dd { margin: 4px 0 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.summary dd.summary-plain { max-width: 70ch; font-size: 1rem; font-weight: 400; letter-spacing: 0; }
.summary dd span { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 0.9rem; font-weight: 400; letter-spacing: 0; }

.answer-report { display: grid; gap: 20px; padding: clamp(20px, 3vw, 32px); }
.answer-report h2 { margin: 0; color: var(--ink-soft); font-size: 0.95rem; font-weight: 600; }
.ar-question { margin: -12px 0 0; max-width: 40ch; font-family: var(--serif); font-size: 1.4rem; line-height: 1.28; }
.ar-said { margin: 0; max-width: 68ch; font-family: var(--serif); font-size: 1.1rem; line-height: 1.6; }
.ar-said.is-empty { font-family: var(--sans); color: var(--ink-soft); font-size: 1rem; }

.pace { margin: 0; }
.scale { position: relative; height: 34px; }
.scale-track, .scale-band { position: absolute; top: 12px; height: 8px; border-radius: 4px; }
.scale-track { left: 0; right: 0; background: var(--wheat); }
.scale-band { background: var(--sage); }
.scale-mark { position: absolute; top: 4px; width: 4px; height: 24px; margin-left: -2px; border-radius: 2px; background: var(--ink); }
.pace figcaption { color: var(--ink-soft); font-size: 0.95rem; }
.pace figcaption strong { color: var(--ink); }

.metrics { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
.metrics th, .metrics td { padding: 9px 0; border-bottom: 1px solid var(--wheat); text-align: left; vertical-align: top; }
.metrics th { width: 46%; padding-right: 16px; color: var(--ink-soft); font-weight: 500; }
.metrics td { font-variant-numeric: tabular-nums; }

.covers { margin: 0; padding: 0; border: 0; min-width: 0; }
.covers legend { padding: 0; margin-bottom: 4px; font-weight: 700; }
.covers-hint { margin: 0 0 6px; color: var(--ink-soft); font-size: 0.92rem; }
.covers label { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.covers input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--desk); }
.covers-count { margin: 6px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.report-note { margin: 0; max-width: 70ch; color: var(--on-desk-soft); font-size: 0.95rem; }
.report-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* -- reflow ----------------------------------------------------------------------------------- */

@media (min-width: 600px) {
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields > fieldset, .fields > .check, .fields > .form-actions, .fields > .alert { grid-column: 1 / -1; }
}

@media (min-width: 920px) {
  .setup { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; gap: 40px; }
  .brief { padding-top: 22px; }
}

@media (max-width: 480px) {
  .room-actions .btn { flex: 1 1 100%; }
  .stages { gap: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .skip, .band, .stages, .setup, .room, .report-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .page { padding: 0; }
  .report-head h1, .report-meta, .report-note { color: #000; }
  .sheet { border-top-color: #000; }
  .answer-report, .summary { break-inside: avoid; box-shadow: none; }
}
