        /* =========================================================
   PALETA FUTURISTA (Dark + Neón)
   ========================================================= */
        :root {
            --bg: #0d1117;
            /* fondo global */
            --card: #1e293b;
            /* panel grafito azulado */
            --fg: #f3f4f6;
            /* texto principal */
            --muted: #9ca3af;
            /* texto secundario */
            --accent: #06b6d4;
            /* cian */
            --accent-2: #8b5cf6;
            /* violeta */
            --border: #2d3748;
            /* bordes */
            --shadow: rgba(0, 0, 0, .35);

            /* Altura uniforme para controles */
            --ctl-h: 48px;
            --ctl-inner-gap: 10px;
        }

        /* =========================================================
   RESET + BASE + FIXES MOBILE
   ========================================================= */
        * {
            box-sizing: border-box;
        }

        html,
        body {
            height: 100%;
        }

        /* Evitar zoom/scroll horizontal inicial en móvil */
        html,
        body {
            width: 100%;
            max-width: 100%;
            overflow-x: hidden;
            -webkit-text-size-adjust: 100%;
        }

        body {
            margin: 0;
            background: var(--bg);
            color: var(--fg);
            font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
        }

        ::selection {
            background: color-mix(in oklab, var(--accent) 35%, transparent);
        }

        /* Scrollbars discretos */
        * {
            scrollbar-width: thin;
            scrollbar-color: color-mix(in oklab, var(--accent)35%, transparent) transparent;
        }

        *::-webkit-scrollbar {
            height: 8px;
            width: 8px;
        }

        *::-webkit-scrollbar-thumb {
            background: color-mix(in oklab, var(--accent)35%, transparent);
            border-radius: 8px;
        }

        /* No cortar ni forzar desbordes en grids */
        .wrap,
        .row,
        .stage,
        .controls-legend-wrap {
            min-width: 0;
        }

        .row>*,
        .stage>*,
        .controls-legend-wrap>* {
            min-width: 0;
        }

        /* Inputs en móvil >=16px para evitar zoom */
        input,
        textarea,
        select {
            font-size: 16px;
        }

        @media (max-width:900px) {

            #asciiIn,
            #morseOut,
            #morseIn,
            #asciiOut {
                font-size: 16px;
            }
        }

        /* Evitar selección/copias/hints en botones/tecla */
        button,
        .btn,
        .key {
            -webkit-user-select: none;
            -moz-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
        }

        /* =========================================================
   CABECERA
   ========================================================= */
        header {
            padding: 20px 12px;
            text-align: center;
        }

        h1 {
            margin: 0 0 8px;
            font-weight: 800;
            font-size: clamp(20px, 4vw, 32px);
        }

        p.sub {
            margin: 0;
            color: var(--muted);
        }

        .kbd {
            font-family: ui-monospace, Menlo, Consolas, monospace;
            background: var(--card);
            border: 1px solid var(--border);
            padding: .2em .45em;
            border-radius: 8px;
        }

        /* =========================================================
   LAYOUT / CARDS
   ========================================================= */
        .wrap {
            max-width: 1200px;
            margin: 0 auto;
            padding: 12px;
            display: grid;
            gap: 16px;
        }

        .card {
            background: var(--card);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 12px;
            box-shadow: 0 8px 26px var(--shadow);
            overflow: hidden;
            /* evita “empujes” por sombras */
        }

        .row {
            display: grid;
            gap: 10px;
            grid-template-columns: 1fr;
        }

        @media (min-width:900px) {
            .row.two {
                grid-template-columns: 1fr 1fr;
            }

            .row.decode {
                grid-template-columns: 1fr;
            }

            /* lo maneja .stage */
        }

        /* Stage: entrada morse | salida ascii | live */
        .stage {
            display: grid;
            gap: 12px;
            grid-template-columns: 1fr;
            align-items: start;
        }

        @media (min-width:900px) {
            .stage {
                grid-template-columns: 1.1fr 1.2fr .75fr;
            }

            .stage>.outputBox {
                grid-column: 2;
            }

            .stage>.liveBox {
                grid-column: 3;
                position: sticky;
                top: 12px;
                align-self: start;
            }
        }

        /* =========================================================
   CAMPOS / TEXTOS
   ========================================================= */
        label {
            display: block;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--muted);
            margin: 4px 0 6px;
        }

        textarea {
            width: 100%;
            min-height: 120px;
            background: var(--bg);
            color: var(--fg);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px 14px;
            resize: vertical;
            transition: border-color .15s, box-shadow .15s;
        }

        textarea:focus {
            outline: none;
            border-color: color-mix(in oklab, var(--accent)60%, var(--border));
            box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent)25%, transparent);
        }

        #asciiIn,
        #morseOut,
        #morseIn,
        #asciiOut {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 15px;
            letter-spacing: .01em;
        }

        #asciiOut {
            min-height: 220px;
            line-height: 1.55;
            word-spacing: .22em;
            letter-spacing: .02em;
            padding: 16px;
        }

        /* Igualar tamaño de los textareas ASCII → Morse */
        .row.two>div textarea {
            height: 220px;
            min-height: 220px;
        }

        /* Evitar que contenido largo de cajas ensanche */
        textarea,
        input,
        .pill,
        .liveBox,
        .outputBox {
            max-width: 100%;
            overflow-wrap: anywhere;
        }

        /* =========================================================
   CONTROLES + LEGEND
   ========================================================= */
        .controls-legend-wrap {
            display: grid;
            gap: 20px;
        }

        @media (min-width:900px) {
            .controls-legend-wrap {
                grid-template-columns: 300px 1fr;
                align-items: start;
            }
        }

        /* Columna de controles */
        .controls {
            display: grid;
            grid-template-columns: 1fr;
            gap: 12px;
        }

        .controls .pill,
        .controls label.pill,
        .controls .tone-pill,
        .controls .toggle {
            min-height: var(--ctl-h);
            height: var(--ctl-h);
            padding: 0 var(--ctl-inner-gap);
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-radius: 28px;
            background: var(--bg);
            border: 1px solid var(--border);
            color: var(--muted);
        }

        /* Inputs numéricos dentro de pill */
        .controls .pill input[type="number"],
        .tone-pill input[type="number"] {
            height: calc(var(--ctl-h) - 12px);
            line-height: calc(var(--ctl-h) - 12px);
            padding: 0 12px;
            border-radius: 12px;
            text-align: center;
            background: var(--bg);
            color: var(--fg);
            border: 1px solid var(--border);
        }

        /* Stepper WPM */
        .stepper {
            display: inline-flex;
            align-items: center;
            gap: 10px;
        }

        .icon-btn {
            width: 36px;
            height: 36px;
            display: grid;
            place-items: center;
            border-radius: 10px;
            border: 1px solid var(--border);
            background: var(--bg);
            color: var(--fg);
            cursor: pointer;
        }

        .icon-btn:hover {
            filter: brightness(1.1);
        }

        .stepper-value {
            min-width: 2ch;
            text-align: center;
            font-weight: 700;
        }

        /* TONO: pill + slider */
        .tone-pill {
            gap: 12px;
        }

        .tone-pill input[type="number"] {
            width: 96px;
        }

        .controls input[type="range"],
        .controls input[type="number"] {
            width: 100%;
        }

        input[type="number"],
        input[type="text"],
        input[type="range"] {
            background: var(--bg);
            color: var(--fg);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 10px;
            outline: none;
        }

        input[type="range"] {
            padding: 0;
            height: 6px;
            accent-color: var(--accent);
        }

        /* Toggle ON/OFF */
        .toggle {
            gap: 10px;
        }

        .switch {
            --on: #10b981;
            --off: #ef4444;
            inline-size: 86px;
            block-size: calc(var(--ctl-h) - 12px);
            border-radius: 999px;
            position: relative;
            border: 1px solid var(--border);
        }

        .switch input {
            position: absolute;
            inset: 0;
            opacity: 0;
            cursor: pointer;
        }

        .switch .bg {
            position: absolute;
            inset: 0;
            border-radius: 999px;
            background: var(--off);
            transition: background .15s;
        }

        .switch .knob {
            position: absolute;
            inset: 3px auto 3px 3px;
            width: 30px;
            height: 30px;
            background: #fff;
            border-radius: 50%;
            transition: transform .2s;
            box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
        }

        .switch .label {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 12px;
            font-weight: 800;
            letter-spacing: .04em;
            color: #fff;
            font-size: 12px;
            pointer-events: none;
        }

        .switch input:checked~.knob {
            transform: translateX(38px);
        }

        .switch input:checked~.bg {
            background: var(--on);
        }

        /* Legend (texto | barra | ms) */
        .legend {
            display: grid;
            grid-template-columns: auto minmax(0, 1fr) minmax(72px, max-content);
            gap: 6px 10px;
            align-items: center;
        }

        .legend .pill {
            white-space: nowrap;
        }

        .legend .mono {
            white-space: nowrap;
            text-align: right;
            opacity: .95;
        }

        /* Barras controladas por JS/porcentaje*/
        .bar {
            height: 12px;
            border-radius: 4px;
            background: var(--accent-2);
            width: 0;
            min-width: 0;
        }


        /* =========================================================
   BOTONES
   ========================================================= */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 10px 14px;
            margin-top: 5px;
            border-radius: 12px;
            border: 1px solid var(--border);
            background: var(--accent-2);
            color: #fff;
            cursor: pointer;
            transition: filter .15s, transform .02s;
        }

        .btn:hover {
            filter: brightness(1.1);
        }

        .btn:active {
            transform: translateY(1px);
        }

        /* Pastilla genérica */
        .pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            border-radius: 999px;
            background: var(--bg);
            border: 1px solid var(--border);
            font-size: 12px;
            color: var(--muted);
            white-space: nowrap;
        }

        /* =========================================================
   KEYER
   ========================================================= */
        .keyer {
            display: grid;
            place-items: center;
            padding: 10px;
            border-radius: 14px;
            background: var(--bg);
            border: 1px dashed var(--border);
            min-height: 120px;
            touch-action: none;
        }

        .key {
            width: 100%;
            max-width: 520px;
            height: 56px;
            border-radius: 999px;
            background: var(--accent);
            border: none;
            display: grid;
            place-items: center;
            color: #fff;
            font-weight: 800;
            letter-spacing: .08em;
            text-align: center;
            transition: filter .15s, box-shadow .15s;
        }

        .key.active {
            filter: brightness(1.2);
            box-shadow: 0 0 14px color-mix(in oklab, var(--accent)60%, transparent);
        }

        /* =========================================================
   PANEL “LIVE”
   ========================================================= */
        .liveBox {
            display: grid;
            gap: 8px;
        }

        .bigLetter {
            font-size: clamp(34px, 7vw, 72px);
            line-height: 1;
            border-radius: 16px;
            background: var(--bg);
            border: 1px solid var(--border);
            text-align: center;
            padding: 14px 10px;
            font-weight: 800;
            color: var(--accent);
        }

        .meter {
            height: 10px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 999px;
            overflow: hidden;
        }

        .meter>span {
            display: block;
            height: 100%;
            background: linear-gradient(90deg, var(--accent), var(--accent-2));
            width: 0;
        }

        /* =========================================================
   UTILIDADES
   ========================================================= */
        .mono {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        }

        .muted {
            color: var(--muted);
        }

        .small {
            font-size: 12px;
        }

        /* ====== Sección de equivalencias ====== */
        .equiv {
            display: grid;
            gap: 8px;
            grid-template-columns: repeat(4, 1fr);
            /* siempre 4 columnas */
            min-width: 0;
            /* evita overflow en móvil */
        }

        .equiv .pill {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 14px;
            font-weight: 600;
            color: var(--fg);
            background: color-mix(in srgb, var(--card) 90%, #000 10%);
            border: 1px solid var(--border);
            border-radius: 999px;
            padding: 4px 8px;
            letter-spacing: 0.03em;
            min-width: 0;
            /* <-- permite encogerse en móvil */
            overflow: hidden;
            /* evita que el texto se desborde */
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* Letra/número */
        .equiv .pill strong {
            font-size: 15px;
            font-weight: 800;
            color: var(--accent-2);
            /* violeta brillante */
            margin-right: 6px;
        }

        /* Código morse */
        .equiv .pill .mono {
            font-weight: 600;
            font-size: 13px;
            color: var(--accent);
            /* cian */
        }

        .btn-link {
            display: inline-block;
            margin-left: 8px;
            padding: 4px 10px;
            font-size: 13px;
            font-weight: 600;
            color: var(--accent);
            background: color-mix(in srgb, var(--accent) 15%, transparent);
            border: 1px solid var(--accent);
            border-radius: 999px;
            text-decoration: none;
            transition: filter 0.2s ease;
        }

        .btn-link:hover {
            filter: brightness(1.2);
        }

        /* scroll suave y con margen al ancla */
        html {
            scroll-behavior: smooth;
        }

        #equiv {
            scroll-margin-top: 16px;
        }

        /* dejá 16–24px de aire al llegar */

        /* que el chip no se encime con el párrafo del header */
        header .sub {
            display: inline-flex;
            flex-wrap: wrap;
            gap: 8px 10px;
            /* espacio entre “Espacio”, “Botón” y el chip */
            align-items: center;
            justify-content: center;
            /* centrado lindo en móvil */
        }

        /* el chip como botoncito inline en desktop */
        header .sub .btn-link {
            display: inline-flex;
            align-items: center;
            white-space: nowrap;
            vertical-align: middle;
            /* evita que “suba/baje” raro con el texto */
        }

        /* en pantallas chicas, mandalo a la línea de abajo y centrado */
        @media (max-width: 520px) {
            header .sub .btn-link {
                order: 2;
                /* que quede después del texto */
                width: 100%;
                max-width: 260px;
                margin-top: 8px;
                justify-content: center;
            }
        }

        /* TOOL NAVBAR */
.tool-nav {
  background: #0e1117;
  border-bottom: 1px solid #262c36;
  padding: .65rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  display: block;
}

.tool-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tool-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: #eab308;
  text-decoration: none;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.tool-menu a {
  margin-left: 1rem;
  color: #e2e8f0;
  text-decoration: none;
  font-size: .85rem;
  padding: .25rem .4rem;
  border-radius: 4px;
}

.tool-menu a:hover {
  background: rgba(255,255,255,.06);
  color: #f1c93b;
}

/* MÓVIL */
@media (max-width: 600px) {
  .tool-container {
    flex-direction: column;
    align-items: flex-start;
    gap: .4rem;
  }
  .tool-menu a {
    margin-left: 0;
    margin-right: .6rem;
  }
}
