/* Johnny Learning OS — the dojo. One committed look: ink ground, rice-paper text, vermilion for actions
   (direction A, "ink and vermilion"). Headings and the oath are set in a serif; everything else in the system font. */
:root {
  color-scheme: dark;
  --page: #121110;             /* ink */
  --surface: #1b1a18;
  --surface-2: #242320;
  --surface-3: #2c2b28;
  --hairline: rgba(255, 255, 255, 0.09);
  --grid: #2c2b28;
  --axis: #3f3d38;
  --ink: #ece6d8;              /* rice paper */
  --ink-2: #c9c2b2;
  --muted: #9a9384;
  --accent: #c8402c;           /* vermilion: actions and the one highlight, never decoration */
  --accent-strong: #b03322;
  --accent-soft: rgba(200, 64, 44, 0.16);
  --accent-ink: #e8a394;       /* vermilion as text on a dark surface */
  --gold: #d2a23a;             /* the second warm tone */
  --good: #3f8f5a;             /* jade */
  --good-ink: #7cc48f;
  --warn: #d2a23a;             /* ochre */
  --serious: #c97a4a;
  --critical: #a8503f;         /* the result red: brick, kept apart from the vermilion */
  --flame: #d26a3a;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 28px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Noto Serif", "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  /* sequential, dark mode: near-surface -> vermilion -> pale */
  --seq-0: #242320;
  --seq-1: #5a2a20;
  --seq-2: #8a3526;
  --seq-3: #c8402c;
  --seq-4: #e8a394;
}

