/* Vaelico app v2 «Mesa de luz» — cimientos: fuentes, tokens, componentes y armazón.
   Diseño: vaelico-web/mockups/app_v2 (css/app.css de la maqueta). Una sola paleta en producción:
   los MANDOS (raíl, compositor, listas, ajustes) son oscuros y se retiran; el contenido de IMAGEN
   (Imágenes, Galería, Estilos) está sobre la mesa clara (.zone-img) y el de LECTURA (Chat, Cuenta)
   en penumbra cálida (.zone-read). Ámbar (#F3BE61) en Generar/Enviar, gema y selección del mando.
   Los nombres de clase de los componentes son los de siempre (btn, btn-line, notice, chip, meter…):
   los módulos JS los pintan tal cual y aquí cambia solo su aspecto. El admin sigue con base.css. */

/* ───────────────────────── Fuentes (self-hosted, como la web) ───────────────────────── */
@font-face { font-family: 'Geist'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/geist-var-latin-v1.woff2') format('woff2');
  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'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/geist-mono-var-latin-v1.woff2') format('woff2');
  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: 'Source Serif 4'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/source-serif-4-600-latin-v1.woff2') format('woff2');
  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: 'Source Serif 4'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/source-serif-4-400-latin-v1.woff2') format('woff2');
  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: 'Source Serif 4'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('/fonts/source-serif-4-400i-latin-v1.woff2') format('woff2');
  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; }
/* Respaldos con métricas casadas: el cambio de fuente no mueve el layout. */
@font-face { font-family: 'Geist Fallback'; src: local('Arial'), local('ArialMT'), local('Helvetica'); size-adjust: 105.86%; ascent-override: 94.94%; descent-override: 27.87%; line-gap-override: 0%; }
@font-face { font-family: 'Geist Mono Fallback'; src: local('Consolas'), local('Menlo'), local('Courier New'); size-adjust: 109.13%; ascent-override: 92.09%; descent-override: 27.03%; line-gap-override: 0%; }
@font-face { font-family: 'Source Serif 4 Fallback'; font-weight: 600; src: local('Georgia Bold'), local('Georgia-Bold'); size-adjust: 84.66%; ascent-override: 122.37%; descent-override: 39.57%; line-gap-override: 0%; }
@font-face { font-family: 'Source Serif 4 Fallback'; font-weight: 400; src: local('Georgia'); size-adjust: 103.85%; ascent-override: 99.76%; descent-override: 32.26%; line-gap-override: 0%; }
@font-face { font-family: 'Source Serif 4 Fallback'; font-weight: 400; font-style: italic; src: local('Georgia Italic'), local('Georgia-Italic'); size-adjust: 93.61%; ascent-override: 110.67%; descent-override: 35.79%; line-gap-override: 0%; }

/* ───────────────────────── Tokens ─────────────────────────
   :root = el MANDO oscuro. .zone-img y .zone-read redefinen los mismos tokens para su contenido,
   así cualquier componente se ve bien dentro de cualquier zona sin variantes propias. */
