/* ==========================================================================
   GUÍA — PWA · hoja de estilos de la app real
   Sistema de diseño Material Design 3, generado desde las semillas propias de
   GUÍA (primary = acento cian #0e7490, tertiary = dorado de valoración
   #f5b301, error = rojo #b42318). Paleta tonal HSL con desaturación en los
   extremos (aproximación sin dependencias — la app es cero-deps en runtime),
   cada rol texto/fondo verificado contra WCAG AA con la fórmula real de
   contraste relativo, no a ojo. Ver /Users/imaginacion/.claude/plans/
   refactored-baking-gray.md para la ramp de 13 tonos completa y la
   verificación de cada par.
   Estructura basada en los wireframes de /wireframes (solo como referencia).
   ========================================================================== */

:root {
  /* ---- Color: roles M3 (esquema claro) ----------------------------------- */
  --primary: #107f9e;                 /* 4.61:1 sobre blanco */
  --on-primary: #ffffff;
  --primary-container: #e3ebed;
  --on-primary-container: #0e2025;    /* 13.88:1 */

  --secondary-container: #e7e9e9;
  --on-secondary-container: #171b1c;  /* 14.24:1 */

  --tertiary: #aa8218;
  --tertiary-container: #eceae4;
  --on-tertiary-container: #241e0f;   /* 13.77:1 */

  --error: #a4281e;
  --on-error: #ffffff;                /* 7.24:1 */
  --error-container: #ece5e4;
  --on-error-container: #231110;      /* 14.58:1 */

  /* Semántica propia de GUÍA (divisas) — no cubierta por roles M3 base */
  --up: #067647; --up-container: #ecfdf3;     /* 5.40:1 */
  --down: #b42318; --down-container: #fef3f2; /* 6.05:1 */

  --surface: #fafaf9;                 /* fondo de página — marfil GUÍA, desviación deliberada de neutral99 puro */
  --surface-container-low: #f1f5f5;   /* elevación 1: superficie + primary 4% */
  --surface-container: #e7f0f2;       /* elevación 2: superficie + primary 8% */
  --surface-container-high: #deebee;  /* elevación 3: superficie + primary 12% */
  --surface-container-highest: #d5e6ea; /* elevación 4: superficie + primary 16% */

  --on-surface: #191a1a;              /* texto primario — 17.0:1 */
  --on-surface-variant: #434e51;      /* texto secundario "muted" — 8.36:1 */
  --on-surface-variant-2: #57666b;    /* texto terciario "faint" — 5.82:1 (antes 2.47:1, fallaba AA) */

  --outline: #708489;                 /* bordes funcionales — 3.83:1 (umbral no-texto) */
  --outline-variant: #eaecf0;         /* divisores decorativos, sin requisito de contraste */

  --inverse-surface: #191a1a;         /* toast/snackbar: siempre opuesta al tema activo */
  --inverse-on-surface: #f1f1f1;
  --inverse-primary: #76d9f4;

  /* Alias de compatibilidad: nombres antiguos usados en estilos inline de
     app.js (ver grep de verificación) → apuntan a los roles M3 nuevos, así
     el cambio de sistema se propaga sin tocar la lógica de las vistas. */
  --ink: var(--on-surface);
  --ink-2: var(--on-surface-variant);
  --ink-3: var(--on-surface-variant-2);
  --line: var(--outline-variant);
  --accent: var(--primary);
  --accent-soft: var(--primary-container);
  --up-soft: var(--up-container);
  --down-soft: var(--down-container);

  /* ---- Espaciado (grid de 4/8, sin cambios) -------------------------------- */
  --s1: 8px; --s2: 12px; --s3: 16px; --s4: 24px; --s5: 32px;

  /* ---- Forma: escala M3 con nombres oficiales ------------------------------ */
  --shape-xs: 4px; --shape-sm: 8px; --shape-md: 12px; --shape-lg: 16px; --shape-xl: 28px; --shape-full: 9999px;
  --r: var(--shape-md); /* compat: --r se usaba directo en algunas reglas */

  /* ---- Elevación: sombra + tinte de superficie combinados ------------------ */
  --shadow-1: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-2: 0 2px 8px rgba(16,24,40,.08), 0 4px 16px rgba(16,24,40,.06);
  --shadow-3: 0 8px 24px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.08);
  --shadow-4: 0 16px 40px rgba(16,24,40,.18);
  --shadow: var(--shadow-1); --shadow-lg: var(--shadow-3); /* compat */

  /* ---- Movimiento: curvas y duraciones estándar M3 -------------------------- */
  --ease-standard: cubic-bezier(.2,0,0,1);
  --ease-emphasized: cubic-bezier(.3,0,0,1);
  --dur-short: 100ms; --dur-medium: 220ms; --dur-long: 350ms;

  --tabbar-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--on-surface);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ---- Foco visible (M3: obligatorio para teclado/switch-access) ---------- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--shape-xs);
}

