/* Lince · consola web (también la usa la referencia de la API, /docs) */

/* ------------------------------------------------------------------ fuente */
/* Inter (licencia OFL, ver fonts/LICENSE-Inter.txt), solo el alfabeto latino:
   ~70 KB y funciona sin conexión. Lo que no cubre lo dibuja la fuente del sistema. */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(../fonts/inter-latin.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;
}

/* ------------------------------------------------------------------ colores */
:root {
  --bg: #f7f7f8;
  --sidebar: #fbfbfc;
  --panel: #ffffff;
  --panel-2: #f4f4f6;
  --panel-3: #ebecef;
  --border: #e7e8eb;
  --border-strong: #d6d8dd;
  --text: #16171b;
  --muted: #5f6471;
  --faint: #80858f;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-ink: #ffffff;
  --primary-soft: #eeedfd;
  --accent-text: #4338ca;
  --brand-1: #5b5cf6;
  --brand-2: #9645ee;
  --ring: rgba(79, 70, 229, .22);
  --danger: #c81e1e;
  --danger-soft: #fdecec;
  --success: #12733a;
  --success-soft: #e8f3ec;
  --warning: #a14a06;
  --warning-soft: #fdf1e3;
  --row-hover: #f8f8fa;
  --nav-active: #ffffff;
  --tip-bg: #1b1c22;
  --tip-ink: #fafafa;
  /* bloques de código: claros aquí y oscuros en el tema oscuro (contraste ≥ 4,5:1) */
  --code-bg: #f6f7f9;
  --code-head: #eef0f2;
  --code-ink: #24272e;
  --code-muted: #5f6471;
  --code-border: #e2e4e8;
  --code-hover: rgba(16, 18, 27, .06);
  --code-tab: #ffffff;
  --tok-key: #0550ae; --tok-str: #116329; --tok-num: #953800; --tok-bool: #8250df; --tok-punc: #636c76;
  --overlay: rgba(15, 16, 22, .4);
  --glow: rgba(91, 92, 246, .08);
  --edge-shadow: rgba(16, 18, 27, .24);
  --shadow-xs: 0 1px 2px rgba(16, 18, 27, .05);
  --shadow-sm: 0 1px 2px rgba(16, 18, 27, .05), 0 1px 3px rgba(16, 18, 27, .05);
  --shadow: 0 8px 20px -6px rgba(16, 18, 27, .12), 0 2px 4px -2px rgba(16, 18, 27, .06);
  --shadow-lg: 0 24px 56px -12px rgba(16, 18, 27, .28), 0 8px 18px -8px rgba(16, 18, 27, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --sidebar-w: 252px;
  --sim-w: 384px;
  --font: "Inter Variable", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.45, .64, 1);
  /* colores de anotaciones */
  --a0: #ffe3a3; --a1: #c8ecff; --a2: #d9f5c9; --a3: #ffd2e1;
  --a4: #e5d9ff; --a5: #ffd9c2; --a6: #c9f1ec; --a7: #f1e6c9;
  --a-ink: #1b2232;
  /* gráficos (paleta validada para daltonismo sobre fondo claro) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-neg: #e34948; --deemph: #c6c5bf;
  --grid: #e7e6e0; --axis: #c3c2b7; --good: #0ca30c; --critical: #d03b3b;
  color-scheme: light;
}

/* Modo oscuro clásico: grises neutros, sin tintes azulados en las superficies */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --sidebar: #151515; --panel: #191919; --panel-2: #202020; --panel-3: #2a2a2a;
    --border: #2a2a2a; --border-strong: #3a3a3a; --text: #ececec; --muted: #a3a3a3; --faint: #7d7d7d;
    --primary: #5558e8; --primary-hover: #6366f1; --primary-ink: #ffffff; --primary-soft: #23233a;
    --accent-text: #a5b4fc; --ring: rgba(99, 102, 241, .38);
    --danger: #f87171; --danger-soft: #3a2323; --success: #4ade80; --success-soft: #1b3326;
    --warning: #fbbf24; --warning-soft: #3a3119; --row-hover: #1d1d1d; --nav-active: #262626;
    --tip-bg: #2e2e2e; --tip-ink: #f5f5f5;
    --code-bg: #0c0c0c; --code-head: #141414; --code-ink: #e4e4e4; --code-muted: #a1a1aa; --code-border: #262626;
    --code-hover: rgba(255, 255, 255, .08); --code-tab: rgba(255, 255, 255, .1);
    --tok-key: #93c5fd; --tok-str: #86efac; --tok-num: #fcd34d; --tok-bool: #f9a8d4; --tok-punc: #8b8b94;
    --overlay: rgba(0, 0, 0, .62); --glow: rgba(255, 255, 255, .025); --edge-shadow: rgba(0, 0, 0, .6);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4); --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow: 0 8px 22px -6px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .8);
    --a0: #5a4718; --a1: #1e4865; --a2: #2d4f1f; --a3: #5e2a3d; --a4: #42356c; --a5: #653a1e;
    --a6: #1d524a; --a7: #504727; --a-ink: #f2f2f2;
    --series-1: #3987e5; --series-2: #d95926; --series-neg: #e66767; --deemph: #5e5e5b;
    --grid: #2c2c2a; --axis: #4a4a47; --good: #0ca30c; --critical: #d03b3b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --sidebar: #151515; --panel: #191919; --panel-2: #202020; --panel-3: #2a2a2a;
  --border: #2a2a2a; --border-strong: #3a3a3a; --text: #ececec; --muted: #a3a3a3; --faint: #7d7d7d;
  --primary: #5558e8; --primary-hover: #6366f1; --primary-ink: #ffffff; --primary-soft: #23233a;
  --accent-text: #a5b4fc; --ring: rgba(99, 102, 241, .38);
  --danger: #f87171; --danger-soft: #3a2323; --success: #4ade80; --success-soft: #1b3326;
  --warning: #fbbf24; --warning-soft: #3a3119; --row-hover: #1d1d1d; --nav-active: #262626;
  --tip-bg: #2e2e2e; --tip-ink: #f5f5f5;
  --code-bg: #0c0c0c; --code-head: #141414; --code-ink: #e4e4e4; --code-muted: #a1a1aa; --code-border: #262626;
  --code-hover: rgba(255, 255, 255, .08); --code-tab: rgba(255, 255, 255, .1);
  --tok-key: #93c5fd; --tok-str: #86efac; --tok-num: #fcd34d; --tok-bool: #f9a8d4; --tok-punc: #8b8b94;
  --overlay: rgba(0, 0, 0, .62); --glow: rgba(255, 255, 255, .025); --edge-shadow: rgba(0, 0, 0, .6);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4); --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow: 0 8px 22px -6px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .8);
  --a0: #5a4718; --a1: #1e4865; --a2: #2d4f1f; --a3: #5e2a3d; --a4: #42356c; --a5: #653a1e;
  --a6: #1d524a; --a7: #504727; --a-ink: #f2f2f2;
  --series-1: #3987e5; --series-2: #d95926; --series-neg: #e66767; --deemph: #5e5e5b;
  --grid: #2c2c2a; --axis: #4a4a47; --good: #0ca30c; --critical: #d03b3b;
  color-scheme: dark;
}

/* ------------------------------------------------------------------- base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.012em; }
code, pre, kbd, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--panel); color: var(--muted);
  font-size: 11px; font-family: var(--font); font-weight: 600; line-height: 1; }

/* -------------------------------------------------------------- animaciones */
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce-dot { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes badge-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
  100% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--primary) 0%, transparent); } }
@keyframes flash { from { background: color-mix(in srgb, var(--primary) 16%, var(--panel)); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes check-pop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes caret { 50% { opacity: 0; } }

.stagger > * { animation: rise .32s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 28ms); }
.flash { animation: flash 1.2s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* tema: la página nueva aparece en círculo desde el botón (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--sim-w);
  height: 100vh; height: 100dvh; }
.app.sim-closed { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 0; }

.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); display: flex;
  flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; text-decoration: none !important; color: var(--text); }
.brand .logo { width: 32px; height: 32px; flex: none; border-radius: 9px;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--brand-1) 60%, transparent); transition: transform .3s var(--spring); }
.brand:hover .logo { transform: rotate(-6deg) scale(1.06); }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.logo { display: block; }

.agent-switch { margin: 2px 12px 8px; display: flex; align-items: center; gap: 10px; width: calc(100% - 24px);
  padding: 7px 10px 7px 7px; border-radius: 11px; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); cursor: pointer; text-align: left; box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, background-color .15s; }
.agent-switch:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.agent-switch[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.agent-switch .name { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.agent-switch .meta { font-size: 11.5px; color: var(--faint); line-height: 1.3; }
.agent-switch > svg.icon { width: 16px; height: 16px; color: var(--faint); }

.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--av1, var(--brand-1)), var(--av2, var(--brand-2)));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); text-shadow: 0 1px 1px rgba(0, 0, 0, .18); }
.avatar svg.icon { width: 16px; height: 16px; }
.avatar.sm { width: 22px; height: 22px; border-radius: 7px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 16px; }

.search-btn { margin: 0 12px 6px; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 10px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--faint);
  cursor: pointer; transition: border-color .15s, color .15s, background-color .15s; }
.search-btn:hover { border-color: var(--border-strong); color: var(--muted); background: var(--panel); }
.search-btn svg.icon { width: 16px; height: 16px; }
.search-btn span { flex: 1; text-align: left; font-size: 13px; }

.nav { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 4px 10px 10px; overflow-y: auto; }
.nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border-radius: 9px; color: var(--muted); font-weight: 500; text-decoration: none; transition: color .15s, background-color .15s; }
.nav a svg.icon { width: 17px; height: 17px; transition: color .15s, transform .25s var(--spring); }
.nav a:hover { color: var(--text); background: color-mix(in srgb, var(--panel-3) 55%, transparent); }
.nav a:hover svg.icon { transform: scale(1.08); }
.nav a.active { color: var(--text); font-weight: 600; background: transparent; }
.nav a.active svg.icon { color: var(--primary); }
:root[data-theme="dark"] .nav a.active svg.icon { color: var(--accent-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav a.active svg.icon { color: var(--accent-text); } }
.nav a .ext { margin-left: auto; width: 14px; height: 14px; color: var(--faint); }
.nav-pill { position: absolute; left: 10px; right: 10px; top: 0; height: 34px; border-radius: 9px; z-index: 0;
  background: var(--nav-active); border: 1px solid var(--border); box-shadow: var(--shadow-xs); pointer-events: none; }
.nav-pill.anim { transition: transform .32s var(--spring), height .2s var(--ease); }
.nav-label { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--faint);
  padding: 14px 10px 5px; }
.nav-label:first-child { padding-top: 6px; }
.nav .badge { margin-left: auto; }
.nav .badge.count { background: var(--primary); color: var(--primary-ink); min-width: 20px; justify-content: center; }
.nav .badge.pop { animation: badge-pop .45s var(--spring); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 10px; }

.sidebar-foot { margin-top: auto; padding: 10px 12px 12px; display: flex; gap: 4px; align-items: center;
  border-top: 1px solid var(--border); }
/* versión: abre las notas de la versión (notes.js); el punto avisa de que hay novedades sin ver */
.version { position: relative; font: inherit; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums;
  padding: 2px 7px; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer;
  transition: color .15s, border-color .15s, background-color .15s; }
.version:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel); }
.version.new::after { content: ""; position: absolute; top: -4px; right: -4px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 2px var(--sidebar); animation: pop-in .3s var(--spring); }

.main { overflow-y: auto; min-width: 0; position: relative;
  background: radial-gradient(900px 340px at 50% -160px, var(--glow), transparent 70%) no-repeat; }
