/* =========================================================
   Profe de inglés — hoja de estilos
   ========================================================= */

:root {
    /* Color */
    --navy: #0b1220;
    --navy-2: #131c2e;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #5c6675;
    --muted-2: #8a93a3;
    --line: #e5e7ee;
    --line-2: #d6dae4;
    --bg: #f6f7fb;
    --card: #ffffff;
    --primary: #4338ca;
    --primary-dark: #3730a3;
    --primary-soft: #eef2ff;
    --gold: #b45309;
    --gold-soft: #fef3c7;
    --ok: #0f766e;
    --ok-soft: #e6f5f2;

    /* Forma */
    --r-xl: 24px;
    --r-lg: 18px;
    --r-md: 14px;
    --r-sm: 10px;
    --r-pill: 999px;

    /* Sombras */
    --sh-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --sh-md: 0 10px 30px rgba(15, 23, 42, .08);
    --sh-lg: 0 24px 60px rgba(15, 23, 42, .12);

    /* Tipografía */
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --serif: Georgia, "Times New Roman", serif;

    /* Medidas */
    --page: 1080px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; }

p { margin: 0; }

button { font: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

.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;
}

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11, 18, 32, .94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.topbar-inner {
    max-width: var(--page);
    margin: 0 auto;
    padding: 12px clamp(16px, 4vw, 32px);
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    margin-right: auto;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(150deg, #e8b44a, #b8802a);
    color: var(--navy);
    font-family: var(--serif);
    font-size: 21px;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}

.brand-mark--sm { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: .1px; }
.brand-text small { font-size: 10.5px; color: rgba(255, 255, 255, .55); letter-spacing: .08em; text-transform: uppercase; }

.topnav { display: flex; align-items: center; gap: 4px; }

.navlink {
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .68);
    font-size: 14px;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    text-decoration: none;
    cursor: pointer;
    transition: color .15s ease, background .15s ease;
}

.navlink:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.navlink--muted { color: rgba(255, 255, 255, .5); font-size: 13.5px; }

