@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/Inter.var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #f6f7fb; --panel: #ffffff; --ink: #101828; --mut: #667085; --line: #eaecf0;
  --acc: #ff6b1a; --acc-soft: #fff3ea; --acc2: #4f46e5; --grn: #12b76a; --red: #e03131;
  --r: 18px; --shadow: 0 8px 24px rgba(16, 24, 40, .06);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0f1420; --panel: #171e2e; --ink: #e8edf6; --mut: #8b98b8; --line: #263248;
  --acc: #ff7a1a; --acc-soft: rgba(255, 122, 26, .14); --acc2: #8b93ff; --grn: #3ddc84;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc2); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { vertical-align: -3px; flex-shrink: 0; }
.sec-ic { display: inline-flex; margin-right: 6px; color: var(--accent); }
.sec-ic .ic { vertical-align: -4px; }
details.answers { margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); }
details.answers summary { cursor: pointer; padding: 10px 14px; font-weight: 600; color: var(--accent2); list-style: none; }
details.answers summary::-webkit-details-marker { display: none; }
details.answers > *:not(summary) { padding: 0 14px 12px; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 11px 22px; background: color-mix(in srgb, var(--panel) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; color: var(--ink); letter-spacing: -.02em; margin-right: 8px; }
.brand span { color: var(--acc); }
.topnav { display: flex; gap: 2px; }
.topnav a {
  display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; font-size: 13.5px;
  padding: 7px 12px; border-radius: 999px;
}
.topnav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); text-decoration: none; }
.pill { background: var(--acc2); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.overall { margin-left: auto; display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--mut); font-weight: 700; }
.ring { transform: rotate(-90deg); }
.ring .bgc { stroke: var(--line); }
.ring .fgc { stroke: var(--acc); transition: stroke-dashoffset .4s; }
.gear {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.gear:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.settings-menu {
  position: absolute; right: 16px; top: 58px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; z-index: 30; width: 230px; display: none;
}
.settings-menu.open { display: block; }
.settings-menu label { display: block; font-size: 11px; color: var(--mut); font-weight: 700; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.settings-menu select { width: 100%; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 14px; font-family: inherit; }

.layout { display: flex; min-height: calc(100vh - 57px); }
.sidebar {
  width: 300px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  padding: 16px 12px; overflow-y: auto; max-height: calc(100vh - 57px); position: sticky; top: 57px;
}
.sidebar h4 { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mut); font-weight: 700; }
.nav-unit { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; font-size: 13.5px; font-weight: 700; color: var(--ink); border-radius: 10px; }
.nav-unit:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); text-decoration: none; }
.nav-lesson { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 9px; font-size: 13px; color: var(--ink); margin: 1px 0; }
.nav-lesson:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); text-decoration: none; }
.nav-lesson.active { background: var(--acc-soft); color: var(--acc); font-weight: 700; }
.dot { width: 17px; height: 17px; border-radius: 50%; background: var(--line); display: inline-flex; align-items: center; justify-content: center; color: transparent; flex-shrink: 0; }
.dot.done { background: var(--grn); color: #fff; }
.nav-page { display: block; padding: 5px 10px; font-size: 13px; color: var(--mut); border-radius: 8px; }
.nav-page:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); text-decoration: none; }