/* --pad-x: margen lateral de la página (lo usan las barras que van de borde a borde, como el índice) */
.page { --pad-x: 32px; max-width: 1360px; margin: 0 auto; padding: 26px var(--pad-x) 72px; animation: page-in .34s var(--ease) backwards; }
/* aviso de servidor desactualizado (arriba, con el mismo ancho que la página) */
.version-notice { max-width: 1360px; margin: 0 auto; padding: 18px 32px 0; animation: page-in .34s var(--ease) backwards; }
.version-notice .notice { align-items: center; }
.page-head { display: flex; align-items: center; gap: 12px 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head-main { flex: 1 1 380px; min-width: 0; display: flex; align-items: center; gap: 14px; }
.head-text { flex: 1; min-width: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; font-weight: 700; letter-spacing: -.025em; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.page-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand-1) 16%, var(--panel)), color-mix(in srgb, var(--brand-2) 14%, var(--panel)));
  color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); }
:root[data-theme="dark"] .page-icon { color: var(--accent-text); background: var(--panel-2); border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .page-icon { color: var(--accent-text); background: var(--panel-2); border-color: var(--border); } }
.page-icon svg.icon { width: 21px; height: 21px; }
.page-head.sticky { position: sticky; top: var(--stick-top, 0px); z-index: 20; margin: -26px -32px 20px; padding: 16px 32px 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid transparent; transition: border-color .2s, box-shadow .2s; }
.page-head.sticky.stuck { border-bottom-color: var(--border); box-shadow: 0 6px 16px -12px rgba(0, 0, 0, .25); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--faint); margin-bottom: 2px; }
.crumbs a { color: var(--muted); }
.crumbs svg.icon { width: 13px; height: 13px; }
.dirty-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 6px;
  background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 600;
  animation: pop-in .25s var(--spring); }
.dirty-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.topbar { display: none; }

/* ------------------------------------------------------------- componentes */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head > svg.icon { color: var(--primary); }
.card-head h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-head .help { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 12px 18px 18px; }
.section-title { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); margin: 20px 0 8px; }
.collapsible-head { width: 100%; border: 0; background: transparent; cursor: pointer; color: inherit; text-align: left;
  padding-bottom: 16px; }
.collapsible-head .chev { transition: transform .25s var(--ease); color: var(--faint); }
.collapsible-head[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* botones */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px;
  padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text); font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs); text-decoration: none !important; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .12s var(--ease), opacity .15s; }
.btn svg.icon { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 12%); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { color: var(--primary-ink); border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px color-mix(in srgb, var(--primary) 40%, transparent),
    0 4px 12px -4px color-mix(in srgb, var(--primary) 55%, transparent); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--primary), var(--primary-hover)); }
.btn.primary:focus-visible { box-shadow: 0 0 0 3px var(--ring), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: color-mix(in srgb, var(--panel-3) 70%, transparent); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn.sm svg.icon { width: 15px; height: 15px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }
.btn.ok { color: var(--success); }
.btn.ok:hover { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite;
  color: var(--text); }
.btn.primary.loading::after { color: var(--primary-ink); }
.btn.done svg.icon { animation: check-pop .3s var(--spring); }
.spinner { display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor;
  border-top-color: transparent; animation: spin .7s linear infinite; vertical-align: -2px; flex: none; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* campos */
input[type=text], input[type=number], input[type=search], input[type=password], input[type=url], input[type=email],
textarea, select {
  font: inherit; font-size: 13.5px; color: var(--text); background-color: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 11px; outline: none; min-width: 0; min-height: 36px;
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, background-color .15s; }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 14%); }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2380858f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px; }
input[type=search] { padding-left: 34px; background-repeat: no-repeat; background-position: 11px center; background-size: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2380858f' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }
input[type=color] { width: 44px; height: 36px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }
input.big { font-size: 19px; font-weight: 650; letter-spacing: -.015em; padding: 6px 12px; min-height: 42px; }
input.plain { border-color: transparent; background: transparent; box-shadow: none; }
input.plain:hover { border-color: var(--border); background: var(--panel); }
input.plain:focus { border-color: var(--primary); background: var(--panel); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin: 0; flex: none;
  border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--panel) center / 12px no-repeat;
  cursor: pointer; vertical-align: middle; transition: background-color .15s, border-color .15s, box-shadow .15s; }
input[type=checkbox]:hover { border-color: var(--primary); }
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox]:checked { background-color: var(--primary); border-color: var(--primary); animation: check-pop .25s var(--spring);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px; cursor: pointer; outline: none;
  background: linear-gradient(to right, var(--primary) 0 var(--fill, 50%), var(--panel-3) var(--fill, 50%) 100%); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary); box-shadow: var(--shadow-sm); transition: transform .2s var(--spring), box-shadow .15s; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm); transition: transform .2s var(--spring), box-shadow .15s; }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.18); }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--ring); }
input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px var(--ring); }
.range-value { min-width: 54px; height: 28px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 8px;
  background: var(--primary-soft); color: var(--accent-text); font-weight: 650; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 550; font-size: 13px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch { position: relative; display: inline-flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.switch input[type=checkbox] { width: 38px; height: 22px; border-radius: 22px; background: var(--panel-3); background-image: none;
  border: 1px solid var(--border-strong); position: relative; cursor: pointer; margin: 0; flex: none; animation: none;
  transition: background-color .2s var(--ease), border-color .2s; }
.switch input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s var(--spring); }
.switch input[type=checkbox]:checked { background: var(--primary); border-color: var(--primary); }
.switch input[type=checkbox]:checked::after { transform: translateX(16px); }
.switch input[type=checkbox]:active::after { width: 19px; }
.switch input[type=checkbox]:checked:active::after { transform: translateX(13px); }
.switch > span { padding-top: 1px; }

/* insignias */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px;
  border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--panel-3);
  color: var(--muted); white-space: nowrap; line-height: 1; border: 1px solid transparent; }
.badge svg.icon { width: 12px; height: 12px; }
.badge.primary { background: var(--primary-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.badge.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, transparent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.badge.warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.badge.ctx-in::before { content: "→"; }
.badge.ctx-out::after { content: "→"; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* chips (listas editables) */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 5px; min-height: 36px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); cursor: text;
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s; }
.chips:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 14%); }
.chips:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 9px;
  border-radius: 7px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500;
  max-width: 100%; animation: pop-in .2s var(--spring); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: transparent; color: var(--faint); cursor: pointer; padding: 2px;
  display: grid; place-items: center; border-radius: 5px; transition: background-color .15s, color .15s; }
.chip button:hover { color: var(--danger); background: var(--danger-soft); }
.chip button svg { width: 13px; height: 13px; }
.chip input.lifespan { width: 46px; height: 20px; min-height: 0; padding: 0 4px; font-size: 12px; border-radius: 5px; box-shadow: none; }
.chips > input { border: 0; outline: 0; box-shadow: none !important; flex: 1; min-width: 120px; min-height: 26px;
  padding: 3px 5px; background: transparent; }

/* listas */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px;
  border-top: 1px solid var(--border); cursor: pointer; transition: background-color .15s; outline: none; }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--row-hover); }
.list-item:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.card > .list > .list-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card > .list > .list-item:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.list-item .title { font-weight: 600; letter-spacing: -.005em; }
.list-item .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.list-item .actions { opacity: 0; transition: opacity .15s; }
.list-item:hover .actions, .list-item:focus-within .actions { opacity: 1; }
.list-item .chev { color: var(--faint); width: 16px; height: 16px; transition: transform .2s var(--ease), color .15s; }
.list-item:hover .chev { transform: translateX(3px); color: var(--text); }
.li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); transition: transform .25s var(--spring); }
.li-icon svg.icon { width: 17px; height: 17px; }
.li-icon.primary { background: var(--primary-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--primary) 16%, transparent); }
.li-icon.warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 18%, transparent); }
.li-icon.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 18%, transparent); }
.list-item:hover .li-icon { transform: scale(1.06); }
.empty { text-align: center; color: var(--muted); padding: 40px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty > svg.icon, .empty-icon { width: 54px; height: 54px; padding: 14px; border-radius: 16px; color: var(--faint);
  background: var(--panel-2); border: 1px solid var(--border); margin-bottom: 6px; animation: float 4s ease-in-out infinite; }
.empty-icon { display: grid; place-items: center; padding: 0; }
.empty-icon svg.icon { width: 24px; height: 24px; }
.empty p { margin: 0; max-width: 100ch; }
.empty .btn { margin-top: 10px; }
.empty-title { font-weight: 650; color: var(--text); font-size: 15px; }

/* medidor pequeño de frases (lista de intenciones) */
.qty { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.qty-bar { width: 44px; height: 5px; border-radius: 9px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.qty-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--faint); transform-origin: left;
  animation: grow-x .7s var(--ease) backwards; }
.qty.ok .qty-bar > span { background: var(--success); }
.qty.low .qty-bar > span { background: var(--warning); }

/* tablas */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.card > .table-wrap { border: 0; border-radius: var(--radius); }
.table-wrap.scroll { max-height: 440px; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 11px; font-weight: 650; color: var(--faint);
  text-transform: uppercase; letter-spacing: .055em; padding: 9px 14px; background: var(--panel-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover > td { background: var(--row-hover); }
.table tbody tr:last-child > td { border-bottom: 0; }
.table input[type=text] { width: 100%; }
.table code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.table th.num, .table td.num { text-align: right; }
.table th.sortable { cursor: pointer; user-select: none; transition: color .15s; }
.table th.sortable:hover { color: var(--text); }
.table th.sortable .sort-ind { display: inline-block; width: 12px; height: 12px; margin-left: 4px; vertical-align: -2px; opacity: .45;
  transition: transform .2s var(--ease), opacity .15s; }
.table th[aria-sort] { color: var(--text); }
.table th[aria-sort] .sort-ind { opacity: 1; color: var(--primary); }
.table th[aria-sort="descending"] .sort-ind { transform: rotate(180deg); }
.table.editable td { padding: 7px 8px; }
.table.editable th { padding-left: 8px; padding-right: 8px; }
.table.editable td:first-child, .table.editable th:first-child { padding-left: 14px; }
.table.editable td:last-child, .table.editable th:last-child { padding-right: 12px; }
.table code.param-ref { background: none; border: 0; padding: 0 0 0 2px; font-size: 11px; color: var(--faint); }
.feedback .row.top > textarea { flex: 1; }
.table.editable input[type=text], .table.editable input[type=number], .table.editable select { box-shadow: none; border-color: var(--border); }
.table.editable input[type=text]:hover { border-color: var(--border-strong); }
.table.editable input[type=text]:focus { border-color: var(--primary); }
.table .cell-muted { color: var(--muted); }
.table tr.add-row > td { background: var(--panel-2); }
.table-empty { padding: 26px; text-align: center; color: var(--muted); }

/* pestañas segmentadas con indicador que se desliza */
.tabs { position: relative; display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 16px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; align-self: flex-start;
  scrollbar-width: none; }
.tabs button { position: relative; z-index: 1; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 550;
  color: var(--muted); padding: 6px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: color .2s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); }
.tabs:not(.has-ind) button.active { background: var(--panel); box-shadow: var(--shadow-sm); }
.tabs-ind { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; border-radius: 9px; background: var(--panel);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border); pointer-events: none; }
.tabs-ind.anim { transition: transform .32s var(--spring), width .32s var(--spring); }
.tabs button .badge { margin-left: 6px; height: 18px; padding: 0 6px; font-size: 11px; }
.tabs button svg.icon { width: 15px; height: 15px; margin-right: 6px; vertical-align: -3px; }

/* avisos */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px;
  background: var(--panel-2); color: var(--text); font-size: 13px; border: 1px solid var(--border); line-height: 1.5; }
