/* ==========================================================================
   EVOL Cryptography Lab — AES / Rijndael
   Tema claro por defecto (cuaderno de laboratorio) con modo oscuro opcional.
   Cada transformación de AES tiene un color fijo que se repite en toda la página.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-alt: #eef1f5;
  --paper-line: rgba(22, 40, 70, .055);
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #e9edf2;
  --ink: #0e1a2b;
  --ink-2: #2b394c;
  --muted: #5a687b;
  --faint: #8792a2;
  --line: #dfe4eb;
  --line-2: #ebeef3;
  --accent: #2459d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(36, 89, 214, .09);

  /* Transformaciones: paleta validada (todos los pares, protan/deutan) en ambos temas.
     El nombre y la sigla siempre acompañan al color. --*-ink es el texto sobre ese relleno. */
  --sub: #4a3aa7;
  --shift: #eda100;
  --mix: #008300;
  --ark: #e87ba4;
  --sub-ink: #ffffff;
  --shift-ink: #1f1600;
  --mix-ink: #ffffff;
  --ark-ink: #2a0715;
  --brand-a: #4a3aa7;
  --brand-b: #b8326f;

  /* Estados (siempre con icono + texto) */
  --ok: #13843f;
  --ok-soft: rgba(19, 132, 63, .1);
  --warn: #a86400;
  --warn-soft: rgba(214, 140, 0, .12);
  --bad: #c42f3c;
  --bad-soft: rgba(196, 47, 60, .09);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(14, 26, 43, .05), 0 6px 20px rgba(14, 26, 43, .05);
  --shadow-lg: 0 2px 6px rgba(14, 26, 43, .05), 0 24px 60px rgba(14, 26, 43, .10);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --max: 1200px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1118;
  --bg-alt: #0f151e;
  --paper-line: rgba(160, 190, 230, .05);
  --surface: #131b26;
  --surface-2: #19222f;
  --surface-3: #212c3b;
  --ink: #e8eef6;
  --ink-2: #c6d0dc;
  --muted: #95a3b5;
  --faint: #6f7d8f;
  --line: #273345;
  --line-2: #1e2836;
  --accent: #7aa2ff;
  --accent-ink: #0c1118;
  --accent-soft: rgba(122, 162, 255, .12);
  --sub: #9085e9;
  --shift: #c98500;
  --mix: #008300;
  --ark: #d55181;
  --sub-ink: #0c1118;
  --shift-ink: #140e00;
  --mix-ink: #ffffff;
  --ark-ink: #1a0710;
  --brand-a: #a79cf2;
  --brand-b: #ef7fa8;
  --ok: #3ccf76;
  --ok-soft: rgba(60, 207, 118, .12);
  --warn: #f3b33d;
  --warn-soft: rgba(243, 179, 61, .12);
  --bad: #ff7482;
  --bad-soft: rgba(255, 116, 130, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 60px rgba(0, 0, 0, .4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
b, strong { font-weight: 650; }
code, .mono, kbd, samp { font-family: var(--mono); font-feature-settings: "zero" 1; }
code { font-size: .92em; }
p code, li code, h4 code, .fact code, .tiny code {
  padding: .08em .38em; border-radius: 6px; background: var(--surface-3); color: var(--ink);
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.15; }
h3 { font-size: 1.12rem; margin: 0 0 .45rem; letter-spacing: -.01em; }
h4 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .8rem; }
p:last-child { margin-bottom: 0; }
sup { font-size: .62em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
svg { display: block; }

.wrap { width: min(var(--max), calc(100% - 48px)); margin-inline: auto; }
.tiny { font-size: .82rem; color: var(--muted); }
.label {
  display: block;
  font: 650 .7rem/1.3 var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.label.center { text-align: center; }
.mt { margin-top: 26px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; text-decoration: none;
}
.skip:focus { top: 12px; }

.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 60;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--ark), var(--sub), var(--shift), var(--mix));
}

/* ---------- Botones y controles ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(14, 26, 43, .04);
  transition: transform .15s var(--ease), border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--faint); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { box-shadow: 0 8px 22px rgba(14, 26, 43, .18); }
.btn.small { padding: 7px 12px; font-size: .86rem; border-radius: 10px; }
.btn.ghost { background: transparent; box-shadow: none; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: background .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { border-color: var(--faint); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chip-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: .8rem;
  font-weight: 550;
  transition: border-color .15s, background .15s, color .15s;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.mini-seg, .seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
}
.mini-seg button, .seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: .8rem;
  font-weight: 600;
  transition: background .15s, color .15s, box-shadow .15s;
}
.mini-seg button.on, .seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(14, 26, 43, .12);
}
.seg button { padding: 8px 18px; font-size: .92rem; }

.field { display: grid; gap: 6px; }
.field > span { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.field small { font-weight: 450; color: var(--muted); }
input[type="text"], input:not([type]), select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.hex-in {
  width: 54px !important; text-align: center; font-family: var(--mono); font-weight: 700; text-transform: uppercase;
  padding: 7px 6px !important;
}
kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px; font-size: .74rem;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface); color: var(--ink-2);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line-2);
}
.nav { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; letter-spacing: .06em; font-size: .92rem; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--ink); color: var(--bg); font-weight: 800; letter-spacing: 0; }
.brand-sub { color: var(--muted); font-weight: 550; letter-spacing: .04em; }
.navlinks { display: flex; gap: 2px; }
.navlinks a {
  text-decoration: none; color: var(--muted); font-size: .88rem; font-weight: 550;
  padding: 6px 10px; border-radius: 8px; transition: color .15s, background .15s;
}
.navlinks a:hover { color: var(--ink); background: var(--surface-3); }
.navlinks a.active { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.nav-actions { display: flex; gap: 8px; }
.menu-btn { display: none; }
.i-sun { display: none !important; }
:root[data-theme="dark"] .i-sun { display: block !important; }
:root[data-theme="dark"] .i-moon { display: none !important; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 72px 0 64px; overflow: hidden; }
.hero-paper {
  position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 60% 30%, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse 80% 70% at 60% 30%, #000 30%, transparent 80%);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 650 .76rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2); padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mix); box-shadow: 0 0 0 0 color-mix(in srgb, var(--mix) 60%, transparent); animation: live 2s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mix) 55%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
h1 {
  font-size: clamp(3.2rem, 7.4vw, 6.6rem);
  line-height: .92;
  letter-spacing: -.045em;
  margin: 26px 0 0;
  font-weight: 800;
}
h1 .slash { color: var(--faint); font-weight: 300; }
h1 .h1-soft {
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { margin-top: 22px; max-width: 580px; font-size: clamp(1.05rem, 1.8vw, 1.22rem); color: var(--ink-2); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }

.path { list-style: none; padding: 0; margin: 34px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 640px; }
.path a {
  display: flex; gap: 10px; align-items: flex-start; text-decoration: none; color: var(--ink);
  padding: 10px; border-radius: 12px; border: 1px solid transparent; transition: border-color .15s, background .15s;
}
.path a:hover { border-color: var(--line); background: var(--surface); }
.path-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 700 .75rem/1 var(--mono); background: var(--surface-3); color: var(--ink-2); }
.path b { display: block; font-size: .86rem; }
.path small { display: block; color: var(--muted); font-size: .76rem; line-height: 1.35; }

.hero-demo { padding: 18px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); }
.demo-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.op-pill {
  --c: var(--ark);
  display: inline-flex; align-items: center; gap: 7px;
  font: 700 .74rem/1 var(--mono); letter-spacing: .02em;
  padding: 6px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  transition: background .3s, border-color .3s;
}
.op-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.hero-stage { display: flex; align-items: center; gap: 18px; justify-content: center; padding: 6px 0; }
.hero-round { display: grid; gap: 4px; min-width: 150px; }
.hero-round .mono { font-weight: 700; font-size: 1.05rem; }
.strip { display: flex; gap: 2px; height: 8px; }
.strip i { flex: 1; border-radius: 2px; background: var(--surface-3); transition: background .25s, transform .25s; }
.strip i.done { background: color-mix(in srgb, var(--c) 55%, var(--surface)); }
.strip i.now { background: var(--c); transform: scaleY(1.5); }
.hero-io { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hero-io code { display: block; margin-top: 4px; font-size: .78rem; color: var(--ink-2); word-break: break-all; line-height: 1.5; }
.hero-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line-2); padding-top: 12px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 56px; }
.metric { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.metric b { display: block; font-size: 1.2rem; letter-spacing: -.01em; }
.metric span { font-size: .84rem; color: var(--muted); }

/* ---------- Secciones ---------- */
.section { padding: 92px 0; position: relative; }
.section.alt { background: var(--bg-alt); border-block: 1px solid var(--line-2); }
.section-head { display: grid; grid-template-columns: .9fr 1.1fr; gap: 56px; align-items: end; margin-bottom: 36px; }
.kicker { display: flex; align-items: center; gap: 10px; font: 650 .76rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kicker span { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--ink); color: var(--bg); letter-spacing: 0; }
h2 { margin: 14px 0 0; font-size: clamp(2rem, 3.8vw, 3.2rem); letter-spacing: -.035em; font-weight: 780; }
.lede { color: var(--ink-2); font-size: 1.06rem; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 22px; }
.card p { color: var(--ink-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.concept { transition: transform .25s var(--ease), box-shadow .25s; }
.concept:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.concept-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); margin-bottom: 14px; }
.concept-ico svg { width: 22px; height: 22px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.concept .label { margin-bottom: 6px; }

.badge { flex: none; font: 700 .7rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 6px 9px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); }