:root {
  color-scheme: dark;
  --bg: #0F0F0F; --rail: #121212; --surface: #1A1A1A; --surface-2: #232323; --raise: #2C2C2C;
  --line: rgb(255 255 255 / 0.08); --line-2: rgb(255 255 255 / 0.14); --line-strong: rgb(255 255 255 / 0.30);
  --text: #F2F2F0; --text-2: #CACAC6; --muted: #A09F9A;
  --accent: #F3BE61; --accent-2: #F8CD80; --on-accent: #1C1404;
  --ok: #93D3A2; --danger: #F08C7C;
  --scrim: rgb(10 10 10 / 0.72);
  --cta: var(--accent); --cta-2: var(--accent-2); --on-cta: var(--on-accent); --cta-edge: transparent;
  --sel: var(--accent); --on-sel: var(--on-accent);
  --gem: var(--accent); --pix: var(--text-2); --hl: var(--accent); --voice: var(--accent);
  --badge: var(--text-2); --on-badge: var(--bg); --star: #fff;
  --track: var(--raise); --active-bg: var(--raise);
  --shadow-img: 0 30px 70px -30px rgb(0 0 0 / 0.8), 0 0 0 1px var(--line);
  --shadow-pop: 0 20px 50px -20px rgb(0 0 0 / 0.8);

  --f-ui: 'Geist', 'Geist Fallback', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-num: 'Geist Mono', 'Geist Mono Fallback', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --f-read: 'Source Serif 4', 'Source Serif 4 Fallback', Georgia, 'Times New Roman', serif;
  --r-1: 6px; --r-2: 10px; --r-3: 14px;
  --rail-w: 76px;
  --topbar-h: 56px;
  --dur: 140ms;
  --tap: 44px;
  --z-bar: 30; --z-drawer: 40; --z-pop: 45; --z-dialog: 50; --z-toast: 60;
}
:root, .zone-img, .zone-read {
  --sel-soft: color-mix(in srgb, var(--sel) 14%, transparent);
  --sel-line: color-mix(in srgb, var(--sel) 45%, transparent);
  --cta-soft: color-mix(in srgb, var(--cta) 14%, transparent);
  --cta-line: color-mix(in srgb, var(--cta) 45%, transparent);
  --hl-soft: color-mix(in srgb, var(--hl) 14%, transparent);
  --pix-soft: color-mix(in srgb, var(--pix) 24%, transparent);
  --pix-line: color-mix(in srgb, var(--pix) 45%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 12%, transparent);
  --ok-soft: color-mix(in srgb, var(--ok) 14%, transparent);
}
/* Contenido de IMAGEN: la mesa de luz encendida, clara. */
.zone-img {
  color-scheme: light;
  --bg: #DEDCD7; --rail: #E3E1DC; --surface: #E8E6E1; --surface-2: #D0CEC8; --raise: #EEECE7;
  --line: rgb(40 32 20 / 0.11); --line-2: rgb(40 32 20 / 0.18); --line-strong: rgb(40 32 20 / 0.36);
  --text: #1E1C18; --text-2: #3F3B35; --muted: #57534B;
  --ok: #22603A; --danger: #9E2A1C;
  --sel: #1E1C18; --on-sel: #F2F0EB; --hl: #734A0B; --voice: #734A0B; --pix: #3F3B35; --gem: #A06A0E;
  --cta-edge: rgb(120 80 10 / 0.42); --track: #C6C3BC; --active-bg: #D3D0C9;
  --shadow-img: 0 20px 44px -26px rgb(40 30 15 / 0.38), 0 0 0 1px rgb(40 32 20 / 0.11);
  --shadow-pop: 0 18px 40px -18px rgb(40 30 15 / 0.3);
  --scrim: rgb(35 25 12 / 0.55);
  color: var(--text);
}
/* Contenido de LECTURA: la mesa en penumbra, gris oscuro cálido; prosa en blanco roto. */
.zone-read {
  color-scheme: dark;
  --bg: #36332E; --rail: #2E2B27; --surface: #403C36; --surface-2: #4A453E; --raise: #524C44;
  --line: rgb(255 240 220 / 0.09); --line-2: rgb(255 240 220 / 0.16); --line-strong: rgb(255 240 220 / 0.32);
  --text: #ECE7DE; --text-2: #D6CFC3; --muted: #C9C1B4;
  --ok: #A9DDB5; --danger: #FFB4A6;
  --sel: #F3BE61; --on-sel: #1C1404; --hl: #F3BE61; --voice: #F3BE61; --pix: var(--text-2);
  --cta-edge: transparent; --track: #5C564D; --active-bg: #4A453E;
  --shadow-pop: 0 18px 40px -18px rgb(0 0 0 / 0.6);
  color: var(--text);
}

/* ───────────────────────── Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14px/1.45 var(--f-ui);
  -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11";
  overflow: hidden; /* cada panel tiene su propio scroll */
}
img, svg, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, h4, ul, ol, dl, dd, figure, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1, h2, h3, h4 { font-weight: 600; }
[hidden] { display: none !important; }
::selection { background: var(--sel-line); color: var(--text); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--raise) transparent; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link {
  position: fixed; z-index: var(--z-toast); left: 12px; top: 12px; transform: translateY(-200%);
  padding: 10px 14px; border-radius: var(--r-2); background: var(--cta); color: var(--on-cta); font-weight: 600;
}
.skip-link:focus, .skip-link:focus-visible { transform: none; }

