:root {
  --bg: #e8e8e8;
  --card: #ffffff;
  --ink: #111111;
  --muted: #555555;
  --border: #cccccc;
  --ok: #1a7a3a;
  --ok-bg: #d8f5e2;
  --fail: #b01a1a;
  --fail-bg: #fde0e0;
  --btn: #111111;
  --spin: #333;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  height: 100%;
  overflow: hidden;
}
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
}
header.bar {
  flex: 0 0 auto;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
header.bar h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }
header.bar .tag { color: var(--muted); font-size: 0.78rem; }
.sheet-area {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.45rem 0.55rem 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
#preview {
  background: #fff;
  border: 1px solid #bbb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  width: 100%;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 297 / 210;
  max-width: min(100%, calc((100dvh - 210px) * 297 / 210));
}
#preview svg { display: block; width: 100%; height: 100%; }
/* La hoja blanca mantiene exactamente la proporción A4 (antes se estiraba y parecía tener
   márgenes laterales vacíos). */
@supports (width: 1cqw) {
  .sheet-area { container-type: size; }
  #preview {
    width: min(100cqw, 100cqh * 297 / 210);
    height: auto;
    max-width: none; max-height: none;
    aspect-ratio: 297 / 210;
  }
}
.controls {
  flex: 0 0 auto;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 0.55rem 0.7rem 0.7rem;
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
}
.row-gen { display: flex; gap: 0.55rem; margin-bottom: 0.5rem; }
button#btn-generar {
  flex: 1;
  cursor: pointer;
  border: 2px solid #000;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--btn);
  color: #fff;
  letter-spacing: 0.01em;
}
button#btn-generar:active { opacity: 0.88; transform: scale(0.99); }
button#btn-generar:disabled { opacity: 0.55; cursor: wait; }
.row-caps {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}
.cap {
  flex: 1;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 0.72rem 0.8rem;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
}
.cap:disabled { opacity: 0.4; cursor: default; }
.cap.bien {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok);
}
.cap.falla {
  background: var(--fail-bg);
  color: var(--fail);
  border-color: var(--fail);
}
.cap:active:not(:disabled) { transform: scale(0.98); opacity: 0.9; }
.status {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
  min-height: 2.6em;
}
.status strong { color: var(--ink); font-weight: 600; }
.status .ok { color: var(--ok); }
.status .bad { color: var(--fail); }
.flash {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.82);
  color: #fff;
  padding: 0.85rem 1.4rem;
  border-radius: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 40;
}
.flash.show { opacity: 1; }
.spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.62);
  display: none;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  z-index: 5;
  border-radius: 0;
}
.sheet-area { position: relative; }
.spinner-overlay.on { display: flex; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #ddd;
  border-top-color: var(--spin);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-overlay .spinner { width: 54px; height: 54px; border-width: 5px; }
.spin-label {
  background: #fff;
  color: var(--btn, #111);
  border: 2px solid var(--btn, #111);
  border-radius: 12px;
  padding: 0.55rem 1.1rem;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
@media print {
  header.bar, .controls, .flash, .spinner-overlay { display: none !important; }
  .app { display: block; height: auto; overflow: visible; }
  .sheet-area { padding: 0; container-type: normal; display: block; }
  #preview {
    border: none; box-shadow: none;
    width: 297mm; height: 210mm;
    max-width: none; max-height: none;
  }
  @page { size: A4 landscape; margin: 0; }
}

/* ===== Traza unificada: niveles + pantalla de inicio ===== */
body.nivel-facil   { --bg: #eef7f1; --btn: #111111; --accent: #bfe8cf; }
body.nivel-medio   { --bg: #e4eaf0; --btn: #1a3a5c; --ink: #142433; --accent: #bcd9f2; }
body.nivel-dificil { --bg: #f1ecf7; --btn: #4b2a66; --accent: #d9c8f0; }
body.nivel-experto { --bg: #f7efe6; --btn: #7a3a10; --accent: #f2d2b6; }
header.bar { align-items: center; }
body[class*="nivel-"] header.bar { background: var(--accent); }
a.back {
  display: inline-flex; align-items: center; gap: 0.3rem;
  text-decoration: none; color: #111; font-weight: 700; font-size: 1.05rem;
  background: #fff; border: 2px solid #111; border-radius: 999px;
  padding: 0.45rem 1rem; margin-right: 0.4rem;
}
a.back:active { transform: scale(0.97); }

body.home { background: #f7f5f0; overflow: auto; }
.home-wrap {
  min-height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 2.2rem calc(2rem + env(safe-area-inset-bottom));
}
.home-wrap h1 { font-size: 2.6rem; margin: 0 0 0.3rem; letter-spacing: 0.04em; }
.home-wrap p.sub { margin: 0 0 1.8rem; color: #666; font-size: 1.1rem; }
.levels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem;
  width: min(100%, 980px);
}
.level {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  min-height: 230px; border-radius: 28px; text-decoration: none; color: #1b1b1b;
  border: 3px solid rgba(0,0,0,0.12); box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  transition: transform 0.1s;
}
.level:active { transform: scale(0.98); }
.level .ico { font-size: 3.2rem; line-height: 1; margin-bottom: 0.5rem; }
.level .name { font-size: 2.4rem; font-weight: 800; }
.level .info { font-size: 1.05rem; color: #444; margin-top: 0.35rem; }
.level.facil   { background: #bfe8cf; }
.level.medio   { background: #bcd9f2; }
.level.dificil { background: #d9c8f0; }
.level.experto { background: #f2d2b6; }

/* ===== v13: capa de trazado ===== */
body.trazado { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
body.trazado .sheet-area { touch-action: none; }
#preview { position: relative; }
#trace {
  position: absolute; left: 0; top: 0;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  z-index: 3; cursor: crosshair;
}
.trace-stats { margin-left: auto; display: flex; gap: 0.9rem; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.trace-stats span { background: #fff; border: 2px solid rgba(0,0,0,0.25); border-radius: 999px; padding: 0.25rem 0.8rem; }
.trace-stats .ts-h b { color: var(--fail); }
.row-gen button.tool {
  flex: 0 0 auto; cursor: pointer; border: 2px solid var(--btn, #111); border-radius: 14px;
  padding: 0.95rem 1.05rem; font-size: 1.15rem; font-weight: 700; background: #fff; color: var(--btn, #111);
  min-width: 7.2rem;
}
.row-gen button.tool.strong { background: var(--accent, #eee); }
.row-gen button.tool.icon { min-width: 4rem; font-size: 1.4rem; padding: 0.8rem 0.9rem; }
.row-gen button.tool:active { transform: scale(0.98); opacity: 0.9; }
.tmodal { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: none; align-items: center; justify-content: center; z-index: 50; }
.tmodal.on { display: flex; }
.tbox { background: #fff; border-radius: 20px; padding: 1.3rem 1.6rem 1.2rem; min-width: min(92vw, 520px); box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.tbox h2 { margin: 0 0 0.9rem; font-size: 1.5rem; }
.tbox .sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.tbox .sum div { background: #f4f4f4; border-radius: 14px; padding: 0.7rem; text-align: center; }
.tbox .sum span { display: block; color: #555; font-size: 0.95rem; }
.tbox .sum b { display: block; font-size: 2rem; margin-top: 0.2rem; }
.tbox .trow { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.tbox .tbtn { flex: 1; font-size: 1.15rem; font-weight: 700; padding: 0.8rem; border-radius: 14px; border: 2px solid #111; background: #fff; cursor: pointer; }
.tbox .srow { display: flex; align-items: center; gap: 0.6rem; margin: 0.6rem 0; }
.tbox .srow span { width: 7rem; font-weight: 700; font-size: 1.1rem; }
.tbox .seg { flex: 1; font-size: 1.1rem; padding: 0.8rem; border-radius: 12px; border: 2px solid #999; background: #fff; cursor: pointer; }
.tbox .seg.sel { border-color: #111; background: #111; color: #fff; font-weight: 700; }
.tbox .snote { color: #555; font-size: 0.9rem; margin: 0.6rem 0 0.2rem; }
@media print { #trace, .trace-stats, .tmodal { display: none !important; } }

/* ===== v14: pantalla completa, control de salida, Historial ===== */
.row-gen button.tool.fs { min-width: 11rem; }
@media (max-width: 1100px) {
  .row-gen button.tool { min-width: 6.2rem; padding: 0.95rem 0.7rem; font-size: 1.05rem; }
  .row-gen button.tool.fs { min-width: 9.6rem; }
}
body.immersive header.bar, body.immersive .controls, body.immersive .flash { display: none !important; }
body.immersive .sheet-area {
  position: fixed; inset: 0; z-index: 30; padding: 0; margin: 0;
  background: #000; display: flex; align-items: center; justify-content: center;
  touch-action: none; overscroll-behavior: none;
}
body.immersive #preview { border: none; box-shadow: none; }
body.immersive .app { height: 100%; }
.fs-exit {
  position: fixed; top: 10px; right: 10px; width: 84px; height: 84px; z-index: 45;
  display: none; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; opacity: 0; transition: opacity 0.35s;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
body.immersive .fs-exit { display: flex; pointer-events: none; }
body.immersive .fs-exit.on { opacity: 1; pointer-events: auto; }
.fs-exit svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.fs-exit circle { fill: none; stroke-width: 6; }
.fs-exit circle.bg { stroke: rgba(255,255,255,0.25); }
.fs-exit circle.ring { stroke: #fff; stroke-dasharray: 213.6; stroke-dashoffset: 213.6; stroke-linecap: round; }
.fs-exit span { position: relative; font-weight: 800; font-size: 1rem; text-align: center; line-height: 1.05; }
.fs-exit small { display: block; font-weight: 500; font-size: 0.56rem; letter-spacing: -0.02em; opacity: 0.85; }
.kidsel, .kidname { flex: 1; font-size: 1.05rem; padding: 0.6rem; border-radius: 10px; border: 2px solid #999; background: #fff; }
.kidname { -webkit-user-select: text; user-select: text; }
a.hist-link {
  margin-top: 1.6rem; display: inline-block; text-decoration: none; color: #111; font-weight: 800; font-size: 1.3rem;
  background: #fff; border: 3px solid rgba(0,0,0,0.15); border-radius: 18px; padding: 0.9rem 1.8rem;
}
body.historial { background: #f7f5f0; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
body.historial header.bar { position: sticky; top: 0; z-index: 2; }
.hist-wrap { padding: 0.9rem 1.1rem 2rem; }
.hist-filters { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.9rem; }
.hist-filters label { font-weight: 700; font-size: 1.05rem; display: flex; gap: 0.5rem; align-items: center; }
.hist-filters select { font-size: 1.05rem; padding: 0.55rem 0.7rem; border-radius: 10px; border: 2px solid #999; background: #fff; }
.hbtn { font-size: 1.05rem; font-weight: 700; padding: 0.7rem 1.2rem; border-radius: 12px; border: 2px solid #111; background: #fff; cursor: pointer; margin-left: auto; }
.charts { display: grid; grid-template-columns: 1fr; gap: 0.9rem; margin-bottom: 1rem; }
.charts figure.chart { max-width: 900px; }
figure.chart { margin: 0; background: #fff; border-radius: 16px; padding: 0.7rem 0.8rem 0.3rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
figure.chart figcaption { font-size: 0.95rem; color: #333; margin-bottom: 0.2rem; }
figure.chart .leg { display: block; color: #555; font-size: 0.85rem; margin-top: 0.15rem; }
figure.chart .leg i { display: inline-block; width: 18px; height: 4px; vertical-align: middle; margin: 0 0.25rem 0 0.7rem; border-radius: 2px; }
figure.chart .leg i.lt { background: #1565c0; } figure.chart .leg i.lh { background: #d32f2f; }
figure.chart .leg i.sq { width: 11px; height: 11px; border-radius: 3px; } figure.chart .leg i.sq.bien { background: #2e7d32; } figure.chart .leg i.sq.falla { background: #c62828; }
figure.chart svg { width: 100%; height: auto; display: block; }
figure.chart .grid { stroke: #e6e6e6; stroke-width: 1; }
figure.chart .ax { font-size: 16px; fill: #555; } figure.chart .ax.t { fill: #1565c0; } figure.chart .ax.h { fill: #d32f2f; }
figure.chart .lt { fill: none; stroke: #1565c0; stroke-width: 3; } figure.chart .lh { fill: none; stroke: #d32f2f; stroke-width: 3; stroke-dasharray: 7 5; }
figure.chart .dt { fill: #1565c0; } figure.chart .dh { fill: #d32f2f; }
figure.chart .vv.bien { fill: #2e7d32; } figure.chart .vv.falla { fill: #c62828; } figure.chart .vv.none { fill: #ccc; }
.hist-list table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; font-size: 0.98rem; }
.hist-list th, .hist-list td { padding: 0.55rem 0.6rem; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; }
.hist-list th { background: #eee; font-size: 0.9rem; }
.hist-list td.fic small { color: #666; }
.hist-list .del { font-size: 0.95rem; padding: 0.5rem 0.8rem; border-radius: 10px; border: 2px solid #b01a1a; color: #b01a1a; background: #fff; cursor: pointer; }
.v-bien { color: #1a7a3a; font-weight: 700; } .v-falla { color: #b01a1a; font-weight: 700; } .v-none { color: #888; }
.empty { color: #666; font-size: 1rem; padding: 0.6rem 0.2rem; }

/* ===== v15: zonas seguras (app de inicio con barra translúcida), pantalla completa robusta,
   salida siempre visible, diagnóstico, Mis circuitos, impresión A4 a prueba de iPad ===== */
header.bar { padding-top: max(0.55rem, env(safe-area-inset-top)); padding-left: max(0.9rem, env(safe-area-inset-left)); padding-right: max(0.9rem, env(safe-area-inset-right)); }
.controls { padding-bottom: max(0.4rem, env(safe-area-inset-bottom)); }
.cap.alt { background: #fff; color: var(--btn, #111); border-color: var(--btn, #111); border-radius: 16px; padding: 0.8rem; }
.cap.alt.fsb { background: var(--accent, #eee); }
html.imm, html.imm body { background: #000 !important; overflow: hidden !important; }
body.immersive .sheet-area {
  position: fixed !important; left: 0; top: 0; right: auto; bottom: auto;
  width: 100vw; height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
  margin: 0; z-index: 30; background: #000; box-sizing: border-box;
}
/* margen negro reservado para el botón Salir: a la derecha si la pantalla es más ancha que A4, arriba si no */
body.immersive.gut-r .sheet-area { padding-right: calc(68px + env(safe-area-inset-right)) !important; }
body.immersive.gut-t .sheet-area { padding-top: calc(64px + env(safe-area-inset-top)) !important; }
body.immersive .spinner-overlay { z-index: 31; }
body.immersive .fs-exit { display: flex; pointer-events: auto; opacity: 0.45; }
body.immersive .fs-exit.on { opacity: 1; }
.fs-exit { width: 58px; height: 58px; top: calc(4px + env(safe-area-inset-top)); right: calc(5px + env(safe-area-inset-right)); background: rgba(255,255,255,0.16); border: 2px solid rgba(255,255,255,0.55); }
body.immersive.gut-t .fs-exit { top: calc(3px + env(safe-area-inset-top)); }
.fs-exit span { font-size: 1.25rem; line-height: 1; }
.fs-exit small { font-size: 0.62rem; letter-spacing: 0; font-weight: 700; }
.fs-exit circle { stroke-width: 7; }
.diag {
  display: none; position: fixed; left: calc(6px + env(safe-area-inset-left)); bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 70;
  max-width: min(96vw, 900px); background: rgba(255,255,230,0.94); color: #111; border: 1px solid #aa8; border-radius: 8px;
  font: 11px/1.35 ui-monospace, Menlo, monospace; padding: 4px 7px; pointer-events: none; white-space: normal;
}
.diag.on { display: block; }
.cmodal .cbox { width: min(96vw, 1000px); max-height: 90dvh; display: flex; flex-direction: column; }
.cmodal .cbox h2 small { color: #666; font-weight: 500; font-size: 1rem; }
.clist { overflow-y: auto; -webkit-overflow-scrolling: touch; display: grid; grid-template-columns: repeat(auto-fill, minmax(410px, 1fr)); gap: 0.7rem; padding: 0.2rem; }
.ccard { display: flex; gap: 0.6rem; background: #f6f6f6; border-radius: 14px; padding: 0.55rem; border: 2px solid transparent; }
.ccard.cur { border-color: var(--btn, #111); }
.cthumb-btn { padding: 0; border: 1px solid #ccc; border-radius: 8px; background: #fff; cursor: pointer; flex: 0 0 auto; height: fit-content; }
.cthumb { display: block; border-radius: 8px; height: auto; }
.cinfo { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.cinfo b { font-size: 1.1rem; }
.cinfo small { color: #555; font-size: 0.85rem; }
.cinfo .cren { flex: 0 0 auto; padding: 0.4rem; font-size: 1rem; }
.cbtns { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.cbtns .seg, .cinfo .seg { flex: 0 0 auto; padding: 0.45rem 0.6rem; font-size: 0.92rem; border-radius: 10px; text-decoration: none; color: #111; border: 2px solid #999; background: #fff; }
.cbtns .seg.sel { background: var(--btn, #111); border-color: var(--btn, #111); color: #fff; font-weight: 700; }
.cbtns .seg.del { color: #b01a1a; border-color: #b01a1a; }
.status .cname { color: var(--btn, #111); }
.tbox h2 small { font-size: 1rem; color: #666; font-weight: 500; }
.tbox .tbtn.big { flex: 1.3; background: var(--accent, #eee); }
figure.chart .ax.p { fill: #2e7d32; font-size: 13px; }
figure.chart .leg .pk { color: #2e7d32; font-weight: 700; margin-left: 0.7rem; }
.cthumb-h { margin-bottom: 0.4rem; }
.cthumb-h .cthumb { border: 1px solid #ccc; background: #fff; }
.hist-list a.clink { color: #1565c0; font-weight: 700; }

/* Impresión del navegador (ordenador). En iPad se imprime un PDF A4 horizontal generado en js/imprimir.js. */
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body, html.imm, html.imm body { background: #fff !important; height: auto !important; overflow: visible !important; }
  header.bar, .controls, .flash, .spinner-overlay, #trace, .trace-stats, .tmodal, .fs-exit, .diag { display: none !important; }
  .app { display: block !important; height: auto !important; max-height: none !important; }
  .sheet-area, body.immersive .sheet-area {
    position: relative !important; display: block !important; container-type: normal !important;
    width: 297mm !important; height: 209mm !important; padding: 0 !important; margin: 0 !important; background: #fff !important; overflow: hidden !important;
  }
  #preview, body.immersive #preview {
    position: absolute !important; left: 0 !important; top: 0 !important; margin: 0 !important; transform: none !important;
    width: 297mm !important; height: 209mm !important; max-width: none !important; max-height: none !important; aspect-ratio: auto !important;
    border: none !important; box-shadow: none !important; background: #fff !important;
  }
}
.trace-hint { position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; border: 4px solid #1565c0; pointer-events: none; z-index: 4; opacity: 0; }
.trace-hint.on { animation: thint 0.8s ease-out 2; }
@keyframes thint { 0% { transform: scale(0.4); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
@media print { .trace-hint { display: none !important; } }

/* ---------- v17: carpeta del nivel ---------- */
body.view-folder .sheet-area, body.view-folder .controls, body.view-folder #trace-stats { display: none !important; }
body.view-trace .folder { display: none !important; }
.folder { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0.9rem 1.1rem calc(1.4rem + env(safe-area-inset-bottom)); }
.fgen { display: flex; gap: 1rem; align-items: stretch; flex-wrap: wrap; background: #fff; border-radius: 20px; padding: 0.9rem; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
button#btn-generar.fgen-btn { flex: 0 0 auto; min-width: 15rem; font-size: 1.45rem; font-weight: 800; border-radius: 18px; padding: 1.1rem 1.4rem; background: #111; color: #fff; border: none; cursor: pointer; }
button#btn-generar.fgen-btn.busy, button#btn-generar.fgen-btn:disabled { background: #666; }
.fmodes { flex: 1 1 30rem; min-width: 0; }
.flabel { display: block; font-weight: 700; color: #555; margin-bottom: 0.35rem; }
.modes { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.mbtn { flex: 1 1 8.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 0.45rem 0.4rem 0.5rem; border-radius: 14px; border: 2px solid #bbb; background: #fff; font-size: 0.95rem; font-weight: 600; cursor: pointer; color: #111; }
.mbtn svg { width: 56px; height: 32px; }
.mbtn.sel { border-color: #111; background: #111; color: #fff; }
.mbtn.sel svg path[stroke="#fff"] { stroke: #111; }
.mbtn.sel svg path[stroke="#222"] { stroke: #fff; }
.mdesc { margin: 0.45rem 0 0; color: #444; font-size: 0.98rem; }
.gstatus { min-height: 1.4rem; margin: 0.55rem 0.2rem 0; font-size: 1rem; }
.gstatus .ok { color: var(--ok); font-weight: 700; } .gstatus .bad { color: var(--fail); font-weight: 700; }
.ftitle { font-size: 1.3rem; margin: 0.9rem 0.2rem 0.6rem; } .ftitle small { color: #666; font-weight: 500; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0.8rem; }
.fcard { background: #fff; border-radius: 18px; padding: 0.6rem; display: grid; grid-template-columns: 150px 1fr; grid-template-rows: auto auto; gap: 0.3rem 0.7rem; border: 2px solid transparent; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.fcard.new { border-color: #1a7a3a; }
.fthumb { grid-row: 1; padding: 0; border: 1px solid #ddd; border-radius: 10px; background: #fff; overflow: hidden; cursor: pointer; }
.fthumb .cthumb { display: block; width: 100%; height: auto; }
.finfo { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.finfo .fname { font-size: 1.15rem; } .finfo small { color: #555; font-size: 0.9rem; }
.frename { display: flex; gap: 0.3rem; } .frename input { min-width: 0; flex: 1; font-size: 1rem; padding: 0.35rem; }
.fbtns { grid-column: 1 / -1; display: flex; gap: 0.45rem; align-items: center; }
.fplay { flex: 1.3; font-size: 1.15rem; font-weight: 800; padding: 0.7rem; border-radius: 14px; background: #111; color: #fff; border: none; cursor: pointer; }
.fevol { flex: 1; text-align: center; font-size: 1.05rem; font-weight: 700; padding: 0.7rem 0.4rem; border-radius: 14px; border: 2px solid #111; color: #111; text-decoration: none; background: #fff; }
.fsmall { display: flex; gap: 0.3rem; }
.fsmall .seg, .frename .seg { font-size: 1rem; padding: 0.55rem 0.65rem; border-radius: 10px; border: 2px solid #bbb; background: #fff; cursor: pointer; }
.fsmall .seg.del { color: #b01a1a; }
.fempty { color: #555; font-size: 1.1rem; background: #fff; border-radius: 16px; padding: 1.2rem; }
.mchip { display: inline-block; align-self: flex-start; font-size: 0.82rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 99px; background: #eee; color: #222; }
.mchip.m-paredes { background: #e3ecff; } .mchip.m-linea { background: #fff1d6; } .mchip.m-doble { background: #e9e0ff; } .mchip.m-sombra { background: #e6e6e6; color: #444; }
.sumlines { font-size: 1.05rem !important; color: #222 !important; }
/* historial: imágenes de los intentos */
.timg { width: 120px; }
.ithumb, .gcard { padding: 0; border: 1px solid #ccc; border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden; }
.ithumb img { display: block; width: 110px; height: auto; min-height: 30px; }
.noimg { color: #999; } .noimg.big { display: block; width: 220px; height: 155px; line-height: 155px; text-align: center; background: #f4f4f4; }
.gallery h2 { font-size: 1.2rem; margin: 0.4rem 0 0.5rem; }
.gstrip { display: flex; gap: 0.6rem; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 0.5rem; margin-bottom: 0.8rem; }
.gcard { flex: 0 0 auto; display: flex; flex-direction: column; text-align: left; font-size: 0.92rem; color: #111; }
.gcard img { display: block; width: 220px; height: auto; border-bottom: 1px solid #eee; }
.gcard span { padding: 0.35rem 0.5rem; }
.ibox { width: min(96vw, 1100px); max-height: 94dvh; overflow-y: auto; }
.ilarge { display: block; width: 100%; height: auto; border: 1px solid #ccc; border-radius: 8px; }
.ibox h2 small { color: #666; font-weight: 500; font-size: 1rem; }