.view { flex: 1; padding: 30px 40px 80px; max-width: 960px; }
.view > h1 { font-size: 29px; letter-spacing: -.02em; margin: 6px 0 4px; display: flex; align-items: center; gap: 10px; }
.view h2 { border-bottom: 2px solid var(--line); padding-bottom: 8px; margin-top: 38px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.view h3 { margin-top: 28px; font-size: 16.5px; display: flex; align-items: center; gap: 8px; }
.meta { color: var(--mut); font-size: 13.5px; }
.view table { border-collapse: separate; border-spacing: 0; margin: 14px 0; display: block; overflow-x: auto; background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); }
.view th { background: color-mix(in srgb, var(--ink) 4%, var(--panel)); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); }
.view th, .view td { padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.view tr:last-child td { border-bottom: none; }
.view blockquote {
  border-left: 4px solid var(--acc2); margin: 14px 0; padding: 10px 16px;
  background: color-mix(in srgb, var(--acc2) 6%, var(--panel)); border-radius: 0 12px 12px 0; line-height: 1.65;
}
.view code { background: color-mix(in srgb, var(--ink) 6%, var(--panel)); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; font-family: var(--mono); }
.view hr { border: none; border-top: 1px solid var(--line); margin: 26px 0; }
.view ul, .view ol { padding-left: 22px; line-height: 1.7; }

.audio-player {
  display: flex; align-items: center; gap: 13px; border-radius: var(--r); padding: 13px 16px; margin: 14px 0;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.audio-player audio { flex: 1; height: 38px; }
.audio-play { width: 42px; height: 42px; border-radius: 50%; background: var(--acc); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.audio-label { font-size: 12.5px; color: var(--mut); font-weight: 600; }
.audio-link { font-size: 13px; font-weight: 600; }
.cards-link {
  display: inline-flex; align-items: center; gap: 7px; background: var(--acc-soft);
  border: 1px solid color-mix(in srgb, var(--acc) 35%, var(--line)); border-radius: 999px;
  padding: 7px 15px; font-weight: 700; color: var(--ink); font-size: 13.5px;
}
.cards-link:hover { text-decoration: none; filter: brightness(1.03); }

.lesson-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lesson-head h1 { flex: 1; min-width: 240px; margin: 0; }
.btn {
  border: none; border-radius: 999px; padding: 9px 17px; font-weight: 700; cursor: pointer; font-size: 13.5px;
  font-family: inherit; display: inline-flex; align-items: center; gap: 7px; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-done { background: var(--grn); color: #fff; }
.btn-done.done { background: var(--line); color: var(--mut); }
.btn-prev, .btn-next { background: var(--panel); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow); }
.btn-continue { background: var(--acc); color: #fff; font-size: 14.5px; padding: 11px 20px; }
.pill-time { background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--mut); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 4px 0 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-num { font-size: 26px; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 6px; }
.stat-sub { font-size: 14px; color: var(--mut); font-weight: 600; }
.stat-lbl { font-size: 12px; color: var(--mut); font-weight: 600; margin-top: 2px; }

.flashcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.flashcard { perspective: 800px; height: 138px; cursor: pointer; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .4s cubic-bezier(.2,.7,.3,1.2); }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 12px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--panel); font-size: 15px; font-weight: 600; box-shadow: var(--shadow);
}
.flashcard .back { transform: rotateY(180deg); background: color-mix(in srgb, var(--grn) 10%, var(--panel)); border-color: color-mix(in srgb, var(--grn) 35%, var(--line)); font-size: 13.5px; font-weight: 500; }
.flashcard .tag { position: absolute; bottom: 5px; right: 10px; font-size: 10px; color: var(--mut); font-weight: 500; }

.unit-list { display: grid; gap: 12px; }
.unit-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; display: block; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .12s, border-color .15s;
}
.unit-card:hover { text-decoration: none; border-color: var(--acc2); transform: translateY(-2px); }
.unit-card .meta { margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cardsheet { width: 100%; max-width: 1100px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--shadow); }
.lesson-nav { display: flex; justify-content: space-between; margin-top: 46px; }

.selftest li { font-family: var(--mono); font-size: 13px; padding: 3px 0; list-style: none; }
.selftest .pass { color: var(--grn); font-weight: 700; }
.selftest .fail { color: var(--red); font-weight: 700; }

.sidebar-toggle { display: none; }
.sidebar.collapsed { display: none; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
  .view { padding: 18px 14px 60px; }
  .topbar { flex-wrap: nowrap; overflow-x: auto; padding: 10px 12px; gap: 6px; }
  .brand { font-size: 15px; }
  .brand span { display: none; }
  .topnav { flex-shrink: 0; }
  .topnav a { padding: 6px 9px; font-size: 12.5px; white-space: nowrap; }
  #overall-label { display: none; }
  .sidebar-toggle { display: inline-flex; }
  .lesson-head { flex-wrap: wrap; gap: 8px; }
  .lesson-head h1 { font-size: 22px; }
  .view table { font-size: 13px; }
  .flashcards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
}

.ex { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; background: var(--panel2); }
.ex-q { font-weight: 600; margin: 0 0 8px; }
.ex-opt, .ex-chip { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 9px; padding: 7px 12px; margin: 3px 4px 3px 0; cursor: pointer; font-size: 14px; }
.ex-opt:hover, .ex-chip:hover { border-color: var(--accent); }
.ex-opt.ok, .ex-chip.ok { background: #1d4d33; border-color: #2e7d4f; color: #c9f2d9; }
.ex-opt.bad { background: #5a2330; border-color: #a33; color: #ffd7dc; }
.ex-in { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 14px; width: min(320px, 100%); }
.ex-fb { margin-top: 8px; font-size: 13.5px; color: var(--muted); min-height: 18px; }
.ex-fb.ok { color: #6fdc9c; }
.ex-fb.bad { color: #ff9aa8; }
.ex-built { font-style: italic; min-height: 20px; margin: 6px 0; }
.ex-score { color: var(--accent2); font-weight: 600; }

.trackbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 4px; }
.trackbar .ex-chip.ok { background: var(--acc2); border-color: var(--acc2); color: #fff; }
