/* ==========================================================================
   PasswordSecure v4
   Colores y letras de la v3 publicada: fondo calido neutro, tarjetas blancas
   con sombra suave y un solo acento turquesa. Inter para el texto y los
   titulares (800), JetBrains Mono para las claves. La contrasena se lee en
   una rejilla, un caracter por casilla, con numeros y simbolos en su color.
   ========================================================================== */

/* Fuentes autoalojadas (SIL OFL 1.1), las mismas de la v3. Variables: un archivo cubre todos los pesos. */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/inter.woff2") format("woff2");
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url("fonts/jetbrains-mono.woff2") format("woff2");
}

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
    --bg: #f7f6f3;
    --surface: #ffffff;
    --sunk: #f1efe9;
    --ink: #14181d;
    --ink-2: #5b6270;
    --line: #d9d5cc;
    --line-2: #e8e5de;
    --accent: #0e6e7a;
    --accent-hover: #0b5a64;
    --accent-ink: #ffffff;
    --accent-soft: #e2eff0;
    /* Numeros en turquesa y simbolos en ambar. --digit/--symbol para texto pequeno (listas);
       las casillas son texto grande y admiten un tono mas vivo, sobre blanco. */
    --digit: #0a8191;
    --symbol: #b45f00;
    --cell-bg: #ffffff;
    --cell-digit: #0b8796;
    --cell-symbol: #c26a00;
    --lvl0: #c53b31;
    --lvl1: #9a6200;
    --lvl2: #16794f;
    --lvl3: #6144cc;
    --warn-bg: #f7ebd2;
    --warn-ink: #6b4500;
    --bad-bg: #f8e0dc;
    --bad-ink: #8a1f17;
    --good-bg: #dcefe5;
    --good-ink: #125c3c;
    --focus: #0e6e7a;

    --shadow-card: 0 1px 2px rgb(16 18 22 / .04), 0 8px 24px rgb(16 18 22 / .05);
    --shadow-lg: 0 10px 32px rgb(16 18 22 / .16);

    --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

    --wrap: 72rem;
    --gutter: clamp(16px, 4vw, 32px);
    --r-sm: 6px;
    --r: 10px;
    --r-lg: 16px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0f1216;
    --surface: #171a1f;
    --sunk: #1e2227;
    --ink: #f2f3f4;
    --ink-2: #a3abb6;
    --line: #30353c;
    --line-2: #23272d;
    --accent: #5ccfe0;
    --accent-hover: #7addea;
    --accent-ink: #06222a;
    --accent-soft: #15333a;
    --digit: #5ccfe0;
    --symbol: #f0b45a;
    --cell-bg: #0f1216;
    --cell-digit: #5ccfe0;
    --cell-symbol: #f0b45a;
    --lvl0: #ff7a6e;
    --lvl1: #eeb04a;
    --lvl2: #45d19a;
    --lvl3: #a894ff;
    --warn-bg: #3a2f17;
    --warn-ink: #f3d39a;
    --bad-bg: #3d1f1c;
    --bad-ink: #ffc2ba;
    --good-bg: #173326;
    --good-ink: #b6ead0;
    --focus: #5ccfe0;

    --shadow-card: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .22);
    --shadow-lg: 0 10px 32px rgb(0 0 0 / .45);

    color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* La barra queda fija arriba: los anclajes no deben quedar debajo */
    scroll-padding-top: 5rem;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 1.0625rem/1.6 var(--sans);
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}

img, svg { display: block; max-width: 100%; }

a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
main:focus { outline: none; }

h1, h2, h3 { font-family: var(--sans); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; margin: 0; }

p, ul, ol, table, figure, details { margin: 0; }

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

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

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.i { width: 1.15em; height: 1.15em; flex: none; }
.i--sm { width: 1em; height: 1em; }

.skip {
    position: absolute; left: var(--gutter); top: -4rem; z-index: 20;
    background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: var(--r);
}
.skip:focus { top: .75rem; color: var(--bg); }

/* --------------------------------------------------------------------------
   Barra superior
   -------------------------------------------------------------------------- */
/* Por encima del contenido: los desplegables salen de aqui */
/* Fija arriba al hacer scroll; por encima del contenido, los desplegables salen de aqui */
.bar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: var(--bg); }

.bar__in {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: .65rem var(--gutter);
    display: flex;
    align-items: center;
    gap: 1rem 1.75rem;
}

.brand {
    display: inline-flex; align-items: center; gap: .55rem;
    color: var(--ink); text-decoration: none;
    font-family: var(--mono); font-size: .95rem; font-weight: 500; letter-spacing: -.03em;
}
.brand:hover { color: var(--ink); }
.brand__mark { width: 1.6rem; height: 1.6rem; color: var(--ink); }
.brand__name b { font-weight: 700; }