/* Chinese pages lead with a CJK serif so Han glyphs and the Latin inside Chinese text come from one face. */
html[lang^="zh"] { --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, "Noto Serif", Georgia, serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: radial-gradient(900px 420px at 50% -10%, rgba(200, 64, 44, 0.07), transparent 60%), var(--page);
  min-height: 100vh;
}
img, svg { max-width: 100%; }
a { color: #d9b38c; text-underline-offset: 3px; }
a:hover { color: #ecd3b4; }
code { overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.88em; background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--ink-2); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: 0; font-family: var(--serif); font-weight: 700; }
h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h2 { font-size: 1.08rem; }
h3 { font-size: 1.15rem; }
p { margin: 0.4rem 0; }
[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; }
.muted { color: var(--ink-2); }
.small { font-size: 0.84rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; font-weight: 700; color: var(--muted); margin: 0 0 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px clamp(14px, 3vw, 32px);
  background: rgba(18, 17, 16, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
.brand-mark, .login-mark {
  display: grid; place-items: center; width: 30px; height: 30px; font-weight: 700; color: #fff;
  font-family: var(--serif); font-size: 1.05rem; background: var(--accent); border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 0.92rem; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-3); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.login-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.shell { max-width: 1180px; margin: 0 auto; padding: clamp(14px, 3vw, 28px) clamp(14px, 3vw, 32px) 64px; }

/* ---- cards & layout ---- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 40%), var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: clamp(14px, 2.4vw, 22px);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.room-grid, .session-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.two-col .card + .card { margin-top: 0; }
.room-side .card + .card, .session-side .card + .card { margin-top: 16px; }
@media (max-width: 880px) {
  .room-grid, .session-grid, .two-col { grid-template-columns: minmax(0, 1fr); }
}

/* ---- buttons & forms ---- */
.btn {
  --btn-bg: var(--surface-3); --btn-ink: var(--ink); --btn-ring: var(--hairline);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px; border-radius: var(--radius); border: 0;
  background: var(--btn-bg); color: var(--btn-ink); box-shadow: inset 0 0 0 1px var(--btn-ring);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { filter: brightness(1.12); color: var(--btn-ink); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: 0.55; cursor: progress; }
.btn-primary { --btn-bg: var(--accent); --btn-ink: #fff; --btn-ring: rgba(255, 255, 255, 0.28); }
.btn-secondary { --btn-bg: var(--surface-3); }
.btn-ghost { --btn-bg: transparent; --btn-ink: var(--ink-2); }
.btn-good { --btn-bg: rgba(63, 143, 90, 0.22); --btn-ring: rgba(124, 196, 143, 0.45); }
.btn-bad { --btn-bg: rgba(168, 80, 63, 0.22); --btn-ring: rgba(232, 163, 148, 0.45); }
.btn-xl { min-height: 52px; padding: 12px 20px; font-size: 1.02rem; border-radius: var(--radius); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.86rem; }
.btn-xs { min-height: 26px; padding: 2px 8px; font-size: 0.78rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.btn-row .spacer { flex: 1; }
.divider-top { border-top: 1px solid var(--hairline); padding-top: 12px; margin-top: 16px; }

.field { display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-2); min-width: 0; }
.field-inline { min-width: min(320px, 100%); }
.problem-switch { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.problem-switch select { min-width: 0; max-width: 100%; flex: 1 1 220px; }
.mission-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.mission-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--grid); padding-top: 8px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--hairline); border-radius: var(--radius); padding: 9px 11px; min-height: 40px; width: 100%;
  max-width: 100%; min-width: 0; text-overflow: ellipsis;
}
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.stack { display: grid; gap: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.span-2 { grid-column: span 2; }
.form-error { color: var(--accent-ink); margin: 0; }
.inline-details { margin-top: 14px; }
.inline-details summary, .table-view summary { cursor: pointer; color: var(--ink-2); font-size: 0.88rem; }

/* ---- chips & pills ---- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--radius-sm); font-size: 0.74rem; font-weight: 600; background: var(--surface-3); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--hairline); text-transform: lowercase; white-space: nowrap; }
.chip-good, .chip-solved, .chip-completed, .chip-easy { color: #a9dfb6; background: rgba(63, 143, 90, 0.2); }
.chip-warn, .chip-medium, .chip-pending, .chip-offered { color: #e4bf63; background: rgba(210, 162, 58, 0.18); }
.chip-failed, .chip-abandoned, .chip-hard { color: #e8a394; background: rgba(168, 80, 63, 0.22); }
.chip-accepted, .chip-partial { color: var(--accent-ink); background: var(--accent-soft); }
.xp-pill { font-weight: 700; font-size: 0.8rem; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; }

/* ---- HUD ---- */
.hud { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 12px; }
.hud-tile > div { min-width: 0; }
.hud-tile .chip { white-space: normal; }
@media (max-width: 1180px) { .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hud-level { grid-column: span 2; } }
@media (max-width: 640px) { .hud { grid-template-columns: minmax(0, 1fr); } .hud-level { grid-column: auto; } }
.hud-level, .hud-tile {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.level-badge {
  flex: none; width: 84px; height: 84px; display: grid; place-content: center; text-align: center; color: #fff;
  background: var(--accent); border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), inset 0 0 0 4px var(--accent), inset 0 0 0 5px rgba(255, 255, 255, 0.35);
}
.level-label { font-size: 0.7rem; letter-spacing: 0.2em; font-weight: 800; opacity: 0.85; }
.level-value { font-size: 2.3rem; font-weight: 700; line-height: 1; font-family: var(--serif); }
.hud-xp { flex: 1; min-width: 0; display: grid; gap: 8px; }
.hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.xpbar { height: 10px; border-radius: 3px; background: var(--surface-3); overflow: hidden; box-shadow: inset 0 0 0 1px var(--hairline); }
.xpbar-fill { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent-strong), var(--gold)); transition: width 0.8s cubic-bezier(.2, .8, .2, 1); }
.stat-inline { color: var(--ink-2); font-size: 0.9rem; }
.stat-inline strong { color: var(--ink); font-size: 1.05rem; }
.stat-inline.is-good strong { color: var(--good-ink); }
.hud-icon { font-size: 1.5rem; filter: saturate(1.1); }
.hud-big { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-family: var(--serif); }
.hud-big .unit { font-size: 0.95rem; font-weight: 600; color: var(--ink-2); }
a.hud-tile { color: var(--ink); text-decoration: none; }
a.hud-tile:hover { color: var(--ink); filter: brightness(1.08); }
.readiness.is-up { box-shadow: var(--shadow), inset 0 0 0 1px rgba(124, 196, 143, 0.35); }
.readiness.is-down { box-shadow: var(--shadow), inset 0 0 0 1px rgba(201, 122, 74, 0.45); }
.streak.is-secured { box-shadow: var(--shadow), inset 0 0 0 1px rgba(124, 196, 143, 0.35); }
.streak.is-at-risk { box-shadow: var(--shadow), inset 0 0 0 1px rgba(210, 162, 58, 0.45); }
.streak.is-at-risk .hud-icon { animation: flicker 1.6s ease-in-out infinite; }
@keyframes flicker { 50% { opacity: 0.55; transform: scale(0.94); } }

/* ---- Ready Room cards ---- */
.cta { background: var(--surface); }
.cta h2 { font-size: 1.35rem; margin-bottom: 10px; }
.start-form { display: grid; gap: 12px; margin-top: 8px; }
.start-form .btn-xl { justify-self: start; }
.mission-name { margin: 2px 0 6px; font-size: 1.2rem; }
.mission-objective { color: var(--ink); background: var(--surface-2); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 0 var(--radius) var(--radius) 0; white-space: pre-line; }
.win-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.anki-group { border-top: 1px solid var(--grid); padding: 8px 0 4px; }
.anki-group summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.anki-group-title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.anki-card-list { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
.anki-card { display: grid; gap: 4px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.anki-front { white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.anki-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.anki-due-now { color: var(--warn); font-weight: 600; }
.win { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--hairline); }
.win:last-child { border-bottom: 0; }
.win-icon { font-size: 1.3rem; }
.win-body { flex: 1; min-width: 0; }
.win-title { font-weight: 600; overflow-wrap: anywhere; }
.buff-mini { margin-left: 4px; }

.buff-grid { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.buff-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.buff {
  --glow: var(--accent);
  position: relative; display: grid; justify-items: center; gap: 4px; text-align: center;
  padding: 14px 8px 10px; border-radius: 12px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--hairline); color: var(--muted); cursor: help;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.buff-list .buff { grid-template-columns: auto 1fr auto; justify-items: start; text-align: left; padding: 10px 12px; align-items: center; }
.buff .buff-icon { font-size: 1.7rem; filter: grayscale(1) opacity(0.35); transition: filter 0.2s ease; }
.buff-list .buff .buff-icon { font-size: 1.3rem; }
.buff .buff-name { font-size: 0.8rem; font-weight: 600; }
.buff.is-active { color: var(--ink); background: radial-gradient(120px 80px at 50% 0, color-mix(in srgb, var(--glow) 28%, transparent), transparent 80%), var(--surface-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glow) 55%, transparent), 0 0 22px color-mix(in srgb, var(--glow) 25%, transparent); }
.buff.is-active .buff-icon { filter: none; }
.buff:hover { transform: translateY(-2px); }
.buff-stacks { position: absolute; top: 6px; right: 8px; font-size: 0.72rem; font-weight: 800; color: var(--ink); }
.buff-list .buff-stacks { position: static; }
/* identity per category (categorical dark slots) — never on text */
.cat-focus { --glow: #d2a23a; }
.cat-recall { --glow: #b8956a; }
.cat-momentum { --glow: #199e70; }
.cat-feedback { --glow: #d95926; }
.cat-practice { --glow: #c98500; }
.cat-explain { --glow: #d55181; }
.cat-memory { --glow: #199e70; }
.cat-combo { --glow: #e66767; }

/* ---- readiness ---- */
.mult { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; padding: 2px 10px; border-radius: var(--radius-sm); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--hairline); }
.mult.is-up, .stat-readiness.is-up .stat-value { color: var(--good-ink); }
.mult.is-down, .stat-readiness.is-down .stat-value { color: var(--serious); }
.effect-list, .suggestion-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.effect, .suggestion-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.effect.is-buff { box-shadow: inset 3px 0 0 var(--good), inset 0 0 0 1px var(--hairline); }
.effect.is-debuff { box-shadow: inset 3px 0 0 var(--serious), inset 0 0 0 1px var(--hairline); }
.effect-icon { font-size: 1.25rem; }
.effect-body { display: grid; gap: 2px; min-width: 0; justify-items: start; }
.effect-name { font-weight: 600; }
.effect-advice { font-size: 0.8rem; color: var(--ink-2); }
.effect-mult, .effect-gain { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.effect.is-buff .effect-mult, .effect-gain { color: var(--good-ink); }
.effect.is-debuff .effect-mult { color: var(--serious); }
.suggestion-list li { background: transparent; box-shadow: inset 0 0 0 1px var(--hairline); }
.suggest-head { margin-top: 14px; }
.suggestion-list .effect-body { gap: 6px; }
.suggest-form { display: flex; gap: 6px; align-items: center; justify-self: stretch; }
.suggest-form input { min-height: 30px; padding: 4px 8px; font-size: 0.85rem; }
.suggest-form input[type="number"] { flex: 0 1 6rem; }
.start-prep-fields { display: grid; gap: 10px; margin-top: 10px; }
.formula { margin: 10px 0 0; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.86rem; color: var(--ink-2); overflow-wrap: anywhere; }
.readiness-form { display: grid; gap: 12px; margin-top: 8px; }
.checkin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-stack { display: grid; gap: 8px; }
.choice-group { border: 1px solid var(--hairline); border-radius: 10px; padding: 8px 12px 10px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; min-width: 0; }
.choice-group legend { color: var(--ink-2); font-size: 0.85rem; padding: 0 4px; }
.inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.inline-form .btn { grid-column: span 2; justify-self: start; }
.readiness-form > .btn { justify-self: start; }
.report-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.report-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.report-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.today-methods .chip { text-transform: none; margin: 2px 2px 0 0; }

/* ---- Session ---- */
.session-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.session-title { font-size: clamp(1.3rem, 3vw, 1.7rem); overflow-wrap: anywhere; }
.session-title .muted { font-size: 0.7em; font-weight: 500; }
.session-stats { display: flex; gap: 10px; }
.stat { display: grid; justify-items: center; min-width: 84px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.stat-value { font-size: 1.35rem; font-weight: 800; }
.stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(200, 64, 44, 0.7); animation: pulse 1.8s infinite; margin-right: 4px; vertical-align: middle; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(200, 64, 44, 0); } 100% { box-shadow: 0 0 0 0 rgba(200, 64, 44, 0); } }
.console-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 10px; margin-top: 10px; }
.console-block { display: grid; gap: 6px; align-content: start; }
.state-line { margin-top: 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 560px; overflow: auto; }
.tl-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--hairline); }
.tl-item.is-voided .tl-label { text-decoration: line-through; color: var(--muted); }
.tl-main { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; min-width: 0; }
.tl-label { font-weight: 600; }
.tl-side { display: flex; align-items: center; gap: 6px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 8px; border-bottom: 1px solid var(--axis); }
.table td { padding: 8px; border-bottom: 1px solid var(--grid); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact td { padding: 5px 8px; }
.table tr.is-next td { color: var(--ink); font-weight: 700; }
.table tr.is-done td { color: var(--muted); }
.table-view { margin-top: 10px; }

/* ---- progress ---- */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; box-shadow: inset 0 0 0 1px var(--hairline); }
.segmented a { padding: 6px 14px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: 0.88rem; }
.segmented a[aria-current="true"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--hairline); }
.tile-label { font-size: 0.8rem; color: var(--ink-2); }
.tile-value { font-size: 1.9rem; font-weight: 650; line-height: 1.15; }
.tile-sub { font-size: 0.78rem; color: var(--muted); }
.chart-scroll { overflow-x: auto; }
.chart { width: 100%; min-width: 520px; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.baseline { stroke: var(--axis); }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .mark { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: rgba(255, 255, 255, 0.05); }
.heatmap { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 14px); gap: 3px; font-size: 10px; color: var(--muted); padding-top: 0; }
.heat-weeks { display: flex; gap: 3px; }
.heat-week { display: grid; grid-template-rows: repeat(7, 14px); gap: 3px; }
.heat-cell { width: 14px; height: 14px; border-radius: 3px; background: var(--seq-0); display: inline-block; }
.heat-cell.is-blank { background: transparent; }
.heat-cell.lvl-1 { background: var(--seq-1); }
.heat-cell.lvl-2 { background: var(--seq-2); }
.heat-cell.lvl-3 { background: var(--seq-3); }
.heat-cell.lvl-4 { background: var(--seq-4); }
.heat-cell[tabindex]:hover, .heat-cell[tabindex]:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 11rem) 1fr 2.5rem; align-items: center; gap: 10px; font-size: 0.88rem; }
.bar-track { height: 12px; }
.bar-fill { display: block; height: 100%; width: 0; min-width: 0; background: var(--accent); border-radius: 0 4px 4px 0; transition: width 0.6s ease; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---- patterns ---- */
.pattern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; margin-bottom: 16px; }
.pattern-grid .card + .card { margin-top: 0; }
.pattern-desc { white-space: pre-line; }
.problem-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.problem-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; border-top: 1px solid var(--hairline); padding-top: 6px; overflow-wrap: anywhere; }

/* ---- login / empty ---- */
.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(400px, 100%); text-align: left; }
.login-mark { width: 52px; height: 52px; font-size: 1.4rem; margin-bottom: 14px; }
.login h1 { margin-bottom: 16px; }
.empty-state { text-align: center; padding: 40px 20px; }

/* ---- toasts & tooltip ---- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface-3); color: var(--ink); border-radius: 12px; padding: 12px 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--hairline); animation: toast-in 0.25s ease-out; }
.toast.is-reward { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(232, 163, 148, 0.5), 0 0 30px rgba(200, 64, 44, 0.25); }
.toast.is-levelup { background: var(--accent-strong); color: #fff; font-weight: 700; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--gold); }
.toast.is-error { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(232, 163, 148, 0.6); }
.toast-title { font-weight: 700; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.tooltip { position: fixed; z-index: 60; pointer-events: none; max-width: 280px; background: var(--surface-3); color: var(--ink); font-size: 0.8rem; padding: 7px 10px; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--hairline); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 560px) {
  .topbar { gap: 10px; flex-wrap: wrap; }
  .brand-text { display: none; }
  .grid-form, .checkin-grid, .inline-form { grid-template-columns: 1fr; }
  .inline-form .btn { grid-column: auto; }
  .session-stats { flex-wrap: wrap; }
  .span-2 { grid-column: auto; }
  .session-stats { width: 100%; }
  .stat { flex: 1; min-width: 0; }
  .bar-row { grid-template-columns: minmax(100px, 8rem) 1fr 2rem; }
}

/* ---- review: today's tasks, results, receipts, the NeetCode 150 roadmap ---- */
.review-today .card-head h2, .review-attention .card-head h2 { font-size: 1.2rem; }
.sync-line { display: grid; gap: 4px; margin-bottom: 4px; }
.sync-line p { margin: 0; }
.notice { padding: 9px 12px; border-radius: var(--radius); background: rgba(210, 162, 58, 0.10); box-shadow: inset 0 0 0 1px rgba(210, 162, 58, 0.35); color: #e4bf63; }
.task-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.task { display: grid; gap: 6px; padding: 12px 12px 10px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); min-width: 0; }
.task.is-done { background: var(--surface-2); }
.task-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.task-title { overflow-wrap: anywhere; min-width: 0; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.task-bug { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.task-feedback { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--hairline); }
.kind-chip { text-transform: none; }
.supplementary-due summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.kind-chip.is-redo { color: var(--accent-ink); background: var(--accent-soft); }
.kind-chip.is-new { color: #e4bf63; background: rgba(210, 162, 58, 0.18); }

/* results are colour AND words, never colour alone */
.result-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.result-dot.dot-red, .is-red > .result-dot { background: var(--critical); }
.result-dot.dot-yellow, .is-yellow > .result-dot { background: var(--warn); }
.result-dot.dot-green, .is-green > .result-dot { background: var(--good-ink); }
.result-chip { text-transform: none; }
.result-chip.is-red { color: var(--accent-ink); background: rgba(168, 80, 63, 0.22); }
.result-chip.is-yellow { color: #e4bf63; background: rgba(210, 162, 58, 0.18); }
.result-chip.is-green { color: #a9dfb6; background: rgba(63, 143, 90, 0.2); }
.sync-chip { text-transform: none; }
.sync-chip.is-pending { color: #e4bf63; background: rgba(210, 162, 58, 0.18); }
.sync-chip.is-failed { color: var(--accent-ink); background: rgba(168, 80, 63, 0.22); }
.sync-chip.is-synced { color: #a9dfb6; background: rgba(63, 143, 90, 0.2); }
.sync-chip.is-conflict { color: #e9b48f; background: rgba(201, 122, 74, 0.2); }

.review-form { display: grid; gap: 10px; }
.review-form h3 { margin: 0; color: var(--ink-2); }
.result-picker { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; min-width: 0; }
.result-option { --c: var(--hairline); position: relative; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hairline); cursor: pointer; min-width: 0; }
.result-option.is-red { --c: var(--critical); }
.result-option.is-yellow { --c: var(--warn); }
.result-option.is-green { --c: var(--good-ink); }
.result-option.is-incomplete { --c: var(--accent); }
.result-option.is-incomplete > .result-dot { background: var(--accent); }
.result-option input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.result-option .opt-text { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.result-option:has(input:checked) { box-shadow: inset 0 0 0 2px var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.result-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.result-option.is-disabled { opacity: 0.4; cursor: not-allowed; }
.result-option.is-disabled input { cursor: not-allowed; }
.review-form textarea { min-height: 64px; resize: vertical; }
.review-form button[type="submit"] { justify-self: start; }

.receipt { display: grid; gap: 4px; min-width: 0; }
.receipt p { margin: 0; }
.receipt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.receipt-title { overflow-wrap: anywhere; min-width: 0; }
.receipt-detail { color: var(--ink-2); overflow-wrap: anywhere; }
.receipt .btn-row { margin-top: 4px; }

.course-summary { display: grid; gap: 8px; }
.course-summary .card-head { margin-bottom: 0; }
.course-summary h3 { font-size: 1rem; }
.course-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--hairline); }
.course-bar .seg { display: block; height: 100%; width: 0; flex: none; transition: width 0.6s ease; }
.seg-red { background: var(--critical); }
.seg-yellow { background: var(--warn); }
.seg-green { background: var(--good); }
.seg-unrated { background: var(--seq-3); }
.course-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); }
.course-legend li { display: inline-flex; align-items: center; gap: 6px; }
.course-legend strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.topic { border-top: 1px solid var(--grid); padding: 8px 0 4px; }
.topic summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; }
.topic-title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.member-list { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
.member { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.member.status-new { background: transparent; }
.member-main { min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.member-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 8px; }
@media (max-width: 640px) {
  .member { grid-template-columns: minmax(0, 1fr); }
  .member-meta { justify-content: flex-start; }
  .result-picker { grid-template-columns: minmax(0, 1fr); }
  .task-actions .btn { flex: 1 1 auto; }
}

/* ---- the dojo: oath, seal, merit, breaking the problem, leaving ---- */
.oath { margin: 0; padding: 6px 0 6px 20px; border-left: 3px solid var(--accent); font-family: var(--serif); font-size: 1.25rem; line-height: 1.9; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
.oath.is-closing { font-size: 1.12rem; }
.ritual-hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 2px; }
.btn-seal { --btn-bg: var(--accent); --btn-ink: #fff; font-family: var(--serif); font-weight: 700; letter-spacing: 0.2em; padding-left: 26px; padding-right: 22px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28), inset 0 0 0 4px var(--accent), inset 0 0 0 5px rgba(255, 255, 255, 0.35); }
.dojo-texts { display: grid; gap: 10px; margin-top: 10px; }
.dojo-texts textarea { min-height: 120px; font-family: var(--serif); font-size: 1rem; line-height: 1.7; }
.beads { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.bead { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--axis); box-sizing: border-box; }
.bead.is-on { background: var(--accent); border-color: var(--accent); }
.merit-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 28px; }
.merit-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 0.92rem; color: var(--ink-2); }
.merit-list li.is-earned { color: var(--ink); }
.merit-points { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); white-space: nowrap; }
.merit-list li.is-earned .merit-points, .merit-points.is-earned { color: var(--good-ink); font-weight: 700; }
.merit-total { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--accent-ink); }
.quote { font-family: var(--serif); color: var(--ink-2); line-height: 1.8; margin: 10px 0 0; }
.breakdown { background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 16px; margin-bottom: 12px; }
.breakdown .card-head { margin-bottom: 4px; }
.breakdown ol { margin: 4px 0 0; padding-left: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; color: var(--ink-2); }
.exit-form { display: grid; gap: 10px; }
.exit-form textarea { min-height: 64px; }
.exit-problem { display: grid; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius); overflow-wrap: anywhere; }
.reflection { margin: 12px 0 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; }
.reflection dt { color: var(--muted); font-size: 0.85rem; }
.reflection dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .merit-list, .breakdown ol { grid-template-columns: minmax(0, 1fr); }
  .reflection { grid-template-columns: minmax(0, 1fr); }
}

/* ---- the day's path: one card from the oath to the last task; the first pick is what the seal starts ---- */
.today-path .oath { font-size: 1.05rem; line-height: 1.75; margin: 2px 0 14px; }
.path-progress { display: flex; align-items: center; gap: 10px; }
.path-progress .beads { margin: 0; }
.path-progress .bead { width: 12px; height: 12px; }
.next-up { display: grid; gap: 6px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent), inset 0 0 0 1px var(--hairline); min-width: 0; }
.next-up .eyebrow { margin: 0; color: var(--accent-ink); }
.next-up [data-next-detail] { display: grid; gap: 6px; min-width: 0; }
.next-up.is-overridden [data-next-detail] { display: none; }
.next-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 1.12rem; min-width: 0; overflow-wrap: anywhere; }
.next-picked { margin: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.next-after { margin-top: 16px; }
.next-after .btn-row { margin-top: 6px; }
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.start-row .ritual-hint { margin: 0; }
.report-elsewhere { margin: 8px 0 0; }
.path-subhead { margin: 20px 0 0; font-family: var(--font); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.today-path .sync-line { margin-top: 10px; }

/* ---- the top bar's way back to a running session ---- */
.live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--ink); text-decoration: none; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(232, 163, 148, 0.45); white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-pill:hover { color: var(--ink); filter: brightness(1.15); }

/* ---- a session: the head, the four steps, recording the result ---- */
.session-head-main { min-width: 0; flex: 1 1 320px; }
.session-head-side { display: grid; justify-items: end; gap: 10px; }
.session-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--hairline); color: var(--muted); font-size: 0.9rem; min-width: 0; }
.step-num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.82rem; background: var(--surface-3); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.step-label { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.step.is-done { color: var(--ink-2); }
.step.is-done .step-num { background: rgba(63, 143, 90, 0.22); color: var(--good-ink); box-shadow: inset 0 0 0 1px rgba(124, 196, 143, 0.45); }
.step.is-current { color: var(--ink); background: linear-gradient(90deg, var(--accent-soft), transparent 80%), var(--surface); border-color: rgba(232, 163, 148, 0.45); }
.step.is-current .step-num { background: var(--accent); color: #fff; box-shadow: none; }
.rate-card.is-pending { box-shadow: var(--shadow), inset 0 0 0 1px rgba(232, 163, 148, 0.5); }
.switch-details .problem-switch { margin-top: 10px; }
.roadmap-filter { margin: 10px 0 6px; }
@media (max-width: 640px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .session-head-side { justify-items: stretch; width: 100%; }
}
.btn-link { --btn-bg: transparent; --btn-ring: transparent; --btn-ink: #d9b38c; padding-left: 0; padding-right: 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.next-step { margin-left: 6px; font-weight: 600; white-space: nowrap; }
/* a roadmap row reads like a line of text: the title wraps as words, its chips follow it */
.member-main { display: block; }
.member-main .chip { margin-left: 6px; vertical-align: 1px; }
.member-meta .btn-xs { min-height: 26px; }
/* On a phone the stats are a compact 2 × 2 under the level, so today's practice starts on the first screen. */
@media (max-width: 640px) {
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hud-level { grid-column: span 2; }
  .hud-level, .hud-tile { padding: 10px 12px; gap: 10px; }
  .level-badge { width: 56px; height: 56px; }
  .level-value { font-size: 1.6rem; }
  .hud-big { font-size: 1.3rem; }
  .hud-big .unit { font-size: 0.8rem; }
  .hud-icon { font-size: 1.1rem; }
  .hud-tile:not(.readiness) .muted.small, .hud-tile .beads { display: none; }
  .hud-tile .eyebrow { margin: 0; }
  .today-path .oath { font-size: 0.98rem; line-height: 1.65; padding-left: 14px; }
  .start-row .btn-seal { flex: 1 1 auto; }
}
