/* ──────────────────────────────────────────────────────────────────────────────
   Radar iPhone 18 Pro Max
   Lenguaje: vidrio oscuro de inspiración Apple, con identidad propia.
   Un solo acento (azul glaciar). Verde y rojo solo para bajadas y subidas de precio.
   Formas: tarjetas 22px, filas 16px, controles 12px, botones y chips en píldora.
   Capas (z-index): ambiente -1, cabecera 40, aviso demo 50.
   ────────────────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Geist Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geist Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/geist-mono-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Permite que el tinte del ambiente cambie de color con una transición suave. */
@property --tint {
  syntax: '<color>';
  inherits: true;
  initial-value: #7a1d3f;
}

:root {
  --sans: 'Geist Variable', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono Variable', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Tema oscuro (por defecto) */
  --bg: #0a0c10;
  --surface: #12161d;
  --surface-2: #181d26;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #eef1f6;
  --muted: #a3adbd;
  --faint: #8591a4;
  --accent: #8fd0ff;
  --accent-ink: #04121d;
  --accent-soft: rgba(143, 208, 255, 0.11);
  --good: #5fd38d;
  --bad: #ff8a80;
  --warn: #f2c14e;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 30px 70px -40px rgba(0, 0, 0, 0.8);
  --blob-a-opacity: 0.5;

  /* Colores de las líneas de tiendas en la gráfica */
  --s1: #e9b44c; --s2: #6fd3a0; --s3: #f08a7e; --s4: #5cc8d4;
  --s5: #f19a56; --s6: #e08fb0; --s7: #9fb0c6; --s8: #b7d36a;

  --r-card: 22px;
  --r-row: 16px;
  --r-ctl: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --line: rgba(15, 19, 25, 0.09);
  --line-strong: rgba(15, 19, 25, 0.17);
  --text: #0f1319;
  --muted: #4f5a6c;
  --faint: #667186;
  --accent: #0b6fb6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(11, 111, 182, 0.09);
  --good: #13803f;
  --bad: #c23a30;
  --warn: #8a6100;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 30px 70px -45px rgba(20, 30, 50, 0.45);
  --blob-a-opacity: 0.22;
  --s1: #a8730a; --s2: #1c8f5a; --s3: #c4473a; --s4: #167f8c;
  --s5: #c2641a; --s6: #b0457c; --s7: #5a6f8a; --s8: #6c8a16;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #f4f5f8;
    --line: rgba(15, 19, 25, 0.09);
    --line-strong: rgba(15, 19, 25, 0.17);
    --text: #0f1319;
    --muted: #4f5a6c;
    --faint: #667186;
    --accent: #0b6fb6;
    --accent-ink: #ffffff;
    --accent-soft: rgba(11, 111, 182, 0.09);
    --good: #13803f;
    --bad: #c23a30;
    --warn: #8a6100;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 30px 70px -45px rgba(20, 30, 50, 0.45);
    --blob-a-opacity: 0.22;
    --s1: #a8730a; --s2: #1c8f5a; --s3: #c4473a; --s4: #167f8c;
    --s5: #c2641a; --s6: #b0457c; --s7: #5a6f8a; --s8: #6c8a16;
    color-scheme: light;
  }
}