.notice > svg.icon { margin-top: 1px; color: var(--muted); width: 17px; height: 17px; }
.notice.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.notice.warning > svg.icon { color: var(--warning); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.notice.danger > svg.icon { color: var(--danger); }
.notice.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 22%, transparent); animation: pop-in .3s var(--ease); }
.notice.success > svg.icon { color: var(--success); }
.notice.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.notice.info > svg.icon { color: var(--accent-text); }

/* bloques de código (siguen el tema: claros en el claro, oscuros en el oscuro) */
.code-block { position: relative; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--code-border);
  border-radius: 12px; overflow: hidden; }
.code-block pre { white-space: pre; padding: 14px 16px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }
.code-block .copy { position: absolute; top: 8px; right: 8px; color: var(--code-muted); background: var(--code-bg);
  border: 1px solid var(--code-border); }
.code-block .copy:hover { color: var(--code-ink); background: var(--code-hover); }
.code-block .copy.done { color: var(--success); }
.code-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--code-border);
  background: var(--code-head); }
.code-head .lang { font-size: 11.5px; color: var(--code-muted); font-weight: 600; letter-spacing: .02em; }
.code-head .copy { position: static; margin-left: auto; border-color: transparent; background: transparent; }
.code-head .copy:hover { background: var(--code-hover); }
.code-tab { border: 0; background: transparent; color: var(--code-muted); font-size: 12.5px; font-weight: 550; padding: 5px 10px;
  border-radius: 7px; cursor: pointer; transition: color .15s, background-color .15s, box-shadow .15s; }
.code-tab:hover { color: var(--code-ink); background: var(--code-hover); }
.code-tab.active { color: var(--code-ink); background: var(--code-tab); box-shadow: var(--shadow-xs); }
.tok-key { color: var(--tok-key); } .tok-str { color: var(--tok-str); } .tok-num { color: var(--tok-num); }
.tok-bool, .tok-null { color: var(--tok-bool); } .tok-punc { color: var(--tok-punc); }

/* tooltips propios (sustituyen al «title» del navegador) */
.tip { position: fixed; z-index: 120; max-width: 300px; padding: 6px 9px; border-radius: 8px; background: var(--tip-bg);
  color: var(--tip-ink); font-size: 12px; font-weight: 500; line-height: 1.4; pointer-events: none;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .35); animation: pop-in .14s var(--ease); white-space: pre-line; }

/* esqueletos de carga */
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--panel-3) 25%, var(--panel-2) 45%, var(--panel-3) 65%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel-page { max-width: 1360px; margin: 0 auto; padding: 26px 32px; animation: fade .3s var(--ease) .1s backwards; }
.skel-head { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }

/* ---------------------------------------------------- frases y anotaciones */
.phrase-add { display: flex; gap: 8px; }
.phrase-add input { flex: 1; }
.phrase-list { display: flex; flex-direction: column; margin-top: 12px; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; }
.phrase-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px;
  border-top: 1px solid var(--border); background: var(--panel); transition: background-color .15s; }
.phrase-row:first-child { border-top: 0; }
.phrase-row:hover { background: var(--row-hover); }
.phrase-row.new { animation: flash 1.4s var(--ease), rise .3s var(--ease); }
.phrase-row .quote { color: var(--faint); font-weight: 700; font-size: 16px; line-height: 1; }
.phrase-row .actions { opacity: 0; transition: opacity .15s; }
.phrase-row:hover .actions, .phrase-row:focus-within .actions { opacity: 1; }
.phrase { flex: 1; min-width: 0; padding: 3px 2px; line-height: 1.8; white-space: pre-wrap;
  word-break: break-word; cursor: text; }
.phrase:focus { outline: none; }
.ann { border-radius: 5px; padding: 1px 3px; color: var(--a-ink); cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .07); transition: box-shadow .15s, filter .15s;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.ann:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 22%, transparent); }
.ann-0 { background: var(--a0); } .ann-1 { background: var(--a1); } .ann-2 { background: var(--a2); }
.ann-3 { background: var(--a3); } .ann-4 { background: var(--a4); } .ann-5 { background: var(--a5); }
.ann-6 { background: var(--a6); } .ann-7 { background: var(--a7); }
.ann-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.phrase-edit { flex: 1; }

/* ------------------------------------------------------------ popovers */
/* por encima de los modales (z 80): también se abren dentro de uno */
.popover { position: fixed; z-index: 85; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 236px; max-width: 330px; padding: 6px;
  animation: pop-in .16s var(--ease); transform-origin: top left; }
.popover .search { width: 100%; margin-bottom: 6px; }
.popover .options { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.popover .opt { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; min-height: 34px;
  cursor: pointer; border: 0; background: transparent; font: inherit; color: var(--text); text-align: left; width: 100%;
  transition: background-color .12s; }
.popover .opt:hover { background: var(--panel-2); }
.popover .opt.focus { background: var(--primary-soft); }
.popover .opt svg.icon { width: 16px; height: 16px; color: var(--muted); }
/* el texto se recorta con «…» en vez de ensanchar la fila */
.popover .opt > .ellipsis, .popover .opt-text { flex: 1 1 auto; min-width: 0; }
.popover .opt.two-line { padding: 6px 8px; gap: 10px; }
.popover .opt-text { display: flex; flex-direction: column; line-height: 1.3; }
.popover .opt-text > :first-child { font-weight: 550; }
.popover .opt-sub { font-size: 11.5px; color: var(--faint); }
.popover .opt .desc { color: var(--faint); font-size: 11.5px; margin-left: auto; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; max-width: 150px; flex: 0 1 auto; }
.popover .opt .check-mark { margin-left: auto; color: var(--primary); }
.popover .group { font-size: 10.5px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 9px 3px; }
.popover .pop-head { padding: 6px 9px; font-weight: 650; }
.pop-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.pop-title { padding: 6px 10px 8px; font-size: 12.5px; color: var(--muted); }
/* cuentas: el usuario en el pie de la barra lateral y la ventana de entrar */
.user-btn { min-width: 0; max-width: 150px; gap: 7px; padding: 0 9px 0 5px; }
.user-btn .ellipsis { min-width: 0; }
.modal-body .logo { width: 48px; height: 48px; flex: none; border-radius: 13px; }
/* compartir: el enlace en Ajustes y la página del agente compartido */
.share-row { gap: 8px; }
.share-link { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; }
.shared-name { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.shared-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.shared-stats span { display: inline-flex; align-items: center; gap: 5px; }
.shared-stats svg.icon { width: 14px; height: 14px; color: var(--faint); }

/* ------------------------------------------------------- modal y toasts */
.modal-back { position: fixed; inset: 0; background: var(--overlay); z-index: 80; display: grid;
  place-items: center; padding: 16px; animation: fade .18s var(--ease);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal-back.leaving { animation: fade-out .16s var(--ease) forwards; pointer-events: none; }
.modal, .modal-leaving { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%;
  border: 1px solid var(--border); max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  animation: modal-in .26s var(--spring); }
.modal-leaving { animation: modal-out .16s var(--ease) forwards; }
.modal.wide, .modal-leaving.wide { max-width: 760px; }
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
.modal-head h3 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.modal-body { padding: 8px 20px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
/* notas de la versión (notes.js): una línea de tiempo con un punto por versión */
.notes { display: flex; flex-direction: column; padding: 2px 0 4px; }
.note-rel { position: relative; padding: 0 0 20px 24px; }
.note-rel::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--border); }
.note-rel:last-child { padding-bottom: 0; }
.note-rel:last-child::before { display: none; }
.note-rel::after { content: ""; position: absolute; left: 0; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--border-strong); }
.note-rel.current::after { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.note-ver { font-weight: 700; font-size: 15px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.note-date { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.note-rel .md { font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.note-rel .md p { margin: 0 0 6px; color: var(--text); }
.note-rel .md ul { margin: 0; padding-left: 18px; }
.note-rel .md li { margin: 3px 0; }
.note-rel .md li::marker { color: var(--faint); }
.note-rel .md b, .note-rel .md strong { color: var(--text); font-weight: 600; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--tip-bg); color: var(--tip-ink);
  padding: 9px 12px 9px 10px; border-radius: 13px; box-shadow: var(--shadow-lg); font-weight: 550; font-size: 13.5px;
  animation: toast-in .34s var(--spring); pointer-events: auto; max-width: min(540px, 90vw); border: 1px solid rgba(255, 255, 255, .06); }
.toast.leaving { animation: toast-out .2s var(--ease) forwards; }
.toast .t-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .14); color: #fff; }
.toast .t-icon svg.icon { width: 13px; height: 13px; stroke-width: 3; }
.toast.success .t-icon { background: #16a34a; }
.toast.error .t-icon { background: #dc2626; }
.toast.info .t-icon { background: var(--brand-1); }
.toast .t-close { border: 0; background: transparent; color: inherit; opacity: .55; cursor: pointer; padding: 2px; border-radius: 6px;
  display: grid; place-items: center; margin-left: 4px; }
.toast .t-close:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.toast .t-close svg.icon { width: 14px; height: 14px; }

/* ---------------------------------------------------- paleta de comandos */
.cmdk-back { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; justify-content: center;
  align-items: flex-start; padding: 12vh 16px 16px; animation: fade .15s var(--ease);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.cmdk-back.leaving { animation: fade-out .14s var(--ease) forwards; pointer-events: none; }
.cmdk { width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 72vh;
  animation: modal-in .24s var(--spring); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.cmdk-input svg.icon { color: var(--faint); }
.cmdk-input input { flex: 1; border: 0 !important; box-shadow: none !important; background: transparent; font-size: 16px;
  height: 54px; padding: 0; min-height: 0; }
.cmdk-list { overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: transparent; color: var(--text);
  font: inherit; text-align: left; padding: 8px 10px; border-radius: 10px; cursor: pointer; min-height: 40px; }
.cmdk-item .ci-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.cmdk-item .ci-icon svg.icon { width: 15px; height: 15px; }
.cmdk-item .ci-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .ci-label mark { background: transparent; color: var(--accent-text); font-weight: 650; }
.cmdk-item .ci-hint { color: var(--faint); font-size: 12px; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item.active { background: var(--primary-soft); }
.cmdk-item.active .ci-icon { color: var(--accent-text); border-color: color-mix(in srgb, var(--primary) 25%, transparent); background: var(--panel); }
.cmdk-item .ci-enter { opacity: 0; color: var(--faint); width: 15px; height: 15px; }
.cmdk-item.active .ci-enter { opacity: 1; }
.cmdk-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.cmdk-foot { display: flex; gap: 14px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--border);
  background: var(--panel-2); color: var(--faint); font-size: 12px; }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* -------------------------------------------------------- simulador */
.sim { background: var(--panel); border-left: 1px solid var(--border); display: flex;
  flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.sim-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--border); }
.sim-head .logo { width: 30px; height: 30px; border-radius: 9px; }
.sim-head h2 { font-size: 14.5px; font-weight: 650; }
.sim-head .sub { font-size: 11.5px; color: var(--faint); display: flex; align-items: center; gap: 5px; }
.sim-head .sub::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 2px color-mix(in srgb, #22c55e 25%, transparent); flex: none; }
.sim-head .sub.off::before { background: var(--faint); box-shadow: none; }
.sim-body { flex: 1; overflow-y: auto; padding: 16px 14px 18px; display: flex; flex-direction: column; gap: 10px;
  background-color: var(--panel-2); scroll-behavior: smooth;
  background-image: radial-gradient(520px 200px at 50% -60px, color-mix(in srgb, var(--brand-1) 13%, transparent), transparent 70%),
    radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1px);
  background-size: auto, 18px 18px; }
.sim-foot { padding: 10px 12px 12px; border-top: 1px solid var(--border); background: var(--panel); }
/* caja de escribir con el botón de enviar dentro */
.composer { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 6px; border: 1px solid var(--border-strong);
  border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .2s; }
.composer:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 14%); }
.composer:focus-within { border-color: color-mix(in srgb, var(--brand-1) 70%, var(--border)); box-shadow: 0 0 0 4px var(--ring),
  0 10px 22px -14px color-mix(in srgb, var(--brand-1) 70%, transparent); }
.composer input, .composer input:hover, .composer input:focus { flex: 1; min-height: 34px; padding: 0 8px; border: 0;
  background: transparent; box-shadow: none; }
/* enviar: el avión de papel (icono «send») despega un poco al pasar el ratón */
.send-btn { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 0; border-radius: 11px; color: #fff;
  cursor: pointer; background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--brand-2) 75%, transparent), inset 0 1px 0 rgba(255, 255, 255, .2);
  transition: transform .2s var(--spring), box-shadow .2s, opacity .15s; }
.send-btn:hover:not(:disabled) { transform: translateY(-1px);
  box-shadow: 0 10px 18px -8px color-mix(in srgb, var(--brand-2) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, .2); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { opacity: .55; cursor: default; }
.send-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
svg.icon .send-plane { transition: transform .3s var(--spring); }
button:hover:not(:disabled) svg.icon .send-plane { transform: translate(1.5px, -1.5px); }
.sim-empty { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  color: var(--muted); padding: 10px 8px 30px; animation: rise .4s var(--ease) backwards; }
.sim-empty .logo { width: 52px; height: 52px; border-radius: 15px; animation: float 4s ease-in-out infinite;
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--brand-1) 70%, transparent); }
.sim-empty b { color: var(--text); font-size: 15px; }
.sim-empty p { margin: 0; font-size: 12.5px; max-width: 34ch; }
.sim-empty .quick { align-self: center; justify-content: center; margin-top: 4px; }
/* tus mensajes, a la derecha; cada respuesta, con el lince a la izquierda y todo lo suyo en columna */
.msg { max-width: 86%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-break: break-word;
  line-height: 1.45; animation: msg-in .3s var(--spring) backwards; }
.msg.user { align-self: flex-end; color: #fff; border-bottom-right-radius: 4px; transform-origin: bottom right;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand-2) 85%, transparent), inset 0 1px 0 rgba(255, 255, 255, .18); }
.bot-turn { align-self: stretch; display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.bot-av { flex: none; display: grid; animation: pop-in .3s var(--spring) backwards; }
.bot-av .logo { width: 28px; height: 28px; border-radius: 9px; box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--brand-1) 65%, transparent); }
.bot-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
/* el borde se tiñe un poco de la marca por el lado del lince */
.msg.bot { max-width: 100%; transform-origin: top left; box-shadow: var(--shadow-xs); border: 1px solid transparent;
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(135deg, color-mix(in srgb, var(--brand-1) 40%, var(--border)), var(--border) 45%) border-box; }
.bot-col > .msg.bot:first-child, .bot-col > .typing:first-child { border-top-left-radius: 4px; }
/* avisos del simulador: una línea fina con el texto en medio */
.msg.system { align-self: stretch; max-width: none; display: flex; align-items: center; gap: 10px; padding: 2px 0;
  background: none; border: 0; box-shadow: none; color: var(--faint); font-size: 11.5px; text-align: center; }
.msg.system::before, .msg.system::after { content: ""; flex: 1 1 24px; height: 1px; background: var(--border); }
/* respuestas rápidas: teñidas de la marca, con una flecha que avanza; al pasar el ratón, en degradado */
.quick { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.quick button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 12px; border-radius: 10px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--accent-text); cursor: pointer;
  background: color-mix(in srgb, var(--primary) 8%, var(--panel)); border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent);
  animation: msg-in .3s var(--spring) backwards;
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .2s, transform .2s var(--spring); }
/* la flecha se forma al pasar el ratón: en reposo, un cheurón fino; luego avanza y le sale el trazo */
.quick button svg.icon.go { width: 14px; height: 14px; margin-right: -3px; stroke-width: 2.4; opacity: .6; transition: opacity .15s; }
svg.icon.go .go-tip { transform: translateX(-3px); transition: transform .28s var(--spring); }
svg.icon.go .go-line { opacity: 0; transform: scaleX(0); transform-box: fill-box; transform-origin: left center;
  transition: opacity .15s, transform .28s var(--spring); }