/* ---- Shell ------------------------------------------------------------ */
/* height duplicada a propósito: dvh donde exista, vh como fallback (iOS<=15.3, Chrome<108).
   El orden importa: vh primero, dvh después (la última válida gana). */
#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; outline: none; }
/* no-scroll (dialer): flex column para que el appbar tome su alto intrínseco y
   el contenido restante (.dial) reciba EXACTAMENTE el espacio sobrante, en vez
   de un height:100% que ignoraba al appbar y desbordaba por debajo del pliegue. */
#view.no-scroll { overflow: hidden; display: flex; flex-direction: column; }
#view.no-scroll > .dial { flex: 1; min-height: 0; height: auto; }

/* Solo para lectores de pantalla: fuera de la vista pero en el árbol de
   accesibilidad (nada de display:none, que lo sacaría también de ahí). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- Iconos ------------------------------------------------------------ */
svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
svg.ic.sm { width: 16px; height: 16px; }
svg.ic.lg { width: 26px; height: 26px; }

/* ---- Tab bar (Navigation Bar M3: indicador píldora tras el ícono activo) - */
.tabbar {
  flex: 0 0 auto; display: flex;
  background: rgba(255,255,255,.92); /* fallback --surface para WebViews sin color-mix */
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--outline-variant);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--on-surface-variant); text-decoration: none; transition: color var(--dur-short) var(--ease-standard);
}
.tabbar a .tab-ind {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 28px; border-radius: var(--shape-full);
  transition: background var(--dur-short) var(--ease-standard);
}
.tabbar a.active { color: var(--on-surface); }
.tabbar a.active .tab-ind { background: var(--secondary-container); }
.tabbar a .ic { width: 22px; height: 22px; }
.tabbar a.active .ic { stroke-width: 2.2; }

/* ---- App bar (tintada a surface-container, como los top app bars M3) ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s2);
  padding: calc(env(safe-area-inset-top) + 12px) var(--s3) 12px;
  background: rgba(241,245,245,.88); /* fallback --surface-container-low */
  background: color-mix(in srgb, var(--surface-container-low) 88%, transparent);
  backdrop-filter: blur(12px);
}
.appbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; } /* Title Large M3, peso GUÍA */
.appbar .sub { font-size: 12px; color: var(--on-surface-variant-2); margin: 0; }
.appbar .grow { flex: 1; }
.iconbtn {
  width: 44px; height: 44px; border-radius: var(--shape-full); border: none; cursor: pointer;
  display: inline-grid; place-items: center;
  background: var(--surface-container-low); color: var(--on-surface);
  box-shadow: var(--shadow-1);
  position: relative; text-decoration: none;
  transition: transform var(--dur-short) var(--ease-standard), background var(--dur-short) var(--ease-standard);
}
.iconbtn:active { transform: scale(.94); background: var(--surface-container-high); }
.iconbtn .badge {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--error); color: var(--on-error);
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface);
}

/* ---- Contenido --------------------------------------------------------- */
.page { padding: 0 var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s2); }

/* Elevated card M3: sin borde, la elevación la da tinte + sombra */
.card {
  background: var(--surface-container-low);
  border-radius: var(--shape-lg); padding: var(--s3);
  box-shadow: var(--shadow-1);
}
.card.tap {
  cursor: pointer; text-decoration: none; color: inherit; display: block;
  transition: transform var(--dur-short) var(--ease-standard), box-shadow var(--dur-short) var(--ease-standard);
}
.card.tap:active { transform: scale(.985); box-shadow: var(--shadow-1); } /* pressed: la elevación "se asienta" */

