/* ============ Variables ============ */
:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #1b2430;
  --muted: #5a6778;
  --border: #dde3ea;
  --primary: #00758f;
  --primary-strong: #005a70;
  --primary-soft: #e0f2f6;
  --accent: #e48e00;
  --ok: #17803d;
  --ok-soft: #e3f5ea;
  --err: #c2312d;
  --err-soft: #fdecec;
  --warn-soft: #fff4dd;
  --info-soft: #e6f0ff;
  --code-bg: #0f1a26;
  --code-bg-2: #16232f;
  --code-text: #d6e2ee;
  --tok-kw: #ff9d5c;
  --tok-str: #8bd59a;
  --tok-num: #e6c07b;
  --tok-com: #6f8397;
  --tok-fn: #7cc4ff;
  --tok-ty: #c9a0ff;
  --lv1: #1f9d55;
  --lv2: #2b6cb0;
  --lv3: #d97706;
  --lv4: #9333ea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 12px;
  --sidebar-w: 300px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg: #0d141b;
  --surface: #131c25;
  --surface-2: #1a2531;
  --text: #e3eaf1;
  --muted: #93a2b3;
  --border: #253242;
  --primary: #3fb6d3;
  --primary-strong: #7fd3e8;
  --primary-soft: #12303a;
  --accent: #f5a623;
  --ok: #4cc77c;
  --ok-soft: #12301f;
  --err: #ff7a76;
  --err-soft: #3a1a1a;
  --warn-soft: #3a2f14;
  --info-soft: #14284a;
  --code-bg: #0a1118;
  --code-bg-2: #101a24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --lv1: #4cc77c;
  --lv2: #6aaaf0;
  --lv3: #f5a623;
  --lv4: #c58bff;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 var(--font); -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: 1.6em 0 .55em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2rem; margin-top: .3em; }
h2 { font-size: 1.45rem; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.15rem; }
p { margin: .8em 0; }
ul, ol { padding-left: 1.4em; }
li { margin: .3em 0; }
code, kbd {
  font-family: var(--mono); font-size: .88em; background: var(--surface-2);
  padding: .12em .4em; border-radius: 5px; border: 1px solid var(--border);
}
kbd { border-bottom-width: 2px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* ============ Topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 50; height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.1rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--primary); }
.brand-logo { display: inline-flex; }
.search { position: relative; flex: 1; max-width: 420px; margin-left: 8px; }
.search input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .92rem;
}
.search input:focus { outline: 2px solid var(--primary); background: var(--surface); }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; padding: 6px;
}
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--primary-soft); text-decoration: none; }
.search-results small { display: block; color: var(--muted); }
.search-results .none { padding: 10px; color: var(--muted); }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-size: .93rem; font-weight: 500; }
.topnav a:hover, .topnav a.active { background: var(--primary-soft); color: var(--primary-strong); text-decoration: none; }
.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
:root[data-theme="dark"] .i-sun, :root:not([data-theme="dark"]) .i-moon { display: none; }

/* ============ Layout ============ */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 60px); }
.sidebar {
  position: sticky; top: 60px; width: var(--sidebar-w); flex: none; height: calc(100vh - 60px); overflow-y: auto;
  padding: 16px 12px 40px; border-right: 1px solid var(--border); background: var(--surface);
}
main { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 80px; outline: none; }
.scrim { display: none; }

