/* Study Planner — calm, minimal UI. Light/dark via CSS variables. */

:root {
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --surface-2: #F1F1EE;
  --surface-3: #E8E8E4;
  --border: #E4E4DF;
  --text: #1D1D1F;
  --text-2: #55555C;
  --text-3: #6E6E76;
  --accent: #5451D6;
  --accent-hover: #4340C4;
  --accent-soft: #ECEBFC;
  --on-accent: #FFFFFF;
  --ok: #17804A;     --ok-soft: #E6F4EC;
  --warn: #9A6A00;   --warn-soft: #FFF4D6;
  --bad: #C0262D;    --bad-soft: #FDECEC;
  --info: #3D5AC2;   --info-soft: #EBF0FD;
  --sec-listening: #2F6FDB;
  --sec-reading: #17844A;
  --sec-writing: #C2581C;
  --sec-speaking: #B0307F;
  --sec-mixed: #6E6E76;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 4px 16px rgba(20, 20, 30, .05);
  --shadow-lg: 0 12px 40px rgba(20, 20, 30, .16);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-w: 224px;
  --top-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131316; --surface: #1C1C21; --surface-2: #24242A; --surface-3: #2E2E35; --border: #2F2F37;
    --text: #EDEDF0; --text-2: #B4B4BD; --text-3: #9C9CA6;
    --accent: #8C89F7; --accent-hover: #A3A0FA; --accent-soft: #2A2950; --on-accent: #13132A;
    --ok: #4CC285; --ok-soft: #173326; --warn: #E6B84A; --warn-soft: #3A2F12; --bad: #F2777B; --bad-soft: #3D1C1E; --info: #8DA6F5; --info-soft: #1E2645;
    --sec-listening: #6EA2F5; --sec-reading: #4CC285; --sec-writing: #F08A4B; --sec-speaking: #E067B3; --sec-mixed: #9C9CA6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131316; --surface: #1C1C21; --surface-2: #24242A; --surface-3: #2E2E35; --border: #2F2F37;
  --text: #EDEDF0; --text-2: #B4B4BD; --text-3: #9C9CA6;
  --accent: #8C89F7; --accent-hover: #A3A0FA; --accent-soft: #2A2950; --on-accent: #13132A;
  --ok: #4CC285; --ok-soft: #173326; --warn: #E6B84A; --warn-soft: #3A2F12; --bad: #F2777B; --bad-soft: #3D1C1E; --info: #8DA6F5; --info-soft: #1E2645;
  --sec-listening: #6EA2F5; --sec-reading: #4CC285; --sec-writing: #F08A4B; --sec-speaking: #E067B3; --sec-mixed: #9C9CA6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-3); }
.small { font-size: .88em; }
.hint { color: var(--text-3); font-size: .9rem; }
.warn-text { color: var(--warn); }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }

/* ---------- shell ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand .icon { color: var(--accent); width: 1.4em; height: 1.4em; }
.lang-switch { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.lang-switch button { border: 0; background: none; padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--text-2); cursor: pointer; }
.lang-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.nav {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--nav-w); z-index: 15;
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .icon { width: 1.25em; height: 1.25em; }

.main { padding: calc(var(--top-h) + 28px) 32px 64px calc(var(--nav-w) + 32px); max-width: calc(var(--nav-w) + 1120px); outline: none; }
body.bare .nav { display: none; }
body.bare .main { padding-left: 32px; max-width: none; }
body.bare .view { max-width: 1120px; margin: 0 auto; }

@media (max-width: 899px) {
  .nav {
    top: auto; width: auto; right: 0; flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border);
  }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .68rem; flex: 1; text-align: center; min-width: 0; }
  .nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .nav a.active { background: none; }
  .main, body.bare .main { padding: calc(var(--top-h) + 18px) 16px 96px; }
  body.bare .main { padding-bottom: 40px; }
  .topbar { padding: 0 16px; }
  h1 { font-size: 1.5rem; }
  .hide-sm { display: none; }
}

.boot { display: grid; place-items: center; min-height: 40vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- building blocks ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; outline: none; }
.eyebrow { color: var(--text-3); margin: 0 0 4px; font-weight: 550; }
.eyebrow::first-letter, .cal-title::first-letter { text-transform: uppercase; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.countdown { display: inline-flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; font-weight: 600; }
.countdown .icon { color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.section { margin-bottom: 28px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card-grid .card { margin: 0; }
.empty { text-align: center; padding: 36px 20px; }
.empty-emoji { font-size: 2.2rem; margin: 0 0 8px; }
.row-center { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.row-end { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
.row-wrap { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.lead { font-size: 1.06rem; color: var(--text-2); }
.plain-list { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: 8px; }
.check-list li { display: flex; gap: 10px; align-items: center; }
.check-list .icon { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: .9rem; }
.btn.big { min-height: 48px; padding: 10px 24px; font-size: 1.02rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.btn-link:hover { text-decoration: underline; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* section badge: colour + icon + text */
.sec-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.sec-badge .icon { color: var(--sec-c); }
.sec-badge.small { font-size: .82rem; padding: 2px 9px 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--sec-c) 12%, transparent); }
.sec-listening { --sec-c: var(--sec-listening); }
.sec-reading { --sec-c: var(--sec-reading); }
.sec-writing { --sec-c: var(--sec-writing); }
.sec-speaking { --sec-c: var(--sec-speaking); }
.sec-mixed { --sec-c: var(--sec-mixed); }
.kind-tag { font-size: .78rem; color: var(--text-2); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; font-weight: 550; }
.chip { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }

/* notices & status */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--info-soft); }
.notice > .icon { margin-top: 3px; }
.notice p:last-child { margin-bottom: 0; }
.notice.info > .icon { color: var(--info); }
.notice.warn { background: var(--warn-soft); } .notice.warn > .icon { color: var(--warn); }
.notice.bad { background: var(--bad-soft); } .notice.bad > .icon { color: var(--bad); }
.notice-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.status-line {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  padding: 12px 16px; margin-bottom: 18px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
}
.status-line:hover { background: var(--surface-2); }
.status-line span { color: var(--text-2); flex: 1; }
.status-line .push { color: var(--text-3); }
.status-line.ok > .icon:first-child, .status-box.ok > .icon { color: var(--ok); }
.status-line.warn > .icon:first-child, .status-box.warn > .icon { color: var(--warn); }
.status-line.bad > .icon:first-child, .status-box.bad > .icon { color: var(--bad); }
.status-line.ok strong { color: var(--ok); } .status-line.warn strong { color: var(--warn); } .status-line.bad strong { color: var(--bad); }
.status-box { display: flex; gap: 12px; padding: 16px; border-radius: var(--radius-sm); margin: 16px 0; }
.status-box .icon { width: 1.5em; height: 1.5em; margin-top: 2px; }
.status-box p { margin: 4px 0 0; color: var(--text-2); }
.status-box.ok { background: var(--ok-soft); } .status-box.warn { background: var(--warn-soft); } .status-box.bad { background: var(--bad-soft); }
.status-box.ok strong { color: var(--ok); } .status-box.warn strong { color: var(--warn); } .status-box.bad strong { color: var(--bad); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.summary-grid.wide .stat { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-val { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--text-3); font-size: .86rem; font-weight: 550; }
@media (max-width: 640px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }

.fixes { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; margin: 12px 0; }
.fixes-title { font-weight: 650; }
.fixes-row { display: flex; gap: 8px; flex-wrap: wrap; }
.needs summary { cursor: pointer; font-weight: 600; color: var(--text-2); padding: 6px 0; }
.table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-3); font-weight: 600; font-size: .85rem; }
.levels-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.level-pill { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------- Today ---------- */
.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .today-grid { grid-template-columns: 1fr; } }
.tasks-card { padding: 24px; }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.task {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); border-left: 4px solid var(--sec-c); background: var(--surface); transition: background .2s, opacity .2s;
}
.task.done { background: var(--surface-2); }
.task.done .task-title { text-decoration: line-through; color: var(--text-3); }
.checkbox {
  width: 30px; height: 30px; flex: none; margin-top: 2px; border-radius: 9px; border: 2px solid var(--text-3);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: transparent; transition: background .15s, border-color .15s;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox[aria-checked="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.checkbox .icon { stroke-width: 3; width: 18px; height: 18px; }
.task.just-done .checkbox { background: var(--ok); border-color: var(--ok); color: #fff; animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.18); } }
.task-body { flex: 1; min-width: 0; }
.task-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; font-size: .88rem; }
.task-title { font-size: 1.05rem; font-weight: 650; margin: 0 0 4px; overflow-wrap: anywhere; }
.task-mat { margin: 0; font-size: .92rem; }
.task-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.mat-link { display: inline-flex; gap: 6px; align-items: center; font-weight: 550; overflow-wrap: anywhere; }
.mat-missing { color: var(--text-3); font-style: italic; }
@media (max-width: 560px) {
  .task { flex-wrap: wrap; }
  .task-body { flex-basis: calc(100% - 48px); }
  .task-actions { width: 100%; justify-content: flex-start; padding-left: 44px; }
}

.side-col { display: grid; gap: 18px; }
.side-col .card { margin: 0; }
.ring-card { display: grid; gap: 18px; justify-items: center; }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 11; }
.ring-arc { fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset .9s cubic-bezier(.3, .8, .3, 1); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center strong { font-size: 2rem; letter-spacing: -.02em; }
.ring-center span { color: var(--text-3); font-size: .85rem; }
.streak { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.streak > .icon { width: 1.8em; height: 1.8em; color: var(--sec-writing); }
.streak div { display: flex; flex-direction: column; }
.streak span { color: var(--text-3); font-size: .86rem; }
.small-card h3 { margin-bottom: 6px; }
.dots-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 440px); }
@media (max-width: 899px) { .toasts { bottom: 86px; } }
.toast {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
}
.toast .btn-link { color: var(--accent-soft); }
.toast.success { border-left: 4px solid var(--ok); }
.toast.warn { border-left: 4px solid var(--warn); }
.toast.error { border-left: 4px solid var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- dialogs ---------- */
.dlg { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(94vw, 520px); max-height: 90vh; }
.dlg.wide { width: min(94vw, 760px); }
.dlg::backdrop { background: rgba(10, 10, 20, .45); }
.dlg-inner { display: flex; flex-direction: column; max-height: 90vh; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 8px 20px; overflow: auto; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }
.dlg[open] { animation: dlgIn .2s ease; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.blk-info { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.blk-title { font-weight: 650; font-size: 1.05rem; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .field .label { font-weight: 600; font-size: .95rem; padding: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.field-row.four { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
input[type=date], input[type=text], input[type=url], input[type=number], input[type=time], input:not([type]), select, textarea {
  min-height: 42px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 0; }
.form-error { color: var(--bad); font-weight: 600; }
.slider-row { display: flex; gap: 14px; align-items: center; }
.slider-row input { flex: 1; accent-color: var(--accent); height: 28px; }
.slider-row output { min-width: 56px; font-weight: 700; text-align: right; }
.switch { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; margin: 8px 0; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); padding: 3px; border-radius: 10px; margin-bottom: 12px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .9rem; color: var(--text-2); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2.5px solid var(--accent); }

.option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.option-cards.col { grid-template-columns: 1fr; }
.option-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.option-card:hover { border-color: var(--accent); }
.option-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option-card input { margin-top: 4px; accent-color: var(--accent); width: 18px; height: 18px; }
.option-card span { display: flex; flex-direction: column; }
.option-card small { color: var(--text-3); font-size: .88rem; }
.option-card.disabled { opacity: .55; cursor: default; }
.option-card.disabled:hover { border-color: var(--border); }

/* ---------- onboarding ---------- */
.onb { max-width: 720px; margin: 0 auto; }
.onb-brand { display: none; }
.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 20px; }
.steps li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--text-3); }
.steps li span { height: 5px; border-radius: 99px; background: var(--surface-3); font-size: 0; }
.steps li.done span, .steps li.cur span { background: var(--accent); }
.steps li.cur { color: var(--text); font-weight: 600; }
.steps em { font-style: normal; }
@media (max-width: 560px) { .steps em { display: none; } .steps li.cur em { display: block; } }
.onb-card { padding: 28px; }
.onb-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.onb-choice { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.q-meta { color: var(--text-3); font-size: .88rem; font-weight: 550; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.known-box { padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm); margin-top: 6px; }
.known-box details summary { cursor: pointer; color: var(--text-2); font-weight: 600; margin-bottom: 10px; }

.mdp { max-width: 360px; }
.mdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; text-transform: capitalize; }
.mdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mdp-wd { text-align: center; font-size: .75rem; color: var(--text-3); padding: 4px 0; text-transform: capitalize; }
.mdp-day { aspect-ratio: 1; border: 1px solid transparent; border-radius: 9px; background: var(--surface-2); cursor: pointer; font-size: .9rem; min-height: 36px; }
.mdp-day:hover:not(:disabled) { border-color: var(--accent); }
.mdp-day.out { opacity: .5; }
.mdp-day.today { border-color: var(--accent); font-weight: 700; }
.mdp-day.on { background: var(--bad-soft); color: var(--bad); font-weight: 700; text-decoration: line-through; border-color: var(--bad); }
.mdp-day:disabled { opacity: .3; cursor: default; }

/* ---------- tests ---------- */
.test-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.timer { display: inline-flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; font-weight: 700; background: var(--surface); border: 1px solid var(--border); padding: 4px 12px; border-radius: 999px; }
.test-progress { height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.test-progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.test-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.test-layout.single { grid-template-columns: minmax(0, 760px); justify-content: center; }
@media (max-width: 900px) { .test-layout { grid-template-columns: 1fr; } }
.passage { position: sticky; top: calc(var(--top-h) + 16px); max-height: calc(100vh - var(--top-h) - 40px); overflow: auto; }
@media (max-width: 900px) { .passage { position: static; max-height: none; } }
.passage-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.passage-head h2 { margin: 0; }
.passage-text { font-size: 1rem; line-height: 1.7; }
.transcript { background: var(--surface-2); padding: 14px; border-radius: var(--radius-sm); margin-top: 10px; font-size: .95rem; }
.audio-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.map-grid { position: relative; display: grid; gap: 4px; margin: 10px 0 12px; padding-top: 22px; }
.map-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.map-cell { min-height: 54px; display: grid; place-items: center; text-align: center; padding: 6px; border-radius: 8px; background: var(--surface-2); font-size: .88rem; color: var(--text-2); }
.map-cell.letter { background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 1.2rem; }
.map-north { position: absolute; top: 0; right: 0; font-size: .8rem; font-weight: 700; color: var(--text-3); }
.q-text { font-size: 1.3rem; margin: 6px 0 18px; }
.options { display: grid; gap: 8px; }
.option {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.option:hover { border-color: var(--accent); }
.option.on { border-color: var(--accent); background: var(--accent-soft); }
.option kbd { font: 600 .8rem var(--font); min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.option.on kbd { background: var(--accent); color: var(--on-accent); }
.q-nav { display: flex; justify-content: space-between; margin-top: 18px; gap: 10px; }
.q-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.q-dot { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: .8rem; cursor: pointer; color: var(--text-2); }
.q-dot.ans { background: var(--surface-3); color: var(--text); }
.q-dot.cur { border: 2px solid var(--accent); color: var(--accent); font-weight: 700; }
.kbd-hint { margin-top: 12px; }
@media (hover: none) { .kbd-hint, .option kbd { display: none; } }
.score-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.score-card { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border-top: 3px solid var(--sec-c); }
.score-big { font-size: 1.8rem; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.two-col h3 { display: flex; gap: 6px; align-items: center; }
@media (max-width: 560px) { .two-col { grid-template-columns: 1fr; } }
.review-list { padding-left: 1.2em; margin: 0; display: grid; gap: 14px; }
.review-item p { margin: 2px 0; }
.review-item.ok .icon { color: var(--ok); }
.review-item.bad .icon { color: var(--bad); }
.explain { color: var(--text-2); font-size: .93rem; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; margin-top: 6px !important; }
.ws-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 14px; }
.ws-block legend { padding: 0 6px; }
.ws-self { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 16px; }
.ws-self > .hint { grid-column: 1 / -1; }
.crit label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: 4px; }
.crit select { max-width: 90px; }
.crit-hint { min-height: 2.6em; margin: 4px 0 8px; }
.test-card .tc-head { display: flex; gap: 12px; align-items: flex-start; }
.test-card .tc-head > .icon { width: 1.6em; height: 1.6em; color: var(--accent); margin-top: 2px; }
.test-card h3 { margin: 0; }
.history { list-style: none; padding: 0; margin: 0; }
.history-row { display: grid; grid-template-columns: 220px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.hs { display: flex; flex-wrap: wrap; gap: 10px; }
.hs-item { display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 760px) { .history-row { grid-template-columns: 1fr; } }

/* ---------- calendar ---------- */
.cal-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg-buttons { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.seg-buttons button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg-buttons button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.cal-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cal-title { margin: 0 0 0 8px; font-size: 1.1rem; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 12px 0; font-size: .88rem; }
.legend-item { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch.over { background: var(--bad-soft); border: 2px solid var(--bad); }
.swatch.blocked { background: repeating-linear-gradient(45deg, var(--surface-3) 0 3px, transparent 3px 6px); border: 1px solid var(--border); }
.swatch.dash { height: 0; width: 18px; border-top: 2px dashed var(--text-2); border-radius: 0; }
.swatch.plan { background: var(--surface-3); }
.swatch.done { background: var(--accent); }
.flags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.flag { display: inline-flex; gap: 6px; align-items: center; font-size: .88rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.flag.small { font-size: .75rem; padding: 2px 8px; }
.flag.over { background: var(--bad-soft); color: var(--bad); }
.flag.exam { background: var(--accent-soft); color: var(--accent); }
.flag.blocked { background: var(--surface-3); }

.cal-block {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: .85rem;
  background: color-mix(in srgb, var(--sec-c) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--sec-c) 30%, var(--border)); border-left: 4px solid var(--sec-c);
  transition: transform .1s, box-shadow .15s;
}
.cal-block:hover { box-shadow: var(--shadow); }
.cal-block.done { opacity: .6; }
.cal-block.done .cb-title { text-decoration: line-through; }
.cal-block.missed { opacity: .5; border-style: dashed; }
.cal-block.dragging { opacity: .4; }
.cb-top { display: flex; gap: 5px; align-items: center; font-weight: 600; font-size: .78rem; color: var(--text-2); }
.cb-top .icon { color: var(--sec-c); }
.cb-done { margin-left: auto; color: var(--ok); }
.cb-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.cb-min { color: var(--text-3); font-size: .78rem; }

.day-grid { position: relative; margin-left: 56px; border-left: 1px solid var(--border); }
.hour-row { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.hour-row span { position: absolute; left: -54px; top: -9px; font-size: .78rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.day-slot { position: absolute; left: 10px; right: 0; display: flex; gap: 10px; }
.day-slot .cal-block { flex: 1; overflow: hidden; }
.slot-time { font-size: .75rem; color: var(--text-3); width: 80px; flex: none; padding-top: 8px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .slot-time { display: none; } }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; min-height: 260px; display: flex; flex-direction: column; gap: 6px; transition: background .15s, border-color .15s; }
.week-col.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.week-col.over { background: var(--bad-soft); border-color: var(--bad); }
.week-col.blocked { background: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, var(--surface) 6px 12px); }
.week-col.past { opacity: .75; }
.week-col.drop-on { border: 2px dashed var(--accent); background: var(--accent-soft); }
.wc-head { display: flex; flex-direction: column; gap: 4px; }
.wc-date { display: flex; gap: 6px; align-items: baseline; border: 0; background: none; padding: 0; cursor: pointer; text-transform: capitalize; color: var(--text-2); }
.wc-date strong { font-size: 1.25rem; color: var(--text); }
.wc-load { font-size: .75rem; color: var(--text-3); display: flex; gap: 4px; align-items: center; }
.week-col.over .wc-load { color: var(--bad); font-weight: 700; }
.load-bar, .mg-load { height: 4px; background: var(--surface-3); border-radius: 9px; overflow: hidden; display: block; }
.load-bar span, .mg-load span { display: block; height: 100%; background: var(--accent); }
.week-col.over .load-bar span, .mg-cell.over .mg-load span { background: var(--bad); }
.wc-blocks { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.wc-add { border: 1px dashed var(--border); background: none; border-radius: 8px; padding: 4px; color: var(--text-3); cursor: pointer; }
.wc-add:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 900px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-col { min-height: 0; }
  .wc-head { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }
  .load-bar { width: 80px; }
}

.month-grid { display: grid; gap: 4px; }
.mg-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mg-row.head span { text-align: center; font-size: .78rem; color: var(--text-3); text-transform: capitalize; padding: 4px; }
.mg-cell { min-height: 86px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; position: relative; }
.mg-cell:hover { border-color: var(--accent); }
.mg-cell.out { opacity: .45; }
.mg-cell.today { border: 2px solid var(--accent); }
.mg-cell.over { background: var(--bad-soft); }
.mg-cell.blocked { background: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, var(--surface) 6px 12px); }
.mg-cell.exam { background: var(--accent-soft); }
.mg-num { font-weight: 650; font-size: .9rem; }
.mg-exam { position: absolute; top: 6px; right: 8px; color: var(--accent); }
.mg-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sec-c); display: inline-block; }
.mg-min { font-size: .72rem; color: var(--text-3); }
@media (max-width: 560px) { .mg-cell { min-height: 58px; padding: 4px; } .mg-min { display: none; } }

/* ---------- charts ---------- */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 12px; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { stroke: var(--surface); stroke-width: 2; }
.chart .end-label { font-size: 12px; fill: var(--text-2); font-weight: 600; }
.chart .target-line { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart .target-label { fill: var(--text-2); font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; }
.chart .bar-plan { fill: var(--surface-3); }
.chart .bar-done { fill: var(--accent); }
.sec-stroke-listening { stroke: var(--sec-listening); } .sec-fill-listening { fill: var(--sec-listening); }
.sec-stroke-reading { stroke: var(--sec-reading); } .sec-fill-reading { fill: var(--sec-reading); }
.sec-stroke-writing { stroke: var(--sec-writing); } .sec-fill-writing { fill: var(--sec-writing); }
.sec-stroke-speaking { stroke: var(--sec-speaking); } .sec-fill-speaking { fill: var(--sec-speaking); }
.tooltip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 10px; padding: 10px 12px; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.table-view summary { cursor: pointer; color: var(--text-2); font-weight: 600; font-size: .9rem; }

.topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px 28px; }
.topic-group ul { list-style: none; padding: 0; margin: 0; }
.topic-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.topic-row .muted { grid-column: 1; grid-row: 2; }
.topic-row .chip { grid-column: 2; grid-row: 1 / span 2; }
.chip.st-mastered { background: var(--ok-soft); color: var(--ok); }
.chip.st-progress { background: var(--info-soft); color: var(--info); }
.chip.st-weak { background: var(--bad-soft); color: var(--bad); }
.chip.st-unknown { color: var(--text-3); }

/* ---------- materials & settings ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.mat-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.mat-item { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-left: 4px solid var(--sec-c); border-radius: var(--radius-sm); background: var(--surface); }
.mat-item .grow { flex: 1; min-width: 0; }
.mat-item h3 { margin: 0 0 4px; overflow-wrap: anywhere; }
.mat-item.stub { border-style: dashed; border-left-style: solid; }
.settings-grid { display: grid; gap: 18px; max-width: 820px; }
.settings-grid .card { margin: 0; }
.link-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.link-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; }
@media (max-width: 560px) { .link-row { grid-template-columns: 1fr; } }
.recovery { margin-top: 40px; }

/* ---------- motion ---------- */
.fade-in { animation: fadeUp .35s ease both; }
.task-list .fade-in:nth-child(2) { animation-delay: .04s; }
.task-list .fade-in:nth-child(3) { animation-delay: .08s; }
.task-list .fade-in:nth-child(4) { animation-delay: .12s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .nav, .topbar, .toasts { display: none; }
  .main { padding: 0; }
}
