/* Contrastes calculados contra el fondo: texto >= 7:1 (AAA), bordes y foco >= 3:1 */
  :root {
    --bg: #ffffff;
    --surface: #f3f5f8;
    --text: #0b1220;
    --muted: #3a4658;
    --border: #3a4658;
    --accent: #0a3fb0;
    --accent-text: #ffffff;
    --focus: #b35c00;
    --error-bg: #fdecec;
    --error: #8a0010;
    --ok-bg: #e6f4ea;
    --ok: #0b4f1e;
    --size: 1.25rem; /* 20px base; el usuario puede agrandarla con los botones A+ / A- */
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      --bg: #000000; --surface: #14181f; --text: #ffffff; --muted: #c9d1de; --border: #c9d1de;
      --accent: #ffd400; --accent-text: #000000; --focus: #4dd0ff;
      --error-bg: #3a0b10; --error: #ffb3ba; --ok-bg: #0c2e18; --ok: #a7f0bc;
    }
  }
  :root[data-theme="dark"] {
    --bg: #000000; --surface: #14181f; --text: #ffffff; --muted: #c9d1de; --border: #c9d1de;
    --accent: #ffd400; --accent-text: #000000; --focus: #4dd0ff;
    --error-bg: #3a0b10; --error: #ffb3ba; --ok-bg: #0c2e18; --ok: #a7f0bc;
  }
  /* Plantilla pastel: fondos suaves con texto ciruela (contrastes verificados: texto >= 7:1, bordes >= 3:1) */
  :root[data-theme="pastel"] {
    --bg: #fdf7f2; --surface: #f9e9ef; --text: #402b3d; --muted: #5d4a5d; --border: #93708f;
    --accent: #983a63; --accent-text: #ffffff; --focus: #b35c00;
    --error-bg: #fbe9ec; --error: #8a0010; --ok-bg: #e2f2e8; --ok: #0b4f1e;
  }
  /* Plantilla océano: azules suaves con texto marino */
  :root[data-theme="oceano"] {
    --bg: #f2f7fc; --surface: #e2eefb; --text: #0f2f4d; --muted: #37526d; --border: #5b7c99;
    --accent: #0b5fa5; --accent-text: #ffffff; --focus: #b35c00;
    --error-bg: #fbe9ec; --error: #8a0010; --ok-bg: #e2f2e8; --ok: #0b4f1e;
  }
  /* Plantilla bosque: verdes suaves con texto pino */
  :root[data-theme="bosque"] {
    --bg: #f4f8f1; --surface: #e4efe0; --text: #1e3a24; --muted: #44584a; --border: #5f7a66;
    --accent: #1f6b3a; --accent-text: #ffffff; --focus: #b35c00;
    --error-bg: #fbe9ec; --error: #8a0010; --ok-bg: #e2f2e8; --ok: #0b4f1e;
  }
  @media (prefers-contrast: more) { :root { --border: var(--text); --muted: var(--text); } }

  * { box-sizing: border-box; }
  html { font-size: 100%; -webkit-text-size-adjust: 100%; }
  body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 400 var(--size)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    min-height: 100dvh;
  }
  main { max-width: 32rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
  .tools { display: flex; justify-content: flex-end; gap: .5rem; padding-bottom: .5rem; }
  h1 { font-size: 1.75em; line-height: 1.2; margin: .5rem 0 .25rem; }
  p.lead { color: var(--muted); margin: 0 0 1.25rem; }

  button, input, select { font: inherit; color: inherit; }
  :focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
  /* Selector de tema: 5 círculos presionables (uno por plantilla) */
  .themes { display: flex; gap: .5rem; align-items: center; }
  .swatch { width: 2.85rem; min-width: 2.85rem; height: 2.85rem; min-height: 2.85rem; border-radius: 50%;
    border: 3px solid var(--border); cursor: pointer; padding: 0; }
  .swatch[data-set-theme="light"] { background: #ffffff; border-color: #0a3fb0; }
  .swatch[data-set-theme="pastel"] { background: #f9e9ef; border-color: #983a63; }
  .swatch[data-set-theme="oceano"] { background: #e2eefb; border-color: #0b5fa5; }
  .swatch[data-set-theme="bosque"] { background: #e4efe0; border-color: #1f6b3a; }
  .swatch[data-set-theme="dark"] { background: #14181f; border-color: #ffd400; }
  .swatch[aria-pressed="true"] { outline: 4px solid var(--focus); outline-offset: 3px; }

  .btn {
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    width: 100%; min-height: 3.5rem; padding: .75rem 1rem; cursor: pointer;
    border: 3px solid var(--accent); border-radius: .75rem;
    background: var(--accent); color: var(--accent-text); font-weight: 700;
  }
  .btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
  .btn.small { width: auto; min-height: 3rem; min-width: 3rem; padding: .25rem .9rem; font-size: .9em; }
  .btn:disabled { opacity: .6; cursor: not-allowed; }

  .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1.5rem; }
  .tabs .btn { background: transparent; color: var(--text); border-color: var(--border); }
  .tabs .btn[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
  .tabs .btn[aria-selected="true"]::before { content: "✓"; }  /* no depender solo del color */

  .field { margin-bottom: 1.25rem; }
  label { display: block; font-weight: 700; margin-bottom: .4rem; }
  .hint { color: var(--muted); font-size: .85em; margin: .3rem 0 0; }
  .control { display: flex; gap: .5rem; }
  input {
    width: 100%; min-height: 3.5rem; padding: .6rem .9rem; background: var(--surface);
    border: 3px solid var(--border); border-radius: .75rem;
  }
  input[aria-invalid="true"] { border-color: var(--error); }
  input.code { text-align: center; font-size: 2rem; letter-spacing: .5em; font-variant-numeric: tabular-nums; padding-left: 1.2em; }

  .msg { display: none; padding: .9rem 1rem; border-radius: .75rem; border: 3px solid; margin-bottom: 1.25rem; font-weight: 600; }
  .msg.show { display: flex; gap: .6rem; }
  .msg.error { background: var(--error-bg); color: var(--error); border-color: var(--error); }
  .msg.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
  .msg::before { font-weight: 800; }
  .msg.error::before { content: "⚠ Error:"; }
  .msg.ok::before { content: "✓"; }

  .stack { display: grid; gap: .75rem; }
  .logo { width: 4.5rem; height: auto; border-radius: 1rem; display: block; margin-bottom: .5rem; }
  .logo.hero { width: 9rem; margin: 1rem auto 1rem; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .brand img { width: 2rem; height: 2rem; border-radius: .4rem; vertical-align: -.4rem; margin-right: .4rem; }
  .site-foot { max-width: 32rem; margin: 0 auto; padding: 0 1rem 2rem; text-align: center; color: var(--muted); font-size: .85em; }
  .site-foot a { color: inherit; }
  [hidden] { display: none !important; }
  @media (prefers-reduced-motion: no-preference) { .btn { transition: transform .1s; } .btn:active { transform: scale(.98); } }