.quick button:nth-child(2) { animation-delay: 40ms; } .quick button:nth-child(3) { animation-delay: 80ms; }
.quick button:nth-child(4) { animation-delay: 120ms; } .quick button:nth-child(n+5) { animation-delay: 160ms; }
.quick button:hover { color: #fff; border-color: transparent; transform: translateY(-1px);
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  box-shadow: 0 8px 16px -8px color-mix(in srgb, var(--brand-2) 85%, transparent); }
.quick button:hover svg.icon.go { opacity: 1; }
.quick button:hover svg.icon.go .go-tip, .quick button:hover svg.icon.go .go-line { opacity: 1; transform: none; }
.turn-meta { align-self: flex-start; display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--muted); flex-wrap: wrap; max-width: 100%; animation: fade .3s var(--ease) .1s backwards; }
.turn-meta .intent-link { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border);
  background: var(--panel); padding: 2px 8px 2px 7px; height: 24px; border-radius: 7px; font: inherit; font-size: 12px;
  font-weight: 600; color: var(--text); cursor: pointer; transition: border-color .15s, box-shadow .15s, color .15s; }
.turn-meta .intent-link svg.icon { width: 13px; height: 13px; color: var(--faint); transition: transform .2s var(--ease); }
.turn-meta .intent-link:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); color: var(--accent-text); box-shadow: var(--shadow-xs); }
.turn-meta .intent-link[aria-expanded="true"] svg.icon { transform: rotate(180deg); }
.turn-detail { align-self: stretch; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-xs);
  border-radius: 12px; padding: 12px 14px; font-size: 12.5px; display: flex; flex-direction: column; gap: 10px;
  animation: pop-in .2s var(--ease); }
.turn-detail .kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; }
.turn-detail .kv > div:nth-child(odd) { color: var(--faint); }
.turn-detail code { background: var(--panel-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; }
.payload { align-self: flex-start; max-width: 100%; background: var(--panel); border: 1px dashed var(--border-strong);
  border-radius: 12px; padding: 8px 10px; animation: msg-in .28s var(--spring) backwards; }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; animation: msg-in .2s var(--ease); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-1); animation: bounce-dot 1s infinite; }
.typing i:nth-child(2) { background: color-mix(in srgb, var(--brand-1) 50%, var(--brand-2)); animation-delay: .15s; }
.typing i:nth-child(3) { background: var(--brand-2); animation-delay: .3s; }
.sim-toggle { position: fixed; right: 20px; bottom: 20px; z-index: 40; width: 56px; height: 56px;
  border-radius: 18px; border: 0; color: #fff; cursor: pointer; display: none; place-items: center;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); animation: pop-in .3s var(--spring);
  box-shadow: 0 12px 28px -8px color-mix(in srgb, var(--brand-1) 70%, transparent); transition: transform .2s var(--spring); }
.sim-toggle:hover { transform: translateY(-2px) scale(1.04); }
.sim-toggle svg { width: 24px; height: 24px; }
.app.sim-closed .sim { display: none; }
.app.sim-closed .sim-toggle { display: grid; }

/* ------------------------------------------------------- analizador */
.conf-bar { position: relative; height: 8px; border-radius: 6px; background: var(--panel-3); overflow: hidden;
  min-width: 90px; }
.conf-bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 6px; transform-origin: left;
  background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 75%, #fff), var(--primary)); animation: grow-x .7s var(--ease) backwards; }
.conf-bar.low > span { background: var(--warning); }
.conf-bar .thr { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--danger); }
/* tokenización (ui.js:tokenGloss): una columna por palabra y una fila por paso, sin cajas */
.gloss { display: grid; width: max-content; grid-auto-columns: max-content; }
.gl-label { grid-column: 1; position: sticky; left: 0; z-index: 1; display: flex; align-items: center; padding: 8px 18px 8px 0;
  background: var(--panel); border-top: 1px solid var(--border); font-size: 10.5px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint); white-space: nowrap; cursor: help; }
.gl-cell { display: flex; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); white-space: nowrap;
  animation: rise .32s var(--ease) backwards; animation-delay: calc(var(--i) * 30ms); transition: background-color .15s; }
.gl-label.first, .gl-cell.first { border-top: 0; }
.gl-cell.lit { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.gl-word { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.gl-word.stop { color: var(--muted); font-weight: 500; }
.gl-word.sym { color: var(--faint); font-weight: 500; }
.gl-mark { color: var(--a-ink); padding: 1px 6px; margin: -1px -6px; border-radius: 6px; }
.gl-mono { font-family: var(--mono); font-size: 12.5px; color: var(--faint); }
.gl-mono.diff { color: var(--accent-text); font-weight: 600; }
.gl-kind { font-size: 12px; font-style: italic; color: var(--faint); }
.gl-corr { font-size: 12.5px; font-weight: 600; color: var(--warning); }
.gl-ent { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--a-ink); padding: 2px 8px; border-radius: 6px; }
.result-text { font-size: 18px; line-height: 2; letter-spacing: -.01em; }
.kv-table { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv-table > div:nth-child(odd) { color: var(--muted); }
.kv-table code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.feedback { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--panel-2); }
.card.highlight { border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 8%, transparent), var(--shadow-xs); }
.analyze-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--panel); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.analyze-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.analyze-box > svg.icon { color: var(--faint); }
.analyze-box input { border: 0 !important; box-shadow: none !important; background: transparent; padding-left: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-4 .card + .card, .grid-2 .card + .card, .agent-cards .card + .card { margin-top: 0; }
.stat { padding: 16px 18px; position: relative; overflow: hidden; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 500; padding-right: 36px; min-height: 19px; }
.stat .s-icon { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 9px; display: grid;
  place-items: center; background: var(--primary-soft); color: var(--accent-text); }
.stat .s-icon svg.icon { width: 16px; height: 16px; }
.agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.agent-card { padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; outline: none;
  transition: border-color .2s, box-shadow .2s, transform .25s var(--spring); }
.agent-card:hover, .agent-card:focus-visible { border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: var(--shadow); transform: translateY(-3px); }
.agent-card h3 { font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.agent-card .desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agent-card .stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.agent-card .stats span { display: inline-flex; align-items: center; gap: 5px; }
.agent-card .stats svg.icon { width: 14px; height: 14px; color: var(--faint); }
.agent-card .foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--faint);
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.agent-card .open { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); font-weight: 600;
  opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s var(--ease); }
.agent-card:hover .open, .agent-card:focus-visible .open { opacity: 1; transform: none; }
.agent-card .open svg.icon { width: 14px; height: 14px; }
.agent-card.new { border-style: dashed; border-width: 1.5px; background: transparent; box-shadow: none; align-items: center;
  justify-content: center; color: var(--muted); min-height: 170px; font: inherit; font-weight: 600; }
