:root {
  --paper: #f3efe6;
  --panel: #fbf9f4;
  --panel-2: #ebe5d8;
  --ink: #1c2227;
  --ink-2: #4a5259;
  --ink-3: #7b8188;
  --line: #d6cfbf;
  --accent: #d9531e;
  --accent-ink: #fff;
  --teal: #2b6b66;
  --teal-soft: #d8e8e5;
  --warn: #a8641a;
  --warn-soft: #f4e2c8;
  --bad: #a3322a;
  --bad-soft: #f3d6d2;
  --good: #2f7a3e;
  --good-soft: #d7ecd9;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 2px 8px rgba(40,30,10,.06);
  --side-bg: #ebe5d6; --side-ink: #1c2227; --side-ink-2: #5d5a52; --side-line: rgba(0,0,0,.1); --side-hover: rgba(0,0,0,.05); --side-on: rgba(0,0,0,.08); --side-on-ink: #000; --side-ring: #a9a392;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15191c; --panel: #1c2125; --panel-2: #252b30; --ink: #ece7dc; --ink-2: #b9b3a7; --ink-3: #8a857c; --line: #343b41;
    --accent: #f06a33; --teal: #6fb5ad; --teal-soft: #1f3533; --warn: #e3a35a; --warn-soft: #3a2e1d; --bad: #e57a70; --bad-soft: #3d2220; --good: #7cc58a; --good-soft: #1f3424;
    --shadow: 0 1px 0 rgba(0,0,0,.3); color-scheme: dark;
    --side-bg: #0e1113; --side-ink: #d4cec2; --side-ink-2: #a59f92; --side-line: rgba(255,255,255,.08); --side-hover: rgba(255,255,255,.05); --side-on: rgba(255,255,255,.08); --side-on-ink: #fff; --side-ring: #5a5f62;
  }
}
:root[data-theme="dark"] {
  --paper: #15191c; --panel: #1c2125; --panel-2: #252b30; --ink: #ece7dc; --ink-2: #b9b3a7; --ink-3: #8a857c; --line: #343b41;
  --accent: #f06a33; --teal: #6fb5ad; --teal-soft: #1f3533; --warn: #e3a35a; --warn-soft: #3a2e1d; --bad: #e57a70; --bad-soft: #3d2220; --good: #7cc58a; --good-soft: #1f3424;
  --shadow: 0 1px 0 rgba(0,0,0,.3); color-scheme: dark;
  --side-bg: #0e1113; --side-ink: #d4cec2; --side-ink-2: #a59f92; --side-line: rgba(255,255,255,.08); --side-hover: rgba(255,255,255,.05); --side-on: rgba(255,255,255,.08); --side-on-ink: #fff; --side-ring: #5a5f62;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
p { margin: 0 0 .8em; }
.mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }

/* Layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-ink); padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { padding: 0 18px 16px; border-bottom: 1px solid var(--side-line); margin-bottom: 10px; }
.brand b { display: block; font-size: 1.05rem; letter-spacing: .01em; }
.brand span { font-family: var(--mono); font-size: .72rem; color: var(--side-ink-2); text-transform: uppercase; letter-spacing: .1em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 18px; color: var(--side-ink); text-decoration: none; font-size: .92rem; border-left: 3px solid transparent; }
.nav a:hover { background: var(--side-hover); }
.nav a.on { background: var(--side-on); color: var(--side-on-ink); border-left-color: var(--accent); }
.nav .num { font-family: var(--mono); font-size: .72rem; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--side-ring); color: var(--side-ink-2); flex: none; }
.nav .done .num { background: var(--teal); border-color: var(--teal); color: #fff; }
.nav .sub { padding-left: 48px; font-size: .86rem; }
.side .foot { padding: 14px 18px; font-size: .8rem; color: var(--side-ink-2); border-top: 1px solid var(--side-line); margin-top: 10px; }
.side .foot button { background: none; border: 1px solid var(--side-ring); color: var(--side-ink); border-radius: 4px; padding: 3px 8px; cursor: pointer; font-size: .78rem; margin: 4px 4px 0 0; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 8px 20px; flex-wrap: wrap; }
.clock { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clock .time { font-family: var(--mono); font-size: .85rem; background: var(--panel-2); padding: 3px 8px; border-radius: 4px; }
.bar { width: 120px; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 80px; max-width: 1180px; }
.menu-btn { display: none; }

/* Elements */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.tight { padding: 12px 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.btn { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-weight: 500; font-size: .9rem; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.sm { padding: 3px 9px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=number], input:not([type]), select, textarea { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
label.f { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: 4px; }
.pill { display: inline-block; font-family: var(--mono); font-size: .72rem; padding: 1px 7px; border-radius: 10px; background: var(--panel-2); color: var(--ink-2); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.teal { background: var(--teal-soft); color: var(--teal); }
.note { border-left: 3px solid var(--teal); background: var(--teal-soft); padding: 10px 12px; border-radius: 0 6px 6px 0; margin-bottom: 12px; font-size: .92rem; }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 6px; z-index: 50; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* Tables */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; max-height: 520px; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel-2); font-weight: 600; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: rgba(127,127,127,.05); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--ink-2); font-weight: 500; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--ink); }