/* Iconos: <svg class="icon"><use href="/img/ui.svg#i-…"/></svg> */
.icon { display: inline-block; flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-20 { width: 20px; height: 20px; }
.gem { display: inline-block; flex: none; width: 12px; height: 9px; color: var(--gem); fill: currentColor; stroke: none; }

/* Utilidades */
.num, .tabular { font-variant-numeric: tabular-nums; }
.num, .mono, code, kbd { font-family: var(--f-num); letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.soft { color: var(--text-2); }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 8px); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--gap, 12px); min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }
.t-xs { font-size: 12px; line-height: 1.4; }
.t-sm { font-size: 13px; line-height: 1.45; }
.serif { font-family: var(--f-read); }
.scroll-x { overflow-x: auto; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; min-height: 18px; }
.only-drawer { display: none !important; } /* también sobre .btn (que va después y pondría inline-flex) */
.only-narrow { display: none !important; }

/* ───────────────────────── Controles ───────────────────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 12px; border-radius: var(--r-2); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; line-height: 1.15; white-space: nowrap; color: var(--text-2); text-align: center;
  transition: background-color var(--dur), color var(--dur), border-color var(--dur);
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-line { border-color: var(--line-2); color: var(--text); }
.btn-line:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-ghost { color: var(--text-2); }
.btn-coral, .btn-accent { background: var(--cta); color: var(--on-cta); font-weight: 600; box-shadow: inset 0 0 0 1px var(--cta-edge); }
.btn-coral:hover, .btn-accent:hover { background: var(--cta-2); color: var(--on-cta); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-danger.btn-solid, .btn-danger.arm, .btn.arm { background: var(--danger); color: var(--bg); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-xs { min-height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-lg { min-height: 48px; padding: 0 18px; font-size: 15px; border-radius: var(--r-3); }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 36px; min-width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; min-width: 30px; }
.btn-icon.btn-xs { width: 26px; min-width: 26px; }
.btn-sm .icon, .btn-xs .icon { width: 15px; height: 15px; }
.btn[aria-pressed="true"] { color: var(--sel); }
.btn[aria-pressed="true"] .icon.fillable { fill: currentColor; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: none; }
.btn-coral:disabled, .btn-coral:disabled:hover { background: var(--surface-2); color: var(--muted); box-shadow: none; opacity: 1; }
.btn > .spinner { display: none; }
.btn[aria-busy="true"] > .spinner { display: inline-block; }
.btn-label { display: inline; }
.spinner { display: inline-block; flex: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: v-spin 0.8s linear infinite; }
@keyframes v-spin { to { transform: rotate(360deg); } }
.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; font-weight: 500; }
.link:hover { text-decoration-color: currentColor; }
button.link { display: inline; padding: 0; min-height: 0; }
.link-sm { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.link-sm:hover { color: var(--hl); }
.kbd { display: inline-block; min-width: 1.6em; font: 500 11px/1.4 var(--f-num); color: var(--muted); padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; text-align: center; }
.info { color: var(--muted); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; flex: none; }
.info:hover { color: var(--text); background: var(--surface-2); }
.info .icon { width: 15px; height: 15px; }
.cost { font-family: var(--f-num); font-size: 11.5px; color: var(--muted); font-weight: 500; }

/* Tooltip: el texto sale de aria-label (.tip) o de data-tip; ya van traducidos. */
.tip, [data-tip] { position: relative; }
.tip::after, [data-tip]::after {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px);
  background: var(--raise); color: var(--text); border: 1px solid var(--line-2); border-radius: 7px;
  font: 500 12px/1.3 var(--f-ui); letter-spacing: 0; text-transform: none; padding: 5px 8px; white-space: nowrap; pointer-events: none;
  display: none; z-index: var(--z-pop); max-width: 280px;
}
.tip::after { content: attr(aria-label); }
[data-tip]::after { content: attr(data-tip); white-space: normal; width: max-content; }
.tip--below::after { bottom: auto; top: calc(100% + 8px); }
.tip--end::after { left: auto; right: 0; transform: translate(0, 4px); }
/* A la derecha del raíl (saldo de créditos): texto largo en varias líneas. */
.tip--right::after { left: calc(100% + 10px); right: auto; bottom: auto; top: 50%; transform: translate(0, -50%); white-space: normal; width: max-content; max-width: 260px; text-align: left; }
@media (hover: hover) {
  .tip:hover::after, .tip:focus-visible::after, [data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; animation: v-tip var(--dur) ease-out both; }
}
/* Táctil: un toque en un ⓘ (o en lo que solo explica, sin acción propia) lo abre; otro toque fuera lo cierra (20-shell). */
[data-tip-open]::after { display: block !important; white-space: normal; width: max-content; max-width: min(280px, calc(100vw - 32px)); }
@keyframes v-tip { from { opacity: 0; } to { opacity: 1; } }

