/* Azterketak MSS26 — estética mate y minimalista.
   Sin sombras ni degradados ni brillos: superficies planas, bordes de 1 px,
   un grano muy suave en el fondo y un único color apagado por examen. */

:root {
  --bg: #e6e3dd;
  --surface: #edebe6;
  --surface-2: #dedbd4;
  --ink: #1f1f20;
  --ink-2: #47453f;
  --muted: #5f5b54; /* ≥4,5:1 sobre --bg y --surface-2 */
  --line: #d0ccc4;
  --line-2: #bdb8ae;
  --page-ph: #d8d4cc;
  --viewer-fs: #121213;
  --urgent-bg: #e3cfc5;
  --urgent-ink: #74361f;
  --acc-l: 44%;
  --grain: .05;
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  --bar-h: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181a;
    --surface: #1f1f22;
    --surface-2: #27272b;
    --ink: #e6e3dd;
    --ink-2: #bcb8b0;
    --muted: #8b877f;
    --line: #2f2f33;
    --line-2: #3c3c41;
    --page-ph: #232326;
    --urgent-bg: #3b2923;
    --urgent-ink: #e2b39f;
    --acc-l: 64%;
    --grain: .07;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18181a;
  --surface: #1f1f22;
  --surface-2: #27272b;
  --ink: #e6e3dd;
  --ink-2: #bcb8b0;
  --muted: #8b877f;
  --line: #2f2f33;
  --line-2: #3c3c41;
  --page-ph: #232326;
  --urgent-bg: #3b2923;
  --urgent-ink: #e2b39f;
  --acc-l: 64%;
  --grain: .07;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  position: relative;
}
/* El grano va en una capa por detrás de todo: nunca ensucia el PDF. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::before { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { filter: invert(1); } }

a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
p { margin: 0; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 12px; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- cabecera */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  max-width: 1120px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; min-width: 0; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; flex: none; background: var(--ink); }
/* El logo (icons/icon.svg): prompt «›_» que acaba en «check», en los colores del tema. */
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-mark path { fill: none; stroke: var(--bg); stroke-width: 50; stroke-linecap: round; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-family: var(--mono); font-size: .92rem; letter-spacing: .06em; }
.brand-text span { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 8px; flex: none; }