/* Brief */
.memo { max-width: 680px; font-size: 1.02rem; }
.memo .hdr { font-family: var(--mono); font-size: .82rem; color: var(--ink-2); border-bottom: 1px dashed var(--line); padding-bottom: 10px; margin-bottom: 14px; }

/* Interviews */
.people { display: grid; grid-template-columns: 230px 1fr; gap: 16px; min-height: 560px; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.person { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.person.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.person b { display: block; font-size: .92rem; }
.person span { font-size: .8rem; color: var(--ink-3); }
.chat { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; height: 560px; min-height: 280px; max-height: 95vh; resize: vertical; overflow: hidden; }
.chat .log { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.msg { max-width: 78%; margin-bottom: 10px; padding: 8px 12px; border-radius: 10px; }
.msg.learner { margin-left: auto; background: var(--teal); color: #fff; border-bottom-right-radius: 2px; }
.msg.character { background: var(--panel-2); border-bottom-left-radius: 2px; }
.msg .who { font-size: .72rem; opacity: .7; margin-bottom: 2px; font-family: var(--mono); }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat form input { flex: 1; }

/* Map */
.mapgrid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; }
.cardstep { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; display: flex; gap: 8px; align-items: flex-start; }
.cardstep .meta { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.cardstep.loop { border-style: dashed; border-color: var(--warn); }
.cardstep .grow { flex: 1; }
.lane { counter-reset: s; }
.lane .cardstep { position: relative; }
.lane .cardstep .idx { font-family: var(--mono); font-size: .75rem; background: var(--ink); color: var(--paper); border-radius: 3px; padding: 0 5px; flex: none; }
.arrow { text-align: center; color: var(--ink-3); font-size: .8rem; margin: -2px 0 4px; }

/* Build */
.sys { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; background: var(--panel); }
.sys > .head { background: var(--panel-2); padding: 8px 14px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; }
.sys > .head .crumb { font-family: var(--mono); font-size: .75rem; color: var(--ink-3); font-weight: 400; }
.sys > .body { padding: 14px; }
.rule { display: grid; grid-template-columns: 240px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }

/* Score */
.score-big { font-size: 3rem; font-weight: 600; font-family: var(--mono); line-height: 1; }
.meter { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--teal); }
.kpi-table td.up { color: var(--good); }
.kpi-table td.down { color: var(--bad); }

.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 30; display: flex; flex-direction: column; box-shadow: -6px 0 24px rgba(0,0,0,.12); }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer textarea { flex: 1; border: none; border-radius: 0; padding: 16px; font-family: var(--mono); font-size: .85rem; background: var(--panel); }

.login { max-width: 460px; margin: 10vh auto; padding: 0 16px; }
.login .card { padding: 28px; }
pre.code { background: var(--panel-2); padding: 10px 12px; border-radius: 6px; overflow: auto; font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; }
  .content { padding: 16px 16px 80px; }
  .grid2, .grid3, .mapgrid, .people { grid-template-columns: 1fr; }
  .rule { grid-template-columns: 1fr; }
  .people { min-height: 0; }
  .plist { flex-direction: row; overflow-x: auto; }
  .person { min-width: 160px; }
}

/* Sign-in */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-top { width: min(1080px, 100%); margin-inline: auto; padding: 16px clamp(16px, 5vw, 48px); }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); text-decoration: none; }
.auth-logo { width: 24px; height: 24px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='6' fill='%23d9531e'/%3E%3Cg fill='white'%3E%3Crect x='5' y='10' width='22' height='5'/%3E%3Crect x='7' y='15' width='4' height='11'/%3E%3Crect x='21' y='15' width='4' height='11'/%3E%3Crect x='11' y='20' width='10' height='3'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; }
.auth-main { width: min(1080px, 100%); margin-inline: auto; padding: clamp(16px, 5vw, 56px) clamp(16px, 5vw, 48px) 56px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(24px, 6vw, 72px); align-items: center; flex: 1; }
.auth-kicker { font-family: var(--mono); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); margin: 0 0 14px; }
.auth-brief h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 18px; }
.auth-lede { font-size: 1.1rem; color: var(--ink-2); max-width: 46ch; margin: 0 0 22px; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; color: var(--ink-2); }
.auth-points li { padding-left: 26px; position: relative; }
.auth-points li::before { content: ""; position: absolute; left: 0; top: .35em; width: 14px; height: 14px; border-radius: 50%; background: var(--teal-soft); border: 2px solid var(--teal); }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: clamp(20px, 4vw, 32px); box-shadow: 0 10px 30px rgba(0,0,0,.10); }
.auth-card h2 { font-size: 1.5rem; margin: 0 0 16px; letter-spacing: -.01em; }
.auth-form { display: grid; gap: 6px; }
.auth-form label:not(.auth-consent) { font-size: .85rem; font-weight: 600; margin-top: 8px; }
.auth-form input:not([type=checkbox]) { padding: 11px 12px; font-size: 1rem; width: 100%; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; }
.auth-form input:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.auth-consent { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-size: .92rem; cursor: pointer; }
.auth-consent input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.auth-more { font-size: .85rem; color: var(--ink-2); margin: 2px 0 6px 28px; }
.auth-more summary { cursor: pointer; color: var(--teal); }
.auth-more p { margin: 6px 0 0; }
.auth-form .btn.lg { width: 100%; padding: 12px; font-size: 1rem; margin-top: 10px; }
.auth-form .btn:disabled { opacity: .45; cursor: not-allowed; }
.auth-hint { min-height: 1.3em; margin: 4px 0 0; font-size: .85rem; color: var(--ink-3); text-align: center; }
.auth-return { margin: 8px 0 0; text-align: center; }
.auth-envelope { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--teal-soft); color: var(--teal); margin-bottom: 12px; }
@media (max-width: 820px) { .auth-main { grid-template-columns: 1fr; } .auth-brief { order: 0; } }