/* Tinte del ambiente según el color de iPhone elegido */
body { --tint: #7a1d3f; transition: --tint 0.9s ease; }
body[data-color='black'] { --tint: #3a4558; }
body[data-color='silver'] { --tint: #5b667a; }
body[data-color='glacier'] { --tint: #2a6fa8; }
body[data-color='burgundy'] { --tint: #8a2147; }

/* ── Base ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
code { font-family: var(--mono); font-size: 0.9em; padding: 0.15em 0.45em; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.ico { display: block; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 40px); }
.skip { position: absolute; left: 16px; top: -60px; z-index: 70; padding: 10px 16px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; transition: top 0.2s; }
.skip:focus { top: 12px; }

/* ── Ambiente ─────────────────────────────────────────────────────────────── */

.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%; filter: blur(90px); will-change: transform; }
.blob-a { left: -14vmax; top: -22vmax; opacity: var(--blob-a-opacity); background: radial-gradient(circle, var(--tint), transparent 66%); animation: drift 40s ease-in-out infinite alternate; }
.blob-b { right: -22vmax; top: 18vmax; opacity: 0.3; background: radial-gradient(circle, var(--accent), transparent 66%); animation: drift 52s ease-in-out infinite alternate-reverse; }
:root[data-theme='light'] .blob-b { opacity: 0.14; }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .blob-b { opacity: 0.14; } }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(6vmax, 5vmax, 0) scale(1.12); }
}

/* ── Aviso de demostración ────────────────────────────────────────────────── */

.demo-banner { position: relative; z-index: 50; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: center; padding: 10px 16px; background: var(--warn); color: #1a1405; font-size: 0.875rem; font-weight: 520; text-align: center; }
:root[data-theme='light'] .demo-banner { color: #fff; }
.demo-banner a { text-decoration: underline; text-underline-offset: 3px; font-weight: 650; }
.demo-banner[hidden] { display: none; }

/* ── Cabecera ─────────────────────────────────────────────────────────────── */

.topbar { position: sticky; top: 0; z-index: 40; height: 64px; background: color-mix(in srgb, var(--bg) 78%, transparent); -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); border-bottom: 1px solid var(--line); }
@media (prefers-reduced-transparency: reduce) { .topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.topbar-in { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-ctl); background: var(--accent); color: var(--accent-ink); }
.brand-name { display: flex; flex-direction: column; font-weight: 650; font-size: 1rem; line-height: 1.1; letter-spacing: -0.02em; }
.brand-sub { font-weight: 450; font-size: 0.75rem; color: var(--faint); letter-spacing: 0; margin-top: 2px; }


.icon-btn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); transition: color 0.2s, background 0.2s, transform 0.3s var(--ease); }
.icon-btn:hover { color: var(--text); background: var(--surface); }
.icon-btn:active { transform: scale(0.94); }
.theme-ico { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity 0.35s, transform 0.5s var(--ease); }
.theme-sun { opacity: 0; transform: rotate(-60deg) scale(0.6); }
:root[data-theme='light'] .theme-moon { opacity: 0; transform: rotate(60deg) scale(0.6); }
:root[data-theme='light'] .theme-sun { opacity: 1; transform: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .theme-moon { opacity: 0; transform: rotate(60deg) scale(0.6); }
  :root:not([data-theme='dark']) .theme-sun { opacity: 1; transform: none; }
}

/* ── Botones y controles ──────────────────────────────────────────────────── */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.6em; padding: 0.85em 1.4em; border-radius: 999px; border: 1px solid transparent; font-weight: 580; font-size: 0.9375rem; white-space: nowrap; transition: transform 0.3s var(--ease), background 0.25s, box-shadow 0.3s, border-color 0.25s; }
.btn:active { transform: translateY(1px) scale(0.975); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 34px -14px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -14px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn-primary .ico { transition: transform 0.35s var(--ease); }
.btn-primary:hover .ico { transform: translate(2px, -2px); }
.btn-ghost { border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }

.seg { --n: 2; --i: 0; position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { position: relative; z-index: 1; padding: 0.7em 1.6em; border-radius: 999px; font-weight: 580; font-size: 0.9375rem; color: var(--muted); transition: color 0.3s; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked='true'] { color: var(--accent-ink); }
.seg-thumb { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n)); border-radius: 999px; background: var(--accent); transform: translateX(calc(var(--i) * 100%)); transition: transform 0.55s var(--ease); box-shadow: 0 6px 20px -8px color-mix(in srgb, var(--accent) 80%, transparent); }
.seg-sm button { padding: 0.5em 1.05em; font-size: 0.8125rem; }

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.hero { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr); gap: clamp(32px, 6vw, 88px); align-items: center; padding-block: clamp(28px, 5vw, 60px) clamp(36px, 5vw, 64px); }
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 22px; min-width: 0; }
h1 { font-size: clamp(2.3rem, 4.6vw, 3.9rem); font-weight: 620; letter-spacing: -0.04em; line-height: 1.03; text-wrap: balance; }
.h1-accent { color: var(--accent); }
.lede { max-width: 44ch; font-size: clamp(1rem, 1.5vw, 1.1875rem); color: var(--muted); text-wrap: pretty; }