/* Campos */
.fgroup { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.fgroup + .fgroup { margin-top: 16px; }
.field-label { display: block; margin-bottom: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field {
  display: block; width: 100%; min-height: 38px; padding: 8px 12px; border-radius: var(--r-2);
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text); outline: none;
  transition: border-color var(--dur);
}
.field::placeholder { color: var(--muted); opacity: 1; }
.field:hover { border-color: var(--line-strong); }
.field:focus, .field:focus-visible { border-color: var(--sel); outline: none; }
.field:disabled { opacity: 0.6; cursor: not-allowed; }
.field[aria-invalid="true"] { border-color: var(--danger); }
textarea.field { resize: vertical; line-height: 1.5; }
textarea.field.field-grow { min-height: 44px; max-height: var(--grow-max, 40vh); resize: none; field-sizing: content; }
.field-read { font: 400 16px/1.6 var(--f-read); }
select.field { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field-help { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.field-error { margin-top: 6px; color: var(--danger); font-size: 12.5px; line-height: 1.45; }
.field-count { color: var(--muted); font: 400 11.5px/1 var(--f-num); }
.field-wrap { position: relative; }
.field-wrap > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 15px; height: 15px; }
.field--search { padding-left: 34px; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.input-group { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.input-group > .field { flex: 1 1 auto; min-width: 0; }

/* Casilla */
.check { display: flex; align-items: flex-start; gap: 10px; padding-block: 8px; cursor: pointer; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.check > input, input.box {
  appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0;
  border: 1.5px solid var(--line-strong); border-radius: 5px; background: transparent; cursor: pointer;
  display: grid; place-content: center;
}
.check > input::before, input.box::before { content: ''; width: 10px; height: 10px; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); background: var(--on-sel); transform: scale(0); }
.check > input:checked, input.box:checked { background: var(--sel); border-color: var(--sel); }
.check > input:checked::before, input.box:checked::before { transform: scale(1); }
.check a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

/* Interruptor. Dos marcados: <label class="switch"><input role="switch">…</label> (módulos de siempre)
   o <button class="switch" role="switch" aria-checked> (nuevo). */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); min-height: 32px; }
.switch > input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch__track { position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line-2); transition: background var(--dur); }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur), background var(--dur); }
.switch > input:checked + .switch__track, .switch[aria-checked="true"] > .switch__track { background: var(--sel); box-shadow: none; }
.switch > input:checked + .switch__track::after, .switch[aria-checked="true"] > .switch__track::after { transform: translateX(14px); background: var(--on-sel); }
.switch > input:focus-visible + .switch__track { outline: 2px solid var(--sel); outline-offset: 3px; }
.switch > input:checked ~ .switch__label { color: var(--text); }
.switch .icon { width: 15px; height: 15px; }