/* Light/dark switch (same control as the landing pages), in the sidebar foot. */
.tsw { position: relative; display: block; width: 62px; height: 32px; padding: 0; margin: 10px 0 8px; border-radius: 16px; border: 1px solid var(--side-ring); background: var(--panel-2); cursor: pointer; transition: background-color .3s, border-color .3s; }
.tsw-hint { position: absolute; top: 7px; width: 16px; height: 16px; display: grid; place-items: center; color: var(--ink-3); opacity: .75; }
.tsw-hint-sun { left: 8.5px; }
.tsw-hint-moon { right: 8.5px; }
.tsw svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tsw-hint-moon svg, .tsw-k-moon svg { fill: currentColor; stroke: none; }
.tsw-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .38s cubic-bezier(.34, 1.56, .64, 1); }
.tsw-k { position: absolute; inset: 4px; display: grid; place-items: center; transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), opacity .25s; }
.tsw-k-sun { color: var(--accent); }
.tsw-k-moon { color: var(--ink); opacity: 0; transform: rotate(-90deg) scale(.4); }
.tsw[aria-checked="true"] .tsw-knob { transform: translateX(30px); }
.tsw[aria-checked="true"] .tsw-k-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
.tsw[aria-checked="true"] .tsw-k-moon { opacity: 1; transform: none; }
.tsw:hover .tsw-knob { box-shadow: 0 1px 3px rgba(0,0,0,.25), 0 0 0 4px rgba(127,127,127,.15); }
.tsw:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
/* The sidebar's generic button rule is more specific than .tsw, so restate the switch's shape here. */
.side .foot .tsw { width: 62px; height: 32px; padding: 0; margin: 12px 0 10px; border: 1px solid var(--side-ring); border-radius: 16px; background: var(--panel-2); font-size: 0; }
.side .foot .signout { display: block; margin: 0; }
@media (prefers-reduced-motion: reduce) { .tsw, .tsw-knob, .tsw-k { transition: none; } }

.auth-ts { min-height: 65px; margin-top: 12px; display: flex; justify-content: center; }

/* Help */
.help-fab { position: fixed; right: 18px; bottom: 18px; z-index: 45; display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 10px 10px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px rgba(217,83,30,.4); transition: transform .15s, right .2s; }
.help-fab:hover { transform: scale(1.05); }
.help-fab:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.help-q { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.22); font-weight: 700; }
.drawer.help { z-index: 40; }
.help-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.hb { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: .94rem; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.hb.bot { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.hb.bot.wait { color: var(--ink-3); letter-spacing: .2em; }
.hb.bot.err { background: var(--bad-soft); color: var(--bad); }
.hb.me { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.hb.me.note { background: var(--accent); }
.hb.me.note::before { content: "Note to the builder"; display: block; font: 500 .66rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; opacity: .85; margin-bottom: 5px; }
.hb.flag { align-self: flex-start; background: var(--warn-soft); color: var(--warn); font-size: .84rem; }
.help-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.help-form { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.help-form[hidden], .help-chips[hidden], .help-link[hidden] { display: none; }
.drawer.help textarea { flex: none; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--sans); font-size: .95rem; resize: none; background: var(--paper); }
.help-link { background: none; border: 0; padding: 6px 16px 14px; color: var(--teal); font-size: .85rem; cursor: pointer; text-align: left; }
.help-link:hover { text-decoration: underline; }
@media (max-width: 600px) { .help-label { display: none; } .help-fab { padding: 10px; } }
/* When a drawer (Notebook or Help) is open, the Help button moves out of its way instead of hiding under it. */
body:has(.drawer) .help-fab { right: calc(min(420px, 100vw) + 18px); }
@media (max-width: 600px) { body:has(.drawer) .help-fab { display: none; } }
