/* ŁódźPrep — application styles (light + dark). */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e8edf5;
  --text: #182032;
  --muted: #566074;
  --faint: #8b94a6;
  --border: #e0e5ee;
  --border-strong: #c9d1de;
  --primary: #1865f2;
  --primary-dark: #0b4fc8;
  --primary-soft: #e7effe;
  --primary-ink: #ffffff;
  --good: #0a8f1b;
  --good-strong: #00a60e;
  --good-soft: #e3f5e6;
  --bad: #d0281b;
  --bad-soft: #fdeceb;
  --warn: #b77700;
  --warn-soft: #fff4d6;
  --violet: #6847d8;
  --violet-soft: #efeaff;
  --m0: transparent;
  --m0-b: #c3cad8;
  --m1: #fde3c4;
  --m1-b: #efa458;
  --m2: #f6a32a;
  --m2-b: #e08c0b;
  --m3: #9c8cff;
  --m3-b: #7d69f2;
  --m4: #4b2fc9;
  --m4-b: #3a20b0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --topbar: 58px;
  --sidebar: 288px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0c111b;
  --surface: #141a26;
  --surface-2: #1a2131;
  --surface-3: #232b3d;
  --text: #e7ecf4;
  --muted: #a3adbf;
  --faint: #758097;
  --border: #273046;
  --border-strong: #354059;
  --primary: #5b9bff;
  --primary-dark: #8db8ff;
  --primary-soft: #1a2a4a;
  --primary-ink: #08101f;
  --good: #4fd36a;
  --good-strong: #3cc85a;
  --good-soft: #143222;
  --bad: #ff7468;
  --bad-soft: #3a1a1c;
  --warn: #ffc24d;
  --warn-soft: #3a2f12;
  --violet: #ad9bff;
  --violet-soft: #2a2350;
  --m0-b: #4a5570;
  --m1: #5a3d1f;
  --m1-b: #c8823a;
  --m2: #d68a17;
  --m2-b: #f0a43a;
  --m3: #7f6cf0;
  --m3-b: #a495ff;
  --m4: #b9a8ff;
  --m4-b: #d6cbff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 1.85rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 750; }
