/* LekhaIQ Learning Book - styles
 * Tokens first; every colour is a custom property so the dark theme is a
 * redefinition, not a second stylesheet. */

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f1f4f7;
  --border: #e2e7ec;
  --text: #2b3440;
  --muted: #5e6a78;
  --heading: #12233d;
  --accent: #0f7a64;
  --accent-strong: #0b5f4e;
  --accent-soft: #e3f4ef;
  --info: #1f5fbf;
  --info-soft: #e8f0fc;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --tip: #6b3fa0;
  --tip-soft: #f2ecfa;
  --dr: #1f5fbf;
  --cr: #b45309;
  --shadow: 0 1px 2px rgba(18, 35, 61, 0.06), 0 4px 16px rgba(18, 35, 61, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 300px;
  --topbar-h: 60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --measure: 760px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1520;
    --surface: #151e2b;
    --surface-2: #1b2636;
    --border: #2a3748;
    --text: #d4dbe4;
    --muted: #97a3b3;
    --heading: #eef2f7;
    --accent: #34c29e;
    --accent-strong: #5bd6b5;
    --accent-soft: #12352e;
    --info: #7aa7f0;
    --info-soft: #172840;
    --warn: #f0b660;
    --warn-soft: #33270f;
    --danger: #f08a80;
    --danger-soft: #3a1a17;
    --tip: #c3a2ec;
    --tip-soft: #2a1f3a;
    --dr: #7aa7f0;
    --cr: #f0b660;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1520;
  --surface: #151e2b;
  --surface-2: #1b2636;
  --border: #2a3748;
  --text: #d4dbe4;
  --muted: #97a3b3;
  --heading: #eef2f7;
  --accent: #34c29e;
  --accent-strong: #5bd6b5;
  --accent-soft: #12352e;
  --info: #7aa7f0;
  --info-soft: #172840;
  --warn: #f0b660;
  --warn-soft: #33270f;
  --danger: #f08a80;
  --danger-soft: #3a1a17;
  --tip: #c3a2ec;
  --tip-soft: #2a1f3a;
  --dr: #7aa7f0;
  --cr: #f0b660;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4 {
  color: var(--heading);
  line-height: 1.3;
  margin: 1.6em 0 0.5em;
}
h1 {
  font-size: 2rem;
  margin-top: 0.2em;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.45rem;
  padding-top: 0.4em;
  border-top: 1px solid var(--border);
}
h3 {
  font-size: 1.15rem;
}
p {
  margin: 0.7em 0;
}
a {
  color: var(--accent-strong);
}
code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05em 0.35em;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus {
  top: 8px;
}

/* ---------- Buttons & inputs ---------- */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--heading);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover {
  background: var(--surface-2);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-strong);
}
:root[data-theme="dark"] .btn-primary,
:root:not([data-theme="light"]) .btn-primary {
  color: #fff;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.icon-btn {
  width: 38px;
  height: 38px;
  justify-content: center;
  padding: 0;
}
input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.95rem;
}
textarea {
  min-height: 120px;
  resize: vertical;
}
label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--heading);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--heading);
  font-weight: 700;
  white-space: nowrap;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
}
.brand small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
}
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin-left: auto;
}
.search-wrap input {
  padding-left: 36px;
  background: var(--surface-2);
}
.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 70vh;
  overflow: auto;
  padding: 6px;
  display: none;
}
.search-results.open {
  display: block;
}
.search-results a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.search-results a:hover,
.search-results a.active {
  background: var(--accent-soft);
}
.search-results strong {
  color: var(--heading);
  display: block;
  font-size: 0.92rem;
}
.search-results span {
  font-size: 0.82rem;
  color: var(--muted);
}
.search-results mark {
  background: var(--warn-soft);
  color: inherit;
}
.top-actions {
  display: flex;
  gap: 6px;
}
.progress-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  height: 3px;
  background: var(--accent);
  width: 0;
  z-index: 41;
  transition: width 0.1s linear;
}
.menu-toggle {
  display: none;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 10px 40px;
}
.overall {
  padding: 10px 12px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.overall-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}