.menu { flex: 1; min-width: 0; }
.menu__prefs { display: none; }

.nav ul { list-style: none; padding: 0; display: flex; gap: .25rem; }
.nav a {
    display: block; padding: .45rem .7rem; border-radius: var(--r);
    color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem; white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--sunk); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

.bar__tools { display: flex; align-items: center; gap: .25rem; }

.ibtn {
    display: inline-grid; place-items: center;
    width: 2.4rem; height: 2.4rem; padding: 0;
    border: 0; border-radius: var(--r); background: transparent; color: var(--ink); cursor: pointer;
}
.ibtn:hover { background: var(--sunk); }
.ibtn .i { width: 1.25rem; height: 1.25rem; }

/* Desplegables de idioma y tema */
.dd { position: relative; }
.ddbtn {
    display: inline-flex; align-items: center; gap: .3rem;
    height: 2.4rem; padding: 0 .5rem 0 .6rem;
    border: 0; border-radius: var(--r); background: transparent; color: var(--ink);
    font-family: var(--mono); font-size: .8rem; font-weight: 600; cursor: pointer;
}
.ddbtn:hover, .ddbtn[aria-expanded="true"] { background: var(--sunk); }
.ddbtn .i { width: 1.2rem; height: 1.2rem; }
.ddbtn .i--chev { width: .95rem; height: .95rem; color: var(--ink-2); transition: transform .15s ease; }
.ddbtn[aria-expanded="true"] .i--chev { transform: rotate(180deg); }

.dd__panel {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 25;
    min-width: 12rem; padding: .35rem;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: 0 14px 36px -14px rgb(0 0 0 / .35);
}
.js .dd__panel:not(.is-open) { display: none; }
html:not(.js) .dd--desk { display: none; }

.opts { list-style: none; padding: 0; display: grid; gap: 2px; }
.opt {
    display: flex; align-items: center; gap: .65rem; width: 100%;
    min-height: 2.6rem; padding: .45rem .65rem;
    border: 0; border-radius: var(--r); background: transparent;
    color: var(--ink); text-decoration: none; text-align: left; font-size: .95rem; cursor: pointer;
}
.opt:hover { background: var(--sunk); color: var(--ink); }
.opt .i { width: 1.15rem; height: 1.15rem; color: var(--ink-2); }
.opt__code { font-family: var(--mono); font-size: .75rem; font-weight: 600; color: var(--ink-2); width: 1.15rem; }
.opt__check { margin-left: auto; visibility: hidden; }
.opt[aria-current="true"], .opt[aria-pressed="true"] { font-weight: 600; }
.opt[aria-current="true"] .opt__check, .opt[aria-pressed="true"] .opt__check { visibility: visible; color: var(--accent); }

