:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #17202b; --muted: #5d6b7a; --line: #e2e6eb;
  --accent: #1f6feb; --accent-ink: #ffffff; --ok: #1a7f37; --ok-bg: #e6f4ea; --warn: #9a6700; --warn-bg: #fff4d6;
  --bad: #cf222e; --bad-bg: #ffebe9; --lock: #8a94a0; --lock-bg: #eef0f3; --info-bg: #e8f0fe;
  --term-bg: #0d1117; --radius: 10px; --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1117; --panel: #161b22; --ink: #e6edf3; --muted: #8d96a0; --line: #2a313c;
    --accent: #4493f8; --ok: #3fb950; --ok-bg: #12261a; --warn: #d29922; --warn-bg: #2b2111; --bad: #f85149;
    --bad-bg: #2d1416; --lock: #6e7681; --lock-bg: #1c2129; --info-bg: #13233d; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
header.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .brand { font-weight: 700; letter-spacing: .2px; color: var(--ink); }
header.top .brand span { color: var(--accent); font-family: var(--mono); }
header.top nav { display: flex; gap: 14px; flex: 1; }
header.top .who { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
main.wide { max-width: 1400px; }
h1 { font-size: 24px; margin: 0 0 6px; } h2 { font-size: 18px; margin: 28px 0 10px; } h3 { font-size: 15px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none !important; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); } .btn.small { padding: 3px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }
textarea { width: 100%; min-height: 90px; font-family: var(--mono); font-size: 13px; }
form.inline { display: inline; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-complete, .s-pass, .s-green { background: var(--ok-bg); color: var(--ok); }
.s-waived { background: var(--info-bg); color: var(--accent); }
.s-in_progress, .s-partial, .s-submitted { background: var(--warn-bg); color: var(--warn); }
.s-available { background: var(--info-bg); color: var(--accent); }
.s-locked, .s-not_checked, .s-fail { background: var(--lock-bg); color: var(--lock); }
.progress { height: 8px; background: var(--lock-bg); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.todo { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel); }
.todo > summary { list-style: none; cursor: pointer; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.todo > summary::-webkit-details-marker { display: none; }
.todo .id { font-family: var(--mono); color: var(--muted); width: 26px; }
.todo .title { flex: 1; font-weight: 600; }
.todo .body { padding: 0 14px 12px 48px; }
.rule { display: flex; gap: 8px; padding: 2px 0; font-size: 14px; }
.rule .mk { width: 16px; flex: none; } .rule.ok .mk { color: var(--ok); } .rule.no .mk { color: var(--bad); }
.hint { color: var(--muted); font-size: 13px; margin-left: 24px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--info-bg); margin-bottom: 14px; font-size: 14px; }
.notice.warn { background: var(--warn-bg); } .notice.ok { background: var(--ok-bg); }
.matrix td, .matrix th { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
pre.actions { white-space: pre-wrap; margin: 6px 0; font-family: inherit; font-size: 14px; }
/* terminal page */
body.term { overflow: hidden; }
.term-layout { display: grid; grid-template-columns: 1fr 340px; height: calc(100vh - 49px); }
.term-main { display: flex; flex-direction: column; background: var(--term-bg); min-width: 0; }
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; background: #010409; }
.tab { padding: 6px 12px; color: #8d96a0; background: #0d1117; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.tab.active { color: #e6edf3; background: var(--term-bg); box-shadow: inset 0 2px 0 var(--accent); }
.tab .x { color: #6e7681; } .tab .x:hover { color: #f85149; }
.tab.add { background: transparent; }
.panes { flex: 1; position: relative; }
.pane { position: absolute; inset: 0; padding: 6px 4px 4px 10px; display: none; } .pane.active { display: block; }
.term-side { border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 14px; }
.term-side .todo-mini { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 13.5px; }
.term-status { position: absolute; top: 10px; right: 14px; color: #8d96a0; font-size: 12px; font-family: var(--mono); z-index: 2; }
@media (max-width: 860px) { .term-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } .term-side { max-height: 34vh; } }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 14px; display: none; z-index: 10; max-width: 360px; }
.login-box { max-width: 400px; margin: 8vh auto; text-align: center; }
.login-box .card { text-align: left; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.stack input { width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.card.hero { border-color: var(--accent); }
ol.chapters { list-style: none; padding: 0; margin: 0 0 8px; }
ol.chapters li a { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 6px; background: var(--panel); color: inherit; text-decoration: none !important; }
ol.chapters li a:hover { border-color: var(--accent); }
ol.chapters li.locked a { opacity: .6; }
ol.chapters li.in_progress a, ol.chapters li.available a { border-color: var(--accent); }
ol.chapters .num { font-family: var(--mono); color: var(--muted); width: 36px; }
ol.chapters .ttl { flex: 1; font-weight: 600; }
.quiz fieldset { border: 1px solid var(--line); }
.quiz legend { font-weight: 600; padding: 0 6px; }
.quiz legend .num { color: var(--muted); font-family: var(--mono); margin-right: 4px; }
.quiz .opt { display: flex; gap: 10px; align-items: flex-start; padding: 6px 4px; cursor: pointer; }
.quiz .opt:hover { background: var(--info-bg); border-radius: 6px; }
.quiz .opt input { margin-top: 4px; }
/* the case */
.building { margin-top: 26px; }
.building.locked h2, .building.locked .chapters { opacity: .75; }
.card.brief { border-left: 4px solid var(--accent); }
.card.casefile { border-left: 4px solid var(--warn); }
.casefile .clue { padding: 8px 0; border-bottom: 1px solid var(--line); }
.casefile .clue:last-child { border-bottom: 0; padding-bottom: 0; }
.casefile .clue:first-child { padding-top: 0; }
.cast { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 8px 0 0; font-size: 14.5px; }
.cast dt { font-weight: 600; } .cast dd { margin: 0; }
.cast .update { margin-top: 4px; color: var(--warn); }
.words { font-size: 14.5px; } .words dt { color: var(--ink); font-weight: 600; } .words dd { font-family: inherit; }
ul.plain { margin: 8px 0 0; padding-left: 20px; } ul.plain li { margin: 4px 0; }
@media (max-width: 600px) { .cast, .words { grid-template-columns: 1fr; gap: 2px 0; } .cast dd, .words dd { margin-bottom: 8px; } }
