/* ---------- Tokens ---------- */
:root {
  /* superficies */
  --bg: #04060c;
  --surface: rgba(9, 13, 24, .86);
  --surface-solid: #0a0f1c;
  --field: #0a1120;
  --field-hover: #0d1629;
  --line: #1c2740;
  --line-strong: #2c4170;
  /* texto */
  --txt: #dbe6ff;
  --txt-2: #c8d6f5;
  --dim: #8696bb;
  /* estados */
  --acc: #19ffa0;
  --acc-ink: #02140c;
  --acc-2: #14b878;
  --acc-3: #0e8f5d;
  --warn: #ffb020;
  --bad: #ff3355;
  --info: #4a7dff;
  --idle: #3a4660;
  --ok-line: #1d5a45; --ok-txt: #9dffd5;
  --warn-line: #6b5320; --warn-txt: #ffd88a;
  --bad-line: #6b2030; --bad-txt: #ff9fb0;
  --info-line: #24407a; --info-txt: #a8c4ff;
  /* forma */
  --r-sm: 8px; --r-md: 12px; --r-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --fs-xs: 11px; --fs-sm: 12px; --fs-md: 14px; --fs-lg: 20px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--acc);
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--txt); font: var(--fs-md)/1.4 var(--font); overflow: hidden; -webkit-tap-highlight-color: transparent; }
p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hint { font-size: var(--fs-sm); color: var(--dim); }
.lbl { font-size: var(--fs-sm); color: var(--dim); }
.unit { font-size: var(--fs-sm); color: var(--dim); font-weight: 600; margin-left: 2px; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.nogl { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); max-width: min(360px, 80vw); text-align: center; display: flex; flex-direction: column; gap: var(--s2); color: var(--dim); font-size: var(--fs-sm); }
.nogl b { color: var(--txt); font-size: var(--fs-md); }

