/* ==========================================================================
   Ruta — capa de rediseño (true-black-flat)
   Dirección: noche neutra, elevación por tono, acento solo en datos/estado,
   primaria por inversión, radios 20/14/999, sin degradados ni cristal.
   Esta capa se carga después de styles.css, study.css y learning.css.
   ========================================================================== */

:root {
  --ground: #0b0c0e;
  --surface: #151619;
  --raised: #1f2125;
  --well: #08090b;
  --rule: #202226;
  --control: #3c3f45;
  --ink: #f4f5f6;
  --ink-2: #b4b6ba;
  --ink-3: #94979c;
  --accent: #5eead4;
  --positive: #57d38c;
  --negative: #ff6b6b;
  --warning: #e5a93b;
  --r-card: 20px;
  --r-well: 14px;
  --r-chip: 999px;

  /* Tokens heredados: los componentes antiguos leen estos nombres. */
  --bg: var(--ground);
  --bg-soft: var(--ground);
  --panel: var(--surface);
  --panel-2: var(--raised);
  --line: var(--rule);
  --line-soft: var(--rule);
  --text: var(--ink);
  --muted: var(--ink-2);
  --dim: var(--ink-3);
  --ok: var(--positive);
  --err: var(--negative);
  --warn: var(--warning);
  --amber: var(--warning);
  --radius: var(--r-card);
}

