/* Aleph — tokens y base.
   Lenguaje de color compartido con la galaxia: el mismo color significa el mismo estado en todo el panel. */
:root {
  color-scheme: dark;

  /* Superficies */
  --bg: #070b12;          /* vacío */
  --s1: #0c121c;          /* paneles */
  --s2: #111a27;          /* relieve: campos, hover */
  --s3: #172234;          /* seleccionado */
  --line: #1b2636;        /* bordes finos */
  --line-2: #27364b;      /* bordes de controles */

  /* Tinta */
  --ink: #e7edf4;
  --ink-2: #a6b3c3;
  --ink-3: #6d7c90;

  /* Estados (galaxia y panel) */
  --cyan: #4cd4e6;        /* acento, trabajando, libre (tenue) */
  --cyan-dim: #2a7f8d;
  --violet: #a28bfa;      /* razonamiento, planificación, revisión */
  --gold: #f0c25a;        /* herramientas, éxito */
  --orange: #f39a4f;      /* esperando, pausa, parcial */
  --red: #ef5f6f;         /* errores */

  --cyan-wash: rgba(76, 212, 230, .10);
  --violet-wash: rgba(162, 139, 250, .10);
  --gold-wash: rgba(240, 194, 90, .10);
  --orange-wash: rgba(243, 154, 79, .10);
  --red-wash: rgba(239, 95, 111, .10);

  /* Gráficos (paleta validada para superficie oscura) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #1c2737;
  --axis: #2c3b50;

  /* Tipografía */
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, "DejaVu Sans Mono", monospace;

  --fs-12: .75rem;
  --fs-13: .8125rem;
  --fs-14: .875rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-22: 1.375rem;
  --fs-28: 1.75rem;
  --fs-36: 2.25rem;

  /* Ritmo */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;
  --gap-7: 48px;

  --r-1: 4px;
  --r-2: 7px;
  --r-3: 12px;

  --topbar-h: 56px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }


html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-14);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  letter-spacing: .005em;
}
h1 { font-size: var(--fs-22); }
h2 { font-size: var(--fs-18); }
h3 { font-size: var(--fs-16); }
h4 { font-size: var(--fs-14); }

p { margin: 0 0 var(--gap-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code, kbd, pre, samp, .mono { font-family: var(--font-mono); font-size: .92em; }

img, svg, canvas { display: block; max-width: 100%; }
/* Los íconos van en línea con el texto (dentro de flex o grid su display no importa). */
svg[focusable="false"] { display: inline-block; vertical-align: -0.18em; flex: none; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: var(--r-1); }

::selection { background: rgba(76, 212, 230, .28); }

.skip-link {
  position: absolute; left: var(--gap-3); top: -60px; z-index: 100;
  background: var(--s3); color: var(--ink); padding: var(--gap-2) var(--gap-3); border-radius: var(--r-2);
}
.skip-link:focus { top: var(--gap-3); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.noscript { padding: var(--gap-6); text-align: center; color: var(--ink-2); }

/* ---------- Controles ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field-label {
  font-size: var(--fs-13);
  color: var(--ink-2);
  font-weight: 500;
}
.field .hint, .hint { font-size: var(--fs-12); color: var(--ink-3); line-height: 1.45; }
.field .error-text { font-size: var(--fs-12); color: var(--red); }

.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  background: var(--s2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  padding: 8px 10px;
  line-height: 1.4;
  color: var(--ink);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: #33455e; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--cyan); background: #0f1825; }
.input:disabled, .select:disabled, .textarea:disabled { opacity: .55; cursor: not-allowed; }
.input[readonly] { background: transparent; color: var(--ink-2); }
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.textarea { resize: vertical; min-height: 84px; }
.select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
}
.select option { background: var(--s1); color: var(--ink); }
.input-num { max-width: 120px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--r-2);
  border: 1px solid var(--line-2);
  background: var(--s2);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--s3); border-color: #36485f; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #04121a;
  font-weight: 600;
}
.btn-primary:hover { background: #73e0ee; border-color: #73e0ee; color: #04121a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--s2); border-color: var(--line); color: var(--ink); }
.btn-danger { color: var(--red); border-color: rgba(239, 95, 111, .35); background: transparent; }
.btn-danger:hover { background: var(--red-wash); border-color: var(--red); color: var(--red); }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: var(--fs-13); }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--ink-2) transparent var(--ink-2) transparent;
  animation: spin .8s linear infinite;
}
.btn-primary.is-busy::after { border-color: #04121a transparent #04121a transparent; }

/* Interruptor */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 34px; height: 20px; border-radius: 999px; background: var(--s3); border: 1px solid var(--line-2);
  position: relative; flex: none; transition: background .15s var(--ease), border-color .15s var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-2); transition: transform .18s var(--ease), background .18s var(--ease);
}
.switch input:checked + .track { background: rgba(76, 212, 230, .25); border-color: var(--cyan); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--cyan); }
.switch input:focus-visible + .track { outline: 2px solid var(--cyan); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

/* Casillas y radios */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { margin: 3px 0 0; accent-color: var(--cyan); width: 15px; height: 15px; flex: none; }
.check .check-body { display: grid; gap: 2px; }
.check .check-title { color: var(--ink); }

/* Control segmentado */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px; background: var(--s2); border: 1px solid var(--line-2);
  border-radius: var(--r-2); max-width: 100%;
}
.segmented button {
  border: 0; background: transparent; color: var(--ink-2); padding: 5px 12px; border-radius: 5px; cursor: pointer;
  font-weight: 500; white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--s3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--dot-glow, rgba(76, 212, 230, .55)); }
  50% { box-shadow: 0 0 0 4px rgba(0, 0, 0, 0); }
}
@keyframes shimmer { 0% { background-position: -320px 0; } 100% { background-position: 320px 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