/* Historial (cabecera): contador como en la v3 */
.ibtn--hist { position: relative; }
.badge {
    position: absolute; top: .1rem; right: .05rem;
    min-width: 1.05rem; height: 1.05rem; padding: 0 .25rem;
    display: grid; place-items: center;
    border-radius: 999px; background: var(--sunk); color: var(--ink-2);
    font-family: var(--mono); font-size: .62rem; font-weight: 700; line-height: 1;
}
.has-items .badge { background: var(--accent); color: var(--accent-ink); }
.hist { width: min(24rem, calc(100vw - 2 * var(--gutter))); padding: .6rem; }
.hist__head { display: flex; align-items: center; gap: .5rem; padding: .1rem .2rem .45rem .35rem; }
.hist__title { font-weight: 700; font-size: .92rem; margin-right: auto; }
.hist__clear { min-height: 2.1rem; padding: .3rem .6rem; font-size: .85rem; }
.hist__list { list-style: none; padding: 0; display: grid; gap: 2px; max-height: min(22rem, 60vh); overflow-y: auto; }
.hist__list li { display: flex; align-items: center; gap: .6rem; padding: .2rem .2rem .2rem .55rem; border-radius: var(--r); }
.hist__list li:hover { background: var(--sunk); }
.hist__pw { flex: 1; min-width: 0; font-family: var(--mono); font-size: .88rem; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.hist__pw .d { color: var(--digit); }
.hist__pw .s { color: var(--symbol); }
.hist__time { font-family: var(--mono); font-size: .72rem; color: var(--ink-2); }
.hist__list .ibtn { width: 2.2rem; height: 2.2rem; }
.hist__empty { justify-content: center; padding: 1.25rem .5rem !important; color: var(--ink-2); font-size: .9rem; }
.hist__list li.hist__empty:hover { background: none; }
.hist__note { display: flex; gap: .4rem; align-items: flex-start; margin-top: .45rem; padding: .55rem .35rem 0; border-top: 1px solid var(--line-2); font-size: .78rem; color: var(--ink-2); }
.hist__note .i { margin-top: .15rem; }

/* Icono del boton de tema segun la preferencia guardada */
.t-light, .t-dark { display: none; }
[data-theme-pref="light"] .t-auto, [data-theme-pref="dark"] .t-auto { display: none; }
[data-theme-pref="light"] .t-light { display: block; }
[data-theme-pref="dark"] .t-dark { display: block; }

.menu-btn { display: none; }
.menu-btn .i--close { display: none; }
.menu-btn[aria-expanded="true"] .i--open { display: none; }
.menu-btn[aria-expanded="true"] .i--close { display: block; }

/* Movil y tableta: menu desplegable a la derecha del todo */
@media (max-width: 900px) {
    .bar__tools { margin-left: auto; }
    .dd--desk { display: none; }
    .menu-btn { display: inline-grid; }
    /* El historial se abre pegado al borde derecho de la pantalla, no al boton */
    .dd--hist { position: static; }
    .hist { right: var(--gutter); }

    .menu {
        position: absolute; right: var(--gutter); top: calc(100% + .4rem); z-index: 25;
        width: min(19rem, calc(100vw - 2 * var(--gutter)));
        max-height: calc(100vh - 5rem); overflow-y: auto;
        padding: .4rem;
        border: 1px solid var(--line); border-radius: var(--r-lg);
        background: var(--surface);
        box-shadow: 0 18px 44px -14px rgb(0 0 0 / .4);
    }
    .js .menu:not(.is-open) { display: none; }
    /* Sin JS no hay boton: el menu se ve como una lista bajo la barra */
    html:not(.js) .bar__in { flex-wrap: wrap; }
    html:not(.js) .menu { position: static; order: 3; flex-basis: 100%; width: auto; padding: 0 0 .5rem; border: 0; box-shadow: none; background: none; }
    html:not(.js) .nav ul { flex-direction: row; flex-wrap: wrap; }
    html:not(.js) .nav a { padding: .45rem .6rem; }
    html:not(.js) .menu__prefs, html:not(.js) .menu-btn { display: none; }

    .nav ul { flex-direction: column; gap: 2px; }
    .nav a { padding: .7rem .75rem; font-size: 1rem; color: var(--ink); }
    .nav a[aria-current="page"] { background: var(--sunk); box-shadow: inset 3px 0 0 var(--accent); }

    .menu__prefs { display: block; margin-top: .4rem; padding-top: .4rem; border-top: 1px solid var(--line-2); }
    .menu__h { padding: .55rem .75rem .2rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
    .menu__prefs .opts + .menu__h { margin-top: .25rem; }
}

/* Tecla del atajo dentro del boton: solo con raton y teclado */
.key {
    display: none;
    min-width: 1.35rem; padding: .05rem .3rem; margin-left: .15rem;
    font-family: var(--mono); font-size: .72rem; font-weight: 600; line-height: 1.35; text-align: center;
    border: 1px solid currentColor; border-radius: 4px; opacity: .55;
}
@media (hover: hover) and (pointer: fine) { .key { display: inline-block; } }

/* Volver arriba */
.totop {
    position: fixed; z-index: 15;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    display: grid; place-items: center;
    width: 2.9rem; height: 2.9rem; padding: 0;
    border: 1px solid var(--line); border-radius: 50%;
    background: var(--surface); color: var(--ink);
    box-shadow: 0 8px 22px -10px rgb(0 0 0 / .4);
    cursor: pointer;
    transition: opacity .2s ease, transform .2s ease;
}
.totop:hover { border-color: var(--ink-2); }
.totop .i { width: 1.25rem; height: 1.25rem; }
.totop.is-away { opacity: 0; transform: translateY(.5rem); pointer-events: none; }

/* --------------------------------------------------------------------------
   Estructura de pagina
   -------------------------------------------------------------------------- */
main { display: block; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter) 4rem; }

.crumbs { padding-top: 1.1rem; font-size: .875rem; color: var(--ink-2); }
.crumbs ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.crumbs li + li::before { content: "/"; margin-right: .3rem; color: var(--line); }
.crumbs a { color: var(--ink-2); }

.phead { padding: 2.25rem 0 1.5rem; max-width: 48rem; }
.phead h1 {
    font-size: clamp(1.85rem, 1.2rem + 2.6vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -.03em;
}
.phead .lead { margin-top: .85rem; font-size: 1.15rem; color: var(--ink-2); max-width: 40rem; }
.phead .dates { margin-top: .9rem; }

/* Tres garantias bajo la entradilla de las herramientas */
.trust { list-style: none; padding: 0; margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: .9rem; color: var(--ink-2); }
.trust li { display: inline-flex; align-items: center; gap: .4rem; }
.trust .i { color: var(--accent); }

.dates { font-size: .875rem; color: var(--ink-2); }

/* --------------------------------------------------------------------------
   Botones y controles
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 2.75rem; padding: .55rem 1.05rem;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface); color: var(--ink);
    font-weight: 600; font-size: .975rem; line-height: 1.2;
    cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }

.btn--main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--main:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--main.is-done { background: var(--good-ink); border-color: var(--good-ink); }
:root[data-theme="dark"] .btn--main.is-done { background: var(--good-ink); color: #0d1c17; }

.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); font-weight: 500; }
.btn--quiet:hover { background: var(--sunk); border-color: transparent; color: var(--ink); }

input[type="number"], input[type="text"], input[type="password"], select {
    min-height: 2.75rem; padding: .45rem .7rem;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface);
}
select { padding-right: 2rem; }

input[type="range"] { accent-color: var(--accent); width: 100%; min-width: 0; height: 2.75rem; margin: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* --------------------------------------------------------------------------
   Herramienta: lectura en casillas
   -------------------------------------------------------------------------- */
.tool { display: grid; gap: 1.25rem; }

.readout {
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    padding: clamp(.9rem, 2.5vw, 1.5rem);
    display: grid; gap: 1.1rem;
}

.cells {
    display: flex; flex-wrap: wrap; gap: 5px;
    min-height: 3.1rem;
    font-family: var(--mono); font-weight: 500;
    font-size: clamp(1.05rem, .7rem + 1.5vw, 1.72rem);
    line-height: 1;
    /* Se puede seleccionar a mano como texto continuo */
    user-select: all; -webkit-user-select: all;
    cursor: text;
}

.cell {
    display: inline-grid; place-items: center;
    width: 1.62em; height: 2.15em;
    border: 1px solid var(--line-2);
    border-bottom-color: var(--line);
    border-radius: var(--r-sm);
    background: var(--cell-bg);
    white-space: pre;
}
.cell.d { color: var(--cell-digit); }
.cell.s { color: var(--cell-symbol); }
.cell.u { font-weight: 600; }

.cells--pin { font-size: clamp(1.6rem, 1rem + 2.5vw, 2.4rem); gap: 7px; }
.cells--pin .cell { width: 1.5em; height: 1.9em; }

.cells--words { gap: 6px; font-size: clamp(1rem, .85rem + .8vw, 1.35rem); font-weight: 500; }
.word {
    display: inline-flex; align-items: center;
    min-height: 2.3em; padding: 0 .55em;
    border: 1px solid var(--line-2); border-bottom-color: var(--line);
    border-radius: var(--r-sm); background: var(--cell-bg);
    white-space: pre;
}
.sep { display: inline-flex; align-items: center; color: var(--cell-symbol); padding: 0 .05em; }

.cells.is-error { font-family: var(--sans); font-size: 1rem; color: var(--bad-ink); align-items: center; user-select: auto; }

/* El unico movimiento de la pagina: al generar, las casillas barajan un instante. */
.cell.spin { color: var(--ink-2); }

.readout__actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.readout__actions .btn--main { min-width: 9.5rem; }

.tool__grid {
    display: grid; gap: 1.25rem;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: start;
}
@media (max-width: 820px) {
    .tool__grid { grid-template-columns: minmax(0, 1fr); }
    .tool__side { order: -1; }
}

/* Las opciones van en una tarjeta, como en la v3 */
.controls {
    display: grid; gap: 1.35rem;
    padding: clamp(1rem, 2.5vw, 1.4rem);
    border: 1px solid var(--line-2); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-card);
}

.ctl { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: .55rem; }
.ctl > label, .ctl > legend, .ctl__label { font-weight: 600; font-size: .95rem; padding: 0; }

.ctl--range { grid-template-columns: minmax(0, 1fr) 5.25rem; align-items: center; column-gap: .9rem; row-gap: .1rem; }
.ctl--range > label { grid-column: 1 / -1; }
.ctl--range input[type="number"] { width: 100%; text-align: center; font-family: var(--mono); font-weight: 600; }

.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.chip { position: relative; display: block; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
    display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .55rem;
    min-height: 2.9rem; padding: .5rem .75rem;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface); color: var(--ink-2); font-weight: 500;
}
.chip span::before {
    content: ""; flex: none; width: 1.05rem; height: 1.05rem;
    border: 1.5px solid var(--ink-2); border-radius: 3px;
}
.chip small { margin-left: auto; white-space: nowrap; font-family: var(--mono); font-size: .78rem; color: var(--ink-2); }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.chip input:checked + span::before {
    border-color: var(--accent);
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 8.5 3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
:root[data-theme="dark"] .chip input:checked + span::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 8.5 3 3 6-7' fill='none' stroke='%2306222a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 380px) { .chips { grid-template-columns: minmax(0, 1fr); } }

