/* =========================================================
   Saberes Generales · hoja de estilos
   Diseño sobrio tipo papel, sin dependencias externas.
   ========================================================= */

:root {
  --bg: #f6f3ec;
  --bg-deep: #eee9df;
  --surface: #fffdf9;
  --surface-2: #f1ece3;
  --surface-3: #e8e1d5;
  --text: #1c2633;
  --text-soft: #3e4b5c;
  --muted: #657184;
  --border: #ddd5c7;
  --border-strong: #c9bfae;
  --accent: #2f5d8a;
  --accent-strong: #23486d;
  --accent-soft: #e8eff7;
  --good: #2d7a58;
  --good-soft: #e3f2ea;
  --bad: #b0443b;
  --bad-soft: #fbe9e7;
  --warn: #a8731c;
  --warn-soft: #fbf1dc;
  --shadow: 0 12px 34px rgba(28, 38, 51, 0.08);
  --shadow-sm: 0 3px 12px rgba(28, 38, 51, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-read: Georgia, "Times New Roman", "Iowan Old Style", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 66px;
  --sidebar-w: 304px;
  --content-w: 1180px;
}

[data-theme="dark"] {
  --bg: #12171e;
  --bg-deep: #0d1117;
  --surface: #1a212b;
  --surface-2: #222b37;
  --surface-3: #2b3542;
  --text: #e8edf3;
  --text-soft: #c3ccd8;
  --muted: #97a4b5;
  --border: #303b49;
  --border-strong: #435164;
  --accent: #7fb0e0;
  --accent-strong: #a5c9ef;
  --accent-soft: #1d3146;
  --good: #74c9a3;
  --good-soft: #183327;
  --bad: #f09289;
  --bad-soft: #3a1f1d;
  --warn: #e0b56a;
  --warn-soft: #362a16;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.22);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 85% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 65%),
    radial-gradient(800px 400px at 0% 100%, color-mix(in srgb, var(--warn) 5%, transparent), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked { overflow: hidden; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-read);
  font-weight: 700;
  line-height: 1.18;
  color: var(--text);
  margin: 0 0 0.55em;
  letter-spacing: -0.012em;
}

h1 { font-size: clamp(2rem, 4vw, 3.25rem); }
h2 { font-size: clamp(1.45rem, 2.4vw, 2rem); }
h3 { font-size: 1.22rem; }
h4 { font-size: 1.03rem; }

p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }
li { margin: 0.28em 0; }
strong { color: var(--text); }
small { font-size: 0.86em; }
kbd {
  display: inline-block;
  padding: 0.12em 0.42em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72em;
  line-height: 1.4;
}

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; color: #fff; }

.icon {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}
.icon svg { width: 100%; height: 100%; display: block; }
svg { width: 1.15em; height: 1.15em; flex: 0 0 auto; }

/* ------------------------------ Topbar ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 clamp(14px, 3vw, 30px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  backdrop-filter: blur(14px);
}

.menu-btn { display: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent-soft), var(--surface));
  color: var(--accent);
  font-size: 19px;
  box-shadow: var(--shadow-sm);
}
.brand-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.12; }
.brand-copy strong { font-family: var(--font-read); font-size: 1.03rem; letter-spacing: -0.01em; }
.brand-copy small { color: var(--muted); font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 18px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.icon-btn:active { transform: translateY(1px); }
.menu-btn { display: none; }

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 10px 0 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.search-trigger:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.search-trigger .icon { font-size: 16px; }
.search-trigger kbd { margin-left: 8px; }

/* Apoyo en el encabezado: cálido y distinguible, sin competir con la navegación. */
.support-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 13px;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--border));
  border-radius: 11px;
  background: color-mix(in srgb, var(--warn-soft) 90%, var(--surface));
  color: color-mix(in srgb, var(--warn) 50%, var(--text));
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.support-btn:hover {
  background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface-2));
  border-color: color-mix(in srgb, var(--warn) 60%, var(--border));
  color: color-mix(in srgb, var(--warn) 40%, var(--text));
}
.support-btn:active { transform: translateY(1px); }
.support-btn .icon { font-size: 17px; }
.support-btn[hidden] { display: none; }