/* ---------- State grid (matriz 4x4) ---------- */
.state-grid {
  --cell: 52px;
  --gap: 6px;
  --c: var(--ink);
  display: grid;
  grid-template-columns: repeat(4, var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
  position: relative;
}
.state-grid.big { --cell: 58px; }
.state-grid.sm { --cell: 34px; --gap: 4px; }
.state-grid.xs { --cell: 20px; --gap: 3px; }
.cell {
  position: relative;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font: 700 .98rem/1 var(--mono);
  color: var(--ink);
  padding: 0;
  transition: background .3s, border-color .3s, box-shadow .2s, opacity .2s;
  user-select: none;
}
button.cell { cursor: pointer; }
button.cell:hover { border-color: var(--c); }
.state-grid.tinted .cell { background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-color: color-mix(in srgb, var(--c) 28%, var(--line)); }
.state-grid.sm .cell { font-size: .78rem; border-radius: 7px; }
.state-grid.xs .cell { border-radius: 4px; font-size: 0; }
.cell.sel { box-shadow: 0 0 0 2px var(--c), 0 6px 16px color-mix(in srgb, var(--c) 25%, transparent); z-index: 2; background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.cell.rel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 13%, var(--surface)); }
.state-grid.dimmed .cell:not(.sel):not(.rel) { opacity: .45; }
.cell .idx { position: absolute; top: 3px; left: 5px; font: 600 .56rem/1 var(--mono); color: var(--faint); }
.cell.pad { color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--surface-3) 5px 10px); }

[data-op="sub"] { --c: var(--sub); --c-ink: var(--sub-ink); }
[data-op="shift"] { --c: var(--shift); --c-ink: var(--shift-ink); }
[data-op="mix"] { --c: var(--mix); --c-ink: var(--mix-ink); }
[data-op="ark"] { --c: var(--ark); --c-ink: var(--ark-ink); }
.op-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--ink)); flex: none; }

/* ---------- Demo simétrica ---------- */
.demo { margin-top: 18px; padding: 24px; }
.demo-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 22px; }
.demo-head h3 { margin-bottom: 4px; }
.demo-head p { margin: 0; color: var(--muted); max-width: 760px; }
.sym-flow { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 20px; align-items: start; }
.actor { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.actor .tiny { margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: .85rem; color: #fff; }
.av-a { background: var(--accent); }
.av-b { background: var(--mix); }
.av-e { background: var(--faint); }
.sym-channel { display: grid; gap: 10px; padding-top: 6px; }
.channel { position: relative; height: 26px; }
.channel::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-50%);
  background-image: linear-gradient(90deg, var(--faint) 50%, transparent 50%); background-size: 10px 2px;
  animation: dash 1s linear infinite;
}
.channel::after { content: ""; position: absolute; right: -2px; top: 50%; width: 9px; height: 9px; border-top: 2px solid var(--faint); border-right: 2px solid var(--faint); transform: translateY(-50%) rotate(45deg); }
@keyframes dash { to { background-position: 10px 0; } }
@keyframes dashv { to { background-position: 0 8px; } }
.packet {
  position: absolute; top: 50%; left: 0; width: 34px; height: 18px; margin-top: -9px; border-radius: 6px;
  background: var(--ark); box-shadow: 0 4px 12px color-mix(in srgb, var(--ark) 40%, transparent);
  opacity: 0;
}
.packet.go { animation: travel 1.1s var(--ease) forwards; }
@keyframes travel { 0% { left: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: calc(100% - 34px); opacity: 0; } }
.cipher-box {
  display: block; padding: 12px; border-radius: 10px; min-height: 96px;
  background: var(--surface-2); border: 1px dashed var(--line);
  font-size: .78rem; line-height: 1.6; color: var(--ink-2); word-break: break-all;
  max-height: 160px; overflow: auto;
}
.eve { border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; background: var(--surface); }
.eve .actor { margin-bottom: 6px; }
.eve-out { font-size: .8rem; color: var(--muted); word-break: break-all; line-height: 1.5; }
.plain-box { min-height: 96px; padding: 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--mix) 35%, var(--line)); background: color-mix(in srgb, var(--mix) 6%, var(--surface)); white-space: pre-wrap; word-break: break-word; }
.ok-line { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: .84rem; color: var(--ok); font-weight: 600; }
.ok-line svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.key-chip { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 600; padding: 7px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ark) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ark) 28%, var(--line)); }
.key-chip svg { width: 16px; height: 16px; fill: none; stroke: var(--ark); stroke-width: 2; stroke-linecap: round; }
.key-chip code { font-size: .78rem; color: var(--ink-2); }