/* Segmentado: radiogroup (label+input) o grupo de botones con aria-pressed/aria-checked */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-2); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg--block { display: flex; }
.seg--block > * { flex: 1 1 0; }
.seg > label { position: relative; display: flex; }
.seg > label > input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg > label > span, .seg > button, .seg > a {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  min-height: 30px; min-width: 32px; padding: 0 10px; border-radius: 7px; color: var(--muted);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.seg > label:hover > span, .seg > button:hover { color: var(--text); }
.seg > label > input:checked + span, .seg > button[aria-pressed="true"], .seg > button[aria-checked="true"], .seg > a[aria-current] { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg > label > input:focus-visible + span { outline: 2px solid var(--sel); outline-offset: -2px; }
.seg > label > input:disabled + span, .seg > button:disabled { opacity: 0.38; cursor: not-allowed; }
.seg .icon { width: 15px; height: 15px; }
.seg .n, .seg small { font: 400 11.5px/1 var(--f-num); color: var(--muted); }

/* Pestañas (role=tab) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs > [role="tab"], .tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  color: var(--muted); font-size: 13.5px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs > [role="tab"]:hover, .tab:hover { color: var(--text); }
.tabs > [role="tab"][aria-selected="true"], .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--sel); }

/* Deslizador */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: none; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--sel) 0 var(--v, 50%), var(--track) var(--v, 50%)); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--track); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--sel); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 4px var(--sel-soft); }
.range::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 4px var(--sel-soft); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row > output { min-width: 3.5ch; text-align: right; font: 500 13px/1 var(--f-num); color: var(--text); }

/* Combobox (patrón ARIA 1.2) */
.combo { position: relative; min-width: 0; }
.combo__list {
  position: absolute; z-index: var(--z-pop); left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 5px;
  max-height: 300px; overflow: auto; list-style: none; border-radius: 12px;
  background: var(--raise); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop);
}
.combo__opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px 4px 5px; border-radius: 8px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.combo__opt:hover, .combo__opt[data-active] { background: var(--active-bg); color: var(--text); }
.combo__opt .meta { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.combo__empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ───────────────────────── Superficies ───────────────────────── */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); padding: 18px 20px; min-width: 0; }
.panel--flush { padding: 0; overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel__title { font-size: 14px; font-weight: 600; color: var(--text); }
.panel__body { padding: 16px 18px; }
.panel__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 13px; }
.kv > dt { color: var(--muted); }
.kv > dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; text-align: right; font-variant-numeric: tabular-nums; }

/* Aviso en línea */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text-2); font-size: 13px; line-height: 1.45; }
.notice > .icon { margin-top: 1px; width: 16px; height: 16px; color: var(--muted); }
.notice__body { flex: 1 1 auto; min-width: 0; }
.notice__title { color: var(--text); font-weight: 600; }
.notice__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notice--warn > .icon { color: var(--danger); }
.notice--warn { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.notice--ok > .icon { color: var(--ok); }
.notice--coral > .icon { color: var(--hl); }
.msg { min-height: 0; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.msg:empty { display: none; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 24px 0; }
.empty__title { font: 600 22px/1.2 var(--f-read); color: var(--text); }
.empty__text { color: var(--text-2); font-size: 14px; line-height: 1.55; }

/* Marco de imagen y glifo */
.frame { position: relative; display: block; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.frame > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame--pending { display: grid; place-items: center; aspect-ratio: var(--ar, 1); color: var(--muted); font-size: 13px; }
.glyph { display: inline-grid; place-items: center; flex: none; width: var(--g, 32px); height: var(--g, 32px); border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text-2); font: 600 calc(var(--g, 32px) * 0.5)/1 var(--f-read); }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.list-label { padding: 14px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 0; }
.rows__main { flex: 1 1 14rem; min-width: 0; }
.rows__title { color: var(--text); font-size: 13.5px; font-weight: 500; line-height: 1.35; }
.rows__meta { color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* Chips de estado: siempre con texto; el color nunca es la única señal */
.chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 500; line-height: 1; color: var(--text-2); background: var(--surface-2); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip--line { background: none; box-shadow: inset 0 0 0 1px var(--line-2); }
.chip--accent, .chip--pro { background: var(--hl-soft); color: var(--hl); }
.chip--ok, .chip--done, .chip--live { background: var(--ok-soft); color: var(--ok); }
.chip--failed, .chip--limit { background: var(--danger-soft); color: var(--danger); }
.chip--running::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--pix); } /* fijo: nada parpadea con temporizadores */
.chip--queued::before { content: ''; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid currentColor; }
.chip--off { color: var(--muted); }
.chip--tester { box-shadow: inset 0 0 0 1px var(--line-strong); }
@keyframes v-blink { 50% { opacity: 0.25; } }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }

/* Medidor de cuota (.meter de siempre) con barra de píxeles, guiño al pixel art de la marca */
.meter { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.meter__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.meter__label { color: var(--text-2); }
.meter__label b { color: var(--text); font-weight: 600; }
.meter__value { color: var(--text); font: 500 12px/1 var(--f-num); white-space: nowrap; }
.meter__value small { color: var(--muted); font-size: 11px; }
.meter__bar, .pmeter {
  position: relative; display: block; height: 8px; min-width: 40px; background: var(--track);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px); mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px);
}
.meter__fill, .pmeter > i { position: absolute; inset: 0 auto 0 0; width: var(--v, 0%); background: var(--pix); }
.meter[data-level="warn"] .meter__fill { background: var(--hl); }
.meter[data-level="full"] .meter__fill { background: var(--danger); }
.meter[data-level="full"] .meter__value { color: var(--danger); }
.meter__note { color: var(--muted); font-size: 12px; line-height: 1.45; }
.meter--sm .meter__bar { height: 6px; }
/* Progreso de una tarea */
.progress { position: relative; height: 6px; background: var(--track); overflow: hidden;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px); mask: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px); }
.progress > span { position: absolute; inset: 0 auto 0 0; width: var(--v, 0%); background: var(--pix); transition: width 300ms ease; }
/* Tramado (dithering) para lo que aún se está generando */
.dither {
  background-color: var(--surface-2);
  background-image: linear-gradient(180deg, transparent 35%, var(--surface-2) 100%), repeating-conic-gradient(var(--pix-soft) 0 25%, transparent 0 50%);
  background-size: 100% 100%, 4px 4px; image-rendering: pixelated; position: relative; overflow: hidden;
}
.dither::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--pix) 10%, transparent) 50%, transparent 70%); transform: translateX(-100%); animation: v-sweep 1.8s ease-in-out infinite; }
@keyframes v-sweep { to { transform: translateX(100%); } }
.veil { display: grid; place-items: center; color: var(--muted); background-color: var(--surface-2);
  background-image: repeating-conic-gradient(var(--pix-soft) 0 25%, transparent 0 50%); background-size: 6px 6px; image-rendering: pixelated; }

/* Menú desplegable */
.menu-anchor { position: relative; }
.menu {
  position: absolute; z-index: var(--z-pop); right: 0; top: calc(100% + 6px);
  min-width: 220px; max-width: min(320px, calc(100vw - 16px)); padding: 5px; margin: 0; list-style: none;
  background: var(--raise); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-pop); color: var(--text);
}
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--text-2); font: 500 13px/1.2 var(--f-ui); text-align: left; cursor: pointer;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--active-bg); color: var(--text); outline: none; }
.menu__item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu__item .ext { margin-left: auto; width: 13px; height: 13px; }
.menu__item .chk { margin-left: auto; visibility: hidden; color: var(--sel); }
.menu__item[aria-checked="true"] .chk { visibility: visible; }
.menu__item--danger { color: var(--danger); }
.menu__sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu__head { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 7px; color: var(--muted); font-size: 12px; }
.menu__head .appbar__email { color: var(--text); font-size: 13px; font-weight: 500; }

/* Velo, cajones laterales (lista de chats, ajustes del chat) */
.scrim { position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--scrim); }

