:root {
  --bg: #eaf5ff;
  --card: #ffffff;
  --ink: #1f3550;
  --muted: #475a6e;
  --line: #d6e8f7;
  --brand: #1565c0;
  --brand2: #4fb3f0;
  --grad: linear-gradient(120deg, #1565c0, #1e7ad4);
  --brand-soft: #eaf5ff;
  --key: #a8dcff;
  --prog: #1565c0;
  --warn-bg: #fff3dc;
  --warn-line: #f2b04a;
  --lock-bg: #edf3f9;
  --shadow: 0 8px 24px rgba(21, 101, 192, .12);
  --radius: 18px;
}
html { font-size: 100%; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); line-height: 1.55;
  background: radial-gradient(900px 400px at 85% -5%, #a8dcff 0, transparent 60%),
              radial-gradient(700px 400px at -5% 10%, #eaf5ff 0, transparent 55%), var(--bg);
  background-attachment: fixed;
}
main { max-width: 1160px; margin: 0 auto; padding: 12px 16px 40px; }

header {
  background: linear-gradient(135deg, #0b3c8c, #1565c0 55%, #4fb3f0); color: #fff; border-radius: 18px; padding: 14px 22px; margin-bottom: 12px;
  box-shadow: 0 14px 34px rgba(21, 101, 192, .30); position: relative; overflow: hidden;
}
header::after {
  content: ""; position: absolute; right: -60px; top: -70px; width: 240px; height: 240px;
  border-radius: 50%; background: rgba(255, 255, 255, .14);
}
.back {
  position: relative; display: inline-block; color: #fff; opacity: .9; font-size: .85rem;
  font-weight: 600; text-decoration: none; margin-bottom: 4px;
}
.back:hover { opacity: 1; text-decoration: underline; }
header h1 { font-size: clamp(1.2rem, 3vw, 1.6rem); margin: 0 0 2px; letter-spacing: -.02em; position: relative; }
header p { margin: 0; font-size: .92rem; max-width: 70ch; opacity: .92; position: relative; }

.steps { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.step {
  background: var(--card); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line); transition: opacity .25s, transform .25s;
}
.step:not(.locked):hover { transform: translateY(-2px); }
.step.locked { opacity: .5; }
.step h2, .box h2.lbl {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 6px;
  color: var(--brand); font-weight: 800;
}
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt {
  font: inherit; text-align: left; cursor: pointer; min-height: 38px;
  border: 1.5px solid var(--line); background: #f6fbff; color: var(--ink);
  border-radius: 12px; padding: 7px 12px; transition: all .18s;
}
.opt small { display: block; font-size: .78rem; opacity: .8; font-weight: 400; }
.opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.opt:active { transform: scale(.97); }
.opt:focus-visible { outline: 3px solid var(--brand2); outline-offset: 2px; }
.opt[aria-pressed="true"] {
  background: var(--grad); border-color: transparent; color: #fff; font-weight: 700;
  box-shadow: 0 6px 16px rgba(21, 101, 192, .35);
}
.opt[aria-disabled="true"] { background: var(--lock-bg); color: #8aa0b8; border-style: dashed; cursor: not-allowed; }
.opt[aria-disabled="true"]:hover { border-color: var(--warn-line); background: var(--lock-bg); }
.na {
  border: 1.5px dashed var(--line); background: var(--lock-bg); color: var(--muted);
  border-radius: 12px; padding: 10px 12px; font-size: .9rem;
}
.tag { display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  background: var(--key); color: #0b3c8c; border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: middle; }
.opt[aria-pressed="true"] .tag { background: rgba(255,255,255,.25); color: #fff; }

#msg {
  margin: 12px 0 0; padding: 0 16px; border-radius: 14px; border: 1px solid transparent;
  max-height: 0; overflow: hidden; opacity: 0; transition: max-height .25s, opacity .25s, padding .25s;
}
#msg.show { max-height: 240px; opacity: 1; padding: 13px 16px; }
#msg.warn { background: var(--warn-bg); border-color: var(--warn-line); border-left: 6px solid var(--warn-line); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 2px 8px; }
#ruta { font-size: .95rem; color: var(--muted); }
#ruta b {
  color: var(--brand); background: var(--brand-soft); padding: 3px 10px; border-radius: 999px;
  font-weight: 700; font-size: .88rem; white-space: nowrap;
}
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.reset {
  font: inherit; font-weight: 600; border: 2px solid var(--brand); background: #fff; color: var(--brand);
  border-radius: 999px; padding: 8px 20px; cursor: pointer; transition: all .15s;
  box-shadow: 0 4px 12px rgba(21, 101, 192, .18);
}
.reset:hover { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(21, 101, 192, .35); }
.reset:active { transform: scale(.97); }
.reset:disabled { opacity: .45; cursor: not-allowed; background: #fff; color: var(--brand); }

[hidden] { display: none !important; }
.box { background: var(--card); border-radius: 20px; padding: 14px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0; margin-bottom: 12px; }
.ej-info { margin: -4px 0 10px; font-size: .84rem; color: var(--muted); }
.ej-info:empty { display: none; }
.num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 4px; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: .78rem; letter-spacing: 0; vertical-align: middle;
}
.step.locked .num { background: #9db4cc; }
.box h2 { margin: 0 0 2px; font-size: 1.1rem; letter-spacing: -.01em; }
.formula { color: var(--brand); font-weight: 600; font-size: .92rem; margin: 0 0 10px; }

.vars { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.var { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: #f9fcff; }
.var.off { opacity: .45; }
label { display: block; font-size: .8rem; font-weight: 700; color: var(--brand); margin: 6px 0 3px; }
label:first-child { margin-top: 0; }
input, textarea {
  width: 100%; font: inherit; font-size: .93rem; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
textarea { resize: vertical; min-height: 82px; }
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 179, 240, .3); }
.hint { font-size: .78rem; color: var(--muted); margin: 3px 0 0; }
.full { grid-column: 1 / -1; }

.scroll { overflow-x: auto; }
table.cruce { border-collapse: separate; border-spacing: 4px; width: 100%; font-size: .85rem; }
.cruce th { font-weight: 700; text-align: left; padding: 6px 8px; border-radius: 10px; background: var(--lock-bg); vertical-align: middle; }
.cruce th.v { background: var(--prog); color: #fff; }
.cruce th.d { background: var(--key); }
.cruce th.corner { background: transparent; }
.cruce td { text-align: center; padding: 6px; border-radius: 10px; border: 1.5px dashed var(--line); color: #a9bacb; min-width: 52px; }
.cruce td.on { border: 0; background: var(--grad); color: #fff; font-weight: 800; box-shadow: 0 4px 10px rgba(21, 101, 192, .3); }
.cruce td.pg { border: 0; background: #0b3c8c; color: #fff; font-weight: 800; }
.cnt { margin: 8px 0 0; font-size: .9rem; }
.cnt b { color: var(--brand); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.tema {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; margin-bottom: 8px;
  border-radius: 16px; background: linear-gradient(135deg, #ffffff, #eef7ff);
  border: 1px solid var(--line); border-left: 6px solid var(--brand2);
}
.tema.g { border-left-color: #0b3c8c; }
.tema .n {
  flex: none; min-width: 42px; height: 30px; padding: 0 6px; border-radius: 12px; background: var(--grad);
  color: #fff; font-weight: 800; font-size: .8rem; display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(21, 101, 192, .3);
}
.tema.g .n { background: #0b3c8c; }
.tema p { margin: 0; font-size: 1rem; }
.tema .h0 { margin-top: 4px; color: var(--muted); font-size: .95rem; }
.tema.empty p { color: var(--muted); font-style: italic; }
mark { padding: 1px 6px; border-radius: 6px; background: var(--key); color: inherit; font-weight: 700; }
mark.p { background: var(--prog); color: #fff; }
.swap .tema { animation: swap .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes swap { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

table.coh { width: 100%; border-collapse: collapse; font-size: .9rem; }
.coh th { background: var(--prog); color: #fff; text-align: left; padding: 8px; }
.coh th:first-child { border-top-left-radius: 10px; } .coh th:last-child { border-top-right-radius: 10px; }
.coh td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.coh tr.g td { background: var(--brand-soft); }
.coh td.k { font-weight: 800; color: var(--brand); white-space: nowrap; }

.note {
  margin-top: 8px; padding: 8px 14px; border-radius: 14px; font-size: .93rem;
  background: var(--brand-soft); border-left: 6px solid var(--brand);
}
.note.warn { background: var(--warn-bg); border-left-color: var(--warn-line); }
.legend { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }

.info { margin-top: 24px; }
.info h2 { font-size: 1.15rem; margin: 0 0 12px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card {
  background: var(--card); border-radius: 16px; padding: 16px; font-size: .92rem;
  box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 5px solid var(--brand);
}
.card:nth-child(2) { border-top-color: var(--brand2); }
.card:nth-child(3) { border-top-color: #0b3c8c; }
.card:nth-child(4) { border-top-color: #4fb3f0; }
.card small { color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-size: .7rem; font-weight: 700; }
.card h3 { margin: 2px 0 8px; font-size: 1.02rem; }
.card p { margin: 0 0 6px; }
.card ul { margin: 0; padding-left: 18px; }
.card li { margin-bottom: 4px; }
.card .ej { color: var(--muted); font-size: .88rem; }

body.hc { --ink: #000; --muted: #1a1a1a; --line: #5a6b80; --brand: #0039a6; --key: #ffe066; --lock-bg: #e4e4e4; background: #fff; }
body.hc .opt[aria-disabled="true"] { color: #444; }

@media (max-width: 820px) { .steps { grid-template-columns: 1fr 1fr; } .steps .step:last-child { grid-column: 1 / -1; } }
@media (max-width: 560px) {
  header { padding: 12px 16px; border-radius: 16px; }
  .steps { grid-template-columns: 1fr; }
  .vars { grid-template-columns: 1fr; }
  .box { padding: 14px; }
  .coh thead { display: none; }
  .coh, .coh tbody, .coh tr, .coh td { display: block; width: 100%; }
  .coh tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
  .coh td { border-bottom: 1px dashed var(--line); }
  .coh td[data-l]::before { content: attr(data-l); display: block; font-size: .72rem; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