.price-block { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.price { display: flex; align-items: baseline; font-size: clamp(3.6rem, 9.4vw, 6.8rem); font-weight: 600; letter-spacing: -0.055em; line-height: 0.95; }
.price-dec, .price-cur { font-size: 0.4em; letter-spacing: -0.02em; color: var(--muted); font-weight: 560; }
.price-dec { margin-left: 0.04em; }
.price-cur { margin-left: 0.18em; }
.price-meta { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }

.chip { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.45em 0.95em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.875rem; color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; }
.chip.good { color: var(--good); background: color-mix(in srgb, var(--good) 11%, transparent); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.chip.good b { color: inherit; }
.chip.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 11%, transparent); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.chip.bad b { color: inherit; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }

.hero-visual { display: flex; flex-direction: column; align-items: center; gap: 20px; min-width: 0; }
/* El iPhone flota sobre el fondo, sin marco: las fotos son PNG con transparencia (ver scripts/build-device-images.mjs). */
.device { --rx: 0deg; --ry: 0deg; position: relative; isolation: isolate; width: min(100%, 440px); aspect-ratio: 711 / 860; transform: perspective(1100px) rotateX(var(--rx)) rotateY(var(--ry)); transition: transform 0.6s var(--ease); }
.device::before { content: ''; position: absolute; inset: -14% -24%; z-index: -1; background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 55%, transparent), transparent 80%); filter: blur(30px); opacity: 0.8; }
.dimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transform: translateY(18px) scale(0.97); filter: drop-shadow(0 30px 38px rgba(0, 0, 0, 0.45)); transition: opacity 0.8s ease, transform 1.1s var(--ease); }
.dimg.is-on { opacity: 1; transform: none; }
:root[data-theme='light'] .dimg { filter: drop-shadow(0 26px 30px rgba(20, 30, 50, 0.3)); }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .dimg { filter: drop-shadow(0 26px 30px rgba(20, 30, 50, 0.3)); } }
.device.is-broken .dimg { display: none; }

