/* Armador · paleta "frambuesa" (acento frambuesa para los cationes, ámbar para los aniones). Contrastes verificados (AA) en claro y oscuro.
   Las fichas nunca dependen solo del color: llevan siempre la carga o el número de oxidación escritos. */
:root {
  --bg: #FDF7FA;
  --surface: #FFFFFF;
  --text: #2E1325;
  --muted: #6B4A5E;
  --border: #EBD6E1;
  --accent: #C2347D;        /* detalles y bordes de foco */
  --accent-fill: #B02B6F;   /* relleno de fichas de catión y botones: con texto blanco da 6,1:1 */
  --accent-ink: #FFFFFF;
  --accent-text: #A02466;   /* acento como texto */
  --warm: #E8A33D;          /* relleno de fichas de anión */
  --warm-ink: #3A2504;
  --warm-edge: #9A6410;     /* borde de las fichas de anión: el ámbar solo no se distingue del fondo claro */
  --error: #C8453B;
  --ok: #1F7A4D;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E0F1A;
    --surface: #2A1624;
    --text: #FBE9F3;
    --muted: #D3A9C2;
    --border: #4A2A40;
    --accent: #FF8FC4;
    --accent-fill: #FF8FC4;
    --accent-ink: #1E0F1A;
    --accent-text: #FFA3D0;
    --warm: #F2B960;
    --warm-ink: #2A1B04;
    --warm-edge: #F2B960;
    --error: #F07A6F;
    --ok: #6FD6A0;
    color-scheme: dark;
  }
}

.muted { color: var(--muted); font-size: 0.9rem; }
.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 12px; }
.logo { border-radius: 10px; }
h1 { font-size: 1.5rem; line-height: 1.2; color: var(--accent-text); }
.tagline { color: var(--muted); font-size: 0.95rem; }
.intro { color: var(--muted); margin-bottom: 14px; }
h2 { font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.note { color: var(--muted); font-size: 0.9rem; }
[hidden] { display: none !important; }

.btn[disabled] { opacity: 0.45; cursor: default; filter: none; }

/* Modos */
.modos { display: flex; gap: 6px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 14px; }
.modos button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--muted); }
.modos button[aria-selected="true"] { background: var(--accent-fill); color: var(--accent-ink); }

/* Fichas */
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  min-height: 56px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text);
}
.tile.cat { border-color: var(--accent); }
.tile.an { border-color: var(--warm-edge); }
.tile:hover:not([disabled]) { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.tile[aria-pressed="true"].cat { background: var(--accent-fill); color: var(--accent-ink); }
.tile[aria-pressed="true"].an { background: var(--warm); color: var(--warm-ink); }
.tile[disabled] { opacity: 0.45; cursor: not-allowed; }
.t-l { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.t-n { font-size: 0.8125rem; opacity: 0.9; }
.ox { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid currentColor; border-radius: 999px; font-size: 0.75rem; font-weight: 600; vertical-align: middle; }
.piezas { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 8px; }
#bandeja { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); }
#bandeja .tile { min-height: 52px; padding: 6px 10px; }
.reto { gap: 8px; padding: 12px 16px; }
.reto h2 { margin-bottom: 2px; }
.reto-prompt { line-height: 1.35; }

/* Mesa */
.mesa { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.slot-l { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.slot-v {
  min-height: 72px; padding: 8px 10px; border-radius: 12px; border: 2px dashed var(--border); background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; text-align: left;
}
.slot-v.lleno { border-style: solid; color: inherit; }
.slot-v.lleno.cat { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.slot-v.lleno.an { background: var(--warm); border-color: var(--warm-edge); color: var(--warm-ink); }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 6px; border: 1px solid var(--border); border-radius: 12px; padding: 2px; }
.stepper button { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; font-size: 1.375rem; color: var(--accent-text); }
.stepper button:hover:not([disabled]) { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.stepper button[disabled] { opacity: 0.35; cursor: default; }
.stepper b { font-size: 1.25rem; min-width: 1.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.mesa-f { font-size: 2rem; line-height: 1.2; font-weight: 700; overflow-wrap: anywhere; min-height: 2.4rem; }
.mesa-q { font-size: 0.9375rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mesa-q .cero { color: var(--ok); font-weight: 700; }
.mesa-q .no-cero { color: var(--error); font-weight: 700; }

/* Taller y Reto */
.taller { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.estado { min-height: 1.5rem; }
.estado.ok { color: var(--ok); font-weight: 600; }
.estado.mal { color: var(--error); font-weight: 600; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.results { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.results:empty { display: none; }
.reto { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.reto-filtro { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reto-filtro select { min-height: 44px; padding: 0 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; }
.reto-prompt { font-size: 1.0625rem; }
.reto-nombre { color: var(--accent-text); font-size: 1.25rem; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--warm); color: var(--warm-ink); font-size: 0.8125rem; font-weight: 600; }
.result { display: flex; flex-direction: column; gap: 12px; }
.formula { font-size: 1.5rem; font-weight: 700; overflow-wrap: anywhere; }
.names { display: flex; flex-direction: column; gap: 10px; }
.name-row { display: grid; grid-template-columns: 7rem 1fr; gap: 4px 12px; align-items: baseline; }
.name-row dt { color: var(--muted); font-size: 0.9rem; }
.name-row .main { font-weight: 600; font-size: 1.0625rem; overflow-wrap: anywhere; }
.name-row .alts { display: block; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 420px) { .name-row { grid-template-columns: 1fr; } }

/* Selector de piezas */
.picker {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 640px; max-height: 88vh; max-height: 88dvh;
  padding: 16px; border: 1px solid var(--border); border-radius: 18px 18px 0 0; background: var(--bg); color: var(--text);
  overflow: auto; overscroll-behavior: contain;
}
.picker:not([open]) { display: none; }
.picker::backdrop { background: rgb(20 8 16 / 0.55); }
.pk-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.pk-cab h2 { margin: 0; font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.filter { width: 100%; min-height: 44px; padding: 0 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.pk-lista { display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }
.pk-lista .piezas { margin-top: 6px; }
.clear { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; }

.foot { margin: 32px 0 16px; display: flex; flex-direction: column; gap: 6px; }