.ctl--checks { gap: .6rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .95rem; color: var(--ink-2); cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; margin: .2rem 0 0; flex: none; }

.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
    display: grid; place-items: center; min-width: 3rem; min-height: 2.75rem; padding: 0 .6rem;
    border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
    font-family: var(--mono); font-weight: 600; color: var(--ink-2);
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.legend { font-size: .875rem; color: var(--ink-2); }
.sw {
    display: inline-grid; place-items: center; width: 1.45em; height: 1.65em; margin-right: .2em;
    border: 1px solid var(--line); border-radius: 3px; background: var(--surface);
    font-family: var(--mono); font-size: .85em; font-weight: 600; vertical-align: -.35em;
}
.sw--d { color: var(--digit); }
.sw--s { color: var(--symbol); }

.tool__side { display: grid; gap: 1rem; }

/* --------------------------------------------------------------------------
   Medidor: regla graduada en bits
   -------------------------------------------------------------------------- */
.meter {
    --lvl: var(--line);
    --pct: 0%;
    border: 1px solid var(--line-2); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-card);
    padding: 1rem 1.1rem 1.05rem;
}
.meter[data-l="0"] { --lvl: var(--lvl0); }
.meter[data-l="1"] { --lvl: var(--lvl1); }
.meter[data-l="2"] { --lvl: var(--lvl2); }
.meter[data-l="3"] { --lvl: var(--lvl3); }