.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.swatches button { display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px 7px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.8125rem; color: var(--muted); transition: color 0.25s, border-color 0.25s, background 0.25s, transform 0.3s var(--ease); }
.swatches button:hover { color: var(--text); transform: translateY(-1px); }
.swatches button[aria-checked='true'] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.swatches i { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), inset 0 -4px 6px rgba(0, 0, 0, 0.18); }
.swatches [data-color='glacier'] i { background: linear-gradient(135deg, #cfe0f1, #7ea4c9); }
.swatches [data-color='black'] i { background: linear-gradient(135deg, #565961, #18191c); }
.swatches [data-color='burgundy'] i { background: linear-gradient(135deg, #a3405f, #4f1226); }
.swatches [data-color='silver'] i { background: linear-gradient(135deg, #f3f4f6, #b4bac3); }

/* ── Resumen ──────────────────────────────────────────────────────────────── */

.kpis { padding-block: 8px 28px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 26px clamp(14px, 2.4vw, 32px); border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi dt { font-size: 0.8125rem; color: var(--faint); font-weight: 480; }
.kpi dd { font-size: clamp(1.6rem, 3.1vw, 2.5rem); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; white-space: nowrap; }
.kpi small { font-size: 0.8125rem; color: var(--muted); min-height: 1.3em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Paneles, gráfica ─────────────────────────────────────────────────────── */

section.wrap { padding-block: clamp(20px, 3vw, 36px); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: clamp(18px, 3vw, 32px); box-shadow: var(--shadow); }
.panel-head, .section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 22px; }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.9rem); font-weight: 610; letter-spacing: -0.03em; line-height: 1.15; }
h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.015em; }
.panel-sub { margin-top: 6px; color: var(--muted); font-size: 0.9375rem; max-width: 60ch; }
.note { margin-top: 14px; padding: 12px 16px; border-radius: var(--r-ctl); background: var(--accent-soft); color: var(--muted); font-size: 0.875rem; }

.chart { min-height: 260px; }
.chart-stage { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; outline: none; border-radius: 12px; }
.chart-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { fill: var(--faint); font: 500 11px var(--mono); }
.chart-svg .line { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-svg .line.best { stroke: var(--accent); stroke-width: 2.6; }
.chart-svg .line.other { stroke-width: 1.7; opacity: 0.92; }
.chart-svg .line.dashed { stroke-dasharray: 6 5; }
.chart-svg .live-dot circle { fill: var(--accent); }
.chart-svg .live-dot .halo { opacity: 0.28; transform-box: fill-box; transform-origin: center; animation: halo 2.6s ease-out infinite; }
@keyframes halo { 0% { transform: scale(0.6); opacity: 0.5; } 100% { transform: scale(2); opacity: 0; } }
.chart-svg .cross { stroke: var(--line-strong); stroke-dasharray: 3 4; }
.chart-svg .hdot { stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: absolute; left: 0; top: 0; z-index: 5; min-width: 200px; padding: 12px 14px; border-radius: 14px; pointer-events: none; background: color-mix(in srgb, var(--surface-2) 94%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--line-strong); box-shadow: 0 22px 44px -22px rgba(0, 0, 0, 0.55); font-size: 0.8125rem; }
.chart-tip[hidden] { display: none; }
.tip-time { color: var(--faint); margin-bottom: 8px; }
.tip-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 3px 0; color: var(--muted); }
.tip-row i { width: 8px; height: 8px; border-radius: 50%; }
.tip-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row.is-best span { color: var(--text); }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.lg { display: inline-flex; align-items: center; gap: 0.55em; padding: 0.45em 0.9em; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 0.8125rem; color: var(--muted); transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.3s var(--ease); }
.lg i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: 0.45; transition: opacity 0.2s; }
.lg:hover { color: var(--text); transform: translateY(-1px); }
.lg[aria-pressed='true'] { color: var(--text); background: var(--surface-2); border-color: var(--c); }
.lg[aria-pressed='true'] i { opacity: 1; }
.lg.is-fixed { cursor: default; border-style: dashed; }
.lg.is-fixed:hover { transform: none; }
.lg.is-best { --c: var(--accent); color: var(--text); cursor: default; }
.lg.is-best i { opacity: 1; }
.lg.is-best:hover { transform: none; }

/* ── Ranking ──────────────────────────────────────────────────────────────── */

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.9375rem; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); transition: background 0.3s, border-color 0.3s; }
.switch-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.45s var(--ease), background 0.3s; }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch input:checked ~ .switch-label { color: var(--text); }

.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 8px; box-shadow: var(--shadow); }
.row { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1.5fr) 128px minmax(0, 1fr) minmax(112px, auto) 42px; align-items: center; gap: 16px; padding: 14px 16px; border-radius: var(--r-row); transition: background 0.25s; }
.row + .row::before { content: ''; position: absolute; left: 16px; right: 16px; top: 0; height: 1px; background: var(--line); }
.row:hover { background: var(--surface-2); }
.row:hover::before, .row:hover + .row::before { opacity: 0; }
.row.is-top { background: linear-gradient(90deg, var(--accent-soft), transparent 75%); }
/* Se atenúan los hijos, no la fila: la fila ya anima su opacidad al aparecer. */
.row.is-dim > * { opacity: 0.6; transition: opacity 0.25s; }
.row.is-dim:hover > * { opacity: 0.95; }