.meter {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}
.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s;
}
.nav-links a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.nav-links a:hover {
  background: var(--surface-2);
}
.nav-links a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.part {
  margin-top: 6px;
}
.part-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.part-toggle:hover {
  background: var(--surface-2);
}
.part-toggle .count {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.75rem;
}
.part-toggle .chev {
  transition: transform 0.2s;
}
.part-toggle[aria-expanded="false"] .chev {
  transform: rotate(-90deg);
}
.part ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.part ol[hidden] {
  display: none;
}
.part li a {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px;
  align-items: start;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
}
.part li a:hover {
  background: var(--surface-2);
}
.part li a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 10px;
  margin-top: 1px;
  color: #fff;
}
.done .dot {
  background: var(--accent);
  border-color: var(--accent);
}

.main {
  min-width: 0;
  padding: 28px 40px 80px;
}
.lesson {
  max-width: var(--measure);
  margin: 0 auto;
}
.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.breadcrumb a {
  color: var(--muted);
}
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0 20px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.lesson-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* ---------- Lesson content blocks ---------- */
.objectives {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
}
.objectives h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.objectives ul {
  margin: 0;
  padding-left: 20px;
}
.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0;
  border: 1px solid transparent;
}
.callout > :first-child {
  margin-top: 0;
}
.callout > :last-child {
  margin-bottom: 0;
}
.callout-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--heading);
}
.callout.example {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}
.callout.important {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.callout.mistake {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}
.callout.warning {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.callout.tip {
  background: var(--tip-soft);
  border-color: color-mix(in srgb, var(--tip) 25%, transparent);
}
.callout.app {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
}
.level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  vertical-align: middle;
}
.level-1 {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.level-2 {
  background: var(--info-soft);
  color: var(--info);
}
.level-3 {
  background: var(--warn-soft);
  color: var(--warn);
}
.path {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: normal;
}

.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th,
td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: var(--surface-2);
  color: var(--heading);
  font-weight: 600;
}
tr:last-child td {
  border-bottom: 0;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tr.total td {
  font-weight: 700;
  background: var(--surface-2);
}
.table-caption {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.journal td.cr-acct {
  padding-left: 36px;
}
.dr {
  color: var(--dr);
  font-weight: 600;
}
.cr {
  color: var(--cr);
  font-weight: 600;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 2px 0 12px 46px;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.steps > li::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 32px;
  bottom: 2px;
  width: 2px;
  background: var(--border);
}
.steps > li:last-child::after {
  display: none;
}

.shot {
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.shot img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}
.shot figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.85);
  display: none;
  place-items: center;
  z-index: 90;
  padding: 20px;
}
.lightbox.open {
  display: grid;
}
.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: block;
}
a.card:hover {
  border-color: var(--accent);
}
.card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.card .card-foot {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Screen tour */
.tour-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 20px 12px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}
.tour-item h3 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tour-item h4 {
  margin: 14px 0 4px;
  color: var(--heading);
}

/* Equation diagram */
.equation {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  margin: 18px 0;
}
.eq-box {
  flex: 1 1 140px;
  max-width: 220px;
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.eq-box b {
  display: block;
  color: var(--heading);
}
.eq-box .eq-val {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.eq-sign {
  align-self: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--muted);
}
.eq-box.a {
  border-color: var(--dr);
}
.eq-box.l,
.eq-box.c {
  border-color: var(--cr);
}

/* Flow diagram */
.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 18px 0;
}
.flow-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--heading);
}
.flow-arrow {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Interactive widgets ---------- */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 22px 0;
  box-shadow: var(--shadow);
}
.widget h3 {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.widget .hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 12px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.form-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-out {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-variant-numeric: tabular-nums;
}
.calc-out .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}
.calc-out .row:last-of-type {
  border-bottom: 0;
}
.calc-out .row.big {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--heading);
}
.calc-out .explain {
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 8px;
}
.neg {
  color: var(--danger);
}
.pos {
  color: var(--accent-strong);
}

