/* player.css — visor StoryFlow: novela visual ilustrada, tinta oscura y oro. */

:root {
  /* Tiempos de la transición de escena (stage.js usa los mismos en sceneTimeline) */
  --t-text-out: 150ms; --t-sprite-out: 350ms; --t-bg: 1200ms; --t-sprite-in: 500ms; --t-text-in: 200ms;
  --t-move: 450ms; /* escenografía: cambio de sitio, atenuado y plano */
  --ink: #0b0a10;
  --ink-2: #14121b;
  --ink-3: #1d1a27;
  --ink-4: #272334;
  --line: rgba(255, 215, 0, 0.16);
  --line-strong: rgba(255, 215, 0, 0.45);
  --gold: #ffd700;
  --gold-2: #c9a227;
  --gold-3: #7a6220;
  --paper: #efe6d2;
  --paper-2: #c9c0ae;
  --paper-dim: #8f887a;
  --red: #e0564a;
  --green: #79c98f;
  --blue: #7fb2e5;
  --f-display: "Constantia", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --f-ui: "Candara", "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
  --f-mono: "Cascadia Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --topbar-h: 52px;
  --panel-w: 360px;
  --radius: 6px;
  --checker: conic-gradient(#2b2838 25%, #1a1824 0 50%, #2b2838 0 75%, #1a1824 0) 0 0 / 22px 22px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { height: 100dvh; }                        /* no 100vh: Safari mueve la barra */
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --bar-h: 56px;
}
.sm { display: none !important; }               /* solo < 1024 px */
body::before {
  /* grano sutil */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.045;
  background-image:
    repeating-radial-gradient(circle at 17% 23%, #fff 0 0.6px, transparent 0.6px 3px),
    repeating-radial-gradient(circle at 71% 64%, #fff 0 0.5px, transparent 0.5px 4px);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.08s;
}
button:hover { border-color: var(--line-strong); background: var(--ink-4); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
button.is-active { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 600; }
button.ghost { background: transparent; }
button.danger:hover { border-color: var(--red); color: var(--red); }
button.round { width: 32px; height: 32px; padding: 0; border-radius: 50%; }
kbd {
  font-family: var(--f-mono);
  font-size: 0.78em;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--gold);
  margin-right: 6px;
  vertical-align: 1px;
}
button.is-active kbd { color: var(--ink); border-color: rgba(0, 0, 0, 0.4); background: rgba(255, 255, 255, 0.35); }
code { font-family: var(--f-mono); font-size: 0.85em; color: var(--paper-2); }
small { color: var(--paper-dim); }
.muted { color: var(--paper-dim); }
input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.12); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 5px; border: 2px solid var(--ink); }
::-webkit-scrollbar-track { background: transparent; }

/* ================================================================
   Cabecera
   ================================================================ */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-auto-flow: column;
  grid-auto-columns: auto;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: linear-gradient(180deg, #16131f, #0f0d16);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.topbar-main { display: flex; align-items: center; gap: 18px; min-width: 0; }
.regen-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 0.8em; color: var(--gold-2);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.regen-pill.is-running svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.regen-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--ink-4); z-index: 2; }
.regen-bar b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width 0.4s; }
.regen-bar.is-indeterminate b { width: 30% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: 0; } 50% { margin-left: 70%; } 100% { margin-left: 0; } }
.mode-switch .badge { margin-left: 4px; vertical-align: 1px; }
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-2) 30%, var(--gold) 50%, var(--gold-2) 70%, transparent);
  opacity: 0.6;
}
.topbar-back {
  color: var(--paper-2);
  text-decoration: none;
  font-size: 0.9em;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.topbar-back:hover { color: var(--gold); }
.topbar-title {
  font-family: var(--f-display);
  font-size: 1.15em;
  color: var(--gold);
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumbs { display: flex; gap: 4px; min-width: 0; overflow: hidden; align-items: center; }
.crumb {
  display: inline-flex;
  flex-direction: column;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  line-height: 1.15;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9em;
  color: var(--paper-2);
}
.crumb:first-child { border-left: 0; padding-left: 0; }
.crumb small { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold-3); }
.mode-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--ink); }
.mode-switch button { border: 0; border-radius: 999px; padding: 4px 16px; background: transparent; font-size: 0.9em; letter-spacing: 0.04em; }
.mode-switch button.is-active { background: var(--gold); color: var(--ink); }
.topbar-tools { display: flex; align-items: center; gap: 10px; font-size: 0.85em; }
.conn { display: inline-flex; align-items: center; gap: 6px; color: var(--paper-dim); white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--paper-dim); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06); }
.conn.is-online i { background: var(--green); box-shadow: 0 0 10px var(--green); }
.conn.is-offline i { background: var(--red); }
.user { color: var(--gold-2); font-family: var(--f-mono); font-size: 0.9em; }

/* ================================================================
   Vistas
   ================================================================ */
#main { flex: 1 1 auto; min-height: 0; position: relative; }
.view { height: 100%; }
.view[hidden] { display: none; }
.view-read { display: flex; flex-direction: column; }
.view-read-body { display: flex; flex: 1 1 auto; min-height: 0; }
.bottombar { display: none; }
.chrome-toggle, .landscape-crumb { display: none; }

/* ---------- Escenario ---------- */
.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #1c1826 0%, var(--ink) 70%);
}
.stage .bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--t-bg) ease-in-out;
}
.stage .bg.is-front { opacity: 1; }
/* Revisión (ni lector ni modo lectura): el fondo conserva el fundido corto de siempre */
body:not([data-reader="1"]):not([data-mode="read"]) .stage .bg { transition-duration: 0.6s; }
/* Salto de transición: el estado final aparece de golpe */
.stage.is-skipping .bg, .stage.is-skipping .character, .stage.is-skipping .dialogue,
.stage.is-skipping .vignette::after { transition-duration: 0ms !important; }
.stage .vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 20%, transparent 70%, rgba(0, 0, 0, 0.6));
}
.characters { position: absolute; inset: 0; pointer-events: none; }
.character {
  position: absolute;
  bottom: 0;
  max-height: 88%;
  max-width: 60%;
  object-fit: contain;
  /* Sitio y plano por variables: moverse, atenuarse o acercarse anima left/transform/filter (--t-move), no recrea el sprite */
  --x: 50%; --ty: 16px; --ex: 0px; --s: 1; --crop: 0%;
  left: var(--x);
  transform-origin: 50% 100%;
  transform: translate(calc(-50% + var(--ex)), calc(var(--ty) + var(--crop))) scale(var(--s));
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6));
  opacity: 0;
  transition: opacity var(--t-sprite-in) ease, transform var(--t-move) ease-in-out, left var(--t-move) ease-in-out, filter var(--t-move) ease-in-out;
}
.character.is-in, .character.is-swap, .character.is-out { --ty: 0px; }
.character.is-in { opacity: 1; }
.character.is-out { opacity: 0; transition: opacity var(--t-sprite-out) ease; }
/* Misma persona con otra emoción: solo fundido, sin desplazamiento */
.character.is-swap { transition: opacity 0.35s ease, transform var(--t-move) ease-in-out, left var(--t-move) ease-in-out, filter var(--t-move) ease-in-out; }
.character.pos-left { --x: 27%; }
.character.pos-center { --x: 50%; }
.character.pos-right { --x: 73%; }
/* Quien calla: atenuado y un poco más bajo */
.character.is-dim { --s: 0.96; filter: brightness(0.6) saturate(0.8) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6)); }
/* Primer plano en emoción intensa: más grande y recortado por abajo (el 6 % inferior queda fuera o bajo la caja) */
.character.scale-up { --s: 1.08; --crop: 6%; }
/* Entrada lateral la primera vez en la escena: desliza desde su borde (500 ms) */
.character.enter-side { transition: opacity var(--t-sprite-in) ease, transform var(--t-sprite-in) ease-out, left var(--t-move) ease-in-out, filter var(--t-move) ease-in-out; }
.character.enter-side:not(.is-in) { --ex: -60vw; }
.character.enter-side.pos-right:not(.is-in) { --ex: 60vw; }
.character-missing {
  opacity: 1;
  --ty: 0px; --s: 1; --crop: 0%;
  bottom: 30%;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--gold-2);
  font-family: var(--f-mono);
  font-size: 0.8em;
  background: rgba(0, 0, 0, 0.5);
}