/* Sidebar */
.side-progress { padding: 4px 8px 14px; font-size: .82rem; color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
.side-level { margin-bottom: 6px; }
.side-level > button {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 8px; border: 0;
  background: transparent; color: var(--text); font-weight: 700; font-size: .9rem; border-radius: 8px;
}
.side-level > button:hover { background: var(--surface-2); }
.side-level .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.side-level .count { margin-left: auto; font-weight: 500; font-size: .76rem; color: var(--muted); }
.side-level .chev { transition: transform .15s; color: var(--muted); }
.side-level.collapsed .chev { transform: rotate(-90deg); }
.side-level.collapsed ul { display: none; }
.side-level ul { list-style: none; margin: 2px 0 8px; padding: 0; }
.side-level li { margin: 0; }
.side-level li a {
  display: flex; gap: 8px; align-items: baseline; padding: 6px 8px 6px 14px; border-radius: 8px;
  color: var(--text); font-size: .89rem; line-height: 1.35;
}
.side-level li a:hover { background: var(--surface-2); text-decoration: none; }
.side-level li a.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.side-level li .n { flex: none; width: 1.5em; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.side-level li .ck { margin-left: auto; flex: none; color: var(--ok); font-weight: 700; visibility: hidden; }
.side-level li a.done .ck { visibility: visible; }

/* ============ Home ============ */
.wrap { max-width: 1000px; margin: 0 auto; }
.hero {
  border-radius: 20px; padding: clamp(24px, 5vw, 48px); color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #00566b 0%, #00758f 45%, #1394b0 100%);
  box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 65%);
}
.hero h1 { color: #fff; font-size: clamp(1.8rem, 4vw, 2.7rem); margin: 0 0 .3em; }
.hero p { max-width: 620px; font-size: 1.08rem; opacity: .95; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .93rem; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-strong); }
.hero .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .4); color: #fff; }
.hero .btn.solid { background: #fff; color: #00566b; border-color: #fff; }
.hero .btn:hover { background: rgba(255, 255, 255, .25); }
.hero .btn.solid:hover { background: #e9f7fa; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 18px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .86rem; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 26px 0; }
.how div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.how h3 { margin: 0 0 .3em; font-size: 1rem; }
.how p { margin: 0; color: var(--muted); font-size: .92rem; }
.levels { display: grid; gap: 18px; margin-top: 10px; }
.level-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.level-card header { padding: 18px 22px; border-left: 6px solid var(--c); }
.level-card header h2 { margin: 0; border: 0; padding: 0; font-size: 1.25rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.level-card header p { margin: .3em 0 0; color: var(--muted); font-size: .95rem; }
.level-card ol { list-style: none; margin: 0; padding: 0 12px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 2px 14px; }
.level-card li { margin: 0; }
.level-card li a {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 10px; color: var(--text); line-height: 1.35;
}
.level-card li a:hover { background: var(--surface-2); text-decoration: none; }
.level-card li .num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c);
}
.level-card li.done .num { background: var(--ok); color: #fff; }
.level-card li small { display: block; color: var(--muted); font-size: .8rem; }
.pill {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 99px; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c);
}

/* ============ Lección ============ */
.lesson-grid > * { min-width: 0; }
.lesson-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; max-width: 1080px; margin: 0 auto; }
@media (min-width: 1300px) { .lesson-grid { grid-template-columns: minmax(0, 1fr) 210px; } }
.crumbs { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lesson-meta { display: flex; gap: 8px 14px; align-items: center; color: var(--muted); font-size: .88rem; margin-bottom: 6px; flex-wrap: wrap; }
.lesson-meta span + span::before { content: "·"; margin-right: 14px; }
.lesson-lead { font-size: 1.12rem; color: var(--muted); margin-top: 0; }
article h2 { margin-top: 1.9em; }
article img, article table { max-width: 100%; }
article table.datos, article table.ref {
  border-collapse: collapse; margin: 1em 0; font-size: .92rem; display: block; overflow-x: auto; max-width: 100%;
}
article table.datos th, article table.datos td, article table.ref th, article table.ref td {
  border: 1px solid var(--border); padding: 7px 12px; text-align: left; vertical-align: top;
}
article table.datos th, article table.ref th { background: var(--surface-2); }
article table.ref td:first-child { white-space: nowrap; }
.toc { position: sticky; top: 84px; align-self: start; font-size: .85rem; display: none; max-height: calc(100vh - 110px); overflow: auto; }
@media (min-width: 1300px) { .toc { display: block; } }
.toc h4 { margin: 0 0 8px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc a { display: block; padding: 4px 0 4px 12px; border-left: 2px solid var(--border); color: var(--muted); line-height: 1.35; }
.toc a:hover { color: var(--primary); text-decoration: none; border-color: var(--primary); }
.lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 34px 0 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.lesson-actions .spacer { flex: 1; }
.btn.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.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); color: var(--text);
}
.pager a:hover { border-color: var(--primary); text-decoration: none; }
.pager small { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.pager .next { text-align: right; grid-column: 2; }

/* Notas */
aside.tip, aside.warn, aside.info, aside.real {
  margin: 1.2em 0; padding: 12px 16px 12px 46px; border-radius: 10px; position: relative; border: 1px solid transparent;
}
aside > :first-child { margin-top: 0; } aside > :last-child { margin-bottom: 0; }
aside::before { position: absolute; left: 14px; top: 11px; font-size: 1.15rem; line-height: 1.5; }
aside.tip { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); } aside.tip::before { content: "💡"; }
aside.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); } aside.warn::before { content: "⚠️"; }
aside.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--lv2) 35%, transparent); } aside.info::before { content: "ℹ️"; }
aside.real { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 40%, transparent); } aside.real::before { content: "🐬"; }