/* Quiz */
.quiz {
  counter-reset: q;
}
.q {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
  background: var(--surface);
}
.q-text {
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 10px;
}
.q-text::before {
  counter-increment: q;
  content: counter(q) ". ";
  color: var(--accent);
}
.q-opts {
  display: grid;
  gap: 6px;
}
.q-opt {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.95rem;
}
.q-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.q-opt:disabled {
  cursor: default;
}
.q-opt.correct {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.q-opt.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.q-feedback {
  margin-top: 10px;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface-2);
}
.q-feedback strong.ok {
  color: var(--accent-strong);
}
.q-feedback strong.no {
  color: var(--danger);
}
.quiz-score {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  margin-top: 14px;
}
.quiz-score b {
  font-size: 1.2rem;
  color: var(--heading);
}

/* Debit/credit practice */
.drcr-q {
  font-weight: 600;
  color: var(--heading);
}
.drcr-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  border: 0;
  background: var(--surface);
  padding: 5px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.seg button + button {
  border-left: 1px solid var(--border);
}
.seg button[aria-pressed="true"].d {
  background: var(--info-soft);
  color: var(--dr);
}
.seg button[aria-pressed="true"].c {
  background: var(--warn-soft);
  color: var(--cr);
}

/* Lesson footer */
.complete-box {
  margin: 36px 0 18px;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.pager a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: var(--heading);
}
.pager a:hover {
  border-color: var(--accent);
}
.pager small {
  display: block;
  color: var(--muted);
}
.pager .next {
  text-align: right;
  grid-column: 2;
}
.notes-box {
  margin-top: 24px;
}
.notes-box .notes-status {
  font-size: 0.8rem;
  color: var(--muted);
}
.summary-list li {
  margin: 4px 0;
}
.answer details,
details.answer {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 8px 0;
  background: var(--surface);
}
details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--heading);
}
.glossary-letter {
  font-size: 1.3rem;
  margin-top: 1.4em;
}
dl.glossary dt {
  font-weight: 700;
  color: var(--heading);
  margin-top: 14px;
}
dl.glossary dd {
  margin: 2px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--border);
}
dl.glossary dd .ex {
  color: var(--muted);
  font-size: 0.92rem;
}
.az {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 12px 0;
}
.az a {
  min-width: 30px;
  text-align: center;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--heading);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 0.9rem;
  transition: transform 0.25s;
  z-index: 95;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 440px;
  padding: 22px;
}
dialog::backdrop {
  background: rgba(5, 10, 20, 0.5);
}
dialog h2 {
  border: 0;
  margin-top: 0;
  padding: 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Reading (focus) mode ---------- */
body.reading .sidebar {
  display: none;
}
body.reading .layout {
  grid-template-columns: 1fr;
}
body.reading .main {
  font-size: 18px;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    width: min(320px, 88vw);
    z-index: 45;
    transform: translateX(-105%);
    transition: transform 0.25s;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar {
    transform: none;
  }
  body.reading .sidebar {
    display: block;
  }
  .main {
    padding: 22px 16px 70px;
  }
  .brand-text small {
    display: none;
  }
}
@media (max-width: 640px) {
  body {
    font-size: 16px;
  }
  h1 {
    font-size: 1.6rem;
  }
  .brand-text {
    display: none;
  }
  .top-actions .hide-sm {
    display: none;
  }
  .pager {
    grid-template-columns: 1fr;
  }
  .pager .next {
    grid-column: 1;
  }
  .drcr-row {
    grid-template-columns: 1fr;
  }
  .lesson-tools {
    margin-left: 0;
  }
}

/* ---------- Print ---------- */
@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #f3f3f3;
    --text: #111;
    --heading: #000;
    --border: #ccc;
  }
  .topbar,
  .sidebar,
  .progress-bar,
  .lesson-tools,
  .complete-box,
  .pager,
  .notes-box,
  .widget,
  .quiz-score,
  .q-opts button:not(.correct),
  .skip-link,
  .toast {
    display: none !important;
  }
  .layout {
    display: block;
  }
  .main {
    padding: 0;
  }
  .lesson {
    max-width: none;
  }
  body {
    font-size: 11pt;
  }
  h2 {
    break-after: avoid;
  }
  .table-wrap,
  .callout,
  .shot,
  .q {
    break-inside: avoid;
    box-shadow: none;
  }
  details {
    display: block;
  }
  details > *:not(summary) {
    display: block !important;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
}
