/* app/public/css/base.css — cimientos de la app de Vaelico (lote cimientos-css).
   Copia de mockups/app/css/app.css sin las reglas propias de las maquetas
   (outline de data-propuesta, .propuesta-tag, .kit-*, .dialog--static,
   .toasts--static) y con las fuentes servidas desde /fonts/.
   1) tokens.css, fonts.css, base.css, components.css y prose.css de la web
      (src/styles), literales salvo la ruta de las fuentes.
   2) Componentes propios de la app, sin capa. Contrato: mockups/app/CIMIENTOS.md
   Orden de capas: base < components < sin capa (css de cada pantalla).
   Compartido: los css de pantalla van sin capa y ganan a los dos.  */
@layer base, components;

/* ==== src/styles/tokens.css ==== */
/**
 * Design tokens — single source of truth.
 *
 * Colours are RGB channels so Tailwind (tailwind.config.mjs) and hand-written CSS
 * can add alpha: rgb(var(--c-coral) / .35). Contrast (WCAG, measured on the real
 * palette): text/bg 14.39 · soft/bg 11.72 · muted/bg 6.91 (6.22 on panel, 5.71 on
 * panel-2) · coral as text on bg 6.28 · on-coral on coral 6.45 (7.82 hover, 5.43
 * active) · live 9.82 · warn 10.88. Field borders (--line-strong) 3.26:1.
 */

:root {
  color-scheme: dark;

  /* Surfaces */
  --c-bg: 14 27 34; /* #0e1b22 */
  --c-panel: 19 37 46; /* #13252e */
  --c-panel-2: 23 44 54; /* #172c36 */
  --c-sink: 11 22 28; /* #0b161c — footer */
  --c-code: 15 30 37; /* #0f1e25 */

  /* Text */
  --c-text: 239 232 220; /* #efe8dc */
  --c-soft: 205 213 210; /* #cdd5d2 */
  --c-muted: 147 166 171; /* #93a6ab */

  /* Accent */
  --c-coral: 242 118 95; /* #f2765f */
  --c-coral-hover: 255 138 115; /* #ff8a73 */
  --c-coral-active: 229 102 79; /* #e5664f */
  --c-on-coral: 38 17 12; /* #26110c */

  /* Signals */
  --c-live: 127 211 166; /* #7fd3a6 */
  --c-warn: 240 198 116; /* #f0c674 — form errors only */

  /* Lines and veils */
  --c-line: 214 232 236;
  --c-scrim: 9 19 24;

  --line: rgb(var(--c-line) / 0.1);
  --line-2: rgb(var(--c-line) / 0.18);
  --line-strong: rgb(var(--c-line) / 0.4); /* form fields only (1.4.11) */
  --line-hover: rgb(var(--c-line) / 0.6);

  /* Pro tint (pricing) */
  --pro-tint: rgb(var(--c-coral) / 0.05);
  --pro-border: rgb(var(--c-coral) / 0.3);

  /* Type families (fallback faces with adjusted metrics live in fonts.css) */
  --font-serif: 'Source Serif 4', 'Source Serif 4 Fallback', Georgia, serif;
  --font-sans: 'Inter', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale */
  --fs-display: clamp(2.125rem, 1.2rem + 3.9vw, 3.75rem);
  --fs-page-h1: clamp(2rem, 4vw, 2.9rem);
  --fs-h2: clamp(1.9rem, 3.3vw, 2.7rem);
  --fs-h3: 1.5rem;
  --fs-h3-sm: 1.375rem;
  --fs-amount: 2.5rem;
  --fs-read: 1.125rem;
  --fs-hero-sub: 1.15625rem;
  --fs-lead: 1.09375rem;
  --fs-body: 1.03125rem;
  --fs-ui: 0.9375rem;
  --fs-small: 0.90625rem;
  --fs-xs: 0.8125rem;
  --fs-code: 0.84375rem;
  --fs-kicker: 0.78125rem;
  --fs-label: 0.6875rem;

  /* Layout */
  --max: 1200px;
  --gutter: clamp(20px, 4.5vw, 56px);
  --section-y: clamp(56px, 9vw, 120px);
  --header-h: 68px; /* full header height */
  --pin-h: 68px; /* the part that stays pinned while scrolling */

  /* Shape */
  --r-sm: 8px; /* buttons, fields */
  --r-md: 10px; /* tiles, windows, prompt line */
  --r-lg: 14px; /* cards, pricing table */
  --shadow-win: 0 30px 60px -30px rgb(0 0 0 / 0.75); /* windows only */

  /* Motion */
  --dur: 150ms;
}

/* Header: one 68 px row from 820 px; below, two rows (56 + 44) and only the
   44 px anchor row stays pinned (sticky top:-56px in SiteHeader). */
@media (max-width: 819.98px) {
  :root {
    --header-h: 100px;
    --pin-h: 44px;
  }
}

@media (max-width: 640.98px) {
  :root {
    --fs-amount: 2rem;
    --fs-read: 1.0625rem;
    --fs-hero-sub: 1.0625rem;
    --fs-body: 1rem;
  }
}

/* ==== src/styles/fonts.css ==== */
/**
 * Self-hosted fonts (public/fonts, generated by scripts/build-fonts.py from the
 * pinned fontsource/Google latin files, instanced with fontTools).
 * Base.astro preloads only Inter and Serif 600 (first view ≈ 50 KB).
 * Latin unicode-range = Google's; it has no → ☰ ≈ (arrows are SVG icons).
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/inter-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;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-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;
}

/* Metric-matched fallbacks (fontTools, letter-frequency average width) so the
   swap does not move the layout (CLS). */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('ArialMT');
  size-adjust: 107.48%;
  ascent-override: 90.14%;
  descent-override: 22.44%;
  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%;
}

/* ==== src/styles/base.css ==== */
/**
 * Base layer — element defaults on top of Tailwind's preflight.
 * No overflow-x:hidden on body: horizontal overflow is fixed where it starts.
 */

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--pin-h) + 12px);
    background-color: rgb(var(--c-bg));
  }

  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  body {
    margin: 0;
    min-height: 100vh;
    background-color: rgb(var(--c-bg));
    color: rgb(var(--c-text));
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.15;
    margin: 0;
  }

  p {
    margin: 0;
  }

  a {
    color: inherit;
  }

  img,
  video {
    display: block;
    max-width: 100%;
    height: auto;
  }

  code,
  kbd,
  samp,
  pre {
    font-family: var(--font-mono);
  }

  button {
    font: inherit;
    color: inherit;
  }

  /* Global focus ring: a dark band between element and ring keeps it visible
     over the video and light art. */
  :focus-visible {
    outline: 2px solid rgb(var(--c-coral));
    outline-offset: 3px;
    box-shadow: 0 0 0 3px rgb(var(--c-bg));
  }

  :focus:not(:focus-visible) {
    outline: none;
  }

  /* main#main receives focus from the skip link; it needs no ring. */
  main:focus {
    outline: none;
  }

  ::selection {
    background: rgb(var(--c-coral) / 0.35);
    color: rgb(var(--c-text));
  }

  [hidden] {
    display: none !important;
  }

  @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;
    }
  }
}

/* ==== src/styles/components.css ==== */
/**
 * Shared components (@layer components) — ported from mockups/orden.html onto
 * the tokens. Section-specific CSS lives in each section's scoped <style>.
 */