/* ---------- Diálogo ---------- */
.dialogue {
  position: absolute;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  width: min(92%, 960px);
  cursor: pointer;
  z-index: 5;
  transition: opacity var(--t-text-in) ease;
}
.stage.is-transitioning .dialogue:not(.is-shown) { opacity: 0; transition: opacity var(--t-text-out) ease; } /* sin pointer-events:none: un clic sobre la caja oculta salta la transición */
/* Tarjeta de capítulo: cubre el escenario mientras cambia de capítulo */
.chapter-card {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: #000; color: var(--paper, #f3ead8);
  font-family: var(--reader-font, Georgia, serif); font-size: clamp(1.4rem, 5vw, 2.4rem);
  text-align: center; padding: 0 16px;
  opacity: 0; transition: opacity 300ms ease; pointer-events: none;
}
.chapter-card[hidden] { display: none; }
.chapter-card.is-in { opacity: 1; }
/* Modo NVL: narración larga en una caja alta (60 % del escenario) sobre el fondo oscurecido al 35 % */
.stage .vignette::after { content: ""; position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity var(--t-bg) ease-in-out; }
.stage.nvl .vignette::after { opacity: 0.65; }
.stage.nvl .text { max-height: calc(var(--nvl-lines, 12) * var(--fs-text) * var(--lh-text)); }
/* Cámara: zoom y deriva lentos del fondo estático en escenas largas (nunca sobre el clip de vídeo) */
@keyframes cam-drift {
  from { transform: scale(1) translateX(0); }
  to { transform: scale(var(--cam-zoom, 1.03)) translateX(var(--cam-dx, 1%)); }
}
.stage.cam-drift .bg:not(.bg-video) { animation: cam-drift 30s ease-in-out infinite alternate; }
.dialogue-frame {
  position: relative;
  background: linear-gradient(180deg, rgba(14, 12, 20, 0.92), rgba(8, 7, 12, 0.94));
  border: 1px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(10, 9, 14, 0.9), 0 0 0 5px var(--gold-3), var(--shadow);
  padding: 22px 30px 20px;
  border-radius: 4px;
}
.dialogue-frame::before,
.dialogue-frame::after {
  content: "❧";
  position: absolute;
  top: -13px;
  color: var(--gold);
  background: var(--ink);
  padding: 0 6px;
  font-size: 15px;
  line-height: 1;
}
.dialogue-frame::before { left: 18px; }
.dialogue-frame::after { right: 18px; transform: scaleX(-1); }
.speaker {
  font-family: var(--f-display);
  color: var(--gold);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.stage.is-narrator .speaker { display: none; }
.stage.is-narrator .dialogue-text, .stage.is-narrator .text { font-style: italic; }
.text {
  font-family: var(--f-display);
  color: #fff;
  min-height: 1.6em;
}
.stage.is-narrator .text { color: var(--paper); }
.hint { margin-top: 8px; font-size: 0.78em; color: var(--paper-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.hint:empty { display: none; }

/* Lectura: tamaño y líneas fijas. La reserva del sprite se calcula con estas variables, no con el texto visible. */
.stage {
  --fs-text: calc(17.7px * var(--reader-scale, 1));   /* 1.18em sobre 15px */
  --fs-speaker: calc(19.5px * var(--reader-scale, 1)); /* 1.3em sobre 15px */
  --lh-text: var(--reader-lh, 1.6);
  --dlg-lines: 6;
  --dlg-pad: 42px;           /* padding vertical del marco */
  --dlg-bottom: 36px;
  --dlg-reserve: calc(var(--dlg-bottom) + var(--dlg-pad) + var(--fs-speaker) * 1.3 + 8px + var(--dlg-lines) * var(--fs-text) * var(--lh-text) + 18px);
}
.speaker { font-size: var(--fs-speaker); }
.text {
  font-size: var(--fs-text);
  line-height: var(--lh-text);
  max-height: calc(var(--dlg-lines) * var(--fs-text) * var(--lh-text));
  overflow: hidden;
}
.text-measure { position: absolute; visibility: hidden; pointer-events: none; left: 0; top: 0; max-height: none !important; overflow: visible !important; }
.pager { position: absolute; right: 12px; bottom: 6px; font-family: var(--f-mono); font-size: 11px; color: var(--paper-dim); letter-spacing: 0.06em; }
.pager:empty { display: none; }

.controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
  z-index: 6;
}
.controls button { background: rgba(10, 9, 14, 0.75); backdrop-filter: blur(6px); padding: 6px 11px; }
.controls .panel-toggle { margin-left: 8px; }
.controls .panel-toggle kbd { margin: 0 0 0 6px; }

.debug {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 6;
  margin: 0;
  padding: 10px 12px;
  max-width: min(560px, 60%);
  font-family: var(--f-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: #9fe8a5;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid rgba(159, 232, 165, 0.4);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- Panel de feedback ---------- */
.fb-panel {
  width: 0;
  flex: 0 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border-left: 1px solid transparent;
  transition: width 0.25s ease, border-color 0.25s;
  display: flex;
  flex-direction: column;
}
.fb-panel.is-open { width: var(--panel-w); border-left-color: var(--line); }
.fb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
  min-width: var(--panel-w);
}
.fb-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.1em; color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; }
.fb-head button { padding: 2px 9px; }
.fb-body { padding: 14px 16px 24px; overflow: auto; min-width: var(--panel-w); flex: 1; }
.fb-empty { color: var(--paper-dim); font-style: italic; }
.fb-kind { font-size: 0.72em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-3); }
.fb-title { margin: 2px 0 4px; font-family: var(--f-display); font-weight: 400; font-size: 1.35em; color: var(--paper); }
.fb-title small { font-size: 0.6em; color: var(--paper-dim); margin-left: 6px; }
.fb-id { display: block; font-size: 0.75em; word-break: break-all; }
.fb-cand { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 0.9em; color: var(--paper-2); }
.fb-section { margin-top: 18px; }
.fb-section h4, .cmp-section h4 {
  margin: 0 0 8px;
  font-weight: 400;
  font-size: 0.74em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.fb-section h4 small, .cmp-section h4 small { text-transform: none; letter-spacing: 0; }
.fb-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.fb-actions button em { font-style: normal; color: var(--gold-2); margin-left: 4px; }
.fb-log ul { list-style: none; margin: 0; padding: 0; font-size: 0.85em; }
.fb-log li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.fb-log time { color: var(--paper-dim); font-family: var(--f-mono); font-size: 0.85em; }

.rate-row { display: flex; gap: 5px; }
.rate-row button { flex: 1; padding: 8px 0; font-family: var(--f-display); font-size: 1.1em; }
.rate-row button:hover { color: var(--gold); }

.defect-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 8px; }
.defect-list button { text-align: left; font-size: 0.86em; padding: 6px 8px; }
.defect-list button kbd { margin-right: 6px; }
.defect-list.is-picking button { border-color: var(--gold-2); animation: pulse 1.2s ease-in-out infinite; }
.defect-list button.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.defect-list button.is-active kbd { color: #fff; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.12); } }

.gen { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 0.82em; }
.gen-row { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--line); padding: 2px 0; min-width: 0; }
.gen dt { color: var(--paper-dim); font-family: var(--f-mono); font-size: 0.9em; }
.gen dd { margin: 0; font-family: var(--f-mono); color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-compact { grid-template-columns: 1fr 1fr 1fr; font-size: 0.74em; }
.gen-empty { font-size: 0.85em; color: var(--paper-dim); font-style: italic; }
.gen-prompt { margin-top: 6px; font-size: 0.78em; color: var(--paper-2); max-height: 4.5em; overflow: hidden; line-height: 1.4; }

.stars { font-family: var(--f-display); letter-spacing: 0.08em; color: var(--gold); white-space: nowrap; }
.stars-empty { color: var(--gold-3); }
.judge { font-family: var(--f-mono); font-size: 0.8em; color: var(--blue); border: 1px solid rgba(127, 178, 229, 0.35); border-radius: 999px; padding: 1px 8px; }
.badge {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 0.72em;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper-2);
  font-weight: 700;
}
.badge-unev { background: var(--gold); }
.badge-def { background: var(--red); color: #fff; }
.badge-ref { background: var(--blue); }
.badge-ok { background: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 0.74em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--gold-2); }
.chip-def { border-color: var(--red); color: var(--red); }

/* ---------- Revisión ---------- */
.view-review { display: grid; grid-template-columns: 280px 1fr; }
.rv-sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--ink-2); min-height: 0; }
.rv-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 12px; border-bottom: 1px solid var(--line); }
.rv-filters button { font-size: 0.82em; padding: 5px 6px; }
.rv-list { flex: 1; overflow: auto; padding: 8px; }
.rv-group-title { font-size: 0.7em; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-3); padding: 12px 8px 6px; }
.rv-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: transparent;
  border-color: transparent;
  padding: 7px 10px;
}
.rv-item:hover { background: var(--ink-3); }
.rv-item.is-active { background: var(--ink-4); border-color: var(--line-strong); }
.rv-item-name { display: flex; flex-direction: column; min-width: 0; font-family: var(--f-display); font-size: 1.02em; }
.rv-item-name small { font-family: var(--f-ui); font-size: 0.72em; }
.rv-item-badges { display: flex; gap: 4px; flex-shrink: 0; }
.rv-empty { padding: 6px 10px; color: var(--paper-dim); font-size: 0.85em; }
.rv-side-foot { padding: 10px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.rv-side-foot button { font-size: 0.82em; padding: 6px 4px; }
.rv-side-foot #rv-download { grid-column: 1 / -1; }
.rv-main { overflow: auto; padding: 22px 28px 40px; min-height: 0; }
.rv-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.rv-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.7em; color: var(--gold); }
.rv-head h2 small { font-size: 0.5em; letter-spacing: 0.14em; color: var(--paper-dim); margin-left: 8px; }
.rv-head p { margin: 4px 0 0; color: var(--paper-2); max-width: 70ch; font-size: 0.92em; }
.rv-refs { font-size: 0.85em; white-space: nowrap; color: var(--paper-2); }
.rv-refs code { margin-left: 4px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; color: var(--blue); }
.rv-empty-main { color: var(--paper-dim); font-style: italic; }