/* Diálogo (<dialog class="dialog">, showModal) */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0;
  border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 40px 80px -30px rgb(0 0 0 / 0.8);
}
.dialog--wide { width: min(860px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(8 8 8 / 0.72); }
.dialog[open] { display: flex; flex-direction: column; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px 4px 20px; }
.dialog__title { font: 600 17px/1.25 var(--f-read); color: var(--text); }
.dialog__body { padding: 10px 20px 18px; overflow: auto; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* Aviso breve (toast): arriba, uno a la vez */
.toasts { position: fixed; z-index: var(--z-toast); left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%; min-height: 42px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line-2); color: var(--text); font-size: 13px; line-height: 1.4; box-shadow: var(--shadow-pop); }
.toast > .icon { width: 16px; height: 16px; color: var(--muted); }
.toast--ok > .icon { color: var(--ok); }
.toast--err { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.toast--err > .icon { color: var(--danger); }
.toast__msg { flex: 1 1 auto; min-width: 0; padding-block: 4px; }
.toast .btn { min-height: 30px; width: 30px; min-width: 30px; }
@media (prefers-reduced-motion: no-preference) { .toasts .toast { animation: v-drop 180ms ease-out; } }
@keyframes v-drop { from { opacity: 0; transform: translateY(-6px); } }

/* Franjas globales (mantenimiento, semana de lanzamiento) */
.maint-band { display: flex; align-items: flex-start; gap: 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; background: color-mix(in srgb, var(--accent) 12%, var(--rail)); border-bottom: 1px solid var(--line-2); color: var(--text); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.maint-band > .icon { margin-top: 1px; width: 16px; height: 16px; color: var(--accent); }

/* ───────────────────────── Armazón ─────────────────────────
   Escritorio: raíl de 76 px + el panel abierto. Móvil (< 900 px): barra arriba y cada panel
   con su propio scroll debajo. El alto descuenta las franjas (--maint-h) y, en iOS con el teclado,
   usa el alto visible real (--app-h, 20-shell). */
#app { height: 100%; }
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: var(--app-h, 100dvh); }
html.has-maint .app { height: calc(var(--app-h, 100dvh) - var(--maint-h, 0px)); }
html.has-maint .ent { min-height: calc(100dvh - var(--maint-h, 0px)); }
.app > .view { grid-column: 2; grid-row: 1; min-width: 0; min-height: 0; overflow: hidden; position: relative; }

.rail {
  grid-column: 1; grid-row: 1; background: var(--rail); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 14px 0 14px; gap: 4px; min-height: 0; z-index: var(--z-bar);
}
.rail__mark { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 12px; }
.mark { display: block; width: 30px; height: 30px; background: url(/img/mark.svg) center / contain no-repeat; }
.rail__sep { width: 28px; height: 1px; background: var(--line-2); margin: 8px 0; flex: none; }
.rail__item { width: 64px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 7px; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; border-radius: var(--r-2); text-align: center; line-height: 1.2; }
.rail__item .pill { position: relative; width: 48px; height: 30px; display: grid; place-items: center; border-radius: 999px; transition: background var(--dur); }
.rail__item .pill .icon { width: 22px; height: 22px; }
.rail__item:hover { color: var(--text-2); }
.rail__item:hover .pill { background: var(--surface-2); }
.rail__item[aria-current="page"] { color: var(--text); }
.rail__item[aria-current="page"] .pill { background: var(--sel-soft); color: var(--sel); }
.rail__badge { position: absolute; right: 2px; top: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font: 600 10px/16px var(--f-num); text-align: center; }
.rail__spacer { flex: 1; }
.rail__credits { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px; border-radius: var(--r-2); font: 500 11px/1 var(--f-num); color: var(--text-2); width: 66px; }
.rail__credits:hover { background: var(--surface-2); color: var(--text); }
.rail__credits .pmeter { width: 40px; min-width: 0; height: 5px; }
.rail__credits[hidden] { display: none; }
.rail__me { position: relative; margin-top: 6px; margin-bottom: 8px; }
.rail__avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px; border: 1px solid var(--line-2); }
.rail__avatar:hover, .rail__avatar[aria-expanded="true"] { border-color: var(--line-strong); }
.rail__me.is-current .rail__avatar { border-color: var(--accent); }
.rail__plan { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--badge); color: var(--on-badge); padding: 1px 5px; border-radius: 4px; line-height: 1.3; white-space: nowrap; }
.rail__plan:hover { background: var(--text); }
.rail .acct-menu { left: calc(100% + 10px); right: auto; top: auto; bottom: 0; }