.agent-card.new:hover { color: var(--accent-text); background: var(--panel); }
.agent-card.new .plus { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--border); transition: transform .3s var(--spring); }
.agent-card.new:hover .plus { transform: rotate(90deg); }
/* grupos de la lista de agentes: «Tus agentes» arriba y «Ejemplos» debajo */
.agent-group + .agent-group { margin-top: 30px; }
.section-head { margin: 2px 0 12px; animation: rise .32s var(--ease) backwards; }
.section-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.section-head h2 svg.icon { width: 17px; height: 17px; color: var(--accent-text); }
.section-head .badge { height: 20px; padding: 0 7px; font-variant-numeric: tabular-nums; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.agents-empty { border-style: dashed; border-width: 1.5px; background: transparent; box-shadow: none; }
.agents-empty .empty { padding: 30px 18px; }
.tpl-list { display: grid; gap: 8px; }
.tpl-list.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Idioma o «Copiar de», según cómo empiece el agente nuevo */
.field.swap { animation: rise .24s var(--ease); }
.source-pick { margin: 0; width: 100%; }
.tpl-card { display: flex; gap: 11px; align-items: flex-start; padding: 12px; border: 1px solid var(--border-strong); border-radius: 12px;
  cursor: pointer; font-weight: 400; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.tpl-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border-strong)); }
.tpl-card.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.tpl-card:focus-within { box-shadow: 0 0 0 3px var(--ring); }
.tpl-card b { font-size: 13.5px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone .card-head > svg.icon { color: var(--danger); }

/* desplegable (ui.js:selectMenu), como el «Menú Expansible» de las plantillas: la cabecera con lo
   elegido y una flecha que gira; debajo, las opciones separadas por una línea fina */
.xmenu { position: relative; min-width: 0; }
.xmenu.w-200 { width: 200px; } .xmenu.w-220 { width: 220px; }
.xm-head { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s; }
.xm-head:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 14%); }
.xm-head:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.xm-head:disabled { opacity: .6; cursor: default; }
.xm-text { flex: 1; min-width: 0; }
.xm-text.placeholder { color: var(--faint); }
.xm-head .xm-arrow { width: 15px; height: 15px; color: var(--faint); transition: transform .3s var(--ease), color .15s; }
.xmenu.open .xm-head { border-color: var(--primary); border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; }
.xmenu.open.up .xm-head { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.xmenu.open .xm-arrow { transform: rotate(180deg); color: var(--accent-text); }
.xm-panel { position: fixed; z-index: 86; display: flex; flex-direction: column; overflow: hidden; background: var(--panel);
  border: 1px solid var(--primary); border-top-color: var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-lg); animation: xm-open .24s var(--ease); }
.xm-panel.up { border-top-color: var(--primary); border-bottom-color: var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  animation-name: xm-open-up; }
.xm-panel.closing { animation: xm-close .14s var(--ease) forwards; pointer-events: none; }
@keyframes xm-open { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
@keyframes xm-open-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@keyframes xm-close { to { opacity: 0; } }
@keyframes xm-item { from { opacity: 0; transform: translateY(-3px); } }
input[type=search].xm-search { margin: 6px 6px 2px; min-height: 32px; font-size: 13px; }
.xm-items { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 4px; }
.xm-group { padding: 10px 12px 4px; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.xm-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13.5px; color: var(--muted); cursor: pointer;
  border-top: 1px solid var(--border); transition: padding-left .18s var(--ease), background-color .12s, color .12s;
  animation: xm-item .24s var(--ease) backwards; animation-delay: calc(var(--i) * 16ms); }
.xm-items > .xm-item:first-child, .xm-group + .xm-item { border-top-color: transparent; }
.xm-item.active { background: var(--panel-2); color: var(--text); padding-left: 18px; }
.xm-item.sel { color: var(--accent-text); font-weight: 600; }
.xm-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.xm-sub { font-size: 11.5px; font-weight: 400; color: var(--faint); }
.xm-item .xm-check { width: 15px; height: 15px; color: var(--primary); }
.xm-empty { padding: 12px; color: var(--faint); font-size: 13px; }

/* selector de color (ui.js:colorPicker), como el «Color Picker HSV» de las plantillas */
.cp-btn { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 10px 0 5px; font: inherit;
  font-size: 13px; color: var(--text); background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.cp-btn:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 14%); }
.cp-btn.open, .cp-btn:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.cp-swatch { width: 26px; height: 26px; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: background-color .15s; }
.cp-code { font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: .03em; }
.cp-btn .cp-arrow { width: 14px; height: 14px; color: var(--faint); transition: transform .3s var(--ease); }
.cp-btn.open .cp-arrow { transform: rotate(180deg); }
.cp-panel { width: 248px; display: flex; flex-direction: column; gap: 12px; padding: 6px; }
.cp-field { position: relative; height: 150px; border-radius: 10px; overflow: hidden; cursor: crosshair; touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.cp-field:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cp-canvas { display: block; width: 100%; height: 100%; }
.cp-cursor { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; transform: translate(-50%, -50%);
  pointer-events: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 3px 8px rgba(0, 0, 0, .35); transition: width .15s var(--spring), height .15s var(--spring); }
.cp-field.drag .cp-cursor { width: 22px; height: 22px; }
input[type=range].cp-hue { width: 100%; height: 12px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }
input[type=range].cp-hue::-webkit-slider-thumb { width: 18px; height: 18px; background: #fff; border: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .35); }
input[type=range].cp-hue::-moz-range-thumb { width: 16px; height: 16px; background: #fff; border: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .35); }
.cp-row { display: flex; align-items: center; gap: 8px; }
.cp-prev { width: 36px; height: 36px; flex: none; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
input[type=text].cp-hex { flex: 1; width: 0; font-family: var(--mono); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
input[type=text].cp-hex.bad { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.cp-dots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.cp-dot { height: 24px; border: 0; border-radius: 7px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
  transition: transform .15s var(--spring), box-shadow .15s; }
.cp-dot:hover { transform: scale(1.12); }
.cp-dot.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }

/* configuración y vista previa del widget (Integraciones) */
.widget-config { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
/* maqueta del widget: mismos colores que web/widget.js (claro u oscuro) */
.widget-preview { --c: #4f46e5; --w-bg: #fff; --w-fg: #1b2232; --w-soft: #f6f7f9; --w-card: #fff; --w-line: #e7e8eb;
  --w-line2: #d6d8dd; --w-muted: #80858f; --w-ink: var(--c);
  position: relative; height: 292px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel-2); overflow: hidden; }
.widget-preview.dark { --w-bg: #1c1c1c; --w-fg: #ececec; --w-soft: #141414; --w-card: #262626; --w-line: #303030;
  --w-line2: #424242; --w-muted: #9b9b9b; --w-ink: color-mix(in srgb, var(--c) 50%, #fff); }
.wp-page { padding: 18px; display: flex; flex-direction: column; gap: 9px; }
.wp-page i { display: block; height: 9px; border-radius: 5px; background: var(--panel-3); }
.wp-bubble { position: absolute; bottom: 14px; left: calc(100% - 54px); width: 40px; height: 40px; border-radius: 12px;
  background: var(--c); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 18px -6px rgba(0, 0, 0, .4);
  transition: left .5s var(--spring), background-color .3s; }
.wp-bubble svg.icon { width: 19px; height: 19px; }
.wp-panel { position: absolute; bottom: 64px; left: calc(100% - 224px); width: 210px; border-radius: 13px; background: var(--w-bg);
  color: var(--w-fg); box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .4), 0 0 0 1px color-mix(in srgb, var(--w-fg) 7%, transparent);
  overflow: hidden; font-size: 11px; line-height: 1.35; transition: left .5s var(--spring), background-color .3s, color .3s; }
.widget-preview.left .wp-bubble, .widget-preview.left .wp-panel { left: 14px; }
.wp-head { background: var(--c); color: #fff; padding: 8px 10px; display: flex; align-items: center; gap: 6px; transition: background-color .3s; }
.wp-head b { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp-head svg.icon { width: 13px; height: 13px; opacity: .85; }
.wp-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--w-soft); transition: background-color .3s; }
.wp-msg { position: relative; align-self: flex-start; margin-left: 22px; background: var(--w-card); border: 1px solid var(--w-line);
  border-radius: 3px 10px 10px 10px; padding: 5px 8px; max-width: 78%; transition: background-color .3s, border-color .3s; }
.wp-msg::before { content: ""; position: absolute; left: -22px; top: 0; width: 17px; height: 17px; border-radius: 6px;
  background: var(--c) linear-gradient(135deg, rgba(255, 255, 255, .25), rgba(0, 0, 0, .06)); transition: background-color .3s; }
.wp-msg.user { margin-left: 0; align-self: flex-end; color: #fff; border-color: transparent; border-radius: 10px 10px 3px 10px;
  background: var(--c) linear-gradient(135deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 60%); }
.wp-msg.user::before { display: none; }
.wp-quick { display: flex; gap: 4px; flex-wrap: wrap; margin-left: 22px; }
.wp-quick span svg.icon { width: 9px; height: 9px; stroke-width: 2.6; opacity: .6; }
.wp-quick span svg.icon .go-tip { transform: translateX(-3px); }
.wp-quick span svg.icon .go-line { opacity: 0; }
.wp-quick span { display: inline-flex; align-items: center; gap: 2px; border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); color: var(--w-ink); border-radius: 6px; padding: 2px 5px 2px 6px; font-size: 10px;
  font-weight: 600; background: color-mix(in srgb, var(--c) 9%, var(--w-card)); transition: background-color .3s; }
.wp-input { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--w-line); color: var(--w-muted);
  background: var(--w-bg); transition: background-color .3s; }
.wp-box { flex: 1; display: flex; align-items: center; gap: 6px; border: 1px solid var(--w-line2); background: var(--w-card);
  border-radius: 9px; padding: 2px 2px 2px 8px; }
.wp-box span:first-child { flex: 1; }
.wp-send { width: 20px; height: 20px; border-radius: 6px; color: #fff; display: grid; place-items: center;
  background: var(--c) linear-gradient(135deg, rgba(255, 255, 255, .22), rgba(0, 0, 0, .06)); }
.wp-send svg.icon { width: 11px; height: 11px; }
.transcript { display: flex; flex-direction: column; gap: 8px; }
.log-item { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.log-item:first-child { border-top: 0; }
.log-item .q { font-size: 15px; }
.validation-item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; font-size: 13px; border-top: 1px solid var(--border); }
.validation-item:first-child { border-top: 0; }

/* ------------------------------------------------------------ gráficos */
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke: var(--series-1); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 1; animation: draw 1.1s var(--ease) backwards; }
.chart-svg .area { fill: var(--series-1); opacity: .1; animation: fade .9s var(--ease) .2s backwards; }
.chart-svg .end-dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.chart-svg .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-title { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.chart-tip { position: absolute; display: none; pointer-events: none; z-index: 5; background: var(--tip-bg); color: var(--tip-ink);
  border-radius: 9px; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .4); padding: 6px 10px; font-size: 12px;
  max-width: 280px; white-space: normal; }
.chart-tip b { display: block; color: inherit; font-size: 13px; }
.chart-tip span { color: inherit; opacity: .72; }
.bars { position: relative; display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; align-items: center; gap: 10px; padding: 1px 0; border-radius: 4px; outline: none; }
.bar-row:hover .bar, .bar-row:focus .bar, .bar-row:hover .dbar, .bar-row:focus .dbar { filter: brightness(1.12); }
.bar-row:hover .bar-label, .bar-row:focus .bar-label { color: var(--text); }
.bar-label { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; transition: color .15s; }
.bar-track { height: 10px; position: relative; }
.bar { height: 100%; border-radius: 0 5px 5px 0; min-width: 2px; transform-origin: left; animation: grow-x .7s var(--ease) backwards; }
.bars > .bar-row:nth-child(2) .bar { animation-delay: 40ms; } .bars > .bar-row:nth-child(3) .bar { animation-delay: 80ms; }
.bars > .bar-row:nth-child(4) .bar { animation-delay: 120ms; } .bars > .bar-row:nth-child(5) .bar { animation-delay: 160ms; }
.bars > .bar-row:nth-child(n+6) .bar { animation-delay: 200ms; }
.dtrack .zero { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--axis); }
.dbar { position: absolute; top: 0; bottom: 0; }
.dbar.pos { background: var(--series-1); border-radius: 0 5px 5px 0; transform-origin: left; animation: grow-x .7s var(--ease) backwards; }
.dbar.neg { background: var(--series-neg); border-radius: 5px 0 0 5px; transform-origin: right; animation: grow-x .7s var(--ease) backwards; }
.columns .col-bar { fill: var(--series-1); transform-box: fill-box; transform-origin: bottom;
  animation: grow-y .6s var(--ease) backwards; transition: opacity .15s; }
.columns:hover .col-bar { opacity: .5; }
.columns:hover .col-bar.hot { opacity: 1; }
@keyframes grow-y { from { transform: scaleY(0); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; flex: none; }
.swatch.dot { border-radius: 50%; }
.swatch.ring { border-radius: 50%; border: 2px solid var(--text); width: 12px; height: 12px; background: transparent; }
.legend-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.legend-key.a { background: var(--series-1); }
.legend-key.b { background: var(--series-2); margin-left: 8px; }
.scatter .plot-frame { fill: var(--panel-2); stroke: var(--border); }
.scatter .pt { fill: var(--deemph); stroke: var(--panel-2); stroke-width: 2; transition: r .2s var(--ease); }
.scatter .pt.a { fill: var(--series-1); }
.scatter .pt.b { fill: var(--series-2); }
.scatter .pts { animation: fade .6s var(--ease) backwards; }
.scatter .pt-hover { fill: none; stroke: var(--text); stroke-width: 2; pointer-events: none; }
.scatter .probe-ring { fill: none; stroke: var(--text); stroke-width: 2.5; }
.scatter .probe-dot { fill: var(--text); }
.scatter .probe-label { fill: var(--text); font-size: 12px; font-weight: 650; paint-order: stroke;
  stroke: var(--panel-2); stroke-width: 4px; }
.meter-box { display: flex; flex-direction: column; gap: 8px; }
.meter { position: relative; height: 10px; border-radius: 6px;
  background: color-mix(in srgb, var(--series-1) 16%, transparent); }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--series-1);
  transform-origin: left; animation: grow-x .8s var(--ease) backwards; }
