:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --text: #171a21;
  --muted: #667085;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --accent: #3b5bdb;
  --accent-hover: #3451c7;
  --accent-soft: #eef2ff;
  --ok: #12805c;
  --ok-soft: #e7f6ef;
  --bad: #c4321f;
  --bad-soft: #fdecea;
  --mid: #b25e09;
  --mid-soft: #fdf3e6;
  --fg-fig: #171a21;
  --bg-fig: #ffffff;
  --grey-fig: #a4a9b4;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --surface: #191c23; --surface-2: #20242d; --surface-3: #2a2f3a; --text: #e9ebf0; --muted: #98a0b0;
    --border: #2a2f3a; --border-strong: #3a404d; --accent: #7b93ff; --accent-hover: #91a5ff; --accent-soft: #232c4d;
    --ok: #4cc38a; --ok-soft: #16322a; --bad: #ff7b6b; --bad-soft: #3d1f1c; --mid: #f0a54a; --mid-soft: #3a2b18;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
.container { max-width: 1160px; margin: 0 auto; padding: 24px 20px 80px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; }
.big { font-size: 1.25rem; }
.center { text-align: center; justify-content: center; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.gap-s { gap: 4px; }
.gap-l { gap: 22px; }
.stack { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1160px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 9px; font-size: 1rem; }
.logo { color: var(--accent); display: inline-flex; }
#nav { display: flex; align-items: center; gap: 2px; }
#nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 550; font-size: .93rem; }
#nav a.active { background: var(--surface-2); color: var(--text); }
#nav a:hover { color: var(--text); }
#nav .user { color: var(--muted); font-size: .88rem; padding: 0 6px 0 14px; margin-left: 6px; border-left: 1px solid var(--border); }

/* ---------- Botones y controles ---------- */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-s); font-weight: 550; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: .85rem; border-radius: 7px; }
.btn.icon { padding: 5px 7px; }
button:disabled { opacity: .45; cursor: default; }
input[type=text], input[type=password], input[type=search], select {
  font: inherit; padding: 8px 12px; border-radius: var(--radius-s); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); min-height: 38px;
}
input:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 9px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; font-size: .86rem; color: var(--muted); border-radius: 7px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.chip { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .74rem; font-weight: 600; vertical-align: 1px; }

/* ---------- Login ---------- */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth h1 { text-align: center; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; }
.tabs button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
label { display: block; font-weight: 550; margin: 10px 0 4px; font-size: .9rem; }
.auth input { width: 100%; }
.err { color: var(--bad); min-height: 1.4em; margin-top: 8px; font-size: .9rem; }

/* ---------- Inicio ---------- */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpis { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; min-width: 104px; }
.kpi b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .78rem; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar input[type=search] { flex: 1 1 200px; max-width: 280px; }
.tb-right { display: flex; gap: 10px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.cat { margin: 22px 0 8px; display: flex; align-items: baseline; gap: 10px; }
.cat h2 { margin: 0; }

/* Tabla de tipos (inicio y estadísticas) */
.ttable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ttable th { text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.ttable th.sortable { cursor: pointer; }
.ttable th.sortable:hover, .ttable th.on { color: var(--text); }
.ttable th .arr { font-size: .62rem; margin-left: 4px; color: var(--accent); }
.ttable td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: normal; }
.ttable tbody tr:last-child td { border-bottom: 0; }
.ttable tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.ttable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tname { font-weight: 600; color: var(--text); }
.ttable td.c-name { min-width: 250px; }
.tname:hover { color: var(--accent); }
.tdesc { color: var(--muted); font-size: .8rem; margin-top: 1px; max-width: 360px; }
.c-act { text-align: right; width: 1%; }
.acts { display: flex; gap: 5px; justify-content: flex-end; }
.ok-t { color: var(--ok); }
.bad-t { color: var(--bad); }
.lvl-ok-t { color: var(--ok); } .lvl-mid-t { color: var(--mid); } .lvl-bad-t { color: var(--bad); }
.accv { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; font-weight: 600; }
.accv i { width: 44px; height: 5px; border-radius: 3px; background: var(--surface-3); position: relative; overflow: hidden; display: inline-block; }
.accv i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: currentColor; border-radius: 3px; }
.accv.lvl-ok { color: var(--ok); } .accv.lvl-mid { color: var(--mid); } .accv.lvl-bad { color: var(--bad); }