.tag {
    display: inline-block;
    padding: 3px 10px;
    border: 1px solid rgba(232, 180, 74, .45);
    border-radius: var(--r-pill);
    color: #e8b44a;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

/* Selector de idioma */
.idioma-form { display: flex; align-items: center; gap: 8px; }

.idioma {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
    white-space: nowrap;
}

.idioma select {
    height: 34px;
    padding: 0 8px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.idioma select option { color: #0b1220; background: #fff; }

.idioma select:focus {
    outline: 2px solid rgba(232, 180, 74, .65);
    outline-offset: 2px;
}

/* ---------- Página ---------- */
.page {
    max-width: var(--page);
    margin: 0 auto;
    padding: clamp(26px, 4vw, 48px) clamp(16px, 4vw, 32px) 72px;
}

.view { animation: aparece .28s ease; }

@keyframes aparece {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.kicker {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--gold);
}

/* ---------- Portada ---------- */
.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(30px, 5vw, 62px);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background:
        radial-gradient(120% 130% at 100% 0%, #eef2ff 0%, rgba(238, 242, 255, 0) 55%),
        radial-gradient(90% 100% at 0% 100%, #fff7e6 0%, rgba(255, 247, 230, 0) 52%),
        var(--card);
    box-shadow: var(--sh-md);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(15, 23, 42, .04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(15, 23, 42, .04) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(75% 85% at 72% 0%, #000 0%, transparent 72%);
    -webkit-mask-image: radial-gradient(75% 85% at 72% 0%, #000 0%, transparent 72%);
    pointer-events: none;
}

.hero > * { position: relative; }

.hero-title {
    font-family: var(--serif);
    font-size: clamp(36px, 6vw, 58px);
    font-weight: 600;
    line-height: 1.06;
    letter-spacing: -1.4px;
    color: var(--ink);
    max-width: 15ch;
}

.hero-title em {
    font-style: italic;
    color: var(--primary);
}

.hero-lead {
    margin: 20px 0 0;
    max-width: 56ch;
    font-size: clamp(15px, 1.7vw, 17.5px);
    color: var(--ink-2);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}

.btn-lg { min-height: 50px; padding: 13px 22px; font-size: 15.5px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(67, 56, 202, .25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(67, 56, 202, .3);
}

.btn-primary:active { transform: none; }

.btn-outline {
    background: var(--card);
    color: var(--ink);
    border-color: var(--line-2);
}

.btn-outline:hover { border-color: var(--ink-2); transform: translateY(-1px); }

.btn-arrow { font-size: 1.05em; transition: transform .15s ease; }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }

/* ---------- Estadísticas ---------- */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 34px 0 0;
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
}

.stat {
    flex: 1 1 120px;
    padding: 0 18px;
    border-left: 1px solid var(--line);
}

.stat:first-child { padding-left: 0; border-left: 0; }

.stat dt {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.stat dd {
    margin: 4px 0 0;
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    color: var(--ink);
}

/* ---------- Bloques ---------- */
.block { margin-top: clamp(38px, 5vw, 60px); }

.block-head { margin-bottom: 18px; }

.block-head h2 {
    font-family: var(--serif);
    font-size: clamp(22px, 2.6vw, 28px);
    font-weight: 600;
    letter-spacing: -.4px;
}

.block-head p { margin-top: 4px; color: var(--muted); font-size: 14.5px; }

/* ---------- Opciones ---------- */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}

.option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    color: inherit;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.option.is-open { border-color: rgba(67, 56, 202, .35); }

.option.is-open::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: linear-gradient(90deg, var(--primary), #8b7cf6);
}

.option:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: var(--sh-md);
    border-color: rgba(67, 56, 202, .45);
}

.option.is-soon { cursor: not-allowed; background: #fbfbfd; }

.option-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-num {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--muted-2);
}

.option.is-open .option-num { color: var(--primary); }

.option-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    font-size: 20px;
}

.option.is-soon .option-icon { background: #f1f2f7; filter: grayscale(1); opacity: .8; }

.option-title {
    font-family: var(--serif);
    font-size: 21px;
    font-weight: 600;
    margin-top: 4px;
}

.option-desc { font-size: 13.5px; color: var(--muted); line-height: 1.45; }

.option-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.option-state {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.option.is-open .option-state { color: var(--ok); }

.option-arrow { color: var(--primary); font-size: 18px; }
.option.is-soon .option-arrow { color: var(--muted-2); }

/* ---------- Pasos ---------- */
.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: paso;
}

.step {
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
}

.step-num {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.step h3 { margin-top: 12px; font-size: 16px; font-weight: 650; }
.step p { margin-top: 4px; font-size: 13.5px; color: var(--muted); }

/* ---------- Vocabulario ---------- */
.vocab-head { max-width: 70ch; }

.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--card);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}

.back:hover { border-color: var(--ink-2); color: var(--ink); }

.vocab-head h1 {
    font-family: var(--serif);
    font-size: clamp(30px, 4.4vw, 42px);
    font-weight: 600;
    letter-spacing: -.8px;
    line-height: 1.08;
}

.lead { margin-top: 10px; max-width: 62ch; color: var(--ink-2); font-size: 15.5px; }

/* ---------- Buscador ---------- */
.search-card {
    margin-top: 24px;
    padding: clamp(16px, 2.6vw, 22px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
}

.search {
    position: relative;
    display: flex;
    gap: 10px;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--muted-2);
    pointer-events: none;
}

.search-icon svg { width: 100%; height: 100%; display: block; }

.search input {
    flex: 1 1 auto;
    min-width: 0;
    height: 52px;
    padding: 0 16px 0 46px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.search input::placeholder { color: #a3aab8; }

.search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, .12);
}

.search .btn { height: 52px; padding: 0 22px; flex: 0 0 auto; }

.search-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
}

/* Ajustes de la IA: nivel y cantidad */
.vocab-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.mini-field { display: flex; flex-direction: column; gap: 4px; }

.mini-field span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.mini-field select {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.mini-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .12);
}

.btn-sm { min-height: 40px; padding: 8px 16px; font-size: 13.5px; }

.vocab-tools .btn-sm { margin-left: auto; }

@media (max-width: 520px) {
    .vocab-tools .btn-sm { margin-left: 0; width: 100%; }
}

.linklike {
    border: 0;
    background: none;
    padding: 0;
    color: var(--primary);
    font: inherit;
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.linklike:hover { color: var(--primary-dark); }

/* ---------- Chips ---------- */
.chips-block { margin-top: 22px; }

.chips-title {
    margin-bottom: 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--card);
    color: var(--ink-2);
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}

.chip:hover {
    border-color: rgba(67, 56, 202, .45);
    background: var(--primary-soft);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

/* ---------- Marcador de posición ---------- */
.resultado { margin-top: 26px; }

.placeholder {
    padding: 46px 24px;
    text-align: center;
    border: 1px dashed var(--line-2);
    border-radius: var(--r-lg);
    background: rgba(255, 255, 255, .6);
    color: var(--muted);
}

.placeholder-icon {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: 12px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 22px;
}

.placeholder strong { display: block; color: var(--ink); font-size: 16px; }
.placeholder p { margin-top: 4px; font-size: 13.5px; }

/* ---------- Resultado (lo genera app.js) ---------- */
.result-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
    padding: clamp(18px, 3vw, 28px);
}

.result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.fuente {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.result-head h2 {
    font-family: var(--serif);
    font-size: clamp(24px, 3.4vw, 32px);
    font-weight: 600;
    letter-spacing: -.4px;
    line-height: 1.15;
}

.result-head h2 .emoji { font-size: .85em; }

.result-desc { margin-top: 6px; max-width: 60ch; color: var(--ink-2); font-size: 14.5px; }

.result-tools { display: flex; flex-wrap: wrap; gap: 8px; }

.btn-ghost {
    padding: 8px 13px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-pill);
    background: #fff;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.btn-ghost:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }
.btn-ghost[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.meta {
    margin: 16px 0 22px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.group + .group { margin-top: 28px; }

.group h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 600;
}

.group h3 .count {
    padding: 2px 9px;
    border-radius: var(--r-pill);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 700;
}

table { width: 100%; border-collapse: collapse; font-size: 15px; }

thead th {
    padding: 7px 10px 9px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted-2);
    border-bottom: 1px solid var(--line);
}

tbody tr { border-bottom: 1px solid #f1f3f8; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }

td { padding: 11px 10px; vertical-align: top; }

td.en { width: 23%; font-weight: 650; color: var(--ink); }
td.es { width: 23%; color: var(--ink-2); }
td.ej { width: 45%; color: var(--ink-2); font-size: 13.5px; }
td.ej small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 12.5px; }
td.say { width: 9%; text-align: right; white-space: nowrap; }

.btn-say {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.btn-say:hover { transform: scale(1.08); border-color: var(--primary); background: var(--primary-soft); }
.btn-say.is-speaking { border-color: var(--primary); background: var(--primary); }

/* Modo estudio */
.result-card.oculto td.es:not(.revelado) {
    color: transparent;
    background: #eef0f6;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
}

.result-card.oculto td.es:not(.revelado)::after {
    content: "toca para ver";
    display: block;
    color: var(--muted-2);
    font-size: 10.5px;
    text-align: center;
}

.result-card.oculto tbody tr:hover { background: transparent; }

/* Estados */
.empty {
    padding: 40px 22px;
    text-align: center;
    border: 1px dashed var(--line-2);
    border-radius: var(--r-lg);
    background: rgba(255, 255, 255, .6);
    color: var(--muted);
    font-size: 14px;
}

.empty strong {
    display: block;
    margin-bottom: 6px;
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
}

.empty .chips { justify-content: center; margin-top: 16px; }

.vacio-detalle {
    margin: 8px auto 12px;
    max-width: 520px;
    color: var(--ink-2);
    font-size: 13.5px;
}

.cargando strong { animation: latido 1.4s ease-in-out infinite; }

@keyframes latido {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

.notice {
    padding: 14px 16px;
    border-radius: var(--r-sm);
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 14px;
    margin-bottom: 20px;
}

.notice.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Si el navegador no puede hablar */
.sin-voz .btn-say,
.sin-voz [data-accion="escuchar-todo"] { display: none !important; }

/* ---------- Pie ---------- */
.footer {
    background: var(--navy);
    color: rgba(255, 255, 255, .72);
    margin-top: 40px;
}

.footer-inner {
    max-width: var(--page);
    margin: 0 auto;
    padding: 34px clamp(16px, 4vw, 32px);
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    align-items: flex-start;
    justify-content: space-between;
}

.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand strong { display: block; color: #fff; font-family: var(--serif); font-size: 16px; }
.footer-brand p { font-size: 12.5px; color: rgba(255, 255, 255, .55); }

.footer-col { min-width: 140px; }

.footer-label {
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .45);
}

.footer-col p { font-size: 13.5px; color: rgba(255, 255, 255, .8); }

/* ---------- Adaptación a móvil ---------- */
@media (max-width: 860px) {
    .option-grid, .steps { grid-template-columns: 1fr; }
    .navlink--muted { display: none; }
    .topbar-extra .tag { display: none; }

    /* Cabecera en móvil: marca y selector arriba, menú en una segunda fila */
    .topbar-inner {
        padding: 10px 14px;
        gap: 10px 12px;
        flex-wrap: wrap;
    }

    .brand {
        gap: 10px;
        min-width: 0;
    }

    .topbar-extra {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
    }

    .topnav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 2px;
        padding-bottom: 2px;
    }

    .topnav::-webkit-scrollbar { display: none; }

    .navlink {
        flex: 0 0 auto;
        padding: 7px 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    .idioma > span { display: none; }

    .idioma select {
        height: 34px;
        max-width: 150px;
        font-size: 12.5px;
    }
}

@media (max-width: 520px) {
    .brand-mark {
        width: 36px;
        height: 36px;
        font-size: 18px;
        border-radius: 10px;
    }

    .brand-text strong { font-size: 15px; }
    .brand-text small { display: none; }

    .idioma select { max-width: 126px; }
    .navlink { font-size: 12.5px; padding: 7px 9px; }
}

@media (max-width: 640px) {
    body { font-size: 15px; }

    .hero { padding: 26px 20px; border-radius: var(--r-lg); }
    .hero-title { max-width: none; }

    .stats { gap: 14px 0; }
    .stat { flex: 1 1 33%; padding: 0 10px; }
    .stat dd { font-size: 24px; }

    .search { flex-direction: column; }
    .search-icon { top: 26px; }
    .search input { width: 100%; }
    .search .btn { width: 100%; }

    .result-head { flex-direction: column; }
    .result-tools { width: 100%; }
    .btn-ghost { flex: 1 1 auto; text-align: center; }

    /* Tabla como tarjetas */
    table, tbody, tr, td { display: block; width: 100%; }
    thead { display: none; }

    tbody tr {
        position: relative;
        margin-bottom: 10px;
        padding: 12px 60px 12px 14px;
        border: 1px solid var(--line);
        border-radius: var(--r-md);
        background: #fff;
    }

    tbody tr:hover { background: #fff; }
    td { padding: 2px 0; }
    td.en { font-size: 17px; }
    td.es { font-size: 14px; }
    td.es::before { content: "= "; color: var(--muted-2); }
    td.ej { margin-top: 6px; font-size: 13px; }
    td.say { position: absolute; top: 10px; right: 10px; width: auto; }

    .footer-inner { flex-direction: column; gap: 22px; }
}

/* ---------- Impresión ---------- */
@media print {
    body { background: #fff; }
    .topbar, .footer, .hero, .block, .back, .search-card, .chips-block,
    .result-tools, .btn-say, td.say, th.say, .placeholder { display: none !important; }
    .page { padding: 0; max-width: none; }
    .result-card { border: 0; box-shadow: none; padding: 0; }
    .result-card.oculto td.es { color: var(--ink-2) !important; background: transparent !important; }
    .result-card.oculto td.es::after { content: none !important; }
    tbody tr { break-inside: avoid; }
}

/* =========================================================
   Opción 2 · Escribir
   ========================================================= */

.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.mode-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    color: inherit;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.mode-card:hover {
    transform: translateY(-3px);
    border-color: rgba(67, 56, 202, .45);
    box-shadow: var(--sh-md);
}

.mode-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: var(--primary-soft);
    font-size: 22px;
}

.mode-card strong {
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.2px;
}

.mode-desc { font-size: 13.5px; color: var(--muted); line-height: 1.5; }

.mode-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--primary);
    font-size: 13.5px;
    font-weight: 600;
}

/* Panel de trabajo */
.panel {
    margin-top: 22px;
    padding: clamp(18px, 3vw, 26px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
}

.panel-head { max-width: 66ch; }

.panel-head h2 {
    font-family: var(--serif);
    font-size: clamp(21px, 2.4vw, 26px);
    font-weight: 600;
    letter-spacing: -.3px;
}

.panel-head p { margin-top: 6px; color: var(--muted); font-size: 14px; }

#es-texto {
    width: 100%;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 15.5px;
    line-height: 1.6;
    min-height: 132px;
    resize: vertical;
}

#es-texto:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, .12);
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.es-resultado { margin-top: 22px; }

/* Traducciones */
.traduccion { display: flex; flex-direction: column; gap: 8px; }

.traduccion-fila {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.15fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: #fbfcff;
}

.traduccion-es { color: var(--ink-2); font-size: 14.5px; }
.traduccion-flecha { color: var(--muted-2); font-size: 14px; }
.traduccion-resultado { display: flex; align-items: center; gap: 8px; }
.traduccion-en { font-weight: 650; color: var(--ink); }

.traduccion-pendiente {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted-2);
}

.traduccion-nota,
.traduccion-fila > small {
    grid-column: 1 / -1;
    color: var(--muted-2);
    font-size: 12px;
}

.fuente-mini {
    padding: 2px 8px;
    border-radius: var(--r-pill);
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.fuente-mini--banco { background: var(--primary-soft); color: var(--primary-dark); }

/* Deberes */
.chips .chip.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.quiz-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.quiz-title { font-family: var(--serif); font-size: 18px; font-weight: 600; }

.quiz-count {
    padding: 2px 9px;
    border-radius: var(--r-pill);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
}

.quiz-score {
    margin-left: auto;
    padding: 4px 12px;
    border-radius: var(--r-pill);
    background: var(--navy);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.quiz { display: flex; flex-direction: column; gap: 10px; }

.quiz-item {
    display: grid;
    grid-template-columns: 30px minmax(110px, .75fr) minmax(0, 1.25fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: #fff;
    transition: border-color .15s ease, background .15s ease;
}

.quiz-num {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.quiz-word {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--ink);
}

.quiz-input {
    height: 42px;
    width: 100%;
    min-width: 0;
    padding: 0 12px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 15px;
}

.quiz-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .12);
}

.quiz-verdict { font-size: 13px; line-height: 1.45; }

.quiz-item.is-ok { border-color: #a7e3c9; background: #f2fbf7; }
.quiz-item.is-bad { border-color: #f3c2c0; background: #fdf5f5; }

.quiz-verdict .ok { color: var(--ok); font-weight: 700; }
.quiz-verdict .bad { color: #b91c1c; font-weight: 700; }
.quiz-verdict .correcta { color: var(--ink); font-weight: 650; }
.quiz-verdict .nota { display: block; margin-top: 2px; color: var(--muted-2); font-size: 11.5px; }

.quiz-nota {
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--muted-2);
}

.btn-say--sm { width: 30px; height: 30px; font-size: 12.5px; }

@media (max-width: 860px) {
    .mode-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .traduccion-fila {
        grid-template-columns: 1fr auto;
        gap: 6px 10px;
    }

    .traduccion-resultado { grid-column: 1 / -1; }
    .traduccion-flecha { display: none; }
    .traduccion-fila > .fuente-mini { grid-column: 2; justify-self: end; }

    .quiz-item {
        grid-template-columns: 30px 1fr;
        gap: 8px 10px;
    }

    .quiz-input { grid-column: 1 / -1; }
    .quiz-verdict { grid-column: 1 / -1; }
    .quiz-score { margin-left: 0; }
}

/* =========================================================
   Opción 3 · Hablado
   ========================================================= */

.hablar-panel {
    margin-top: 24px;
    padding: clamp(20px, 3vw, 32px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
    text-align: center;
}

.mic {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.mic-icon {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: linear-gradient(150deg, #4f46e5, #3730a3);
    color: #fff;
    font-size: 34px;
    box-shadow: 0 14px 30px rgba(67, 56, 202, .35);
    transition: transform .15s ease, box-shadow .15s ease;
}

.mic:hover:not(:disabled) .mic-icon { transform: translateY(-2px) scale(1.02); }

.mic.is-recording .mic-icon {
    background: linear-gradient(150deg, #dc2626, #b91c1c);
    animation: pulso 1.2s infinite;
}

@keyframes pulso {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); }
    70% { box-shadow: 0 0 0 22px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.mic-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.mic.is-disabled { opacity: .5; cursor: not-allowed; }

.mic-estado {
    margin: 12px 0 0;
    min-height: 20px;
    font-size: 13px;
    color: var(--muted);
}

#hablar-texto {
    width: 100%;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 15.5px;
    line-height: 1.6;
    min-height: 96px;
    resize: vertical;
    text-align: left;
}

#hablar-texto:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, .12);
}

.hablar-panel .panel-actions { justify-content: center; }

.hablar-card {
    padding: clamp(18px, 3vw, 26px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
}

.hablar-block + .hablar-block {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.hablar-label {
    display: block;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.hablar-texto { color: var(--muted); font-size: 15px; }

.hablar-corregido {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-family: var(--serif);
    font-size: clamp(20px, 3vw, 26px);
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
}

.hablar-ok {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 11px;
    font-weight: 700;
}

.hablar-traduccion { font-size: 15.5px; color: var(--ink-2); }
.hablar-nota { font-size: 14px; color: var(--ink-2); }

.hablar-errores {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.hablar-errores li {
    padding-left: 12px;
    border-left: 3px solid var(--line-2);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-2);
}

.hablar-errores s { color: #b91c1c; text-decoration-color: #f3c2c0; }
.hablar-errores b { color: var(--ink); }
.hablar-errores .flecha { color: var(--muted-2); }

.hablar-errores .porque {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--muted);
}

@media (max-width: 640px) {
    .mic-icon { width: 78px; height: 78px; font-size: 28px; }
}

/* Opción 4 · Traducir hablando */
.mic--es .mic-icon {
    background: linear-gradient(150deg, #d97706, #b45309);
    box-shadow: 0 14px 30px rgba(180, 83, 9, .35);
}

.hablar-corregido--vacio {
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
}