@layer components {
  /* ------------------------------------------------------------------ */
  /* Layout                                                              */
  /* ------------------------------------------------------------------ */
  .wrap {
    width: 100%;
    max-width: var(--max);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  .section {
    padding-block: var(--section-y);
    border-top: 1px solid var(--line);
  }

  .skip-link {
    position: absolute;
    left: 12px;
    top: -200px;
    z-index: 100;
    padding: 12px 16px;
    border-radius: var(--r-sm);
    background: rgb(var(--c-panel));
    color: rgb(var(--c-text));
    border: 1px solid rgb(var(--c-coral));
    font: 600 var(--fs-ui) / 1.2 var(--font-sans);
    text-decoration: none;
  }

  .skip-link:focus,
  .skip-link:focus-visible {
    top: 12px;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  /* ------------------------------------------------------------------ */
  /* Type scale                                                          */
  /* ------------------------------------------------------------------ */
  .display-hero {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-display);
    line-height: 1.05;
    letter-spacing: -0.015em;
    text-wrap: balance;
  }

  .display-hero:lang(en) {
    max-width: 13em;
  }

  .page-h1 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-page-h1);
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }

  .h2 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-h2);
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }

  .h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-h3);
    line-height: 1.15;
  }

  .h3-sm {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-h3-sm);
    line-height: 1.2;
  }

  .amount {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-amount);
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  .read {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: var(--fs-read);
    line-height: 1.7;
  }

  @media (max-width: 640.98px) {
    .read {
      line-height: 1.65;
    }
  }

  .hero-sub {
    font-size: var(--fs-hero-sub);
    line-height: 1.55;
    color: rgb(var(--c-soft));
  }

  .kicker {
    font: 600 var(--fs-kicker) / 1 var(--font-sans);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgb(var(--c-coral));
    margin-bottom: 14px;
  }

  .lead {
    color: rgb(var(--c-soft));
    font-size: var(--fs-lead);
    line-height: 1.6;
    max-width: 34em;
    margin-top: 14px;
  }

  .label {
    font: 600 var(--fs-label) / 1.2 var(--font-sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgb(var(--c-muted));
  }

  .tabular {
    font-variant-numeric: tabular-nums;
  }

  /* ------------------------------------------------------------------ */
  /* Links                                                               */
  /* ------------------------------------------------------------------ */
  .link {
    color: rgb(var(--c-soft));
    text-decoration: underline;
    text-decoration-color: rgb(var(--c-coral) / 0.7);
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    transition: color var(--dur) ease;
  }

  .link:hover {
    color: rgb(var(--c-text));
  }

  .link svg,
  .link .icon {
    display: inline-block;
    vertical-align: -0.15em;
  }

  /* ------------------------------------------------------------------ */
  /* Buttons                                                             */
  /* ------------------------------------------------------------------ */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 18px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font: 600 var(--fs-ui) / 1.2 var(--font-sans);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition:
      background-color var(--dur) ease,
      border-color var(--dur) ease,
      color var(--dur) ease;
  }

  .btn .icon {
    flex: none;
    width: 16px;
    height: 16px;
    transition: transform var(--dur) ease;
  }

  .btn:hover .icon-arrow {
    transform: translateX(3px);
  }

  .btn:hover .icon-arrow-left {
    transform: translateX(-3px);
  }

  .btn-coral {
    background-color: rgb(var(--c-coral));
    color: rgb(var(--c-on-coral));
  }

  .btn-coral:hover {
    background-color: rgb(var(--c-coral-hover));
  }

  .btn-coral:active {
    background-color: rgb(var(--c-coral-active));
  }

  .btn-line {
    background-color: transparent;
    color: rgb(var(--c-text));
    border-color: var(--line-2);
  }

  .btn-line:hover {
    border-color: rgb(var(--c-line) / 0.4);
  }

  .btn-sm {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.875rem;
  }

  .btn-lg {
    min-height: 50px;
    padding: 14px 24px;
    font-size: 1rem;
  }

  .btn[aria-disabled='true'] {
    background-color: rgb(var(--c-panel-2));
    color: rgb(var(--c-muted));
    border-color: var(--line-2);
    cursor: not-allowed;
  }

  .btn[aria-disabled='true']:hover .icon-arrow,
  .btn[aria-disabled='true']:hover .icon-arrow-left {
    transform: none;
  }

  .btn[aria-busy='true'] {
    cursor: progress;
  }

  /* ------------------------------------------------------------------ */
  /* Surfaces                                                            */
  /* ------------------------------------------------------------------ */
  .card {
    background: rgb(var(--c-panel));
    border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    padding: 26px;
  }

  @media (max-width: 640.98px) {
    .card {
      padding: 20px;
    }
  }

  /* Status: live / in preparation */
  .status-live,
  .status-soon {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font: 600 0.75rem / 1 var(--font-sans);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .status-live {
    color: rgb(var(--c-live));
  }

  .status-soon {
    color: rgb(var(--c-muted));
  }

  .status-live::before,
  .status-soon::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
  }

  .status-live::before {
    background: rgb(var(--c-live));
  }

  .status-soon::before {
    border: 1.5px solid rgb(var(--c-muted));
  }

  /* Pixel-art window. --w is the design width (250 street / 360 card); it
     never exceeds its container. Never image-rendering:pixelated. */
  .win {
    flex: none;
    width: var(--w, 360px);
    max-width: 100%;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow-win);
    background: #000;
  }

  .win img {
    display: block;
    width: 100%;
    height: auto;
  }

  .win--street {
    border-bottom: 0;
    border-radius: var(--r-md) var(--r-md) 0 0;
    box-shadow: none;
  }

  /* ------------------------------------------------------------------ */
  /* Forms                                                               */
  /* ------------------------------------------------------------------ */
  .field-label {
    display: block;
    font: 600 var(--fs-label) / 1.2 var(--font-sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgb(var(--c-muted));
    margin-bottom: 8px;
  }

  .field {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    background: rgb(var(--c-panel-2));
    color: rgb(var(--c-text));
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font: 400 var(--fs-ui) / 1.4 var(--font-sans);
    transition: border-color var(--dur) ease;
  }

  .field::placeholder {
    color: rgb(var(--c-muted));
    opacity: 1;
  }

  .field:hover {
    border-color: var(--line-hover);
  }

  .field[aria-invalid='true'] {
    border-color: rgb(var(--c-warn));
  }

  textarea.field {
    min-height: 8rem;
    resize: vertical;
  }

  select.field {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a6ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    cursor: pointer;
  }

  .field-error {
    margin-top: 6px;
    color: rgb(var(--c-warn));
    font-size: var(--fs-small);
    line-height: 1.4;
  }

  @media (max-width: 640.98px) {
    .field {
      font-size: 16px; /* iOS does not zoom at >= 16px */
    }
  }

  /* ------------------------------------------------------------------ */
  /* Code and copy                                                       */
  /* ------------------------------------------------------------------ */
  .code-inline {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: rgb(0 0 0 / 0.18);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.1em 0.35em;
    overflow-wrap: anywhere;
  }

  .code-block {
    font: 400 var(--fs-code) / 1.55 var(--font-mono);
    color: rgb(var(--c-soft));
    background: rgb(var(--c-code));
    border: 1px solid var(--line-2);
    border-radius: var(--r-md);
    padding: 16px 18px;
    overflow-x: auto;
    white-space: pre;
  }

  .copy {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    min-width: 36px;
    padding: 6px 12px;
    background: rgb(var(--c-panel-2));
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    color: rgb(var(--c-soft));
    font: 600 var(--fs-xs) / 1 var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition:
      color var(--dur) ease,
      border-color var(--dur) ease;
  }

  .copy:hover {
    color: rgb(var(--c-text));
    border-color: rgb(var(--c-line) / 0.4);
  }

  .copy .icon {
    width: 16px;
    height: 16px;
  }

  .copy[data-state='done'] {
    color: rgb(var(--c-live));
  }

  .copy[data-state='fail'] {
    color: rgb(var(--c-warn));
    white-space: normal;
    text-align: left;
    line-height: 1.3;
  }

  @media (pointer: coarse) {
    .copy {
      min-height: 44px;
      min-width: 44px;
    }
  }

  /* CopyField: label + value + copy button */
  .copyfield {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: center;
  }

  .copyfield > .copyfield-label {
    grid-column: 1 / -1;
    margin: 0;
  }

  /* the frontend's literal field name: keep its real casing */
  .copyfield-field {
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: rgb(var(--c-soft));
  }

  .copyfield-value {
    display: block;
    min-width: 0;
    font: 400 var(--fs-code) / 1.55 var(--font-mono);
    color: rgb(var(--c-text));
    background: rgb(0 0 0 / 0.18);
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    padding: 9px 12px;
    overflow-wrap: anywhere;
  }

  /* ------------------------------------------------------------------ */
  /* Tabs (WAI-ARIA, src/scripts/tabs.ts)                                */
  /* ------------------------------------------------------------------ */
  .tabs {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs [role='tab'] {
    flex: none;
    min-height: 44px;
    padding: 10px 14px 12px;
    margin-bottom: -1px;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    color: rgb(var(--c-muted));
    font: 500 var(--fs-small) / 1.2 var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--dur) ease;
  }

  .tabs [role='tab']:hover {
    color: rgb(var(--c-soft));
  }

  .tabs [role='tab'][aria-selected='true'] {
    color: rgb(var(--c-text));
    border-bottom-color: rgb(var(--c-coral));
  }

  .tabs [role='tab']:focus-visible {
    outline-offset: -2px;
    box-shadow: none;
  }

  /* keepHeight (set by tabs.ts only once it runs): the panels' own wrapper
     becomes a one-cell grid, so the box keeps the tallest panel's height;
     inactive panels are invisible + inert. */
  [data-tabs-stack] {
    display: grid;
  }

  [data-tabs-stack] > [role='tabpanel'] {
    grid-area: 1 / 1;
    min-width: 0;
  }

  [role='tabpanel'][data-inactive] {
    visibility: hidden;
  }

  /* No JS: every panel visible with its own heading; the tablist is hidden */
  [data-tabs]:not([data-tabs-ready]) [role='tablist'] {
    display: none;
  }

  [data-tabs][data-tabs-ready] [data-tabs-nojs-heading] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  /* ------------------------------------------------------------------ */
  /* Selectable tile (radio inside a label)                              */
  /* ------------------------------------------------------------------ */
  .tile {
    position: relative;
    display: block;
    cursor: pointer;
  }

  .tile > input[type='radio'],
  .tile > input[type='checkbox'] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
  }

  .tile-frame {
    display: block;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: rgb(var(--c-panel));
    overflow: hidden;
    transition:
      border-color var(--dur) ease,
      box-shadow var(--dur) ease;
  }

  .tile:hover .tile-frame {
    border-color: var(--line-2);
  }

  .tile:has(input:checked) .tile-frame {
    border-color: rgb(var(--c-coral));
    box-shadow:
      0 0 0 1px rgb(var(--c-coral)),
      0 0 0 4px rgb(var(--c-coral) / 0.15);
  }

  .tile:has(input:focus-visible) .tile-frame {
    outline: 2px solid rgb(var(--c-coral));
    outline-offset: 3px;
  }

  /* ------------------------------------------------------------------ */
  /* Menu path: <ol class="menu-path"> with a CSS-drawn separator        */
  /* ------------------------------------------------------------------ */
  .menu-path {
    display: inline;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .menu-path > li {
    display: inline;
  }

  .menu-path > li + li::before {
    content: '\203A';
    content: '\203A' / '';
    display: inline-block;
    margin-inline: 0.45em;
    color: rgb(var(--c-muted));
  }
}