/* ---------- Datos → State ---------- */
.data-lab { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0; overflow: hidden; }
.data-left, .data-right { padding: 24px; display: grid; gap: 14px; align-content: start; }
.data-right { border-left: 1px solid var(--line-2); background: var(--surface-2); justify-items: center; }
.data-right .step-label { justify-self: stretch; }
.step-label { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; }
.step-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 700 .74rem/1 var(--mono); flex: none; }
.byte-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 58px; }
.bchip {
  display: grid; justify-items: center; gap: 3px; min-width: 40px; padding: 6px 6px 5px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  font: 700 .86rem/1 var(--mono); cursor: default; transition: transform .15s, border-color .15s;
  animation: pop .35s var(--ease) both;
}
.bchip small { font: 500 .66rem/1 var(--font); color: var(--muted); min-height: 10px; }
.bchip.multi { border-color: color-mix(in srgb, var(--sub) 40%, var(--line)); }
.bchip.pad { color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--surface-3) 5px 10px); }
.bchip:hover, .bchip.hl { transform: translateY(-2px); border-color: var(--accent); }
.bchip.blockstart { margin-left: 10px; }
.bchip.still { animation: none; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.9); } to { opacity: 1; transform: none; } }
.byte-info { font-size: .84rem; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); min-height: 42px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--muted); }
.legend-row.col { flex-direction: column; gap: 8px; }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; flex: none; }
.sw-data { background: var(--surface); }
.sw-pad { background: repeating-linear-gradient(135deg, var(--surface-2) 0 3px, var(--surface-3) 3px 6px); }
.sw-diff { background: var(--ark); border-color: var(--ark); }
.sw-same { background: var(--surface-3); }
.sw-aes { background: var(--ink); border-color: var(--ink); }
.sw-rj { background: var(--surface-2); }
.block-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 28px; }
.block-tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.block-tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.facts { margin-top: 14px; }
.fact { padding: 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); display: grid; gap: 6px; }
.fact span { color: var(--ink-2); font-size: .92rem; }