.rank { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 600; font-size: 0.9375rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row.is-top .rank { background: var(--accent); color: var(--accent-ink); }
.store { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.store-name { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.015em; }
.store-name a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-name a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--accent); }
.store-meta { font-size: 0.8125rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; padding: 0.15em 0.65em; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 0.6875rem; font-weight: 520; color: var(--muted); letter-spacing: 0.01em; }
.tag.is-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.tag.is-out { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.spark { width: 128px; height: 30px; overflow: visible; }
.spark path { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark.is-down path { stroke: var(--good); }
.spark.is-up path { stroke: var(--bad); }
.spark circle { fill: var(--text); }
.change { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--faint); }
.change.is-down { color: var(--good); }
.change.is-up { color: var(--bad); }
.change small { color: var(--faint); font-size: inherit; }
.price-cell { display: flex; flex-direction: column; align-items: flex-end; border-radius: 10px; padding: 2px 8px; margin-right: -8px; }
.price-cell strong { font-size: 1.3125rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-cell span { font-size: 0.8125rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.price-cell span.is-best { color: var(--accent); font-weight: 560; }
.go { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--muted); transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.4s var(--ease); }
.go .ico { transition: transform 0.4s var(--ease); }
.row:hover .go, .go:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.go:hover .ico { transform: translate(2px, -2px); }
.go:active { transform: scale(0.94); }

.flash-down { animation: flashDown 1.8s ease-out; }
.flash-up { animation: flashUp 1.8s ease-out; }
@keyframes flashDown { 0% { background: color-mix(in srgb, var(--good) 40%, transparent); } 100% { background: transparent; } }
@keyframes flashUp { 0% { background: color-mix(in srgb, var(--bad) 40%, transparent); } 100% { background: transparent; } }

.empty { margin-top: 12px; padding: 40px clamp(20px, 5vw, 56px); border-radius: var(--r-card); border: 1px dashed var(--line-strong); text-align: center; }
.empty h3 { font-size: 1.25rem; margin-bottom: 8px; }
.empty p { max-width: 52ch; margin-inline: auto; color: var(--muted); }
.empty.is-error { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.empty[hidden] { display: none; }

/* ── Estado del bot ───────────────────────────────────────────────────────── */

.status-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.status-copy { display: flex; flex-direction: column; gap: 14px; }
.status-copy p { color: var(--muted); max-width: 54ch; }
.status-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow); }
.status-panel h3 { margin-bottom: 14px; }
.sources { display: flex; flex-direction: column; }
.source { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 0; font-size: 0.9375rem; }
.source + .source { border-top: 1px solid var(--line); }
.source .s-ok { color: var(--good); }
.source .s-warn { color: var(--warn); }
.source .s-bad { color: var(--bad); }
.source em { font-style: normal; font-size: 0.8125rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.source .s-state { font-size: 0.8125rem; color: var(--muted); min-width: 4.5em; text-align: right; }
.runs { display: flex; align-items: flex-end; gap: 3px; height: 40px; margin-top: 22px; }
.runs i { flex: 1; min-width: 2px; max-width: 8px; height: var(--h, 100%); border-radius: 3px; background: var(--good); opacity: 0.85; transform-origin: bottom; }
.runs i.is-bad { background: var(--bad); }
.runs-caption { margin-top: 10px; font-size: 0.8125rem; color: var(--faint); }

/* ── Pie ──────────────────────────────────────────────────────────────────── */

.foot { margin-top: 28px; padding-block: 36px 56px; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.875rem; }
.foot-in { display: flex; flex-direction: column; gap: 8px; }
.foot p { max-width: 70ch; }
.foot-small { font-size: 0.8125rem; }


/* ── Esqueletos de carga ──────────────────────────────────────────────────── */

.skel { color: transparent !important; border-radius: 12px; background: linear-gradient(100deg, var(--surface-2) 30%, var(--line-strong) 50%, var(--surface-2) 70%); background-size: 220% 100%; animation: shimmer 1.5s linear infinite; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.price .skel { margin-right: 6px; }
.row.is-skel { pointer-events: none; }
.row.is-skel .skel-bar { height: 18px; border-radius: 8px; }

/* ── Aparición al desplazarse ─────────────────────────────────────────────── */

.js .reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); transition-delay: calc(var(--d, 0) * 80ms); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* ── Adaptación a pantallas pequeñas ──────────────────────────────────────── */

@media (max-width: 1020px) {
  .row { grid-template-columns: 48px minmax(0, 1.4fr) minmax(0, 1fr) minmax(104px, auto) 40px; }
  .row .spark { display: none; }
}
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .hero-visual { order: -1; }
  .device { width: min(78%, 330px); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; padding-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .status-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
@media (max-width: 640px) {
  .row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 10px; }
  .row .change { grid-column: 2 / 3; grid-row: 2; }
  .row .go { display: none; }
  .row .price-cell { grid-column: 3; grid-row: 1 / span 2; margin-right: 0; }
  .rank { width: 32px; height: 32px; }
  .cta-row .btn { flex: 1 1 auto; }
  .seg button { padding: 0.65em 1.3em; }
  .panel-head { align-items: flex-start; }
}

/* ── Reducir movimiento ───────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .blob { animation: none; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ──────────────────────────────────────────────────────────────────────────────
   Portada: buscador, filtros y tarjetas de móviles
   ────────────────────────────────────────────────────────────────────────────── */

.topbar-in { gap: 20px; }
.hdr-search { position: relative; flex: 1; max-width: 340px; margin-inline: auto 0; }
.hdr-search input { width: 100%; height: 40px; padding: 0 16px 0 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.875rem; transition: border-color 0.2s, background 0.2s; }
.hdr-search input::placeholder { color: var(--faint); }
.hdr-search input:focus-visible { outline: none; border-color: var(--accent); background: var(--surface); }
.hdr-search-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; display: grid; }
body[data-route='home'] .hdr-search { display: none; }
body[data-route='home'] .topbar-in { justify-content: space-between; }

.home-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; padding-block: clamp(36px, 7vw, 88px) 20px; }
.home-hero h1 { max-width: 16ch; }
.search { position: relative; width: min(100%, 720px); }
.search input { width: 100%; height: 64px; padding: 0 56px 0 60px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 1.125rem; letter-spacing: -0.01em; box-shadow: var(--shadow); transition: border-color 0.25s, box-shadow 0.35s; }
.search input::placeholder { color: var(--faint); }
.search input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.search input::-webkit-search-cancel-button { display: none; }
.search-ico { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; pointer-events: none; }
.search-clear { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); transition: background 0.2s, color 0.2s; }
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-clear[hidden] { display: none; }