/* ------------------------------------------------------------------ */
/* Confirmación en línea (sustituye a confirm() y al doble toque)       */
/* ------------------------------------------------------------------ */
.confirm-inline {
  margin-top: 12px; padding: 16px; border-radius: var(--r-md);
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-2); border-left: 3px solid rgb(var(--c-coral));
}
.confirm-inline--warn { border-left-color: rgb(var(--c-warn)); }
.confirm-inline__title { font: 600 1.0625rem / 1.3 var(--font-serif); color: rgb(var(--c-text)); }
.confirm-inline__title:focus { outline: none; }
.confirm-inline__title:focus-visible { outline: 2px solid rgb(var(--c-coral)); outline-offset: 3px; }
.confirm-inline__text { margin-top: 6px; color: rgb(var(--c-soft)); font-size: var(--fs-small); line-height: 1.55; max-width: 60em; }
.confirm-inline__text b { color: rgb(var(--c-text)); font-weight: 600; }
.confirm-inline__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.confirm-inline .table-wrap { margin-top: 8px; background: rgb(var(--c-panel)); }
.table tr.confirm-row > td { white-space: normal; background: rgb(var(--c-panel-2)); border-left: 3px solid rgb(var(--c-warn)); padding: 12px 14px; }
.table tr.confirm-row--coral > td { border-left-color: rgb(var(--c-coral)); }
.confirm-row .confirm-inline__text { margin: 0; }
.confirm-row .confirm-inline__actions { margin-top: 10px; }

/* Forced colours (Windows high contrast) */
@media (forced-colors: active) {
  .btn,
  .copy,
  .card,
  .win,
  .tile-frame {
    border: 1px solid CanvasText;
  }

  .btn-coral {
    border-color: ButtonText;
  }

  .tabs [role='tab'][aria-selected='true'],
  .tile:has(input:checked) .tile-frame {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }

  .status-live::before,
  .status-soon::before {
    border: 1px solid CanvasText;
  }
}

/* ==== src/styles/prose.css ==== */
/**
 * .prose-v — dark long-form prose for Legal.astro and docs/[slug].
 * Own ~60 lines instead of @tailwindcss/typography.
 */

