:root {
  --bg: #f6f7f9; --bg-card: #ffffff; --border: #dde3e8; --text: #1b2a33; --text-muted: #5a6b76;
  --slate: #1f3b4d; --accent: #0f6e7a; --accent-ink: #ffffff; --good: #1f7a4d; --good-bg: #e8f5ee; --bad: #a11d1e; --bad-bg: #fbeaea;
  --warn: #8a5a00; --warn-bg: #fff4dc; --opt: #8795a0; --review: #7a5ea8; --exam: #a11d1e;
  --max: 1100px; --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; --serif: 'Playfair Display', Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f171c; --bg-card: #17232a; --border: #253640; --text: #e8edf0; --text-muted: #98a8b2; --slate: #a9c3d1; --accent: #3fb6c4; --accent-ink: #0f171c;
    --good: #5fc48f; --good-bg: #16302a; --bad: #ff7b7b; --bad-bg: #3a1e22; --warn: #f0c060; --warn-bg: #3a2f16; --opt: #6f7f8a; --review: #b69be0; --exam: #ff7b7b; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-family: var(--serif); font-size: 1.6rem; }
h2 { font-family: var(--serif); font-size: 1.4rem; color: var(--slate); }
h3 { font-size: 1rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
ul { margin: 0 0 1em; padding-left: 1.2em; }
li { margin: .2em 0; }
.sub, .disclaimer { color: var(--text-muted); font-size: .9rem; }
.disclaimer { margin-top: 28px; }

.top { max-width: var(--max); margin: 0 auto; padding: 18px 16px 6px; display: flex; align-items: baseline; gap: 20px; }
.top .brand { color: var(--text-muted); font-size: .9rem; white-space: nowrap; }
.top .title p { margin: 0; color: var(--text-muted); font-size: .95rem; }
#countdown { color: var(--accent); font-weight: 600; }

.tabs { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; gap: 4px; max-width: var(--max); margin: 0 auto; padding: 8px 16px 0; }
.tabs button { appearance: none; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

main { max-width: var(--max); margin: 0 auto; padding: 8px 16px 60px; }

.btn { appearance: none; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 10px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-ghost { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); filter: none; }
.btn-ghost.on { border-color: var(--accent); color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.chip { display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .03em; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, var(--bg-card)); color: var(--accent); }

/* ---------- calendar */
.progress-row { display: flex; align-items: center; gap: 14px; margin: 18px 0 14px; flex-wrap: wrap; }
.progress { flex: 1 1 240px; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress-row p { margin: 0; }

.day-detail { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 22px; }
.day-detail.optional { border-left-color: var(--opt); }
.day-detail.review { border-left-color: var(--review); }
.day-detail.exam { border-left-color: var(--exam); }
.day-detail .when { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 4px; }
.day-detail h2 { margin-bottom: .6em; }
.day-detail .cols { display: grid; grid-template-columns: 3fr 2fr; gap: 8px 28px; }
.day-detail h3 { margin-top: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--slate); }
.day-detail .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.dot.req { background: var(--accent); } .dot.opt { background: var(--opt); } .dot.review { background: var(--review); } .dot.exam { background: var(--exam); }

.calendar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .7fr)); gap: 6px; }
.dow { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 0 4px; }
.cell { appearance: none; text-align: left; font: inherit; color: inherit; background: var(--bg-card); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 8px; padding: 6px 8px; min-height: 84px; cursor: pointer; position: relative; display: flex; flex-direction: column; gap: 2px; }
.cell:hover { border-color: var(--accent); }
.cell.optional { border-top-color: var(--opt); background: color-mix(in srgb, var(--opt) 6%, var(--bg-card)); }
.cell.review { border-top-color: var(--review); }
.cell.exam { border-top-color: var(--exam); background: color-mix(in srgb, var(--exam) 8%, var(--bg-card)); }
.cell.pad { visibility: hidden; }
.cell .d { font-size: .78rem; font-weight: 700; color: var(--text-muted); }
.cell .t { font-size: .8rem; line-height: 1.3; }
.cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cell.selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.cell.done::after { content: '✓'; position: absolute; top: 5px; right: 8px; color: var(--good); font-weight: 700; }
.cell.done .t { color: var(--text-muted); }
.cell.past:not(.done):not(.optional):not(.exam)::after { content: '•'; position: absolute; top: 2px; right: 8px; color: var(--warn); font-size: 1.2rem; }

.howto { margin-top: 24px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; }
.howto summary, .history summary { cursor: pointer; font-weight: 600; }
.howto ul { margin-top: 10px; }

/* ---------- practice */
.practice-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 18px 0 16px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.controls label { display: flex; flex-direction: column; font-size: .8rem; color: var(--text-muted); gap: 3px; }
.controls label.check { flex-direction: row; align-items: center; gap: 6px; font-size: .9rem; padding-bottom: 8px; }
.controls select { font: inherit; font-size: .95rem; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text); max-width: 100%; }

.case, .empty { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; }
.empty p { margin: 0; color: var(--text-muted); }
.case-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-muted); }
.timer.low { color: var(--warn); } .timer.over { color: var(--bad); }
.stem { font-size: 1.05rem; }
.ask { font-weight: 600; border-left: 3px solid var(--accent); padding-left: 12px; margin: 18px 0 10px; }
textarea { width: 100%; font: inherit; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); resize: vertical; }
textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.answer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; }
#mic.rec { border-color: var(--bad); color: var(--bad); }

.turn { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.turn .you { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: .95rem; }
.fb { margin-top: 12px; border-radius: 10px; padding: 14px 16px; background: color-mix(in srgb, var(--accent) 6%, var(--bg-card)); border: 1px solid var(--border); }
.fb h4 { margin: 10px 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--slate); }
.fb h4:first-child { margin-top: 0; }
.fb ul { margin: 0 0 4px; }
.fb .score { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; margin-bottom: 6px; }
.fb .pips { letter-spacing: 2px; color: var(--accent); }
.points { list-style: none; padding: 0; }
.points li { padding-left: 1.5em; position: relative; }
.points li::before { position: absolute; left: 0; font-weight: 700; }
.points li.hit::before { content: '✓'; color: var(--good); }
.points li.miss::before { content: '○'; color: var(--text-muted); }
.points li.miss { color: var(--text-muted); }
.crit { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 12px; font-size: .92rem; margin: 8px 0; }
.model { background: var(--good-bg); border-radius: 8px; padding: 10px 14px; font-size: .95rem; }
.followup { font-style: italic; }
.note { font-size: .82rem; color: var(--text-muted); margin: 6px 0 0; }
.err { color: var(--bad); }
.rate { display: flex; gap: 10px; flex-wrap: wrap; }
#wrap-up { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 6px; }

.history { margin-top: 22px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; }
.history ol { padding-left: 1.4em; font-size: .92rem; }
.history li button { font-size: inherit; }
.topic-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.topic-stats span { font-size: .8rem; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; }
.r-pass { color: var(--good); } .r-borderline { color: var(--warn); } .r-fail { color: var(--bad); }

@media (max-width: 760px) {
  .top { flex-direction: column; gap: 4px; }
  .day-detail .cols { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: 1fr; }
  .dow, .cell.pad { display: none; }
  .cell { min-height: 0; flex-direction: row; gap: 10px; align-items: baseline; padding: 8px 10px; }
  .cell .d { min-width: 64px; }
  .case, .empty { padding: 18px 16px; }
  .timer { margin-left: 0; }
}

.ask.curve { border-left-color: var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 0 8px 8px 0; }
.ask .cb-tag { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--warn); margin-bottom: 2px; }
.empty p + p { margin-top: 10px; }