.matrix-wrap { overflow: auto; }
.matrix { border-collapse: separate; border-spacing: 6px; }
.matrix th { font-weight: 400; font-size: 0.78em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--paper-dim); text-align: left; padding: 4px 6px; vertical-align: top; }
.matrix thead th { text-align: center; }
.matrix tbody th { min-width: 110px; max-width: 170px; }
.matrix tbody th .outfit-id { display: block; font-family: var(--f-display); font-size: 1.25em; letter-spacing: 0; text-transform: none; color: var(--paper); }
.matrix tbody th small { display: block; font-size: 0.85em; letter-spacing: 0; text-transform: none; line-height: 1.3; }
.matrix td { padding: 0; vertical-align: top; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }

.cell {
  display: flex;
  flex-direction: column;
  width: 150px;
  padding: 0;
  overflow: hidden;
  background: var(--ink-2);
  text-align: left;
}
.bg-grid .cell { width: auto; }
.cell.is-selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5); }
.cell.is-dim { opacity: 0.3; }
.cell.has-defects .cell-status { color: var(--red); }
.cell.is-unevaluated .cell-status { color: var(--gold); }
.cell.is-promoted .cell-status { color: var(--blue); }
.cell-thumb { display: block; width: 100%; aspect-ratio: 3 / 4; background: var(--checker); position: relative; }
.bg-grid .cell-thumb { aspect-ratio: 16 / 9; }
.cell-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cell-thumb img[data-missing]::after { content: "falta"; }
.cell-thumb img[data-missing] { visibility: hidden; }
.cell-thumb:has(img[data-missing])::after {
  content: "sin imagen";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--paper-dim);
  font-size: 0.78em;
  font-style: italic;
}
.cell-meta { display: flex; flex-direction: column; gap: 2px; padding: 7px 9px 8px; font-size: 0.82em; }
.cell-label { font-family: var(--f-display); font-size: 1.1em; color: var(--paper); }
.cell-row { display: flex; justify-content: space-between; align-items: center; }
.cell-row em { font-style: normal; color: var(--paper-dim); font-size: 0.85em; }
.cell-status { font-size: 0.85em; color: var(--paper-dim); }

/* ================================================================
   Overlays
   ================================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 5, 9, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.overlay[hidden] { display: none; }
.checker { background: var(--checker); }

/* ---------- Comparar ---------- */
.cmp { padding: 0; }
.cmp-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}
.cmp-head-title { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.cmp-kind { font-size: 0.72em; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-3); }
.cmp-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.35em; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-head code { font-size: 0.78em; white-space: nowrap; }
.cmp-progress { display: flex; align-items: center; gap: 12px; font-size: 0.85em; white-space: nowrap; }
.cmp-progress i { display: block; width: 180px; height: 6px; background: var(--ink-4); border-radius: 3px; overflow: hidden; }
.cmp-progress i b { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width 0.25s; }
.cmp-head-tools { display: flex; gap: 6px; }
.cmp-body { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.cmp-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px 22px; min-height: 0; }
.cmp-panes.is-single { grid-template-columns: minmax(0, 720px); justify-content: center; }
.cmp-pane {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-2);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cmp-pane.is-focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.18), var(--shadow); }
.cmp-pane.is-empty { border-style: dashed; }
.cmp-img { position: relative; flex: 1; min-height: 240px; background-size: cover; background-position: center; }
.cmp-img.real-bg::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.35)); }
.cmp-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5)); }
.cmp-img:has(img[data-missing])::after { content: "imagen no encontrada"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--paper-dim); font-style: italic; }
.cmp-img img[data-missing] { visibility: hidden; }
.cmp-key {
  position: absolute;
  top: 10px; left: 10px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-size: 1.2em;
  color: var(--ink);
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.cmp-active-tag { position: absolute; top: 14px; right: 12px; font-size: 0.72em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); border: 1px solid var(--gold-2); border-radius: 999px; padding: 2px 9px; background: rgba(0, 0, 0, 0.5); }
.cmp-pane figcaption { padding: 10px 14px 12px; border-top: 1px solid var(--line); font-size: 0.9em; }
.cmp-cap-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 6px; }
.cmp-cap-head strong { font-family: var(--f-display); font-size: 1.15em; color: var(--paper); }
.cmp-cap-head .wins { margin-left: auto; font-family: var(--f-mono); font-size: 0.8em; color: var(--paper-dim); }
.cmp-pane .chips { margin-bottom: 8px; }
.cmp-side { border-left: 1px solid var(--line); background: var(--ink-2); padding: 16px 18px 24px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.cmp-verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cmp-verdict button { padding: 12px 8px; font-size: 0.92em; text-align: left; }
.cmp-verdict button:first-child, .cmp-verdict button:nth-child(3) { font-family: var(--f-display); font-size: 1.02em; }
.cmp-verdict.is-single { display: block; color: var(--paper-dim); font-size: 0.9em; }
.cmp-verdict.is-single p { margin: 0; }
.cmp-section.is-picking .defect-list button { border-color: var(--gold-2); animation: pulse 1.2s ease-in-out infinite; }
.cmp-side .defect-list { grid-template-columns: 1fr; margin-top: 0; }
.rank { margin: 0; padding-left: 22px; font-size: 0.88em; }
.rank li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.rank li:first-child span:first-child { color: var(--gold); }
.rank li span:last-child { font-family: var(--f-mono); font-size: 0.85em; color: var(--paper-2); }
.cmp-actions { display: flex; flex-direction: column; gap: 5px; margin-top: auto; }
.cmp-actions button { text-align: left; font-size: 0.88em; }
.cmp-final { padding: 40px; align-self: center; max-width: 640px; margin: 0 auto; }
.cmp-final h3 { font-family: var(--f-display); font-weight: 400; font-size: 1.6em; color: var(--gold); margin: 0 0 14px; }
.cmp-final ol { font-size: 1.05em; line-height: 1.9; }
.cmp-final li:first-child strong { color: var(--gold); }

/* ---------- Panel de mejora ---------- */
.imp-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--ink-2); gap: 20px; }
.imp-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.5em; color: var(--gold); }
.imp-head p { margin: 2px 0 0; color: var(--paper-dim); font-size: 0.9em; }
.imp-head > div:last-child { display: flex; gap: 6px; }
.imp-body { padding: 24px 28px 48px; max-width: 1240px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
.imp-loading { padding: 60px; text-align: center; color: var(--paper-dim); font-style: italic; }
.imp-body h3 { margin: 0 0 10px; font-family: var(--f-display); font-weight: 400; font-size: 1.15em; color: var(--paper); letter-spacing: 0.02em; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.kpi { background: var(--ink-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; }
.kpi-value { font-family: var(--f-display); font-size: 2em; color: var(--gold); line-height: 1.1; }
.kpi-label { font-size: 0.74em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--paper-dim); margin-top: 6px; }
.imp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.imp-table th { text-align: left; font-weight: 400; font-size: 0.74em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--paper-dim); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.imp-table td { padding: 8px; border-bottom: 1px dotted var(--line); vertical-align: top; }
.imp-table .rule { color: var(--paper-2); font-size: 0.92em; max-width: 42ch; }
.imp-table .actions { white-space: nowrap; }
.imp-table .actions button { font-size: 0.82em; padding: 4px 10px; margin-left: 4px; }
.imp-table tr.is-accepted td { background: rgba(121, 201, 143, 0.08); }
.imp-table tr.is-ignored td { opacity: 0.45; }
.bar { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.bar b { display: block; height: 8px; background: linear-gradient(90deg, var(--gold-2), var(--gold)); border-radius: 4px; min-width: 2px; }
.bar span { font-family: var(--f-mono); font-size: 0.85em; }
.imp-refs { list-style: none; margin: 0; padding: 0; font-size: 0.92em; }
.imp-refs li { padding: 5px 0; border-bottom: 1px dotted var(--line); }
.imp-refs code { margin-left: 4px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; color: var(--blue); }
.imp-actions { display: grid; gap: 6px; }
.imp-actions button { text-align: left; }

/* ---------- Ayuda ---------- */
.help { align-items: center; justify-content: center; padding: 30px; }
.help-card { background: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 24px 30px 20px; max-width: 1100px; width: 100%; max-height: 100%; overflow: auto; box-shadow: var(--shadow); }
.help-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.help-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; color: var(--gold); font-size: 1.5em; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px 28px; }
.help-grid h3 { margin: 0 0 8px; font-size: 0.76em; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-3); }
.help-grid dl { margin: 0; }
.help-grid dl > div { display: grid; grid-template-columns: 120px 1fr; gap: 8px; padding: 4px 0; border-bottom: 1px dotted var(--line); font-size: 0.9em; }
.help-grid dt { white-space: nowrap; }
.help-grid dd { margin: 0; color: var(--paper-2); }
.help-card > p { margin: 18px 0 0; font-size: 0.82em; line-height: 2; }

/* ---------- Error fatal ---------- */
.fatal { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 40; display: grid; place-items: center; background: var(--ink); }
.fatal[hidden] { display: none; }
.fatal-card { max-width: 640px; padding: 30px 36px; border: 1px solid var(--gold-3); border-radius: 8px; background: var(--ink-2); box-shadow: var(--shadow); }
.fatal-card h2 { margin: 0 0 10px; font-family: var(--f-display); font-weight: 400; color: var(--gold); }
.fatal-card ol { color: var(--paper-2); line-height: 1.8; }
.fatal-card a { color: var(--gold); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  z-index: 200;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: var(--red); color: #fff; }

/* ================================================================
   Componentes compartidos (todas las anchuras)
   ================================================================ */
b.ok, .ok { color: var(--green); font-weight: 600; }
b.warn, .warn { color: var(--red); font-weight: 600; }
button.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 600; }
button.primary:hover { background: #ffe34d; color: var(--ink); }
button.primary:disabled { background: var(--ink-4); color: var(--paper-dim); border-color: var(--line); }
button.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
button.danger-solid:hover { background: #ef6a5e; color: #fff; }
button.big { min-height: 52px; font-size: 1.05em; }
a.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-3); color: var(--paper); text-decoration: none; font-size: 0.9em; }
textarea {
  width: 100%; font: inherit; color: var(--paper); background: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; outline: none; resize: vertical; font-family: var(--f-mono); font-size: 14px; line-height: 1.45;
}
textarea:focus { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.12); }
input[type="range"] { accent-color: var(--gold); flex: 1; min-width: 0; }
mark { background: rgba(255, 215, 0, 0.22); color: var(--gold); padding: 0 2px; border-radius: 2px; }