@layer components {
  .prose-v {
    max-width: 42rem;
    color: rgb(var(--c-soft));
    font-size: var(--fs-body);
    line-height: 1.65;
  }

  .prose-v > * + * {
    margin-top: 1em;
  }

  .prose-v h1 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: var(--fs-page-h1);
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: rgb(var(--c-text));
    text-wrap: balance;
  }

  .prose-v h2 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.6rem;
    line-height: 1.2;
    color: rgb(var(--c-text));
    margin-top: 2.2em;
    padding-top: 1.1em;
    border-top: 1px solid var(--line);
  }

  .prose-v h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.25;
    color: rgb(var(--c-text));
    margin-top: 1.8em;
  }

  .prose-v h2 + *,
  .prose-v h3 + * {
    margin-top: 0.75em;
  }

  .prose-v ul,
  .prose-v ol {
    padding-left: 1.3em;
  }

  .prose-v ul {
    list-style: disc;
  }

  .prose-v ol {
    list-style: decimal;
  }

  .prose-v li + li {
    margin-top: 0.4em;
  }

  .prose-v li::marker {
    color: rgb(var(--c-muted));
  }

  .prose-v a {
    color: rgb(var(--c-soft));
    text-decoration: underline;
    text-decoration-color: rgb(var(--c-coral) / 0.7);
    text-underline-offset: 4px;
    overflow-wrap: anywhere;
  }

  .prose-v a:hover {
    color: rgb(var(--c-text));
  }

  .prose-v strong,
  .prose-v b {
    color: rgb(var(--c-text));
    font-weight: 600;
  }

  .prose-v code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: rgb(0 0 0 / 0.18);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.1em 0.35em;
    overflow-wrap: anywhere;
  }

  .prose-v pre {
    font: 400 var(--fs-code) / 1.55 var(--font-mono);
    background: rgb(var(--c-code));
    border: 1px solid var(--line-2);
    border-radius: var(--r-md);
    padding: 16px 18px;
    overflow-x: auto;
  }

  .prose-v pre code {
    background: none;
    border: 0;
    padding: 0;
    font-size: inherit;
    overflow-wrap: normal;
  }

  .prose-v hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin-block: 2em;
  }

  .prose-v blockquote {
    border-left: 2px solid var(--line-2);
    padding-left: 1em;
    color: rgb(var(--c-muted));
  }

  .prose-v table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-small);
    display: block;
    overflow-x: auto;
  }

  .prose-v th,
  .prose-v td {
    text-align: left;
    padding: 8px 10px;
    border-top: 1px solid var(--line);
    vertical-align: top;
  }

  .prose-v th {
    color: rgb(var(--c-text));
    font-weight: 600;
  }
}

/* ===================================================================== */
/* APP — componentes propios de la app (sin capa: ganan a base/components */
/* de la web). Contrato de clases: mockups/app/CIMIENTOS.md.              */
/* No renombrar clases publicadas.                                        */
/* ===================================================================== */

:root {
  --appbar-h: 56px;
  --side-w: 288px; /* barra lateral (lista de chats, secciones de cuenta) */
  --rail-w: 320px; /* panel derecho (ajustes de imagen, detalles) */
  --read-max: 42rem; /* ancho de lectura del chat */
  --z-appbar: 30;
  --z-drawer: 40;
  --z-dialog: 50;
  --z-toast: 60;
  --tap: 44px;
}

/* ------------------------------------------------------------------ */
/* Utilidades mínimas                                                  */
/* ------------------------------------------------------------------ */
.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }
.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; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: rgb(var(--c-muted)); }
.soft { color: rgb(var(--c-soft)); }
.mono { font-family: var(--font-mono); font-size: var(--fs-code); }
.t-xs { font-size: var(--fs-xs); line-height: 1.4; }
.t-sm { font-size: var(--fs-small); line-height: 1.45; }
.t-ui { font-size: var(--fs-ui); line-height: 1.45; }
.serif { font-family: var(--font-serif); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ------------------------------------------------------------------ */
/* Iconos (sprite /img/icons.svg, <use href="/img/icons.svg#i-nombre">) */
/* ------------------------------------------------------------------ */
.icon {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }

/* ------------------------------------------------------------------ */
/* Esqueleto de la app: barra 56 px + área de trabajo a alto completo  */
/* ------------------------------------------------------------------ */
html.app-html, html.app-html body { height: 100%; }
.app {
  display: grid;
  grid-template-rows: var(--appbar-h) minmax(0, 1fr);
  height: 100vh;
  height: var(--app-h, 100dvh); /* --app-h: respaldo de visualViewport para iOS (20-shell) */
  min-height: 0;
}
.app-main { min-height: 0; min-width: 0; overflow: auto; }

/* Página de lectura/ajustes (cuenta, admin): columna centrada con scroll */
.page {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding: 32px var(--gutter) 64px;
}
.page--narrow { max-width: 720px; }
.page--wide { max-width: 1320px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.page-title { font: 600 1.75rem / 1.15 var(--font-serif); letter-spacing: -0.01em; }
.page-sub { margin-top: 6px; color: rgb(var(--c-soft)); font-size: var(--fs-ui); line-height: 1.5; max-width: 40em; }

/* Section inside a page */
.sect + .sect { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--line); }
.sect-title { font: 600 1.25rem / 1.2 var(--font-serif); margin-bottom: 4px; }
.sect-sub { color: rgb(var(--c-muted)); font-size: var(--fs-small); line-height: 1.5; margin-bottom: 16px; }

/* Split: lateral + contenido (+ rail opcional). <900 el lateral pasa a cajón. */
.split {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.split--rail { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--rail-w); }
.split--rail-only { grid-template-columns: minmax(0, 1fr) var(--rail-w); }
.split > * { min-height: 0; min-width: 0; }

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgb(var(--c-sink));
  border-right: 1px solid var(--line);
}
.side--right { border-right: 0; border-left: 1px solid var(--line); background: rgb(var(--c-panel) / 0.5); }
.side__head { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.side__body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px; }
.side__foot { padding: 12px; border-top: 1px solid var(--line); }
.side__close { display: none; }

/* ------------------------------------------------------------------ */
/* Barra de app (56 px)                                                */
/* ------------------------------------------------------------------ */
.appbar {
  position: relative;
  z-index: var(--z-appbar);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 28px;
  height: var(--appbar-h);
  padding-inline: 16px;
  background: rgb(var(--c-bg));
  border-bottom: 1px solid var(--line);
}
.appbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  color: rgb(var(--c-text));
  text-decoration: none;
  border-radius: var(--r-sm);
}
.appbar__mark { width: 28px; height: 28px; object-fit: contain; flex: none; }
.appbar__name { font: 600 21px / 1 var(--font-serif); letter-spacing: -0.01em; }

/* La pestaña ocupa el alto de la barra (objetivo de toque de 55 px, subrayado sobre el
   borde inferior): el hijo de la rejilla es el <nav>, que se estira y pasa el alto a la lista. */
.appbar > nav { align-self: stretch; display: flex; min-width: 0; }
.appbar__tabs { display: flex; flex: 1 1 auto; align-self: stretch; gap: 4px; margin: 0; padding: 0; list-style: none; min-width: 0; }
.appbar__tabs > li { display: flex; }
.appbar__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-inline: 12px;
  background: none;
  border: 0;
  color: rgb(var(--c-soft));
  font: 500 14.5px / 1 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur) ease;
}
.appbar__tab:hover, .appbar__tab[aria-current] { color: rgb(var(--c-text)); }
.appbar__tab[aria-current]::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  background: rgb(var(--c-coral));
}
.appbar__tab:focus-visible { outline-offset: -4px; box-shadow: none; }
.appbar__tab .icon { color: rgb(var(--c-muted)); }
.appbar__tab[aria-current] .icon { color: rgb(var(--c-coral)); }