h3 { font-size: 1.12rem; font-weight: 700; }
p { margin: 0 0 0.8em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0.2em 0 0.8em; padding-left: 1.4em; }
li { margin: 0.15em 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.78rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.spacer { flex: 1; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.tex-error { color: var(--bad); font-family: var(--mono); }
.katex { font-size: 1.08em; }
.katex-display { margin: 0.6em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 850; font-size: 1.12rem; color: var(--text); letter-spacing: -0.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #1865f2, #6847d8); color: #fff; font-weight: 900; font-size: 0.95rem; box-shadow: 0 2px 6px rgba(24, 101, 242, 0.35); }
.brand small { font-weight: 600; color: var(--muted); font-size: 0.78rem; margin-left: 2px; }
.nav { display: flex; gap: 2px; margin-left: 10px; }
.nav a { color: var(--muted); font-weight: 600; font-size: 0.92rem; padding: 7px 11px; border-radius: 9px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.top-stats { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 0.86rem; background: var(--surface-2); color: var(--text); white-space: nowrap; border: 1px solid transparent; }
.pill.streak { color: #e8590c; }
.pill.points { color: var(--violet); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-btn { display: none; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar {
  width: var(--sidebar); flex: none;
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar));
  overflow-y: auto; padding: 18px 12px 40px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar[hidden] { display: none; }
main { flex: 1; min-width: 0; padding: 26px 28px 80px; }
.container { max-width: 1120px; margin: 0 auto; }
.container-narrow { max-width: 860px; margin: 0 auto; }
.scrim { display: none; }

.side-unit { margin-bottom: 4px; }
.side-unit-title { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.side-unit-title a { color: inherit; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-size: 0.93rem; font-weight: 550; line-height: 1.3; }
.side-link:hover { background: var(--surface-2); text-decoration: none; }
.side-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.side-link.disabled { color: var(--faint); pointer-events: none; }
.side-link .mastery-sq { flex: none; }
.side-sep { height: 1px; background: var(--border); margin: 12px 8px; }
.side-all { display: block; margin: 0 10px 12px; font-weight: 700; font-size: 0.9rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 42px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 0.95rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 2px rgba(24, 101, 242, 0.25); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
[data-theme="dark"] .btn-primary:hover { background: #7aaeff; border-color: #7aaeff; }
.btn-good { background: var(--good-strong); border-color: var(--good-strong); color: #fff; }
.btn-good:hover { background: #078a12; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 0.87rem; border-radius: 9px; }
.btn-lg { padding: 13px 24px; min-height: 50px; font-size: 1.04rem; border-radius: 12px; }
.btn-block { width: 100%; }
.kbd { display: inline-block; font-family: var(--mono); font-size: 0.72rem; font-weight: 700; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; color: var(--muted); background: var(--surface); line-height: 1.3; }
.btn .kbd { margin-left: 2px; opacity: 0.8; }
.btn-primary .kbd, .btn-good .kbd { color: inherit; border-color: rgba(255, 255, 255, 0.5); background: transparent; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.card-tight { padding: 14px 16px; }
.card h2, .card h3 { margin-top: 0; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; margin-bottom: 10px; }
.card-link { display: block; color: inherit; transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s; }
.card-link:hover { text-decoration: none; box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 14px; font-size: 1.2rem; font-weight: 800; }
.section-title:first-child { margin-top: 0; }
.eyebrow { font-size: 0.76rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); }

/* ---------- hero / home ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 28px 30px;
  background: linear-gradient(120deg, #0f3fa8 0%, #1865f2 45%, #6847d8 100%);
  color: #fff; box-shadow: var(--shadow-md);
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 280px; height: 280px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.hero::before { content: ""; position: absolute; right: 120px; bottom: -90px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, 0.06); }
.hero h1 { color: #fff; margin-bottom: 6px; font-size: 1.9rem; }
.hero p { color: rgba(255, 255, 255, 0.88); max-width: 640px; }
.hero .btn { border-color: rgba(255, 255, 255, 0.5); }
.hero .btn-light { background: #fff; color: #0f3fa8; border-color: #fff; }
.hero .btn-light:hover { background: #eef3ff; }
.hero .btn-outline { background: rgba(255, 255, 255, 0.1); color: #fff; }
.hero .btn-outline:hover { background: rgba(255, 255, 255, 0.2); }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 24px; align-items: center; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-stat { background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 16px; padding: 16px 18px; }
.hero-stat .big { font-size: 2.3rem; font-weight: 850; line-height: 1.05; }
.hero-stat .lbl { font-size: 0.82rem; color: rgba(255, 255, 255, 0.82); font-weight: 600; }
.gauge { width: 100%; height: 12px; background: rgba(255, 255, 255, 0.2); border-radius: 99px; position: relative; margin: 12px 0 6px; overflow: visible; }
.gauge-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ffd166, #7cf29c); transition: width 0.6s; }
.gauge-mark { position: absolute; top: -5px; bottom: -5px; width: 3px; background: #fff; border-radius: 2px; }
.gauge-mark span { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; font-weight: 800; white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat .v { font-size: 1.5rem; font-weight: 850; line-height: 1.1; }
.stat .k { font-size: 0.8rem; color: var(--muted); font-weight: 650; margin-top: 3px; }

.mastery-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.mastery-bar span { display: block; height: 100%; transition: width 0.5s; }
.mastery-bar .b4 { background: var(--m4); }
.mastery-bar .b3 { background: var(--m3); }
.mastery-bar .b2 { background: var(--m2); }
.mastery-bar .b1 { background: var(--m1-b); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.mastery-sq { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--m0-b); background: var(--m0); vertical-align: middle; }
.mastery-sq.lv1 { background: var(--m1); border-color: var(--m1-b); }
.mastery-sq.lv2 { background: var(--m2); border-color: var(--m2-b); }
.mastery-sq.lv3 { background: var(--m3); border-color: var(--m3-b); }
.mastery-sq.lv4 { background: var(--m4); border-color: var(--m4-b); position: relative; }
.mastery-sq.lv4::after { content: ""; position: absolute; inset: 2px; border-radius: 2px; background: linear-gradient(135deg, rgba(255, 255, 255, 0.45), transparent 60%); }
.mastery-sq.lg { width: 22px; height: 22px; border-radius: 6px; }
.mastery-sq.na { border-style: dashed; opacity: 0.6; }
.level-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 750; padding: 4px 10px 4px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.level-badge.lv3, .level-badge.lv4 { color: var(--violet); background: var(--violet-soft); }
.level-badge.lv2 { color: #b45f00; background: #fff1dc; }
[data-theme="dark"] .level-badge.lv2 { color: #ffbd5c; background: #3b2a10; }

.units-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.unit-card { position: relative; padding: 18px 20px 16px 24px; overflow: hidden; }
.unit-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--unit, var(--primary)); }
.unit-card .unit-n { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--unit, var(--primary)); }
[data-theme="dark"] .unit-card .unit-n { filter: brightness(1.45); }
.unit-card h3 { margin: 2px 0 6px; font-size: 1.1rem; }
.unit-card h3 a { color: var(--text); }
.unit-lessons { list-style: none; padding: 0; margin: 10px 0 12px; }
.unit-lessons li { margin: 0; }
.unit-lessons a { display: flex; align-items: center; gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: 8px; color: var(--text); font-size: 0.93rem; font-weight: 550; }
.unit-lessons a:hover { background: var(--surface-2); text-decoration: none; }
.unit-lessons a .lvl-name { margin-left: auto; font-size: 0.75rem; color: var(--faint); font-weight: 650; }
.unit-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.unit-progress { flex: 1; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.unit-progress span { display: block; height: 100%; background: var(--unit, var(--primary)); border-radius: 99px; }
.searchbox { width: 100%; padding: 11px 14px 11px 40px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b94a6' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px 50% / 18px; font-size: 0.95rem; }
.search-results { margin-top: 10px; }
.next-card { display: flex; align-items: center; gap: 16px; }
.next-card .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }

/* ---------- page header / tabs ---------- */
.crumbs { font-size: 0.86rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs a { color: var(--muted); }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin-bottom: 6px; }
.lesson-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 16px 0 22px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 0.95rem; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-size: 0.72rem; font-weight: 800; background: var(--surface-2); color: var(--muted); padding: 1px 7px; border-radius: 99px; }

/* ---------- learn content ---------- */
.learn-grid { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 28px; align-items: start; }
.toc { position: sticky; top: calc(var(--topbar) + 20px); font-size: 0.88rem; }
.toc ol { list-style: none; padding: 0; margin: 8px 0 0; counter-reset: toc; }
.toc li { margin: 0; }
.toc a { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-weight: 600; line-height: 1.35; }
.toc a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.toc a .dot { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 0.65rem; font-weight: 800; color: var(--faint); }
.toc a.read .dot { background: var(--good-strong); border-color: var(--good-strong); color: #fff; }
.toc a.current { color: var(--primary); background: var(--primary-soft); }
.objectives { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 22px; }
.objectives ul { list-style: none; padding: 0; margin: 8px 0 0; }
.objectives li { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; }
.objectives li .icon { color: var(--good); margin-top: 3px; }
.lsec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 20px; box-shadow: var(--shadow); }
.lsec > h2 { display: flex; align-items: baseline; gap: 12px; font-size: 1.32rem; }
.lsec > h2 .num { flex: none; font-size: 0.85rem; font-weight: 800; color: var(--primary); background: var(--primary-soft); border-radius: 8px; padding: 2px 9px; }
.blk { margin: 14px 0; }
.blk:first-child { margin-top: 0; }
.blk:last-child { margin-bottom: 0; }
.formula-box { border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); background: linear-gradient(180deg, var(--primary-soft), transparent 140%); border-radius: 12px; padding: 10px 18px; text-align: center; }
.formula-box .katex-display { margin: 0.4em 0; }
.formula-box .flabel { font-size: 0.86rem; color: var(--muted); font-weight: 600; }
.callout { border-radius: 12px; padding: 12px 16px 12px 46px; position: relative; border: 1px solid; }
.callout .c-ico { position: absolute; left: 14px; top: 13px; }
.callout .c-title { font-weight: 800; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.callout.keyidea { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.callout.keyidea .c-title, .callout.keyidea .c-ico { color: var(--primary); }
.callout.tip { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.callout.tip .c-title, .callout.tip .c-ico { color: var(--good); }
.callout.warning { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.callout.warning .c-title, .callout.warning .c-ico { color: var(--bad); }
.callout.polish { background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 30%, transparent); }
.callout.polish .c-title, .callout.polish .c-ico { color: var(--violet); }
.callout.polish::before { content: ""; position: absolute; right: 12px; top: 12px; width: 22px; height: 14px; border-radius: 2px; background: linear-gradient(#fff 50%, #dc143c 50%); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.example { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.example-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface-2); font-weight: 800; font-size: 0.92rem; }
.example-head .tag { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #fff; background: var(--warn); padding: 2px 8px; border-radius: 6px; }
[data-theme="dark"] .example-head .tag { color: #1b1300; }
.example-body { padding: 14px 18px; }
.example-steps { list-style: none; padding: 0; margin: 10px 0 0; counter-reset: st; }
.example-steps li { counter-increment: st; position: relative; padding: 6px 0 6px 38px; border-top: 1px dashed var(--border); animation: fadein 0.25s ease; }
.example-steps li::before { content: counter(st); position: absolute; left: 0; top: 7px; width: 25px; height: 25px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 0.8rem; display: grid; place-items: center; }
.example-answer { margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: var(--good-soft); font-weight: 600; animation: fadein 0.25s ease; }
.example-answer b { color: var(--good); }
.example-ctrl { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.figure { margin: 0; text-align: center; }
.figure svg.fig { max-height: 380px; }
.figure figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 8px; }
.table-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 0.95rem; background: var(--surface); }
table.tbl th, table.tbl td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
table.tbl th { background: var(--surface-2); font-weight: 750; }
table.tbl.center-cells td, table.tbl.center-cells th { text-align: center; }
.tbl-caption { font-size: 0.88rem; color: var(--muted); margin-top: 6px; }
.lesson-end { text-align: center; padding: 26px; }

/* ---------- questions ---------- */
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.q-top { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 0.85rem; font-weight: 700; color: var(--muted); flex-wrap: wrap; }
.q-top .diff { display: inline-flex; gap: 3px; align-items: center; }
.q-top .diff i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); display: inline-block; }
.q-top .diff i.on { background: var(--warn); }
.q-body { padding: 20px 22px 8px; }
.q-stem { font-size: 1.06rem; margin-bottom: 14px; }
.q-figure { margin: 4px 0 16px; text-align: center; }
.q-figure svg.fig { max-height: 300px; }
.choices { display: grid; gap: 10px; margin-bottom: 14px; }
.choices.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 11px 14px; min-height: 54px;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
  cursor: pointer; transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  font-size: 1.02rem;
}
.choice:hover { border-color: var(--border-strong); background: var(--surface-2); }
.choice .letter { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; color: var(--muted); background: var(--surface); }
.choice .ctext { flex: 1; min-width: 0; overflow-x: auto; }
.choice .mark { flex: none; margin-left: auto; display: none; }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.choice.selected .letter { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.choice.correct { border-color: var(--good-strong); background: var(--good-soft); box-shadow: none; }
.choice.correct .letter { background: var(--good-strong); border-color: var(--good-strong); color: #fff; }
.choice.correct .mark.ok { display: block; color: var(--good); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.choice.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice.wrong .mark.no { display: block; color: var(--bad); }
.choice.struck { opacity: 0.55; }
.choice.struck .ctext { text-decoration: line-through; text-decoration-color: var(--bad); }
.choice[disabled] { cursor: default; }
.choice[disabled]:hover { background: inherit; }
.choice.correct[disabled]:hover { background: var(--good-soft); }
.choice.wrong[disabled]:hover { background: var(--bad-soft); }
.q-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface); }
.q-actions .spacer { flex: 1; }
.feedback { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; font-weight: 700; margin: 0 0 14px; animation: pop 0.25s ease; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .fb-sub { font-weight: 550; color: var(--text); font-size: 0.92rem; }
.hint-box { border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: 0 10px 10px 0; padding: 10px 14px; margin: 0 0 14px; animation: fadein 0.25s; }
.hint-box .h-title { font-weight: 800; color: var(--warn); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.solution { border: 1px solid var(--border); border-radius: 12px; margin: 0 0 14px; overflow: hidden; animation: fadein 0.25s; }
.solution-head { padding: 9px 14px; background: var(--surface-2); font-weight: 800; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; }
.solution ol { margin: 0; padding: 10px 16px 12px 40px; }
.solution li { padding: 4px 0; animation: fadein 0.25s; }
.solution li::marker { font-weight: 800; color: var(--primary); }
.q-progress { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.q-progress i { width: 28px; height: 8px; border-radius: 99px; background: var(--surface-3); display: block; transition: background 0.2s; }
.q-progress i.cur { background: var(--primary); opacity: 0.45; }
.q-progress i.ok { background: var(--good-strong); }
.q-progress i.help { background: var(--warn); }
.q-progress i.no { background: var(--bad); }
.session-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.inline-check { border: 2px dashed color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: 14px; padding: 4px; }
.inline-check .q-card { box-shadow: none; border: 0; }
.inline-check-label { display: flex; align-items: center; gap: 8px; padding: 8px 16px 0; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
.lesson-tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.lesson-tag:hover { text-decoration: none; color: var(--text); }

/* ---------- results ---------- */
.result-hero { text-align: center; padding: 30px 20px; }
.result-score { font-size: 3.4rem; font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.result-score small { font-size: 1.3rem; color: var(--muted); font-weight: 700; }
.result-verdict { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 7px 16px; border-radius: 99px; font-weight: 800; }
.result-verdict.pass { background: var(--good-soft); color: var(--good); }
.result-verdict.fail { background: var(--bad-soft); color: var(--bad); }
.level-change { display: inline-flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 16px; border-radius: 14px; background: var(--surface-2); font-weight: 700; }
.review-list { display: grid; gap: 14px; }
.review-item summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 16px; font-weight: 650; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item summary .rnum { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; }
.review-item summary .rnum.ok { background: var(--good-soft); color: var(--good); }
.review-item summary .rnum.no { background: var(--bad-soft); color: var(--bad); }
.review-item summary .rnum.skip { background: var(--surface-3); color: var(--muted); }
.review-item summary .rstem { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.review-item[open] summary { border-bottom: 1px solid var(--border); }
.review-item .q-card { border: 0; box-shadow: none; border-radius: 0; }
.review-item { padding: 0; overflow: hidden; }
.breakdown td.bar-cell { width: 40%; }
.hbar { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hbar span { display: block; height: 100%; border-radius: 99px; background: var(--good-strong); }
.hbar span.mid { background: var(--warn); }
.hbar span.low { background: var(--bad); }

/* ---------- mock exam ---------- */
.exam-shell { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.exam-side { position: sticky; top: calc(var(--topbar) + 16px); }
.timer { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 1.7rem; font-weight: 800; padding: 10px; border-radius: 12px; background: var(--surface-2); letter-spacing: 0.02em; }
.timer.warn { background: var(--warn-soft); color: var(--warn); }
.timer.danger { background: var(--bad-soft); color: var(--bad); animation: pulse 1s infinite; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin: 14px 0; }
.palette button { position: relative; aspect-ratio: 1; border-radius: 9px; border: 2px solid var(--border); background: var(--surface); font-weight: 800; font-size: 0.86rem; cursor: pointer; color: var(--muted); padding: 0; }
.palette button:hover { border-color: var(--border-strong); }
.palette button.answered { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 50%, transparent); color: var(--primary); }
.palette button.current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); color: var(--text); }
.palette button.flagged::after { content: ""; position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.palette button.ok { background: var(--good-soft); border-color: var(--good-strong); color: var(--good); }
.palette button.no { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.palette-legend { display: grid; gap: 4px; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.palette-legend span { display: inline-flex; gap: 6px; align-items: center; }
.palette-legend i { width: 12px; height: 12px; border-radius: 4px; border: 2px solid var(--border); display: inline-block; }
.palette-legend i.a { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 50%, transparent); }
.palette-legend i.f { background: var(--warn); border-color: var(--warn); border-radius: 50%; }
.flag-btn.on { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.history-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding: 10px 0 0; position: relative; border-bottom: 1px solid var(--border); }
.history-chart .hb { flex: 1; max-width: 44px; border-radius: 6px 6px 0 0; background: var(--primary); position: relative; min-height: 4px; }
.history-chart .hb.pass { background: var(--good-strong); }
.history-chart .hb.fail { background: var(--bad); }
.history-chart .hb span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.history-chart .line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--good); }
.history-chart .line span { position: absolute; right: 0; top: -18px; font-size: 0.7rem; font-weight: 800; color: var(--good); }

/* ---------- flashcards ---------- */
.fc-wrap { perspective: 1400px; max-width: 640px; margin: 0 auto; }
.flashcard { position: relative; height: 300px; cursor: pointer; transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.3, 1); }
.flashcard.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-md); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; font-size: 1.15rem; overflow: auto; }
.fc-face .fc-label { position: absolute; top: 14px; left: 18px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.fc-back { transform: rotateY(180deg); background: linear-gradient(180deg, var(--primary-soft), var(--surface)); }
.fc-controls { display: flex; justify-content: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.leitner { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.leitner span { font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }

/* ---------- widgets ---------- */
.wg { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.wg-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: linear-gradient(90deg, var(--primary-soft), transparent); font-weight: 800; font-size: 0.92rem; color: var(--primary); border-bottom: 1px solid var(--border); }
.wg-head .tag { margin-left: auto; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
.wg-main { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 0; }
.wg-main.stacked { grid-template-columns: 1fr; }
.wg-canvas { padding: 12px; min-width: 0; display: flex; align-items: center; justify-content: center; background: var(--surface); }
.wg-canvas svg { width: 100%; height: auto; max-height: 420px; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.wg-panel { padding: 14px 16px; border-left: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: 12px; font-size: 0.92rem; min-width: 0; }
.wg-main.stacked .wg-panel { border-left: 0; border-top: 1px solid var(--border); }
.wg-slider { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.wg-slider .sl-name { font-weight: 800; min-width: 18px; font-style: italic; font-family: "Times New Roman", serif; font-size: 1.08rem; }
.wg-slider .sl-val { font-family: var(--mono); font-weight: 700; min-width: 46px; text-align: right; font-size: 0.88rem; }
.wg-slider input[type="range"] { width: 100%; accent-color: var(--primary); }
.wg-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.wg-toggle { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 0.84rem; }
.wg-toggle.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.wg-readout { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; overflow-x: auto; }
.wg-readout .rk { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.wg-readout .rv { font-weight: 650; }
.wg-readout .katex { font-size: 1.02em; }
.wg-formula { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; background: var(--surface); overflow-x: auto; min-height: 46px; }
.wg-note { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.wg-formula .wg-fn { display: inline-block; margin: 2px 12px; white-space: nowrap; }
.wg-dot { font-size: 0.85em; margin-right: 3px; }
.wg-caption { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--muted); background: var(--surface-2); }
.wg-input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font-family: var(--mono); font-size: 0.9rem; }
.wg-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.wg svg text { font-family: var(--font); }
.wg .w-grid { stroke: var(--fig-grid); stroke-width: 1; }
.wg .w-axis { stroke: var(--fig-soft); stroke-width: 1.4; }
.wg .w-tick { fill: var(--fig-soft); font-size: 11px; font-weight: 600; }
.wg .w-lbl { fill: var(--fig-ink); font-size: 13px; font-weight: 700; }
.wg .w-lbl-s { fill: var(--fig-soft); font-size: 12px; font-weight: 600; }
.wg .w-curve { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.wg .c-acc { stroke: var(--fig-acc); }
.wg .c-acc2 { stroke: var(--fig-acc2); }
.wg .c-good { stroke: var(--fig-good); }
.wg .c-bad { stroke: var(--fig-bad); }
.wg .c-ink { stroke: var(--fig-ink); }
.wg .c-soft { stroke: var(--fig-soft); }
.wg .f-acc { fill: var(--fig-acc); }
.wg .f-acc2 { fill: var(--fig-acc2); }
.wg .f-good { fill: var(--fig-good); }
.wg .f-bad { fill: var(--fig-bad); }
.wg .f-ink { fill: var(--fig-ink); }
.wg .f-soft { fill: var(--fig-soft); }
.wg .dashed { stroke-dasharray: 6 5; }
.wg .handle { cursor: grab; }
.wg .handle:active { cursor: grabbing; }
.wg .handle-ring { fill: transparent; stroke: transparent; stroke-width: 14; }
.wg .handle:hover .handle-ring { stroke: var(--fig-acc-soft); }
.wg-hint { font-size: 0.8rem; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.wg .bar { fill: var(--fig-acc); }
.wg .bar.neg { fill: var(--fig-acc2); }
.wg .bar.hl { fill: var(--fig-good); }
.wg .bar-theory { stroke: var(--fig-bad); stroke-width: 2.5; }
.wg-big { font-size: 1.4rem; font-weight: 850; }
.wg-kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; align-items: baseline; }
.wg-kv dt { color: var(--muted); font-weight: 650; font-size: 0.85rem; }
.wg-kv dd { margin: 0; font-weight: 700; }

/* ---------- misc pages ---------- */
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fact { padding: 16px 18px; }
.fact .v { font-size: 1.6rem; font-weight: 850; line-height: 1.1; color: var(--primary); }
.fact .k { font-weight: 700; margin-top: 4px; }
.fact .d { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.src { font-size: 0.8rem; color: var(--faint); }
.src a { color: var(--faint); text-decoration: underline; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--good-strong); flex: none; }
.glossary-table td:first-child { font-weight: 750; white-space: nowrap; }
.formula-group { break-inside: avoid; }
.formula-item { display: grid; grid-template-columns: minmax(0, 1fr); padding: 8px 0; border-bottom: 1px dashed var(--border); }
.formula-item .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.formula-item:last-child { border-bottom: 0; }
.formula-item .katex-display { margin: 0.2em 0; text-align: left; }
.formula-item .katex-display > .katex { text-align: left; }
.formula-item .flabel { font-size: 0.85rem; color: var(--muted); }
.plan-week { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.plan-week.current { background: var(--primary-soft); margin: 0 -16px; padding: 14px 16px; border-radius: 12px; border-bottom: 0; }
.plan-week.past { opacity: 0.75; }
.plan-week .wk { font-weight: 800; }
.plan-week .wk small { display: block; color: var(--muted); font-weight: 600; }
.plan-items { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-item { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 0.9rem; color: var(--text); }
.plan-item:hover { text-decoration: none; border-color: var(--border-strong); }
.plan-item.special { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heatmap i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-3); display: block; }
.heatmap i.l1 { background: #b7e4c0; }
.heatmap i.l2 { background: #6fcf86; }
.heatmap i.l3 { background: #2fa84a; }
.heatmap i.l4 { background: #146c2b; }
[data-theme="dark"] .heatmap i.l1 { background: #1f4a2b; }
[data-theme="dark"] .heatmap i.l2 { background: #2b7a40; }
[data-theme="dark"] .heatmap i.l3 { background: #3fae5a; }
[data-theme="dark"] .heatmap i.l4 { background: #7ee29a; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.badge-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 0.85rem; font-weight: 700; }
.badge-item .b-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); flex: none; }
.badge-item.earned .b-ico { background: linear-gradient(135deg, #ffd166, #f59e0b); color: #fff; }
.badge-item:not(.earned) { color: var(--faint); }
.badge-item small { display: block; font-weight: 550; color: var(--muted); font-size: 0.74rem; line-height: 1.3; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: var(--faint); margin-bottom: 8px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 0; color: var(--muted); font-weight: 600; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: 0.9rem; }
.field input, .field select { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; font-weight: 700; cursor: pointer; border-right: 1px solid var(--border); font-size: 0.9rem; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: var(--primary-ink); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); font-size: 0.93rem; }
.notice .icon { color: var(--warn); margin-top: 3px; }
.notice.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.notice.info .icon { color: var(--primary); }

/* ---------- toast / modal / confetti ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px; background: #182032; color: #fff; box-shadow: var(--shadow-lg); font-weight: 650; font-size: 0.92rem; animation: toastin 0.3s ease; max-width: 360px; }
[data-theme="dark"] .toast { background: #e7ecf4; color: #182032; }
.toast .t-pts { color: #ffd166; font-weight: 850; }
[data-theme="dark"] .toast .t-pts { color: #6847d8; }
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 25, 0.5); z-index: 300; display: grid; place-items: center; padding: 20px; animation: fadein 0.15s; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: min(480px, 100%); box-shadow: var(--shadow-lg); animation: pop 0.2s; }
.modal h3 { margin-bottom: 8px; }
.modal .row { justify-content: flex-end; margin-top: 18px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.6s cubic-bezier(0.2, 0.6, 0.4, 1) forwards; }
.shortcuts-table td:first-child { white-space: nowrap; }

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes toastin { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.65; } }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .nav a .lbl-long { display: none; }
  .learn-grid { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 1020px) {
  .wg-main { grid-template-columns: 1fr; }
  .wg-panel { border-left: 0; border-top: 1px solid var(--border); }
  .exam-shell { grid-template-columns: 1fr; }
  .exam-side { position: static; order: -1; }
  .palette { grid-template-columns: repeat(13, 1fr); }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --topbar: 54px; }
  .menu-btn { display: inline-grid; }
  .nav { display: none; }
  .sidebar { position: fixed; left: 0; top: var(--topbar); bottom: 0; height: auto; z-index: 60; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
  .sidebar[hidden] { display: block; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--topbar) 0 0 0; background: rgba(10, 15, 25, 0.35); z-index: 55; }
  main { padding: 18px 14px 70px; }
  .hero { padding: 22px 20px; border-radius: 16px; }
  .hero h1 { font-size: 1.5rem; }
  .hero-grid { grid-template-columns: 1fr; }
  .units-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lsec { padding: 16px 16px; }
  .q-body { padding: 16px 16px 6px; }
  .q-actions { padding: 12px 16px; }
  .q-top { padding: 10px 16px; }
  .choices.two-col { grid-template-columns: 1fr; }
  .plan-week { grid-template-columns: 1fr; gap: 8px; }
  .palette { grid-template-columns: repeat(9, 1fr); }
  .brand small { display: none; }
  .top-stats .pill.points { display: none; }
  h1 { font-size: 1.5rem; }
}
@media (max-width: 560px) {
  .info-grid { grid-template-columns: 1fr; }
  .flashcard { height: 260px; }
  .result-score { font-size: 2.8rem; }
  .q-actions .btn { flex: 1 1 auto; }
  .palette { grid-template-columns: repeat(7, 1fr); }
}

/* ---------- print (formula sheet, glossary) ---------- */
@media print {
  .topbar, .sidebar, .no-print, .toasts { display: none !important; }
  main { padding: 0; }
  body { background: #fff; }
  .card, .lsec { box-shadow: none; border-color: #ccc; }
  .formula-columns { columns: 2; }
}
.wg-lab { font-weight: 700; color: var(--muted); font-size: 0.9rem; }

/* ---------- app additions ---------- */
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow-md); }
.skip-link:focus { left: 8px; }
.feedback.info { background: var(--primary-soft); color: var(--primary); }
.feedback .icon { width: 1.35em; height: 1.35em; flex: none; }
.side-count { margin-left: auto; font-size: 0.72rem; font-weight: 800; padding: 1px 8px; border-radius: 99px; background: var(--bad-soft); color: var(--bad); }
.side-unit-title { color: var(--faint); }
.side-unit-title a { color: var(--muted); }
.side-unit-title a:hover { color: var(--text); text-decoration: none; }
.side-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unit, var(--primary)); flex: none; }
.side-link .icon { color: var(--faint); }
.side-link.active .icon { color: var(--primary); }
.good-ink { color: var(--good); font-weight: 700; }
.bad-ink { color: var(--bad); font-weight: 700; }
.modal-wide { width: min(720px, 100%); }
.modal-body { max-height: 60vh; overflow: auto; }
.modal-body p { margin: 0 0 0.6em; }
.checklist label { cursor: pointer; }
.checklist li > .icon { color: var(--good); margin-top: 4px; }
.formula-unit h2 { font-size: 1.15rem; margin-bottom: 4px; }
.formula-columns { columns: 2 340px; column-gap: 28px; }
.formula-group { break-inside: avoid; }
.formula-group h3 { font-size: 0.98rem; }
.fc-face > div { max-width: 100%; }
.next-card .ico .icon { width: 24px; height: 24px; }
.lesson-end h2 { margin-top: 4px; }
.hero .btn .icon, .btn .icon { width: 1.1em; height: 1.1em; }
.q-fb:empty { display: none; }
.q-top .lesson-tag { margin-left: 4px; }
.choice .mark .icon { width: 1.4em; height: 1.4em; }
.review-item summary .rnum .icon { width: 15px; height: 15px; }
.stat .v .icon { vertical-align: -0.12em; }
.tabs .tab .icon { width: 1.05em; height: 1.05em; }
.exam-side .card { padding: 16px; }
.timer .icon { width: 0.9em; height: 0.9em; }
.result-hero .result-verdict .icon { width: 1.2em; height: 1.2em; }
.level-change .icon { color: var(--faint); }
.history-chart { margin-top: 18px; }
.seg { flex-wrap: wrap; }
.plan-item .mastery-sq { width: 13px; height: 13px; }
.badge-item .b-ico .icon { width: 18px; height: 18px; }
.legend .heatmap i { width: 11px; height: 11px; }
.unit-card h3 a:hover { color: var(--primary); }
.lsec .figure, .lsec .q-figure { overflow-x: auto; }
.nobr { white-space: nowrap; }
.tag-bonus { display: inline-block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; margin-left: 6px; }
@media (max-width: 900px) {
  .exam-side .palette { grid-template-columns: repeat(9, 1fr); }
  .session-head h2 { font-size: 1.15rem; }
}

.tab-short { display: none; }
@media (max-width: 560px) {
  .tabs { gap: 0; }
  .tab { padding: 10px 9px; gap: 5px; font-size: 0.92rem; }
  .tab .icon, .tab .count, .tab-long { display: none; }
  .tab-short { display: inline; }
}

/* bonus (beyond the exam scope) */
.bonus-wrap { border: 1px dashed var(--warn); border-radius: 12px; padding: 4px 14px 2px; margin: 14px 0; background: color-mix(in srgb, var(--warn-soft) 40%, transparent); }
.bonus-label { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--warn); margin: 8px 0 2px; }
.bonus-label .icon { width: 14px; height: 14px; }
.bonus-note { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; color: var(--muted); background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; margin: 4px 0 14px; }
.bonus-note .icon { color: var(--warn); flex: none; margin-top: 2px; }
.lsec h2 .tag-bonus { margin-left: 4px; }
.toc .tag-bonus { font-size: 0.6rem; padding: 1px 5px; margin-left: 2px; }
.bonus-card { margin-top: 14px; border-style: dashed; }
.fc-label .tag-bonus { font-size: 0.6rem; }
.glossary-table { table-layout: fixed; }
.glossary-table th:nth-child(1) { width: 31%; }
.glossary-table th:nth-child(2) { width: 27%; }
@media (max-width: 640px) { .glossary-table { table-layout: auto; } }
@media (max-width: 560px) { .intro-ico { display: none; } }