body { background: var(--ground); color: var(--ink); font-size: 15px; line-height: 1.6; }
html { -webkit-text-size-adjust: 100%; }
::selection { background: rgba(94, 234, 212, .24); color: #f7fffe; }
html { scrollbar-color: #33363b var(--ground); }
a { color: var(--ink); text-underline-offset: .22em; }
a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------- topbar ------------------------------- */
.topbar {
  height: 60px;
  gap: 16px;
  padding: 0 24px;
  background: var(--ground);
  border-bottom: 1px solid var(--rule);
}
.brand { min-width: 170px; gap: 9px; }
.topbar .menu-toggle { display: none; }
.brand svg { width: 22px; height: 22px; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.topbar-progress { max-width: 460px; gap: 10px; }
.topbar-progress .bar { height: 4px; background: var(--raised); }
.topbar-progress .count { font-family: var(--sans); font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.ghost-btn {
  margin-left: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: var(--r-chip);
  min-height: 38px;
  padding: 0 11px;
  font-size: 13.5px;
}
.ghost-btn:hover { background: var(--raised); color: var(--ink); border-color: transparent; }
#btnPractice { background: var(--ink); color: #0b0c0e; font-weight: 650; padding: 0 17px; }
#btnPractice:hover { background: #ffffff; color: #000000; }
.badge {
  background: var(--raised);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 11px;
  padding: 1px 6px;
}
.badge.empty { background: var(--raised); color: var(--ink-3); }

/* ------------------------------- shell ------------------------------- */
.shell { grid-template-columns: 264px minmax(0, 1fr); max-width: 1480px; }
.sidebar {
  top: 60px;
  height: calc(100vh - 60px);
  padding: 26px 16px 40px 20px;
  background: var(--ground);
  border-right: 1px solid var(--rule);
}
.sidebar::-webkit-scrollbar, .term-out::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .term-out::-webkit-scrollbar-thumb { background: #2c2f34; border-radius: 20px; }

.sidebar-head { padding: 0 4px 16px; }
.side-mark { display: none; }
.space-name { margin: 0 0 4px; font-size: 18px; font-weight: 650; letter-spacing: -.015em; color: var(--ink); }
.sidebar-head p { font-size: 13px; color: var(--ink-2); line-height: 1.5; }

.study-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 4px;
  padding: 12px 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.study-nav a { padding: 8px 8px; border-radius: 9px; color: var(--ink-2); font-size: 12.8px; }
.study-nav a:hover, .study-nav a:focus-visible { background: var(--surface); color: var(--ink); }
.study-nav a[aria-current="page"] { background: transparent; color: var(--ink); font-weight: 600; }

.course-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0 0 18px; }
.course-tab {
  background: var(--surface);
  border: 0;
  border-radius: 12px;
  padding: 9px 11px;
  gap: 1px;
}
.course-tab:hover { background: var(--raised); border-color: transparent; }
.course-tab.active { background: var(--raised); border-color: transparent; }
.ct-name { font-size: 12.8px; font-weight: 600; color: var(--ink); }
.ct-count { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.course-tab.active .ct-count { color: var(--ink-2); opacity: 1; }

.course-search { margin: 0 2px 20px; }
.course-search label { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.course-search input {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 42px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
}
.course-search input:focus { border-color: var(--control); }
.search-status { color: var(--ink-3); }
.search-result { border-bottom: 1px solid var(--rule); padding: 10px 4px; }
.search-result:hover { background: var(--surface); }
.search-result strong { font-size: 13.5px; font-weight: 550; }
.search-result span { font-size: 11.5px; color: var(--ink-3); }

.mod-item {
  border: 0;
  border-radius: 10px;
  padding: 9px 8px;
  margin: 1px 0;
  gap: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
}
.mod-item:hover { background: var(--surface); color: var(--ink); }
.mod-item.active { background: transparent; border-color: transparent; color: var(--ink); font-weight: 600; }
.mod-num {
  width: 22px; height: 22px;
  margin-top: 1px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.mod-item.active .mod-num { color: var(--ink); border: 0; background: transparent; font-weight: 600; }
.mod-item.complete .mod-num { color: var(--accent); border: 0; background: transparent; }
.mod-title { font-weight: inherit; line-height: 1.4; }
.mod-meta { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

.sidebar-foot { border-top: 1px solid var(--rule); margin-top: 20px; }
.sidebar-foot p { font-size: 11.5px; color: var(--ink-3); }
.sidebar-foot code { background: var(--raised); color: var(--ink-2); }

/* -------------------------------- main -------------------------------- */
.main { padding: 42px 48px 120px; }
.view { max-width: 1060px; animation: none; }
.mod-head, .study-page { scroll-margin-top: 92px; }
.mod-head { margin-bottom: 26px; }
.mod-head h1, .mod-head h2 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.16;
  letter-spacing: -.022em;
  font-weight: 650;
  text-wrap: balance;
}
.module-meta { margin: 0 0 12px; font-family: var(--sans); font-size: 13px; color: var(--ink-3); }
.mod-head .blurb { color: var(--ink-2); font-size: 16.5px; line-height: 1.6; max-width: 64ch; }

.module-guide { border-block: 1px solid var(--rule); padding-block: 20px 0; margin-bottom: 34px; }
.guide-meta { font-family: var(--sans); font-size: 12.5px; color: var(--ink-3); }
.guide-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.guide-meta .icon { width: 14px; height: 14px; color: var(--ink-3); }
.module-progress { height: 3px; background: var(--raised); margin-block: 14px 18px; }
.module-progress span { background: var(--accent); }
.module-goals { font-size: 14.5px; line-height: 1.8; color: var(--ink-2); }
.module-goals li::marker { color: var(--ink-3); }
.guide-actions { margin-bottom: 16px; }
.module-outline { border-top: 1px solid var(--rule); }
.module-outline summary { font-size: 13.5px; color: var(--ink-2); }
.module-outline summary:hover { color: var(--ink); }
.module-outline ol { color: var(--ink-3); font-size: 13px; }
.module-outline button { color: var(--ink); font-size: 14px; }
.module-outline button:hover { color: var(--accent); }

.lesson { padding-block: 34px 16px; }
.lesson h3 { margin: 0 0 14px; font-size: 21px; line-height: 1.35; font-weight: 600; letter-spacing: -.015em; }
.lesson p { font-size: 16px; line-height: 1.75; color: var(--ink); max-width: 68ch; }
.lesson h4 { margin: 26px 0 10px; font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 600; }
.lesson strong { color: #ffffff; font-weight: 620; }
.lesson code:not(pre code) {
  background: var(--raised);
  border: 0;
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--ink);
  font-size: .88em;
}
.lesson ul.clean, .lesson ol.clean { color: var(--ink); }
.lesson li::marker { color: var(--ink-3); }

pre.code {
  background: var(--well);
  border: 0;
  border-radius: var(--r-well);
  padding: 18px 20px;
  color: #d6d8db;
  font-size: 13px;
}
.copy-btn {
  background: var(--raised);
  border: 0;
  border-radius: var(--r-chip);
  color: var(--ink-2);
  padding: 5px 10px;
  font-size: 11px;
}
.copy-btn:hover { color: var(--ink); border-color: transparent; }

.note {
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 0;
  border-radius: var(--r-well);
}
.note p { font-size: 14.5px; color: var(--ink); line-height: 1.65; }
.note-k {
  background: var(--raised);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0;
  text-transform: none;
  border-radius: var(--r-chip);
  padding: 3px 9px;
}
.note-tip { background: #1b1810; }
.note-tip .note-k { background: #2b2414; color: var(--warning); }
.note-warn { background: #1d1416; }
.note-warn .note-k { background: #2c1a20; color: #ff9b9b; }

.zones { gap: 10px; }
.zone { padding: 15px 16px; background: var(--surface); border: 0; border-radius: var(--r-well); }
.zone-t { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--ink); letter-spacing: 0; }
.zone p { font-size: 13.5px; color: var(--ink-2); }

/* ------------------------------ ejercicios ------------------------------ */
.ex-head { margin: 40px 0 6px; }
.ex-head h3 { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--ink-3); font-weight: 600; }
.ex-head .pill { font-family: var(--sans); font-size: 11.5px; border: 0; background: var(--surface); color: var(--ink-3); }
.ex {
  margin: 12px 0;
  background: var(--surface);
  border: 0;
  border-radius: var(--r-card);
  overflow: hidden;
}
.ex.done { border-color: transparent; outline: 1px solid rgba(94, 234, 212, .32); outline-offset: -1px; }
.ex-top { padding: 12px 20px; background: transparent; border-bottom: 1px solid var(--rule); }
.tag {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  padding: 3px 9px;
  border: 0;
  border-radius: var(--r-chip);
  background: var(--raised);
  color: var(--ink-2);
}
.tag.quiz, .tag.fill, .tag.term, .tag.sql { color: var(--ink-2); border-color: transparent; background: var(--raised); }
.ex-id { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); }
.ex-check { font-family: var(--sans); color: var(--accent); }
.ex-body { padding: 18px 20px 20px; }
.ex-prompt { font-size: 15.5px; color: var(--ink); line-height: 1.65; }
.ex-prompt code { background: var(--raised); border: 0; color: var(--ink); }

.options { gap: 8px; }
.opt {
  background: var(--raised);
  border: 1px solid transparent;
  border-radius: var(--r-well);
  padding: 12px 14px;
  color: var(--ink);
  font-size: 14.5px;
}
.opt:hover:not(:disabled) { background: #26282d; border-color: transparent; }
.opt .key { border: 0; background: rgba(0, 0, 0, .22); color: var(--ink-3); font-size: 11.5px; }
.opt.correct { background: rgba(87, 211, 140, .13); border-color: rgba(87, 211, 140, .45); color: var(--ink); }
.opt.correct .key { border: 0; color: var(--positive); background: rgba(87, 211, 140, .12); }
.opt.wrong { background: rgba(255, 107, 107, .1); border-color: rgba(255, 107, 107, .4); color: var(--ink); }
.opt.wrong .key { border: 0; color: var(--negative); background: rgba(255, 107, 107, .12); }

.fill-row input {
  background: var(--well);
  border: 1px solid var(--control);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--ink);
  font-size: 13.5px;
}
.fill-row input:focus { border-color: var(--accent); }
.fill-row input.ok { border-color: var(--positive); }
.fill-row input.bad { border-color: var(--negative); }

.btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--control);
  border-radius: var(--r-chip);
  min-height: 40px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 550;
}
.btn:hover { background: var(--raised); border-color: #50545a; filter: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn.secondary { background: transparent; color: var(--ink-2); border: 1px solid var(--rule); }
.btn.secondary:hover { background: var(--surface); color: var(--ink); border-color: var(--control); }
.btn.small { min-height: 36px; padding: 7px 13px; font-size: 12.5px; }
.btn.danger { color: var(--negative); border-color: rgba(255, 107, 107, .4); }
#btnPractice, .study-lead .btn:not(.secondary), .guide-actions .btn:not(.secondary), .nav-foot .btn:not(.secondary), .practice-hub > .btn:not(.secondary), .practice-session .btn:not(.secondary), .review .btn:not(.secondary) {
  background: var(--ink);
  color: #0b0c0e;
  border-color: transparent;
  font-weight: 650;
}
#btnPractice:hover, .study-lead .btn:not(.secondary):hover, .guide-actions .btn:not(.secondary):hover, .nav-foot .btn:not(.secondary):hover, .practice-hub > .btn:not(.secondary):hover, .practice-session .btn:not(.secondary):hover, .review .btn:not(.secondary):hover { background: #ffffff; color: #000000; }

.fb { border: 0; border-radius: var(--r-well); padding: 12px 14px; font-size: 13.5px; }
.fb.good { background: rgba(87, 211, 140, .12); color: var(--ink); }
.fb.bad { background: rgba(255, 107, 107, .1); color: var(--ink); }
.fb.good > strong:first-child { color: var(--positive); }
.fb.bad > strong:first-child { color: #ff9b9b; }
.fb code { background: rgba(0, 0, 0, .28); }

.hint-box { background: #1b1810; border: 0; border-radius: var(--r-well); color: #e8d9b0; }
.hint-box code { background: rgba(0, 0, 0, .3); }

/* terminal y workbench */
.term { background: var(--well); border: 0; border-radius: 16px; }
.term-bar { background: #0d0e11; border-bottom: 1px solid var(--rule); padding: 9px 14px; }
.term-label { font-family: var(--sans); font-size: 11.5px; letter-spacing: 0; color: var(--ink-3); }
.term-branch { font-family: var(--sans); font-size: 11.5px; opacity: 1; color: var(--ink-2); }
.term-out { font-size: 12.5px; line-height: 1.62; }
.term-in-row { border-top: 1px solid var(--rule); padding: 10px 14px 12px; }
.term-in { font-size: 13.5px; color: var(--ink); }
.term-actions { margin-top: 14px; }

.wb { gap: 12px; }
.wb-right { background: var(--surface); border: 0; border-radius: 16px; }
.wb-tabs { background: transparent; border-bottom: 1px solid var(--rule); padding: 8px; }
.wb-tab { font-size: 12.5px; padding: 6px 11px; border-radius: var(--r-chip); color: var(--ink-3); }
.wb-tab.active { background: var(--raised); color: var(--ink); }
.wb-list-head { font-family: var(--sans); font-size: 11px; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.file-list { border-bottom: 1px solid var(--rule); }
.file-row { font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); }
.file-row:hover { background: var(--raised); }
.file-row.active { background: var(--raised); color: var(--ink); }
.fstat { color: var(--ink-3); }
.edit-head { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); border-bottom: 1px solid var(--rule); }
.edit-area { background: var(--well); color: var(--ink); font-size: 12px; }
.edit-foot { font-family: var(--sans); font-size: 11px; color: var(--ink-3); border-top: 1px solid var(--rule); }
.icon-btn { background: transparent; border: 0; color: var(--ink-2); border-radius: 999px; }
.icon-btn:hover { background: var(--raised); color: var(--ink); border-color: transparent; }
.graph-box { scrollbar-color: #2c2f34 transparent; }
.graph-legend .lg { font-family: var(--sans); font-size: 11px; background: var(--surface); border: 0; color: var(--ink-2); }
.graph-empty { color: var(--ink-3); }
.graph-empty span { color: var(--ink-3); }

/* SQL */
.sql-schema { gap: 8px; }
.schema-head { font-family: var(--sans); font-size: 11.5px; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.table-card { background: var(--surface); border: 0; border-radius: 14px; }
.table-card-head { background: transparent; border-bottom: 1px solid var(--rule); }
.tname { font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: var(--ink); }
.preview-btn { font-family: var(--sans); font-size: 11px; border: 0; background: var(--raised); color: var(--ink-3); border-radius: 999px; padding: 3px 8px; }
.preview-btn:hover { color: var(--ink); border-color: transparent; }
.col-list li { font-family: var(--sans); font-size: 12px; color: var(--ink-2); }
.ctype { font-size: 11px; color: var(--ink-3); }
.kbadge { font-family: var(--sans); font-size: 10.5px; }
.table-refs { font-family: var(--sans); font-size: 11px; color: var(--ink-3); }
.sql-editor { background: var(--well); border: 0; border-radius: 16px; }
.sql-bar { background: #0d0e11; border-bottom: 1px solid var(--rule); font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); }
.sql-bar .kbd { font-size: 11px; padding: 2px 6px; }
.sql-input { color: var(--ink); font-size: 13.5px; }
.sql-actions { background: transparent; border-top: 1px solid var(--rule); }
.sql-out { background: var(--surface); border: 0; border-radius: 16px; }
.sql-out-head { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); border-bottom: 1px solid var(--rule); }
.sql-table { font-size: 12.5px; }
.sql-table th { background: transparent; color: var(--ink-3); font-family: var(--sans); font-weight: 600; font-size: 11.5px; border-bottom: 1px solid var(--rule); }
.sql-table td { color: var(--ink); border-bottom: 1px solid var(--rule); }
.sql-table tbody tr:nth-child(even) td { background: transparent; }
.sql-table td.is-num { color: var(--positive); }
.sql-empty, .sql-mutation { color: var(--ink-3); font-size: 13px; }

/* ------------------------------- modales ------------------------------- */
.overlay { background: rgba(0, 0, 0, .72); padding: 24px; }
.modal {
  background: #121315;
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55);
}
.modal-head { background: transparent; border-bottom: 1px solid var(--rule); padding: 15px 20px; }
.modal-head h3 { font-size: 15.5px; font-weight: 600; }
.modal-x { background: var(--raised); border: 0; border-radius: 999px; color: var(--ink-2); }
.modal-x:hover { background: #2a2c31; color: var(--ink); border-color: transparent; }
.modal > :not(.modal-head)::-webkit-scrollbar { width: 8px; }
.modal > :not(.modal-head)::-webkit-scrollbar-thumb { background: #2c2f34; }

.review { padding: 20px 22px 24px; }
.review-top { font-family: var(--sans); font-size: 11.5px; color: var(--ink-3); }
.review-top .bar { height: 4px; background: var(--raised); }
.card-face { background: var(--surface); border: 0; border-radius: 18px; padding: 24px; }
.card-tag { font-family: var(--sans); font-size: 11.5px; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.card-front { font-size: 22px; line-height: 1.4; color: var(--ink); }
.card-back { background: var(--raised); border: 0; border-radius: var(--r-well); color: var(--ink); }
.card-back code { background: rgba(0, 0, 0, .3); color: var(--accent); }
.kbd-hint { font-family: var(--sans); font-size: 11px; color: var(--ink-3); }
.grade { background: var(--surface); border: 0; border-radius: var(--r-well); }
.grade strong { color: var(--ink); }
.grade span { font-family: var(--sans); color: var(--ink-3); }
.grade:hover { background: var(--raised); border-color: transparent; }
.review-finish .big { color: var(--positive); }

.stats { padding: 20px 22px 22px; }
.stat-grid { gap: 0; background: var(--surface); border-radius: 16px; overflow: hidden; margin-bottom: 22px; }
.stat-box { background: transparent; border: 0; border-left: 1px solid var(--rule); border-radius: 0; padding: 16px 18px; }
.stat-box:first-child { border-left: 0; }
.stat-box strong { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-box span { font-size: 12px; color: var(--ink-2); }
.stat-section h4 { font-family: var(--sans); font-size: 12.5px; letter-spacing: 0; text-transform: none; color: var(--ink-3); font-weight: 600; }
.stat-row { font-size: 12.5px; color: var(--ink-2); }
.sr-bar { background: var(--raised); }
.sr-bar i { background: var(--accent); opacity: 1; }
.sr-count, .sr-acc { font-family: var(--sans); color: var(--ink-3); }
.stat-note { color: var(--ink-3); }
.fail-row { background: var(--surface); border: 0; border-radius: 12px; color: var(--ink); font-size: 12.5px; }
.fail-row:hover { background: var(--raised); border-color: transparent; }
.fail-name code { color: var(--ink-3); }
.fail-meta { font-family: var(--sans); color: #ff9b9b; }
.stat-actions { border-top: 1px solid var(--rule); }

.cheat { padding: 16px 20px 20px; }
.cheat-search { background: var(--surface); border: 1px solid transparent; border-radius: 12px; color: var(--ink); font-family: var(--sans); font-size: 13px; }
.cheat-search:focus { border-color: var(--control); }
.cheat-sec h4 { font-family: var(--sans); font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.cheat-row { border-bottom: 1px solid var(--rule); }
.cheat-row code { color: var(--ink); font-size: 12.5px; }
.cheat-row span { color: var(--ink-2); font-size: 13px; }
.copy-mini { border: 0; background: var(--raised); color: var(--ink-2); border-radius: 999px; padding: 3px 9px; font-family: var(--sans); font-size: 11px; }
.copy-mini:hover { color: var(--ink); border-color: transparent; }
.cheat-empty { color: var(--ink-3); }

/* orden y diff */
.order-chip { background: var(--raised); border: 0; border-radius: 10px; color: var(--ink); font-family: var(--sans); font-size: 13px; }
.order-chip:hover:not(:disabled) { background: #26282d; border-color: transparent; }
.order-answer { border: 1px dashed var(--control); border-radius: 14px; }
.order-answer.static { background: var(--surface); border-style: solid; }
.order-answer li { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; font-family: var(--sans); font-size: 13px; }
.order-answer .num { color: var(--ink-3); }
.order-answer .order-empty { color: var(--ink-3); }
.diff-box { background: var(--well); border: 0; border-radius: 12px; }
.diff-row span { font-family: var(--sans); letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.diff-row code { color: var(--ink); }

/* proyectos */
.project { background: var(--surface); border: 0; border-radius: var(--r-card); }
.project.done { border-color: transparent; outline: 1px solid rgba(94, 234, 212, .3); outline-offset: -1px; }
.project-title-row h3 { font-size: 21px; }
.chip-level, .chip-time, .proj-done-chip { font-family: var(--sans); font-size: 11.5px; border: 0; background: var(--raised); color: var(--ink-2); }
.chip-level { color: var(--ink); }
.proj-done-chip { color: var(--positive); }
.proj-bar { background: var(--raised); }

/* ------------------------- páginas de estudio ------------------------- */
.study-page { max-width: 1040px; padding: 36px 0 64px; }
.study-page > h1, .study-page > h2 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 14px; }
.study-intro { max-width: 66ch; color: var(--ink-2); font-size: 16px; margin-bottom: 30px; }
.study-lead { display: flex; align-items: center; justify-content: space-between; gap: 26px; flex-wrap: wrap; padding: 24px 26px; background: var(--surface); border: 0; border-radius: var(--r-card); margin-bottom: 8px; }
.lead-copy { min-width: 0; max-width: 62ch; }
.study-lead h3 { font-size: 20px; margin-bottom: 8px; }
.study-lead p { margin-bottom: 0; color: var(--ink-2); }
.study-row { padding: 22px 0; border-bottom: 1px solid var(--rule); gap: 24px; }
.study-row h3 { font-size: 16px; margin-bottom: 6px; }
.study-row p { color: var(--ink-2); font-size: 14px; }

.route-block { padding: 30px 0 8px; }
.route-block h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.01em; }
.route-block > p { margin: 0 0 18px; color: var(--ink-2); font-size: 14px; max-width: 62ch; }
.route { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.route-stop {
  display: grid;
  gap: 10px;
  text-align: left;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.route-stop:hover { background: var(--raised); }
.route-stop.is-next { border-color: var(--control); }
.route-stop-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.route-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.route-count { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.route-bar { height: 3px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.route-stop:hover .route-bar { background: #2a2c31; }
.route-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.route-action { font-size: 11.5px; color: var(--ink-2); }
.route-stop.is-next .route-action { color: var(--ink); font-weight: 600; }

.study-page input:not([type=checkbox]), .study-page textarea, .study-page select, .login-panel input {
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: 12px;
  color: var(--ink);
  padding: 11px 12px;
  min-height: 42px;
}
.study-page textarea { min-height: 160px; }
.study-page pre { background: var(--surface); border-radius: 12px; }
.study-tools { gap: 10px; }
.notebook-form { max-width: 760px; }
.solution-explanation { color: var(--ink-2); }
.solution-explanation summary { color: var(--ink-2); }
#saveStatus { color: var(--ink-3); }
.login-panel { max-width: 420px; }

/* práctica */
.practice-hub, .practice-session, .practice-lab { padding: 20px; }
.practice-summary { color: var(--ink-2); }
.practice-summary strong { color: var(--ink); }
.practice-course { background: var(--surface); border: 0; border-radius: 16px; }
.practice-limits, .practice-status { color: var(--ink-2); }
.practice-field input, .practice-field textarea, .practice-hub select, .practice-lab select {
  background: var(--well);
  border: 1px solid var(--control);
  border-radius: 12px;
  color: var(--ink);
}
.practice-field .lab-code { background: var(--well); border-radius: 12px; }
.practice-lab pre { background: var(--well); border: 0; border-radius: 12px; }
.lab-tabs [aria-pressed="true"] { border-color: var(--control); color: var(--ink); background: var(--raised); }
.lab-rubric .criterion-ok { color: var(--accent); }
.lab-rubric .criterion-pending { color: var(--warning); }

/* diálogos y menús flotantes conservan sombra; nada en reposo la lleva. */
.toast { background: var(--raised); border: 1px solid var(--rule); color: var(--ink); font-size: 13px; }

/* ------------------------- iconos y micrográficos ------------------------- */
.icon { width: 16px; height: 16px; flex: none; display: inline-block; }
.ghost-btn { display: inline-flex; align-items: center; gap: 7px; }
.ghost-btn .icon { width: 15px; height: 15px; }
.topbar-actions .ghost-btn .badge { margin-left: 0; }

.study-nav a { display: flex; align-items: center; gap: 8px; }
.study-nav a .icon { width: 15px; height: 15px; color: var(--ink-3); }
.study-nav a:hover .icon, .study-nav a[aria-current="page"] .icon { color: var(--ink); }

.course-tabs .ct-name { display: flex; align-items: center; gap: 6px; }
.ct-name .icon { width: 14px; height: 14px; color: var(--ink-3); }
.course-tab.active .ct-name .icon { color: var(--ink); }

.mod-num .icon { width: 14px; height: 14px; }
.mod-item.complete .mod-num .icon { color: var(--accent); }
.mod-bar { display: block; height: 2px; margin-top: 6px; background: var(--raised); border-radius: 99px; overflow: hidden; }
.mod-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; opacity: .7; }
.mod-item.active .mod-bar i { opacity: 1; }

.module-map { position: relative; display: flex; align-items: flex-start; margin: 0 0 22px; padding: 2px 8px 0 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.module-map::-webkit-scrollbar { display: none; }
.module-map::before { content: ""; position: absolute; left: 17px; right: 17px; top: 11px; height: 1px; background: var(--rule); }
.map-node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; flex: none; min-width: 42px; padding: 0 6px; background: transparent; border: 0; color: var(--ink-3); font-family: inherit; cursor: pointer; }
.map-dot { position: relative; z-index: 1; display: block; width: 19px; height: 19px; border-radius: 50%; border: 1.5px solid var(--control); background: var(--ground); }
.map-node.done .map-dot { background: var(--accent); border-color: var(--accent); }
.map-node:hover .map-dot { border-color: var(--ink-2); }
.map-node.done:hover .map-dot { border-color: #8ff5e6; }
.map-label { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.map-node.done .map-label { color: var(--ink-2); }

.activity-block { margin-top: 26px; padding: 26px 0 12px; border-top: 1px solid var(--rule); }
.activity-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.activity-head h3 { margin: 0; font-size: 18px; letter-spacing: -.01em; display: flex; align-items: center; gap: 7px; }
.activity-head h3 .icon { width: 17px; height: 17px; color: var(--accent); }
.activity-total { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.activity-chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; height: 112px; border-bottom: 1px solid var(--rule); }
.activity-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; }
.activity-bar { flex: 1; display: flex; align-items: flex-end; justify-content: center; width: 100%; }
.activity-bar i { display: block; width: 100%; max-width: 22px; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; }
.activity-bar i[data-zero] { background: var(--raised); opacity: 1; }
.activity-day { font-size: 11px; color: var(--ink-3); line-height: 1; font-variant-numeric: tabular-nums; }
.activity-empty { margin: 10px 0 0; font-size: 13px; color: var(--ink-3); }

.tag { display: inline-flex; align-items: center; gap: 6px; }
.tag .icon { width: 13px; height: 13px; }
.ex-check { display: none; align-items: center; gap: 4px; }
.ex.done .ex-check { display: inline-flex; }
.ex-check .icon { width: 13px; height: 13px; }
.route-name { display: flex; align-items: center; gap: 6px; }
.route-name .icon { width: 14px; height: 14px; color: var(--ink-3); }
.route-stop.is-next .route-name .icon { color: var(--ink); }

/* ------------------------------- móvil ------------------------------- */
@media (max-width: 1080px) and (min-width: 861px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .main { padding-inline: 32px; }
}
@media (max-width: 860px) {
  .shell { display: block; max-width: none; }
  .brand-name { display: inline; }
  .side-mark { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--accent); font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
  .side-mark svg { flex: none; }
  .topbar .menu-toggle { display: grid; place-items: center; width: 44px; min-height: 44px; flex: none; padding: 0; }
  body.modal-open .topbar { visibility: hidden; }
  .sidebar {
    inset: 60px auto 0 0;
    width: min(330px, 88vw);
    height: auto;
    padding: 24px 18px 40px;
    background: var(--ground);
    border-right: 1px solid var(--rule);
  }
  .main { padding: 30px 24px 72px; }
  .topbar-actions .ghost-btn { min-height: 44px; }
  .btn, .btn.small { min-height: 44px; }
  .copy-btn, .icon-btn, .preview-btn { min-height: 40px; }
  .icon-btn { width: 44px; height: 44px; }
  .modal-x { width: 44px; height: 44px; }
  .study-nav { grid-template-columns: 1fr 1fr; }
  .route { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mod-item { padding-block: 12px; }
  .module-outline button, .study-page summary, .practice-lab summary { min-height: 44px; padding-block: 12px; }
  .module-outline summary { padding-block: 14px; }
  .study-nav a { min-height: 44px; }
  .wb-tab { min-height: 44px; padding: 8px 12px; }
  .map-node { min-height: 44px; }
  .order-chip { min-height: 44px; }
}
@media (max-width: 740px) {
  #btnReview .topbar-label, #btnStats .topbar-label, #btnCheat .topbar-label { display: none; }
  #btnReview, #btnStats, #btnCheat { padding-inline: 9px; }
  .course-search input, .cheat-search, .sql-input, .term-in, .fill-row input, .edit-area { font-size: 16px; }
}
@media (max-width: 540px) {
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 6px;
  }
  .brand { display: none; }
  .topbar .menu-toggle { width: 44px; min-height: 44px; border-radius: 999px; }
  .topbar-progress .count { font-size: 11.5px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .ghost-btn { min-height: 44px; padding-inline: 8px; font-size: 12.5px; }  .main { padding: 24px 18px calc(64px + env(safe-area-inset-bottom)); }
  .mod-head h1, .mod-head h2, .study-page > h1, .study-page > h2 { font-size: 25px; }
  .study-lead { padding: 20px; }
  .study-lead .btn { width: 100%; }
  .route { grid-template-columns: 1fr 1fr; gap: 8px; }
  .route-stop { padding: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-box:nth-child(odd) { border-left: 0; }
  .stat-box:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .modal { max-height: 92vh; max-height: 92dvh; }
  .btn, .btn.small { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .preview-btn { min-width: 40px; min-height: 40px; }
  .order-chip { min-height: 44px; }
  .file-row { min-height: 40px; }
}
@media (max-width: 360px) {
  .topbar-progress { display: flex; flex: 0 0 44px; gap: 0; }
  .topbar-progress .count { display: none; }
  .topbar-progress .bar { display: block; width: 44px; height: 5px; background: #2f3237; }
  .topbar-actions { gap: 3px; }
}
@media (min-width: 361px) and (max-width: 540px) {
  .brand { display: flex; min-width: auto; }
  .brand-name { display: none; }
}
@media (max-width: 380px) {
  .activity-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .activity-total { font-size: 12px; }
}
@media (pointer: coarse) {
  .modal-x { width: 44px; height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .file-row { min-height: 40px; }
  .copy-btn, .copy-mini, .preview-btn { min-height: 40px; }
}
