/* Lexen design system v1.0 (owner sign-off 4 Nov 2026). Mobile-first, system fonts only.
   Dark forest is the default look; a readable light mode is derived from it.
   Colours live ONLY in these tokens. Measured contrast ratios: docs/design-system.md (checked by tests). */
:root {
  color-scheme: dark;
  /* Approved palette */
  --forest: #142119;          /* brand dark forest */
  --forest-deep: #151D19;     /* deeper background */
  --card: #25362B;            /* card / surface */
  --card-2: #26372D;          /* raised surface */
  --line: #35483B;            /* decorative border */
  --line-2: #486450;          /* decorative border, stronger */
  --lime: #C6FF38;            /* accent: primary buttons, focus, progress only */
  --white: #FFFFFF;
  --mist: #D7E3D9;            /* secondary text */

  /* Semantic tokens (dark, default) */
  --bg: var(--forest);
  --bg-deep: var(--forest-deep);
  --surface: var(--card);
  --surface-2: var(--card-2);
  --input-bg: #1B2A20;
  --note-bg: #1B2A20;
  --text: var(--white);
  --muted: var(--mist);
  --border: var(--line);
  --border-2: var(--line-2);
  /* Interactive boundaries must reach 3:1, which the decorative borders can't; derived from the palette. */
  --control: #8FA896;
  --brand: var(--lime);
  --brand-text: var(--forest);
  --link: var(--lime);
  --sel-bg: #34503C;
  --sel-text: var(--white);
  --sel-border: var(--lime);
  --sel-mark: var(--lime);
  --sel-mark-fg: var(--forest);
  --focus: var(--lime);
  --progress: var(--lime);
  --track: var(--line);
  --ok: #A8E6B8;
  --warn: #FFC37A;
  /* Voice: red is the record call-to-action, never an error. Errors use amber below. */
  --danger: #C62828;
  --danger-hover: #A61F1F;
  --danger-edge: #FF8A80;
  --danger-text: var(--white);
  --rec-disabled: #5D6B61;
  --error-bg: #3D2A12;
  --error-text: #FFD9A8;
  --fact-bg: #2F4A36;
  --fact-text: #DDF5B0;
  --hyp-bg: #4A3F1C;
  --hyp-text: #FFE9A8;
  --shadow: rgba(0, 0, 0, .35);
  --print-ink: #000000;
  --print-paper: #FFFFFF;
  --radius: 12px;
  --tap: 48px;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F3F6F2;
    --bg-deep: #E8EEE8;
    --surface: var(--white);
    --surface-2: #EEF3EE;
    --input-bg: var(--white);
    --note-bg: #EEF3EE;
    --text: var(--forest);
    --muted: #3D5244;
    --border: #C9D6CC;
    --border-2: #A9BCAE;
    --control: #5E7A66;
    /* Lime never sits on light backgrounds: primary buttons are forest with a lime label. */
    --brand: var(--forest);
    --brand-text: var(--lime);
    --link: #2F5D18;
    --sel-bg: var(--forest);
    --sel-text: var(--white);
    --sel-border: var(--forest);
    --sel-mark: var(--lime);
    --sel-mark-fg: var(--forest);
    --focus: #3B6E00;
    --progress: #3B6E00;
    --track: #DDE6DE;
    --ok: #2F5D18;
    --warn: #8A4B00;
    --danger: #B3261E;
    --danger-hover: #8C2A24;
    --danger-edge: #8C2A24;
    --error-bg: #FFF1DE;
    --error-text: #6B3A00;
    --fact-bg: #E3F1E8;
    --fact-text: #0F4D2A;
    --hyp-bg: #FDF0DC;
    --hyp-text: #6B3A00;
    --shadow: rgba(20, 33, 25, .12);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 17px;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus, [tabindex="-1"]:focus { outline: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--surface); color: var(--text); padding: 12px 16px; border-radius: 8px; z-index: 10; }