/* ---------- Layout ---------- */
#hud {
  position: fixed; inset: 0; pointer-events: none; display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr minmax(290px, 340px);
  grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--s3);
  padding: calc(var(--s3) + var(--safe-t)) calc(var(--s3) + var(--safe-r)) calc(var(--s3) + var(--safe-b)) calc(var(--s3) + var(--safe-l));
}
#hud > * { pointer-events: auto; }
#top {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) 20px; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s2) 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.brand { font-weight: 800; letter-spacing: .14em; font-size: 15px; display: flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.brand b { color: var(--acc); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 10px var(--acc); }
.tools { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.panel-col { display: flex; flex-direction: column; gap: var(--s3); overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; padding: 2px 4px 2px 2px; overscroll-behavior: contain; }
#left { grid-column: 1; grid-row: 2; } #right { grid-column: 3; grid-row: 2; }
#tabs { display: none; }

/* ---------- Chips de estado ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; list-style: none; margin: 0; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--dim); cursor: default; transition: border-color .3s, color .3s; }
.chip i, .conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; display: inline-block; transition: background .3s, box-shadow .3s; }
.chip.ok { color: var(--txt); border-color: var(--ok-line); }
.chip.wait { color: var(--txt); border-color: var(--warn-line); }
.chip.bad { color: var(--txt); border-color: var(--bad-line); }
.ok > i, .ok i { background: var(--acc); box-shadow: 0 0 8px var(--acc); }
.wait > i, .wait i { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
.bad > i, .bad i { background: var(--bad); box-shadow: 0 0 6px var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

.conn { display: grid; gap: 6px; margin: 0; }
.conn > div { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: var(--s2); align-items: baseline; padding: 6px var(--s2); border-radius: var(--r-sm); background: var(--field); border: 1px solid var(--line); }
.conn dt { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--dim); }
.conn dd { margin: 0; font-size: var(--fs-sm); text-align: right; overflow-wrap: anywhere; }
.conn .ok { border-color: var(--ok-line); } .conn .wait { border-color: var(--warn-line); } .conn .bad { border-color: var(--bad-line); }
.conn .bad dd { color: var(--bad-txt); }

/* ---------- Controles ---------- */
input[type=text], input[type=password], input[type=number], select {
  background: var(--field); color: var(--txt); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 7px 9px; font: inherit; width: 100%; min-width: 0; min-height: 36px; transition: border-color .15s, background .15s;
}
select { width: auto; padding-right: 6px; }
input:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--line-strong); }
input:focus-visible, select:focus-visible { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(25, 255, 160, .18); }
input::placeholder { color: #56658a; }
input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
input[aria-invalid=true] { border-color: var(--bad); }

button, .btn {
  font: inherit; cursor: pointer; border-radius: var(--r-sm); border: 1px solid var(--line); padding: 8px 12px; min-height: 36px;
  color: var(--txt); background: #0f1a30; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color .15s, background .15s, filter .15s, transform .08s;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--line-strong); background: #132240; }
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: linear-gradient(180deg, var(--acc-2), var(--acc-3)); border-color: var(--acc); color: var(--acc-ink); font-weight: 700; }
button.primary:hover:not(:disabled), .btn.primary:hover { filter: brightness(1.1); background: linear-gradient(180deg, var(--acc-2), var(--acc-3)); }
button.ghost { background: transparent; }
button.small, .btn.small { padding: 5px 10px; font-size: var(--fs-sm); min-height: 30px; }
button.danger { background: #2a0d16; border-color: var(--bad-line); color: #ff8aa0; }
button.danger:hover:not(:disabled) { background: #3a1220; border-color: var(--bad); }
button.armed { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 700; }
button.busy::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.grow { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--dim); padding: 5px 11px; min-height: 30px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: #12203a; color: var(--acc); }
.sel { color: var(--dim); font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; }
.sel select { min-height: 30px; padding: 3px 6px; font-size: var(--fs-sm); }
#fps { color: var(--dim); font-size: var(--fs-sm); min-width: 54px; text-align: right; }

.tog { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 30px; }
.tog input { accent-color: var(--acc); width: 18px; height: 18px; flex: none; margin: 0; cursor: inherit; }
.rng { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s2); font-size: var(--fs-sm); color: var(--dim); }
.rng input { grid-column: 1 / -1; accent-color: var(--acc); width: 100%; margin: 4px 0; min-height: 22px; cursor: pointer; }
.rng output { color: var(--txt); font-family: var(--mono); }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .55; }
fieldset:disabled .tog, fieldset:disabled .rng input { cursor: not-allowed; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 10px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); flex: none; }
.card h2 { margin: 0; font-size: var(--fs-sm); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; gap: var(--s2); align-items: center; } .row > input { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.grid2 > * { min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pw { display: flex; gap: 6px; }
.badge { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .1em; padding: 2px 8px; border-radius: var(--r-pill); border: 1px solid; }
.badge.warn { color: var(--warn-txt); border-color: var(--warn-line); background: rgba(255, 176, 32, .08); }

.nets { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.nets li + li { border-top: 1px solid #111a2e; }
.nets button { width: 100%; justify-content: space-between; border: 0; border-radius: 0; background: transparent; padding: 7px 10px; min-height: 34px; text-align: left; }
.nets button:hover { background: #12203a; }
.nets button[aria-pressed=true] { background: #12203a; color: var(--acc); }
.nets small { color: var(--dim); font-family: var(--mono); white-space: nowrap; }
.nets .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg { border-radius: var(--r-sm); padding: var(--s2) 10px; font-size: 13px; border: 1px solid var(--line); background: var(--field); }
.msg.ok { border-color: var(--ok-line); color: var(--ok-txt); }
.msg.err { border-color: var(--bad-line); color: var(--bad-txt); }
.msg.warn { border-color: var(--warn-line); color: var(--warn-txt); }
.msg.info { border-color: var(--info-line); color: var(--info-txt); }
.empty { margin: 0; padding: 14px 10px; text-align: center; font-size: var(--fs-sm); color: var(--dim); border: 1px dashed var(--line); border-radius: var(--r-sm); }
.adv summary { cursor: pointer; color: var(--dim); font-size: var(--fs-sm); margin-bottom: var(--s2); border-radius: 4px; }
.adv summary:hover { color: var(--txt); }
.adv .grid2 { margin-bottom: var(--s2); }

/* ---------- Jefe ---------- */
.big { font-size: var(--fs-lg); font-weight: 800; letter-spacing: .06em; }
#boss-state { transition: color .6s; }
#boss-state[data-st=focused] { color: var(--acc); }
#boss-state[data-st=distracted] { color: var(--bad); }
#boss-state[data-st=absent] { color: var(--info); }
#boss-state[data-st=unknown] { color: #8892a8; }
.bar { height: 8px; border-radius: var(--r-pill); background: var(--field); border: 1px solid var(--line); overflow: hidden; }
.bar.thin { height: 4px; border: 0; }
#score-bar, #pomo-bar { height: 100%; width: 0; background: var(--acc); transition: width .6s var(--ease), background .6s; }
#pomo-bar { transition: width 1s linear, background .6s; }
.say { font-style: italic; color: var(--txt-2); min-height: 2.8em; border-left: 3px solid var(--acc); padding-left: 10px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.metrics div { background: var(--field); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px var(--s2); display: flex; flex-direction: column; min-width: 0; }
.metrics span { font-size: var(--fs-xs); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metrics b { font-size: 15px; white-space: nowrap; }
.chart { display: block; width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-sm); }
.legend { display: flex; gap: var(--s3); font-size: var(--fs-xs); color: var(--dim); }
.lg::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.lg.f::before { background: var(--acc); } .lg.d::before { background: var(--bad); } .lg.a::before { background: var(--info); }
.pomo { display: flex; flex-direction: column; gap: var(--s2); padding: 10px; background: var(--field); border: 1px solid var(--line); border-radius: 10px; }
.pomo select { padding: 4px 6px; font-size: var(--fs-sm); min-height: 30px; }
.pomo[data-mode=focus] { border-color: var(--bad-line); } .pomo[data-mode=focus] #pomo-bar { background: var(--bad); }
.pomo[data-mode=break] { border-color: var(--ok-line); }
#pomo-mode { font-weight: 700; letter-spacing: .06em; }
.pomo[data-mode=focus] #pomo-mode { color: var(--bad); } .pomo[data-mode=break] #pomo-mode { color: var(--acc); }
.pomo[data-paused=true] #pomo-mode { color: var(--warn); }
.chatbox { display: flex; flex-direction: column; gap: 6px; }
.chat { max-height: 130px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; scrollbar-width: thin; }
.chat:empty { display: none; }
.chat .m { padding: 5px var(--s2); border-radius: var(--r-sm); background: var(--field); border: 1px solid var(--line); max-width: 92%; }
.chat .m.me { align-self: flex-end; border-color: var(--info-line); } .chat .m.bo { border-color: var(--ok-line); color: #c8f5e0; }
.chat .m b { color: var(--dim); font-weight: 600; }

/* ---------- Personalidad ---------- */
.pers { display: flex; flex-direction: column; gap: 6px; }
.pers-seg { display: flex; }
.pers-seg button { flex: 1; min-width: 0; }
.seg button[aria-checked=true] { background: #12203a; color: var(--acc); font-weight: 700; }
/* acento sutil del bocadillo segun la personalidad */
body[data-pers=estricto] .say { border-left-color: var(--warn); }
body[data-pers=sarcastico] .say { border-left-color: var(--info); }

/* ---------- Progreso (gamificacion) ---------- */
.lvl { display: flex; gap: var(--s3); align-items: center; }
.lvl-badge { flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--acc); background: radial-gradient(circle at 50% 35%, rgba(25, 255, 160, .22), rgba(25, 255, 160, .03) 70%); box-shadow: 0 0 16px rgba(25, 255, 160, .25), inset 0 0 12px rgba(25, 255, 160, .15); }
.lvl-badge span { font: 800 var(--fs-lg)/1 var(--mono); color: var(--acc); }
.lvl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.lvl-info b { font-size: 15px; letter-spacing: .04em; }
#xp-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--acc-3), var(--acc)); box-shadow: 0 0 8px var(--acc); transition: width .6s var(--ease); }
.metrics.two { grid-template-columns: 1fr 1fr; }
.metrics small { font-size: var(--fs-xs); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ach { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 0 var(--s2); align-items: start; padding: 7px var(--s2); border-radius: var(--r-sm); background: var(--field); border: 1px solid var(--line); min-width: 0; }
.ach > :not(.ach-ico) { grid-column: 2; min-width: 0; }
.ach-ico { grid-row: 1 / span 3; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: #111a2e; color: var(--dim); filter: grayscale(1); opacity: .7; }
.ach b { font-size: var(--fs-sm); color: var(--dim); overflow-wrap: anywhere; }
.ach small { font-size: var(--fs-xs); color: #6f7fa6; line-height: 1.3; }
.ach .ach-when { margin-top: 2px; }
.ach.on { border-color: var(--ok-line); background: linear-gradient(160deg, rgba(25, 255, 160, .08), var(--field) 60%); }
.ach.on .ach-ico { background: var(--acc); color: var(--acc-ink); filter: none; opacity: 1; box-shadow: 0 0 10px rgba(25, 255, 160, .45); }
.ach.on b { color: var(--txt); } .ach.on small { color: var(--dim); } .ach.on .ach-when { color: var(--ok-txt); }
.ach.new { animation: ach-new 1.2s var(--ease) 3; }
@keyframes ach-new { 50% { box-shadow: 0 0 0 2px var(--acc), 0 0 18px rgba(25, 255, 160, .5); } }
#prog.celebrate { animation: celebrate 1.3s var(--ease) 2; }
@keyframes celebrate { 40% { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc), 0 0 28px rgba(25, 255, 160, .35); } }

/* ---------- Dialogo del reporte ---------- */
.dlg { padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-solid); color: var(--txt); width: min(640px, calc(100vw - 24px)); max-height: min(92dvh, 860px); box-shadow: var(--shadow), 0 0 40px rgba(25, 255, 160, .08); overflow: hidden; }
.dlg[open] { display: flex; animation: toast-in .25s var(--ease); }
.dlg::backdrop { background: rgba(2, 4, 10, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.dlg-body { flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.dlg-body section { display: flex; flex-direction: column; gap: var(--s2); }
.dlg-head { display: flex; align-items: center; gap: 10px; }
.dlg-head h2 { margin: 0; font-size: var(--fs-md); letter-spacing: .14em; text-transform: uppercase; color: var(--txt); }
.dlg-x { margin-left: auto; font-size: 18px; line-height: 1; padding: 2px 10px; }
.sub { margin: 4px 0 0; font-size: var(--fs-sm); font-weight: 700; color: var(--txt-2); letter-spacing: .04em; }
.sub::first-letter { text-transform: uppercase; }
.rep-metrics { grid-template-columns: repeat(4, 1fr); }
.badge.ok { color: var(--ok-txt); border-color: var(--ok-line); background: rgba(25, 255, 160, .08); }
.dlg-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 2px; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 5px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid #111a2e; }
.tbl thead th { color: var(--dim); font-weight: 600; background: var(--field); }
.tbl th:first-child { text-align: left; }
.tbl tbody th { font-weight: 600; text-transform: capitalize; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Dispositivos ---------- */
.devs { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; scrollbar-width: thin; }
.dev { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s2); align-items: center; padding: 6px var(--s2); background: var(--field); border: 1px solid var(--line); border-radius: var(--r-sm); transition: border-color .2s, opacity .2s; }
.dev.off { opacity: .65; }
.dev .nm { font-size: 13px; min-width: 0; } .dev .nm small { color: var(--dim); display: block; font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev .ex { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--dim); }
.dev .ex label { display: inline-flex; align-items: center; gap: 4px; }
.dev .ex input[type=number] { width: 76px; padding: 3px 6px; min-height: 28px; }
.dev .ex button { padding: 3px 8px; font-size: var(--fs-sm); min-height: 28px; }
.dev input[type=checkbox] { accent-color: var(--acc); width: 18px; height: 18px; cursor: pointer; }

/* ---------- Log ---------- */
#log { grid-column: 1 / -1; grid-row: 3; align-self: end; max-height: 84px; overflow-y: auto; display: flex; flex-direction: column-reverse; font-size: var(--fs-xs); color: var(--dim); background: rgba(4, 6, 12, .72); border-radius: var(--r-sm); padding: 6px 10px; border: 1px solid var(--line); scrollbar-width: none; }
#log .e { color: #ff8aa0; } #log .w { color: var(--warn-txt); }

/* ---------- Bocadillo del jefe ---------- */
#bubble { position: fixed; left: 0; top: 0; z-index: 3; max-width: min(280px, 70vw); padding: 10px 14px; border-radius: 14px; background: rgba(8, 14, 28, .94); border: 1px solid var(--acc); color: #eafff5; font-size: var(--fs-md); font-style: italic; line-height: 1.35; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s linear .35s; box-shadow: 0 0 22px rgba(25, 255, 160, .25); will-change: transform; }
#bubble.show { opacity: 1; visibility: visible; transition: opacity .35s; }
#bubble.off { opacity: 0 !important; }
#bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 14px; height: 14px; background: rgba(8, 14, 28, .94); border-right: 1px solid var(--acc); border-bottom: 1px solid var(--acc); transform: translateX(-50%) rotate(45deg); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 10; bottom: calc(112px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: start; padding: 10px 12px; border-radius: var(--r-md); background: rgba(10, 15, 28, .96); border: 1px solid var(--line); border-left-width: 4px; box-shadow: var(--shadow); animation: toast-in .28s var(--ease); }
.toast.out { animation: toast-out .22s ease-in forwards; }
.toast i { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--info); }
.toast b { font-size: 13px; } .toast p { grid-column: 2; font-size: var(--fs-sm); color: var(--txt-2); overflow-wrap: anywhere; }
.toast small { grid-column: 2; font-size: var(--fs-xs); color: var(--dim); }
.toast button { grid-column: 3; grid-row: 1 / span 3; border: 0; background: transparent; color: var(--dim); min-height: 28px; padding: 2px 8px; font-size: 16px; line-height: 1; }
.toast button:hover:not(:disabled) { background: rgba(255, 255, 255, .06); color: var(--txt); }
.toast.info { border-left-color: var(--info); }
.toast.warn { border-left-color: var(--warn); } .toast.warn i { background: var(--warn); }
.toast.bad { border-left-color: var(--bad); } .toast.bad i { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.toast.ok { border-left-color: var(--acc); } .toast.ok i { background: var(--acc); }
.toast.achv { border-color: var(--ok-line); border-left-color: var(--acc); background: linear-gradient(120deg, rgba(25, 255, 160, .16), rgba(10, 15, 28, .97) 55%); box-shadow: var(--shadow), 0 0 24px rgba(25, 255, 160, .25); }
.toast.achv b { color: var(--acc); letter-spacing: .03em; } .toast.achv p { color: var(--txt); font-weight: 600; font-size: 13px; }
.toast.achv i { box-shadow: 0 0 10px var(--acc); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Móvil y tablet ---------- */
@media (max-width: 980px) {
  #hud { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; gap: var(--s2); padding: calc(var(--s2) + var(--safe-t)) calc(var(--s2) + var(--safe-r)) calc(var(--s2) + var(--safe-b)) calc(var(--s2) + var(--safe-l)); }
  #top { padding: 6px 10px; gap: 6px 12px; }
  #tabs { display: flex; grid-column: 1; grid-row: 2; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px; gap: 4px; }
  #tabs button { flex: 1; border: 0; background: transparent; color: var(--dim); min-height: 40px; }
  #tabs button[aria-selected=true] { background: #12203a; color: var(--acc); }
  #left, #right { grid-column: 1; grid-row: 3; display: none; }
  body.tab-left #left, body.tab-right #right { display: flex; }
  #log { grid-row: 4; max-height: 52px; }
  .tools .sel, #fps, .hide-sm { display: none; }
  .chip { padding: 2px 8px; }
  body:not(.tab-scene) #bubble { display: none; }
  .toasts { bottom: calc(76px + var(--safe-b)); }
  /* objetivos táctiles de al menos 40 px */
  button, .btn, input[type=text], input[type=password], input[type=number], select { min-height: 40px; }
  button.small, .btn.small, .seg button { min-height: 36px; }
}
@media (max-width: 520px) {
  .brand { font-size: 13px; }
  .chip span { font-size: var(--fs-xs); }
  .grid2 { grid-template-columns: 1fr; }
  .adv .grid2 { grid-template-columns: 1fr 1fr; }
  .metrics, .rep-metrics { grid-template-columns: repeat(2, 1fr); }
  .dlg { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .dlg-body { padding: 12px; }
  .dlg-foot button { flex: 1 1 auto; }
  .dlg-foot .grow { display: none; }
  .conn > div { grid-template-columns: 1fr; gap: 2px; } .conn dd { text-align: left; }
}
@media (max-height: 520px) and (max-width: 980px) { #log { display: none; } #hud { grid-template-rows: auto auto minmax(0, 1fr); } }

/* =====================================================================
   Modo demostración: pantalla de entrada + recorrido guiado
   ===================================================================== */
:root {
  --violet: #b38cff;
  --t-fs: clamp(20px, calc(.9vw + 7px), 25px);            /* globos: >= 20 px siempre en escritorio */
  --t-body: clamp(20px, calc(1vw + 7px), 30px);           /* texto de capitulos */
  --t-h: clamp(40px, 3.4vw, 76px);                        /* titulos de capitulos */
  --t-glass: linear-gradient(160deg, rgba(14, 24, 44, .97), rgba(7, 11, 22, .97));
}
#hud { transition: opacity .7s var(--ease); }
body.landing-on #hud { opacity: 0; pointer-events: none; }
body.landing-on #hud > * { pointer-events: none; }
body.landing-on #bubble, body.landing-on .toasts { opacity: 0; }

/* ---------- Ojo del jefe (SVG compartido por landing y portada) ---------- */
.t-eye-ico { fill: rgba(25, 255, 160, .05); stroke: var(--acc); stroke-width: 2.5; stroke-linejoin: round; }
.t-eye-ico2 { opacity: .45; transform-origin: 100px 100px; animation: t-spin 24s linear infinite; }
.t-eye-face { fill: var(--acc); stroke: var(--acc); }
.t-eye-face rect, .t-eye-face circle { stroke: none; }
.t-eye-pupil { animation: t-look 7s ease-in-out infinite; }
@keyframes t-spin { to { transform: rotate(360deg); } }
@keyframes t-look { 0%, 18% { transform: translateX(0); } 26%, 44% { transform: translateX(-7px); } 52%, 70% { transform: translateX(7px); } 78%, 100% { transform: translateX(0); } }
@keyframes t-float { 50% { transform: translateY(-10px); } }

/* ---------- Pantalla de entrada ---------- */
.landing {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(24px + var(--safe-t)) calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l));
  background: radial-gradient(110% 80% at 50% 42%, rgba(4, 6, 12, .25), rgba(4, 6, 12, .9) 72%), rgba(4, 6, 12, .35);
  backdrop-filter: blur(12px) saturate(1.25); -webkit-backdrop-filter: blur(12px) saturate(1.25);
  animation: land-in .9s var(--ease) both;
}
.landing.out { animation: land-out .5s ease-in forwards; pointer-events: none; }
@keyframes land-in { from { opacity: 0; } }
@keyframes land-out { to { opacity: 0; transform: scale(1.03); filter: blur(6px); } }
.landing-glow { position: absolute; left: 50%; top: 40%; width: min(900px, 120vw); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(25, 255, 160, .13), transparent 62%); pointer-events: none; }
.landing-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: clamp(14px, 2.4vh, 30px); max-width: 1100px; }
.landing-card > * { animation: t-rise .9s var(--ease) both; }
.landing-card > :nth-child(2) { animation-delay: .12s; } .landing-card > :nth-child(3) { animation-delay: .26s; }
.landing-card > :nth-child(4) { animation-delay: .4s; } .landing-card > :nth-child(5) { animation-delay: .54s; } .landing-card > :nth-child(6) { animation-delay: .66s; }
@keyframes t-rise { from { opacity: 0; transform: translateY(22px); filter: blur(6px); } }
.landing-eye { width: clamp(96px, 11vw, 190px); height: auto; filter: drop-shadow(0 0 22px rgba(25, 255, 160, .45)); }
.landing-eye { animation: t-rise .9s var(--ease) both, t-float 5s ease-in-out 1s infinite; }
.landing-brand { margin: 0; font-size: clamp(54px, 8.6vw, 156px); font-weight: 800; letter-spacing: .14em; line-height: 1; padding-left: .14em; text-shadow: 0 0 40px rgba(25, 255, 160, .25); }
.landing-brand b { color: var(--acc); }
.landing-lema { font-size: clamp(19px, 1.9vw, 36px); color: var(--txt-2); max-width: 28em; line-height: 1.35; text-wrap: balance; }
.landing-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(12px, 1.6vw, 24px); margin-top: 6px; }
.landing-btn { flex-direction: column; gap: 2px; min-width: clamp(220px, 17vw, 330px); min-height: 0; padding: clamp(14px, 1.4vw, 22px) 28px; border-radius: 16px; font-size: clamp(22px, 1.6vw, 32px); font-weight: 800; letter-spacing: .02em; background: rgba(15, 26, 48, .8); border-color: var(--line-strong); }
.landing-btn small { font-size: .55em; font-weight: 600; opacity: .75; letter-spacing: .04em; }
.landing-btn.primary { box-shadow: 0 0 0 1px var(--acc), 0 10px 40px rgba(25, 255, 160, .28); }
.landing-btn:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--acc); }
.landing-authors { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; font-size: clamp(15px, 1.15vw, 22px); color: var(--txt-2); }
.landing-authors li { padding: 6px 16px; border: 1px solid var(--line); border-radius: var(--r-pill); background: rgba(9, 13, 24, .6); }
.landing-foot { font-size: clamp(12px, .85vw, 15px); color: var(--dim); letter-spacing: .06em; }
kbd { font: 700 .85em var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: rgba(255, 255, 255, .04); color: var(--txt); }

/* ---------- Capas del recorrido ---------- */
.tour { position: fixed; inset: 0; z-index: 40; pointer-events: none; font-size: var(--t-fs); line-height: 1.45; }
.tour:focus { outline: none; }
.tour-progress { position: fixed; z-index: 6; left: 0; right: 0; top: 0; height: 4px; background: rgba(25, 255, 160, .08); }
.tour-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--acc-3), var(--acc)); box-shadow: 0 0 12px var(--acc); transition: width .6s var(--ease); }
.tour-spot { position: fixed; z-index: 1; left: 0; top: 0; width: 0; height: 0; border-radius: 16px; pointer-events: none; opacity: 0; transition: opacity .4s var(--ease); box-shadow: 0 0 0 200vmax rgba(2, 4, 10, .74); will-change: transform; }
.tour-spot.on { opacity: 1; }
.tour[data-dim=light] .tour-spot { box-shadow: 0 0 0 200vmax rgba(2, 4, 10, .42); }
.tour-spot.ring::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--acc); box-shadow: 0 0 26px rgba(25, 255, 160, .5), inset 0 0 18px rgba(25, 255, 160, .16); animation: spot-pulse 2.4s ease-in-out infinite; }
@keyframes spot-pulse { 50% { box-shadow: 0 0 40px rgba(25, 255, 160, .7), inset 0 0 22px rgba(25, 255, 160, .24); } }
/* el resto del panel queda por encima o por debajo segun el tipo de paso */
body.tour-on .toasts { z-index: 46; }
body[data-tour=chapter] .toasts { z-index: 10; }
body[data-tour=chapter] #bubble { opacity: 0 !important; }
body.tour-on .dlg[open]:not(:modal) { position: fixed; z-index: 41; left: max(16px, 4vw); right: auto; top: 50%; transform: translateY(-50%); margin: 0; max-height: min(86dvh, 860px); }
.boss-card.tour-shake { animation: t-shake .7s cubic-bezier(.36, .07, .19, .97); }
@keyframes t-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }

/* ---------- Capítulos a pantalla completa ---------- */
.tour-ch {
  position: fixed; z-index: 2; inset: 0; display: flex; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  padding: clamp(28px, 5vh, 72px) clamp(16px, 5vw, 120px) calc(clamp(28px, 4vh, 48px) + 76px + var(--safe-b));
  background: radial-gradient(90% 70% at 50% 35%, rgba(10, 22, 40, .55), rgba(3, 5, 11, .9) 75%), rgba(3, 5, 11, .45);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  opacity: 0; visibility: hidden; transition: opacity .45s var(--ease), visibility 0s linear .45s; pointer-events: none;
}
.tour-ch.on { opacity: 1; visibility: visible; transition: opacity .45s var(--ease); pointer-events: auto; }
.tour-ch-in { width: min(1640px, 100%); margin: auto; display: flex; flex-direction: column; gap: clamp(16px, 3vh, 40px); font-size: var(--t-body); animation: ch-in .55s var(--ease) both; }
@keyframes ch-in { from { opacity: 0; transform: translateY(26px) scale(.99); } }
.tour-ch-h h2 { margin: 0; font-size: var(--t-h); line-height: 1.05; font-weight: 800; letter-spacing: -.01em; color: #fff; text-wrap: balance; }
.tour-kicker { margin: 0 0 .4em; font-size: clamp(14px, .95vw, 19px); font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: var(--acc); }
.tour-ch-body { display: flex; flex-direction: column; gap: clamp(16px, 2.6vh, 36px); }
.tz { animation: tz-in .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 110ms + 140ms); }
@keyframes tz-in { from { opacity: 0; transform: translateY(18px); filter: blur(4px); } }
.t-small { font-size: .8em; color: var(--dim); }
.t-note { font-size: clamp(20px, 1.3vw, 28px); color: var(--txt-2); border-left: 4px solid var(--acc); padding: .2em 0 .2em .8em; }
.t-note b { color: #fff; }
.t-note .t-ico { display: inline-block; width: 1.5em; vertical-align: -.3em; margin-right: .45em; color: var(--acc); }
.t-ico { display: block; width: clamp(40px, 3.2vw, 64px); color: var(--c, var(--acc)); }
.t-ico svg { display: block; width: 100%; height: auto; }

/* portada y cierre */
.t-cover { display: flex; flex-direction: column; align-items: center; text-align: center; gap: clamp(12px, 2.2vh, 28px); }
.t-eye { width: clamp(96px, 10vw, 180px); height: auto; filter: drop-shadow(0 0 22px rgba(25, 255, 160, .45)); animation: t-float 5s ease-in-out infinite; }
.t-brand { margin: 0; font-size: clamp(60px, 8.4vw, 160px); font-weight: 800; letter-spacing: .14em; padding-left: .14em; line-height: 1; text-shadow: 0 0 40px rgba(25, 255, 160, .25); }
.t-brand b { color: var(--acc); }
.t-cover.end .t-brand { font-size: clamp(46px, 6.2vw, 120px); letter-spacing: 0; padding-left: 0; }
.t-lema { font-size: clamp(22px, 2vw, 38px); color: var(--txt-2); max-width: 30em; text-wrap: balance; }
.t-lema b { color: var(--acc); }
.t-authors { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 16px; font-size: clamp(17px, 1.25vw, 25px); }
.t-authors li { padding: 6px 18px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: rgba(9, 13, 24, .6); }
.t-kicker { font-size: clamp(14px, .95vw, 18px); color: var(--dim); letter-spacing: .2em; text-transform: uppercase; }
.t-url { font-size: clamp(22px, 2vw, 38px); color: var(--acc); padding: .2em .9em; border: 1px solid var(--ok-line); border-radius: var(--r-pill); background: rgba(25, 255, 160, .06); }

/* problema */
.t-problem { display: flex; flex-direction: column; gap: clamp(20px, 4vh, 52px); }
.t-huge { font-size: clamp(40px, 4.4vw, 92px); font-weight: 800; line-height: 1.08; letter-spacing: -.015em; text-wrap: balance; }
.t-huge em { font-style: normal; color: var(--warn); }
.t-trio { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(12px, 1.4vw, 24px); }
.t-trio li { padding: clamp(16px, 1.8vw, 32px); border-radius: 20px; border: 1px solid var(--line-strong); background: rgba(12, 20, 38, .72); font-size: clamp(22px, 1.6vw, 34px); line-height: 1.25; }
.t-trio b { color: var(--acc); }
.t-punch { font-size: clamp(28px, 2.6vw, 54px); font-weight: 700; border-left: 6px solid var(--acc); padding-left: .6em; line-height: 1.15; }
.t-punch.sm { font-size: clamp(24px, 1.9vw, 40px); }
.t-punch em { font-style: normal; color: var(--bad); }

/* tarjetas */
.t-card { --c: var(--acc); display: flex; flex-direction: column; gap: .45em; padding: clamp(16px, 1.7vw, 34px); border-radius: 20px; background: rgba(12, 20, 38, .76); border: 1px solid var(--line-strong); border-top: 4px solid var(--c); min-width: 0; font-size: clamp(19px, 1.25vw, 27px); line-height: 1.3; box-shadow: 0 18px 50px rgba(0, 0, 0, .3); }
.t-card.blue { --c: var(--info); } .t-card.amber { --c: var(--warn); } .t-card.violet { --c: var(--violet); }
.t-card h3 { margin: 0; color: var(--c); font-size: clamp(22px, 1.6vw, 34px); line-height: 1.15; }
.t-card b { color: #fff; }
.t-idea { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: clamp(10px, 1.2vw, 22px); }
.t-idea .t-card h3 { font-size: clamp(30px, 2.6vw, 56px); letter-spacing: .1em; }
.t-idea.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.t-arrow { align-self: center; width: clamp(28px, 3vw, 60px); height: 4px; border-radius: 2px; position: relative; background: linear-gradient(90deg, rgba(25, 255, 160, .1), var(--acc)); background-size: 200% 100%; animation: tz-in .7s var(--ease) both, t-flow 1.6s linear infinite; animation-delay: calc(var(--i, 0) * 110ms + 140ms), 0s; }
.t-arrow::after { content: ""; position: absolute; right: -2px; top: 50%; width: 14px; height: 14px; border-top: 4px solid var(--acc); border-right: 4px solid var(--acc); transform: translateY(-50%) rotate(45deg); }
@keyframes t-flow { to { background-position: -200% 0; } }
.t-grid2x2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(10px, 1.2vw, 22px); }
.t-grid3x2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 1.2vw, 22px); }

/* arquitectura */
.t-archwrap { width: 100%; display: flex; justify-content: center; }
.t-arch { width: 100%; height: auto; max-height: calc(100dvh - 410px); min-height: 300px; overflow: visible; }
.t-arch .t-col { fill: var(--dim); font: 800 20px var(--font); letter-spacing: .22em; text-anchor: middle; }
.t-vps { fill: rgba(74, 125, 255, .035); stroke: var(--line-strong); stroke-width: 2; stroke-dasharray: 10 8; }
.t-node rect { fill: #0b1426; stroke: var(--line-strong); stroke-width: 2; }
.t-node.edge rect { stroke: var(--acc); fill: rgba(25, 255, 160, .06); }
.t-node.hot rect { stroke: var(--acc); stroke-width: 3; fill: rgba(25, 255, 160, .1); filter: drop-shadow(0 0 12px rgba(25, 255, 160, .35)); }
.t-node.ext rect { stroke: var(--warn-line); fill: rgba(255, 176, 32, .05); }
.t-n1 { fill: var(--txt); font: 800 26px var(--font); text-anchor: middle; }
.t-n2 { fill: var(--dim); font: 600 19px var(--font); text-anchor: middle; }
.t-wire { fill: none; stroke-width: 3; opacity: .5; stroke-linecap: round; }
.t-wire.mqtt { stroke: var(--acc); } .t-wire.wss { stroke: var(--info); } .t-wire.http { stroke: var(--warn); } .t-wire.int { stroke: var(--dim); }
.t-wire.ble { stroke: var(--violet); stroke-dasharray: 9 9; }
.t-dot { fill: var(--acc); } .t-dot.wss { fill: #7fa4ff; } .t-dot.http { fill: var(--warn); } .t-dot.ble { fill: var(--violet); } .t-dot.int { fill: var(--txt-2); }
.t-dot { filter: drop-shadow(0 0 6px currentColor); }
.t-wl { font: 700 19px var(--font); fill: var(--txt-2); } .t-wl.ble { fill: var(--violet); } .t-wl.dim { fill: var(--dim); font-weight: 600; }
.t-pill rect { fill: var(--acc); } .t-pill text { fill: var(--acc-ink); font: 800 17px var(--font); text-anchor: middle; }
.t-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px clamp(16px, 2vw, 40px); font-size: clamp(16px, 1.05vw, 22px); }
.t-legend li { display: flex; align-items: center; gap: .5em; }
.t-legend small { color: var(--dim); font-size: .85em; }
.t-legend i { width: 34px; height: 4px; border-radius: 2px; background: var(--acc); }
.t-legend i.wss { background: var(--info); } .t-legend i.http { background: var(--warn); }
.t-legend i.ble { background: repeating-linear-gradient(90deg, var(--violet) 0 7px, transparent 7px 12px); }

/* dispositivos */
.t-tblwrap { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: 16px; background: rgba(9, 14, 28, .78); }
.t-tbl { width: 100%; border-collapse: collapse; font-size: clamp(16px, 1.05vw, 23px); }
.t-tbl th, .t-tbl td { padding: .42em .9em; text-align: left; border-bottom: 1px solid #142039; white-space: nowrap; }
.t-tbl td:last-child { white-space: normal; color: var(--txt-2); }
.t-tbl thead th { font-size: .78em; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); background: rgba(255, 255, 255, .02); }
.t-tbl tbody th { font-family: var(--mono); font-weight: 600; color: var(--txt); }
.t-tbl tr.hl { background: linear-gradient(90deg, rgba(25, 255, 160, .12), transparent 70%); }
.t-tbl tr.hl th { color: var(--acc); }
.t-tbl tbody tr:last-child > * { border-bottom: 0; }
.t-tag { display: inline-block; font-size: .78em; font-weight: 800; letter-spacing: .06em; padding: .1em .7em; border-radius: var(--r-pill); border: 1px solid; }
.t-tag.real { color: var(--acc); border-color: var(--ok-line); background: rgba(25, 255, 160, .1); }
.t-tag.twin { color: var(--violet); border-color: #4a3a75; background: rgba(179, 140, 255, .08); }
.t-tag.api { color: var(--warn-txt); border-color: var(--warn-line); background: rgba(255, 176, 32, .08); }
.t-tag.ds { color: var(--info-txt); border-color: var(--info-line); background: rgba(74, 125, 255, .1); }

/* tópicos */
.t-topics { display: flex; justify-content: center; }
.t-tree { list-style: none; margin: 0; padding: clamp(16px, 2vw, 34px) clamp(18px, 2.4vw, 44px); border: 1px solid var(--line-strong); border-radius: 20px; background: rgba(9, 14, 28, .8); display: flex; flex-direction: column; gap: .32em; font-size: clamp(19px, 1.35vw, 30px); width: min(1300px, 100%); }
.t-tree li { position: relative; display: grid; grid-template-columns: minmax(0, 15em) minmax(0, 1fr); gap: 1em; align-items: baseline; padding-left: 2.2em; }
.t-tree li.root { display: block; padding-left: 0; color: var(--acc); font-weight: 800; }
.t-tree li:not(.root)::before { content: "├─"; position: absolute; left: .3em; color: var(--line-strong); }
.t-tree li.last::before { content: "└─"; }
.t-tree code { font: inherit; color: var(--acc); font-weight: 700; overflow-wrap: anywhere; }
.t-tree span { font-family: var(--font); color: var(--txt-2); font-size: .9em; }
.t-tree li:not(.root)::after { content: ""; position: absolute; left: 0; top: .62em; width: .45em; height: .45em; border-radius: 50%; background: var(--acc); box-shadow: 0 0 10px var(--acc); opacity: 0; animation: t-pkt 5.6s linear infinite; animation-delay: calc(var(--i, 0) * .7s); }
@keyframes t-pkt { 0% { transform: translateX(0); opacity: 0; } 3% { opacity: 1; } 14% { transform: translateX(12em); opacity: 0; } 100% { opacity: 0; } }

/* firmware y backend */
.t-mem { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(10px, 1.2vw, 22px); }
.t-mem > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .8em; padding: .6em 1em; border: 1px solid var(--line-strong); border-radius: 16px; background: rgba(9, 14, 28, .78); font-size: clamp(18px, 1.2vw, 26px); }
.t-mem span { color: var(--dim); font-weight: 700; letter-spacing: .08em; }
.t-membar { height: 14px; border-radius: var(--r-pill); background: var(--field); border: 1px solid var(--line); overflow: hidden; }
.t-membar i { display: block; height: 100%; width: var(--w); background: linear-gradient(90deg, var(--acc-3), var(--acc)); box-shadow: 0 0 10px var(--acc); animation: t-grow 1.5s var(--ease) .9s both; }
@keyframes t-grow { from { width: 0; } }
.t-mem b { color: var(--acc); }
.t-backend { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: clamp(12px, 1.6vw, 28px); align-items: center; }
.t-bignum { display: flex; flex-direction: column; align-items: center; text-align: center; padding: clamp(18px, 2vw, 36px); border-radius: 24px; border: 1px solid var(--ok-line); background: radial-gradient(circle at 50% 40%, rgba(25, 255, 160, .16), rgba(9, 14, 28, .8) 70%); }
.t-bignum b { font: 800 clamp(76px, 8vw, 170px)/1 var(--mono); color: var(--acc); text-shadow: 0 0 30px rgba(25, 255, 160, .45); }
.t-bignum span { font-size: clamp(20px, 1.4vw, 30px); color: var(--txt-2); }

/* reglas */
.t-rulegrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1vw, 16px); }
.t-rulegrid li { --c: var(--warn); display: flex; flex-direction: column; gap: .1em; padding: .55em .9em; border-radius: 14px; border: 1px solid var(--line-strong); border-left: 5px solid var(--c); background: rgba(9, 14, 28, .8); font-size: clamp(17px, 1.1vw, 24px); }
.t-rulegrid li.bad { --c: var(--bad); } .t-rulegrid li.info { --c: var(--info); } .t-rulegrid li.ok { --c: var(--acc); }
.t-rulegrid code { font: 700 1.05em var(--mono); color: var(--txt); overflow-wrap: anywhere; }
.t-rulegrid span { color: var(--txt-2); }