.appbar__end { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

/* Plan: solo la palabra del plan (Libre / Pro / Pro · tester), enlace a
   Cuenta > Plan. SIN contador: el consumo se ve donde se gasta (compositor de
   imágenes, aviso de tokens del chat desde el 80 %, Cuenta > Plan y uso).
   app.js escribe textContent en [data-plan]: el <b> es opcional. */
.appbar__plan {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: rgb(var(--c-text));
  font: 600 var(--fs-xs) / 1 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
}
.appbar__plan:hover { border-color: rgb(var(--c-line) / 0.4); }
.appbar__plan b { color: inherit; font-weight: 600; text-transform: none; }
.appbar__plan[data-plan-kind='pro'], .appbar__plan[data-plan-kind='tester'] { border-color: var(--pro-border); color: rgb(var(--c-coral)); }
.appbar__plan[data-plan-kind='tester'] { color: rgb(var(--c-soft)); font-weight: 500; }
.appbar__plan[data-plan-kind='tester'] b { color: rgb(var(--c-coral)); }
@media (pointer: coarse) { .appbar__plan { min-height: var(--tap); } }

.appbar__lang { display: inline-flex; align-items: center; color: rgb(var(--c-muted)); font: 500 12.5px / 1 var(--font-sans); letter-spacing: 0.04em; white-space: nowrap; }
.appbar__lang [aria-current] { color: rgb(var(--c-text)); font-weight: 600; padding-inline: 4px; }
.appbar__lang [aria-hidden='true'] { padding-inline: 2px; }
.appbar__lang button, .appbar__lang a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: var(--tap);
  background: none; border: 0; padding: 0;
  color: inherit; font: inherit; letter-spacing: inherit; text-decoration: none; cursor: pointer;
  border-radius: var(--r-sm);
}
.appbar__lang button:hover, .appbar__lang a:hover { color: rgb(var(--c-text)); }

/* Sesión: botón con la inicial del email (no el icono de persona, que ya es
   el de la pestaña Cuenta) + menú con email, plan, idioma (< 720), Escribirnos,
   vaelico.ai, admin (si is_admin) y Salir. Visible a todos los anchos. */
.appbar__menu { display: inline-flex; }
.appbar__me .glyph { --g: 30px; border-radius: 999px; font-size: 15px; }
.appbar__me[aria-expanded='true'] .glyph { border-color: rgb(var(--c-coral)); color: rgb(var(--c-text)); }
.acct-menu { width: 300px; }
.acct-menu .menu__head { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 8px; }
/* .appbar__email ya no va suelto en la barra: vive en la cabecera del menú */
.appbar__email, .acct-menu .acct-email { display: block; max-width: 100%; color: rgb(var(--c-text)); font-size: var(--fs-small); }
.acct-menu .menu__item .ext { margin-left: auto; width: 14px; height: 14px; }
.acct-menu .menu__item .chk { visibility: hidden; margin-left: auto; }
.acct-menu .menu__item[aria-checked='true'] { color: rgb(var(--c-text)); }
.acct-menu .menu__item[aria-checked='true'] .chk { visibility: visible; color: rgb(var(--c-coral)); }
.acct-menu .only-narrow { display: none; }

@media (max-width: 1023.98px) {
  .appbar { column-gap: 16px; }
}
/* < 720: sin nombre de marca, pestañas centradas; plan e idioma pasan al
   menú de sesión (lo único visible a la derecha). */
@media (max-width: 719.98px) {
  .appbar { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 8px; padding-inline: 8px 4px; }
  .appbar__name { display: none; }
  .appbar__tabs { justify-content: center; gap: 0; }
  .appbar__tab { padding-inline: 10px; font-size: 14px; gap: 6px; }
  .appbar__end > :not(.appbar__menu) { display: none; }
  .acct-menu .only-narrow { display: block; }
  .acct-menu { width: min(320px, calc(100vw - 16px)); }
}
@media (max-width: 359.98px) {
  .appbar__tab .icon { display: none; }
}

/* ------------------------------------------------------------------ */
/* Botones (añadidos a .btn .btn-coral .btn-line .btn-sm .btn-lg web)  */
/* ------------------------------------------------------------------ */
.btn-ghost {
  background: transparent;
  color: rgb(var(--c-soft));
  border-color: transparent;
}
.btn-ghost:hover { background: rgb(var(--c-line) / 0.06); color: rgb(var(--c-text)); }
.btn-danger {
  background: transparent;
  color: rgb(var(--c-warn));
  border-color: rgb(var(--c-warn) / 0.45);
}
.btn-danger:hover { border-color: rgb(var(--c-warn)); background: rgb(var(--c-warn) / 0.08); }
.btn-danger.btn-solid { background: rgb(var(--c-warn)); color: rgb(var(--c-on-coral)); border-color: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-icon { min-width: var(--tap); width: var(--tap); padding: 0; }
.btn-icon.btn-sm { min-width: 40px; width: 40px; }
.btn-icon .icon { width: 18px; height: 18px; }
.btn-xs { min-height: 32px; padding: 6px 10px; font-size: var(--fs-xs); gap: 6px; }
.btn-xs .icon { width: 14px; height: 14px; }
@media (pointer: coarse) { .btn-xs, .btn-sm { min-height: var(--tap); } .btn-icon.btn-sm { min-width: var(--tap); width: var(--tap); } }
.btn[aria-pressed='true'] { border-color: rgb(var(--c-coral)); color: rgb(var(--c-text)); background: rgb(var(--c-coral) / 0.1); }
.btn[aria-busy='true'] > .spinner { display: inline-block; }
.btn:disabled { background: rgb(var(--c-panel-2)); color: rgb(var(--c-muted)); border-color: var(--line-2); cursor: not-allowed; }
.btn-ghost:disabled, .btn-ghost[aria-disabled='true'] { background: transparent; border-color: transparent; }

.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;
}
.btn > .spinner { display: none; }
@keyframes v-spin { to { transform: rotate(360deg); } }

.kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 500 0.75rem / 1.4 var(--font-mono);
  color: rgb(var(--c-soft));
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Campos (añadidos a .field .field-label .field-error web)            */
/* ------------------------------------------------------------------ */
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.fgroup { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.fgroup + .fgroup { margin-top: 16px; }
.stack > .fgroup + .fgroup, .row > .fgroup + .fgroup { margin-top: 0; }
.field-help { margin-top: 6px; color: rgb(var(--c-muted)); font-size: var(--fs-xs); line-height: 1.45; }
.field-count { color: rgb(var(--c-muted)); font: 400 var(--fs-xs) / 1 var(--font-sans); font-variant-numeric: tabular-nums; }
.field-sm { min-height: 36px; padding: 6px 10px; font-size: var(--fs-small); }
.field:focus-visible { outline-offset: 1px; border-color: rgb(var(--c-coral)); box-shadow: none; }
.field:disabled { opacity: 0.6; cursor: not-allowed; }
.field--mono { font-family: var(--font-mono); font-size: var(--fs-code); }

/* Textarea que crece con el texto (field-sizing; fallback: el JS ajusta
   style.height). Tope --grow-max y luego scroll. */
textarea.field.field-grow {
  min-height: 44px;
  max-height: var(--grow-max, 40vh);
  resize: none;
  field-sizing: content;
  line-height: 1.5;
}
/* Textarea de escritura larga: serif (se lee lo que se escribe) */
.field-read { font: 400 var(--fs-body) / 1.6 var(--font-serif); }

/* Campo + botón pegado (buscar, copiar, enviar) */
.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; min-height: var(--tap); padding-block: 10px; cursor: pointer; font-size: var(--fs-ui); line-height: 1.45; color: rgb(var(--c-soft)); }
.check > input {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 18px; height: 18px; margin: 1px 0 0;
  border: 1.5px solid var(--line-strong); border-radius: 4px;
  background: rgb(var(--c-panel-2)); cursor: pointer;
  display: grid; place-content: center;
}
.check > input::before {
  content: ''; width: 10px; height: 10px;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: rgb(var(--c-on-coral)); transform: scale(0);
}
.check > input:checked { background: rgb(var(--c-coral)); border-color: rgb(var(--c-coral)); }
.check > input:checked::before { transform: scale(1); }
.check > input:focus-visible { outline: 2px solid rgb(var(--c-coral)); outline-offset: 2px; box-shadow: none; }