.meter__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.meter__lvl { font-weight: 700; font-size: 1.1rem; color: var(--lvl); }
.meter__bits { font-family: var(--mono); font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.meter__bits b { font-size: 1.5rem; font-weight: 600; color: var(--ink); letter-spacing: -.03em; }

.scale {
    position: relative;
    height: 2.4rem; margin-top: .65rem;
    /* Graduacion: una raya cada 8 bits sobre 128 */
    background:
        repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px calc(100% / 16)) 0 0 / 100% .5rem no-repeat,
        linear-gradient(var(--sunk), var(--sunk)) 0 .5rem / 100% .55rem no-repeat;
}
.scale__fill {
    position: absolute; left: 0; top: .5rem; height: .55rem;
    width: var(--pct);
    background: var(--lvl);
    border-radius: 0 2px 2px 0;
    transition: width .25s ease, background-color .25s ease;
}
.scale__mark {
    position: absolute; top: 1.3rem;
    font-family: var(--mono); font-size: .68rem; color: var(--ink-2);
    transform: translateX(-50%);
}
.scale__mark::before {
    content: ""; position: absolute; left: 50%; top: -.85rem; width: 1px; height: .75rem; background: var(--ink-2);
}
.scale__mark--40 { left: 31.25%; }
.scale__mark--70 { left: 54.6875%; }
.scale__mark--100 { left: 78.125%; }
.scale__mark--128 { left: 100%; transform: translateX(-100%); }
.scale__mark--128::before { left: auto; right: 0; }

.meter__crack { margin-top: .55rem; font-size: .9rem; color: var(--ink-2); }
.meter__pending { font-size: .85rem; color: var(--ink-2); }

/* --------------------------------------------------------------------------
   Lista de "mas para elegir"
   -------------------------------------------------------------------------- */
.more { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: .5rem; }
.more__head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.more__head h2 { font-size: 1.05rem; margin-right: auto; }
.more__qty { display: inline-flex; align-items: center; gap: .5rem; font-size: .95rem; color: var(--ink-2); }

