/* Layout: app de una columna (máx. 560px), cabecera con banda suave ciruela→crema, barra de pestañas fija abajo.
   El veredicto es una "etiqueta" a todo ancho; debajo, una fila por persona de la familia.
   Paleta: dirección A «Ciruela» (BL-123, D-019) + veredictos capa A (D-022); ver 03_DESIGN/BRAND_COLOR_PROPOSALS.md. */
:root {
  /* Neutros cálidos (crema) */
  --bg: #f8f3ec;
  --surface: #ffffff;
  --ink: #2a2230;
  --muted: #5e5565;
  --line: #e6ddd3;            /* decorativo */
  --line-strong: #857c8c;     /* bordes de controles (>= 3:1) */
  /* Marca: ciruela */
  --accent: #7e2f93;
  --accent-ink: #ffffff;
  --accent-text: #66267a;
  --accent-soft: #f1e1f5;
  --focus: #7e2f93;
  /* Secundario / "mixto": azul (no teal/verde; no se confunde con APTO) */
  --sky: #1f5fa8;
  --sky-soft: #dceaf8;
  --band-a: #f1e1f5;
  --band-b: #fbeee0;
  /* Semánticos de veredicto, capa A (independientes de la marca): --x = texto/borde/icono, --x-bg = tinte */
  --ok: #14583a;   --ok-bg: #e1f2ea;
  --warn: #6b4700; --warn-bg: #fff1cc;
  --no: #7f1d1d;   --no-bg: #fbe4e4;
  --nd: #3f4a52;   --nd-bg: #e9ecef;
  --cam: #120d16;
  --good: #3f6b14;  --good-bg: #e9f5e2;
  /* Colores de persona (avatares): sin teal/verde ni tonos de veredicto */
  --p1: #7e2f93; --p2: #1f5fa8; --p3: #4a4aae; --p4: #a62f66; --p5: #9a4a1c; --p6: #55607a;
  --p-ink: #ffffff;

  --f-display: 'Archivo', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --f-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --r: 16px;
  --r-s: 12px;
  --shadow: 0 1px 2px rgba(42, 34, 48, .05), 0 6px 20px -8px rgba(42, 34, 48, .14);
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17121b; --surface: #211a26; --ink: #f4eef6; --muted: #b8adbf; --line: #3a3042; --line-strong: #7c6f85;
    --accent: #c98ad8; --accent-ink: #230c2b; --accent-text: #e3c3eb; --accent-soft: #34213c; --focus: #e3c3eb;
    --sky: #7db0ec; --sky-soft: #1b2d44;
    --band-a: #2a1b31; --band-b: #211b33;
    --ok: #63cf92; --ok-bg: #12321f; --warn: #e8b45e; --warn-bg: #33270f;
    --no: #ff8f86; --no-bg: #3a1a19; --nd: #c9d1d8; --nd-bg: #23282d; --good: #a3d77c; --good-bg: #1a2e14;
    --p1: #c98ad8; --p2: #7db0ec; --p3: #a5a5f0; --p4: #f08fb8; --p5: #eda56a; --p6: #a9b8d0; --p-ink: #17121b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17121b; --surface: #211a26; --ink: #f4eef6; --muted: #b8adbf; --line: #3a3042; --line-strong: #7c6f85;
  --accent: #c98ad8; --accent-ink: #230c2b; --accent-text: #e3c3eb; --accent-soft: #34213c; --focus: #e3c3eb;
  --sky: #7db0ec; --sky-soft: #1b2d44;
  --band-a: #2a1b31; --band-b: #211b33;
  --ok: #63cf92; --ok-bg: #12321f; --warn: #e8b45e; --warn-bg: #33270f;
  --no: #ff8f86; --no-bg: #3a1a19; --nd: #c9d1d8; --nd-bg: #23282d; --good: #a3d77c; --good-bg: #1a2e14;
  --p1: #c98ad8; --p2: #7db0ec; --p3: #a5a5f0; --p4: #f08fb8; --p5: #eda56a; --p6: #a9b8d0; --p-ink: #17121b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
/* Alto contraste (claro): fondos blancos, tinta negra, sin tintes, bordes gruesos */
@media (prefers-contrast: more) {
  :root {
    --bg: #ffffff; --surface: #ffffff; --ink: #000000; --muted: #000000; --line: #000000; --line-strong: #000000;
    --accent: #4f1d5f; --accent-ink: #ffffff; --accent-text: #4f1d5f; --accent-soft: #ffffff; --focus: #000000;
    --sky: #133b6a; --sky-soft: #ffffff;
    --band-a: #ffffff; --band-b: #ffffff;
    --ok: #17613f; --ok-bg: #ffffff; --warn: #6b4700; --warn-bg: #ffffff;
    --no: #5c0a0a; --no-bg: #ffffff; --nd: #000000; --nd-bg: #ffffff; --good: #2f5a0e; --good-bg: #ffffff;
    --p1: #4f1d5f; --p2: #133b6a; --p3: #2f2f85; --p4: #7a1d4a; --p5: #6e3410; --p6: #3a4256; --p-ink: #ffffff;
    --shadow: none;
  }
}
/* Alto contraste + oscuro (variante propuesta en BRAND_COLOR_PROPOSALS §4, pendiente de validar): fondo negro, tinta blanca */
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #000000; --ink: #ffffff; --muted: #ffffff; --line: #ffffff; --line-strong: #ffffff;
    --accent: #d09adb; --accent-ink: #000000; --accent-text: #d09adb; --accent-soft: #000000; --focus: #ffffff;
    --sky: #8cb8e6; --sky-soft: #000000;
    --band-a: #000000; --band-b: #000000;
    --ok: #63cf92; --ok-bg: #000000; --warn: #f2b01e; --warn-bg: #000000;
    --no: #ff8f86; --no-bg: #000000; --nd: #ffffff; --nd-bg: #000000; --good: #a3d77c; --good-bg: #000000;
    --p1: #d09adb; --p2: #8cb8e6; --p3: #b4b4f5; --p4: #f5a3c4; --p5: #f2b07a; --p6: #b9c6da; --p-ink: #000000;
  }
}
@media (prefers-contrast: more) {
  :root[data-theme="dark"] {
    --bg: #000000; --surface: #000000; --ink: #ffffff; --muted: #ffffff; --line: #ffffff; --line-strong: #ffffff;
    --accent: #d09adb; --accent-ink: #000000; --accent-text: #d09adb; --accent-soft: #000000; --focus: #ffffff;
    --sky: #8cb8e6; --sky-soft: #000000;
    --band-a: #000000; --band-b: #000000;
    --ok: #63cf92; --ok-bg: #000000; --warn: #f2b01e; --warn-bg: #000000;
    --no: #ff8f86; --no-bg: #000000; --nd: #ffffff; --nd-bg: #000000; --good: #a3d77c; --good-bg: #000000;
    --p1: #d09adb; --p2: #8cb8e6; --p3: #b4b4f5; --p4: #f5a3c4; --p5: #f2b07a; --p6: #b9c6da; --p-ink: #000000;
  }
}