/* chips de un toque (defecto / hint) */
.chip-btn {
  min-height: 40px; padding: 0 14px; border-radius: 22px; font-size: 14px;
  background: var(--ink-3); border: 1px solid var(--line-strong); color: var(--paper); white-space: nowrap;
}
.chip-btn.is-def, .chip-btn.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.chip-btn.is-hint { border-color: rgba(127, 178, 229, 0.6); background: #16202c; color: #bcd8f2; }
.chip-btn.is-hint.is-active { background: var(--blue); color: var(--ink); border-color: var(--blue); }
.chip-btn kbd { margin-right: 5px; }
.chip-hint { border-color: rgba(127, 178, 229, 0.6); color: #bcd8f2; }
.chip-note { border-color: rgba(127, 178, 229, 0.6); color: #bcd8f2; font-style: italic; }
.chip-filter { border-radius: 999px; padding: 8px 14px; font-size: 0.9em; white-space: nowrap; min-height: 40px; }
.chip-filter b { font-family: var(--f-mono); font-weight: 400; color: var(--gold-2); margin-left: 3px; }
.chip-filter.is-active b { color: var(--ink); }

/* hoja de defecto (👎) — misma función en panel lateral y hoja inferior */
.ds-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.ds-thumb { width: 48px; height: 64px; border-radius: 6px; overflow: hidden; flex: 0 0 auto; position: relative; background: var(--checker); }
.ds-thumb img { width: 100%; height: 100%; object-fit: contain; }
.ds-thumb.is-bg { width: 72px; height: 48px; }
.ds-head-main { min-width: 0; flex: 1; }
.ds-kicker, .ds-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-2); }
.ds-label { color: var(--paper-dim); margin: 12px 0 8px; }
.ds-title { font-family: var(--f-display); font-size: 1.15em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-title small { font-size: 0.75em; color: var(--paper-dim); margin-left: 6px; }
.ds-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-wish { display: flex; gap: 8px; align-items: center; }
.ds-wish input { flex: 1; min-width: 0; height: 48px; border-radius: 10px; font-size: 16px; padding: 0 14px; }
.ds-wish button { width: 48px; height: 48px; padding: 0; border-radius: 24px; color: var(--gold); flex: 0 0 auto; }
.ds-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13px; }
.ds-status { color: var(--green); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-status.is-pending { color: var(--gold-2); }
.ds-foot button { background: transparent; border: 0; color: var(--gold-2); font-weight: 600; }
.fb-body .ds-chips .chip-btn { min-height: 36px; font-size: 0.86em; padding: 0 10px; }
.fb-body .ds-wish input { height: 40px; font-size: 14px; }
.fb-body .ds-wish button { width: 40px; height: 40px; }

/* hoja inferior genérica */
.sheet { position: fixed; inset: 0; z-index: 120; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(6, 5, 9, 0.55); opacity: 0; transition: opacity 0.2s; }
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: calc(100% - var(--sat) - 24px);
  display: flex; flex-direction: column;
  background: var(--ink-2);
  border-top: 1px solid var(--line-strong);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.6);
  padding: 8px 16px calc(12px + var(--sab));
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.is-open .sheet-panel { transform: translateY(0); }
.sheet-panel.is-dragging { transition: none; }
.sheet-grip { display: flex; justify-content: center; padding: 2px 0 8px; cursor: grab; touch-action: none; }
.sheet-grip i { width: 40px; height: 5px; border-radius: 3px; background: rgba(239, 230, 210, 0.3); }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; touch-action: none; }
.sheet-head-main { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.2em; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-2); }
.sheet-kicker:empty { display: none; }
.sheet-close { width: 44px; height: 44px; font-size: 20px; flex: 0 0 auto; }
.sheet-body { overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.sheet-section { margin-top: 10px; }
.menu-list { display: flex; flex-direction: column; }
.menu-list button, .menu-list a {
  min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 10px;
  background: transparent; border: 0; border-radius: 10px; color: var(--paper); font-size: 15px; text-align: left; text-decoration: none;
}
.menu-list button:hover, .menu-list a:hover { background: var(--ink-3); }
.menu-list .ic { width: 28px; text-align: center; color: var(--gold-2); font-family: var(--f-display); font-size: 1.1em; flex: 0 0 auto; }
.menu-list .tail { margin-left: auto; color: var(--paper-dim); font-size: 13px; font-family: var(--f-mono); white-space: nowrap; }
.menu-list .tail .badge { font-size: 0.8em; }
.menu-modes { display: flex; gap: 8px; margin-bottom: 8px; }
.menu-modes button { flex: 1; min-height: 48px; border-radius: 12px; font-weight: 500; }
.menu-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 0; font-size: 12px; color: var(--paper-dim); }
.menu-status a { color: var(--gold-2); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; }
.menu-rate { display: flex; gap: 6px; padding: 4px 10px 8px; }
.menu-rate button { flex: 1; min-height: 44px; font-family: var(--f-display); font-size: 1.1em; }
.goto-list { display: flex; flex-direction: column; gap: 2px; }
.goto-list h4 { margin: 10px 0 4px; font-weight: 400; font-size: 0.74em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-3); }
.goto-list button { text-align: left; min-height: 44px; display: flex; justify-content: space-between; gap: 10px; background: transparent; border-color: transparent; }
.goto-list button.is-current { border-color: var(--gold-2); }
.goto-list button small { font-family: var(--f-mono); }
.menu-gen { padding: 0 10px 10px; }