.skip-link:focus { top: 8px; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 720px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--lime); color: var(--forest); display: grid; place-items: center; font-weight: 800; flex: none; }
.brand-name { font-weight: 800; letter-spacing: .02em; }
.brand-sub { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 419px) { .topbar:has(.save-status:not(:empty)) .brand-sub { display: none; } }
.save-status { font-size: .875rem; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.save-status[data-state="saved"] { color: var(--ok); }
.save-status[data-state="offline"], .save-status[data-state="error"] { color: var(--warn); font-weight: 600; }
.save-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.container { max-width: 720px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 16px; margin-bottom: 16px; }
@media (min-width: 600px) { .card { padding: 28px; } .container { padding-top: 32px; } }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.eyebrow { color: var(--muted); font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
.note { background: var(--note-bg); border-radius: 10px; padding: 14px 16px; margin: 16px 0; }
.note ul { margin: 6px 0 0; padding-left: 20px; }
.note li { margin-bottom: 4px; }
.situation { background: var(--surface-2); border-left: 4px solid var(--control); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }

/* Buttons */
.btn {
  appearance: none; font: inherit; font-weight: 600; cursor: pointer;
  min-height: var(--tap); padding: 10px 18px; border-radius: 10px;
  border: 2px solid var(--control); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn:hover { background: var(--surface-2); }
a.btn { text-decoration: none; }
.note .row { margin-top: 10px; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.1); }
.btn-link { border-color: transparent; background: transparent; color: var(--link); text-decoration: underline; padding-left: 8px; padding-right: 8px; }
.btn-danger-outline { border-color: var(--danger); color: var(--text); }
.btn-block { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > .btn { flex: 1 1 auto; }

/* Nav bar under each question */
.qnav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.qnav .next { grid-column: 1 / -1; }
.qnav .btn { padding-left: 8px; padding-right: 8px; }
@media (min-width: 600px) { .qnav { grid-template-columns: auto auto auto 1fr; } .qnav .btn { padding-left: 18px; padding-right: 18px; } .qnav .next { grid-column: auto; justify-self: end; min-width: 160px; } }

/* Progress */
.progress { margin-bottom: 16px; }
.progress-label { display: flex; justify-content: space-between; font-size: .95rem; color: var(--muted); margin-bottom: 6px; }
.progress-label strong { color: var(--text); }
.bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--progress); width: 0; }

/* Forms */
fieldset { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
legend { padding: 0; font-weight: 700; font-size: 1.2rem; margin-bottom: 6px; }
label.field { display: block; font-weight: 600; margin: 16px 0 6px; }
.hint { color: var(--muted); font-size: .95rem; margin: 0 0 12px; }
input[type="text"], input[type="email"], select, textarea {
  font: inherit; color: var(--text); background: var(--input-bg);
  border: 2px solid var(--control); border-radius: 10px; width: 100%; min-height: var(--tap); padding: 10px 12px;
}
textarea { min-height: 110px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

/* Choice options (radio / checkbox) — selection is high contrast and not colour-only. */
.options { display: grid; gap: 10px; margin-top: 12px; }
.opt { position: relative; display: block; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt .opt-box {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 14px;
  border: 2px solid var(--control); border-radius: 10px; background: var(--input-bg); color: var(--text);
}
.opt .mark { width: 24px; height: 24px; flex: none; border: 2px solid var(--control); display: grid; place-items: center; background: var(--surface); }
.opt input[type="radio"] + .opt-box .mark { border-radius: 50%; }
.opt input[type="checkbox"] + .opt-box .mark { border-radius: 6px; }
.opt .mark svg { width: 16px; height: 16px; visibility: hidden; }
.opt:hover .opt-box { border-color: var(--control); }
.opt input:checked + .opt-box { background: var(--sel-bg); color: var(--sel-text); border-color: var(--sel-border); font-weight: 600; }
.opt input:checked + .opt-box .mark { background: var(--sel-mark); border-color: var(--sel-mark); }
.opt input:checked + .opt-box .mark svg { visibility: visible; color: var(--sel-mark-fg); }
.opt input:focus-visible + .opt-box { outline: 3px solid var(--focus); outline-offset: 2px; }
.likert .opt .num { font-variant-numeric: tabular-nums; color: inherit; opacity: .85; min-width: 1ch; }

/* Rank */
.rank-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.rank-item { display: flex; align-items: center; gap: 8px; border: 2px solid var(--sel-border); background: var(--sel-bg); color: var(--sel-text); border-radius: 10px; padding: 6px 8px 6px 12px; }
.rank-item .pos { font-weight: 800; min-width: 1.5em; }
.rank-item .lbl { flex: 1; font-weight: 600; }
.rank-item .btn { min-height: var(--tap); min-width: var(--tap); padding: 6px 10px; background: var(--surface); color: var(--text); border-color: var(--surface); }
@media (max-width: 479px) {
  .rank-item { flex-wrap: wrap; padding: 10px 10px 10px 12px; }
  .rank-item .lbl { flex: 1 1 calc(100% - 2.5em); }
  .rank-item .btn:first-of-type { margin-left: auto; }
}
.rank-pool { display: grid; gap: 8px; }
.rank-pool .btn { justify-content: flex-start; text-align: left; font-weight: 500; }

/* Voice */
.voice { margin-top: 14px; }
.btn-record {
  width: 100%; min-height: 52px; border-radius: 14px; border: 2px solid var(--danger-edge);
  background: var(--danger); color: var(--danger-text); font-size: 1.05rem; font-weight: 700;
}
.btn-record:hover { background: var(--danger-hover); }
.btn-record[disabled] { opacity: 1; background: var(--rec-disabled); color: var(--white); border-color: var(--rec-disabled); }
.btn-record .rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--danger-text); flex: none; }
.voice-helper { color: var(--muted); font-size: .95rem; margin: 6px 0 0; text-align: center; }
.voice-panel { border: 2px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface); }
.voice-panel.recording { border-color: var(--danger); }
.rec-status { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.pulse { width: 16px; height: 16px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
.btn-stop { width: 100%; min-height: 56px; border-radius: 12px; background: var(--text); color: var(--bg); border: 0; font-size: 1.1rem; font-weight: 700; }
.btn-stop .sq { width: 14px; height: 14px; background: currentColor; border-radius: 2px; }
.rec-warning { color: var(--warn); font-weight: 600; margin: 10px 0 0; }
.voice-panel .row + .row { margin-top: 10px; }
.voice-panel .row > .confirm { flex: 1 1 100%; }
.voice-panel audio { width: 100%; margin: 6px 0 10px; }
.voice-meta { color: var(--muted); font-size: .95rem; margin-bottom: 10px; }
.voice-error { background: var(--error-bg); color: var(--error-text); border-radius: 12px; padding: 14px; }
.voice-error p { margin-bottom: 10px; }
.voice-error .btn { background: var(--surface); color: var(--text); }
.confirm { border: 2px solid var(--danger); border-radius: 10px; padding: 12px; margin-top: 10px; }
.saved-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ok); margin-bottom: 6px; }

.alert { background: var(--error-bg); color: var(--error-text); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.summary div { background: var(--surface-2); border-radius: 10px; padding: 12px; text-align: center; }
.summary strong { display: block; font-size: 1.5rem; }

/* Follow-ups */
.followup-badge { display: inline-block; background: var(--note-bg); color: var(--text); border: 1px solid var(--control); border-radius: 99px; padding: 4px 12px; font-size: .9rem; font-weight: 600; margin: 0 0 12px; }

/* Report portal */
.report .summary-text { font-size: 1.05rem; }
.rep-section { margin-top: 20px; }
.rep-section h3 { font-size: 1.1rem; }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.point { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.tag { justify-self: start; font-size: .8rem; font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.tag-fact { background: var(--fact-bg); color: var(--fact-text); }
.tag-hypothesis { background: var(--hyp-bg); color: var(--hyp-text); }
.sources { font-size: .85rem; color: var(--muted); }
.ans-item { border-top: 1px solid var(--border); padding: 14px 0; }
.ans-item:first-of-type { border-top: 0; }
.ans-q { font-weight: 700; margin-bottom: 4px; }
.ans-a { margin-bottom: 4px; }
.ans-c { margin-bottom: 4px; }
.ans-voice audio { width: 100%; margin: 4px 0; }
#report-link { font-size: .95rem; }

/* Analytics consent (shown only when a GTM container is configured) */
.consent-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); color: var(--text); border-top: 2px solid var(--control);
  padding: 16px max(16px, env(safe-area-inset-left)) calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px var(--shadow);
}
.consent-banner > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.consent-banner .consent-title { font-weight: 700; margin-bottom: 4px; }
.consent-banner .row { margin-top: 10px; }
.consent-banner .row > .btn { flex: 1 1 140px; }
.site-footer { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }
.site-footer .btn-link { min-height: var(--tap); padding-left: 0; }

/* Public pages */
.hero h1 { font-size: 1.9rem; }
@media (min-width: 600px) { .hero h1 { font-size: 2.3rem; } }
.lead { font-size: 1.1rem; }
.checks { padding-left: 20px; margin: 0 0 20px; }
.checks li { margin-bottom: 6px; }
.btn-lg { min-height: 56px; font-size: 1.1rem; padding-left: 24px; padding-right: 24px; }
.turnstile-box { margin: 16px 0 4px; min-height: 0; }
.turnstile-box[data-turnstile="off"] { display: none; }
.voice-error { border: 2px solid var(--warn); }

@media print {
  :root { --bg: var(--print-paper); --surface: var(--print-paper); --input-bg: var(--print-paper); --text: var(--print-ink); --muted: var(--print-ink); --border: var(--print-ink); --control: var(--print-ink); }
  .topbar, .no-print, .skip-link, .consent-banner, .site-footer { display: none !important; }
  body { font-size: 11pt; }
  .card { border: 0; padding: 0; margin: 0 0 12pt; }
  .container { max-width: none; padding: 0; }
  .point, .ans-item { break-inside: avoid; }
  a { color: var(--print-ink); text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .pulse { opacity: 1; transform: none; }
}
@media (forced-colors: active) {
  .opt input:checked + .opt-box { outline: 3px solid Highlight; }
  .btn-record .rec-dot { background: ButtonText; }
}

/* Continue my assessment */
.resume-row { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.resume-row p { margin: 0; flex: 1 1 200px; }
.resume-foot { margin: 16px 0 0; }
.resume-row + p, [data-screen="resume"] > p.small:last-child { margin-top: 18px; }