/* Banda sólida de veredicto (BL-127, D-025). Ver 03_DESIGN/BRAND_COLOR_PROPOSALS.md §1.3.
   --x-fill/--x-on: banda (texto sobre relleno); --x-edge: borde de tarjeta. El cuerpo usa --x-bg (tinte) y --ink.
   SIN DATOS no es banda sólida: tinte claro + borde discontinuo (solo --nd-edge). MIXTO (no está en la tabla): azul --sky. */
:root {
  --ok-fill: #1f7a52;   --ok-on: #ffffff;   --ok-edge: #1f7a52;
  --warn-fill: #f2b01e; --warn-on: #2b1d00; --warn-edge: #8a5800;
  --no-fill: #7f1d1d;   --no-on: #ffffff;   --no-edge: #7f1d1d;
  --mix-fill: #1f5fa8;  --mix-on: #ffffff;  --mix-edge: #1f5fa8;
  --nd-edge: #5f6b73;
  /* BL-138 (D-031) REVISA LA ETIQUETA: neutro (no es veredicto de alérgeno). Banda sólida pizarra con borde DISCONTINUO grueso: se separa de SIN DATOS (tinte claro) y de PRECAUCIÓN (ámbar) por tono, relleno, borde, icono (lupa) y palabra */
  --rv-fill: #3e4a53;   --rv-on: #ffffff;   --rv-edge: #3e4a53;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ok-edge: #63cf92; --warn-edge: #e8b45e; --no-edge: #ff8f86; --mix-edge: #7db0ec; --nd-edge: #8a96a0;
    --rv-fill: #c7d0d8; --rv-on: #11161a; --rv-edge: #c7d0d8;
  }
}
:root[data-theme="dark"] {
  --ok-edge: #63cf92; --warn-edge: #e8b45e; --no-edge: #ff8f86; --mix-edge: #7db0ec; --nd-edge: #8a96a0;
  --rv-fill: #c7d0d8; --rv-on: #11161a; --rv-edge: #c7d0d8;
}
@media (prefers-contrast: more) {
  :root {
    --ok-fill: #17613f; --no-fill: #5c0a0a; --warn-on: #000000; --mix-fill: #133b6a;
    --ok-edge: #000000; --warn-edge: #000000; --no-edge: #000000; --mix-edge: #000000; --nd-edge: #000000;
    --rv-fill: #000000; --rv-on: #ffffff; --rv-edge: #000000;
  }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ok-edge: #ffffff; --warn-edge: #ffffff; --no-edge: #ffffff; --mix-edge: #ffffff; --nd-edge: #ffffff;
    --rv-fill: #ffffff; --rv-on: #000000; --rv-edge: #ffffff;
  }
}
@media (prefers-contrast: more) {
  :root[data-theme="dark"] {
    --ok-edge: #ffffff; --warn-edge: #ffffff; --no-edge: #ffffff; --mix-edge: #ffffff; --nd-edge: #ffffff;
    --rv-fill: #ffffff; --rv-on: #000000; --rv-edge: #ffffff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Banda superior suave */
.band {
  background: linear-gradient(120deg, var(--band-a), var(--band-b));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.band-in { max-width: 560px; margin: 0 auto; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* Cabecera */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 18px 18px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.logo svg { width: 22px; height: 22px; stroke-width: 2.4; }
.brand-txt { display: grid; min-width: 0; }
.mark {
  font-family: var(--f-display); font-weight: 850; font-stretch: 80%;
  font-size: 25px; line-height: 1; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap;
}
.mark-b { color: var(--accent); }
.sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who {
  display: inline-flex; align-items: center; gap: 8px; max-width: 58%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 5px 12px 5px 5px; font: 600 14px var(--f-body); cursor: pointer; box-shadow: var(--shadow);
}
.who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .ct { color: var(--muted); font-weight: 400; white-space: nowrap; }
.stack { display: inline-flex; }
.stack .av + .av { margin-left: -9px; }
.stack .av { box-shadow: 0 0 0 2px var(--surface); }

/* Avatar de persona */
.av {
  --pc: var(--p1);
  width: 28px; height: 28px; border-radius: 50%; background: var(--pc); color: var(--p-ink);
  display: grid; place-items: center; font: 800 13px var(--f-display); flex: none; text-transform: uppercase;
}
.av.lg { width: 44px; height: 44px; font-size: 18px; }
.c1 { --pc: var(--p1); } .c2 { --pc: var(--p2); } .c3 { --pc: var(--p3); }
.c4 { --pc: var(--p4); } .c5 { --pc: var(--p5); } .c6 { --pc: var(--p6); }

/* Tipografía de secciones */
.h-section {
  font-family: var(--f-display); font-stretch: 88%; font-weight: 800;
  font-size: 24px; line-height: 1.15; margin: 0 0 6px; text-wrap: balance;
}
.h-group {
  font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 26px 0 10px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
}
.h-group small { font: 400 12px var(--f-body); letter-spacing: 0; text-transform: none; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 700 15px var(--f-body); cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--sky-soft); border-color: transparent; color: var(--sky); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.on-dark { background: rgba(0,0,0,.55); color: #fff; border-color: rgba(255,255,255,.35); }
.btn.danger-btn { background: var(--no); border-color: var(--no); color: var(--surface); }
.btn.link { border: 0; background: none; color: var(--no); padding: 0; min-height: 32px; font-weight: 600; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Escáner */
.scanner { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.for { display: grid; gap: 8px; }
.for-lbl { font-size: 13px; color: var(--muted); }
.scan-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.scan-actions .btn.primary { min-height: 54px; font-size: 16px; }
.viewfinder { position: relative; border-radius: var(--r-s); overflow: hidden; background: var(--cam); aspect-ratio: 4 / 3; max-width: 100%; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.reticle { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.reticle span {
  width: 78%; height: 38%; border: 2px solid rgba(255,255,255,.9); border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35);
}
.reticle span::after {
  content: ""; display: block; height: 2px; margin-top: 18%; background: #d09adb;
  animation: sweep 1.6s ease-in-out infinite alternate;
}
@keyframes sweep { from { transform: translateY(-120%); } to { transform: translateY(260%); } }
.viewfinder .btn { position: absolute; right: 10px; bottom: 10px; }
.viewfinder .btn.torch { right: auto; left: 10px; }
.viewfinder .btn.torch[aria-pressed="true"] { background: #f2b632; color: #1d1a10; border-color: #f2b632; }
.verdict.loading .ico { background: transparent; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.manual label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }
input:not([type]), input[type="text"] {
  min-height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font: 500 16px var(--f-body); width: 100%;
}
input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
#code { font-family: var(--f-mono); letter-spacing: 0.06em; }
.status { margin: 0; font-size: 14px; }
.status:empty { display: none; }
.status.err { color: var(--no); }
.status.busy { color: var(--muted); }
.examples { display: grid; gap: 8px; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 13px var(--f-body); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip .x { font-size: 16px; line-height: 1; color: var(--muted); }
/* Chip de persona (evaluar para) */
.pchip { padding: 0 12px 0 4px; min-height: 36px; }
.pchip .av { width: 26px; height: 26px; font-size: 12px; }
.pchip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pchip[aria-pressed="false"] { color: var(--muted); }
.pchip[aria-pressed="false"] .av { opacity: .4; }

/* Resultado */
#result { margin-top: 18px; display: grid; gap: 14px; }
#result:empty { display: none; }
.verdict {
  --fill: var(--nd-bg); --on: var(--nd); --edge: var(--nd-edge); --cb: var(--nd-bg);
  background: var(--cb); color: var(--ink); border: 2px dashed var(--edge); border-radius: var(--r); overflow: hidden;
}
.verdict.APTO { --fill: var(--ok-fill); --on: var(--ok-on); --edge: var(--ok-edge); --cb: var(--ok-bg); }
.verdict.NO_APTO { --fill: var(--no-fill); --on: var(--no-on); --edge: var(--no-edge); --cb: var(--no-bg); }
.verdict.PRECAUCION { --fill: var(--warn-fill); --on: var(--warn-on); --edge: var(--warn-edge); --cb: var(--warn-bg); }
.verdict.MIXTO { --fill: var(--mix-fill); --on: var(--mix-on); --edge: var(--mix-edge); --cb: var(--sky-soft); }
.verdict.REVISA { --fill: var(--rv-fill); --on: var(--rv-on); --edge: var(--rv-edge); --cb: var(--nd-bg); border-width: 3px; }   /* BL-138: borde discontinuo (heredado de .verdict) y 3 px */
.verdict.APTO, .verdict.NO_APTO, .verdict.PRECAUCION, .verdict.MIXTO { border-style: solid; border-width: 2px; }
/* Banda: relleno sólido a todo el ancho con icono + palabra (texto --on, contraste >= 4,5:1) */
.verdict .band { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--fill); color: var(--on); }
.verdict.SIN_DATOS .band, .verdict.SIN_PERFIL .band { border-bottom: 2px dashed var(--edge); }
.verdict.REVISA .band { border-bottom: 3px dashed var(--edge); }
.verdict .vbody { padding: 12px 18px 16px; display: grid; gap: 4px; }
.verdict .ico { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--on); color: var(--fill); display: grid; place-items: center; }
.verdict .ico svg { width: 26px; height: 26px; stroke-width: 3; }
.verdict .ico .num { font: 900 18px/1 var(--f-display); font-stretch: 75%; font-variant-numeric: tabular-nums; }
.verdict .word {
  font-family: var(--f-display); font-weight: 900; font-stretch: 68%; text-transform: uppercase;
  font-size: clamp(34px, 10vw, 48px); line-height: 0.92; letter-spacing: 0.01em; text-wrap: balance;
}
.verdict .word.long { font-size: clamp(28px, 8vw, 38px); }
/* BL-134 (BUG-010): en pantallas muy estrechas «PRECAUCIÓN» no cabía y overflow:hidden recortaba la última letra */
@media (max-width: 359px) {
  .verdict .band { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .verdict .word { font-size: 28px; }
  .verdict .word.long { font-size: 24px; }
}
.verdict .why { color: var(--ink); font-size: 15px; }
.verdict .act { margin-top: 8px; }
/* BL-138: lista de palabras de «REVISA LA ETIQUETA» (idioma no reconocido / palabras sin reconocer) y consejo */
.rev-words { margin-top: 6px; display: grid; gap: 6px; }
.rev-words .rv-t { font: 700 12px var(--f-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--nd); }
.rev-words ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rev-words li { font-size: 14px; color: var(--ink); background: var(--surface); border: 1.5px dashed var(--nd-edge); border-radius: 6px; padding: 1px 8px; overflow-wrap: anywhere; }
.rev-words .rv-tip { font-size: 14px; color: var(--ink); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.product { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; }
.thumb {
  width: 64px; height: 64px; border-radius: var(--r-s); background: var(--bg); border: 1px solid var(--line);
  display: grid; place-items: center; overflow: hidden; color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.product .pn { font-family: var(--f-display); font-weight: 750; font-size: 19px; line-height: 1.2; text-wrap: balance; }
.product .pb { color: var(--muted); font-size: 14px; }
.ean { font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.12em; color: var(--muted); margin-top: 2px; }
.badge-demo { display: inline-block; font: 700 11px var(--f-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--sky); background: var(--sky-soft); border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }

/* Resultado por persona */
.people-res { list-style: none; margin: 0; padding: 0; display: grid; }
.people-res > li { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 8px; }
.people-res > li:first-child { border-top: 0; padding-top: 2px; }
.people-res > li:last-child { padding-bottom: 0; }
.pr-head { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.pr-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.findings { list-style: none; margin: 0; padding: 0 0 0 38px; display: grid; gap: 6px; }
.findings li { font-size: 14px; color: var(--muted); }
.findings b { color: var(--ink); font-weight: 700; }
.findings .tag { font: 800 10.5px var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; margin-right: 6px; vertical-align: 1px; }
.findings .tag.no { background: var(--no-bg); color: var(--no); }
.findings .tag.trazas { background: var(--warn-bg); color: var(--warn); }
.findings .tag.ok { background: var(--ok-bg); color: var(--ok); }
/* BL-136: «Sin reconocer» (no sabemos qué es) se distingue de «Dudoso» (alérgeno posible) con el mismo color de aviso pero sin relleno y con borde; no es un veredicto nuevo */
.findings .tag.trazas.unk { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
/* BL-138 (D-031): «Sin reconocer» / «Otro idioma» ya no son PRECAUCIÓN ámbar: etiqueta neutra con borde discontinuo */
.findings .tag.rev { background: transparent; color: var(--nd); border: 1.5px dashed var(--nd-edge); padding: 0 5px; }
.pr-clean { padding-left: 38px; font-size: 13.5px; color: var(--muted); }

.pill { font: 800 11px var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; align-self: center; white-space: nowrap; }
.pill.APTO { background: var(--ok-bg); color: var(--ok); }
.pill.NO_APTO { background: var(--no-bg); color: var(--no); }
.pill.PRECAUCION { background: var(--warn-bg); color: var(--warn); }
.pill.MIXTO { background: var(--sky-soft); color: var(--sky); }
.pill.SIN_DATOS, .pill.SIN_PERFIL { background: var(--nd-bg); color: var(--nd); }
.pill.pend { background: var(--nd-bg); color: var(--nd); min-width: 3.2em; text-align: center; }   /* BL-142: «…» mientras se calcula el veredicto de la fila (neutro, nunca un veredicto) */
.pill.REVISA { background: var(--rv-fill); color: var(--rv-on); }   /* BL-138: relleno pizarra (SIN DATOS es tinte claro) */

.card h3 { font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.ingr { font-size: 15px; line-height: 1.65; margin: 0; overflow-wrap: anywhere; }
.ingr mark { background: var(--no-bg); color: var(--no); font-weight: 700; border-radius: 3px; padding: 0 2px; box-shadow: inset 0 -2px 0 var(--no); }
.ingr mark.trazas { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 -2px 0 var(--warn); }
.ingr mark.unk { background: var(--nd-bg); color: var(--nd); box-shadow: none; text-decoration: underline dashed var(--nd-edge) 2px; text-underline-offset: 3px; }   /* BL-138: palabra sin reconocer / otro idioma */
.declared { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.declared span { font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.declared span.tr { border-style: dashed; color: var(--muted); }
.source { font-size: 13px; color: var(--muted); margin: 0; }
.source a { color: var(--sky); }
.empty { color: var(--muted); }

/* Calidad nutricional */
.nutri { display: grid; gap: 14px; }
.nutri h3 { margin: 0; }
.ns-top { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.score {
  --c: var(--nd); --p: 0;
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--surface) 78%, transparent 79%), conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0);
}
.score .n { font: 900 28px/1 var(--f-display); font-stretch: 75%; color: var(--c); font-variant-numeric: tabular-nums; }
.score .of { font-size: 11px; color: var(--muted); }
.b-top { --c: var(--ok); } .b-good { --c: var(--good); } .b-mid { --c: var(--warn); } .b-bad { --c: var(--no); }
.sl { font: 800 22px/1.1 var(--f-display); font-stretch: 85%; color: var(--c, var(--ink)); }
.sm { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ns-rows { display: grid; border-top: 1px solid var(--line); }
.ns-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ns-row .nk { color: var(--muted); font-size: 13px; }
.ns-row .nv { min-width: 0; }
.muted { color: var(--muted); }
.nscale { display: inline-flex; gap: 2px; vertical-align: middle; }
.nscale .g { width: 26px; height: 26px; display: grid; place-items: center; font: 800 13px var(--f-display); color: #fff; opacity: .35; border-radius: 4px; }
.nscale .g.on { opacity: 1; transform: scale(1.18); border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.g-a { background: #038141; } .g-b { background: #85bb2f; } .g-c { background: #fecb02; color: #3d3100 !important; } .g-d { background: #ee8100; } .g-e { background: #e63e11; }
.nova { display: inline-block; font: 800 11px var(--f-display); letter-spacing: .06em; padding: 3px 8px; border-radius: 4px; color: #fff; margin-right: 4px; }
.nova.n1 { background: #2f9e44; } .nova.n2 { background: #c9a000; } .nova.n3 { background: #e8740c; } .nova.n4 { background: #d9381e; }
.r2 { color: var(--no); } .r1 { color: var(--warn); }
.adds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.adds li { font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 6px 10px; border-radius: 8px; background: var(--bg); }
.adds li.r2 { background: var(--no-bg); } .adds li.r1 { background: var(--warn-bg); }
.adds .code { font: 500 12px var(--f-mono); color: var(--muted); }
.adds .risk { font-size: 12px; font-weight: 700; margin-left: auto; }
.adds li.r2 .risk { color: var(--no); } .adds li.r1 .risk { color: var(--warn); }
.nutri h4 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.lights { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lights li { display: grid; grid-template-columns: 12px 1fr auto 62px; gap: 10px; align-items: center; font-size: 14px; }
.lights .dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.low, .ll.low { --lc: var(--ok); } .dot.med, .ll.med { --lc: var(--warn); } .dot.high, .ll.high { --lc: var(--no); }
.lights .dot { background: var(--lc); }
.lights .lv { font-variant-numeric: tabular-nums; font-weight: 700; }
.lights.pos .dot.high, .lights.pos .ll.high { --lc: var(--ok); }
.lights.pos .dot.source, .lights.pos .ll.source { --lc: var(--good); }
.lights.pos .dot.low, .lights.pos .ll.low { --lc: var(--nd); }
.lights.pos .dot.none, .lights.pos .ll.none { --lc: var(--line); }
.lights .ln small { font-size: 12px; color: var(--muted); }
.lights .ll { font-size: 12px; font-weight: 700; color: var(--lc); text-align: right; }
.nutri .src { font-size: 12px; color: var(--muted); margin: 0; }

/* Perfiles */
.intro { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--r); padding: 16px 18px; margin: 0 0 18px; font-size: 15px; display: grid; gap: 10px; justify-items: start; }
.intro strong { display: block; font-family: var(--f-display); font-size: 19px; color: var(--accent); }
.people { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: thin; }
.person {
  flex: none; width: 96px; display: grid; justify-items: center; gap: 6px; text-align: center;
  padding: 12px 8px 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer;
}
.person .pn { font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .pc { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.person[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), var(--shadow); background: var(--accent-soft); }
.person.add { border-style: dashed; color: var(--accent); background: transparent; }
.person.add .plus { width: 44px; height: 44px; border-radius: 50%; border: 1.5px dashed var(--accent); display: grid; place-items: center; }
.person.add .plus svg { width: 22px; height: 22px; stroke-width: 2.2; }

.editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-top: 4px; }
.editor-head { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: end; }
.editor-head label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.editor .h-group:first-of-type { margin-top: 22px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 8px; }
.tile {
  display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: start; text-align: left;
  padding: 12px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; font: inherit; min-height: 74px;
}
.tile:hover { border-color: var(--accent); }
.tile .num {
  font: 500 12px var(--f-mono); color: var(--muted); width: 24px; height: 24px; border-radius: 7px;
  border: 1px solid var(--line); display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.tile .tn { font-weight: 700; font-size: 15px; line-height: 1.25; }
.tile .td { grid-column: 2; font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.tile[aria-pressed="true"] { border-color: var(--no); background: var(--no-bg); box-shadow: inset 0 0 0 1px var(--no); }
.tile[aria-pressed="true"] .num { background: var(--no); border-color: var(--no); color: var(--surface); }
.tile[aria-pressed="true"] .num::before { content: "✕"; font-family: var(--f-body); }
.tile[aria-pressed="true"] .num span { display: none; }
.tile.has-ex .td { color: var(--no); font-weight: 700; }
.tile.goal[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tile.goal[aria-pressed="true"] .num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tile.goal[aria-pressed="true"] .num::before { content: "✓"; }
.diet { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-left: 38px; }
.diet-l { font-size: 12px; color: var(--muted); font-weight: 700; margin-right: 2px; }
.dchip { --dc: var(--nd); --dbg: var(--nd-bg); display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700;
  color: var(--dc); background: var(--dbg); border-radius: 999px; padding: 3px 9px 3px 4px; }
.dchip.ok { --dc: var(--ok); --dbg: var(--ok-bg); } .dchip.med { --dc: var(--warn); --dbg: var(--warn-bg); } .dchip.bad { --dc: var(--no); --dbg: var(--no-bg); }
.dchip .dm { width: 16px; height: 16px; border-radius: 50%; background: var(--dc); color: var(--surface); display: grid; place-items: center; font-size: 10px; }
.dchip .dv { font-weight: 400; opacity: .85; }
.parts {
  grid-column: 1 / -1; background: var(--bg); border: 1px dashed var(--no); border-radius: var(--r-s);
  padding: 12px; display: grid; gap: 10px; margin-top: -2px;
}
.parts-head { font-size: 13.5px; color: var(--muted); }
.parts-head b { color: var(--ink); }
.chip.part { padding-left: 8px; }
.chip.part .pm { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.chip.part[aria-pressed="true"] { border-color: var(--no); background: var(--no-bg); color: var(--no); }
.chip.part[aria-pressed="true"] .pm { background: var(--no); color: var(--surface); }
.chip.part[aria-pressed="false"] { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.chip.part[aria-pressed="false"] .pm { background: var(--ok); color: var(--surface); }
.parts-note { margin: 0; font-size: 13px; color: var(--warn); }
.danger { margin-top: 22px; display: grid; gap: 10px; justify-items: start; }
.danger.global { margin-top: 28px; }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }

/* Favoritos: botón y editor en el resultado */
.fav-slot { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 12px; }
.fav-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.fav-add svg { color: var(--accent); }
.fav-state { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--muted); }
.fav-state b { color: var(--ink); }
.fav-state > span { min-width: 0; overflow-wrap: anywhere; }
svg.on { fill: #f2b632; stroke: #c98f12; }
.fav-edit { display: grid; gap: 14px; }
.field label, .flabel { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.hint-s { font-size: 13px; color: var(--muted); align-self: center; }
.fav-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fav-actions .btn.link { margin-left: auto; }
.gchip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.gchip .n { font: 500 12px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.gchip[aria-pressed="true"] .n { color: var(--accent); }
.gchip.add { border-style: dashed; color: var(--accent); background: transparent; }
.gchip.add svg { width: 16px; height: 16px; }

/* Favoritos: vista */
.group-bar { margin-bottom: 12px; }
.group-box { margin-bottom: 12px; }
.fav-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--band-a), var(--band-b)); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px;
}
.fh-txt { min-width: 0; }
.fh-name { font-family: var(--f-display); font-stretch: 88%; font-weight: 800; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.fh-sum { font-size: 14px; color: var(--muted); }
.fh-sum b { color: var(--ok); }
.fh-act { display: flex; gap: 10px; align-items: center; }
.empty-card {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; font-size: 14px; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 16px;
}
.empty-card b { color: var(--ink); }
.empty-card svg { width: 26px; height: 26px; color: var(--accent); }

/* Historial */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history button {
  width: 100%; display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; color: var(--ink); font: inherit; cursor: pointer;
}
.history .thumb { width: 44px; height: 44px; }
.history .hn { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .hm { font-size: 13px; color: var(--muted); }
.history .txt { min-width: 0; }
.history .txt br { display: none; }
.history .hn, .history .hm { display: block; }
.history .hm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .tags { display: flex; align-items: center; gap: 6px; }
.mini-score {
  min-width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; padding: 0 4px;
  font: 800 13px var(--f-display); font-variant-numeric: tabular-nums; color: var(--c); border: 2px solid var(--c);
}
.view-head { padding-top: 2px; }

/* Pestañas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(8px, env(safe-area-inset-left, 0px));
  padding-right: max(8px, env(safe-area-inset-right, 0px));
}
.tabs button {
  height: var(--tabs-h); background: none; border: 0; color: var(--muted); cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 3px; font: 600 12px var(--f-body);
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button[aria-current="page"] svg { background: var(--accent-soft); border-radius: 999px; padding: 3px 14px; box-sizing: content-box; }

@media (min-width: 640px) {
  .tabs { left: 50%; right: auto; width: 560px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
@media (max-width: 420px) {
  .who .ct { display: none; }
  .who .stack + .nm { display: none; }
  .who:has(.stack) { padding-right: 5px; }
  .sub { max-width: 150px; }
}
@media (max-width: 360px) {
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .reticle span::after { animation: none; transform: translateY(80%); }
  .spin { animation-duration: 2.4s; }
}
/* Alto contraste: bordes gruesos (al final para ganar en cascada) */
@media (prefers-contrast: more) {
  /* BL-134 (BUG-009): misma especificidad que la regla de los estados sólidos (0,2,0), si no ganaba esta última con 2 px */
  .verdict, .verdict.APTO, .verdict.NO_APTO, .verdict.PRECAUCION, .verdict.MIXTO, .verdict.REVISA { border-width: 3px; }
  .verdict .band { border-bottom-width: 3px; }
  .card, .scanner, .editor, .intro, .person, .tile, .btn, .chip, .who, .history button, .tabs, input:not([type]), input[type="text"] { border-width: 2px; }
}