.row { display: flex; align-items: center; gap: var(--s2); }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--s2); }

/* ---- Tipografía: roles M3, mismos nombres de clase que ya usa app.js ---- */
h2.section { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--on-surface-variant-2); margin: var(--s2) 0 2px; } /* Label Medium */
.muted { color: var(--on-surface-variant); } .faint { color: var(--on-surface-variant-2); }
.small { font-size: 14px; } .xs { font-size: 12px; } /* Body Medium / Body Small */
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
p { margin: 0; }
/* Display: números "hero" (precio de divisa, countdown, rating) — unifica 3
   tamaños ad hoc previos en un solo rol reutilizable. */
.display { font-size: 36px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
/* Headline: H1 de pantallas completas (splash, gates de instalación/update) */
/* Title: títulos de tarjeta/sección con énfasis medio */
.title { font-size: 17px; font-weight: 700; }

/* ---- Botones: Filled / Outlined / Text / Tonal (M3) ---------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--outline); background: var(--surface); color: var(--primary);
  font: 600 14px/1 inherit; padding: 13px 18px; border-radius: var(--shape-sm);
  cursor: pointer; text-decoration: none;
  transition: transform var(--dur-short) var(--ease-standard), background var(--dur-short) var(--ease-standard);
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); } /* Filled */
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; } /* Text button */
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: var(--shape-xs); }

/* Táctil sólido: elimina el retraso/zoom de doble-tap sin bloquear el scroll
   (manipulation, NO none). Callout/selección desactivados en teclas y dialer. */
.key, .btn, .li, .tabbar a, .iconbtn, .segment button, .callbtn { touch-action: manipulation; }
.key, .callbtn, .dial .display { -webkit-user-select: none; user-select: none; }

/* ---- Tags / segmentado ---- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--shape-full); font-size: 11.5px; font-weight: 600; background: var(--surface-container-low); border: 1px solid var(--outline-variant); color: var(--on-surface-variant); }
.tag.accent { background: var(--primary-container); border-color: transparent; color: var(--on-primary-container); }
.tag.up { background: var(--up-container); border-color: transparent; color: var(--up); }
.tag.down { background: var(--down-container); border-color: transparent; color: var(--down); }

.segment { display: flex; background: var(--surface-container-low); border-radius: var(--shape-sm); padding: 3px; }
.segment button {
  flex: 1; border: none; background: none; padding: 9px 4px; border-radius: var(--shape-xs);
  font: 600 13.5px inherit; color: var(--on-surface-variant); cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.segment button.active { background: var(--secondary-container); color: var(--on-secondary-container); }

/* ---- Listas ------------------------------------------------------------ */
.list { background: var(--surface-container-low); border-radius: var(--shape-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.li { display: flex; align-items: center; gap: var(--s2); padding: 14px var(--s3); text-decoration: none; color: inherit; border: none; background: none; width: 100%; font: inherit; text-align: left; cursor: pointer; transition: background var(--dur-short) var(--ease-standard); }
.li + .li { border-top: 1px solid var(--outline-variant); }
.li .lead { width: 38px; height: 38px; border-radius: var(--shape-sm); background: var(--surface-container); border: none; display: grid; place-items: center; color: var(--on-surface-variant); flex: 0 0 auto; }
.li:active { background: var(--surface-container); }
div.li { cursor: default; } div.li:active { background: none; }

/* ---- Formularios -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%; border: 1.5px solid var(--outline); border-radius: var(--shape-sm); background: var(--surface);
  font-size: 16px; /* iOS hace zoom si el input enfocado es <16px */
}
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 96px; resize: vertical; }

/* ---- Switch (M3: track outlined cuando está apagado) --------------------- */
.switch { position: relative; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: var(--shape-full); background: var(--surface-container-high); border: 1.5px solid var(--outline); transition: background var(--dur-short) var(--ease-standard), border-color var(--dur-short) var(--ease-standard); }
.switch .track::after { content: ""; position: absolute; top: 2.5px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--outline); box-shadow: 0 1px 3px rgba(16,24,40,.25); transition: transform var(--dur-short) var(--ease-standard), background var(--dur-short) var(--ease-standard); }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(19px); background: var(--on-primary); }