/* ------------------------------ Shell ------------------------------ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 22px 16px 28px 22px;
  border-right: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

.main {
  width: 100%;
  max-width: var(--content-w);
  min-height: calc(100vh - var(--topbar-h));
  padding: clamp(22px, 3.2vw, 46px) clamp(18px, 3.5vw, 54px) 80px;
  outline: none;
}

.overlay {
  position: fixed;
  inset: var(--topbar-h) 0 0;
  z-index: 45;
  background: rgba(10, 15, 22, 0.5);
  backdrop-filter: blur(2px);
}

/* ------------------------------ Tree ------------------------------ */

.tree { display: flex; flex-direction: column; gap: 4px; }
.tree-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 10px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tree-module { border-radius: 12px; }
.tree-module-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
  font-size: 0.88rem;
  font-weight: 650;
  transition: background 0.15s ease, color 0.15s ease;
}
.tree-module-head:hover { background: var(--surface-2); color: var(--text); }
.tree-module-head .num {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--module-accent, var(--accent)) 13%, var(--surface));
  color: var(--module-accent, var(--accent));
  font-size: 0.72rem;
  font-weight: 800;
}
.tree-module-head .label { flex: 1; min-width: 0; }
.tree-module-head .chev { color: var(--muted); font-size: 13px; transition: transform 0.18s ease; }
.tree-module.is-open .tree-module-head .chev { transform: rotate(90deg); }
.tree-module.is-current > .tree-module-head { background: var(--surface-2); color: var(--text); }
.tree-sections {
  display: none;
  margin: 1px 0 7px 16px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.tree-module.is-open .tree-sections { display: block; }
.tree-link {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-decoration: none;
}
.tree-link:hover { background: var(--surface-2); color: var(--text); }
.tree-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.tree-link .dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  transform: translateY(-1px);
}
.tree-link.is-visited .dot { background: var(--good); opacity: 1; }
.tree-topic {
  display: block;
  padding: 4px 8px 4px 20px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  text-decoration: none;
}
.tree-topic:hover { color: var(--text); background: var(--surface-2); }
.tree-planned {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0.72;
}
.tree-planned .num {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.72rem;
  font-weight: 800;
}
.tree-planned small { display: block; font-size: 0.66rem; opacity: 0.8; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-link .icon { font-size: 15px; }
.sidebar-note {
  margin: 12px 9px 0;
  padding: 10px 11px;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

/* ------------------------------ Buttons & chips ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 25%, transparent);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
[data-theme="dark"] .btn-primary { color: #10161f; }
[data-theme="dark"] .btn-primary:hover { color: #10161f; }
[data-theme="dark"] .chip.is-active,
[data-theme="dark"] .option.is-selected .letter,
[data-theme="dark"] .option.is-correct .letter,
[data-theme="dark"] .option.is-wrong .letter { color: #10161f; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface-2)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 1rem; border-radius: 12px; }
.btn-danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-module {
  border-color: color-mix(in srgb, var(--module-accent, var(--accent)) 28%, var(--border));
  background: color-mix(in srgb, var(--module-accent, var(--accent)) 9%, var(--surface));
  color: var(--module-accent, var(--accent));
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }

/* ------------------------------ Hero & home ------------------------------ */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(26px, 4vw, 52px);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: calc(var(--radius) + 6px);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 88%, var(--surface)) 0%, var(--surface) 58%),
    var(--surface);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -110px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: 0 0 0 28px color-mix(in srgb, var(--accent) 4%, transparent), 0 0 0 60px color-mix(in srgb, var(--accent) 3%, transparent);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { margin-bottom: 14px; }