/* Interruptor: <label class="switch"><input type="checkbox" role="switch"><span class="switch__track"></span><span>Texto</span></label> */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; font-size: var(--fs-ui); color: rgb(var(--c-soft)); }
.switch > input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch__track {
  position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px;
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-strong);
  transition: background-color var(--dur) ease, border-color var(--dur) ease;
}
.switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: rgb(var(--c-muted)); transition: transform var(--dur) ease, background-color var(--dur) ease;
}
.switch > input:checked + .switch__track { background: rgb(var(--c-coral)); border-color: rgb(var(--c-coral)); }
.switch > input:checked + .switch__track::after { transform: translateX(16px); background: rgb(var(--c-on-coral)); }
.switch > input:focus-visible + .switch__track { outline: 2px solid rgb(var(--c-coral)); outline-offset: 3px; }
.switch > input:checked ~ .switch__label { color: rgb(var(--c-text)); }

/* Segmentado: radiogroup de 2–5 opciones cortas */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: rgb(var(--c-sink)); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg--block { display: flex; }
.seg--block > label { 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 {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 36px; padding: 6px 12px; border-radius: 6px;
  color: rgb(var(--c-muted)); font: 500 var(--fs-small) / 1.1 var(--font-sans); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur) ease, color var(--dur) ease;
}
.seg > label:hover > span { color: rgb(var(--c-soft)); }
.seg > label > input:checked + span { background: rgb(var(--c-panel-2)); color: rgb(var(--c-text)); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg > label > input:focus-visible + span { outline: 2px solid rgb(var(--c-coral)); outline-offset: -2px; }
.seg small { color: rgb(var(--c-muted)); font-size: var(--fs-xs); font-weight: 400; }
@media (pointer: coarse) { .seg > label > span { min-height: var(--tap); } }

/* Deslizador */
.range { width: 100%; height: var(--tap); background: none; appearance: none; -webkit-appearance: none; cursor: pointer; accent-color: rgb(var(--c-coral)); }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgb(var(--c-line) / 0.25); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: rgb(var(--c-line) / 0.25); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: rgb(var(--c-coral)); border: 3px solid rgb(var(--c-bg)); }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: rgb(var(--c-coral)); border: 3px solid rgb(var(--c-bg)); }
.range:focus-visible { outline-offset: 0; box-shadow: none; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row > output { min-width: 3.5ch; text-align: right; font: 500 var(--fs-small) / 1 var(--font-mono); color: rgb(var(--c-text)); }

/* Combobox con lista (artistas, modelos): patrón ARIA 1.2 */
.combo { position: relative; min-width: 0; }
.combo > .field { padding-right: 36px; }
.combo__icon { position: absolute; right: 12px; top: 14px; color: rgb(var(--c-muted)); pointer-events: none; }
.combo__list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px; overflow: auto; margin: 0; padding: 4px; list-style: none;
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.6);
}
.combo__opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  min-height: 40px; padding: 9px 10px; border-radius: 6px;
  color: rgb(var(--c-soft)); font-size: var(--fs-small); cursor: pointer;
}
.combo__opt:hover, .combo__opt[data-active] { background: rgb(var(--c-line) / 0.08); color: rgb(var(--c-text)); }
.combo__opt[aria-selected='true'] { color: rgb(var(--c-text)); box-shadow: inset 2px 0 0 rgb(var(--c-coral)); }
.combo__opt .meta { color: rgb(var(--c-muted)); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.combo__empty { padding: 10px; color: rgb(var(--c-muted)); font-size: var(--fs-small); }

/* ------------------------------------------------------------------ */
/* Superficies                                                         */
/* ------------------------------------------------------------------ */
/* .card (web, 14 px, 26 px de relleno) para bloques grandes; .panel para
   bloques de trabajo densos. */
.panel { background: rgb(var(--c-panel)); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 16px; min-width: 0; }
.panel--flush { padding: 0; overflow: hidden; }
.panel--sunk { background: rgb(var(--c-sink)); border-color: var(--line); }
.panel--pro { background: linear-gradient(var(--pro-tint), var(--pro-tint)), rgb(var(--c-panel)); border-color: var(--pro-border); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel__title { font: 600 var(--fs-ui) / 1.3 var(--font-sans); color: rgb(var(--c-text)); }
.panel__body { padding: 16px; }
.panel__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.card--pro { background: linear-gradient(var(--pro-tint), var(--pro-tint)), rgb(var(--c-panel)); border-color: var(--pro-border); }

/* Pares etiqueta/valor (datos de cuenta, detalles de imagen) */
.kv { display: grid; grid-template-columns: minmax(8em, max-content) minmax(0, 1fr); gap: 8px 20px; margin: 0; font-size: var(--fs-small); }
.kv > dt { color: rgb(var(--c-muted)); }
.kv > dd { margin: 0; color: rgb(var(--c-text)); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (max-width: 479.98px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv > dd + dt { margin-top: 10px; } }

/* Aviso en línea (sesión caducada, límite, error de red) */
.notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-sm);
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-2);
  color: rgb(var(--c-soft)); font-size: var(--fs-small); line-height: 1.5;
}
.notice > .icon { margin-top: 2px; color: rgb(var(--c-muted)); }
.notice__body { flex: 1 1 auto; min-width: 0; }
.notice__title { color: rgb(var(--c-text)); font-weight: 600; }
.notice__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notice--warn { border-color: rgb(var(--c-warn) / 0.45); }
.notice--warn > .icon { color: rgb(var(--c-warn)); }
.notice--coral { border-color: var(--pro-border); background: linear-gradient(var(--pro-tint), var(--pro-tint)), rgb(var(--c-panel-2)); }
.notice--coral > .icon { color: rgb(var(--c-coral)); }
.notice--ok > .icon { color: rgb(var(--c-live)); }

/* Estado vacío (primer uso) */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; max-width: 34rem; padding: 24px 0; }
.empty--center { align-items: center; text-align: center; margin-inline: auto; }
.empty__title { font: 600 1.375rem / 1.2 var(--font-serif); color: rgb(var(--c-text)); }
.empty__text { color: rgb(var(--c-soft)); font-size: var(--fs-ui); line-height: 1.55; }
.empty__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.empty--center .empty__actions { justify-content: center; }

/* Esqueleto de carga */
.skel { display: block; border-radius: 6px; background: rgb(var(--c-line) / 0.08); }
.skel-line { height: 0.8em; margin-block: 0.45em; }
@media (prefers-reduced-motion: no-preference) {
  .skel { animation: v-pulse 1.4s ease-in-out infinite; }
}
@keyframes v-pulse { 50% { opacity: 0.5; } }

/* Marco de imagen (galería, resultado). Nunca image-rendering:pixelated. */
.frame { position: relative; display: block; border-radius: var(--r-md); overflow: hidden; background: rgb(var(--c-sink)); border: 1px solid var(--line); }
.frame > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame__badge { position: absolute; left: 8px; top: 8px; }
.frame__actions { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; }
.frame__actions .btn-icon { background: rgb(var(--c-scrim) / 0.72); color: rgb(var(--c-text)); border-color: var(--line-2); }
.frame__foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; background: linear-gradient(transparent, rgb(var(--c-scrim) / 0.85)); color: rgb(var(--c-soft)); font-size: var(--fs-xs); }
.frame--pending { display: grid; place-items: center; aspect-ratio: var(--ar, 1); border-style: dashed; border-color: var(--line-2); color: rgb(var(--c-muted)); font-size: var(--fs-small); }
.frame--failed { border-color: rgb(var(--c-warn) / 0.45); }