/* ---- Banner de sesión --------------------------------------------------- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  background: var(--surface-container-low); border-radius: var(--shape-lg);
  padding: 12px var(--s3); box-shadow: var(--shadow-1);
}

/* ---- Dialer (Móviles) --------------------------------------------------- */
.dial { display: flex; flex-direction: column; height: 100%; padding: 0 var(--s4) var(--s3); }
.dial-head { display: flex; justify-content: flex-end; padding-top: 4px; }
.dial-head .tag { text-decoration: none; }
.dial .display { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 0; }
.dial .number { font-size: clamp(24px, 9vw, 34px); font-weight: 700; letter-spacing: .5px; min-height: 44px; display: flex; align-items: baseline; gap: 10px; }
.dial .number .cc { font-size: 22px; color: var(--on-surface-variant-2); font-weight: 600; }
/* Ocho huecos, agrupados 2·3·3 como el formato final. Todos con el MISMO ancho
   (dígito o guion) para que el número no se descoloque al teclear. */
.dial .slots { display: inline-flex; gap: 10px; }
.dial .slots .grp { display: inline-flex; }
.dial .slots b, .dial .slots i {
  display: inline-block; min-width: .62em; text-align: center;
  font-style: normal; font-variant-numeric: tabular-nums;
}
.dial .slots b { font-weight: 700; }
/* El hueco se DIBUJA en vez de escribirse: un guion tipográfico a 34 px sale
   larguísimo y se comía el ritmo de los grupos. La barra va bajo la línea base
   y ocupa poco más de medio hueco. */
.dial .slots i { position: relative; height: 1em; }
.dial .slots i::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: .12em;
  height: 3px; border-radius: 2px; background: var(--outline);
}
.dial .slots i.now::after { background: var(--primary); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dial .hint { font-size: 12.5px; color: var(--on-surface-variant-2); }

/* Recientes: reconsultar sale de la caché (sin red ni cuota), así que van a mano
   en vez de escondidos tras el icono de historial. */

/* El display nunca se comprime a cero: sin este mínimo, en pantalla corta su
   contenido se solapaba con la cuota y con los recientes. Quien cede espacio es
   el teclado — ver el bloque @media (max-height: 730px) más abajo, que va
   DESPUÉS de .pad/.key a propósito: misma especificidad, gana el último. */
.dial .display { min-height: 74px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; justify-items: center; padding: var(--s2) 0; }
.key {
  width: min(72px, 18vw); aspect-ratio: 1; border-radius: 50%;
  border: none; background: var(--surface-container-low); box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; font: inherit; color: var(--on-surface); transition: transform .08s, background .08s;
}
.key:active { transform: scale(.92); background: var(--surface-container-high); }
.key .d { font-size: 24px; font-weight: 600; line-height: 1.1; }
.key .l { font-size: 8.5px; letter-spacing: 2px; color: var(--on-surface-variant-2); height: 10px; font-weight: 600; }
.key.blank { visibility: hidden; }
/* Borrar: plano y sin sombra (es secundaria frente a los dígitos), pero con
   superficie propia — el borde punteado de antes no correspondía a ningún rol
   M3 y leía como "campo vacío" más que como botón. */
.key.fn { background: var(--surface-container-low); border: none; box-shadow: none; color: var(--on-surface-variant); }
.key.fn.off { opacity: .3; }        /* sin nada que borrar */
/* El botón de buscar va centrado de verdad, no "centrado entre lo que haya":
   por eso el hueco de la derecha existe y está vacío. Con `space-between` y un
   solo botón al lado, el de buscar se iría a un lado y el pulgar dejaría de
   encontrarlo donde lo dejó. */
.callrow { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding-top: 4px; }
.callside {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none;
  min-width: 64px; padding: 6px 4px; border-radius: 12px;
  color: var(--on-surface-variant); font-size: 11.5px; font-weight: 600;
}
.callside .ic { width: 20px; height: 20px; }
.callside:active { background: var(--surface-container-high); }
.callside.ghost { pointer-events: none; }
.callbtn {
  width: 66px; height: 66px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: var(--on-primary); display: grid; place-items: center;
  box-shadow: var(--shadow-3); transition: transform var(--dur-short) var(--ease-standard);
}
.callbtn:active { transform: scale(.92); }
.callbtn .ic { width: 26px; height: 26px; }
/* Número incompleto: atenuado pero PULSABLE — al tocarlo dice qué falta. Un
   botón deshabilitado de verdad no explica nada y se ignora. */
.callbtn.off { background: var(--surface-container-high); color: var(--on-surface-variant-2); box-shadow: none; }
.quota { position: absolute; right: var(--s3); }

/* ---- Divisas ------------------------------------------------------------ */
.ccy { flex: 0 0 auto; width: 42px; height: 42px; border-radius: var(--shape-sm); background: var(--surface-container); border: none; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; color: var(--on-surface); }
.spark { display: block; width: 100%; height: 48px; }
.spark polyline { fill: none; stroke: var(--primary); stroke-width: 2; }
.spark .area { fill: var(--primary); opacity: .1; stroke: none; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 700; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.flat { color: var(--on-surface-variant-2); }

/* Franja de estadísticas (Divisas: detalle) — un solo contenedor en vez de
   4 tarjetas sueltas; la cuadrícula 2×2 con divisores internos ya comunica
   "estos 4 números son un conjunto", sin peso visual extra. */
/* ---- Divisas: una card por moneda ---- */
.fx-cards { display: flex; flex-direction: column; gap: var(--s2); }
.fx-card .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.fx-card-go { margin-top: 6px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; }

/* ---- La bolita: los tres números de una tirada ----
   Fijo y corridos son del mismo tamaño porque son la misma clase de número (dos
   cifras, del 1 al 100); lo que distingue al fijo es el color, no el tamaño.
   El boleto va aparte y en gris: son tres cifras, otra apuesta. */
.bol { display: flex; gap: var(--s2); margin-top: 12px; flex-wrap: wrap; }
.bol-n {
  flex: 1 1 0; min-width: 64px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; border-radius: var(--shape-sm); background: var(--surface-container);
}
.bol-n .bol-v { font-size: 26px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.bol-n .bol-l { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--on-surface-variant-2); }
.bol-fijo { background: var(--primary-container); }
.bol-fijo .bol-v, .bol-fijo .bol-l { color: var(--on-primary-container); }
.bol-bol .bol-v { font-size: 22px; color: var(--on-surface-variant); }
.bol-extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--outline-variant); }
.bol-extra .num { font-size: 15px; letter-spacing: .01em; }
.lot-card .title { font-size: 17px; }