/* Comparar en phone */
.cmpp-head { display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 4px) 8px 4px; border-bottom: 1px solid var(--line); background: var(--ink-2); flex: 0 0 auto; }
.cmpp-head-main { flex: 1; min-width: 0; }
.cmpp-title { font-family: var(--f-display); font-size: 16px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.cmpp-sub { font-size: 11px; color: var(--paper-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmpp-head .round { width: 44px; height: 44px; }
.cmpp-progress { height: 3px; background: var(--ink-4); flex: 0 0 auto; }
.cmpp-progress b { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width 0.25s; }
.cmpp-panes { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px 12px; touch-action: pan-y; }
.cmpp-panes.is-single { grid-template-rows: 1fr; }
.cmpp-pane {
  position: relative; padding: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line-strong);
  background-size: cover; background-position: center; min-height: 0;
}
.cmpp-pane.checker { background: var(--checker); }
.cmpp-pane.is-focus { border: 2px solid var(--gold); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15); }
.cmpp-pane img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5)); }
.cmpp-pane img[data-missing] { visibility: hidden; }
.cmpp-pane:has(img[data-missing])::after { content: "imagen no encontrada"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--paper-dim); font-style: italic; }
.cmpp-key { position: absolute; top: 10px; left: 10px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--ink); font-family: var(--f-display); font-size: 18px; font-weight: 600; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
.cmpp-pane[data-side="b"] .cmpp-key { background: var(--gold-2); }
.cmpp-pane .cmp-active-tag, .cmpp-pane .cmp-new-tag, .cmpp-tag { position: absolute; top: 12px; right: 10px; }
.cmpp-tag { font-family: var(--f-mono); font-size: 11px; color: var(--paper-2); background: rgba(0, 0, 0, 0.5); border-radius: 999px; padding: 2px 8px; }
.cmp-new-tag { position: absolute; top: 14px; right: 12px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--green); color: var(--ink); }
.cmpp-meta { position: absolute; left: 10px; right: 10px; bottom: 8px; display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-family: var(--f-mono); color: var(--paper-2); background: rgba(0, 0, 0, 0.55); border-radius: 6px; padding: 4px 8px; }
.cmpp-meta .is-def { color: var(--red); }
.cmpp-meta .is-judge { color: var(--blue); }
.cmpp-verdict { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 6px 12px 0; }
.cmpp-verdict button { min-height: 56px; border-radius: 12px; font-size: 13px; font-weight: 600; line-height: 1.1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px; }
.cmpp-verdict button small { font-size: 11px; font-weight: 400; color: inherit; opacity: 0.8; }
.cmpp-verdict .win-a { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.cmpp-verdict .win-b { background: var(--gold-2); color: var(--ink); border-color: var(--gold-2); }
.cmpp-verdict .danger { color: var(--red); border-color: var(--red); }
.cmpp-chips { flex: 0 0 auto; display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; scrollbar-width: none; }
.cmpp-chips::-webkit-scrollbar { display: none; }
.cmpp-chips .chip-btn { min-height: 36px; font-size: 13px; padding: 0 12px; flex: 0 0 auto; }
.cmpp-focus { min-height: 36px; min-width: 44px; border-radius: 18px; font-family: var(--f-display); color: var(--gold); flex: 0 0 auto; }
.cmpp-actions { flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 12px 0; align-items: center; }
.cmpp-actions input { flex: 1; min-width: 0; height: 44px; border-radius: 10px; font-size: 16px; }
.cmpp-actions button { min-height: 44px; border-radius: 10px; white-space: nowrap; }
.cmpp-rate { flex: 0 0 auto; display: flex; gap: 6px; padding: 8px 12px calc(10px + var(--sab)); }
.cmpp-rate button { flex: 1; min-height: 40px; font-family: var(--f-display); }
.cmpp-final { flex: 1; padding: 30px 20px; display: flex; flex-direction: column; justify-content: center; }
.cmpp-final h3 { font-family: var(--f-display); font-weight: 400; font-size: 1.5em; color: var(--gold); margin: 0 0 12px; }
.cmpp-final ol { line-height: 1.9; padding-left: 22px; margin: 0 0 20px; }
.cmpp-final li:first-child strong { color: var(--gold); }

/* Revisión en phone: tarjetas */
.rv-chips { display: flex; gap: 6px; padding: 10px 12px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.rv-chips::-webkit-scrollbar { display: none; }
.rv-chips .chip-filter { flex: 0 0 auto; }
.rv-cards { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 16px; }
.rv-card { border: 1px solid var(--line); border-radius: 12px; background: var(--ink-2); overflow: hidden; }
.rv-card.is-open { border-color: var(--line-strong); }
.rv-card-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 60px; background: transparent; border: 0; border-radius: 0; text-align: left; }
.rv-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; border: 2px solid var(--ink-4); background: var(--checker); position: relative; }
.rv-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.rv-avatar img[data-missing] { visibility: hidden; }
.rv-avatar.big { width: 72px; height: 72px; border-radius: 10px; }
.rv-avatar-bg { border-radius: 8px; background: linear-gradient(135deg, #4f6b55, #171a24); }
.rv-card-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rv-card-name strong { font-family: var(--f-display); font-weight: 400; font-size: 1.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-card-name small { font-size: 0.8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-chevron { color: var(--paper-dim); transition: transform 0.2s; flex: 0 0 auto; display: flex; }
.rv-card.is-open .rv-chevron { transform: rotate(90deg); }
.rv-row { border-top: 1px solid var(--line); padding: 8px 0 10px; }
.rv-row-title { font-family: var(--f-display); font-size: 1em; padding: 0 12px 6px; }
.rv-row-title .rv-row-hint { margin-left: 6px; font-family: var(--f-ui); }
.rv-strip { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.rv-strip::-webkit-scrollbar { display: none; }
.rv-strip .cell { flex: 0 0 112px; width: 112px; min-height: 190px; scroll-snap-align: start; }
.rv-strip .cell-meta { padding: 6px 8px 8px; font-size: 0.78em; }
.cell-new { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--green); color: var(--ink); font-family: var(--f-ui); }
.cell.has-new-round .cell-status { color: var(--green); }
.rv-foot-phone { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--sab)); background: var(--ink-2); border-top: 1px solid var(--line); }
.rv-foot-phone button { min-height: 52px; border-radius: 12px; }
.rv-foot-phone .primary { flex: 1; font-size: 1.02em; }

/* Correcciones (todas las anchuras) */
.view-corrections { display: flex; flex-direction: column; overflow: hidden; }
.cx-wrap, .cx-detail { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; max-width: 960px; margin: 0 auto; }
.cx-counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 12px 12px 6px; flex: 0 0 auto; }
.cx-kpi { border-radius: 10px; background: var(--ink-2); border: 1px solid var(--line); padding: 8px 6px; text-align: center; display: flex; flex-direction: column; }
.cx-kpi b { font-family: var(--f-display); font-weight: 400; font-size: 24px; line-height: 1; }
.cx-kpi span { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--paper-dim); margin-top: 4px; }
.cx-kpi.is-pending b { color: var(--red); }
.cx-kpi.is-queued b { color: var(--gold); }
.cx-kpi.is-done b { color: var(--green); }
.cx-kpi.is-accepted b { color: var(--blue); }
.cx-jobline { margin: 4px 12px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 215, 0, 0.08); border: 1px solid var(--line-strong); font-size: 0.86em; color: var(--gold-2); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.cx-jobline .spin svg { animation: spin 1.1s linear infinite; display: block; }
.cx-groups { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 6px 12px 16px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.cx-group { border: 1px solid var(--line); border-radius: 12px; background: var(--ink-2); overflow: hidden; }
.cx-group.has-pending { border-color: var(--line-strong); }
.cx-group-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cx-ficha { min-height: 40px; padding: 0 12px; border-radius: 20px; color: var(--gold); border-color: var(--line-strong); background: transparent; white-space: nowrap; }
.cx-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; text-align: left; min-height: 64px; }
.cx-group-head + .cx-row { border-top: 0; }
.cx-row:hover { background: var(--ink-3); }
.cx-thumb { width: 40px; height: 52px; border-radius: 6px; overflow: hidden; flex: 0 0 auto; position: relative; }
.cx-thumb.is-bg { width: 64px; height: 40px; }
.cx-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cx-thumb img[data-missing] { visibility: hidden; }
.cx-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cx-row-main strong { font-weight: 500; font-size: 0.95em; }
.cx-row-main .chips .chip { font-size: 11px; }
.cx-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; background: var(--paper-2); color: var(--ink); flex: 0 0 auto; }
.cx-pill.is-pending { background: var(--red); color: #fff; }
.cx-pill.is-queued, .cx-pill.is-running { background: var(--gold); }
.cx-pill.is-done, .cx-pill.is-compare { background: var(--green); }
.cx-pill.is-accepted { background: var(--blue); }
.cx-pill.is-failed { background: var(--ink-4); color: var(--red); }
.cx-others { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85em; color: var(--paper-dim); padding: 4px 2px; }
.cx-others .chip-btn { min-height: 36px; font-size: 0.95em; }
.cx-empty { padding: 30px 16px; text-align: center; color: var(--paper-2); }
.cx-empty p { margin: 6px 0; }
.cx-foot { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--sab)); background: var(--ink-2); border-top: 1px solid var(--line); justify-content: center; }
.cx-foot > * { max-width: 720px; }
.cx-foot button { min-height: 52px; border-radius: 12px; white-space: nowrap; }
.cx-foot .primary { flex: 1; font-size: 1.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cx-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--line); background: var(--ink-2); flex: 0 0 auto; min-height: 52px; }
.cx-head .round { width: 44px; height: 44px; flex: 0 0 auto; }
.cx-head-main { flex: 1; min-width: 0; }
.cx-title { font-family: var(--f-display); font-size: 17px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.cx-sub { font-size: 11px; color: var(--paper-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.cx-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 6px 12px 16px; -webkit-overflow-scrolling: touch; }
.cx-section { margin-top: 14px; }
.cx-section h4, .cx-section > label { display: block; margin: 0 0 8px; font-weight: 400; font-size: 0.74em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--paper-dim); }
.cx-section h4 small, .cx-section > label small { text-transform: none; letter-spacing: 0; }
.cx-section > label + textarea { margin-bottom: 12px; }
.cx-loading { padding: 30px; text-align: center; color: var(--paper-dim); font-style: italic; }
.cx-error { margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(224, 86, 74, 0.5); border-radius: 10px; background: rgba(224, 86, 74, 0.08); font-size: 0.92em; }
.cx-error p { margin: 6px 0; }
.cx-instr { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dotted var(--line); cursor: pointer; }
.cx-instr input[type="checkbox"] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--gold); flex: 0 0 auto; }
.cx-instr.is-off .cx-instr-main { opacity: 0.45; }
.cx-instr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cx-instr-desc { font-size: 0.95em; }
.cx-note-edit { margin-top: 6px; font-size: 16px; height: 44px; border-radius: 8px; }
.cx-preview { margin: 0; font-family: var(--f-mono); font-size: 12.5px; line-height: 1.55; color: var(--paper-2); background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; max-height: 190px; overflow: auto; }
.cx-preview.is-neg { margin-top: 8px; }
.cx-roundline { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--f-mono); font-size: 12px; color: var(--paper-2); }
.cx-roundline i { color: var(--gold-3); font-style: normal; }
.cx-ref { display: flex; gap: 14px; align-items: center; }
.cx-ref-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.92em; }
.cx-refs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.9em; color: var(--paper-dim); }
.cx-refs .chip-btn { min-height: 34px; padding: 0 10px; font-size: 0.9em; }
.cx-outfit { padding: 8px 0 10px; border-bottom: 1px dotted var(--line); display: flex; flex-direction: column; gap: 6px; }
.cx-outfit-head { display: flex; justify-content: space-between; align-items: baseline; }
.cx-outfit-head strong { font-family: var(--f-display); font-weight: 400; font-size: 1.05em; }
.cx-outfit input { font-size: 16px; min-height: 44px; }
.cx-range { display: flex; align-items: center; gap: 12px; }
.cx-range span { font-family: var(--f-mono); font-size: 0.85em; color: var(--paper-dim); }
.cx-range b { font-family: var(--f-mono); color: var(--gold); min-width: 3.5ch; text-align: right; }
.cx-impact { margin-top: 16px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(224, 86, 74, 0.55); background: rgba(224, 86, 74, 0.1); font-size: 0.92em; line-height: 1.5; }
.cx-jobs { display: flex; flex-direction: column; gap: 8px; }
.cx-job { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--ink-2); }
.cx-job.is-running { border-color: var(--line-strong); }
.cx-job.is-failed { border-color: rgba(224, 86, 74, 0.5); }
.cx-job-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.92em; }
.cx-job-main strong { font-family: var(--f-mono); font-weight: 600; font-size: 0.9em; }
.cx-job-error { font-family: var(--f-mono); font-size: 0.8em; color: var(--red); word-break: break-word; }
.cx-job-actions { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.cx-job-actions button, .cx-job-actions a { min-height: 36px; font-size: 0.85em; }

/* ================================================================
   Móvil — breakpoints (desktop ≥ 1024 px conserva el diseño actual)
   ================================================================ */
@media (max-width: 1100px) {
  .topbar { gap: 10px; }
  .cmp-body { grid-template-columns: 1fr 280px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- tablet + phone (< 1024) ---------- */
@media (max-width: 1023px) {
  .lg { display: none !important; }
  .sm { display: inline-flex !important; }
  .topbar {
    height: calc(44px + var(--sat));
    padding: var(--sat) 8px 0 4px;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }
  .topbar-back { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3em; color: var(--paper-2); }
  .topbar-main { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 0; min-width: 0; height: 44px; }
  .topbar-title { display: block !important; font-size: 16px; max-width: none; line-height: 1.1; }
  .crumbs { display: flex; gap: 0; height: 15px; }
  .crumb { flex-direction: row; gap: 4px; padding: 0; border: 0; font-size: 11px; color: var(--paper-dim); letter-spacing: 0.04em; }
  .crumb small { font-size: 1em; text-transform: none; letter-spacing: 0; color: var(--paper-dim); }
  .crumb + .crumb::before { content: " · "; color: var(--gold-3); margin: 0 3px; }
  #btn-more { width: 44px; height: 44px; font-size: 22px; background: transparent; border-color: transparent; align-items: center; justify-content: center; }
  .regen-pill { font-size: 11px; padding: 2px 8px; }
  .regen-pill #regen-label { display: inline; }
  #main { position: relative; }
  button, a.btn, .cell { min-height: 44px; }   /* targets ≥ 44 pt; .chip (span) es solo etiqueta */
  .chip { display: inline-flex; align-items: center; min-height: 24px; }
  input[type="text"], input[type="search"], textarea { font-size: 16px; }
  .controls button:not(.panel-toggle) { display: none; }
  .controls { top: 10px; right: 10px; }
  .character { pointer-events: auto; -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
  .conn-dot { margin-left: 2px; }
  .controls .panel-toggle { margin: 0; min-height: 40px; }
  .fb-panel.is-open { position: absolute; right: 0; top: 0; bottom: 0; z-index: 10; width: min(var(--panel-w), 100%); box-shadow: var(--shadow); }
  .view-review { grid-template-columns: 220px 1fr; }
  .rv-main { padding: 16px; }
  .cmp-body { grid-template-columns: 1fr; }
  .cmp-side { border-left: 0; border-top: 1px solid var(--line); }
  .cmp-head { padding: calc(var(--sat) + 10px) 16px 10px; gap: 12px; }
  .imp-grid { grid-template-columns: 1fr; }
  .imp-head { padding: calc(var(--sat) + 12px) 16px 12px; }
  .imp-body { padding: 16px 16px calc(32px + var(--sab)); }
  .help { padding: calc(var(--sat) + 16px) 12px calc(16px + var(--sab)); }
  .help-card { padding: 18px 16px; }
  .help-grid dl > div { grid-template-columns: 100px 1fr; }
  .toast { bottom: calc(var(--bar-h) + var(--sab) + 14px); max-width: 92vw; }
  .fatal { inset: calc(44px + var(--sat)) 0 0 0; }
  .fatal-card { margin: 16px; padding: 20px; }
  .bottombar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    flex: 0 0 auto;
    padding: 6px 8px calc(6px + var(--sab));
    padding-left: calc(8px + var(--sal));
    padding-right: calc(8px + var(--sar));
    background: var(--ink-2);
    border-top: 1px solid var(--line);
    z-index: 15;
  }
  .bottombar button {
    height: var(--bar-h);
    border: 0;
    border-radius: 10px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 500;
    color: var(--paper);
    padding: 0;
  }
  .bottombar button:active { background: var(--ink-3); transform: none; }
  .bottombar button:disabled { opacity: 0.35; }
  .bottombar .bb-good { color: var(--green); }
  .bottombar .bb-bad { color: var(--red); }
  .bottombar button em { font-style: normal; color: var(--gold-2); }
  .bottombar button em:empty { display: none; }
  .bottombar button.is-active { background: var(--ink-3); color: var(--gold); }
}

/* ---------- phone (≤ 600) ---------- */
@media (max-width: 600px) {
  .topbar-main .crumbs { height: 15px; }
  .view-read-body { position: relative; }
  .stage .bg { object-fit: cover; object-position: 50% 50%; }
  /* El sprite se apoya detrás de la caja: los pies quedan bajo la caja más baja posible (1 línea),
     así no flota con letra grande ni encoge con texto largo. Tamaño fijo por escenario. */
  .character { max-height: calc(100% - var(--dlg-bottom) - 56px); max-width: 78%; bottom: calc(var(--dlg-bottom) + 40px); }
  .character-missing { bottom: calc(var(--dlg-reserve) + 40px); }
  .dialogue { left: 12px; right: 12px; bottom: 12px; width: auto; transform: none; }
  .dialogue-frame { padding: 14px 16px 12px; box-shadow: 0 0 0 3px rgba(10, 9, 14, 0.9), 0 0 0 4px var(--gold-3), 0 12px 30px rgba(0, 0, 0, 0.5); }
  .dialogue-frame::before, .dialogue-frame::after { display: none; }
  .stage { --fs-text: calc(17px * var(--reader-scale, 1)); --fs-speaker: calc(18px * var(--reader-scale, 1)); --lh-text: var(--reader-lh, 1.5); --dlg-lines: 5; --dlg-pad: 26px; --dlg-bottom: 12px; }
  .speaker { margin-bottom: 6px; }
  .hint { font-size: 0.72em; }
  .fb-panel.is-open { width: 100%; }
  .controls { display: none; }           /* en phone, feedback = barra inferior + hojas */
  .view-review { display: flex; flex-direction: column; }
  .rv-sidebar { display: none; }
  .rv-main { padding: 0; display: flex; flex-direction: column; }
  .cmp { display: flex; flex-direction: column; overflow: hidden; }
  .sheet-panel { padding-left: calc(16px + var(--sal)); padding-right: calc(16px + var(--sar)); }
  .cx-counters { padding-top: 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .imp-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .imp-table { font-size: 0.82em; }
  .imp-table .actions button { display: block; margin: 2px 0; }
  .help-grid { grid-template-columns: 1fr; }
}

/* ---------- phone apaisado: escenario completo ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  body[data-layout="phone"] .topbar {
    position: absolute; left: 0; right: 0; top: 0; z-index: 30;
    transform: translateY(-100%);
    transition: transform 0.25s ease;
  }
  body[data-layout="phone"].show-chrome .topbar { transform: translateY(0); }
  body[data-layout="phone"] #main { position: absolute; inset: 0; }
  body[data-layout="phone"] .view-read .bottombar {
    position: absolute; right: 0; top: 0; bottom: 0; left: auto;
    width: calc(64px + var(--sar));
    grid-template-columns: 1fr;
    grid-auto-rows: 56px;
    align-content: center;
    padding: 8px calc(4px + var(--sar)) 8px 4px;
    border-top: 0; border-left: 1px solid var(--line);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 25;
  }
  body[data-layout="phone"].show-chrome .view-read .bottombar { transform: translateX(0); }
  body[data-layout="phone"] .bottombar button { height: 56px; }
  body[data-layout="phone"] .stage .bg { object-fit: cover; }
  body[data-layout="phone"] .character { max-height: calc(100% - var(--dlg-bottom) - 28px); max-width: 40%; bottom: calc(var(--dlg-bottom) + 20px); }
  body[data-layout="phone"] .dialogue { left: calc(10px + var(--sal)); right: calc(10px + var(--sar)); bottom: calc(8px + var(--sab)); width: auto; max-width: 720px; margin: 0 auto; transform: none; }
  body[data-layout="phone"] .dialogue-frame { padding: 10px 16px 10px; display: flex; gap: 12px; align-items: baseline; }
  body[data-layout="phone"] .stage { --fs-text: calc(17px * var(--reader-scale, 1)); --fs-speaker: calc(16px * var(--reader-scale, 1)); --lh-text: var(--reader-lh, 1.4); --dlg-lines: 3; --dlg-pad: 20px; --dlg-bottom: calc(8px + var(--sab)); --dlg-reserve: calc(var(--dlg-bottom) + var(--dlg-pad) + var(--dlg-lines) * var(--fs-text) * var(--lh-text) + 14px); }
  body[data-layout="phone"] .speaker { margin: 0; white-space: nowrap; }
  body[data-layout="phone"] .text { flex: 1; min-height: 0; }
  body[data-layout="phone"] .hint { display: none; }
  body[data-layout="phone"] .chrome-toggle {
    display: grid; place-items: center;
    position: absolute; top: 6px; right: calc(8px + var(--sar));
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(10, 9, 14, 0.7); border: 1px solid var(--line-strong);
    color: var(--paper); font-size: 22px; opacity: 0.7; z-index: 26;
  }
  body[data-layout="phone"].show-chrome .chrome-toggle { opacity: 0; pointer-events: none; }
  body[data-layout="phone"] .landscape-crumb {
    display: block; position: absolute; top: 14px; left: calc(14px + var(--sal));
    font-size: 11px; color: rgba(239, 230, 210, 0.6); letter-spacing: 0.06em; z-index: 6;
  }
  body[data-layout="phone"] .controls { display: none; }
  body[data-layout="phone"] .cmpp-panes { grid-template-rows: 1fr; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-layout="phone"] .cmpp-verdict .win-a small::after { content: " (izq.)"; }
  body[data-layout="phone"] .toast { bottom: 12px; }
}

/* ---------- tablet (601–1023) ---------- */
@media (min-width: 601px) and (max-width: 1023px) {
  .topbar-main { flex-direction: row; align-items: center; gap: 14px; }
  .topbar-title { max-width: 280px; }
  .crumbs { height: auto; }
  .crumb { flex-direction: column; font-size: 0.85em; }
  .crumb small { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold-3); }
  .crumb + .crumb::before { content: none; }
  .crumb + .crumb { border-left: 1px solid var(--line); padding-left: 10px; margin-left: 10px; }
  .fb-panel.is-open { width: 360px; }
  .cmp-panes { padding: 12px; gap: 12px; }
}

/* reduce movimiento */
@media (prefers-reduced-motion: reduce) {
  :root { --t-text-out: 0ms; --t-sprite-out: 0ms; --t-bg: 300ms; --t-sprite-in: 0ms; --t-text-in: 0ms; --t-move: 0ms; }
  .stage.cam-drift .bg { animation: none !important; }
  .sheet-panel, .topbar, .bottombar { transition: none !important; }
  .regen-pill svg, .cx-jobline .spin svg { animation: none !important; }
}

/* ================================================================
   Modo lector (?reader=1): sin UI de revisión, portada y final
   ================================================================ */
body[data-reader="1"] [data-set-mode],
body[data-reader="1"] #conn,
body[data-reader="1"] #user-label,
body[data-reader="1"] #btn-improve,
body[data-reader="1"] #btn-panel,
body[data-reader="1"] #feedback-panel,
body[data-reader="1"] #bottombar,
body[data-reader="1"] #btn-more { display: none !important; }

.overlay.reader { align-items: center; justify-content: center; padding: 20px 16px calc(20px + var(--sab, 0px)); z-index: 60; }
.reader-card { width: min(560px, 100%); margin: auto; display: flex; flex-direction: column; gap: 14px; color: var(--paper); font-family: var(--f-ui); }
.reader-card h1 { margin: 0; font-family: var(--f-display); font-size: 1.9em; line-height: 1.2; color: var(--gold); }
.reader-card h2 { margin: 0 0 4px; font-size: 1em; color: var(--gold-2); text-transform: uppercase; letter-spacing: 0.06em; }
.reader-author { margin: 0; color: var(--paper-2); }
.reader-where { margin: 0; font-weight: 600; }
.reader-recap { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-3); }
.reader-recap p { margin: 0; line-height: 1.5; color: var(--paper-2); }
.reader-actions { display: flex; flex-direction: column; gap: 10px; }
.reader-actions .primary { min-height: 48px; font-size: 1.05em; }
#reader-cover-actions:empty { display: none; }
.reader-ai { margin: 6px 0 0; font-size: 0.8em; color: var(--paper-dim); text-align: center; }
.reader-q { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 6px; }
.reader-q legend { padding: 0 6px; font-weight: 600; }
.reader-q label { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.reader-q textarea { width: 100%; box-sizing: border-box; resize: vertical; background: var(--ink-2); color: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; font: inherit; }
.reader-credits ul { margin: 0; padding-left: 1.2em; line-height: 1.6; }
.reader-credits a { color: var(--blue); }

/* Botón de altavoz (música del lector): visible también en phone, donde .controls se oculta */
.controls .audio-toggle[hidden] { display: none; }
.controls .audio-toggle:not([hidden]) { display: inline-block; padding: 6px 10px; }
body[data-reader="1"][data-layout="phone"] .controls { display: flex; }
body[data-reader="1"][data-layout="phone"] .controls button:not(.audio-toggle):not(.font-toggle) { display: none; }
/* Botón «Aa»: visible también en el lector móvil, donde .controls solo enseña el altavoz */
.controls .font-toggle { font-family: var(--f-display); }
body[data-reader="1"][data-layout="phone"] .controls .font-toggle { display: inline-block; min-height: 40px; min-width: 40px; padding: 6px 10px; }

/* Hoja de letra */
.font-scales { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.font-scales button { min-height: 56px; font-family: var(--f-display); line-height: 1.1; }
.font-scales button.is-active { border-color: var(--gold); color: var(--gold); }
.font-opt { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; }
.font-opt input { width: 22px; height: 22px; }
.font-sample { margin: 12px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--f-display); font-size: calc(17px * var(--reader-scale, 1)); line-height: var(--reader-lh, 1.5); }

/* Alto contraste: sin cursiva, blanco puro, caja casi opaca */
body[data-font-contrast="1"] .stage .text, body[data-font-contrast="1"] .stage.is-narrator .text { font-style: normal; color: #fff; }
body[data-font-contrast="1"] .dialogue-frame { background: rgba(5, 4, 8, 0.97); }
body[data-font-contrast="1"] .speaker { color: #ffd98a; }
body[data-reader="1"][data-layout="phone"] .controls .audio-toggle { min-height: 40px; min-width: 40px; }

/* Selector de capítulos */
.chapter-list { gap: 6px; }
.chapter-row { border-bottom: 1px solid rgba(255, 255, 255, 0.06); padding-bottom: 6px; }
.chapter-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; width: 100%; text-align: left; background: transparent; border-color: transparent; }
div.chapter-head { padding: 0 10px; }
.chapter-title { font-family: var(--f-display); }
.chapter-row.is-read .chapter-head small { color: var(--gold-3); }
.chapter-recap { padding: 0 10px 8px; font-size: 0.9em; line-height: 1.45; color: var(--paper-dim); }
.chapter-recap b { color: var(--gold-2); font-weight: 600; }
.chapter-scenes { display: flex; flex-direction: column; gap: 2px; padding-left: 10px; }
.chapter-scenes[hidden] { display: none; }
.chapter-row.is-current > .chapter-head .chapter-title { color: var(--gold-2); }
.chapter-scenes button.is-current { border-color: var(--gold-2); }
.chapter-scenes button.is-ahead { opacity: 0.6; }
.chapter-row.is-locked .chapter-title { opacity: 0.5; }
.chapter-skip { min-height: 44px; }
.chapter-empty { padding: 16px 10px; color: var(--paper-dim); }
.spoiler-confirm { padding: 10px; border: 1px solid var(--gold-3); border-radius: 12px; }
.spoiler-confirm p { margin: 0 0 10px; }
.spoiler-actions { display: flex; gap: 8px; }
.spoiler-actions button { flex: 1; min-height: 44px; }

/* Planos de cine (assets/planos/planos.json): el clip a pantalla completa tapa fondo y sprites */
.stage.is-cine .bg:not(.plano) { opacity: 0; }
.stage.is-cine .characters { display: none; }
.stage .bg.plano { transition-duration: 0.8s; }

/* ===================== Lector inmersivo (2026-10-18) =====================
   Sin barra superior ni iconos pequeños: un solo botón «Menú» abre el menú grande; capítulos en cajón lateral. */
.reader-menu-btn { display: none; }
body[data-reader="1"] .topbar,
body[data-reader="1"] .view-read .controls,
body[data-reader="1"] .chrome-toggle,
body[data-reader="1"] .landscape-crumb,
body[data-reader="1"] .view-read .bottombar { display: none !important; }
body[data-reader="1"] .reader-menu-btn {
  display: inline-flex; align-items: center; gap: 8px; position: absolute; z-index: 7;
  top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px));
  min-height: 48px; padding: 0 18px; border-radius: 24px; cursor: pointer;
  font: 600 1rem var(--f-ui); color: var(--paper); background: rgba(10, 9, 14, 0.55);
  border: 1px solid var(--line); backdrop-filter: blur(6px); opacity: 0.7; transition: opacity 0.2s;
}
body[data-reader="1"] .reader-menu-btn:hover, body[data-reader="1"] .reader-menu-btn:focus-visible { opacity: 1; }
body[data-reader="1"] .reader-menu-btn span { font-size: 1.2em; color: var(--gold); }

/* Menú grande: rejilla de botones amplios centrada */
.sheet.menu-big .sheet-panel {
  left: 50%; right: auto; bottom: auto; top: 50%; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  transform: translate(-50%, -46%) scale(0.98); opacity: 0; border-radius: 16px; transition: transform 0.2s, opacity 0.2s;
}
.sheet.menu-big.is-open .sheet-panel { transform: translate(-50%, -50%); opacity: 1; }
.sheet.menu-big .sheet-grip { display: none; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 4px 0 6px; }
.menu-grid button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 96px;
  padding: 12px; border-radius: 12px; cursor: pointer; font: 500 0.98rem var(--f-ui); color: var(--paper);
  background: var(--ink-3); border: 1px solid var(--line); transition: border-color 0.15s, background 0.15s;
}
.menu-grid button b { font-size: 1.7rem; font-weight: 400; color: var(--gold); line-height: 1; }
.menu-grid button:hover, .menu-grid button:focus-visible { border-color: var(--gold); background: var(--ink-4); }
.menu-grid button[data-m="continue"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.menu-grid button[data-m="continue"] b { color: var(--ink); }

/* Cajón izquierdo de capítulos (lector) */
.sheet.drawer .sheet-panel {
  left: 0; right: auto; top: 0; bottom: 0; width: min(440px, 88vw); max-height: none; height: 100%;
  border-radius: 0 16px 16px 0; transform: translateX(-102%); transition: transform 0.25s ease-out;
  padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-left: calc(18px + env(safe-area-inset-left, 0px));
}
.sheet.drawer.is-open .sheet-panel { transform: translateX(0); }
.sheet.drawer .sheet-grip { display: none; }

/* Aviso «gira el móvil» (no bloquea: se puede seguir en vertical) */
.rotate-hint { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  body[data-reader="1"]:not(.rotate-ok) .rotate-hint {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 300; padding: 24px;
    background: rgba(6, 5, 9, 0.92); color: var(--paper); text-align: center; font-family: var(--f-ui);
  }
}
.rotate-card { display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 320px; }
.rotate-card p { font-family: var(--f-display); font-size: 1.4em; color: var(--gold); }
.rotate-icon { font-size: 64px; animation: rotate-phone 2.4s ease-in-out infinite; }
.rotate-card button { min-height: 48px; padding: 0 20px; border-radius: 24px; border: 1px solid var(--line-strong); background: transparent; color: var(--paper-2); font: inherit; }
@keyframes rotate-phone { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { .rotate-icon { animation: none; transform: rotate(-90deg); } }

/* Suscripción fase 1 (acceso.js): candado de interfaz, apagado por defecto (?suscripcion=1) */
.chapter-row.is-paid .chapter-title { opacity: 0.6; }
.chapter-row.is-paid .chapter-head small { color: var(--gold-2); }
.paywall { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; line-height: 1.45; }
.paywall p { margin: 0; }
.paywall ul { margin: 0; padding-left: 1.2em; color: var(--paper-dim); }
.paywall button { min-height: 48px; border-radius: 12px; }
.paywall .paywall-cta { background: var(--gold-2); color: #1a1408; font-weight: 700; border: 0; font-size: 1.05em; }
.paywall-lib { text-align: center; color: var(--paper-dim); padding: 6px; }

/* Reportar un fallo (reportes.js): botón abajo a la izquierda en el lector y formulario por chips */
.reader-report-btn { display: none; }
body[data-reader="1"] .reader-report-btn {
  display: inline-flex; align-items: center; gap: 6px; position: absolute; z-index: 7;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: calc(12px + env(safe-area-inset-left, 0px));
  min-height: 44px; padding: 0 14px; border-radius: 22px; cursor: pointer;
  font: 600 0.9rem var(--f-ui); color: var(--paper); background: rgba(10, 9, 14, 0.55);
  border: 1px solid var(--line); backdrop-filter: blur(6px); opacity: 0.55; transition: opacity 0.2s;
}
body[data-reader="1"] .reader-report-btn:hover, body[data-reader="1"] .reader-report-btn:focus-visible { opacity: 1; }
body[data-reader="1"] .reader-report-btn span { color: var(--gold); }
.plano-info {
  position: absolute; z-index: 7; top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px)); max-width: min(70vw, 560px); padding: 4px 10px;
  border-radius: 8px; font: 500 0.75rem/1.3 ui-monospace, monospace; color: var(--gold-2);
  background: rgba(10, 9, 14, 0.7); border: 1px solid var(--line); pointer-events: none; user-select: text;
}
.report-form { display: flex; flex-direction: column; gap: 6px; }
.rep-frame { width: 100%; max-height: 22vh; object-fit: contain; border-radius: 10px; background: #000; }
.rep-q { margin: 8px 0 2px; font-weight: 600; }
.rep-q small { font-weight: 400; color: var(--paper-dim); }
.rep-row { display: flex; flex-wrap: wrap; gap: 6px; }
.rep-chip { min-height: 40px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--paper); font: inherit; cursor: pointer; }
.rep-chip.is-on { border-color: var(--gold-2); background: rgba(212, 175, 55, 0.18); color: var(--gold-2); }
.rep-text { width: 100%; box-sizing: border-box; margin-top: 6px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--paper); font: inherit; resize: vertical; }
.rep-actions { display: flex; gap: 8px; margin-top: 8px; }
.rep-actions button { flex: 1; min-height: 48px; border-radius: 12px; }
.rep-send { background: var(--gold-2); color: #1a1408; font-weight: 700; border: 0; }
.rep-send:disabled { opacity: 0.4; }
/* móvil apaisado: la caja de texto ocupa todo el ancho abajo; el botón sube a la esquina superior izquierda */
@media (max-height: 520px) {
  body[data-reader="1"] .reader-report-btn { top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; }
}