/* Barra superior y subpestañas: solo en estrecho */
.topbar { display: none; }
.subtabs { display: none; }

@media (max-width: 899.98px) {
  .app { display: flex; flex-direction: column; }
  .rail { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; flex: none; height: var(--topbar-h); padding: 0 10px 0 12px;
    background: var(--rail); border-bottom: 1px solid var(--line); z-index: var(--z-bar);
    padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  }
  .topbar__mark { width: 36px; height: 36px; display: grid; place-items: center; }
  .topbar__mark .mark { width: 28px; height: 28px; }
  .topbar .seg { margin-left: 2px; }
  .topbar .seg > button { min-height: 32px; padding: 0 12px; font-size: 13.5px; }
  .topbar__cr { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font: 500 12.5px/1 var(--f-num); color: var(--text); }
  .topbar__cr[hidden] { display: none; }
  .topbar .rail__me { margin: 0; }
  .topbar .rail__avatar { width: 34px; height: 34px; font-size: 13px; }
  .topbar .rail__plan { bottom: -7px; font-size: 8.5px; }
  .topbar .acct-menu { right: 0; left: auto; top: calc(100% + 10px); bottom: auto; }
  .subtabs { display: flex; flex: none; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--rail); z-index: calc(var(--z-bar) - 1); }
  .subtabs > button { position: relative; height: 42px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 13.5px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
  .subtabs > button[aria-current="page"] { color: var(--text); border-bottom-color: var(--sel); }
  .subtabs .chip { height: 18px; padding: 0 6px; font-size: 11px; }
  .app > .view { flex: 1 1 auto; }
  .only-drawer { display: inline-flex !important; }
  .hide-sm { display: none !important; }
}
@media (max-width: 359.98px) {
  .topbar .seg > button { padding: 0 9px; }
  .topbar__cr { padding: 0 8px; }
}

/* Objetivos táctiles de 44 px con puntero grueso */
@media (pointer: coarse) {
  .btn-sm, .btn-xs { min-height: 38px; }
  .btn-icon.btn-sm, .btn-icon.btn-xs { width: 38px; min-width: 38px; }
  .menu__item { min-height: var(--tap); }
  .seg > label > span, .seg > button { min-height: 38px; }
  .field, select.field { font-size: 16px; } /* sin zoom de Safari al enfocar */
  .switch { min-height: var(--tap); }
}

/* Movimiento reducido: nada de barridos ni parpadeos */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .dither::after { display: none; }
}

/* Colores forzados (alto contraste de Windows) */
@media (forced-colors: active) {
  .chip, .panel, .card, .menu, .dialog, .toast, .seg, .switch__track, .meter__bar, .pmeter, .progress, .field, .btn-line { border: 1px solid CanvasText; }
  .rail__item[aria-current="page"] .pill, .tabs > [aria-selected="true"] { outline: 2px solid Highlight; }
  .meter__fill, .progress > span, .pmeter > i { background: Highlight; forced-color-adjust: none; }
  .meter__bar, .pmeter, .progress { -webkit-mask: none; mask: none; }
}

/* Japonés (lang="ja"): Geist y Source Serif solo traen latín; detrás, góticas del sistema. */
:root:lang(ja) {
  --f-jp: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Noto Sans JP', sans-serif;
  --f-ui: 'Geist', 'Geist Fallback', var(--f-jp);
  --f-read: 'Source Serif 4', 'Source Serif 4 Fallback', var(--f-jp);
}
body:lang(ja) { line-height: 1.65; }
:root:lang(ja) :is(.label, .list-label, .chip, .rail__plan, h1, h2, h3) { letter-spacing: normal; text-transform: none; }
:root:lang(ja) :is(em, i) { font-style: normal; font-weight: 600; }
:root:lang(ja) :is(h1, h2, h3, .btn, .tab, .chip, .field-label, .notice__title) { word-break: auto-phrase; }