/* ============ Código ============ */
.code { margin: 1.1em 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); border: 1px solid #1f2f3f; box-shadow: var(--shadow); }
.code-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; background: var(--code-bg-2);
  border-bottom: 1px solid #1f2f3f; font-size: .76rem; color: #8ea2b5; min-height: 38px; flex-wrap: wrap; row-gap: 6px;
}
.code-head .lbl { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.code-head .sp { flex: 1; }
.cbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 7px; border: 1px solid #2b3d50;
  background: #1a2a3a; color: #cfe0f0; font-size: .78rem; font-weight: 600; white-space: nowrap; flex: none;
}
.cbtn:hover { background: #22364a; }
.cbtn.run { background: #1c8a4a; border-color: #23a75b; color: #fff; }
.cbtn.run:hover { background: #23a05a; }
.cbtn.check { background: var(--primary); border-color: var(--primary); color: #fff; }
.cbtn:disabled { opacity: .5; cursor: default; }
.editor { position: relative; }
.editor pre, .editor textarea {
  margin: 0; padding: 14px 16px; font: 14px/1.6 var(--mono); tab-size: 2; white-space: pre; letter-spacing: 0;
  border: 0; width: 100%; word-break: normal; overflow-wrap: normal;
}
.editor pre.hl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--code-text); }
.editor pre.hl code { font: inherit; background: none; border: 0; padding: 0; color: inherit; }
.editor textarea {
  position: relative; display: block; resize: none; overflow-x: auto; overflow-y: hidden; background: transparent; color: transparent;
  caret-color: #fff; outline: none;
}
.editor textarea::selection { background: rgba(99, 179, 237, .35); }
.editor textarea[readonly] { cursor: text; }
.tk-kw { color: var(--tok-kw); font-weight: 600; } .tk-str { color: var(--tok-str); } .tk-num { color: var(--tok-num); }
.tk-com { color: var(--tok-com); font-style: italic; } .tk-fn { color: var(--tok-fn); } .tk-ty { color: var(--tok-ty); } .tk-id { color: #f0d8a8; }
pre.salida {
  margin: 1.1em 0; padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  font: 13.5px/1.5 var(--mono); overflow-x: auto; color: var(--text);
}
pre.salida::before { content: "Salida"; display: block; font: 700 .68rem var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* Resultados */
.result { border-top: 1px solid #1f2f3f; background: var(--surface); color: var(--text); }
.result:empty { display: none; }
.res-item { padding: 10px 12px; }
.res-item + .res-item { border-top: 1px dashed var(--border); }
.res-sql { font: 12px var(--mono); color: var(--muted); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl-wrap { overflow: auto; max-height: 340px; border: 1px solid var(--border); border-radius: 8px; }
.tbl-wrap table { border-collapse: collapse; width: 100%; font: 13px/1.4 var(--mono); }
.tbl-wrap th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1; }
.tbl-wrap td { padding: 5px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.tbl-wrap tr:last-child td { border-bottom: 0; }
.tbl-wrap tbody tr:hover { background: var(--primary-soft); }
.tbl-wrap td.num { text-align: right; }
.tbl-wrap .null { color: var(--muted); font-style: italic; }
.res-foot { margin-top: 6px; font-size: .78rem; color: var(--muted); }
.res-ok { padding: 8px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-size: .9rem; font-weight: 500; }
.res-err { padding: 8px 12px; border-radius: 8px; background: var(--err-soft); color: var(--err); font: 500 .88rem/1.5 var(--mono); white-space: pre-wrap; }
.res-err small { display: block; margin-top: 4px; opacity: .8; font-family: var(--font); }
.res-empty { padding: 10px; color: var(--muted); font-size: .9rem; }

/* Ejercicios */
.ejercicio { margin: 2em 0; border: 2px solid color-mix(in srgb, var(--primary) 45%, var(--border)); border-radius: 16px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.ejercicio.solved { border-color: var(--ok); }
.ej-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: var(--primary-soft); font-weight: 700; }
.ejercicio.solved .ej-head { background: var(--ok-soft); color: var(--ok); }
.ej-head .st { margin-left: auto; font-size: .82rem; font-weight: 600; }
.ej-body { padding: 4px 18px 16px; }
.ej-body .code { margin: .8em 0 0; }
.ej-fb { margin-top: 12px; }
.ej-fb .res-ok, .ej-fb .res-err { margin-bottom: 8px; }
.ej-extra { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border); }
.ej-extra > b { display: block; margin-bottom: 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ej-extra .code { margin: 8px 0 0; }

/* ============ Playground / Esquema ============ */
.pg { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; max-width: 1280px; margin: 0 auto; }
@media (max-width: 1000px) { .pg { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 8px; font-size: .95rem; }
.panel + .panel { margin-top: 14px; }
.tbl-list { list-style: none; padding: 0; margin: 0; }
.tbl-list li { margin: 0; }
.tbl-list details { border-bottom: 1px solid var(--border); padding: 6px 0; }
.tbl-list summary { cursor: pointer; font-weight: 600; font-size: .9rem; display: flex; gap: 6px; align-items: center; }
.tbl-list summary .n { margin-left: auto; color: var(--muted); font-weight: 400; font-size: .78rem; }
.tbl-list .cols { margin: 6px 0 4px 6px; font: 12px/1.7 var(--mono); color: var(--muted); }
.tbl-list .cols .pk { color: var(--accent); font-weight: 700; }
.tbl-list .ins { border: 0; background: none; color: var(--primary); font-size: .76rem; padding: 0; margin-left: 6px; text-decoration: underline; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select.sel { height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 8px; font: inherit; font-size: .88rem; max-width: 100%; }
.er-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.er-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.er-card > header { padding: 10px 14px; background: var(--primary); color: #fff; font-weight: 700; display: flex; justify-content: space-between; }
.er-card > header span { font-weight: 400; opacity: .85; font-size: .8rem; }
.er-card table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.er-card td { padding: 5px 14px; border-bottom: 1px solid var(--border); font-family: var(--mono); }
.er-card td:last-child { color: var(--muted); text-align: right; }
.er-card .fk { color: var(--lv2); font-size: .75rem; }
.er-card .key { color: var(--accent); }
.er-card footer { padding: 8px 14px; }

/* ============ Otros ============ */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #16232f; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem; transition: all .25s; z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.page-title { margin-top: 0; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .topnav { display: none; }
  .search { max-width: none; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 60px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); width: min(86vw, 340px); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 60px 0 0 0; background: rgba(0, 0, 0, .4); z-index: 55; }
  .brand-text { display: none; }
}
@media (max-width: 560px) {
  h1 { font-size: 1.6rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: auto; }
}
@media print {
  .topbar, .sidebar, .toc, .lesson-actions, .pager, .cbtn { display: none !important; }
  main { padding: 0; }
}