/* telegram */
.t-tg { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(20px, 4vw, 80px); align-items: center; }
.t-phone { width: clamp(330px, 26vw, 480px); border-radius: 34px; padding: 14px; background: #0e1621; border: 2px solid #2b3a52; box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 8px #070b12; }
.t-phone-head { display: flex; align-items: center; gap: 12px; padding: 6px 8px 12px; border-bottom: 1px solid #1d2a3c; }
.t-phone-head b { display: block; font-size: clamp(17px, 1.1vw, 22px); } .t-phone-head small { color: #6c8aa8; font-size: .8em; }
.t-ava { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--acc-ink); background: linear-gradient(160deg, var(--acc), var(--acc-3)); }
.t-chat { display: flex; flex-direction: column; gap: 10px; padding: 14px 4px 4px; }
.t-msg { position: relative; max-width: 94%; padding: .55em .8em 1.3em; border-radius: 16px 16px 16px 4px; background: #182533; font-size: clamp(15px, .95vw, 20px); line-height: 1.3; border-left: 3px solid var(--info); }
.t-msg.warn { border-left-color: var(--warn); } .t-msg.ok { border-left-color: var(--acc); }
.t-msg b { display: block; color: #e8f1ff; } .t-msg p { color: #b9c9dc; }
.t-msg time { position: absolute; right: .8em; bottom: .3em; font-size: .72em; color: #6c8aa8; }
.t-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .45em; }
.t-list li { position: relative; padding-left: 1.2em; }
.t-list li::before { content: ""; position: absolute; left: 0; top: .55em; width: .48em; height: .48em; border-radius: 50%; background: var(--acc); box-shadow: 0 0 8px var(--acc); }
.t-list.lg { font-size: clamp(22px, 1.7vw, 36px); gap: .7em; }
.t-list b { color: #fff; }

/* CI/CD */
.t-pipe { display: flex; flex-direction: column; gap: clamp(18px, 3vh, 40px); }
.t-stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(14px, 2vw, 40px); }
.t-stages li { position: relative; display: flex; flex-direction: column; gap: .35em; padding: clamp(16px, 1.6vw, 30px); border-radius: 20px; border: 1px solid var(--line-strong); background: rgba(9, 14, 28, .82); transition: border-color .3s, background .3s, opacity .3s; font-size: clamp(19px, 1.25vw, 27px); }
.t-stages li + li::before { content: ""; position: absolute; right: 100%; top: 2.3em; width: clamp(14px, 2vw, 40px); height: 4px; background: var(--line-strong); transition: background .3s; }
.t-stages b { font-size: 1.2em; }
.t-stages small { color: var(--dim); font-size: .8em; line-height: 1.3; }
.t-stage-dot { width: 2.2em; height: 2.2em; border-radius: 50%; border: 3px solid var(--line-strong); display: grid; place-items: center; font: 800 .9em var(--mono); color: var(--dim); transition: all .3s; }
.t-stage-dot::after { content: "…"; }
.t-stages li.run { border-color: var(--warn-line); }
.t-stages li.run .t-stage-dot { border-color: var(--warn); border-right-color: transparent; animation: spin .9s linear infinite; }
.t-stages li.run .t-stage-dot::after { content: ""; }
.t-stages li.ok { border-color: var(--ok-line); background: linear-gradient(160deg, rgba(25, 255, 160, .1), rgba(9, 14, 28, .82) 60%); }
.t-stages li.ok::before, .t-stages li.ok + li.run::before { background: var(--acc); }
.t-stages li.ok .t-stage-dot { border-color: var(--acc); background: var(--acc); color: var(--acc-ink); box-shadow: 0 0 16px rgba(25, 255, 160, .5); }
.t-stages li.ok .t-stage-dot::after { content: "✓"; }
.t-stages li.fail { border-color: var(--bad-line); background: linear-gradient(160deg, rgba(255, 51, 85, .14), rgba(9, 14, 28, .82) 60%); }
.t-stages li.fail .t-stage-dot { border-color: var(--bad); background: var(--bad); color: #fff; }
.t-stages li.fail .t-stage-dot::after { content: "✗"; }
.t-stages li.skip { opacity: .4; }
.t-stages li.skip .t-stage-dot::after { content: "—"; }
.t-pipe-st { font-size: clamp(18px, 1.2vw, 26px); color: var(--dim); min-height: 1.5em; }
.t-pipe-st.ok { color: var(--acc); } .t-pipe-st.bad { color: var(--bad-txt); }

/* cifras */
.t-stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 28px); }
.t-stats li { display: flex; flex-direction: column; align-items: center; text-align: center; padding: clamp(16px, 2.6vh, 40px) 12px; border-radius: 22px; border: 1px solid var(--line-strong); background: radial-gradient(circle at 50% 30%, rgba(25, 255, 160, .1), rgba(9, 14, 28, .82) 70%); }
.t-stats b { font: 800 clamp(60px, 6.4vw, 136px)/1 var(--mono); color: var(--acc); text-shadow: 0 0 28px rgba(25, 255, 160, .4); }
.t-stats span { margin-top: .3em; font-size: clamp(19px, 1.35vw, 30px); color: var(--txt-2); }

/* ---------- Globo de los pasos de foco ---------- */
.tour-tip { position: fixed; z-index: 3; left: 0; top: 0; width: 520px; max-width: calc(100vw - 20px); display: flex; flex-direction: column; border-radius: 18px; background: var(--t-glass); border: 1px solid var(--line-strong); box-shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 0 1px rgba(25, 255, 160, .1), 0 0 44px rgba(25, 255, 160, .12); opacity: 0; visibility: hidden; transition: opacity .3s var(--ease), visibility 0s linear .3s; pointer-events: auto; will-change: transform; }
.tour[data-type=chapter] .tour-tip { display: none; }
.tour-tip.on { opacity: 1; visibility: visible; transition: opacity .3s var(--ease); }
.tour-tip.on .tour-tip-in { animation: tip-in .45s var(--ease) both; }
@keyframes tip-in { from { opacity: 0; transform: translateY(10px); } }
.tour-tip-in { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: clamp(18px, 1.3vw, 26px) clamp(20px, 1.5vw, 30px); scrollbar-width: thin; }
.tour-tip h3 { margin: 0 0 .5em; font-size: 1.36em; line-height: 1.15; color: #fff; }
.tour-tip .tour-kicker { font-size: .62em; }
.tour-tip-body p + p, .tour-tip-body p + ul, .tour-tip-body ul + p, .tour-tip-body ol + p { margin-top: .6em; }
.tour-tip .mono { font-size: .92em; color: var(--acc); }
.tour-arrow { position: absolute; width: 18px; height: 18px; background: #0e182c; border: 1px solid var(--line-strong); transform: rotate(45deg); display: none; }
.tour-tip[data-side=right] .tour-arrow { display: block; left: -10px; margin-top: -9px; border-top-color: transparent; border-right-color: transparent; }
.tour-tip[data-side=left] .tour-arrow { display: block; right: -10px; margin-top: -9px; border-bottom-color: transparent; border-left-color: transparent; }
.tour-tip[data-side=bottom] .tour-arrow { display: block; top: -10px; margin-left: -9px; border-bottom-color: transparent; border-right-color: transparent; }
.tour-tip[data-side=top] .tour-arrow { display: block; bottom: -10px; margin-left: -9px; border-top-color: transparent; border-left-color: transparent; }
.t-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: .5em; }
.t-steps li { counter-increment: s; display: flex; gap: .6em; align-items: center; }
.t-rules li { flex-wrap: nowrap; align-items: center; }
.t-steps li::before { content: counter(s); flex: none; width: 1.7em; height: 1.7em; border-radius: 50%; display: grid; place-items: center; font: 800 .85em var(--mono); color: var(--acc-ink); background: var(--acc); box-shadow: 0 0 12px rgba(25, 255, 160, .5); }
.t-chiplist, .t-rules { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .45em; }
.t-chiplist li, .t-rules li { display: flex; align-items: baseline; gap: .6em; flex-wrap: wrap; }
.t-c { flex: none; min-width: 5.4em; text-align: center; font-size: .82em; font-weight: 800; padding: .05em .6em; border: 1px solid var(--ok-line); border-radius: var(--r-pill); color: var(--acc); }
.t-st { flex: none; display: inline-block; min-width: 6.6em; text-align: center; font-size: .78em; font-weight: 800; letter-spacing: .06em; padding: .12em .6em; border-radius: var(--r-pill); border: 1px solid var(--line-strong); color: var(--dim); }
.t-st.f, .t-st[data-st=focused] { color: var(--acc); border-color: var(--ok-line); background: rgba(25, 255, 160, .08); }
.t-st.d, .t-st[data-st=distracted] { color: #ff8aa0; border-color: var(--bad-line); background: rgba(255, 51, 85, .1); }
.t-st.a, .t-st[data-st=absent] { color: var(--info-txt); border-color: var(--info-line); background: rgba(74, 125, 255, .1); }
.t-live { display: flex; align-items: center; justify-content: space-between; gap: .6em; margin-top: .8em; padding: .5em .7em; border-radius: 12px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); }
.t-live .t-st { font-size: .95em; min-width: 8em; transition: all .4s; }
.t-live b { font-size: 1.2em; color: #fff; }
.t-actions { display: flex; flex-wrap: wrap; gap: .5em; margin-top: .8em; }
.t-actions.center { justify-content: center; }
.t-btn { font-size: .82em; min-height: 46px; padding: 0 1em; border-radius: 12px; border-color: var(--ok-line); background: rgba(25, 255, 160, .07); color: var(--txt); font-weight: 700; }
.t-btn.sm { min-height: 42px; }
.t-btn.on { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.t-btn.primary { background: linear-gradient(180deg, var(--acc-2), var(--acc-3)); color: var(--acc-ink); border-color: var(--acc); }
.t-btn.xl { font-size: clamp(22px, 1.6vw, 32px); min-height: 66px; padding: 0 1.4em; border-radius: 16px; box-shadow: 0 10px 40px rgba(25, 255, 160, .3); }
.t-livebox { margin-top: .8em; padding: .7em .9em; border-radius: 14px; border: 1px solid var(--warn-line); background: rgba(255, 176, 32, .07); }
.t-livebox b { display: flex; align-items: center; gap: .5em; color: var(--warn-txt); }
.t-livebox b i { width: .6em; height: .6em; border-radius: 50%; background: var(--bad); box-shadow: 0 0 10px var(--bad); animation: pulse 1.1s ease-in-out infinite; }
.t-livebox p { margin: .3em 0 .2em; font-size: .9em; color: var(--txt-2); }
.t-pers { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .45em; }
.t-pers li { padding: .45em .7em; border-radius: 12px; border: 1px solid var(--line); transition: border-color .35s, background .35s, transform .35s var(--ease); }
.t-pers li.on { border-color: var(--acc); background: rgba(25, 255, 160, .08); transform: translateX(4px); }
.t-pers b { display: block; } .t-pers li.on b { color: var(--acc); }
.t-pers q { display: block; font-style: italic; color: var(--txt-2); font-size: .9em; quotes: "«" "»"; }
.t-miss { margin-top: .6em; }

/* ---------- Guion del expositor ---------- */
.tour-notes { position: fixed; z-index: 4; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); width: min(1100px, calc(100vw - 24px)); max-height: 36vh; overflow-y: auto; padding: 16px 22px; border-radius: 16px; background: rgba(22, 16, 4, .96); border: 1px solid var(--warn-line); box-shadow: 0 20px 60px rgba(0, 0, 0, .55); pointer-events: auto; animation: tip-in .3s var(--ease); }
.tour-notes-h { font-size: clamp(13px, .8vw, 16px); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--warn); margin-bottom: 6px; }
.tour-notes p { font-size: clamp(18px, 1.15vw, 24px); color: #fff3d6; line-height: 1.45; }

/* ---------- Barra de control ---------- */
.tour-bar { position: fixed; z-index: 5; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); width: min(1500px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 10px; border-radius: 18px; background: rgba(7, 11, 22, .92); border: 1px solid var(--line-strong); box-shadow: 0 16px 50px rgba(0, 0, 0, .5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: clamp(15px, .95vw, 19px); pointer-events: auto; }
.tour-b { min-height: 48px; padding: 0 16px; border-radius: 12px; font-size: inherit; background: rgba(15, 26, 48, .9); }
.tour-b.sm { font-size: .9em; }
.tour-b[data-act=prev] { width: 52px; padding: 0; font-size: 30px; line-height: 1; }
.tour-b.next { background: linear-gradient(180deg, var(--acc-2), var(--acc-3)); border-color: var(--acc); color: var(--acc-ink); font-weight: 800; padding: 0 22px; }
.tour-b.next:hover:not(:disabled) { filter: brightness(1.1); background: linear-gradient(180deg, var(--acc-2), var(--acc-3)); }
.tour-b.armed { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 800; }
.tour-b kbd { font-size: .75em; }
.tour-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tour-chap { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tour-count { color: var(--dim); font-size: .85em; }
.tour-speaker { --c: var(--acc); display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--c); color: var(--c); font-weight: 800; background: color-mix(in srgb, var(--c) 10%, transparent); white-space: nowrap; }
.tour-speaker::before { content: "Expone"; font-weight: 600; color: var(--dim); font-size: .8em; letter-spacing: .06em; }
.tour-speaker i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); order: -1; }
.tour-speaker.sp-jaime { --c: var(--warn); } .tour-speaker.sp-juan { --c: #7fa4ff; }
.tour-sim { padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--warn); color: #1a1000; background: var(--warn); font-weight: 800; letter-spacing: .12em; font-size: .85em; animation: pulse 1.8s ease-in-out infinite; white-space: nowrap; }
.tour-gap { flex: 1; }

/* ---------- Demo: laptop baja y móvil ---------- */
@media (max-height: 820px) and (min-width: 701px) {
  .tour-ch { padding-top: 22px; }
  .tour-ch-in { gap: 14px; }
  .tour-ch-body { gap: 14px; }
  .t-tbl th, .t-tbl td { padding: .28em .8em; }
  .t-arch { max-height: calc(100dvh - 290px); }
  .t-stats li { padding: 14px 10px; }
  .t-rulegrid li { padding: .4em .8em; }
}
@media (max-width: 1200px) and (min-width: 701px) { .tour-speaker::before { display: none; } }
@media (max-width: 700px) {
  :root { --t-fs: 17px; --t-body: 17px; --t-h: 32px; }
  .tour-bar { gap: 6px 8px; padding: 8px; bottom: calc(8px + var(--safe-b)); width: calc(100vw - 16px); font-size: 14px; }
  .tour-meta { order: -3; flex: 1 1 auto; } .tour-speaker { order: -2; padding: 4px 10px; } .tour-sim { order: -1; }
  .tour-speaker::before, .tour-b kbd, [data-act=fs] { display: none; }
  .tour-gap { flex: 1 1 100%; height: 0; order: 0; }
  .tour-b { order: 1; min-height: 42px; padding: 0 12px; } .tour-b.next { flex: 1; }
  .tour-ch { padding: 20px 14px calc(140px + var(--safe-b)); }
  .tour-notes { bottom: calc(122px + var(--safe-b)); max-height: 30vh; padding: 12px 14px; }
  .t-idea, .t-idea.three, .t-trio, .t-grid2x2, .t-grid3x2, .t-backend, .t-mem, .t-rulegrid, .t-tg, .t-stages { grid-template-columns: minmax(0, 1fr); }
  .t-arrow { justify-self: center; transform: rotate(90deg); margin: 6px 0; }
  .t-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .t-stages li + li::before { display: none; }
  .t-phone { width: 100%; }
  .t-archwrap { overflow-x: auto; justify-content: flex-start; }
  .t-arch { min-width: 720px; max-height: none; }
  .t-tree li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .t-tbl { font-size: 14px; }
  .tour-tip h3 { font-size: 1.22em; }
  .landing-btn { min-width: 0; width: 100%; }
  .landing-actions { flex-direction: column; width: min(340px, 100%); }
  body.tour-on .dlg[open]:not(:modal) { left: 8px; right: 8px; width: auto; max-height: 52dvh; top: 12px; transform: none; }
}

/* ---------- Accesibilidad ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .wait > i, .wait i { animation: none; opacity: .7; }
  .tz, .landing-card > *, .landing, .tour-ch-in, .tour-tip-in, .t-arrow, .t-membar i, .t-tree li::after { animation: none !important; }
}
@media (forced-colors: active) {
  .chip i, .conn i, .toast i { forced-color-adjust: none; }
  .card, .toast { border: 1px solid CanvasText; }
}