.hero h1 { max-width: 19ch; margin-bottom: 14px; }
.hero p { max-width: 66ch; color: var(--text-soft); font-size: 1.03rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.55;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 38px 0 16px;
}
.section-heading h2 { margin: 0; font-size: clamp(1.35rem, 2.2vw, 1.75rem); }
.section-heading p { margin: 0; color: var(--muted); font-size: 0.86rem; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.quick-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 132px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.quick-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); color: var(--text); }
.quick-card .q-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}
.quick-card strong { font-family: var(--font-read); font-size: 1.02rem; }
.quick-card small { color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.quick-card .q-arrow { margin-top: auto; color: var(--muted); font-size: 14px; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.module-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--module-accent, var(--accent)) 40%, var(--border)); box-shadow: var(--shadow); color: var(--text); }
.module-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--module-accent, var(--accent));
  opacity: 0.8;
}
.module-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.module-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--module-accent, var(--accent)) 13%, var(--surface));
  color: var(--module-accent, var(--accent));
  font-family: var(--font-read);
  font-weight: 800;
  font-size: 0.95rem;
}
.module-card h3 { margin: 0; font-size: 1.18rem; }
.module-card p { margin: 0; color: var(--muted); font-size: 0.86rem; }
.module-card .module-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 6px; }
.module-card .module-foot .progress { flex: 1; }
.module-card .pct { color: var(--muted); font-size: 0.74rem; font-weight: 700; }

.progress {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--module-accent, var(--accent));
  transition: width 0.4s ease;
}

.continue-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 17px 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
}
.continue-card:hover { color: var(--text); border-color: var(--accent); }
.continue-card .c-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 11px; background: var(--surface); color: var(--accent); font-size: 19px; }
.continue-card strong { display: block; font-family: var(--font-read); font-size: 1.02rem; }
.continue-card small { color: var(--text-soft); }
.continue-card .c-arrow { margin-left: auto; color: var(--accent); font-size: 18px; }

.pilot-note {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  padding: 15px 17px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--muted);
  font-size: 0.84rem;
}
.pilot-note .icon { color: var(--warn); font-size: 18px; margin-top: 2px; }

/* ------------------------------ Page header ------------------------------ */

.page-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 0.78rem;
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs .sep { opacity: 0.5; }
.page-header h1 { font-size: clamp(1.75rem, 3.4vw, 2.7rem); margin-bottom: 10px; }
.page-header .page-subtitle { max-width: 75ch; margin: 0; color: var(--text-soft); font-size: 1rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }

.module-banner {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--module-accent, var(--accent)) 8%, var(--surface)), var(--surface) 62%);
  box-shadow: var(--shadow-sm);
}
.module-banner .big-num {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 15px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--module-accent, var(--accent)) 28%, var(--border));
  color: var(--module-accent, var(--accent));
  font-family: var(--font-read);
  font-size: 1.5rem;
  font-weight: 800;
}
.module-banner h1 { font-size: clamp(1.55rem, 3vw, 2.3rem); margin-bottom: 6px; }
.module-banner p { margin: 0; color: var(--text-soft); }

/* ------------------------------ Layout & prose ------------------------------ */