/* ---- Timeline del historial ----
   Tres columnas fijas y no una tabla: en 320 px de ancho, `table-layout:auto`
   reparte según el contenido y la columna de la fecha baila de fila en fila.
   Con el grid, los números quedan alineados y se leen en vertical. */
.tl { background: var(--surface-container-low); border-radius: var(--shape-md); overflow: hidden; }
.tl-head, .tl-row {
  display: grid; grid-template-columns: 1fr auto 76px;
  gap: var(--s2); align-items: center; padding: 11px var(--s3);
}
.tl-head {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--on-surface-variant-2); background: var(--surface-container);
}
.tl-row + .tl-row { border-top: 1px solid var(--outline-variant); }
.tl-row .tl-f { color: var(--on-surface-variant); font-size: 13.5px; }
.tl-row .num { font-size: 16px; }
.tl .r { text-align: right; justify-self: end; }
.tl-mas {
  display: block; width: 100%; padding: 13px; border: none; background: none;
  border-top: 1px solid var(--outline-variant);
  color: var(--primary); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tl-mas:active { background: var(--surface-container-high); }
.tl-fin { text-align: center; padding: 12px; margin: 0; border-top: 1px solid var(--outline-variant); }

.stat-strip { display: grid; grid-template-columns: 1fr 1fr; }
.stat-strip .stat { text-align: center; padding: 10px 4px; min-width: 0; }
.stat-strip .stat:nth-child(odd) { border-right: 1px solid var(--outline-variant); }
.stat-strip .stat:nth-child(-n+2) { border-bottom: 1px solid var(--outline-variant); }
.stat-strip .stat p:first-child { margin-bottom: 4px; }

/* ---- Lotería ------------------------------------------------------------ */
.balls { display: flex; gap: 8px; flex-wrap: wrap; }
.ball {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-container); border: none;
  font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--on-surface);
}
.ball.special { background: var(--primary); color: var(--on-primary); }
.ball.sm { width: 34px; height: 34px; font-size: 13.5px; }