/* ---------- Variantes ---------- */
.variants { padding: 24px; display: grid; gap: 24px; margin-bottom: 16px; }
.variant-body { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 36px; }
.v-block { display: grid; gap: 10px; align-content: start; }
.keybar, .roundbar { display: grid; gap: 4px; }
.keybar { grid-template-columns: repeat(8, 1fr); }
.roundbar { grid-template-columns: repeat(14, 1fr); }
.keybar i, .roundbar i {
  height: 34px; border-radius: 6px; background: var(--surface-3);
  transition: background .35s var(--ease), transform .35s var(--ease);
  display: grid; place-items: center; font: 600 .66rem/1 var(--mono); font-style: normal; color: transparent;
}
.keybar i.on { background: var(--ark); color: var(--ark-ink); }
.roundbar i.on { background: var(--ink); color: var(--bg); }
.roundbar i.on.final { background: color-mix(in srgb, var(--ink) 55%, var(--surface)); }
.v-cap { font-size: .88rem; color: var(--ink-2); }
.v-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 2px; }
.stat b { font-size: 1.6rem; letter-spacing: -.02em; }
.stat small { color: var(--muted); font-size: .78rem; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; }
.table-wrap table { width: 100%; min-width: 720px; }
.table-wrap th, .table-wrap td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--line-2); }
.table-wrap th { color: var(--muted); font: 650 .7rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; background: var(--surface-2); }
.table-wrap td { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap td:last-child { white-space: normal; min-width: 200px; }
.table-wrap tr:last-child td { border-bottom: 0; }

/* ---------- Mapa ---------- */
.map { padding: 28px 24px; display: grid; gap: 26px; overflow-x: auto; }
.map-flow, .map-keys { display: flex; align-items: center; gap: 0; }
.map-node {
  flex: none; display: grid; gap: 2px; text-align: center; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); text-decoration: none; color: var(--ink);
}
.map-node b { font-size: .86rem; }
.map-node small { color: var(--muted); font-size: .72rem; }
.map-node.io { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.map-node.io small { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.map-node.key { border-color: color-mix(in srgb, var(--ark) 40%, var(--line)); background: color-mix(in srgb, var(--ark) 8%, var(--surface)); }
a.map-node:hover { border-color: var(--accent); }
.map-arrow { flex: 1 1 14px; min-width: 14px; height: 2px; position: relative; background-image: linear-gradient(90deg, var(--faint) 50%, transparent 50%); background-size: 8px 2px; animation: dash .8s linear infinite; background-position: 0 0; }
.map-arrow::after { content: ""; position: absolute; right: 0; top: -4px; width: 8px; height: 8px; border-top: 2px solid var(--faint); border-right: 2px solid var(--faint); transform: rotate(45deg); }
.map-group { flex: none; position: relative; padding: 26px 8px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.map-group.loop { padding-bottom: 30px; border-style: dashed; border-color: var(--faint); }
.map-group.final { border-style: dashed; }
.map-glabel { position: absolute; top: 7px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 10px; font: 650 .68rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.times { color: var(--ink); }
.map-ops { display: flex; gap: 6px; }
.map-op {
  display: grid; gap: 1px; padding: 8px 9px; border-radius: 10px; text-align: center;
  font-size: .78rem; font-weight: 650; color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line));
  background: color-mix(in srgb, var(--c) 10%, var(--surface));
  transition: transform .15s var(--ease), box-shadow .15s;
}
.map-op small { font: 500 .68rem/1 var(--mono); color: var(--muted); }
button.map-op:hover { transform: translateY(-2px); box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 25%, transparent); }
.map-op.op-sub { --c: var(--sub); } .map-op.op-shift { --c: var(--shift); } .map-op.op-mix { --c: var(--mix); } .map-op.op-ark { --c: var(--ark); }
.map-op.ghost { --c: var(--faint); opacity: .55; text-decoration: line-through; background: transparent; border-style: dashed; }
.loop-arrow { position: absolute; left: 14px; right: 14px; bottom: 6px; height: 16px; width: calc(100% - 28px); overflow: visible; }
.loop-arrow path { fill: none; stroke: var(--faint); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.map-group.loop::after { content: ""; position: absolute; left: 14px; bottom: 19px; width: 6px; height: 6px; border-left: 1.5px solid var(--faint); border-top: 1.5px solid var(--faint); transform: translateX(-2.5px) rotate(45deg); }
.map-keys { padding-top: 22px; border-top: 1px dashed var(--line); }
.rk-strip { display: flex; gap: 4px; flex-wrap: nowrap; }
.rk-strip span { font: 600 .72rem/1 var(--mono); padding: 7px 7px; border-radius: 7px; background: color-mix(in srgb, var(--ark) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ark) 30%, var(--line)); color: var(--ink); animation: pop .3s var(--ease) both; }
.op-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.legend-card { display: flex; gap: 12px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c); }
.legend-card .op-dot { margin-top: 6px; }
.legend-card b { display: block; }
.legend-card .verb { font: 600 .72rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.legend-card p { margin: 6px 0 0; font-size: .88rem; color: var(--ink-2); }

/* ---------- Explorador ---------- */
.explorer { overflow: hidden; }
.ex-inputs { display: grid; grid-template-columns: 150px 1fr 1fr; gap: 14px 16px; padding: 20px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.ex-field { display: grid; gap: 6px; align-content: start; }
.ex-field label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.ex-field label small { font-weight: 450; color: var(--muted); }
.field-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.ex-field input { font-size: .88rem; }
.input-btn { display: flex; gap: 6px; }
.input-btn input { min-width: 0; }
.ex-presets { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ex-presets .label { margin-right: 6px; }
.ex-msg { grid-column: 1 / -1; font-size: .84rem; min-height: 0; }
.ex-msg:empty { display: none; }
.ex-msg.err { color: var(--bad); }
.ex-msg.info { color: var(--muted); }

.ex-timeline { position: relative; display: flex; gap: 6px; padding: 14px 20px; overflow-x: auto; border-bottom: 1px solid var(--line-2); scrollbar-width: thin; }
.tl-round { flex: none; display: grid; gap: 5px; }
.tl-round > span { font: 600 .64rem/1 var(--mono); color: var(--muted); letter-spacing: .04em; white-space: nowrap; }
.tl-round.cur > span { color: var(--ink); }
.tl-steps { display: flex; gap: 2px; }
.tl-step {
  width: 26px; height: 26px; border-radius: 6px; border: 0; padding: 0;
  font: 700 .58rem/1 var(--mono); letter-spacing: -.02em;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  color: var(--ink-2);
  transition: background .2s, transform .2s, box-shadow .2s;
}
.tl-step:hover { background: color-mix(in srgb, var(--c) 30%, var(--surface)); }
.tl-step.past { background: color-mix(in srgb, var(--c) 42%, var(--surface)); color: var(--ink); }
.tl-step.now { background: var(--c); color: var(--c-ink, #fff); transform: translateY(-2px); box-shadow: 0 4px 10px color-mix(in srgb, var(--c) 45%, transparent); }

.ex-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); }
.transport { display: flex; gap: 6px; }
.icon-btn.play { width: 44px; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.icon-btn.play svg { fill: currentColor; stroke: currentColor; }
.icon-btn.play .i-pause { display: none; fill: none; stroke-width: 3; }
.icon-btn.play.playing .i-play { display: none; }
.icon-btn.play.playing .i-pause { display: block; }
.ex-pos { font-size: .86rem; font-weight: 600; }
.speed { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); }
.speed select { width: auto; padding: 6px 30px 6px 10px; font-size: .84rem; }
.kbd-hint { margin-left: auto; }

.ex-stage { padding: 24px 20px; display: grid; gap: 22px; }
.ex-stage-head { display: grid; grid-template-columns: auto 1fr; gap: 12px 28px; align-items: center; }
.ex-title { display: flex; align-items: center; gap: 12px; }
.op-bar { width: 6px; height: 44px; border-radius: 3px; background: var(--c); transition: background .3s; }
.ex-round { font-size: .78rem; color: var(--muted); font-weight: 600; }
.ex-title h3 { font-size: 1.55rem; margin: 2px 0 0; letter-spacing: -.02em; }
.ex-stage-head p { margin: 0; color: var(--ink-2); max-width: 720px; }
.ex-mats { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 6px 0; }
.mat { margin: 0; display: grid; gap: 8px; justify-items: center; }
.mat figcaption { font: 650 .7rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mat-op {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font: 700 1.1rem/1 var(--mono); color: var(--c-ink, #fff); background: var(--c); margin-top: 18px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 35%, transparent);
}
.mat-op.mat-eq { background: var(--surface-3); color: var(--ink); box-shadow: none; }
.mat-key .state-grid { --c: var(--ark); }

.inspector { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); overflow: hidden; }
.insp-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line-2); background: var(--surface); }
.insp-body { padding: 18px; display: grid; grid-template-columns: 1fr auto; gap: 18px 28px; align-items: start; min-height: 170px; }
.insp-body.anim > * { animation: fadeUp .35s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.insp-big { display: flex; align-items: center; gap: 12px; font: 750 1.6rem/1 var(--mono); margin-bottom: 10px; flex-wrap: wrap; }
.insp-big .arrow { color: var(--faint); font-weight: 400; }
.insp-big .v { padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.insp-big .v.out { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.insp-text { color: var(--ink-2); font-size: .94rem; }
.insp-text p { margin-bottom: .5rem; }
.insp-link { font-size: .86rem; font-weight: 600; }
.calc-lines { font: 500 .86rem/1.75 var(--mono); white-space: pre; overflow-x: auto; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2); }
.calc-lines .hl { color: var(--ink); font-weight: 750; background: color-mix(in srgb, var(--c) 16%, transparent); border-radius: 4px; padding: 0 2px; }
.calc-lines .dim { color: var(--faint); }

.mini-sbox { display: grid; grid-template-columns: 14px repeat(16, 11px); grid-auto-rows: 11px; gap: 1px; font: 600 .5rem/11px var(--mono); color: var(--faint); text-align: center; }
.mini-sbox i { display: block; border-radius: 2px; background: var(--surface-3); }
.mini-sbox i.row, .mini-sbox i.col { background: color-mix(in srgb, var(--sub) 22%, var(--surface)); }
.mini-sbox i.hit { background: var(--sub); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sub) 35%, transparent); }
.mini-sbox b { font-weight: 600; }
.mini-sbox b.on { color: var(--ink); }

.mini-row { display: grid; gap: 6px; }
.mini-row .r { display: flex; gap: 4px; align-items: center; }
.mini-row .r span.l { font: 600 .66rem/1 var(--mono); color: var(--muted); width: 56px; }
.mini-row .r i { width: 32px; height: 28px; border-radius: 6px; display: grid; place-items: center; font: 700 .72rem/1 var(--mono); font-style: normal; background: var(--surface); border: 1px solid var(--line); }
.mini-row .r i.hit { background: color-mix(in srgb, var(--shift) 20%, var(--surface)); border-color: var(--shift); }

.mix-mat { display: grid; grid-template-columns: repeat(4, 28px); gap: 3px; font: 700 .72rem/28px var(--mono); text-align: center; }
.mix-mat i { font-style: normal; border-radius: 5px; background: var(--surface); border: 1px solid var(--line-2); color: var(--muted); }
.mix-mat i.hit { background: color-mix(in srgb, var(--mix) 20%, var(--surface)); border-color: var(--mix); color: var(--ink); }

.bits { display: grid; gap: 4px; }
.bits .r { display: flex; align-items: center; gap: 3px; }
.bits .r .l { width: 64px; font: 600 .7rem/1 var(--mono); color: var(--muted); }
.bits .r .h { width: 36px; text-align: right; font: 700 .8rem/1 var(--mono); margin-left: 8px; }
.bits .b { width: 22px; height: 26px; border-radius: 5px; display: grid; place-items: center; font: 700 .76rem/1 var(--mono); background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.bits .b.one { color: var(--ink); background: var(--surface-3); }
.bits .r.key .b.one { background: color-mix(in srgb, var(--ark) 16%, var(--surface)); border-color: color-mix(in srgb, var(--ark) 40%, var(--line)); }
.bits .r.res { border-top: 2px solid var(--ink); padding-top: 4px; margin-top: 2px; }
.bits .r.res .b.flip { box-shadow: inset 0 -3px 0 var(--ark); }

.ex-result { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2); }
.ex-ct code { display: block; font-size: 1rem; font-weight: 700; margin-top: 4px; word-break: break-all; }
.ex-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; padding: 6px 10px; border-radius: 999px; }
.check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.check.ok { background: var(--ok-soft); color: var(--ok); }
.check.bad { background: var(--bad-soft); color: var(--bad); }
.check.neutral { background: var(--surface-3); color: var(--ink-2); }

/* ---------- Laboratorio ---------- */
.lab { overflow: hidden; }
.tabs { display: flex; gap: 2px; overflow-y: hidden; padding: 8px 8px 0; border-bottom: 1px solid var(--line); background: var(--surface-2); overflow-x: auto; }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  border: 1px solid transparent; border-bottom: 0; background: transparent;
  padding: 11px 16px; border-radius: 10px 10px 0 0; font-weight: 600; font-size: .9rem; color: var(--muted);
  position: relative; top: 1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--surface); border-color: var(--line); color: var(--ink); }