/* Glifo de personaje/chat (inicial en caja, sin emojis) */
.glyph {
  display: inline-grid; place-items: center; flex: none;
  width: var(--g, 32px); height: var(--g, 32px); border-radius: 8px;
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-2);
  color: rgb(var(--c-soft)); font: 600 calc(var(--g, 32px) * 0.5) / 1 var(--font-serif);
}

/* ------------------------------------------------------------------ */
/* Listas densas (chats, claves, historial)                            */
/* ------------------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.list__item {
  position: relative; display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: var(--tap); padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: rgb(var(--c-soft)); text-align: left; text-decoration: none; font: inherit; font-size: var(--fs-small);
  cursor: pointer; transition: background-color var(--dur) ease, color var(--dur) ease;
}
.list__item:hover { background: rgb(var(--c-line) / 0.06); color: rgb(var(--c-text)); }
.list__item[aria-current], .list__item[aria-selected='true'] { background: rgb(var(--c-panel-2)); color: rgb(var(--c-text)); }
.list__item[aria-current]::before, .list__item[aria-selected='true']::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: rgb(var(--c-coral)); }
.list__item:focus-visible { outline-offset: -2px; box-shadow: none; }
.list__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.list__meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgb(var(--c-muted)); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
/* Fila con acciones: <li class="list__row"><a class="list__item">…</a><div class="list__actions">…</div></li> */
.list__row { position: relative; display: flex; align-items: center; }
.list__row > .list__item { padding-right: 44px; }
.list__actions { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: flex; opacity: 0; transition: opacity var(--dur) ease; }
.list__row:hover .list__actions, .list__row:focus-within .list__actions, .list__actions:has([aria-expanded='true']) { opacity: 1; }
@media (hover: none) { .list__actions { opacity: 1; } }
.list-label { padding: 14px 10px 6px; font: 600 var(--fs-label) / 1.2 var(--font-sans); letter-spacing: 0.1em; text-transform: uppercase; color: rgb(var(--c-muted)); }