/* ---- Hoja inferior / overlays -------------------------------------------- */
.sheet-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(16,24,40,.44); opacity: 0; transition: opacity var(--dur-medium) var(--ease-standard); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 520px; margin: 0 auto;
  background: var(--surface-container-high); border-radius: var(--shape-xl) var(--shape-xl) 0 0;
  padding: 10px var(--s4) calc(var(--s4) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-3);
  transform: translateY(100%); transition: transform var(--dur-medium) var(--ease-emphasized);
}
.sheet-open .sheet { transform: none; }
.sheet-open .sheet-scrim { opacity: 1; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--outline-variant); margin: 0 auto 14px; }

/* ---- FAB (M3: forma "large" 16px, NO píldora; primary-container) --------- */
.fab {
  position: fixed; right: max(16px, calc(50% - 260px + 16px)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); z-index: 30;
  display: inline-flex; align-items: center; gap: 8px;
  height: 50px; padding: 0 20px; border-radius: var(--shape-lg); border: none; cursor: pointer;
  background: var(--primary-container); color: var(--on-primary-container); font: 600 14px inherit;
  box-shadow: var(--shadow-3); transition: transform var(--dur-short) var(--ease-standard), box-shadow var(--dur-short) var(--ease-standard);
}
.fab:active { transform: scale(.95); box-shadow: var(--shadow-2); }

/* ---- Pantallas completas (splash / gates / límite) ------------------------ */
.full { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 24px) var(--s4) calc(env(safe-area-inset-bottom) + 24px); }
.full .center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--s2); }
.logo-mark {
  width: 84px; height: 84px; border-radius: var(--shape-xl); background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 900; font-size: 26px; letter-spacing: -.04em;
  box-shadow: var(--shadow-3);
}
.full h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 0; } /* = .headline */
.step { display: flex; gap: 12px; align-items: flex-start; text-align: left; }
.step .n { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-size: 12.5px; font-weight: 700; display: grid; place-items: center; flex: 0 0 auto; margin-top: 1px; }
.countdown { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; } /* alineado a .display: mismo rol "número hero" */
.progress { width: 160px; height: 4px; border-radius: 2px; background: var(--outline-variant); overflow: hidden; }
.progress span { display: block; height: 100%; width: 40%; background: var(--primary); border-radius: 2px; animation: load 1.4s ease-in-out infinite; }
@keyframes load { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* Alturas bajas (landscape, ~375px de alto): compactar el dialer para que quepa
   completo (display + 4 filas de teclas + botón buscar) sin scroll ni recortes. */
/* Pantallas cortas (360×640 y compañía). El teclado medía lo mismo llueva o
   truene, así que el display se comprimía hasta solaparse con lo de arriba y lo
   de abajo. Aquí cede el teclado, que es de donde sobra tamaño. */
@media (max-height: 730px) {
  .dial { padding: 0 var(--s3) var(--s2); }
  .pad { gap: 9px; padding: 2px 0; }
  .key { width: min(60px, 16vw); }
  .key .d { font-size: 21px; }
  .key .l { font-size: 8px; letter-spacing: 1.5px; height: 9px; }
  .callbtn { width: 54px; height: 54px; }
  .callbtn .ic { width: 22px; height: 22px; }
  .callrow { padding-top: 0; }
  .dial .number { font-size: clamp(22px, 8vw, 28px); min-height: 34px; }
  .dial .display { gap: 4px; }
    }
/* Ya muy cortas: los recientes son lo prescindible — siguen a un toque en el
   icono de historial de la barra superior. */

@media (max-height: 500px) {
  .key { width: 52px; }
  .pad { gap: 8px; padding: 4px 0; }
  .callbtn { width: 52px; height: 52px; }
  .dial .number { font-size: 24px; min-height: 32px; }
  .dial .display { gap: 2px; }
  .logo-mark { width: 56px; height: 56px; }
}

/* ---- Barra de actualización (PWA update controller) ------------------------- */
/* Superficie "inverse": siempre opuesta al tema activo, para que el aviso de
   sistema destaque sin importar si la app está en claro u oscuro (M3 Snackbar). */
#update-bar {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%);
  z-index: 55; width: min(480px, calc(100% - 24px));
  background: var(--inverse-surface); color: var(--inverse-on-surface); border-radius: var(--shape-lg); padding: 10px 12px;
  box-shadow: var(--shadow-3); animation: in var(--dur-medium) var(--ease-standard);
}
#update-bar .ic { color: var(--inverse-on-surface); }