.tabs button.on::after { content: ""; position: absolute; left: 12px; right: 12px; top: -1px; height: 3px; border-radius: 0 0 3px 3px; background: var(--c); }
.tabs button .op-dot { width: 9px; height: 9px; }
.tabs button[data-tab="sub"] { --c: var(--sub); } .tabs button[data-tab="shift"] { --c: var(--shift); } .tabs button[data-tab="mix"] { --c: var(--mix); } .tabs button[data-tab="ark"] { --c: var(--ark); }
.tab-panel { padding: 24px; animation: fadeUp .35s var(--ease); }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 28px; }
.lab-main { min-width: 0; display: grid; gap: 14px; align-content: start; }
.lab-side { display: grid; gap: 12px; align-content: start; padding: 18px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); }
.lab-side p { color: var(--ink-2); font-size: .94rem; margin: 0; }
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.sbox-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.sbox { width: 100%; min-width: 560px; font: 600 .74rem/1 var(--mono); text-align: center; }
.sbox th, .sbox td { padding: 0; height: 27px; width: 5.9%; }
.sbox th { color: var(--muted); font-weight: 700; background: var(--surface-2); font-size: .7rem; }
.sbox td { color: var(--ink-2); cursor: pointer; transition: background .12s; border-radius: 3px; }
.sbox td.row, .sbox td.col { background: color-mix(in srgb, var(--sub) 8%, transparent); }
.sbox td:hover { background: color-mix(in srgb, var(--sub) 22%, transparent); color: var(--ink); }
.sbox td.on { background: var(--sub); color: var(--sub-ink); }
.sbox th.on { color: var(--ink); background: color-mix(in srgb, var(--sub) 18%, var(--surface-2)); }