.meter-thr { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 2px; }
.meter.small-meter { height: 8px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff;
  font-size: 12px; font-weight: 700; flex: none; }
.status-icon.good { background: var(--good); }
.status-icon.critical { background: var(--critical); }
.heatmap-wrap { position: relative; overflow-x: auto; margin-top: 8px; }
.heatmap { border-collapse: separate; border-spacing: 3px; font-size: 11.5px; }
.heatmap th { font-weight: 600; color: var(--muted); padding: 2px 4px; text-align: center; }
.heatmap th.corner { text-align: right; font-weight: 500; color: var(--faint); white-space: nowrap; }
.heatmap th.row-label { text-align: right; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.heatmap td { width: 30px; height: 28px; text-align: center; border-radius: 6px; background: var(--panel-2);
  font-variant-numeric: tabular-nums; color: var(--text); transition: transform .15s var(--spring); }
.heatmap td.has:hover, .heatmap td.has:focus { transform: scale(1.15); outline: none; position: relative; z-index: 1; }
.heatmap td.diag { box-shadow: inset 0 0 0 1px var(--axis); }
.heatmap td.ink-light { color: #fff; }
/* matriz compacta (muchas intenciones): cabe a lo ancho; en el móvil se desplaza */
.heatmap-svg { display: block; width: 100%; max-width: 960px; min-width: 600px; height: auto; outline: none;
  border-radius: 8px; animation: fade .5s var(--ease) backwards; }
.heatmap-svg:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.heatmap-svg .hm-empty { fill: var(--panel-2); }
.heatmap-svg .hm-cell.diag { fill: var(--series-1); }
.heatmap-svg .hm-cell.off { fill: var(--series-2); }
.heatmap-svg .hm-sep { stroke: var(--axis); stroke-width: .8; opacity: .55; }
.heatmap-svg .hm-group { font-size: 11px; font-weight: 600; fill: var(--muted); text-anchor: end; dominant-baseline: middle; }
.heatmap-svg .hm-band { fill: var(--text); opacity: .07; pointer-events: none; }
.heatmap-svg .hm-focus { fill: none; stroke: var(--text); stroke-width: 1.4; pointer-events: none; }
.heatmap-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.heatmap-legend .legend-key.b { margin-left: 10px; }

/* ------------------------------------------------- «Por dentro» (cómo funciona, con fórmulas) */
math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", math; font-size: 1.08em; }
.inside .in-content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.inside .in-content > .card + .card { margin-top: 0; }
.inside .in-sec { scroll-margin-top: 18px; animation: rise .45s var(--ease) backwards; }
.inside .in-body { gap: 14px; }
.inside .in-body > p, .inside .in-body > ul, .inside .in-body > ol { margin: 0; line-height: 1.62; }
.inside .in-body h3 { margin: 6px 0 0; font-size: 14.5px; }
.inside .lead { font-size: 15px; line-height: 1.6; }
.inside .card-head h2 { font-size: 16px; }
.sec-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--primary-soft); color: var(--accent-text); font-weight: 700; font-size: 13px; }
.in-list { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.in-steps { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.in-steps.trace { margin: 0; }
.formula { --scroll-bg: var(--panel-2); padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 44px;
  /* «safe»: si no cabe, a la izquierda (centrada, lo que sobrara por la izquierda no se podría ver) */
  justify-content: center; justify-content: safe center; }
.formula.scrolls { justify-content: flex-start; }  /* ni encogida cabe (math.js:fitFormulas) */
.formula math { font-size: 1.18em; }
.formula > math { flex-shrink: 0; }  /* a su ancho de verdad: si no, fitFormulas mediría la caja y no la fórmula */
.formula.live-formula { --scroll-bg: color-mix(in srgb, var(--primary-soft) 55%, var(--panel)); border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
  column-gap: 10px; }
/* lo que se desplaza a lo ancho enseña una sombra en el borde por el que sigue: las tapas (local)
   se mueven con el contenido y las sombras (scroll) se quedan en los bordes */
.formula, .table-scroll {
  background: linear-gradient(to right, var(--scroll-bg) 40%, transparent) left / 28px 100% no-repeat local,
    linear-gradient(to left, var(--scroll-bg) 40%, transparent) right / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--edge-shadow), transparent) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--edge-shadow), transparent) right / 14px 100% no-repeat scroll,
    var(--scroll-bg); }
.formula.conf-calc { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: 6px; }
.formula.conf-calc math { font-size: 1.05em; }
.sym-legend { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 13px; align-items: baseline; }
.sym-legend dt { text-align: right; white-space: nowrap; }
.sym-legend dd { margin: 0; color: var(--muted); }
.code-ref { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--faint); }
.code-ref svg { width: 14px; height: 14px; }
.code-ref code { font-size: 12px; }
.live { --live-bg: color-mix(in srgb, var(--primary-soft) 35%, var(--panel)); border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: var(--radius-sm); padding: 12px 14px; background: var(--live-bg); display: flex; flex-direction: column; gap: 10px; }
.live-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--accent-text);
  text-transform: uppercase; letter-spacing: .05em; }
.live-title svg { width: 14px; height: 14px; }
.live-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.live-body:empty::before { content: "Analizando…"; color: var(--faint); font-size: 13px; }

/* ¿Y el teorema de Bayes? (paso 7): Naive Bayes al lado de la regresión logística.
   Naranja (--series-2) es Naive Bayes y azul (--series-1), la regresión, como en los gráficos. */
.bayes { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; padding: 18px; border-radius: var(--radius);
  border: 1px solid transparent; background: linear-gradient(var(--panel-2), var(--panel-2)) padding-box,
    linear-gradient(135deg, color-mix(in srgb, var(--series-2) 45%, var(--border)), var(--border) 40%,
    color-mix(in srgb, var(--series-1) 45%, var(--border))) border-box; }
.bayes h3 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.01em; }
.bayes h4 { margin: 6px 0 -4px; font-size: 14.5px; }
.bayes p { margin: 0; }
.bayes-head { display: flex; gap: 12px; align-items: flex-start; }
.bayes-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--series-2), var(--series-1)); box-shadow: 0 6px 14px -8px var(--series-1); }
.bayes-icon svg.icon { width: 21px; height: 21px; }
.bayes-duel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.duel { --duel: var(--series-1); display: flex; flex-direction: column; gap: 10px; padding: 14px; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--duel); border-radius: 12px;
  animation: rise .4s var(--ease) backwards; }
.duel.nb { --duel: var(--series-2); }
.duel.lr { animation-delay: 80ms; }
.duel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 15px; }
.duel-tag { font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 6px; color: var(--duel);
  background: color-mix(in srgb, var(--duel) 13%, var(--panel)); }
.duel .formula { margin: 0; }
.duel p { font-size: 13.5px; color: var(--muted); }
.duel-step { display: flex; align-items: center; justify-content: center; gap: 6px; margin: -4px 0; font-size: 12px; color: var(--faint); }
.duel-step svg.icon { width: 15px; height: 15px; }
/* las piezas que se corresponden, del mismo color en las dos fórmulas (\hl{n}{…} de math.js) */
.hl { border-radius: 4px; padding: 0 2px; }
.hl-1 { background: var(--a1); } .hl-2 { background: var(--a0); } .hl-3 { background: var(--a2); }
.bayes-map { display: grid; grid-template-columns: max-content max-content max-content 1fr; gap: 8px 10px; align-items: center;
  margin-top: auto; padding-top: 4px; font-size: 13px; }