/* ---- Toast ------------------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); transform: translateX(-50%) translateY(8px);
  z-index: 70; background: var(--inverse-surface); color: var(--inverse-on-surface); padding: 11px 18px; border-radius: var(--shape-full);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-3);
  opacity: 0; transition: var(--dur-medium) var(--ease-standard); pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---- Animación de entrada ---------------------------------------------------- */
.page, .full { animation: in var(--dur-medium) var(--ease-standard); }
@keyframes in { from { opacity: 0; transform: translateY(4px); } }

/* ---- Estados vacíos ------------------------------------------------------------ */
.empty { text-align: center; padding: var(--s5) var(--s3); color: var(--on-surface-variant-2); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { width: 34px; height: 34px; }

/* ---- Accesibilidad: respeta la preferencia de movimiento reducido -------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .dial .number .caret { animation: none; opacity: 1; }
  .progress span { animation: none; margin-left: 0; width: 100%; opacity: .5; }
}

/* ---- Modo oscuro: mismos roles, tonos invertidos (esquema M3 dark) -------
   Sigue prefers-color-scheme del sistema, sin selector manual en Ajustes por
   ahora. Cada par texto/fondo verificado con la fórmula WCAG real (6.36:1 a
   14.23:1, ver /Users/imaginacion/.claude/plans/refactored-baking-gray.md).
   Solo se redefinen los roles de color: espaciado, forma, elevación, tipo y
   movimiento son independientes del tema y no cambian aquí. */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #bcdde7;                 /* tone80 — 7.02:1 con on-primary */
    --on-primary: #07485a;              /* tone20 */
    --primary-container: #0b6e89;       /* tone30 */
    --on-primary-container: #e3ebed;    /* tone90 — 4.82:1 */

    --secondary-container: #3e5156;     /* tone30 */
    --on-secondary-container: #e7e9e9;  /* tone90 — 6.85:1 */

    --tertiary: #e4dabe;                /* tone80 — 12.52:1 sobre surface */
    --tertiary-container: #816312;      /* tone30 */
    --on-tertiary-container: #eceae4;   /* tone90 — 4.68:1 */

    --error: #e2c2c0;                   /* tone80 — 10.56:1 sobre surface */
    --on-error: #52140f;                /* tone20 — 8.67:1 */
    --error-container: #7d1e17;         /* tone30 */
    --on-error-container: #ece5e4;      /* tone90 — 8.16:1 */

    --up: #81eec0; --up-container: #143d2c;     /* 8.61:1 */
    --down: #eba8a2; --down-container: #451a17; /* 7.54:1 */

    --surface: #191a1a;                 /* neutral10 */
    --surface-container-low: #1e2020;
    --surface-container: #232626;
    --surface-container-high: #282c2c;
    --surface-container-highest: #2e3335;

    --on-surface: #e8e8e8;              /* neutral90 — 14.23:1 */
    --on-surface-variant: #cfd3d4;      /* neutral-variant80 — 11.56:1 */
    --on-surface-variant-2: #aeb9bc;    /* neutral-variant70 — 8.69:1 */

    --outline: #8f9fa3;                 /* neutral-variant60 — 6.36:1 (umbral no-texto) */
    --outline-variant: #434e51;         /* divisor sutil, sin requisito de contraste */

    /* Snackbar/toast/update-bar: superficie inversa = SIEMPRE opuesta al
       tema activo. En dark, "inverse" pasa a ser clara. */
    --inverse-surface: #e8e8e8;
    --inverse-on-surface: #191a1a;
    --inverse-primary: #107f9e;
  }
}