.calc { list-style: none; counter-reset: c; padding: 0; margin: 0; display: grid; gap: 10px; }
.calc li { counter-increment: c; position: relative; padding-left: 32px; font-size: .9rem; color: var(--ink-2); }
.calc li::before { content: counter(c); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--sub); color: var(--sub-ink); font: 700 .72rem/1 var(--mono); }
.calc .calc-lines { margin-top: 6px; font-size: .78rem; line-height: 1.6; }
.nonlin { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.nonlin-row { display: flex; gap: 16px; align-items: center; font: 600 .9rem/1 var(--mono); }
.nonlin-row label { display: flex; align-items: center; gap: 6px; }
.nonlin-out { font-size: .8rem; line-height: 1.7; white-space: pre; overflow-x: auto; }
.nonlin-out .ne { color: var(--bad); font-weight: 700; }

.shift-demo { display: grid; gap: 8px; padding: 18px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); justify-content: center; }
.sh-row { display: flex; align-items: center; gap: 10px; }
.sh-lbl { width: 86px; font: 600 .72rem/1.2 var(--mono); color: var(--muted); }
.sh-lbl b { display: inline-block; margin-top: 3px; padding: 1px 6px; border-radius: 5px; background: color-mix(in srgb, var(--shift) 28%, var(--surface)); color: var(--ink); font-weight: 750; }
.sh-cells { display: grid; grid-template-columns: repeat(4, 52px); gap: 6px; position: relative; }
.sh-cell { height: 52px; border-radius: 10px; display: grid; place-items: center; font: 750 1rem/1 var(--mono); border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.sh-cell small { font-size: .6rem; font-weight: 600; color: var(--muted); margin-left: 1px; }
.sh-cell.c0 { background: color-mix(in srgb, #3b6fe0 14%, var(--surface)); border-color: color-mix(in srgb, #3b6fe0 35%, var(--line)); }
.sh-cell.c1 { background: color-mix(in srgb, #2f9e44 14%, var(--surface)); border-color: color-mix(in srgb, #2f9e44 35%, var(--line)); }
.sh-cell.c2 { background: color-mix(in srgb, #9a5cf6 14%, var(--surface)); border-color: color-mix(in srgb, #9a5cf6 35%, var(--line)); }
.sh-cell.c3 { background: color-mix(in srgb, #7a8699 18%, var(--surface)); border-color: color-mix(in srgb, #7a8699 40%, var(--line)); }
.col-check { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.col-check div { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font: 600 .74rem/1.4 var(--mono); }
.col-check div.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.col-check div span { display: block; font-family: var(--font); font-size: .7rem; color: var(--muted); }
.col-check div.ok span { color: var(--ok); font-weight: 650; }

.mix-lab { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 18px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); justify-content: center; }
.mix-col { display: grid; gap: 5px; }
.mix-col input { width: 56px !important; }
.mix-col .out { width: 56px; height: 38px; display: grid; place-items: center; border-radius: 10px; font: 750 .92rem/1 var(--mono); border: 1px solid color-mix(in srgb, var(--mix) 45%, var(--line)); background: color-mix(in srgb, var(--mix) 10%, var(--surface)); cursor: pointer; }
.mix-col .out.changed { animation: flash .6s var(--ease); }
.mix-col .out.sel { box-shadow: 0 0 0 2px var(--mix); }
@keyframes flash { 0% { background: var(--mix); color: #fff; } 100% { } }
.mix-sym { font: 700 1.1rem/1 var(--mono); color: var(--muted); }
.mix-matrix { display: grid; grid-template-columns: repeat(4, 34px); gap: 4px; padding: 6px 10px; border-left: 2px solid var(--ink-2); border-right: 2px solid var(--ink-2); border-radius: 6px; }
.mix-matrix i { font-style: normal; height: 34px; display: grid; place-items: center; font: 700 .8rem/1 var(--mono); border-radius: 6px; color: var(--ink-2); transition: background .2s; }
.mix-matrix i.hit { background: color-mix(in srgb, var(--mix) 18%, var(--surface)); color: var(--ink); }
.mix-detail { font-size: .82rem; line-height: 1.75; white-space: pre; overflow-x: auto; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); }
.gf-inputs { display: flex; align-items: center; gap: 8px; font: 700 1.1rem/1 var(--mono); }
.gf-r { padding: 8px 12px; border-radius: 10px; background: var(--mix); color: var(--mix-ink); min-width: 54px; text-align: center; }
.gf-poly { font-size: .78rem; line-height: 1.6; color: var(--ink-2); }
.gf-table { width: 100%; font: 500 .76rem/1.2 var(--mono); }
.gf-table th { text-align: left; font: 650 .62rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.gf-table td { padding: 5px 6px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.gf-table tr.use td { color: var(--ink); background: color-mix(in srgb, var(--mix) 9%, transparent); }
.gf-table tr.use td:first-child { box-shadow: inset 3px 0 0 var(--mix); }
.gf-table .red { color: var(--warn); font-weight: 700; }
.gf-table tfoot td { font-weight: 750; color: var(--ink); border-bottom: 0; }

.xor-lab { display: grid; gap: 8px; padding: 18px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); overflow-x: auto; }
.xrow { display: flex; align-items: center; gap: 4px; }
.xrow .l { width: 88px; font: 600 .74rem/1.2 var(--mono); color: var(--muted); flex: none; }
.xrow .h { width: 44px; font: 750 .96rem/1 var(--mono); text-align: right; margin-left: 10px; flex: none; }
.xbit { display: grid; place-items: center; width: 36px; height: 40px; flex: none; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font: 750 1rem/1 var(--mono); color: var(--faint); transition: background .2s, color .2s, transform .15s; }
button.xbit:hover { transform: translateY(-2px); border-color: var(--ink-2); }
.xbit.one { color: var(--ink); background: var(--surface-3); border-color: var(--faint); }
.xrow.key .xbit.one { background: color-mix(in srgb, var(--ark) 18%, var(--surface)); border-color: var(--ark); }
.xrow.res { border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 2px; }
.xrow.res .xbit.flip { box-shadow: inset 0 -3px 0 var(--ark); }
.xrow.res .xbit.pulse { animation: flash-ark .5s var(--ease); }
@keyframes flash-ark { 0% { background: var(--ark); color: var(--ark-ink); } }
.xor-back { font-size: .9rem; color: var(--ink-2); min-height: 24px; }
.xor-back .check { margin-left: 6px; }
.truth { font: 600 .84rem/1 var(--mono); width: 100%; max-width: 240px; }
.truth th, .truth td { padding: 7px 10px; text-align: center; border-bottom: 1px solid var(--line); }
.truth th { color: var(--muted); font-size: .72rem; }
.ticks { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--ink-2); font-size: .92rem; }

/* ---------- Key schedule ---------- */
.ks { overflow: hidden; }
.ks-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); font-size: .88rem; font-weight: 600; }
.ks-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.ks-grid { padding: 18px 20px; display: grid; gap: 5px; align-content: start; max-height: 620px; overflow: auto; }
.ks-row { display: grid; grid-template-columns: 46px repeat(4, 1fr); gap: 5px; align-items: center; }
.ks-row > span { font: 700 .74rem/1 var(--mono); color: var(--muted); }
.ks-row > span sub { font-size: .6rem; }
.word {
  display: flex; justify-content: space-between; gap: 2px; padding: 7px 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  font: 600 .74rem/1 var(--mono); color: var(--ink-2); cursor: pointer;
  transition: background .2s, border-color .2s, box-shadow .2s, opacity .3s, transform .3s;
  min-width: 0; white-space: nowrap; overflow: hidden;
}
.word .wi { color: var(--faint); font-size: .62rem; margin-right: 4px; }
.word:hover { border-color: var(--ark); }
.word.orig { background: color-mix(in srgb, var(--ark) 10%, var(--surface)); border-color: color-mix(in srgb, var(--ark) 30%, var(--line)); }
.word.core { border-left: 3px solid var(--sub); }
.word.on { box-shadow: 0 0 0 2px var(--ark); background: color-mix(in srgb, var(--ark) 14%, var(--surface)); color: var(--ink); }
.word.src1 { box-shadow: 0 0 0 2px var(--accent); }
.word.src2 { box-shadow: 0 0 0 2px var(--mix); }
.word.pending { opacity: .15; transform: scale(.96); }
.ks-detail { padding: 20px; border-left: 1px solid var(--line-2); background: var(--surface-2); display: grid; gap: 12px; align-content: start; }
.ks-detail h4 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ks-steps { display: grid; gap: 6px; }
.ks-step { display: grid; grid-template-columns: 124px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); animation: fadeUp .35s var(--ease) both; }
.ks-step .n { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.ks-step .n small { display: block; font-weight: 450; color: var(--muted); font-size: .72rem; }
.ks-step .v { display: flex; gap: 4px; font: 700 .82rem/1 var(--mono); flex-wrap: wrap; }
.ks-step .v i { font-style: normal; padding: 5px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line-2); }
.ks-step.s-src1 { box-shadow: inset 3px 0 0 var(--accent); }
.ks-step.s-src2 { box-shadow: inset 3px 0 0 var(--mix); }
.ks-step.s-core { box-shadow: inset 3px 0 0 var(--sub); }
.ks-step.s-out { border-color: var(--ark); box-shadow: inset 3px 0 0 var(--ark); }
.ks-step.s-out .v i { background: color-mix(in srgb, var(--ark) 12%, var(--surface)); border-color: color-mix(in srgb, var(--ark) 35%, var(--line)); }
.rcon-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.rcon { display: flex; gap: 4px; flex-wrap: wrap; }
.rcon span { display: grid; gap: 2px; text-align: center; font: 700 .76rem/1 var(--mono); padding: 5px 7px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line-2); }
.rcon span small { font: 500 .58rem/1 var(--mono); color: var(--muted); }
.rcon span.on { border-color: var(--sub); background: color-mix(in srgb, var(--sub) 12%, var(--surface)); }

/* ---------- Avalancha ---------- */
.aval { padding: 22px; }
.aval-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.bitgrid-wrap { overflow-x: auto; padding-bottom: 4px; }
.bitgrid { display: grid; grid-template-columns: repeat(16, minmax(30px, 1fr)); gap: 4px; min-width: 560px; }
.bcol { display: grid; gap: 2px; }
.bcol .bh { font: 700 .72rem/1 var(--mono); text-align: center; padding: 4px 0 5px; color: var(--ink-2); border-radius: 5px; transition: background .2s; }
.bcol.changed .bh { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.bbit { height: 16px; border: 0; padding: 0; border-radius: 3px; background: var(--surface-3); transition: background .15s, transform .15s; }
.bbit.one { background: color-mix(in srgb, var(--ink) 55%, var(--surface)); }
.bbit.flipped { background: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.bbit:hover { transform: scaleY(1.25); }
.aval-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; margin-top: 18px; }
.chart-card { padding: 16px 16px 12px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); min-width: 0; }
.chart-title { font-weight: 650; font-size: .94rem; }
.chart-sub { margin-top: 2px; }
.chart { position: relative; margin-top: 8px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis line, .chart .axis path { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart text { fill: var(--muted); font: 500 11px var(--mono); font-variant-numeric: tabular-nums; }
.chart .ref { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .ref-t { fill: var(--muted); font-size: 10px; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .dot.hot { r: 6; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .xhair { stroke: var(--faint); stroke-width: 1; visibility: hidden; }
.chart .xhair.on { visibility: visible; }
.chart .val { fill: var(--ink); font-weight: 700; font-size: 12px; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.chart .bar-l { fill: var(--ink); font: 650 12px var(--font); }
.chart .bar-v { fill: var(--ink-2); font: 600 11.5px var(--font); }
.chart .cat { fill: var(--ink); font: 650 12px var(--font); }
.chart .cat-s { fill: var(--muted); font: 500 10.5px var(--mono); }
.chart path.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.table-view { margin-top: 8px; font-size: .84rem; }
.table-view summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 4px 0; }
.table-scroll { overflow-x: auto; }
.table-view table { width: 100%; font: 500 .78rem/1.3 var(--mono); margin-top: 6px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 5px 8px; border-bottom: 1px solid var(--line-2); text-align: right; white-space: nowrap; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { color: var(--muted); font-weight: 650; }
.aval-side { display: grid; gap: 12px; align-content: start; min-width: 0; }
.stat-tile { padding: 16px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); display: grid; gap: 4px; }
.stat-tile b { font-size: 2.6rem; line-height: 1; letter-spacing: -.03em; }
.stat-tile b small { font-size: 1rem; color: var(--muted); font-weight: 550; letter-spacing: 0; }
.ct-compare { padding: 16px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); display: grid; gap: 10px; min-width: 0; }
.ct-compare code { display: block; margin-top: 3px; font-size: .78rem; word-break: break-all; line-height: 1.6; color: var(--ink-2); }
.ct-compare code .d { color: var(--ink); background: color-mix(in srgb, var(--ark) 18%, transparent); border-radius: 3px; font-weight: 750; }
.diffstrip { display: grid; grid-template-columns: repeat(32, 1fr); gap: 2px; }
.diffstrip i { aspect-ratio: 1; border-radius: 2px; background: var(--surface-3); transition: background .3s; }
.diffstrip i.on { background: var(--ark); }
.aval-rounds { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 4px; }
.av-r { flex: none; display: grid; gap: 6px; justify-items: center; padding: 10px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); animation: fadeUp .4s var(--ease) both; }
.av-r > span { font: 650 .66rem/1 var(--mono); color: var(--muted); }
.av-r > b { font: 700 .76rem/1 var(--mono); }
.av-r .cell { background: var(--surface-3); border: 0; }

/* ---------- Modos ---------- */
.modes { padding: 22px; }
.modes-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.modes-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.img-fig { margin: 0; display: grid; gap: 8px; }
.img-fig canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 12px; border: 1px solid var(--line); image-rendering: pixelated; background: var(--surface-2); }
.img-fig figcaption { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: .86rem; }
.img-fig figcaption > span:not(.st) { color: var(--muted); font-size: .8rem; }
.st { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 650; padding: 3px 8px; border-radius: 999px; }
.st svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.st-ok { background: var(--ok-soft); color: var(--ok); }
.st-bad { background: var(--bad-soft); color: var(--bad); }
.st-warn { background: var(--warn-soft); color: var(--warn); }
.modes-note { margin: 18px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: .94rem; }
.mode-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 16px; }
.mode-card { display: grid; gap: 12px; align-content: start; }
.mode-head { display: flex; justify-content: space-between; align-items: center; }
.mode-head b { font: 750 1.05rem/1 var(--mono); }
.mode-svg { width: 100%; height: auto; }
.mode-svg rect { stroke-width: 1; }
.mode-svg text { font: 600 9.5px var(--mono); text-anchor: middle; fill: var(--ink); }
.mode-svg .d-lbl { fill: var(--muted); font-size: 9px; text-anchor: start; }
.mode-svg .d-mid { text-anchor: middle; }
.mode-svg .d-blk rect { fill: var(--surface-2); stroke: var(--line); }
.mode-svg .d-aes rect { fill: color-mix(in srgb, var(--sub) 12%, var(--surface)); stroke: color-mix(in srgb, var(--sub) 45%, var(--line)); }
.mode-svg .d-out rect { fill: var(--ink); stroke: var(--ink); }
.mode-svg .d-out text { fill: var(--bg); }
.mode-svg .d-iv rect { fill: color-mix(in srgb, var(--shift) 12%, var(--surface)); stroke: color-mix(in srgb, var(--shift) 45%, var(--line)); }
.mode-svg .d-key rect { fill: color-mix(in srgb, var(--ark) 12%, var(--surface)); stroke: color-mix(in srgb, var(--ark) 45%, var(--line)); }
.mode-svg .d-xor { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.2; }
.mode-svg .d-line { fill: none; stroke: var(--faint); stroke-width: 1.2; }
.mode-svg .d-plus { fill: none; stroke: var(--ink-2); stroke-width: 1.2; }
.mode-card p { font-size: .9rem; }

/* ---------- Seguridad ---------- */
.callout { display: flex; gap: 16px; padding: 22px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); }
.callout > svg { width: 28px; height: 28px; flex: none; fill: none; stroke: var(--warn); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.callout h3 { margin-bottom: 6px; }
.callout p { color: var(--ink-2); margin: 0; }
.brute { padding: 22px; margin-top: 16px; }
.brute-top { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 32px; align-items: start; margin-bottom: 8px; }
.rate { display: grid; gap: 10px; }
.rate label { font-size: .9rem; color: var(--ink-2); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.nonce { padding: 22px; margin-top: 16px; }
.nonce-top { display: flex; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.nonce-top > div:first-child { max-width: 640px; }
.nonce-grid { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 12px; }
.nonce-op { font: 700 1.4rem/1 var(--mono); color: var(--muted); padding-bottom: 28px; }
.sec-cards { margin-top: 16px; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 22px; margin-top: 16px; }
.checklist h4 { display: flex; align-items: center; gap: 8px; }
.checklist h4 svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.ok-h { color: var(--ok); }
.bad-h { color: var(--bad); }
.checklist ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); font-size: .94rem; }

/* ---------- Historia ---------- */
.timeline { position: relative; display: grid; gap: 0; padding-left: 0; }
.tl-line { position: absolute; left: 111px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-line span { display: block; width: 100%; height: 0; background: linear-gradient(var(--sub), var(--ark)); border-radius: 2px; transition: height .1s linear; }
.tl-item { display: grid; grid-template-columns: 90px 1fr; gap: 42px; padding: 0 0 26px; position: relative; }
.tl-year { font: 750 1rem/1.5 var(--mono); color: var(--ink); text-align: right; }
.tl-copy { position: relative; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); max-width: 680px; transition: border-color .2s, transform .2s; }
.tl-copy:hover { transform: translateX(3px); border-color: var(--faint); }
.tl-copy::before { content: ""; position: absolute; left: -27px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--faint); }
.tl-item.major .tl-copy::before { background: var(--sub); border-color: var(--sub); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sub) 18%, transparent); }
.tl-item.evol .tl-copy { border-color: color-mix(in srgb, var(--ark) 40%, var(--line)); background: color-mix(in srgb, var(--ark) 5%, var(--surface)); }
.tl-item.evol .tl-copy::before { border-color: var(--ark); }
.tl-copy b { display: block; }
.tl-copy span { color: var(--ink-2); font-size: .94rem; }

/* ---------- Rijndael ---------- */
.rj { padding: 24px; display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: center; }
.rj-grid-wrap { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 10px; align-items: center; }
.rj-axis-y { writing-mode: vertical-rl; transform: rotate(180deg); font: 650 .7rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: center; }
.rj-axis-x { grid-column: 2; text-align: center; font: 650 .7rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.rj-grid { display: grid; grid-template-columns: 44px repeat(5, 58px); grid-auto-rows: 48px; gap: 5px; }
.rj-grid .hd { display: grid; place-items: center; font: 650 .74rem/1 var(--mono); color: var(--muted); }
.rj-cell { display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font: 700 .9rem/1 var(--mono); color: var(--muted); cursor: default; transition: transform .15s, box-shadow .15s; }
.rj-cell.aes { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.rj-cell:hover, .rj-cell.on { transform: scale(1.06); box-shadow: 0 0 0 2px var(--accent); }
.rj-cell.axis-hl { border-color: var(--accent); }
.rj-side { display: grid; gap: 16px; align-content: center; }
.rj-info { padding: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); min-height: 110px; }
.rj-info b { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.rj-info p { font-size: .92rem; color: var(--ink-2); margin: 0; }

/* ---------- Quiz ---------- */
.quiz { padding: 0; overflow: hidden; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); flex-wrap: wrap; }
.q-progress { display: flex; gap: 4px; }
.q-progress i { width: 26px; height: 6px; border-radius: 3px; background: var(--surface-3); transition: background .3s; }
.q-progress i.cur { background: var(--ink); }
.q-progress i.ok { background: var(--ok); }
.q-progress i.bad { background: var(--bad); }
.q-body { padding: 26px 22px; display: grid; gap: 16px; animation: fadeUp .35s var(--ease); }
.q-body h3 { font-size: 1.3rem; letter-spacing: -.01em; }
.q-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.q-opt { text-align: left; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 550; transition: border-color .15s, background .15s, transform .15s; }
.q-opt:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.q-opt .k { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font: 700 .76rem/1 var(--mono); background: var(--surface-3); color: var(--ink-2); }
.q-opt:disabled { cursor: default; }
.q-opt.right { border-color: var(--ok); background: var(--ok-soft); }
.q-opt.right .k { background: var(--ok); color: #fff; }
.q-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-opt.wrong .k { background: var(--bad); color: #fff; }
.q-fb { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); font-size: .94rem; animation: fadeUp .3s var(--ease); }
.q-fb b.okc { color: var(--ok); }
.q-fb b.badc { color: var(--bad); }
.q-nav { display: flex; justify-content: flex-end; gap: 8px; }
.q-score { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 34px 22px; animation: fadeUp .35s var(--ease); }
.q-ring { width: 120px; height: 120px; }
.q-ring circle { fill: none; stroke-width: 10; }
.q-ring .bg { stroke: var(--surface-3); }
.q-ring .fg { stroke: var(--ok); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s var(--ease); }
.q-ring text { font: 800 26px var(--font); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }

/* ---------- Proyecto / footer ---------- */
.ref-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ref-links a { text-decoration: none; color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; font-size: .88rem; font-weight: 550; }
.ref-links a:hover { border-color: var(--accent); color: var(--accent); }
.selftest { display: inline-flex; margin-top: 8px; }
footer { border-top: 1px solid var(--line-2); padding: 40px 0 52px; color: var(--muted); }
.foot { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.signature { color: var(--ink-2); line-height: 1.8; }
.signature strong { color: var(--ink); }
.signature.right { text-align: right; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  padding: 8px 10px; border-radius: 9px; max-width: 260px;
  background: var(--ink); color: var(--bg);
  font-size: .8rem; line-height: 1.45; box-shadow: var(--shadow-lg);
}
.tooltip b { display: block; }

/* ---------- Revelado al hacer scroll ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

/* Movimiento reducido: por defecto sigue la preferencia del sistema; el botón de la barra la cambia */
:root.reduce-motion { scroll-behavior: auto; }
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
}
:root.reduce-motion .reveal { opacity: 1; transform: none; }
.i-still { display: none !important; }
:root.reduce-motion .i-still { display: block !important; }
:root.reduce-motion .i-motion { display: none !important; }
:root.reduce-motion #motionToggle { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .navlinks a { padding: 6px 7px; font-size: .84rem; }
  .op-legend { grid-template-columns: 1fr 1fr; }
  .mode-cards { grid-template-columns: 1fr 1fr; }
}

/* El mapa pasa a ser vertical cuando no cabe en una fila */
@media (max-width: 1180px) {
  .map-flow, .map-keys { flex-direction: column; align-items: center; min-width: 0; }
  .map-arrow { flex: none; width: 2px; min-width: 2px; height: 24px; background-image: linear-gradient(var(--faint) 50%, transparent 50%); background-size: 2px 8px; animation-name: dashv; }
  .map-arrow::after { right: -3px; top: auto; bottom: 0; transform: rotate(135deg); }
  .map-group { width: 100%; max-width: 520px; }
  .map-ops { flex-wrap: wrap; justify-content: center; }
  .map-node { min-width: 200px; }
  .rk-strip { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 980px) {
  .menu-btn { display: inline-grid; }
  .navlinks {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 10px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .navlinks.open { display: flex; }
  .navlinks a { padding: 10px 12px; font-size: .95rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-demo { max-width: 560px; }
  .section-head { grid-template-columns: 1fr; gap: 14px; }
  .sym-flow { grid-template-columns: 1fr; }
  .data-lab { grid-template-columns: 1fr; }
  .data-right { border-left: 0; border-top: 1px solid var(--line-2); }
  .variant-body { grid-template-columns: 1fr; }
  .ex-inputs { grid-template-columns: 1fr 1fr; }
  .ex-inputs .ex-field:first-child { grid-column: 1 / -1; max-width: 220px; }
  .lab-grid { grid-template-columns: 1fr; }
  .ks-body { grid-template-columns: 1fr; }
  .ks-detail { border-left: 0; border-top: 1px solid var(--line-2); }
  .aval-body { grid-template-columns: 1fr; }
  .modes-grid { grid-template-columns: 1fr 1fr; }
  .brute-top { grid-template-columns: 1fr; }
  .nonce-grid { grid-template-columns: 1fr 1fr 1fr; }
  .nonce-op { display: none; }
  .rj { grid-template-columns: 1fr; justify-items: center; }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .kbd-hint { display: none; }
}

@media (max-width: 680px) {
  .wrap { width: calc(100% - 32px); }
  .section { padding: 68px 0; }
  .hero { padding: 44px 0 48px; }
  .path { grid-template-columns: 1fr 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; margin-top: 36px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .hero-stage { flex-direction: column; gap: 10px; }
  .hero-round { text-align: center; min-width: 0; }
  .hero-io { grid-template-columns: 1fr; }
  .state-grid { --cell: 46px; --gap: 5px; }
  .state-grid.big { --cell: 56px; }
  .ex-inputs { grid-template-columns: 1fr; padding: 16px; }
  .ex-inputs .ex-field:first-child { max-width: none; }
  .ex-stage { padding: 20px 14px; }
  .ex-stage-head { grid-template-columns: 1fr; }
  .ex-mats { flex-direction: column; gap: 10px; }
  .ex-mats .mat-op { margin-top: 0; }
  .ex-mats .state-grid { --cell: 38px; --gap: 4px; }
  .ex-mats .cell { font-size: .8rem; border-radius: 8px; }
  .mat-op { width: 34px; height: 34px; font-size: .9rem; margin-top: 16px; }
  .insp-body { grid-template-columns: 1fr; }
  .ex-transport { padding: 12px 14px; }
  .ex-timeline { padding: 12px 14px; }
  .op-legend { grid-template-columns: 1fr; }
  .mode-cards { grid-template-columns: 1fr; }
  .v-stats { grid-template-columns: 1fr; }
  .modes-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .nonce-grid { grid-template-columns: 1fr 1fr; }
  .nonce-grid figure:last-child { grid-column: 1 / -1; }
  .checklist { grid-template-columns: 1fr; }
  .q-opts { grid-template-columns: 1fr; }
  .tl-line { left: 67px; }
  .tl-item { grid-template-columns: 54px 1fr; gap: 30px; }
  .tl-year { font-size: .88rem; }
  .tl-copy::before { left: -21px; }
  .rj-grid { grid-template-columns: 36px repeat(5, minmax(0, 46px)); grid-auto-rows: 40px; gap: 4px; }
  .signature.right { text-align: left; }
  .sh-cells { grid-template-columns: repeat(4, 44px); }
  .sh-cell { height: 44px; }
  .sh-lbl { width: 64px; }
  .demo, .aval, .modes, .brute, .nonce, .variants { padding: 16px; }
  .tab-panel { padding: 16px; }
  .xbit { width: 30px; height: 36px; }
  .xrow .l { width: 64px; }
  .brand-sub { display: none; }
}