.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; width: 100%; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.5em 1em; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 0.875rem; font-weight: 520; transition: color 0.2s, background 0.25s, border-color 0.25s, transform 0.3s var(--ease); }
.chip-btn small { font-size: 0.75rem; opacity: 0.65; font-variant-numeric: tabular-nums; }
.chip-btn:hover { color: var(--text); transform: translateY(-1px); }
.chip-btn[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

.featured { padding-block: 8px 4px; }
.featured[hidden] { display: none; }
.featured-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; }

.results .section-head { margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.more-row { display: flex; justify-content: center; margin-top: 28px; }
.more-row:has(> [hidden]) { display: none; }

.card { position: relative; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; transition: transform 0.45s var(--ease), border-color 0.3s, box-shadow 0.45s; }
.card:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.card-link { display: flex; flex-direction: column; height: 100%; }
.card-link:focus-visible { outline-offset: -3px; border-radius: var(--r-card); }
.thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; padding: 18px; background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 22%, transparent), transparent 82%); }
.thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; opacity: 0; transform: scale(0.96); filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.35)); transition: opacity 0.6s ease, transform 0.8s var(--ease); }
.thumb img.is-ready { opacity: 1; transform: none; }
.card:hover .thumb img.is-ready { transform: scale(1.05) translateY(-3px); }
:root[data-theme='light'] .thumb img { filter: drop-shadow(0 14px 16px rgba(20, 30, 50, 0.25)); }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .thumb img { filter: drop-shadow(0 14px 16px rgba(20, 30, 50, 0.25)); } }
.thumb.is-tile { background: #f3f3f5; }
.thumb.is-tile img { mix-blend-mode: multiply; filter: none; }
.thumb.is-broken { background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.thumb.is-broken img { display: none; }

.card-body { display: flex; flex-direction: column; gap: 4px; padding: 6px 18px 18px; }
.card-brand { font-size: 0.8125rem; color: var(--faint); }
.card-name { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; text-wrap: balance; }
.card-priceline { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; }
.card-from { font-size: 0.8125rem; color: var(--faint); }
.card-price { font-size: 1.5rem; font-weight: 620; letter-spacing: -0.035em; }
.card-out { font-size: 0.9375rem; color: var(--faint); }
.card-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 0.8125rem; color: var(--muted); min-height: 22px; }
.chg { display: inline-flex; align-items: center; gap: 3px; font-weight: 560; font-variant-numeric: tabular-nums; }
.chg.is-down { color: var(--good); }
.chg.is-up { color: var(--bad); }
.mini { width: 64px; height: 20px; margin-left: auto; overflow: visible; }
.mini path { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.mini.is-down path { stroke: var(--good); }
.mini.is-up path { stroke: var(--bad); }

/* Destacado: tarjeta grande, foto a un lado */
.card.is-featured { background: linear-gradient(135deg, var(--accent-soft), transparent 60%), var(--surface); }
.card.is-featured .card-link { flex-direction: row; align-items: center; }
.card.is-featured .thumb { flex: 0 0 44%; aspect-ratio: auto; align-self: stretch; min-height: 240px; }
.card.is-featured .card-body { padding: 24px 24px 24px 4px; gap: 6px; }
.card.is-featured .card-name { font-size: clamp(1.4rem, 2.4vw, 1.9rem); letter-spacing: -0.03em; }
.card.is-featured .card-price { font-size: clamp(2rem, 3.4vw, 2.75rem); }

.card.is-skel { pointer-events: none; }
.card.is-skel .thumb { margin: 14px; border-radius: 14px; aspect-ratio: 1; }
.card.is-skel .card-body { gap: 10px; }
.card.is-skel .skel-bar { height: 14px; border-radius: 8px; }

.back { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.875rem; transition: color 0.2s, transform 0.3s var(--ease); }
.back:hover { color: var(--text); transform: translateX(-2px); }
.inline-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.foot-note { margin-top: 14px; color: var(--faint); font-size: 0.8125rem; max-width: 70ch; }
.src-count { font-style: normal; color: var(--faint); font-size: 0.8125rem; }

/* Foto de la ficha sobre una ficha clara (cuando no se pudo quitar el fondo) */
.device.is-tile { border-radius: 32px; overflow: hidden; background: #f3f3f5; box-shadow: var(--shadow); }
.device.is-tile::before { display: none; }
.device.is-tile .dimg { padding: 9%; mix-blend-mode: multiply; filter: none; }

@media (max-width: 880px) {
  .card.is-featured .card-link { flex-direction: column; align-items: stretch; }
  .card.is-featured .thumb { flex: none; min-height: 0; aspect-ratio: 1; }
  .card.is-featured .card-body { padding: 6px 18px 20px; }
}
@media (max-width: 720px) {
  .hdr-search { display: none; }
  .search input { height: 56px; font-size: 1rem; padding-left: 52px; }
  .search-ico { left: 18px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-body { padding: 4px 14px 14px; }
  .card-price { font-size: 1.25rem; }
  .mini { display: none; }
}

.swatches[hidden] { display: none; }