.more__list { list-style: none; padding: 0; margin-top: .9rem; display: grid; gap: .4rem; counter-reset: n; }
.more__list li {
    display: flex; align-items: center; gap: .75rem;
    padding: .35rem .35rem .35rem .8rem;
    border: 1px solid var(--line-2); border-radius: var(--r);
    background: var(--surface); box-shadow: 0 1px 2px rgb(16 18 22 / .04);
    counter-increment: n;
}
.more__list li::before { content: counter(n); font-family: var(--mono); font-size: .72rem; color: var(--ink-2); width: 1.4rem; flex: none; }
.more__pw { flex: 1; min-width: 0; font-family: var(--mono); font-size: .95rem; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.more__pw .d { color: var(--digit); }
.more__pw .s { color: var(--symbol); }
.more__list .ibtn { width: 2.5rem; height: 2.5rem; }
.more__list .ibtn.is-done { color: var(--good-ink); }

/* --------------------------------------------------------------------------
   Comprobador
   -------------------------------------------------------------------------- */
.probe { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: .6rem; max-width: 46rem; }
.probe > label { font-weight: 600; }
.probe__field { display: flex; gap: .5rem; }
.probe__field input {
    flex: 1; min-width: 0; min-height: 3.6rem; padding: .6rem 1rem;
    font-family: var(--mono); font-size: 1.2rem; border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
/* Edge y Safari anaden su propio boton de mostrar: ya hay uno */
.probe__field input::-ms-reveal, .probe__field input::-ms-clear { display: none; }

.probe__note { display: flex; gap: .45rem; align-items: flex-start; font-size: .875rem; color: var(--ink-2); }
.probe__note .i { margin-top: .2rem; }

.verdict { display: grid; gap: 1rem; max-width: 46rem; }
.hints { list-style: none; padding: 0; display: grid; gap: .35rem; font-size: .95rem; }
.hints:empty { display: none; }
.hints li { padding-left: 1rem; border-left: 2px solid var(--line); color: var(--ink-2); }
.hints li.hints__warn { border-left-color: var(--lvl1); color: var(--ink); font-weight: 500; }

.breach:empty { display: none; }

/* --------------------------------------------------------------------------
   Avisos
   -------------------------------------------------------------------------- */
.note { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--r); font-size: .95rem; }
.note .i { width: 1.35rem; height: 1.35rem; margin-top: .05rem; }
.note h3 { font-family: var(--sans); font-size: 1rem; font-weight: 700; letter-spacing: 0; margin-bottom: .15rem; }
.note--warn { background: var(--warn-bg); color: var(--warn-ink); }
.note--bad { background: var(--bad-bg); color: var(--bad-ink); }
.note--good { background: var(--good-bg); color: var(--good-ink); }
.note--plain { background: var(--sunk); color: var(--ink-2); }

/* --------------------------------------------------------------------------
   Texto largo (contenido de herramientas y guias)
   -------------------------------------------------------------------------- */
/* minmax(0, 1fr): sin el, una tabla ancha ensancha la columna en vez de desplazarse dentro de su caja */
.content { margin-top: 3.5rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3rem; }

.prose { max-width: 42rem; }
/* Fuera de las guias no hay indice lateral: el texto ocupa todo el ancho de la pagina */
body:not(.k-article) .phead, body:not(.k-article) .phead .lead,
body:not(.k-article) .prose, body:not(.k-article) .faq,
body:not(.k-article) .probe, body:not(.k-article) .verdict { max-width: none; }
.prose > * + * { margin-top: 1.05rem; }
.prose h2 { font-size: clamp(1.2rem, 1rem + .8vw, 1.5rem); margin-top: 2.75rem; scroll-margin-top: 1rem; }
.prose h3 { font-family: var(--sans); font-size: 1.1rem; font-weight: 700; letter-spacing: 0; margin-top: 1.9rem; }
.prose h2 + *, .prose h3 + * { margin-top: .7rem; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .4rem; }
.prose li::marker { color: var(--ink-2); }
.prose code, .prose kbd, .mono {
    font-family: var(--mono); font-size: .86em;
    background: var(--sunk); border-radius: 3px; padding: .08em .3em;
}
.prose strong { font-weight: 650; }
.prose blockquote { margin-left: 0; padding-left: 1.1rem; border-left: 3px solid var(--accent); color: var(--ink-2); }
.prose .src { font-size: .875rem; color: var(--ink-2); }

.formula {
    font-family: var(--mono); font-size: .95rem;
    padding: .9rem 1rem; border-radius: var(--r);
    background: var(--surface); border: 1px solid var(--line);
    overflow-x: auto; white-space: nowrap;
}

/* Tablas */
.tbl { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.tbl table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl caption { text-align: left; padding: .75rem .9rem .25rem; font-size: .875rem; color: var(--ink-2); }
.tbl th, .tbl td { padding: .55rem .9rem; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: baseline; }
.tbl thead th { font-size: .82rem; color: var(--ink-2); font-weight: 600; border-bottom-color: var(--line); white-space: nowrap; }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Sin padding propio: si .mono va en la celda, le quitaria el de la tabla */
.tbl .mono { background: none; }
.prose .tbl { max-width: none; }

/* Tabla grande de tiempos: ocupa el ancho del contenido, no solo el de la prosa */
.crack-wrap { display: grid; gap: .9rem; }
.crack-tbl td { font-size: .86rem; min-width: 6.25rem; line-height: 1.35; }
.crack-tbl thead th { white-space: normal; vertical-align: bottom; }
.crack-tbl th[scope="row"] { width: 1%; }
.crack-tbl th[scope="row"], .crack-tbl thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.crack-note { font-size: .875rem; color: var(--ink-2); }
.crack-tbl td[data-l="0"] { background: var(--bad-bg); color: var(--bad-ink); }
.crack-tbl td[data-l="1"] { background: var(--warn-bg); color: var(--warn-ink); }
.crack-tbl td[data-l="2"] { background: var(--good-bg); color: var(--good-ink); }
.crack-tbl td[data-l="3"] { color: var(--ink); }
.crack-tbl th[scope="row"] { font-family: var(--mono); font-weight: 600; }

.scenario { border: 0; padding: 0; margin: 0; }
.scenario legend { font-weight: 600; font-size: .95rem; margin-bottom: .5rem; }
.scenario .seg span { font-family: var(--sans); font-weight: 500; text-align: left; place-items: center start; padding: .45rem .8rem; line-height: 1.3; }
.scenario .seg small { display: block; font-size: .78rem; opacity: .85; }

/* Paso a paso */
.steps { list-style: none; padding: 0 !important; counter-reset: s; }
.steps > li { position: relative; padding-left: 2.6rem; counter-increment: s; }
.steps > li + li { margin-top: 1.1rem; }
.steps > li::before {
    content: counter(s); position: absolute; left: 0; top: -.05rem;
    display: grid; place-items: center; width: 1.85rem; height: 1.85rem;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
    font-family: var(--mono); font-weight: 600; font-size: .85rem;
}

/* Recuadro que lleva a una herramienta desde una guia */
.cta {
    display: flex; flex-wrap: wrap; align-items: center; gap: .9rem 1.25rem;
    padding: 1rem 1.15rem; border-radius: var(--r-lg);
    background: var(--accent-soft);
}
.cta p { flex: 1 1 18rem; margin: 0; }
.prose .cta { margin-top: 1.75rem; margin-bottom: 1.75rem; }

/* Ejemplo de clave en una casilla, dentro del texto */
/* Puede partirse (por los guiones de las frases): en el movil una frase larga no cabe en una linea */
.sample { font-family: var(--mono); font-size: .92em; overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; padding: .1em .35em; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); }

/* Guia con indice lateral */
.article { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1040px) {
    /* El texto llega hasta el indice: sin hueco en medio */
    .article { grid-template-columns: minmax(0, 1fr) 15rem; gap: 3rem; }
    .article .prose, .k-article .phead, .k-article .phead .lead, .k-article .faq { max-width: none; }
    .toc { position: sticky; top: 5.25rem; align-self: start; }
}
.toc { font-size: .9rem; border-left: 1px solid var(--line); padding-left: 1rem; }
.toc h2 { font-family: var(--sans); font-size: .9rem; font-weight: 700; letter-spacing: 0; margin-bottom: .5rem; }
.toc ol { list-style: none; padding: 0; display: grid; gap: .35rem; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 1039px) { .toc { display: none; } }

/* Preguntas frecuentes */
.faq { max-width: 46rem; }
.faq h2 { font-size: clamp(1.2rem, 1rem + .8vw, 1.5rem); margin-bottom: 1rem; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary {
    list-style: none; cursor: pointer;
    display: flex; justify-content: space-between; gap: 1rem;
    padding: 1rem 0; font-weight: 600;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--mono); font-weight: 400; color: var(--ink-2); }
.faq details[open] summary::after { content: "−"; }
.faq__a { padding: 0 0 1.15rem; color: var(--ink-2); }
.faq__a > * + * { margin-top: .75rem; }
.faq__a ul { padding-left: 1.2rem; }

/* Relacionadas */
.related h2 { font-size: 1.05rem; margin-bottom: 1rem; }
.related ul { list-style: none; padding: 0; display: grid; gap: 0; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); border-top: 1px solid var(--line); }
.related li { padding: 1rem 1.25rem 1.1rem 0; border-bottom: 1px solid var(--line-2); }
.related a { font-weight: 650; }
.related p { margin-top: .3rem; font-size: .92rem; color: var(--ink-2); }