.lang, .seg {
  display: inline-flex; padding: 2px; gap: 2px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
}
.lang button, .seg button {
  border: 0; background: none; cursor: pointer;
  padding: 5px 10px; border-radius: 7px;
  font-size: .8rem; font-family: var(--mono); letter-spacing: .03em; color: var(--muted);
  white-space: nowrap;
}
.lang button:hover, .seg button:hover { color: var(--ink); }
.lang button.on, .seg button.on { background: var(--ink); color: var(--bg); }
.seg button small { font-size: .74rem; opacity: .75; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled, .icon-btn[aria-disabled="true"] { opacity: .35; cursor: default; background: var(--surface); }

/* ---------------------------------------------------------------- ordutegia */
dialog.tt {
  width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  margin: auto; padding: 18px 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
dialog.tt::backdrop { background: rgb(0 0 0 / .38); }
dialog.tt[open] { animation: q-pop-in .22s cubic-bezier(.2, .9, .3, 1.2); }
.tt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tt-head h2 { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.tt-head h2 .ico { width: 20px; height: 20px; color: var(--muted); }
.tt-tabs { display: grid; grid-template-columns: repeat(5, 1fr) 1.35fr; gap: 4px; margin-top: 14px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tt-tab { border: 0; background: none; cursor: pointer; padding: 7px 0; border-radius: 7px; font: 600 .82rem var(--mono); color: var(--muted); position: relative; }
.tt-tab:hover { color: var(--ink); }
.tt-tab.on { background: var(--ink); color: var(--bg); }
.tt-tab.all { font-family: var(--sans, inherit); letter-spacing: .01em; }
.tt-tab.today::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.tt-day { margin-top: 14px; font-weight: 600; }
.tt-rel { font-weight: 400; color: var(--muted); }
.tt-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.tt-row { display: grid; grid-template-columns: 3.4em minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tt-time { display: flex; flex-direction: column; font-family: var(--mono); font-size: .74rem; line-height: 1.25; color: var(--muted); font-variant-numeric: tabular-nums; }
.tt-time b { font-weight: 600; font-size: .82rem; color: var(--ink-2); }
.tt-subj { display: flex; align-items: center; gap: 8px; min-width: 0; color: inherit; text-decoration: none; padding: 10px 0; }
.tt-subj:hover .tt-name { text-decoration: underline; }
.tt-mark { flex: none; width: 4px; align-self: stretch; border-radius: 2px; background: hsl(var(--hue) 20% var(--acc-l)); }
.tt-row, .tt-legend li { --acc: hsl(var(--hue) 20% var(--acc-l)); }
.tt-subj .subj-code { margin-right: 0; min-width: calc(6ch + 16px); box-sizing: border-box; text-align: center; }
.tt-name { line-height: 1.3; }
.tt-row.break { min-height: 34px; padding-block: 5px; background: transparent; border-style: dashed; }
.tt-break { font-size: .86rem; color: var(--muted); }
.tt-row.past, .tt-list.is-off .tt-row { background: transparent; }
.tt-row.past .tt-name, .tt-row.past .tt-time, .tt-row.past .tt-time b, .tt-row.past .subj-code,
.tt-list.is-off .tt-name, .tt-list.is-off .tt-time, .tt-list.is-off .tt-time b, .tt-list.is-off .subj-code { color: var(--muted); }
.tt-row.past .tt-mark, .tt-list.is-off .tt-mark { opacity: .35; }
.tt-row.now { border-color: var(--ink-2); box-shadow: inset 3px 0 0 var(--ink-2); }
.tt-badge { font: 600 .7rem var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tt-badge.now { background: var(--ink); border-color: var(--ink); color: var(--bg); }
/* «Dena»: la semana en una tabla (tramos en filas, días en columnas). */
.tt-week { width: 100%; margin-top: 8px; table-layout: fixed; border-collapse: separate; border-spacing: 3px; }
.tt-week .tt-col-time { width: 3.3em; }
.tt-week th, .tt-week td { padding: 0; font-weight: normal; }
.tt-week thead th { padding: 2px 0 4px; text-align: center; font: 600 .78rem var(--mono); color: var(--muted); position: relative; }
.tt-week thead th.today { color: var(--ink); }
.tt-week thead th.today::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.tt-week tbody th { text-align: left; vertical-align: middle; }
.tt-week tbody tr { height: 40px; }
.tt-week tbody tr.break { height: 30px; }
.tt-wcell {
  position: relative; border-radius: 8px; text-align: center; vertical-align: middle;
  background: color-mix(in srgb, hsl(var(--hue) 35% var(--acc-l)) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, hsl(var(--hue) 20% var(--acc-l)) 38%, transparent);
}
.tt-wcell a {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: inherit;
  font: 600 .72rem var(--mono); letter-spacing: .01em; color: hsl(var(--hue) 22% var(--acc-ink-l)); text-decoration: none;
}
.tt-wcell a:hover { background: color-mix(in srgb, hsl(var(--hue) 35% var(--acc-l)) 12%, transparent); }
.tt-wcell a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.tt-wcell.empty { background: none; border-style: dashed; border-color: var(--line); color: var(--muted); font-size: .8rem; }
.tt-wcell.past, .tt-wcell.off { background: transparent; border-style: dashed; }
.tt-wcell.past a, .tt-wcell.off a { color: var(--muted); }
.tt-wcell.now { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tt-wbreak { text-align: center; vertical-align: middle; font-size: .8rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }
.tt-wbreak.now { color: var(--ink); border-style: solid; border-color: var(--ink); }
.tt-wbreak.past { color: var(--muted); }
.tt-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 2px 0; padding: 0; list-style: none; font-size: .8rem; color: var(--muted); }
.tt-legend li { display: flex; align-items: center; gap: 6px; }
.tt-legend .tt-mark { height: 12px; align-self: center; }
.tt-legend b { font: 600 .74rem var(--mono); color: var(--ink-2); }
@media (max-width: 380px) {
  dialog.tt { width: calc(100% - 20px); padding-inline: 12px; }
  .tt-row { gap: 8px; } .tt-subj .subj-code { display: none; }
  .tt-week { border-spacing: 2px; } .tt-week .tt-col-time { width: 3em; }
  .tt-wcell a { font-size: .66rem; letter-spacing: 0; }
}

/* Días sin clase en el horario (festivos, zubiak, oporrak: egutegia) */
.tt-off { margin-top: 12px; padding: 8px 12px; border: 1px dashed var(--line-2); border-radius: 10px; font-size: .86rem; color: var(--ink-2); }
.tt-off + .tt-day { margin-top: 12px; }
.tt-day + .tt-off { margin-top: 8px; }

.tt-week thead th.off { text-decoration: line-through; text-decoration-thickness: 1.5px; }

.tt-week-off { margin-top: 10px; }

/* --------------------------------------------------------- eskola-egutegia */
.cal-page { max-width: 760px; margin: 0 auto; }
.cal-page .page-head { margin-top: 4px; }
.cal-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 24px; }
.cal-stat { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.cal-stat-k { font: 600 .72rem var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cal-stat-v { font-size: 1.12rem; font-weight: 600; line-height: 1.25; }
.cal-stat-sub { font-size: .86rem; color: var(--muted); }
.cal-bar { display: block; height: 6px; margin-top: 8px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.cal-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ink-2); }

/* Colores del papel (rojo, verde, azul, lima, amarillo), mates y con buen
   contraste en los dos temas: el número va siempre en --ink. */
:root { --cal-s: 55%; --cal-l: 80%; --cal-bl: 33%; }
:root[data-theme="dark"] { --cal-s: 32%; --cal-l: 30%; --cal-bl: 62%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cal-s: 32%; --cal-l: 30%; --cal-bl: 62%; } }
.k-holiday { --k: 4; } .k-bridge { --k: 138; } .k-vacation { --k: 207; } .k-local { --k: 72; } .k-limit { --k: 46; }
/* Larunbata eta igandea: un poco de rojo, más suave que un jaieguna (sin
   borde) y con el número en rojo oscuro (≥5,9:1 en los dos temas). */
:root { --we-bg: hsl(4 62% 92%); --we-ink: hsl(4 48% 38%); }
:root[data-theme="dark"] { --we-bg: hsl(4 24% 17%); --we-ink: hsl(4 58% 72%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --we-bg: hsl(4 24% 17%); --we-ink: hsl(4 58% 72%); } }

.cal-legend { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 8px; font-size: .9rem; }
.cal-legend li { display: flex; align-items: baseline; gap: 10px; }
.cal-legend b { font-weight: 600; }
.cal-leg-dates { color: var(--muted); }
.cal-sw { flex: none; width: 14px; height: 14px; border-radius: 4px; transform: translateY(2px); background: hsl(var(--k) var(--cal-s) var(--cal-l)); border: 1.5px solid hsl(var(--k) 45% var(--cal-bl)); }
.cal-sw.k-limit { background: none; border-style: dashed; }
.cal-sw.k-exam { background: none; border: 2px solid var(--ink); border-radius: 50%; }
.cal-sw.k-exam-maybe { background: none; border: 2px dashed var(--ink); border-radius: 50%; }

.cal-past { margin-top: 26px; }
.cal-past > summary { cursor: pointer; color: var(--muted); font-size: .92rem; width: fit-content; padding: 4px 2px; }
.cal-past > summary:hover { color: var(--ink); }
.cal-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 228px), 1fr)); gap: 22px 18px; margin-top: 26px; }
.cal-past .cal-months { margin-top: 14px; }
.cal-month table { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.cal-month caption { text-align: left; font-weight: 600; padding: 0 2px 6px; }
.cal-month.current caption::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: var(--ink); vertical-align: 2px; }
.cal-y { color: var(--muted); font-weight: 400; }
.cal-month th { font: 600 .68rem var(--mono); color: var(--muted); padding: 2px 0 4px; }
.cal-month td { padding: 0; height: 34px; text-align: center; vertical-align: middle; border-radius: 7px; font-size: .86rem; font-variant-numeric: tabular-nums; position: relative; }
.cal-month td.out { color: var(--muted); }
.cal-month th.we { color: var(--we-ink); }
.cal-month td.we { background: var(--we-bg); color: var(--we-ink); }
.cal-month td.we.past { background: color-mix(in srgb, var(--we-bg) 55%, transparent); color: color-mix(in srgb, var(--we-ink) 50%, var(--muted)); }
/* Sin clase (jaieguna, zubia, oporrak, herriko jaiak): fondo de su color y
   borde oscuro, que se ve aunque no se distingan los colores. */
.cal-month td[class*=" k-"] { background: hsl(var(--k) var(--cal-s) var(--cal-l)); color: var(--ink); box-shadow: inset 0 0 0 1.5px hsl(var(--k) 45% var(--cal-bl)); }
/* Hasiera y amaiera sí tienen clase: solo contorno discontinuo. */
.cal-month td.k-limit { background: none; box-shadow: none; outline: 1.5px dashed hsl(var(--k) 55% var(--cal-bl)); outline-offset: -2px; }
.cal-month td.past { color: var(--muted); }
.cal-month td.past[class*=" k-"] { background: color-mix(in srgb, hsl(var(--k) var(--cal-s) var(--cal-l)) 55%, var(--bg)); color: var(--muted); }
.cal-month td.today { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; color: var(--ink); }
.cal-month td.has-exam .cal-n { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 50%; font-weight: 700; }
.cal-month td.has-exam a { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: inherit; text-decoration: none; border-radius: inherit; }
.cal-month td.has-exam a:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
/* Día posible de un examen aún sin decidir: círculo discontinuo. */
.cal-month td.has-exam.maybe .cal-n { border-style: dashed; font-weight: 600; }
.cal-month td .cal-more { position: absolute; top: 1px; right: 2px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: .62rem; font-weight: 800; line-height: 14px; text-align: center; }
.cal-note { margin-top: 28px; font-size: .86rem; }
@media (min-width: 700px) { .cal-month td { height: 30px; font-size: .82rem; } .cal-month td.has-exam .cal-n { width: 24px; height: 24px; } }

/* Con el símbolo de la app Android (solo en Android) son cinco cosas arriba:
   el nombre se esconde antes y, en los móviles más estrechos, se aprietan un
   poco (40 px sigue siendo un objetivo cómodo para el dedo). */
@media (max-width: 440px) {
  .top:has(.apk-btn) .brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top:has(.apk-btn) .tools { gap: 6px; }
}
@media (max-width: 359px) {
  .top:has(.apk-btn) { gap: 8px; }
  .top:has(.apk-btn) .tools { gap: 4px; }
  .top:has(.apk-btn) .icon-btn { width: 40px; height: 40px; }
  .top:has(.apk-btn) .lang button { padding: 5px 7px; }
}

/* Aviso de cómo instalar la app Android (tras pulsar el símbolo de arriba) */
.apk-toast { gap: 6px; padding: 6px 6px 6px 16px; border-radius: 16px; font-size: .86rem; line-height: 1.35; }
.apk-toast .icon-btn { border: 0; background: transparent; flex: none; }

/* Con cuatro cosas arriba (horario, egutegia, idioma, tema) el nombre de la
   web no cabe en los móviles más estrechos: se queda solo el logo. */
@media (max-width: 359px), (max-width: 374px) and (pointer: coarse) {
  .brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tools { gap: 6px; }
}

/* Aviso de versión nueva (cuando no se puede recargar sola) */
.update-bar {
  position: fixed; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 50;
  width: max-content; max-width: calc(100% - 32px); margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .9rem;
  box-shadow: 0 8px 28px rgb(0 0 0 / .18);
  animation: q-rise .3s ease-out both;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; font-size: .95rem;
}
.btn:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ cuerpo */
main { padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.home, .narrow { max-width: 760px; margin: 0 auto; }
.home { padding-top: clamp(28px, 7vh, 72px); }

.page-head h1, .exam-head h1 { font-size: clamp(1.85rem, 5.2vw, 2.6rem); line-height: 1.12; overflow-wrap: anywhere; }
.lead { color: var(--muted); margin-top: 10px; font-size: 1.02rem; }
.empty { color: var(--muted); margin-top: 32px; }

.exam-list { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 10px; }
.exam {
  --acc: hsl(var(--hue) 20% var(--acc-l));
  display: grid; grid-template-columns: 4px minmax(0, 1fr) auto 18px; align-items: center; gap: 16px;
  padding: 18px 18px 18px 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; transition: background-color .15s, border-color .15s;
}
.exam:hover { background: var(--surface-2); border-color: var(--line-2); }
.exam-mark { align-self: stretch; background: var(--acc); margin: -18px 0; }
.exam-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.exam-title { font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.exam-when { color: var(--muted); font-size: .92rem; }
.exam-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px 3px 7px;
}
.tag .ico { width: 14px; height: 14px; }
.tag-dim { color: var(--muted); }
.exam-go { color: var(--muted); width: 18px; height: 18px; grid-column: -2; }
.is-done .exam { background: transparent; border-style: dashed; }
.is-done .exam-mark { background: var(--line-2); }
.is-done .exam-title { color: var(--ink-2); }

.chip {
  font-size: .8rem; font-family: var(--mono); letter-spacing: .01em;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.chip.urgent { background: var(--urgent-bg); color: var(--urgent-ink); }

section.done { margin-top: 44px; }
section.done h2, .section-h {
  font-family: var(--mono); font-size: .78rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
}
section.done .exam-list { margin-top: 14px; }

@media (max-width: 560px) {
  .exam { grid-template-columns: 4px minmax(0, 1fr) 18px; gap: 14px; padding: 16px 14px 16px 0; }
  .exam-mark { margin: -16px 0; }
  .exam .chip { grid-column: 2; grid-row: 2; justify-self: start; margin-top: -4px; }
  .exam-go { grid-column: 3; grid-row: 1 / span 2; }
}

/* --------------------------------------------------------- página de examen */
.exam-page { --acc: hsl(var(--hue) 20% var(--acc-l)); }
.back {
  display: inline-flex; align-items: center; gap: 4px; margin: 18px 0 18px -4px;
  color: var(--muted); text-decoration: none; font-size: .92rem; padding: 4px 6px 4px 2px; border-radius: 8px;
}
.back:hover { color: var(--ink); }
.exam-head { border-left: 3px solid var(--acc); padding-left: 16px; }
.exam-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; color: var(--muted); }
.exam-meta > span:first-child::first-letter { text-transform: uppercase; }

.quiz-card {
  display: flex; gap: 14px; align-items: flex-start;
  margin-top: 30px; padding: 16px 18px;
  border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--muted);
}
.quiz-ico { width: 22px; height: 22px; margin-top: 1px; }
.quiz-card h2 { font-size: 1.02rem; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.quiz-card p { font-size: .92rem; margin-top: 3px; }
.badge {
  font-family: var(--mono); font-size: .68rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--muted);
}

.section-h { display: flex; align-items: center; gap: 8px; margin: 38px 0 0; }
.section-h .ico { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ visor */
.viewer { max-width: 2400px; margin: 0 auto; }
.viewer-bar {
  position: static; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  /* Ancho fijo respecto al alto de pantalla: si dependiera de --bar-h (que
     sale de su propio alto) habría un bucle con el ResizeObserver. */
  width: min(100%, max(760px, calc((100svh - 108px) * var(--ar, 1.7778))));
  margin: 14px auto 0; padding: 10px 10px 10px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: opacity .3s;
}
/* Fija arriba solo si hay sitio: en el móvil (sobre todo en horizontal)
   se comería media pantalla; allí sale la pastilla de abajo. */
@media (min-width: 561px) and (min-height: 501px) {
  .viewer-bar { position: sticky; top: 8px; }
}
.vb-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; }
.vb-title strong { font-weight: 600; font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vb-meta { font-size: .8rem; color: var(--muted); font-family: var(--mono); }
.vb-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vb-nav { display: flex; align-items: center; gap: 4px; }
.vb-actions { display: flex; align-items: center; gap: 8px; }
.vb-counter {
  font-family: var(--mono); font-size: .84rem; font-variant-numeric: tabular-nums;
  min-width: 72px; text-align: center; color: var(--ink-2); white-space: nowrap;
}
.formats { display: flex; align-items: center; gap: 8px; }
.formats-label { font-family: var(--mono); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.viewer-status {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 16px; text-align: center; color: var(--muted);
}
.viewer-status:not(:has(p)) { flex-direction: row; justify-content: center; }
.viewer-status[hidden] { display: none; }
.viewer.has-error .pages { display: none; }

.pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 18px 0 56px; outline: none; }
.page {
  position: relative; flex: none;
  width: min(100%, calc((100svh - var(--bar-h, 0px) - 32px) * var(--ar, 1.7778)));
  aspect-ratio: var(--ar, 1.7778);
  background: var(--page-ph); border-radius: 4px; overflow: hidden;
}
@supports not (height: 100svh) {
  .page { width: min(100%, calc((100vh - var(--bar-h, 0px) - 32px) * var(--ar, 1.7778))); }
  .viewer-bar { width: min(100%, max(760px, calc((100vh - 108px) * var(--ar, 1.7778)))); }
}
.page::before {
  content: attr(data-n);
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--mono); font-size: .85rem; color: var(--muted);
}
.page.ready::before { content: none; }
.page canvas { position: relative; display: block; width: 100%; height: 100%; }

/* Pastilla de lectura del móvil: página actual y pantalla completa. */
.viewer-pill {
  position: fixed; z-index: 6;
  right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom));
  display: none; align-items: center; gap: 4px; padding: 4px 4px 4px 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
}
.viewer-pill.show { display: flex; }
.viewer-pill .vb-counter { min-width: 0; }
.viewer-pill .icon-btn { border-radius: 999px; border: 0; background: transparent; }