.bm-row { display: contents; }
.bm-sym { justify-self: center; padding: 2px 8px; border-radius: 7px; color: var(--a-ink); }
.bm-eq { color: var(--faint); }
.bm-text { color: var(--muted); }
/* con tu frase: la palabra, sus rasgos y cuánto empujan */
.fam { display: flex; flex-direction: column; gap: 10px; }
.fam-word { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.fam-quote { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.fam-count { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.fam-count svg.icon { width: 15px; height: 15px; color: var(--faint); }
.fam-groups { display: flex; flex-direction: column; gap: 6px; padding-left: 12px; border-left: 2px solid color-mix(in srgb, var(--series-2) 45%, var(--border)); }
.fam-group { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fam-label { flex: none; width: 150px; font-size: 12px; color: var(--faint); }
.fam-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; flex: 1; }
.fam-chip { font-family: var(--mono); font-size: 12px; padding: 2px 7px; border-radius: 6px; background: var(--panel);
  border: 1px solid var(--border); cursor: help; animation: pop-in .25s var(--spring) backwards; animation-delay: calc(var(--i) * 25ms); }
.fam-chip.k-w { font-family: var(--font); font-weight: 650; background: color-mix(in srgb, var(--series-2) 14%, var(--panel)); border-color: transparent; }
.fam-chip.k-b { font-family: var(--font); font-weight: 550; }
.push { display: flex; flex-direction: column; gap: 8px; }
.push-row { --bar: var(--series-1); display: grid; grid-template-columns: 150px minmax(60px, 1fr) minmax(0, auto); gap: 10px; align-items: center; font-size: 13px; }
.push-row.nb { --bar: var(--series-2); }
.push-name { font-weight: 600; }
.push-track { height: 12px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.push-fill { height: 100%; border-radius: 4px; background: var(--bar); transform-origin: left; animation: grow-x .7s var(--ease) backwards; }
.push-val { color: var(--muted); }
.push-val b { color: var(--text); font-variant-numeric: tabular-nums; }
.duel-probs { display: flex; flex-direction: column; gap: 8px; }
.dp-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); }
.dp-key { width: 10px; height: 10px; border-radius: 3px; background: var(--series-1); }
.dp-key.nb { background: var(--series-2); margin-left: 8px; }
.dp-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 13px; }
.dp-name { font-weight: 550; }
.dp-bars { display: flex; flex-direction: column; gap: 3px; }
.dp-bar { --bar: var(--series-1); display: grid; grid-template-columns: minmax(40px, 1fr) 88px; gap: 8px; align-items: center; }
.dp-bar.nb { --bar: var(--series-2); }
.dp-track { height: 8px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.dp-fill { height: 100%; border-radius: 3px; background: var(--bar); transform-origin: left; animation: grow-x .7s var(--ease) backwards; }
.dp-val { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bayes-table td.win { color: var(--text); font-weight: 600; }
.bayes-table td.win svg.icon { width: 14px; height: 14px; color: var(--success); margin-right: 5px; vertical-align: -2px; }
.bayes-table th[scope=row] { text-align: left; color: var(--muted); font-weight: 550; white-space: nowrap;
  text-transform: none; letter-spacing: 0; font-size: 13px; }
@container (max-width: 760px) {
  .bayes-duel { grid-template-columns: minmax(0, 1fr); }
  .bayes { padding: 14px; }
  .fam-label { width: 100%; }
  .push-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .dp-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
/* la tabla comparativa, en estrecho: cada fila en un bloque, con las dos respuestas lado a lado */
@container (max-width: 560px) {
  .bayes-table thead { display: none; }
  .bayes-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border); }
  .bayes-table tr:last-child { border-bottom: 0; }
  .bayes-table th[scope=row] { grid-column: 1 / -1; padding: 0; border: 0; color: var(--text); font-weight: 650; white-space: normal; }
  .bayes-table td { padding: 0; border: 0; }
  .bayes-table td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 500; color: var(--faint); }
}
.in-input { display: flex; gap: 8px; }
.in-input input { flex: 1; min-width: 0; font-size: 15px; }
.in-try { display: flex; gap: 12px; flex-wrap: wrap; }
.in-try .field { flex: 1 1 160px; margin: 0; }
.in-pair { gap: 18px; align-items: center; }
.in-pair > p { flex: 1 1 260px; margin: 0; }
.in-pair > svg.in-chart, .in-pair > .in-figure { flex: 1 1 340px; max-width: 440px; }
/* los pequeños se ven a su tamaño (si se estiraran, el texto saldría enorme) */
.in-pair > svg.in-chart.small-chart { flex: 0 1 300px; max-width: 300px; }
.in-pair > svg.in-chart.cosine { flex: 0 1 250px; max-width: 250px; }
.in-pair.idf-pair { align-items: flex-start; }
.in-pair.idf-pair > svg.in-chart { flex: 1 1 300px; max-width: 380px; }
.in-pair.idf-pair > .table-scroll { flex: 1 1 220px; }
.in-figure { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chart-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chart-legend .legend-key.b { margin-left: 0; }
.chart-legend math { font-size: 1em; color: var(--text); }
.mini-table th.plain { text-transform: none; letter-spacing: 0; }
.in-chart .leader { stroke: var(--axis); stroke-width: 1; }
.in-chart .badge { fill: var(--panel); stroke: var(--series-2); stroke-width: 2; }
.in-chart .badge-num { font-size: calc(10.5px * var(--text-k, 1)); font-weight: 700; fill: var(--text); }
.badge-dot { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; border: 2px solid var(--series-2);
  font-size: 11px; font-weight: 700; line-height: 1; }
.stem-word .rg.none { color: var(--faint); font-weight: 400; background: transparent; padding-left: 0; }
.in-note { margin: 0; }
.in-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.in-chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 7px; font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--border); font-family: var(--mono); }
.in-chip.hit { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 45%, var(--border)); font-weight: 650; }
.in-chip.param { font-family: var(--font); }
.feat-group { display: flex; flex-direction: column; gap: 6px; }
.fg-title { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mini-table { border-collapse: collapse; font-size: 13px; width: 100%; }
.mini-table th { text-align: left; font-size: 11.5px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .04em;
  padding: 6px 10px; border-bottom: 1px solid var(--border); }
.mini-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table tr.sum td { font-weight: 650; border-top: 1px solid var(--border-strong); }
.mini-table code.chg { background: var(--warning-soft); }
.table-scroll { --scroll-bg: var(--panel); overflow-x: auto; }
.live .table-scroll { --scroll-bg: var(--live-bg); }
/* recorrido de la frase */
.pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pl-step { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 11px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--panel); cursor: pointer; text-align: left; color: var(--text);
  font: inherit; transition: border-color .15s, transform .2s var(--spring), box-shadow .15s; max-width: 220px; }