.section-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 274px;
  gap: 34px;
  align-items: start;
}
.section-body { min-width: 0; }
.section-aside {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.aside-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.aside-card h3 { margin: 0 0 10px; font-size: 0.95rem; }
.aside-card p, .aside-card li { color: var(--muted); font-size: 0.8rem; }
.aside-card ul { margin: 0; padding-left: 1.05em; }
.aside-card .aside-link { display: block; padding: 5px 0; color: var(--text-soft); font-size: 0.82rem; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.aside-card .aside-link:last-child { border-bottom: 0; }
.aside-card .aside-link:hover { color: var(--accent); }
.aside-actions { display: flex; flex-direction: column; gap: 8px; }

.prose { font-family: var(--font-read); font-size: 1.04rem; line-height: 1.72; color: var(--text-soft); }
.prose p { margin-bottom: 1.05em; }
.prose strong { color: var(--text); }
.prose ul, .prose ol { margin-bottom: 1.1em; }
.prose li { margin: 0.35em 0; }

.block { margin-bottom: 34px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.block-head h2 { margin: 0; font-size: 1.35rem; }
.block-head .block-kicker { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.summary-box {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--module-accent, var(--accent));
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.summary-box .prose { font-size: 1.02rem; }
.summary-box .prose p:last-child { margin-bottom: 0; }

.key-points {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.key-points li {
  position: relative;
  padding: 11px 14px 11px 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}
.key-points li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--module-accent, var(--accent));
  opacity: 0.8;
}

.topic-list { display: grid; gap: 10px; }
.topic-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.topic-card h3 { margin: 0 0 5px; font-size: 1.03rem; }
.topic-card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

.terms-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.term-card {
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
.term-card dt { margin: 0 0 5px; color: var(--text); font-weight: 700; font-size: 0.88rem; }
.term-card dd { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

.nexo-list { display: grid; gap: 10px; }
.nexo-card {
  display: flex;
  gap: 13px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.nexo-card:hover { border-color: var(--accent); background: var(--surface-2); color: var(--text); }
.nexo-card .n-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 15px; }
.nexo-card strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
.nexo-card small { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.nexo-card .n-type { margin-left: auto; flex: 0 0 auto; align-self: flex-start; }

.source-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.source-box summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 14px 16px;
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.source-box summary::-webkit-details-marker { display: none; }
.source-box summary:hover { background: var(--surface-2); }
.source-box summary .icon { color: var(--accent); }
.source-box[open] summary { border-bottom: 1px solid var(--border); }
.source-text {
  max-height: 560px;
  overflow: auto;
  padding: 18px 20px;
  color: var(--text-soft);
  font-family: var(--font-read);
  font-size: 0.94rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.source-text p { margin: 0 0 0.9em; }

.timeline { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 7px; bottom: 7px; width: 1px; background: var(--border-strong); }
.timeline-item { position: relative; padding: 0 0 18px 36px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 5px; width: 13px; height: 13px; border: 2px solid var(--surface); border-radius: 50%; background: var(--module-accent, var(--accent)); box-shadow: 0 0 0 1px var(--border-strong); }
.timeline-date { display: block; color: var(--module-accent, var(--accent)); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.timeline-item strong { display: block; margin: 1px 0 2px; font-family: var(--font-read); font-size: 0.98rem; }
.timeline-item p { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }

.callout {
  display: flex;
  gap: 12px;
  padding: 15px 17px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--text-soft);
  font-size: 0.88rem;
}
.callout .icon { color: var(--warn); font-size: 18px; margin-top: 2px; }
.callout strong { color: var(--text); }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.info-card { padding: 15px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.info-card h3 { margin: 0 0 6px; font-size: 0.92rem; }
.info-card p, .info-card li { color: var(--muted); font-size: 0.84rem; }
.info-card ul { margin: 0; padding-left: 1.1em; }

.section-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.section-nav a { max-width: 48%; }

/* ------------------------------ Tables ------------------------------ */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { padding: 11px 13px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); color: var(--text); font-size: 0.76rem; letter-spacing: 0.04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td { color: var(--text-soft); }

/* ------------------------------ Flashcards ------------------------------ */

.flash-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.flash-toolbar .spacer { flex: 1; }
.flash-toggle { cursor: pointer; user-select: none; }
.flash-toggle input { accent-color: var(--accent); margin: 0 2px 0 0; }
.flash-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; color: var(--muted); font-size: 0.8rem; }
.flash-progress-row .progress { flex: 1; height: 7px; }

.flash-stage { display: grid; place-items: center; min-height: 360px; padding: 10px 0 20px; perspective: 1400px; }
.flashcard {
  position: relative;
  display: block;
  width: min(100%, 720px);
  min-height: 300px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.flashcard-inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 300px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: clamp(22px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  overflow: auto;
}
.flashcard-face.back { transform: rotateY(180deg); background: linear-gradient(145deg, var(--accent-soft), var(--surface) 60%); }
.flashcard-label { color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.flashcard-question { font-family: var(--font-read); font-size: clamp(1.25rem, 2.6vw, 1.8rem); line-height: 1.35; }
.flashcard-answer { font-family: var(--font-read); font-size: clamp(1.05rem, 2vw, 1.35rem); line-height: 1.5; color: var(--text-soft); }
.flashcard-hint { margin-top: auto; color: var(--muted); font-size: 0.76rem; }
.flashcard-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.flash-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 16px; }
.flash-actions .btn { min-width: 116px; }
.flash-empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.flash-empty h2 { color: var(--text); }
.flash-stats { display: flex; justify-content: center; gap: 20px; margin-top: 18px; color: var(--muted); font-size: 0.8rem; }
.flash-stats strong { color: var(--text); }

/* ------------------------------ Quiz ------------------------------ */

.quiz-shell { max-width: 860px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.quiz-top .progress { flex: 1; height: 7px; }
.quiz-counter { color: var(--muted); font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.quiz-timer { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.quiz-card { padding: clamp(20px, 3vw, 32px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.quiz-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 14px; }
.quiz-question { font-family: var(--font-read); font-size: clamp(1.2rem, 2.4vw, 1.55rem); line-height: 1.4; margin-bottom: 20px; }
.quiz-options { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.45;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.option .letter {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}
.option.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.option.is-selected .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.option.is-correct { border-color: var(--good); background: var(--good-soft); color: var(--text); }
.option.is-correct .letter { background: var(--good); border-color: var(--good); color: #fff; }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--text); }
.option.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.option:disabled { cursor: default; }
.option:disabled:hover { background: var(--surface); border-color: var(--border); }

.quiz-feedback {
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.88rem;
}
.quiz-feedback.is-correct { border-color: color-mix(in srgb, var(--good) 40%, var(--border)); background: var(--good-soft); }
.quiz-feedback.is-wrong { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background: var(--bad-soft); }
.quiz-feedback strong { display: block; margin-bottom: 3px; color: var(--text); }
.quiz-feedback .feedback-source { display: block; margin-top: 7px; color: var(--muted); font-size: 0.78rem; }
.quiz-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 20px; }
.quiz-nav .spacer { flex: 1; }

.quiz-intro { max-width: 760px; margin: 0 auto; }
.quiz-intro .quiz-card { padding: clamp(24px, 4vw, 40px); }
.quiz-intro h1 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
.quiz-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.quiz-mode {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  color: var(--text);
  text-decoration: none;
}
.quiz-mode:hover { border-color: var(--border-strong); background: var(--surface-2); }
.quiz-mode.is-active { border-color: var(--accent); background: var(--accent-soft); }
.quiz-mode strong { display: block; font-size: 0.92rem; }
.quiz-mode small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.78rem; }
.quiz-config { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 22px; }

.quiz-results { max-width: 860px; margin: 0 auto; }
.result-hero { text-align: center; padding: 32px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.result-score { font-family: var(--font-read); font-size: clamp(3rem, 8vw, 5rem); line-height: 1; color: var(--accent); }
.result-score small { font-size: 0.28em; color: var(--muted); }
.result-hero h1 { margin: 8px 0 4px; font-size: 1.6rem; }
.result-hero p { margin: 0; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 20px; }
.result-breakdown { display: grid; gap: 10px; margin-top: 22px; }
.breakdown-row { display: grid; grid-template-columns: 150px 1fr 48px; align-items: center; gap: 10px; font-size: 0.84rem; }
.breakdown-row .progress { height: 8px; }
.breakdown-row span:last-child { text-align: right; color: var(--muted); font-weight: 700; }
.review-list { display: grid; gap: 10px; margin-top: 14px; }
.review-item { padding: 15px 17px; border: 1px solid var(--border); border-left: 4px solid var(--bad); border-radius: 9px; background: var(--surface); }
.review-item.is-correct { border-left-color: var(--good); }
.review-item h3 { margin: 0 0 6px; font-size: 0.92rem; }
.review-item p { margin: 0 0 4px; color: var(--text-soft); font-size: 0.84rem; }
.review-item .answer-line { color: var(--good); font-weight: 650; }
.review-item .wrong-line { color: var(--bad); font-weight: 650; }
.review-item .review-source { color: var(--muted); font-size: 0.76rem; }

/* ------------------------------ Search modal ------------------------------ */

.modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: start center; padding: min(10vh, 90px) 16px 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 15, 22, 0.55); backdrop-filter: blur(3px); }
.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(74vh, 680px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-6px) scale(0.99); } to { opacity: 1; transform: none; } }
.search-head { display: flex; align-items: center; gap: 10px; padding: 14px 15px; border-bottom: 1px solid var(--border); }
.search-head .icon { color: var(--muted); font-size: 18px; }
.search-head input { flex: 1; min-width: 0; padding: 7px 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 1rem; }
.search-head input::placeholder { color: var(--muted); }
.search-results { overflow-y: auto; padding: 8px; }
.search-group-label { padding: 8px 10px 5px; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.search-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.search-result:hover, .search-result.is-active { background: var(--accent-soft); color: var(--text); }
.search-result .s-icon { display: grid; place-items: center; width: 27px; height: 27px; flex: 0 0 auto; border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.search-result strong { display: block; font-size: 0.86rem; }
.search-result small { display: block; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.search-result mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-foot { display: flex; flex-wrap: wrap; gap: 14px; padding: 9px 15px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.72rem; }
.search-foot span { display: inline-flex; align-items: center; gap: 4px; }
.search-empty { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 0.88rem; }

/* ------------------------------ Glossary / nexos / comparisons ------------------------------ */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.toolbar .spacer { flex: 1; }
.input {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.input-search { flex: 1; min-width: 200px; }

.glossary-group { margin-bottom: 24px; }
.glossary-letter { display: flex; align-items: center; gap: 10px; margin: 0 0 9px; color: var(--accent); font-family: var(--font-read); font-size: 1.3rem; }
.glossary-letter::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.glossary-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.glossary-item:last-child { border-bottom: 0; }
.glossary-item dt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 3px; font-weight: 700; color: var(--text); }
.glossary-item dd { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

.nexo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.nexo-full { grid-column: 1 / -1; }

/* ------------------------------ Progress / settings ------------------------------ */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { padding: 17px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-card .stat-label { color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.stat-card .stat-value { margin: 5px 0 0; font-family: var(--font-read); font-size: 2rem; line-height: 1; color: var(--text); }
.stat-card .stat-sub { margin: 5px 0 0; color: var(--muted); font-size: 0.76rem; }
.progress-list { display: grid; gap: 12px; }
.progress-item { padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.progress-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.progress-item-head strong { font-size: 0.9rem; }
.progress-item-head span { color: var(--muted); font-size: 0.76rem; }
.history-list { display: grid; gap: 8px; }
.history-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 0.82rem; }
.history-row .h-date { color: var(--muted); font-size: 0.76rem; }
.history-row .h-score { margin-left: auto; font-weight: 800; color: var(--accent); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-card { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.settings-card h2 { font-size: 1.05rem; margin-bottom: 8px; }
.settings-card p { color: var(--muted); font-size: 0.84rem; }
.settings-card .btn-row { margin-top: 12px; }

.empty-state { padding: 42px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 6px; }
.empty-state p { margin: 0 auto 16px; max-width: 52ch; }

/* ------------------------------ Toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 150;
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.noscript { margin: 40px; padding: 20px; border: 1px solid var(--bad); border-radius: 10px; background: var(--bad-soft); color: var(--bad); }

/* ------------------------------ Apoyo y anuncios ------------------------------ */

.support-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.support-copy { min-width: 0; flex: 1 1 320px; }
.support-card strong { display: block; font-family: var(--font-read); font-size: 1rem; }
.support-card p { margin: 2px 0 0; color: var(--muted); font-size: 0.83rem; max-width: 58ch; }
.support-card .btn { flex: 0 0 auto; }

.support-home {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 15px 46px 15px 18px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface));
}
.support-home .btn { flex: 0 0 auto; }
.support-close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.support-close:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.support-close svg { width: 15px; height: 15px; }

.ad-slot {
  margin: 28px auto 0;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
}

.site-footer {
  margin-top: 48px;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 28px;
  flex-wrap: wrap;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 22px 28px 30px;
}
.site-footer-note { margin: 0; max-width: 64ch; color: var(--muted); font-size: 0.77rem; line-height: 1.5; }
.site-footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.82rem; font-weight: 600; }
.site-footer-links a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); text-decoration: none; }
.site-footer-links a:hover { color: var(--accent-strong); text-decoration: underline; }
.site-footer-links a[hidden] { display: none; }

/* Páginas estáticas (apoyar, privacidad) */

.doc-shell { max-width: 780px; margin: 0 auto; padding: 44px 22px 56px; }
.doc-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 30px; }
.doc-shell h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); margin-bottom: 0.4em; }
.doc-lede { color: var(--text-soft); font-size: 1.02rem; }
.doc-shell h2 { font-size: 1.3rem; margin-top: 1.9em; }
.doc-card { padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 6px; }
.doc-note { color: var(--muted); font-size: 0.82rem; }
.doc-sign { margin: 30px 0 6px; font-family: var(--font-read); font-style: italic; color: var(--text-soft); font-size: 1.05rem; }
.doc-shell ul { padding-left: 1.2em; }
.doc-shell li { margin: 0.35em 0; }
.doc-footer { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; display: flex; flex-wrap: wrap; gap: 8px 18px; }

@media (max-width: 760px) {
  .site-footer-inner { padding: 18px 18px 26px; }
  .support-card { padding: 14px 15px; }
  .support-card .btn { width: 100%; }
  .support-home { padding: 15px 46px 15px 16px; }
  .support-home .btn { width: 100%; }
  .support-close { width: 44px; height: 44px; }
  .doc-shell { padding: 30px 16px 44px; }
}


/* ------------------------------ Motion & focus ------------------------------ */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ------------------------------ Responsive ------------------------------ */

@media (max-width: 1180px) {
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-layout { grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; }
}

@media (max-width: 980px) {
  .menu-btn { display: inline-grid; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    z-index: 50;
    width: min(86vw, 330px);
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-104%);
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.22s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .main { max-width: none; }
  .section-layout { grid-template-columns: 1fr; }
  .section-aside { position: static; }
}

@media (max-width: 760px) {
  :root { --topbar-h: 60px; }
  .brand-copy small { display: none; }
  .search-trigger-label, .search-trigger kbd { display: none; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .support-btn-label { display: none; }
  .support-btn { width: 40px; padding: 0; justify-content: center; }
  .module-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .terms-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .nexo-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .quiz-modes { grid-template-columns: 1fr; }
  .breakdown-row { grid-template-columns: 100px 1fr 44px; }
  .flashcard, .flashcard-inner, .flashcard-face { min-height: 270px; }
  .flash-actions .btn { min-width: 0; flex: 1 1 30%; }
  .section-nav { flex-direction: column; }
  .section-nav a { max-width: none; }
}

@media (max-width: 520px) {
  .main { padding-left: 15px; padding-right: 15px; }
  .hero { padding: 24px 19px; }
  .hero h1 { font-size: 1.85rem; }
  .quick-grid { grid-template-columns: 1fr; }
  .module-banner { padding: 18px; gap: 12px; }
  .module-banner .big-num { width: 46px; height: 46px; font-size: 1.2rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .flashcard-face { padding: 20px; }
  .quiz-card { padding: 18px; }
  .option { padding: 11px 12px; font-size: 0.87rem; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-mark { display: none; }
  .brand-copy { overflow: hidden; }
  .brand-copy strong { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .site-footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .site-footer-links { width: 100%; gap: 0 22px; }
  .site-footer-links a { min-height: 44px; }
}

@media print {
  .topbar, .sidebar, .overlay, .section-aside, .section-nav, .flash-actions, .quiz-nav, .result-actions, .toast, .modal, .site-footer, .support-card, .ad-slot { display: none !important; }
  .app-shell { display: block; }
  .main { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
  .summary-box, .key-points li, .topic-card, .term-card, .nexo-card, .source-box, .quiz-card, .result-hero { box-shadow: none; break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
}