/* Pantalla completa: una página por pantalla, encajada entera. */
.viewer.is-fs { background: var(--viewer-fs); max-width: none; width: 100vw; height: 100vh; overflow: hidden; }
.viewer.is-fs .viewer-bar {
  position: fixed; top: 12px; right: 12px; left: auto; z-index: 10; width: auto;
  min-height: 0; padding: 6px; margin: 0;
  background: rgba(24, 24, 26, .82); color: #e6e3dd; border: 1px solid #333; border-radius: 12px;
}
.viewer.is-fs .viewer-bar.idle { opacity: 0; pointer-events: none; }
.viewer.is-fs .viewer-bar:has(:focus-visible) { opacity: 1; pointer-events: auto; }
.viewer.is-fs :focus-visible { outline-color: #e6e3dd; }
.viewer.is-fs .viewer-pill { display: none; }
.viewer.is-fs .vb-title, .viewer.is-fs .formats, .viewer.is-fs a.icon-btn { display: none; }
.viewer.is-fs .vb-controls, .viewer.is-fs .vb-actions { flex-wrap: nowrap; width: auto; }
.viewer.is-fs .icon-btn { background: transparent; border-color: #3a3a3e; color: #d8d4cc; }
.viewer.is-fs .vb-counter { color: #d8d4cc; }
.viewer.is-fs .pages {
  position: relative; height: 100vh; height: 100dvh; overflow-y: auto; gap: 0; padding: 0;
  scroll-snap-type: y mandatory; overscroll-behavior: contain;
}
.viewer.is-fs .page {
  width: 100vw; height: 100vh; height: 100dvh; aspect-ratio: auto;
  border-radius: 0; background: transparent; scroll-snap-align: center;
}
.viewer.is-fs .page::before { color: #555; }
.viewer.is-fs .page canvas { object-fit: contain; }

/* ------------------------------------------------------------------ varios */
.state {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 90px 16px; text-align: center; color: var(--muted);
}
.state:not(:has(p)) { flex-direction: row; justify-content: center; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--line-2); border-top-color: var(--ink-2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.foot {
  max-width: 760px; margin: 72px auto 0;
  padding: 18px max(16px, env(safe-area-inset-left)) max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); font-size: .82rem; display: grid; gap: 4px;
}
.exam-page ~ .foot, main:has(.exam-page) + .foot, main:has(.note-page > .viewer:last-child) + .foot { margin-top: 24px; }
/* Que la pastilla de lectura del móvil no tape el pie. */
@media (max-width: 560px), (max-height: 500px) { main:has(.viewer) + .foot { padding-bottom: 88px; } }

@media (max-width: 560px) {
  .brand-text span { display: none; }
  .exam-mark { grid-row: 1 / span 2; }
  .viewer-bar { padding: 10px 10px 10px 12px; }
  .vb-title { flex-basis: 100%; }
  /* Dos filas: formatos arriba; contador a la izquierda y acciones a la
     derecha abajo. Cabe a 320 px con "108 / 108". */
  .vb-controls { width: 100%; gap: 8px; }
  .formats { flex-basis: 100%; }
  .formats .seg { flex: 1; }
  .formats .seg button { flex: 1; }
  .formats-label, .seg button small, .vb-nav .icon-btn { display: none; }
  .vb-nav { margin-right: auto; }
  .vb-counter { min-width: 0; padding: 0 4px; }
  .pages { gap: 12px; }
}

/* Dedos: objetivos de 40-44 px. */
@media (pointer: coarse) {
  .lang button, .seg button { min-height: 40px; }
  .seg, .lang { gap: 4px; }
  .icon-btn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .q-feedback.fresh, .q-feedback.fresh .qf-why.open { animation: none !important; }
}

@media print {
  .top, .foot, .viewer-bar, .quiz-card, .back { display: none; }
  body::before { display: none; }
}

/* ================================================================ quiz */
:root { --good-bg: #d8e2d3; --good-ink: #2e5429; --bad-bg: #ead3cb; --bad-ink: #7a3322; }
:root[data-theme="dark"] { --good-bg: #1f2b21; --good-ink: #a8cfa0; --bad-bg: #33211d; --bad-ink: #e3ab98; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --good-bg: #1f2b21; --good-ink: #a8cfa0; --bad-bg: #33211d; --bad-ink: #e3ab98; } }

.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--acc, var(--ink-2)); transition: width .25s; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.ghost { background: transparent; }
.btn .ico { width: 16px; height: 16px; }

/* Tarjeta del quiz en la página del examen */
.quiz-live { margin-top: 30px; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.quiz-live-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.quiz-live-head h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.quiz-live-head h2 .ico { width: 20px; height: 20px; color: var(--muted); }
.lvl-note, .lvl-warn { margin-top: 10px; font-size: .88rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.lvl-warn { color: var(--urgent-ink); }
.lvl-warn .ico { width: 16px; height: 16px; }
.levels button.on.lvl-btn-3 { background: var(--urgent-ink); color: var(--bg); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mode {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.mode:hover { background: var(--surface-2); border-color: var(--line-2); }
.mode-name { font-weight: 600; }
.mode-sub { font-size: .86rem; color: var(--muted); }
.mode .last { font-family: var(--mono); font-size: .76rem; color: var(--ink-2); margin-top: 2px; }
.mode-go { margin-top: auto; padding-top: 8px; display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; font-weight: 600; color: var(--ink); }
.mode-go .ico { width: 15px; height: 15px; }
@media (max-width: 560px) { .modes { grid-template-columns: 1fr; } }

/* Pantalla del quiz */
.quiz-page { --acc: hsl(var(--hue) 22% var(--acc-l)); max-width: 760px; margin: 0 auto; }
.quiz-head .back { margin-bottom: 10px; }
.quiz-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.quiz-title h1 { font-size: clamp(1.5rem, 4.4vw, 2rem); }
.lvl { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--ink-2); }
.lvl-3 { border-color: var(--urgent-ink); color: var(--urgent-ink); }
.quiz-progress { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; margin: 16px 0 14px; }
.qp-count { font-family: var(--mono); font-size: .84rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.q-card, .res-card { padding: 18px 20px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-num { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.peek { font-family: var(--mono); font-size: .72rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); cursor: pointer; }
.peek[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.q-prompt { margin: 6px 0 16px; }
.q-prompt p, .q-prompt .q-pair { font-size: 1.1rem; font-weight: 500; line-height: 1.45; }
.q-pair { display: block; }
.q-alt { display: block; margin-top: 4px; font-size: .88em; font-weight: 400; font-style: italic; color: var(--muted); }

.q-fig { margin: 0 0 16px; }
.q-fig.photo img { display: block; max-width: 100%; max-height: 300px; width: auto; height: auto; margin: 0 auto; border-radius: 8px; }
.q-fig figcaption { margin-top: 6px; text-align: center; font-size: .72rem; color: var(--muted); }
.diagram { --d-acc: hsl(var(--hue, 210) 38% calc(var(--acc-l) + 4%)); padding: 8px 0; }
.diagram svg { display: block; width: 100%; max-height: 280px; margin: 0 auto; }
.diagram .k { fill: none; stroke: var(--ink-2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.diagram .s { fill: var(--surface-2); stroke: var(--ink-2); stroke-width: 3; stroke-linejoin: round; }
.diagram .a { fill: none; stroke: var(--d-acc); stroke-width: 3.5; stroke-linecap: round; }
.diagram .af, .diagram .pk { fill: var(--d-acc); }
.diagram .d { opacity: .3; }
.diagram .hot { stroke: var(--d-acc); stroke-width: 7; stroke-linecap: round; }
.diagram .g { fill: none; stroke: var(--d-acc); stroke-width: 2.5; stroke-dasharray: 8 7; }
.diagram .t { font: 700 26px var(--mono); fill: var(--ink); }
.diagram .ti, .diagram .tp { font: 700 17px var(--mono); fill: var(--bg); }

.abcd { display: grid; gap: 10px; }
.abcd-opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  cursor: pointer; line-height: 1.4; transition: background-color .15s, border-color .15s, color .15s, opacity .25s;
}
.q-card:not(.revealed) .abcd-opt:hover { background: var(--surface-2); }
.abcd-opt.on { border-color: var(--ink-2); background: var(--surface-2); }
.abcd-key {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-top: -2px;
  border: 1px solid var(--line-2); border-radius: 7px; font-family: var(--mono); font-size: .85rem; font-weight: 600;
}
.abcd-opt.on .abcd-key { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.abcd-opt .q-alt { font-size: .85em; }

.quiz-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; }
.quiz-nav.end { margin-top: 24px; }
.quiz-nav:has(.q-dots) { flex-wrap: wrap; }
.q-dots { order: -1; flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-bottom: 4px; }
.dot { width: 11px; height: 11px; padding: 0; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; cursor: pointer; transition: background-color .25s, border-color .25s; }
.dot.done { background: var(--ink-2); border-color: var(--ink-2); }
.dot.good { background: var(--good-ink); border-color: var(--good-ink); }
.dot.bad { background: transparent; border: 3px solid var(--bad-ink); }
.dot.cur { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (max-width: 560px) {
  .q-dots { display: none; }
  .q-card, .res-card { padding: 16px; }
}
@media (pointer: coarse) { .dot { width: 14px; height: 14px; } }

.score { margin: 18px 0 22px; text-align: center; }
.score-big strong { font-family: var(--mono); font-size: clamp(3.2rem, 12vw, 4.4rem); font-weight: 600; line-height: 1; }
.score-big span { font-family: var(--mono); font-size: 1.6rem; color: var(--muted); }
.score p { margin: 8px 0 14px; color: var(--ink-2); }
.score .bar { max-width: 360px; margin: 0 auto; height: 6px; }
.score-done { font-size: 1.1rem; }

.res-list { display: grid; gap: 12px; }
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.res-head h2 { font-family: var(--mono); font-size: .8rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.res-card .q-prompt { margin-bottom: 12px; }
.res-line { display: grid; grid-template-columns: 9.5em 1fr; gap: 10px; align-items: baseline; padding: 8px 12px; border-radius: 8px; margin-top: 6px; }
.res-line.bad { background: var(--bad-bg); color: var(--bad-ink); }
.res-line.good { background: var(--good-bg); color: var(--good-ink); }
.res-line .q-alt { color: inherit; opacity: .8; }
.res-k { font-family: var(--mono); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.res-why { margin-top: 10px; font-size: .95rem; color: var(--ink-2); line-height: 1.5; }
.res-right { margin-top: 16px; }
.res-right summary { cursor: pointer; color: var(--ink-2); font-size: .92rem; }
.res-right ol { margin: 10px 0 0; padding-left: 0; list-style: none; display: grid; gap: 6px; font-size: .9rem; color: var(--ink-2); }
.res-ok { color: var(--good-ink); }
.all-right { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--good-ink); font-weight: 600; margin: 10px 0; }
.all-right .ico { width: 20px; height: 20px; }
@media (max-width: 560px) { .res-line { grid-template-columns: 1fr; gap: 2px; } }

.dev-text {
  width: 100%; min-height: 120px; resize: vertical; padding: 12px 14px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--ink);
  font: inherit; line-height: 1.5;
}
.dev-text:focus { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.dev-compare { display: grid; gap: 10px; }
.dev-box { padding: 12px 14px; border-radius: 10px; margin-top: 8px; }
.dev-box.yours { border: 1px dashed var(--line-2); }
.dev-box.model { background: var(--good-bg); color: var(--good-ink); }
.dev-box .res-k { display: block; margin-bottom: 4px; }
.dev-box p { line-height: 1.5; }
.dev-yours { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ------------------------------------ corrección: al final / al momento */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Tarjeta del examen: selector del modo */
.fb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.fb-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fb-modes button { display: inline-flex; align-items: center; gap: 6px; }
.fb-modes .ico { width: 14px; height: 14px; }
.mode-fb { color: var(--ink-2); }
.lvl-mode { border-style: dashed; }

/* Marcador en vivo (modo al momento) */
.quiz-progress.with-tally { grid-template-columns: auto 1fr auto; }
.qp-tally { display: inline-flex; gap: 10px; font-family: var(--mono); font-size: .84rem; font-variant-numeric: tabular-nums; }
.qp-tally > span:not(.sr-only) { display: inline-flex; align-items: center; gap: 2px; }
.qp-tally .ico { width: 14px; height: 14px; }
.qp-tally .ico svg, .abcd-mark svg, .qf-head .ico svg, .all-right .ico svg { stroke-width: 2.4; }
.qp-tally .good { color: var(--good-ink); }
.qp-tally .bad { color: var(--bad-ink); }

/* Opciones corregidas: la buena en verde, la elegida mal en rojo, el resto apagado */
.q-card.revealed .abcd-opt { cursor: default; }
.abcd-mark { flex: none; width: 20px; height: 20px; margin: 1px 0 0 auto; }
.abcd-opt.is-right { background: var(--good-bg); border-color: var(--good-ink); color: var(--good-ink); }
.abcd-opt.is-right .abcd-key { background: var(--good-ink); border-color: var(--good-ink); color: var(--good-bg); }
.abcd-opt.is-wrong { background: var(--bad-bg); border-color: var(--bad-ink); color: var(--bad-ink); }
.abcd-opt.is-wrong .abcd-key { background: var(--bad-ink); border-color: var(--bad-ink); color: var(--bad-bg); }
.abcd-opt.is-right .q-alt, .abcd-opt.is-wrong .q-alt { color: inherit; opacity: .9; }
/* Apagadas con color, no con opacidad: se siguen leyendo (≥4,5:1). */
.abcd-opt.is-dim { color: var(--muted); }
.abcd-opt.is-dim .abcd-key { color: var(--muted); border-color: var(--line); }

/* Veredicto y explicación */
.q-feedback { margin-top: 14px; padding: 12px 14px; border-radius: 10px; }
.q-feedback.good { background: var(--good-bg); color: var(--good-ink); }
.q-feedback.bad { background: var(--bad-bg); color: var(--bad-ink); }
.qf-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qf-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.qf-head .ico { width: 20px; height: 20px; flex: none; }
.qf-toggle {
  display: inline-flex; align-items: center; gap: 4px; flex: none; cursor: pointer;
  font: inherit; font-size: .84rem; color: inherit; background: transparent;
  border: 1px solid currentColor; border-radius: 999px; padding: 3px 8px 3px 11px;
}
.qf-toggle .ico { width: 14px; height: 14px; transition: transform .25s; }
.qf-toggle[aria-expanded="true"] .ico { transform: rotate(180deg); }
.qf-why { display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden; transition: grid-template-rows .3s ease, opacity .3s ease, visibility 0s linear .3s; }
.qf-why.open { grid-template-rows: 1fr; opacity: 1; visibility: visible; transition-delay: 0s; }
.qf-why-in { overflow: hidden; min-height: 0; }
.q-feedback .res-why { margin-top: 8px; color: var(--ink); }
.q-feedback .q-alt { color: var(--ink-2); }
@media (pointer: coarse) { .qf-toggle { min-height: 36px; } }

/* Animaciones, solo al corregir (no al volver a una pregunta ni al cambiar de idioma) */
.q-card.fresh .abcd-opt.picked { animation: q-fill .18s ease-out, q-pop .42s cubic-bezier(.2, .9, .3, 1.3); }
.q-card.fresh .abcd-opt.is-wrong { animation: q-fill .18s ease-out, q-shake .42s cubic-bezier(.36, .07, .19, .97); }
.q-card.fresh .abcd-opt.reveal { animation: q-fill .45s .24s ease-out both, q-pop .42s .24s cubic-bezier(.2, .9, .3, 1.3); }
.q-card.fresh .abcd-opt.reveal .abcd-key { animation: q-key .45s .24s ease-out both; }
.q-card.fresh .abcd-opt.is-dim { animation: q-dim .35s ease-out; }
.q-card.fresh .abcd-mark { animation: q-mark .34s .1s cubic-bezier(.2, .9, .3, 1.4) both; }
.q-card.fresh .abcd-opt.reveal .abcd-mark { animation-delay: .4s; }
.q-card.fresh .abcd-mark path { stroke-dasharray: 1; animation: q-draw .32s .16s ease-out both; }
.q-card.fresh .abcd-opt.reveal .abcd-mark path { animation-delay: .46s; }
.q-feedback.fresh { animation: q-drop .36s .14s cubic-bezier(.2, .8, .2, 1) both; }
.q-feedback.fresh.bad .qf-why.open { animation: q-grow .42s .26s ease-out both; }
.q-feedback.fresh .qf-head .ico path { stroke-dasharray: 1; animation: q-draw .32s .3s ease-out both; }
.dot.fresh { animation: q-dot .42s cubic-bezier(.2, .9, .3, 1.5); }
.btn.primary.go .ico { animation: q-nudge .8s .7s ease-in-out 2; }

/* Pasar de pregunta: entra desde el lado hacia el que se va */
.q-card.enter-fwd { animation: q-in-fwd .28s cubic-bezier(.2, .8, .2, 1); }
.q-card.enter-back { animation: q-in-back .28s cubic-bezier(.2, .8, .2, 1); }

/* Resultados y respuestas modelo */
.score.anim .score-big { animation: q-rise .4s ease-out both; }
.score.anim .bar-fill { animation: q-bar .8s .12s cubic-bezier(.2, .8, .2, 1) both; }
.res-list.anim .res-head { animation: q-rise .4s .2s ease-out both; }
.res-list.anim .res-card { animation: q-rise .4s ease-out both; animation-delay: calc(.28s + var(--i, 0) * 60ms); }
.all-right.anim { animation: q-pop-in .5s .3s cubic-bezier(.2, .9, .3, 1.4) both; }
.dev-compare.fresh .dev-box { animation: q-rise .36s ease-out both; }
.dev-compare.fresh .dev-box.model { animation-delay: .12s; }

@keyframes q-fill { from { background-color: var(--bg); border-color: var(--line); color: var(--ink); } }
@keyframes q-key { from { background-color: transparent; border-color: var(--line-2); color: var(--ink); } }
@keyframes q-pop { 40% { transform: scale(1.018); } }
@keyframes q-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes q-dim { from { color: var(--ink); } }
@keyframes q-mark { from { opacity: 0; transform: scale(.4) rotate(-25deg); } }
@keyframes q-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes q-drop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes q-grow { from { grid-template-rows: 0fr; opacity: 0; } }
@keyframes q-dot { 50% { transform: scale(1.6); } }
@keyframes q-nudge { 50% { transform: translateX(3px); } }
@keyframes q-in-fwd { from { opacity: 0; transform: translateX(18px); } }
@keyframes q-in-back { from { opacity: 0; transform: translateX(-18px); } }
@keyframes q-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes q-bar { from { width: 0; } }
@keyframes q-pop-in { from { opacity: 0; transform: scale(.9); } }

/* ================================================= ikasgaiak eta apunteak */
.visually-hidden, .hp { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn-sm { padding: 6px 12px; font-size: .86rem; }
.btn-sm .ico { width: 15px; height: 15px; }

/* Menú: sección Ikasgaiak */
.subjects { margin-top: 44px; }
.subjects-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subjects-head h2 { font-family: var(--mono); font-size: .78rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.subjects-lead { margin-top: 6px; font-size: .92rem; }
.subjects .exam-list { margin-top: 14px; }
.subj-code {
  display: inline-block; margin-right: 8px; padding: 1px 7px; border-radius: 6px; vertical-align: 2px;
  font-family: var(--mono); font-size: .72em; font-weight: 600; letter-spacing: .02em;
  color: hsl(var(--hue) 20% var(--acc-ink-l)); border: 1px solid color-mix(in srgb, var(--acc) 45%, transparent);
}
/* Texto del código de asignatura: más oscuro que --acc para llegar a 4,5:1. */
:root { --acc-ink-l: 32%; }
:root[data-theme="dark"] { --acc-ink-l: 64%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --acc-ink-l: 64%; } }
.exam-head h1 .subj-code { font-size: .5em; vertical-align: 6px; }

/* Página de la asignatura */
.subject-page { --acc: hsl(var(--hue) 20% var(--acc-l)); }
.subject-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; }
.subject-page .exam-list { margin-top: 14px; }
.subject-page .section-h + .muted { margin-top: 12px; }
.subject-page .subject-done { margin-top: 22px; }
.subject-page .subject-done .exam-list { margin-top: 10px; }

/* Tarjetas de apuntes de la clase */
.cnote-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.cnote {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 18px; align-items: center; gap: 16px;
  padding: 12px 16px 12px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: inherit; transition: background-color .15s, border-color .15s;
}
.cnote:hover { background: var(--surface-2); border-color: var(--line-2); }
.cnote-thumbs { display: flex; gap: 4px; }
.cnote-thumbs img, .cnote-nothumb { width: 46px; height: 60px; object-fit: cover; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.cnote-thumbs img:nth-child(n+3) { display: none; }
.cnote-nothumb { display: grid; place-items: center; color: var(--muted); }
.cnote-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cnote-title { font-weight: 600; overflow-wrap: anywhere; }
.cnote-by { font-size: .86rem; color: var(--muted); }
.cnote-what { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
@media (min-width: 561px) { .cnote-thumbs img:nth-child(n+3) { display: block; } }

/* Página de unos apuntes */
.note-page { --acc: hsl(var(--hue) 20% var(--acc-l)); }
.cn-files { display: grid; gap: 22px; margin-top: 26px; }
.cn-img { margin: 0; }
/* Tamaño natural como máximo: una captura pequeña no se amplía ni se pixela. */
.cn-img img { display: block; max-width: 100%; width: auto; height: auto; margin-inline: auto; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.cn-img figcaption { margin-top: 6px; text-align: center; font-family: var(--mono); font-size: .76rem; color: var(--muted); }
/* Los PDF se leen con el visor de los exámenes, a todo el ancho. */
.note-page > .viewer { margin-top: 26px; }
.note-page > .viewer + .viewer { margin-top: 8px; }

/* Tarjeta "Klaseko apunteak" en la página del examen */
.cnotes-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 14px;
  margin-top: 14px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.cnotes-card .quiz-ico { color: var(--muted); }
.cnotes-card h2 { font-size: 1.02rem; }
.cnotes-card p { font-size: .9rem; color: var(--muted); margin-top: 2px; }
.cnotes-btns { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 560px) {
  .cnotes-card { grid-template-columns: auto minmax(0, 1fr); }
  .cnotes-btns { grid-column: 1 / -1; }
  .cnotes-btns .btn { flex: 1; justify-content: center; }
}

/* Formulario de subida */
.upload-page .page-head { margin-top: 8px; }
.up-form { display: grid; gap: 20px; margin-top: 26px; }
.up-field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.up-field > label, .up-field > legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: 6px; }
.up-field input[type=text], .up-field select, .up-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.up-field input[type=text]:focus, .up-field select:focus, .up-field textarea:focus { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.up-field textarea { resize: vertical; min-height: 104px; line-height: 1.5; }
.up-desc-hint { display: flex; justify-content: space-between; gap: 12px; }
.up-desc-count.over { color: var(--bad-ink); font-weight: 600; }

/* Editor con formato de la descripción */
/* min-width:0: un código o una tabla anchos hacen scroll DENTRO del editor, no ensanchan la página. */
.rt-wrap { min-width: 0; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); }
.rt-wrap:focus-within { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.rt-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); }
.rt-btn {
  display: inline-grid; place-items: center; min-width: 34px; height: 32px; padding: 0 6px;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font: 600 .84rem/1 var(--mono); cursor: pointer;
}
.rt-btn:hover { background: var(--surface-2); }
.rt-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.rt-btn:disabled { opacity: .5; cursor: default; }
.rt-btn .ico { width: 18px; height: 18px; }
.rt-b span { font-family: inherit; font-weight: 800; }
.rt-i span { font-style: italic; font-family: Georgia, serif; font-weight: 400; font-size: .98rem; }
.rt-x { margin-left: auto; }
@media (pointer: coarse) { .rt-btn { min-width: 40px; height: 40px; } }
.rt-edit {
  position: relative; min-height: 140px; max-height: 60vh; overflow: auto; padding: 10px 12px;
  color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; outline: none; cursor: text;
}
/* «/ ""»: el marcador no es contenido para los lectores de pantalla (va en aria-placeholder). */
.rt-edit.rt-empty::before { content: attr(data-ph); content: attr(data-ph) / ""; position: absolute; inset: 10px 12px auto; color: var(--muted); pointer-events: none; }
.rt-edit[aria-disabled="true"] { opacity: .6; }

/* Texto con formato (descripción de unos apuntes y el editor) */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md .md-table, .md hr { margin: 0 0 .7em; }
.md h2, .md h3, .md h4, .md h5 { line-height: 1.25; margin: 1.1em 0 .45em; color: var(--ink); overflow-wrap: anywhere; }
.md h2 { font-size: 1.45rem; }
.md h3 { font-size: 1.22rem; }
.md h4 { font-size: 1.06rem; }
.md h5 { font-size: .95rem; text-transform: none; color: var(--ink-2); }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: .18em 0; }
.md li > ul, .md li > ol { margin: .18em 0 .1em; }
.md blockquote { padding: .2em 0 .2em 1em; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.md code { font-family: var(--mono); font-size: .88em; padding: .1em .35em; border-radius: 5px; background: var(--surface-2); }
.md pre { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); overflow-x: auto; white-space: pre; tab-size: 4; }
.md pre code { padding: 0; background: none; font-size: .86rem; }
.md hr { border: 0; border-top: 1px solid var(--line-2); }
.md .md-table { overflow-x: auto; }
.md table { border-collapse: collapse; font-size: .92rem; min-width: 50%; }
/* Palabras enteras en las celdas: si no caben, la tabla hace scroll (.md-table). */
.md th, .md td { padding: 6px 10px; border: 1px solid var(--line-2); text-align: left; vertical-align: top; overflow-wrap: normal; word-break: normal; }
.md th { background: var(--surface-2); font-weight: 600; }
.rt-edit h3, .rt-edit h4, .rt-edit h2, .rt-edit h5 { margin: .8em 0 .35em; line-height: 1.25; }
.rt-edit h2 { font-size: 1.35rem; }
.rt-edit h3 { font-size: 1.18rem; }
.rt-edit h4 { font-size: 1.04rem; }
.rt-edit h5 { font-size: .95rem; }
.rt-edit p, .rt-edit ul, .rt-edit ol, .rt-edit pre, .rt-edit blockquote { margin: 0 0 .5em; }
.rt-edit ul, .rt-edit ol { padding-left: 1.5em; }
.rt-edit pre { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); overflow-x: auto; white-space: pre; tab-size: 4; }
.rt-edit .md-table { overflow-x: auto; }
.rt-edit code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border-radius: 4px; padding: .05em .3em; }
.rt-edit blockquote { padding-left: .9em; border-left: 3px solid var(--line-2); }
.rt-edit table { border-collapse: collapse; }
.rt-edit th, .rt-edit td { padding: 4px 8px; border: 1px solid var(--line-2); overflow-wrap: normal; word-break: normal; }
.up-desc-count { font-family: var(--mono); font-size: .78rem; font-variant-numeric: tabular-nums; }
/* Descripción de unos apuntes: texto plano con sus saltos de línea. */
.cn-desc { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.cn-desc.md { white-space: normal; padding: 16px 18px; }
.cnote-desc { font-size: .88rem; color: var(--ink-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
/* Desplegable con flecha propia: la nativa de Chrome en Windows se pone
   blanca con borde azul al pasar el ratón y no sigue el tema. */
.up-field select { appearance: none; -webkit-appearance: none; padding-right: 42px; cursor: pointer; transition: border-color .15s; }
.up-field select:hover:not(:disabled) { border-color: var(--ink-2); }
.up-select { position: relative; display: block; }
.up-select::after {
  content: ""; position: absolute; top: 50%; right: 14px; width: 16px; height: 16px; margin-top: -8px; pointer-events: none;
  background-color: var(--ink-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 9.5 12 16l6.5-6.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 9.5 12 16l6.5-6.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.up-select:has(select:disabled)::after { opacity: .5; }
.up-field input:disabled, .up-field select:disabled, .up-field textarea:disabled { opacity: .6; }
.up-hint { font-size: .84rem; }
.up-drop {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 16px;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: var(--surface); text-align: center;
  transition: background-color .15s, border-color .15s;
}
.up-drop.over { background: var(--surface-2); border-color: var(--ink-2); }
.up-drop-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.up-drop .muted { font-size: .86rem; }
@media (pointer: fine) { .up-cam { display: none; } }
.up-limits { font-size: .82rem; margin-top: 6px; }
.up-grid { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.up-grid:empty { display: none; }
.up-item { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; animation: q-rise .25s ease-out both; }
.up-item img, .up-pdf { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.up-pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.up-name { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-item.bad img, .up-item.bad .up-pdf { border-color: var(--bad-ink); outline: 2px solid var(--bad-ink); }
.up-field .up-msg { margin-top: 4px; }
.up-rm { position: absolute; top: 5px; right: 5px; width: 30px; height: 30px; background: var(--bg); }
.up-rm .ico { width: 16px; height: 16px; }
.up-count { font-family: var(--mono); font-size: .8rem; }
.up-rules { display: flex; gap: 8px; align-items: flex-start; font-size: .86rem; color: var(--muted); }
.up-rules .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.up-msg { padding: 10px 14px; border-radius: 10px; background: var(--bad-bg); color: var(--bad-ink); font-size: .92rem; }
.up-closed { margin-top: 22px; padding: 12px 16px; border-radius: 10px; background: var(--urgent-bg); color: var(--urgent-ink); }
.up-progress { display: grid; gap: 8px; }
.up-progress[hidden] { display: none; }
.up-phase { font-family: var(--mono); font-size: .84rem; color: var(--ink-2); }
.up-progress .bar { height: 6px; }
.up-actions { display: flex; justify-content: flex-end; }
.up-done { margin-top: 30px; padding: 28px 20px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); animation: q-pop-in .45s cubic-bezier(.2, .9, .3, 1.3) both; }
.up-done h2 { font-size: 1.4rem; margin-top: 10px; }
.up-done h2:focus { outline: none; }
.up-done p { color: var(--ink-2); margin-top: 6px; }
.up-done-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--good-bg); color: var(--good-ink); }
.up-done-ico .ico { width: 26px; height: 26px; }
.up-done-ico .ico svg { stroke-width: 2.4; }
.up-done-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

/* ------------------------------------------- avisar de un problema (arazoak.js) */
.report-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 14px;
  margin-top: 14px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.report-card .quiz-ico { color: var(--muted); }
.report-card h2 { font-size: 1.02rem; }
.report-card p { font-size: .9rem; color: var(--muted); margin-top: 2px; }
.report-btns { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 560px) {
  .report-card { grid-template-columns: auto minmax(0, 1fr); }
  .report-btns { grid-column: 1 / -1; }
  .report-btns .btn { flex: 1; justify-content: center; }
}
/* En cada pregunta: el número a la izquierda; «ikusi» y la bandera, a la derecha. */
.q-top .q-num { margin-right: auto; }
.q-report { width: 32px; height: 32px; border-radius: 8px; color: var(--muted); background: transparent; border-color: transparent; }
.q-report .ico { width: 16px; height: 16px; }
/* En pantallas táctiles, objetivo de 44 px sin que crezca la fila. */
@media (pointer: coarse) { .q-report { width: 44px; height: 44px; margin: -6px -6px -6px 0; } }

dialog.rp {
  width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  margin: auto; padding: 18px 20px 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
dialog.rp::backdrop { background: rgb(0 0 0 / .38); }
dialog.rp[open] { animation: q-pop-in .22s cubic-bezier(.2, .9, .3, 1.2); }
.rp-form { display: grid; gap: 16px; margin-top: 12px; }
.rp-intro { color: var(--ink-2); font-size: .94rem; }
.rp-sev-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rp-sev {
  --sev: var(--line-2);
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--line); border-left: 4px solid var(--sev); border-radius: 10px; background: var(--surface);
}
.rp-sev.sev-txikia { --sev: #4a7fd6; }
.rp-sev.sev-ertaina { --sev: #d99a00; }
.rp-sev.sev-larria { --sev: #c62828; }
.rp-sev input { margin: 3px 0 0; accent-color: var(--ink); flex: none; }
.rp-sev:has(input:checked) { border-color: var(--sev); box-shadow: inset 0 0 0 1px var(--sev); background: var(--surface-2); }
.rp-sev:has(input:focus-visible) { outline: 2px solid var(--ink-2); outline-offset: 2px; }
.rp-sev:has(input:disabled) { opacity: .6; cursor: default; }
.rp-sevs[aria-invalid="true"] .rp-sev { border-top-color: var(--bad-ink); border-right-color: var(--bad-ink); border-bottom-color: var(--bad-ink); }
.rp-sev-txt { display: grid; gap: 2px; min-width: 0; }
.rp-sev-name { font-weight: 600; font-size: .95rem; }
.rp-sev-sub { font-size: .8rem; color: var(--muted); line-height: 1.3; }
.rp-ctx[hidden] { display: none; }
.rp-photo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-form .up-closed { margin-top: 0; }
.rp-done { margin-top: 14px; }
@media (max-width: 520px) {
  .rp-sev-row { grid-template-columns: 1fr; }
  dialog.rp { width: calc(100% - 16px); padding-inline: 14px; }
}

/* ------------------------------------------------ reading (comprensión lectora) */
.mode-reading { grid-column: 1 / -1; }
.rd-text { margin-top: 16px; padding: 20px 22px; border: 1px solid var(--line); border-left: 4px solid var(--ink-2); border-radius: var(--radius); background: var(--surface); }
.rd-text h2 { font-size: 1.2rem; margin-bottom: 10px; }
.rd-text p { font-size: 1.04rem; line-height: 1.65; }
.rd-text p + p { margin-top: .75em; }
.rd-label { text-align: center; }
.ram-stick { position: relative; margin: 14px auto 6px; max-width: 560px; padding: 22px 12px 34px; border-radius: 10px 10px 5px 5px; background: #3e8a4f; display: flex; justify-content: center; }
.ram-stick::after { content: ""; position: absolute; left: 4%; right: 4%; bottom: 8px; height: 14px; border-radius: 2px; background: repeating-linear-gradient(90deg, #d9b44a 0 6px, #3e8a4f 6px 8px); }
.ram-sticker { background: #fff; color: #15171a; border-radius: 5px; padding: 10px 16px; font: 700 clamp(1.05rem, 4.6vw, 1.75rem)/1.2 ui-monospace, "JetBrains Mono", Consolas, monospace; letter-spacing: .04em; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); overflow-wrap: anywhere; }
.rd-hint { color: var(--ink-2); font-size: .95rem; }
.rd-qh { font-size: 1.05rem; margin: 22px 0 10px; }
.rd-qs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rd-q .q-prompt { margin: 6px 0 12px; font-size: 1.05rem; font-weight: 500; line-height: 1.45; }
.rd-q .q-card.rd-good { border-color: var(--good-ink); }
.rd-q .q-card.rd-bad { border-color: var(--bad-ink); }
.rd-q .res-why { margin-top: 12px; }
.rd-score { margin-top: 18px; }