.pl-step:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pl-step:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.pl-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--muted); }
.pl-head svg { width: 14px; height: 14px; color: var(--accent-text); }
.pl-val { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 196px; }
.pl-arrow { color: var(--faint); display: grid; place-items: center; }
.pl-arrow svg { width: 14px; height: 14px; }
/* distancia de edición */
.edit-view { display: flex; flex-direction: column; gap: 10px; }
.dp-table { border-collapse: separate; border-spacing: 3px; font-size: 13px; font-variant-numeric: tabular-nums; }
.dp-table th { font-weight: 650; color: var(--muted); padding: 2px 6px; font-family: var(--mono); }
.dp-table td { width: 30px; height: 28px; text-align: center; border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.dp-table td.on { background: color-mix(in srgb, var(--series-1) 30%, var(--panel)); color: var(--text); font-weight: 650; }
.dp-table td.final { box-shadow: inset 0 0 0 2px var(--series-1); }
.ops { display: flex; flex-wrap: wrap; gap: 4px; }
.op { padding: 2px 8px; border-radius: 6px; font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--border); }
.op.chg { background: color-mix(in srgb, var(--series-2) 18%, var(--panel)); border-color: color-mix(in srgb, var(--series-2) 45%, var(--border)); }
/* raíces */
.stem-word .letters { display: inline-grid; gap: 2px 2px; align-items: center; font-family: var(--mono); max-width: 100%; }
.stem-word .lt { grid-row: 1; text-align: center; padding: 3px 0; border-radius: 4px; background: var(--panel-2); font-weight: 650; }
.stem-word .lt.cut { color: var(--faint); text-decoration: line-through; font-weight: 400; }
.stem-word .arrow { grid-row: 1; padding-left: 10px; font-family: var(--font); white-space: nowrap; }
.stem-word .rg { height: 15px; border-radius: 4px; font-size: 10px; font-family: var(--font); font-weight: 650; padding-left: 4px; line-height: 15px; }
.stem-word .r1 { grid-row: 2; background: color-mix(in srgb, var(--series-1) 22%, transparent); color: var(--accent-text); }
.stem-word .r2 { grid-row: 3; background: color-mix(in srgb, var(--series-1) 40%, transparent); color: var(--text); }
.stem-word .rv { grid-row: 4; background: color-mix(in srgb, var(--series-2) 25%, transparent); color: var(--text); }
/* entidades sobre los tokens: la frase con cada entidad en su caja */
.ner { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.ner-tok { padding: 5px 9px; border-radius: 7px; background: var(--panel); border: 1px solid var(--border); font-size: 13.5px; }
.ner-ent { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 4px 9px 5px; border-radius: 7px;
  background: color-mix(in srgb, var(--series-1) 20%, var(--panel)); border: 1px solid color-mix(in srgb, var(--series-1) 45%, var(--border));
  animation: rise .4s var(--ease) backwards; }
.ner-text { font-size: 13.5px; font-weight: 650; }
.ner-tag { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ner-tag b { font-family: var(--mono); font-weight: 650; color: var(--accent-text); }
/* gráficos de la página */
.in-chart { width: 100%; max-width: 600px; height: auto; display: block; }
.in-chart.small-chart { max-width: 300px; flex: none; }
.in-chart.cosine { max-width: 260px; flex: none; }
.in-chart .tick { font-size: calc(10.5px * var(--text-k, 1)); fill: var(--faint); }
.in-chart .axis-label { font-size: calc(11px * var(--text-k, 1)); fill: var(--muted); }
.in-chart .grid { stroke: var(--grid); stroke-width: 1; }
.in-chart .axis { stroke: var(--axis); stroke-width: 1; }
.in-chart .line { fill: none; stroke: var(--series-1); stroke-width: 2.2; }
.in-chart .line.b { stroke: var(--series-2); }
.in-chart .pt-live { fill: var(--series-2); stroke: var(--panel); stroke-width: 2; }
.in-chart .pt-live.minor { fill: var(--deemph); }
.in-chart .pt-you { fill: none; stroke: var(--text); stroke-width: 2.5; }
.in-chart .pt-label { font-size: calc(11px * var(--text-k, 1)); fill: var(--text); }
.in-chart .pt-label.b { fill: var(--text); }
.in-chart .strong { font-weight: 700; }
.in-chart .faint { fill: var(--faint); }
.in-chart .vec { stroke-width: 2.6; }
.in-chart .vec.a { stroke: var(--series-1); }
.in-chart .vec.b { stroke: var(--series-2); }
.in-chart .arrow-head { fill: var(--text); }
.in-chart .arc { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 3 3; }
/* cascada de la puntuación */
.wf { display: flex; flex-direction: column; font-size: 12px; }
.wf-row { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr) 52px; align-items: center; column-gap: 10px; height: 23px; }
.wf-label { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-row.total .wf-label, .wf-row.total .wf-val { font-weight: 700; color: var(--text); }
.wf-track { position: relative; align-self: stretch; }
.wf-zero { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--axis); }
.wf-bar { position: absolute; top: 5px; bottom: 5px; min-width: 2px; border-radius: 3px; transform-origin: left center;
  animation: wf-grow .45s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
.wf-bar.pos { background: var(--series-1); }
.wf-bar.neg { background: var(--series-neg); transform-origin: right center; }
.wf-bar.total { background: var(--text); opacity: .8; }
.wf-link { position: absolute; top: calc(100% - 5px); height: 10px; border-left: 1px dashed var(--axis); }
.wf-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes wf-grow { from { transform: scaleX(0); opacity: 0; } }
.conf-wrap { flex: 0 1 380px; min-width: 260px; }
.conf-map .cm-cell { fill: var(--series-1); }
.conf-map .cm-thr { fill: none; stroke: var(--text); stroke-width: 2.2; }
.conf-map .cm-guide { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 4; opacity: .45; }
.conf-map .cm-zone { font-size: calc(12px * var(--text-k, 1)); font-weight: 700; fill: var(--text); opacity: .7; }
.softmax { display: flex; flex-direction: column; gap: 6px; }
/* conversación */
.dlg-flow { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.fl-box { padding: 9px 13px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--panel); font-size: 13px; max-width: 420px; line-height: 1.5; }
.fl-box.start { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.fl-box.end { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.fl-box.side { background: var(--panel-2); color: var(--muted); }
.fl-down { color: var(--faint); padding-left: 22px; line-height: 1.2; }
.fl-split { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fl-branch { display: flex; align-items: center; gap: 8px; }
.fl-tag { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.fl-tag::after { content: " →"; }
.ctx-table .life { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.ctx-table .life-bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--series-1); opacity: .75;
  width: calc(var(--turns) * var(--turn-w, 18px)); }
/* validación cruzada */
.kfold { display: flex; flex-direction: column; gap: 5px; }
.kf-row { display: grid; grid-template-columns: 70px repeat(5, minmax(0, 1fr)); gap: 5px; align-items: center; max-width: 560px; }
.kf-label { font-size: 12px; color: var(--muted); }
.kf-cell { font-size: 11.5px; text-align: center; padding: 5px 0; border-radius: 6px; color: var(--accent-text);
  background: color-mix(in srgb, var(--series-1) 16%, var(--panel)); }
.kf-cell.test { background: color-mix(in srgb, var(--series-2) 30%, var(--panel)); color: var(--text); font-weight: 650; }
/* «Por dentro» y la Guía con la zona central estrecha: el índice es una barra pegada arriba que dice en
   qué sección estás («Contenido / Primeros pasos») y despliega la lista */
@container (max-width: 900px) {
  .cq .guide-layout { display: block; }
  .cq .toc { top: var(--stick-top, 0px); z-index: 15; margin: 0 calc(-1 * var(--pad-x)) 18px; padding: 8px var(--pad-x);
    background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid transparent; transition: border-color .2s, box-shadow .2s; }
  .cq .toc.stuck { border-bottom-color: var(--border); box-shadow: 0 6px 16px -12px rgba(0, 0, 0, .25); }
  .cq .toc-toggle { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--text);
    font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; box-shadow: var(--shadow-xs);
    transition: border-color .15s, box-shadow .15s; }
  .cq .toc-toggle:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text) 14%); }
  .cq .toc.open .toc-toggle { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
  .cq .toc-toggle svg.icon { width: 16px; height: 16px; color: var(--faint); flex: none; }
  .cq .toc-label { color: var(--muted); flex: none; }
  .cq .toc-label::after { content: "/"; margin-left: 9px; color: var(--border-strong); }
  .cq .toc-now { flex: 1; min-width: 0; font-weight: 600; }
  .cq .toc-toggle .toc-chev { transition: transform .2s var(--ease); }
  .cq .toc.open .toc-chev { transform: rotate(180deg); }
  .cq .toc-list { display: none; position: absolute; left: var(--pad-x); right: var(--pad-x); top: calc(100% - 3px);
    max-height: min(62vh, 460px); overflow-y: auto; overscroll-behavior: contain; padding: 6px; border: 1px solid var(--border);
    border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-lg); }
  .cq .toc.open .toc-list { display: flex; animation: pop-in .16s var(--ease); transform-origin: top center; }
  .cq .toc-list > .toc-title:first-child { display: none; }
  .cq .toc a { margin: 0; padding: 8px 10px; border-left: 0; border-radius: 8px; font-size: 13.5px; }
  .cq .toc a.active { background: var(--primary-soft); }
  .cq .toc a + .toc-title { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
}
@container (max-width: 560px) {
  .sym-legend { grid-template-columns: 1fr; }
  .sym-legend dt { text-align: left; }
  .pl-arrow { display: none; }
  .pipeline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pl-step { max-width: none; }
  .pl-val { max-width: none; white-space: normal; overflow-wrap: anywhere; }
  .formula { padding: 12px; gap: 10px 28px; }
  .formula math { font-size: 1.04em; }
  /* cascada: el nombre del rasgo y su valor encima y la barra debajo, a todo el ancho; filas de 31 px
     (17 de texto + 14 de pista) para que la línea discontinua llegue a la barra siguiente */
  .wf-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 17px 14px; height: 31px; column-gap: 8px; }
  .wf-label { grid-area: 1 / 1; text-align: left; }
  .wf-val { grid-area: 1 / 2; }
  .wf-track { grid-area: 2 / 1 / 3 / 3; }
  .wf-bar { top: 2px; bottom: 2px; }
  .wf-link { top: calc(100% - 2px); height: 21px; }
  /* barras (frases parecidas, rasgos con más peso): la etiqueta entera encima de la barra */
  .inside .bar-row { grid-template-columns: minmax(0, 1fr) !important; gap: 4px; }
  .inside .bar-label { text-align: left; white-space: normal; }
  .tok-table .c-kind, .tok-table .c-norm, .softmax .meter, .softmax .c-ez { display: none; }
  .softmax td:first-child { overflow-wrap: anywhere; }
  .mini-table th, .mini-table td { padding-left: 6px; padding-right: 6px; }
  /* tabla de tres columnas: cada fila se apila (nombre y ejemplo arriba, explicación debajo) */
  .mini-table.stack-sm thead { display: none; }
  .mini-table.stack-sm tr { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .mini-table.stack-sm tr:last-child { border-bottom: 0; }
  .mini-table.stack-sm td { border: 0; padding: 0; }
  .mini-table.stack-sm td:last-child { grid-column: 1 / -1; color: var(--muted); }
}
/* teléfonos: nada se corta ni se desplaza (salvo lo que de verdad no cabe, con sombra en el borde) */
@container (max-width: 440px) {
  .formula { padding: 12px 10px; }
  /* tabla en tarjetas: candidata y lados en la primera línea; cada número con su columna delante */
  .mini-table.cards-sm thead { display: none; }
  .mini-table.cards-sm tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 9px 0; border-bottom: 1px solid var(--border); }
  .mini-table.cards-sm tr:last-child { border-bottom: 0; }
  .mini-table.cards-sm td { border: 0; padding: 0; text-align: left; }
  .mini-table.cards-sm td:nth-child(2) { flex: 1 0 calc(100% - 2.5em); }  /* ocupa el resto: los números bajan */
  .mini-table.cards-sm td[data-label]::before { content: attr(data-label) " "; color: var(--faint); }
  .ctx-table { --turn-w: 9px; }
  .dp-table { border-spacing: 2px; font-size: 12px; }
  .dp-table td { width: 24px; height: 24px; }
  .dp-table th { padding: 2px 3px; }
  .stem-word .arrow { grid-row: 5; grid-column: 1 / -1; padding: 6px 0 0; }
}

/* las rejillas de cifras se adaptan al ancho que tienen (el simulador abierto lo reduce) */
.cq { container-type: inline-size; }
@container (max-width: 900px) { .grid-stats { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }
@container (max-width: 640px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@container (max-width: 520px) { .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }

/* ------------------------------------------------------ página Entrenar */
.grid-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid-stats .card + .card, .grid-3 .card + .card { margin-top: 0; }
.grid-stats .stat .v, .learn .grid-3 .stat .v { font-size: 23px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.step { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 12px 0;
  transition: opacity .35s var(--ease); }
.step:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 46px; bottom: -8px; width: 2px;
  border-radius: 2px; background: var(--border); }
.step.done:not(:last-child)::before { background: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.step-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: 13px; background: var(--panel-3); color: var(--muted); flex: none; position: relative; z-index: 1;
  transition: background-color .35s, color .35s, transform .35s var(--spring); }
.step-num.sm { width: 22px; height: 22px; font-size: 12px; }
.step.done .step-num { background: var(--primary); color: var(--primary-ink); }
.step.active .step-num { background: var(--primary); color: var(--primary-ink); transform: scale(1.12);
  animation: pulse-ring 1.2s var(--ease) infinite; }
.step.pending { opacity: .35; }
.step.final .step-num { background: var(--good); color: #fff; }
.step.final.pending .step-num { background: var(--panel-3); color: var(--muted); }
.step-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.step-time { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 6px; }
.step-viz { margin-top: 10px; max-width: 760px; }
.flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.flow-step { border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; display: flex; flex-direction: column;
  gap: 9px; min-width: 0; background: var(--panel); animation: rise .35s var(--ease) backwards; }
.flow > .flow-step:nth-child(2) { animation-delay: 50ms; } .flow > .flow-step:nth-child(3) { animation-delay: 100ms; }
.flow > .flow-step:nth-child(4) { animation-delay: 150ms; } .flow > .flow-step:nth-child(5) { animation-delay: 200ms; }
.flow > .flow-step:nth-child(6) { animation-delay: 250ms; }
.flow-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.placeholder { background: var(--panel-3); padding: 1px 5px; border-radius: 5px; }
.neighbors { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.multiple { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, box-shadow .2s; }
.multiple:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.multiple-title { font-weight: 650; color: var(--text); }

/* ------------------------------------------------------------- guía */
/* índice (ui.js:tocNav): lista fija junto al texto; con poco sitio, una barra con desplegable (más abajo) */
.guide-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.toc { position: sticky; top: 20px; font-size: 13px; }
.toc-toggle { display: none; }
.toc-list { display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--border); padding-left: 2px; }
.toc a { color: var(--muted); padding: 5px 10px; border-radius: 0 7px 7px 0; margin-left: -3px; border-left: 2px solid transparent;
  transition: color .15s, border-color .2s, background-color .15s; }
.toc a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent-text); border-left-color: var(--primary); font-weight: 600; }
.toc-title { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 0 10px 6px; }
.toc a + .toc-title { margin-top: 16px; }
.md { font-size: 15px; line-height: 1.7; }
.md h1 { font-size: 30px; margin: 0 0 12px; letter-spacing: -.03em; }
.md h2 { font-size: 21px; margin: 38px 0 10px; padding-top: 10px; border-top: 1px solid var(--border); letter-spacing: -.02em; scroll-margin-top: 16px; }
.md h3 { font-size: 16.5px; margin: 24px 0 8px; scroll-margin-top: 16px; }
.md h4 { font-size: 15px; margin: 16px 0 6px; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0 0 6px; }
.md li > ul, .md li > ol { margin: 4px 0 6px; }
.md code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.md pre.md-code { background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--code-border); border-radius: 12px; padding: 12px 14px;
  overflow-x: auto; white-space: pre; margin: 0 0 14px; }
.md pre.md-code code { background: none; border: 0; padding: 0; color: inherit; }
.md img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); margin: 6px 0 14px; box-shadow: var(--shadow); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.md .md-note { margin: 0 0 14px; }
.md .md-note p:last-child { margin: 0; }
.md-table { margin-bottom: 0; font-size: 14px; }
.md .table-wrap { margin-bottom: 16px; }

/* ------------------------------------------------------------ móvil */
@media (max-width: 1380px) {
  .flow { grid-template-columns: 1fr; }
  .widget-config { grid-template-columns: 1fr; }
  .widget-preview { max-width: 420px; }
}
@media (max-width: 1180px) {
  .app, .app.sim-closed { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sim { position: fixed; right: 0; top: 0; bottom: 0; width: min(var(--sim-w), 100vw); z-index: 50;
    box-shadow: var(--shadow-lg); animation: sim-in .3s var(--ease); }
  .page { --pad-x: 22px; padding: 20px var(--pad-x) 90px; }
  .version-notice { padding: 16px 22px 0; }
  .page-head.sticky { margin: -20px -22px 18px; padding: 14px 22px 12px; }
}
@keyframes sim-in { from { transform: translateX(40px); opacity: 0; } }
@media (max-width: 760px) {
  .app, .app.sim-closed { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  /* lo que se pega arriba al desplazar (cabeceras, índice) queda debajo de esta barra: --stick-top */
  .main { --stick-top: 52px; }
  .topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px; background: color-mix(in srgb, var(--panel) 88%, transparent);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; backdrop-filter: blur(10px); }
  .topbar .title { font-weight: 650; }
  .topbar .logo { width: 26px; height: 26px; border-radius: 8px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 55; transform: translateX(-100%);
    transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .main::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 50; animation: fade .2s; }
  .page { --pad-x: 14px; padding: 16px var(--pad-x) 96px; }
  .version-notice { padding: 12px 14px 0; }
  .page-head.sticky { margin: -16px -14px 16px; padding: 12px 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }
  .flow { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 20px; }
  .page-icon { display: none; }
  .head-actions { width: 100%; }
  .head-actions > input[type=search] { flex: 1 1 100%; width: auto !important; }
  .list-item .actions, .phrase-row .actions { opacity: 1; }
  .list-item { padding: 12px 14px; }
  .qty-bar { display: none; }
  .tpl-list.two { grid-template-columns: minmax(0, 1fr); }
}
@media (hover: none) {
  .search-btn kbd { display: none; }
}