/* ---------- Ejercicio ---------- */
.qhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.crumbs { color: var(--muted); font-size: .85rem; margin-bottom: 2px; }
.qhead h1 { margin: 0; }
.pill { background: var(--surface-2); border-radius: 999px; padding: 3px 11px; font-size: .84rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.timer.low { color: var(--bad); }
.question { padding: 22px 24px; }
.prompt { font-size: 1.05rem; margin-bottom: 14px; }
.qbody { margin: 4px 0 18px; overflow-x: auto; padding: 3px; -webkit-overflow-scrolling: touch; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.options.figs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.options.id { grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; }
.opt { justify-content: flex-start; text-align: left; padding: 12px 14px; min-height: 50px; font-weight: 500; white-space: normal; border-color: var(--border); }
.opt:hover { border-color: var(--accent); background: var(--surface); }
.options.figs .opt { flex-direction: column; padding: 10px 6px; gap: 4px; }
.opt .lt { font-weight: 700; color: var(--muted); min-width: 1.3em; font-size: .85rem; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.opt:disabled { opacity: 1; cursor: default; }
.opt:disabled:not(.right):not(.wrong) { opacity: .6; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: var(--surface-2); }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback h3 { margin: 0 0 6px; font-size: .98rem; }
.nextbar { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.kbd { font-size: .78rem; color: var(--muted); }

/* ---------- Examen ---------- */
.qnav { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 14px; }
.qnav button { width: 34px; height: 32px; padding: 0; font-size: .82rem; border-color: var(--border); }
.qnav button.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.qnav button.cur { box-shadow: 0 0 0 2px var(--accent); }
.qnav button.r-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.qnav button.r-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.result-head { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.nota { font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.review { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.review details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.review summary { cursor: pointer; font-weight: 600; display: flex; gap: 10px; align-items: center; }

/* ---------- Estadísticas ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 14px; margin-top: 14px; }
.chart h3 { font-size: .95rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--muted); font-size: 12px; }
.chart .line { stroke: var(--accent); fill: none; stroke-width: 2.2; }
.chart .dot { fill: var(--accent); }
.chart .area { fill: var(--accent); opacity: .1; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- Figuras de los ejercicios (siempre sobre "papel" claro) ---------- */
.fig { max-width: 100%; height: auto; background: var(--bg-fig); border-radius: 3px; }
.fig text { fill: var(--fg-fig); font-family: system-ui, sans-serif; }
.fig .invtext { fill: var(--bg-fig); font-weight: 600; }
.stroke { stroke: var(--fg-fig); }
.fgfill { fill: var(--fg-fig); }
.bgfill { fill: var(--bg-fig); }
.greyfill { fill: var(--grey-fig); }
.okstroke { stroke: var(--ok); }
.faint { opacity: .35; }
.grid { stroke: #e4e7ec; stroke-width: 1; }
.cell { fill: var(--bg-fig); stroke: var(--fg-fig); stroke-width: 1.2; }
.skin { stroke: #c98b63; }
.skinfill { fill: #c98b63; }
.piecefill { fill: #8f96a3; }
.face-top { fill: #e4e7ee; }
.face-front { fill: #ffffff; }
.face-side { fill: #a9afbb; }

.grid3 { display: grid; grid-template-columns: repeat(3, auto); gap: 8px; justify-content: center; }
.grid3.tight { gap: 0; }
.grid3.tight > * { margin: -0.5px; }
.qcell { width: 76px; height: 76px; border: 1.2px solid var(--fg-fig); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 700; background: var(--bg-fig); color: var(--fg-fig); }
.qcell.small { width: 70px; height: 70px; border-style: dashed; }
.q { font-weight: 800; font-size: 1.2rem; color: var(--accent); padding: 0 6px; }
.model { font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.serie { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.serie.letras { font-family: ui-monospace, Consolas, monospace; letter-spacing: .1em; }
.eq { text-align: center; font-size: 1.45rem; font-family: "Cambria Math", Georgia, serif; }
.texto, .serie, .eq, .clave { color: var(--text); }
.texto { font-family: ui-monospace, Consolas, monospace; font-size: 1.02rem; line-height: 1.8; background: var(--surface-2); padding: 12px 14px; border-radius: 8px; letter-spacing: .03em; }
.clave { display: flex; justify-content: center; align-items: stretch; border: 1.5px solid currentColor; border-radius: 6px; width: max-content; margin: 0 auto; font-size: 1.3rem; }
.clave-ops { padding: 10px 18px; border-right: 1.5px solid currentColor; }
.clave-q { padding: 10px 22px; display: flex; align-items: center; font-weight: 700; }
.sym, .s { font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; }
.sym { font-size: 1.15em; }
.hl { background: #ffd84d; color: #000; border-radius: 3px; }

.cmp { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.seq { font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; font-size: 1.45rem; letter-spacing: .12em; white-space: nowrap; }
.seq.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .25em; }
.vs { color: var(--muted); font-weight: 700; font-size: .9rem; }
@media (min-width: 720px) { .cmp.row-on-wide { flex-direction: row; justify-content: center; gap: 24px; } }
.mgrid { display: grid; width: max-content; margin: 0 auto; grid-template-columns: repeat(6, 1.9em); font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; font-size: 1.2rem; border: 1px solid #dde1ea; background: var(--bg-fig); color: var(--fg-fig); }
.mgrid span { text-align: center; border: .5px solid #dde1ea; line-height: 1.75em; }
.linea { display: flex; flex-wrap: wrap; gap: 1px 5px; font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; font-size: 1.35rem; line-height: 1.9; background: var(--bg-fig); color: var(--fg-fig); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.cgrid { display: grid; grid-template-columns: repeat(var(--cols), 1.55em); justify-content: center; font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; font-size: 1.15rem; line-height: 1.6; background: var(--bg-fig); color: var(--fg-fig); padding: 8px; border-radius: 8px; border: 1px solid var(--border); width: max-content; margin: 0 auto; }
.cgrid span { text-align: center; }
.lbox { display: grid; grid-template-columns: repeat(4, 1.7em); border: 1.5px solid var(--fg-fig); padding: 6px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; background: var(--bg-fig); color: var(--fg-fig); }
.lbox span { text-align: center; }
.codif { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.wrow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wbox { border: 1.5px solid currentColor; padding: 3px 10px; font-family: ui-monospace, Consolas, monospace; font-size: .95rem; letter-spacing: .06em; }
.cbox { border: 1.5px solid var(--fg-fig); padding: 3px 8px; font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; font-size: 1.05rem; letter-spacing: .1em; background: var(--bg-fig); color: var(--fg-fig); }
.mats { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 12px 22px; justify-content: center; }
.mat { display: grid; grid-template-columns: repeat(4, 38px); gap: 2px; background: var(--surface-2); padding: 8px 8px 8px 26px; border-radius: 8px; position: relative; }
.mlabel { position: absolute; left: 8px; top: 6px; font-weight: 700; color: var(--muted); }

/* ---------- Tablet ---------- */
@media (max-width: 900px) {
  .tdesc { display: none; }
  .ttable th:nth-child(8), .ttable td:nth-child(8) { display: none; } /* columna "Última vez" / "Mejor nota" */
}

/* ---------- Móvil ---------- */
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .container { padding: 16px 12px calc(90px + env(safe-area-inset-bottom)); }
  .topbar-in { padding: 8px 12px; }
  #nav .user { display: none; }
  #nav a { padding: 6px 9px; }
  h1 { font-size: 1.3rem; }
  .hero { align-items: stretch; margin-bottom: 14px; }
  .kpis { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); }
  .kpi { min-width: 0; padding: 7px 10px; }
  .kpi b { font-size: 1.1rem; }
  .toolbar input[type=search] { max-width: none; flex-basis: 100%; }
  .toolbar > .seg { width: 100%; }
  .toolbar > .seg button { flex: 1; padding: 6px 4px; }
  .tb-right { margin-left: 0; width: 100%; }
  .tb-right select { flex: 1; min-width: 0; }

  /* Tablas → tarjetas */
  .ttable thead { display: none; }
  .ttable, .ttable tbody { display: block; }
  .ttable tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .ttable tbody tr:last-child { border-bottom: 0; }
  .ttable td { display: block !important; padding: 0; border: 0; text-align: left !important; min-width: 0; }
  .ttable td[data-l]::before { content: attr(data-l); display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
  .ttable td[data-l=""]::before { content: none; }
  .ttable td.c-name { grid-column: 1 / -1; }
  .ttable td.c-name::before { display: none !important; }
  .ttable td:nth-child(6), .ttable td:nth-child(7), .ttable td:nth-child(8) { display: none !important; }
  .ttable td.c-act { grid-column: 1 / -1; width: auto; margin-top: 4px; }
  .ttable td.c-act:empty { display: none !important; }
  .ttable tr.nodata td.num { grid-column: 1 / -1; }
  .acts { justify-content: stretch; }
  .acts .btn { flex: 1; }
  .acts .btn.icon { flex: 0 0 auto; }
  .accv i { display: none; }
  .accv { justify-content: flex-start; }

  /* Ejercicio */
  .question { padding: 14px; }
  .prompt { font-size: 1rem; }
  .options { grid-template-columns: 1fr; gap: 8px; }
  .options.figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options.id { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opt { min-height: 48px; }
  .qhead { align-items: flex-start; }
  .qhead .row { width: 100%; }
  .seq { font-size: 1.05rem; letter-spacing: .06em; }
  .serie { font-size: 1.25rem; gap: 10px; }
  .eq { font-size: 1.2rem; }
  .cgrid { font-size: .92rem; }
  .linea { font-size: 1.15rem; }
  .mgrid { font-size: 1rem; }
  .mats { gap: 8px; }
  .mat { grid-template-columns: repeat(4, 28px); padding: 6px 6px 6px 20px; }
  .mat .fig { width: 28px; }
  .mlabel { left: 6px; }
  .grid3.tight .fig, .grid3.tight .qcell { width: 64px; height: 64px; }
  .qnav button { width: 32px; height: 32px; }

  /* Barra de acciones fija al pie durante el examen */
  .exambar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border); flex-wrap: nowrap; }
  .exambar .row { flex: 1; }
  .exambar button { flex: 1; padding: 9px 8px; }
}
@media (max-width: 380px) {
  .brand-t { display: none; }
}

/* ---------- Panel de inicio ---------- */
.sect { margin: 26px 0 10px; }
.dash { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dcard { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.dcard > .btn, .dcard > button { align-self: flex-start; }
.dhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dhead h3 { margin: 0; font-size: .98rem; }
.big-n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big-n .muted { font-weight: 600; font-size: 1rem; }
.dcard p { margin: 0; }
.streaks { display: flex; gap: 12px; margin-top: 6px; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.streaks b { color: var(--text); font-size: .95rem; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 64px; align-items: end; }
.wd { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.wd i { display: block; width: 100%; max-width: 22px; background: var(--surface-3); border-radius: 4px 4px 2px 2px; }
.wd i.met { background: var(--ok); }
.wd:last-child i { outline: 2px solid var(--accent); outline-offset: 1px; }
.wd span { font-size: .68rem; color: var(--muted); text-transform: uppercase; }
.rec { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.rec li { display: flex; gap: 10px; align-items: flex-start; }
.rdot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; background: var(--accent); }
.cat-0 { background: #3b5bdb; } .cat-1 { background: #0c8599; } .cat-2 { background: #9c36b5; } .cat-3 { background: #e8590c; } .cat-4 { background: #2f9e44; }
.simlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; flex: 1; font-size: .88rem; }
.simlist li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--border); padding-bottom: 6px; }
.simlist li:last-child { border-bottom: 0; }
.ring { flex: 0 0 auto; }

/* Nivel de dificultad */
.lvl { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.lvl-1, .pill.lvl-pill.lvl-1 { background: var(--ok-soft); color: var(--ok); }
.lvl-2, .pill.lvl-pill.lvl-2 { background: var(--mid-soft); color: var(--mid); }
.lvl-3, .pill.lvl-pill.lvl-3 { background: var(--bad-soft); color: var(--bad); }

/* Barra de tiempo objetivo */
.tbar { height: 4px; border-radius: 3px; background: var(--surface-3); margin: -4px 0 12px; overflow: hidden; }
.tbar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .2s linear; }
.tbar.over i { background: var(--bad); }
.qlabel { color: var(--text); font-size: .82rem; margin-bottom: 6px; font-weight: 600; }
.qlabel .muted { font-weight: 400; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 .78rem/1.4 ui-monospace, Consolas, monospace; color: var(--text); text-align: center; }

/* Avisos */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .92rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: tin .2s ease-out, tout .4s ease-in 3.2s forwards; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
@keyframes tout { to { opacity: 0; transform: translateY(8px); } }

/* Ventana de atajos */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 18, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--surface); border-radius: 14px; padding: 20px; width: min(460px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.keys { width: 100%; margin-top: 10px; }
.keys td { border: 0; padding: 6px 4px; white-space: normal; vertical-align: top; }
.keys td:first-child { white-space: nowrap; padding-right: 14px; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.keys-grid h3 { font-size: .95rem; margin: 0; }

/* Modo foco */
body.focus .topbar { display: none; }
body.focus .container { max-width: 980px; padding-top: 18px; }
body.focus .crumbs { display: none; }

/* Ajustes */
.settings { display: flex; flex-direction: column; gap: 4px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.set-row > div:first-child { flex: 1 1 280px; }
input[type=number] { font: inherit; padding: 7px 10px; border-radius: var(--radius-s); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); min-height: 36px; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Simulacro */
.simblocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; margin-top: 12px; }
.simblock { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 0; font-weight: 400; cursor: pointer; }
.simblock:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.simblock input { margin-top: 3px; accent-color: var(--accent); }
.empty-state { text-align: center; padding: 34px 18px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty-state h2 { margin: 0; }
.empty-state p { margin: 0; max-width: 520px; }

@media (max-width: 1080px) { .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .ttable.showall th:nth-child(8), .ttable.showall td:nth-child(8) { display: table-cell; } }
@media (max-width: 720px) {
  .dash { grid-template-columns: 1fr; }
  .ttable.showall td { display: block !important; }
  .dcard > .btn, .dcard > button { align-self: stretch; }
  #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .toast { text-align: center; }
}

/* Exámenes por bloque, teoría y selector de dificultad */
.dash.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.blockbtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.blockbtns .btn { display: flex; align-items: center; gap: 8px; justify-content: flex-start; }
.blockbtns .btn .rdot { margin-top: 0; }
.blockbtns .btn .muted { margin-left: auto; }
.diffsel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) { .dash.two { grid-template-columns: 1fr; } .diffsel { width: 100%; } .diffsel .seg { flex: 1; } .diffsel .seg button { flex: 1; padding: 6px 4px; } }