/* Lista con bordes (ajustes, claves): filas de 56+ px separadas por línea */
.rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-md); background: rgb(var(--c-panel)); }
.rows > li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 56px; padding: 12px 16px; }
.rows > li + li { border-top: 1px solid var(--line); }
.rows__main { flex: 1 1 14rem; min-width: 0; }
.rows__title { color: rgb(var(--c-text)); font-size: var(--fs-ui); line-height: 1.35; }
.rows__meta { color: rgb(var(--c-muted)); font-size: var(--fs-xs); line-height: 1.45; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* Tablas (admin, uso)                                                 */
/* ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--r-md); background: rgb(var(--c-panel)); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.table caption { text-align: left; padding: 12px 14px; color: rgb(var(--c-muted)); font-size: var(--fs-xs); caption-side: bottom; }
.table th, .table td { padding: 10px 14px; line-height: 1.4; text-align: left; vertical-align: middle; border-top: 1px solid var(--line); white-space: nowrap; }
.table thead th { position: sticky; top: 0; z-index: 1; border-top: 0; background: rgb(var(--c-panel-2)); color: rgb(var(--c-muted)); font: 600 var(--fs-label) / 1.2 var(--font-sans); letter-spacing: 0.1em; text-transform: uppercase; }
.table tbody tr:hover { background: rgb(var(--c-line) / 0.04); }
.table tbody tr[aria-selected='true'] { background: rgb(var(--c-coral) / 0.06); }
.table .num { text-align: right; }
.table .wrap-cell { white-space: normal; min-width: 16rem; }
.table td.mono, .table .id { font-family: var(--font-mono); font-size: var(--fs-code); color: rgb(var(--c-soft)); }
.table--dense th, .table--dense td { padding: 6px 12px; }
.table th[aria-sort] button { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }

/* Cifra destacada (panel de admin, uso) */
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat__value { font: 600 1.75rem / 1 var(--font-serif); font-variant-numeric: tabular-nums; color: rgb(var(--c-text)); }
.stat__label { font: 600 var(--fs-label) / 1.2 var(--font-sans); letter-spacing: 0.1em; text-transform: uppercase; color: rgb(var(--c-muted)); }
.stat__delta { font-size: var(--fs-xs); color: rgb(var(--c-muted)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* ------------------------------------------------------------------ */
/* Cuota y progreso                                                    */
/* ------------------------------------------------------------------ */
/* <div class="meter" data-level="ok|warn|full"><div class="meter__row"><span class="meter__label">…</span><span class="meter__value">…</span></div>
     <div class="meter__bar" role="progressbar" aria-valuenow… style="--v:40%"><span class="meter__fill"></span></div></div> */
.meter { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meter__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: var(--fs-small); }
.meter__label { color: rgb(var(--c-soft)); }
.meter__value { color: rgb(var(--c-text)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter__value small { color: rgb(var(--c-muted)); font-size: var(--fs-xs); }
.meter__bar { position: relative; height: 6px; border-radius: 3px; background: rgb(var(--c-line) / 0.12); overflow: hidden; }
.meter__fill { position: absolute; inset: 0 auto 0 0; width: var(--v, 0%); border-radius: inherit; background: rgb(var(--c-soft)); transition: width 300ms ease; }
.meter[data-level='warn'] .meter__fill { background: rgb(var(--c-coral)); }
.meter[data-level='full'] .meter__fill { background: rgb(var(--c-warn)); }
.meter[data-level='full'] .meter__value { color: rgb(var(--c-warn)); }
.meter__note { color: rgb(var(--c-muted)); font-size: var(--fs-xs); }
.meter--sm .meter__bar { height: 4px; }

/* Progreso de una tarea (imagen generándose): determinado o indeterminado */
.progress { position: relative; height: 3px; border-radius: 2px; background: rgb(var(--c-line) / 0.12); overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; width: var(--v, 0%); background: rgb(var(--c-coral)); transition: width 300ms ease; }
.progress[data-indeterminate] > span { width: 35%; }
@media (prefers-reduced-motion: no-preference) {
  .progress[data-indeterminate] > span { animation: v-indet 1.3s ease-in-out infinite; }
}
@keyframes v-indet { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* ------------------------------------------------------------------ */
/* Chips de estado                                                     */
/* ------------------------------------------------------------------ */
/* <span class="chip chip--queued">En cola</span> — siempre con texto;
   el color nunca es la única señal. */
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 24px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); background: rgb(var(--c-bg) / 0.6);
  color: rgb(var(--c-soft)); font: 600 0.75rem / 1.2 var(--font-sans); letter-spacing: 0.02em; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip--plain::before { display: none; }
.chip--queued { color: rgb(var(--c-muted)); }
.chip--queued::before { background: none; border: 1.5px solid currentColor; }
.chip--running { color: rgb(var(--c-coral)); border-color: rgb(var(--c-coral) / 0.45); }
@media (prefers-reduced-motion: no-preference) {
  .chip--running::before { animation: v-pulse 1.1s ease-in-out infinite; }
}
.chip--done { color: rgb(var(--c-live)); border-color: rgb(var(--c-live) / 0.35); }
.chip--failed { color: rgb(var(--c-warn)); border-color: rgb(var(--c-warn) / 0.45); }
.chip--failed::before { border-radius: 1px; transform: rotate(45deg); width: 6px; height: 6px; }
.chip--live { color: rgb(var(--c-live)); border-color: rgb(var(--c-live) / 0.35); }
.chip--limit { color: rgb(var(--c-warn)); border-color: rgb(var(--c-warn) / 0.45); background: rgb(var(--c-warn) / 0.08); }
.chip--limit::before { border-radius: 1px; width: 8px; height: 2px; }
.chip--pro { color: rgb(var(--c-coral)); border-color: var(--pro-border); }
.chip--pro::before, .chip--free::before, .chip--tester::before { display: none; }
.chip--free { color: rgb(var(--c-soft)); }
.chip--tester { color: rgb(var(--c-text)); border-style: dashed; }
.chip--off { color: rgb(var(--c-muted)); }
.chip--off::before { background: none; border: 1.5px solid currentColor; }

/* ------------------------------------------------------------------ */
/* Menú desplegable (acciones de fila, menú de la barra en móvil)      */
/* ------------------------------------------------------------------ */
.menu-anchor { position: relative; }
.menu {
  position: absolute; z-index: var(--z-drawer); right: 0; top: calc(100% + 6px);
  min-width: 220px; max-width: min(320px, calc(100vw - 16px)); padding: 6px; margin: 0; list-style: none;
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-2); border-radius: var(--r-md);
  box-shadow: 0 20px 44px -16px rgb(0 0 0 / 0.7);
}
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px;
  border: 0; border-radius: 6px; background: none; color: rgb(var(--c-soft)); font: 500 var(--fs-small) / 1.2 var(--font-sans);
  text-align: left; text-decoration: none; cursor: pointer;
}
.menu__item:hover, .menu__item:focus-visible { background: rgb(var(--c-line) / 0.08); color: rgb(var(--c-text)); outline: none; box-shadow: none; }
.menu__item .icon { color: rgb(var(--c-muted)); }
.menu__item--danger { color: rgb(var(--c-warn)); }
.menu__item--danger .icon { color: currentColor; }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu__head { padding: 8px 10px 6px; color: rgb(var(--c-muted)); font-size: var(--fs-xs); }
@media (pointer: coarse) { .menu__item { min-height: var(--tap); } }

/* ------------------------------------------------------------------ */
/* Cajones laterales + velo                                            */
/* ------------------------------------------------------------------ */
.scrim {
  position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1);
  background: rgb(var(--c-scrim) / 0.72);
}
.drawer {
  position: fixed; z-index: var(--z-drawer); top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  width: min(86vw, 340px);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgb(var(--c-sink)); border-right: 1px solid var(--line-2);
  box-shadow: 24px 0 48px -24px rgb(0 0 0 / 0.7);
  transform: translateX(-102%); visibility: hidden;
  transition: transform 200ms ease, visibility 0s linear 200ms;
}
.drawer--right { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--line-2); transform: translateX(102%); box-shadow: -24px 0 48px -24px rgb(0 0 0 / 0.7); }
.drawer[data-open] { transform: none; visibility: visible; transition: transform 200ms ease; }

/* .side se vuelve cajón por debajo de 900 px (lista de chats, secciones);
   .side--right (rail) por debajo de 1200 px. */
@media (max-width: 1199.98px) {
  .split--rail { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .split--rail-only { grid-template-columns: minmax(0, 1fr); }
  .side--right {
    position: fixed; z-index: var(--z-drawer); top: 0; bottom: 0; right: 0;
    width: min(92vw, 380px); background: rgb(var(--c-sink));
    border-left: 1px solid var(--line-2); box-shadow: -24px 0 48px -24px rgb(0 0 0 / 0.7);
    transform: translateX(102%); visibility: hidden;
    transition: transform 200ms ease, visibility 0s linear 200ms;
  }
  .side--right[data-open] { transform: none; visibility: visible; transition: transform 200ms ease; }
  .side--right .side__close { display: inline-flex; }
}
@media (max-width: 899.98px) {
  .split, .split--rail { grid-template-columns: minmax(0, 1fr); }
  .side:not(.side--right) {
    position: fixed; z-index: var(--z-drawer); top: 0; bottom: 0; left: 0;
    width: min(86vw, 340px); border-right: 1px solid var(--line-2);
    box-shadow: 24px 0 48px -24px rgb(0 0 0 / 0.7);
    transform: translateX(-102%); visibility: hidden;
    transition: transform 200ms ease, visibility 0s linear 200ms;
  }
  .side:not(.side--right)[data-open] { transform: none; visibility: visible; transition: transform 200ms ease; }
  .side .side__close { display: inline-flex; }
}
.only-drawer { display: none; }
@media (max-width: 899.98px) { .only-drawer { display: inline-flex; } .hide-sm { display: none !important; } }

/* ------------------------------------------------------------------ */
/* Diálogo (<dialog class="dialog">, showModal())                     */
/* ------------------------------------------------------------------ */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: rgb(var(--c-panel)); color: rgb(var(--c-text));
  box-shadow: 0 40px 80px -30px rgb(0 0 0 / 0.8);
}
.dialog--wide { width: min(880px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(var(--c-scrim) / 0.78); }
.dialog[open] { display: flex; flex-direction: column; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 0 24px; }
.dialog__title { font: 600 1.375rem / 1.2 var(--font-serif); }
.dialog__body { padding: 12px 24px 20px; overflow: auto; color: rgb(var(--c-soft)); font-size: var(--fs-ui); line-height: 1.55; }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; border-top: 1px solid var(--line); }
@media (max-width: 559.98px) {
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .dialog__foot { flex-direction: column-reverse; align-items: stretch; }
  .dialog__foot > .btn { width: 100%; }
}

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */
/* Arriba, 12 px bajo la barra: abajo tapaba el compositor y, con el teclado
   abierto (resizes-content), Enviar y Generar. */
.toasts {
  position: fixed; z-index: var(--z-toast); left: 50%; top: calc(var(--appbar-h) + 12px + 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 - 32px); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  max-width: 100%; min-height: 44px; padding: 8px 8px 8px 14px; border-radius: var(--r-sm);
  background: rgb(var(--c-panel-2)); border: 1px solid var(--line-2); color: rgb(var(--c-text));
  font-size: var(--fs-small); line-height: 1.4; box-shadow: 0 16px 36px -14px rgb(0 0 0 / 0.75);
}
.toast > .icon { color: rgb(var(--c-muted)); }
.toast--ok > .icon { color: rgb(var(--c-live)); }
.toast--err { border-color: rgb(var(--c-warn) / 0.5); }
.toast--err > .icon { color: rgb(var(--c-warn)); }
.toast__msg { flex: 1 1 auto; min-width: 0; padding-block: 4px; }
.toast .btn { min-height: 32px; padding: 6px 10px; font-size: var(--fs-xs); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: v-rise 180ms ease-out; }
}
@keyframes v-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes v-drop { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: no-preference) {
  .toasts .toast { animation-name: v-drop; }
}

/* Forced colours */
@media (forced-colors: active) {
  .chip, .panel, .rows, .table-wrap, .menu, .dialog, .toast, .drawer, .seg, .switch__track, .meter__bar { border: 1px solid CanvasText; }
  .list__item[aria-current], .appbar__tab[aria-current] { outline: 2px solid Highlight; }
  .meter__fill, .progress > span { background: Highlight; }
}