/* Indice de guias */
.guide-list { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.guide-list li {
    position: relative; display: grid; gap: .4rem; align-content: start;
    padding: 1.25rem 1.35rem 1.2rem;
    border: 1px solid var(--line-2); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-card);
    transition: border-color .15s ease, transform .15s ease;
}
.guide-list li:hover { border-color: var(--accent); }
.guide-list a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.guide-list .dates { margin-top: auto; padding-top: .4rem; }
.guide-list a { font-family: var(--sans); font-weight: 700; font-size: 1.15rem; letter-spacing: -.015em; text-decoration: none; }
.guide-list a:hover { text-decoration: none; }
.guide-list a:focus-visible { outline: none; }
.guide-list li:has(a:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.guide-list p { color: var(--ink-2); max-width: 40rem; }
.guide-list .dates { font-size: .82rem; }

/* --------------------------------------------------------------------------
   Pie
   -------------------------------------------------------------------------- */
.foot { border-top: 1px solid var(--line); background: var(--sunk); font-size: .92rem; }
.foot__in {
    max-width: var(--wrap); margin: 0 auto; padding: 2.5rem var(--gutter) 1.5rem;
    display: grid; gap: 2rem;
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
}
@media (max-width: 860px) { .foot__in { grid-template-columns: repeat(2, minmax(0, 1fr)); } .foot__about { grid-column: 1 / -1; } }
@media (max-width: 420px) { .foot__in { grid-template-columns: minmax(0, 1fr); } }
.foot__about p { margin-top: .75rem; color: var(--ink-2); max-width: 26rem; }
.foot h2 { font-family: var(--sans); font-size: .92rem; font-weight: 700; letter-spacing: 0; margin-bottom: .6rem; }
.foot ul { list-style: none; padding: 0; display: grid; gap: .4rem; }
.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.foot .brand { color: var(--ink); }
.foot__legal { max-width: var(--wrap); margin: 0 auto; padding: 1rem var(--gutter) 2rem; color: var(--ink-2); font-size: .85rem; border-top: 1px solid var(--line-2); }


/* --------------------------------------------------------------------------
   Compartir y aviso flotante
   -------------------------------------------------------------------------- */
.share {
    width: min(34rem, calc(100vw - 2rem));
    padding: 1.1rem 1.2rem 1.25rem;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface); color: var(--ink);
    box-shadow: 0 18px 50px -12px rgb(0 0 0 / .35);
}
.share::backdrop { background: rgb(10 14 12 / .45); }
.share__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; }
.share__head h2 { font-size: 1.05rem; }
.share__link { display: flex; gap: .5rem; }
.share__link input { flex: 1; min-width: 0; font-size: .85rem; color: var(--ink-2); }
.share__list { list-style: none; padding: 0; margin-top: 1rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
@media (max-width: 460px) { .share__list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.share__list a {
    display: flex; align-items: center; gap: .65rem;
    min-height: 3.1rem; padding: .6rem .85rem;
    border: 1px solid var(--line); border-radius: var(--r);
    color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.share__list a:hover { border-color: var(--ink-2); background: var(--sunk); color: var(--ink); }
.share__list .i { width: 1.3rem; height: 1.3rem; }
/* Cada red con su color de marca; X y el correo van en el color del texto */
.sh--whatsapp .i { color: #25d366; }
.sh--telegram .i { color: #26a5e4; }
.sh--facebook .i { color: #0866ff; }
.sh--linkedin .i { color: #0a66c2; }
:root[data-theme="dark"] .sh--linkedin .i { color: #3b8fe0; }
:root[data-theme="dark"] .sh--facebook .i { color: #3d8bff; }
/* QR para abrir la pagina en el movil: en pantallas tactiles no tiene sentido */
.share__qr { display: flex; align-items: center; gap: 1.1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line-2); }
.share__qr img { flex: none; width: 7rem; height: 7rem; padding: .35rem; border-radius: var(--r); background: #fff; box-shadow: 0 0 0 1px var(--line-2); }
.share__qr-t { font-weight: 700; }
.share__qr-d { margin-top: .2rem; font-size: .9rem; color: var(--ink-2); }
@media (pointer: coarse) { .share__qr { display: none; } }

.toast {
    position: fixed; left: 50%; bottom: 1.25rem; z-index: 30;
    transform: translateX(-50%);
    max-width: calc(100vw - 2rem);
    padding: .7rem 1.1rem; border-radius: var(--r);
    background: var(--ink); color: var(--bg);
    font-weight: 500; font-size: .95rem;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
    .bar, .foot, .readout__actions, .more__head, .share, .toast { display: none !important; }
}
