/*
 * Estudio de idiomas — pensado primero para un celular de 360 px: nada se sale de la
 * pantalla y todo lo que se toca mide al menos 44 px. Colores del curso de K'iche',
 * el primero del estudio.
 */
:root {
    --anil: #1c1f4a;
    --granate: #a8244f;
    --granate-sombra: #7a1838;
    --maiz: #f0b429;
    --crema: #f8f1e4;
    --tinta: #2b3452;
    --blanco: #fffdf8;
    --borde: #e3d8c4;
    --suave: #6b7290;
    --verde: #2e7d4f;
    --verde-claro: #e3f3e8;
    --rojo-claro: #fbe6ec;
    --radio: 14px;
    --toque: 44px;
    font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--tinta);
    background: var(--crema);
    -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
html:has(.login-page) { background: var(--anil); }
body { font-size: 16px; line-height: 1.45; font-weight: 500; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--suave); }

/* ── Barra superior ─────────────────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
    background: var(--anil); color: var(--crema);
}
.topbar__brand {
    display: flex; align-items: center; gap: 8px; min-height: var(--toque);
    color: var(--crema); text-decoration: none; font-weight: 700; white-space: nowrap; flex: 0 0 auto;
}
.topbar__bird { font-size: 1.3rem; }
.topbar__nav { display: flex; gap: 2px; margin-right: auto; }
.topbar__nav a {
    display: inline-flex; align-items: center; min-height: var(--toque); padding: 0 10px; border-radius: 10px;
    color: #cfd1ea; text-decoration: none; font-weight: 700; font-size: .9rem;
}
.topbar__nav a.is-current { color: var(--anil); background: var(--maiz); }
.topbar__user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
@media (max-width: 420px) { .topbar__name { display: none; } }
.topbar__name small { color: var(--maiz); }
.topbar .btn--ghost { color: var(--crema); border-color: rgba(248, 241, 228, .4); }

/* ── Página ─────────────────────────────────────────────────────────────────── */
.page { max-width: 760px; margin: 0 auto; padding: 12px 12px 96px; }
.page__title { font-size: 1.4rem; line-height: 1.2; margin: 8px 0 12px; color: var(--anil); overflow-wrap: anywhere; }
.back { display: inline-flex; align-items: center; min-height: var(--toque); color: var(--granate); font-weight: 700; text-decoration: none; }

.card {
    background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio);
    padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 0 var(--borde);
}
.empty { text-align: center; color: var(--suave); }
.note {
    margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
    background: #fdf3d6; border-left: 4px solid var(--maiz); font-size: .95rem;
}
.alert { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.alert--error { background: var(--rojo-claro); color: var(--granate-sombra); }
.alert--ok { background: var(--verde-claro); color: var(--verde); }
.alert--locked { background: var(--verde-claro); color: var(--verde); }

/* ── Botones ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--toque); min-width: var(--toque); padding: 8px 16px;
    border: 2px solid transparent; border-radius: 12px;
    font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .filter:focus-visible { outline: 3px solid var(--maiz); outline-offset: 2px; }
.btn--primary { background: var(--granate); color: #fff; box-shadow: 0 3px 0 var(--granate-sombra); }
.btn--primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--granate-sombra); }
.btn--soft { background: #e9d3db; color: var(--granate-sombra); box-shadow: none; }
.btn--approve { background: var(--verde); color: #fff; box-shadow: 0 3px 0 #1d5534; }
.btn--ghost { background: transparent; color: var(--granate); border-color: var(--borde); }
.btn--small { min-height: var(--toque); padding: 6px 12px; font-size: .9rem; }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: var(--toque); background: var(--crema); color: var(--anil); border-color: var(--borde); }
.btn--icon.is-playing { background: var(--maiz); }
.btn--danger { color: var(--granate); }
.btn--toggle { background: var(--crema); color: var(--tinta); border-color: var(--borde); }
.btn--toggle[aria-pressed="true"] { background: var(--anil); color: var(--crema); border-color: var(--anil); }

.btn--record { background: var(--granate); color: #fff; box-shadow: 0 3px 0 var(--granate-sombra); flex: 1 1 auto; }
.btn--record__dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.is-recording .btn--record { background: var(--anil); box-shadow: 0 3px 0 #0d0f2a; }
.is-recording .btn--record__dot { border-radius: 3px; background: var(--maiz); animation: pulso 1s infinite; }
@keyframes pulso { 50% { opacity: .35; } }

/* ── Formularios ────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; min-width: 0; }
.field__label { display: block; margin-bottom: 4px; font-size: .85rem; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; }
.input, .select {
    display: block; width: 100%; min-height: var(--toque); padding: 10px 12px;
    border: 2px solid var(--borde); border-radius: 12px; background: #fff; color: var(--tinta);
    font: inherit; font-size: 1.05rem; /* 16 px o más: iOS no hace zoom al tocar */
}
.input:focus { border-color: var(--anil); outline: none; }
.input--invalid { border-color: var(--granate); }
.input::placeholder { color: #9aa0b8; font-weight: 500; opacity: 1; }
.input[readonly] { background: #f4efe5; color: var(--suave); }
.field__help { margin: 4px 0 0; font-size: .85rem; color: var(--suave); }
.field__error { margin: 4px 0 0; font-size: .9rem; font-weight: 700; color: var(--granate); }
.field__error:empty { display: none; }
fieldset.field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.check {
    display: flex; align-items: flex-start; gap: 12px; min-height: var(--toque); padding: 10px 12px; margin-bottom: 6px;
    border: 2px solid var(--borde); border-radius: 12px; background: #fff; cursor: pointer;
}
.check input[type="checkbox"] { flex: 0 0 auto; width: 24px; height: 24px; margin: 0; accent-color: var(--granate); }
.check span { display: flex; flex-direction: column; min-width: 0; }
.check small { color: var(--suave); font-weight: 500; overflow-wrap: anywhere; }
.form-actions { display: flex; justify-content: flex-end; }
.form-actions .btn { flex: 1 1 auto; max-width: 320px; }
.danger-zone { margin-top: 24px; text-align: center; }
.page__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.charbar-preview { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 0; }
.charbar-preview span { padding: 2px 8px; border-radius: 8px; background: var(--crema); border: 1px solid var(--borde); font-weight: 700; color: var(--anil); }
.chip--lang { background: var(--granate); color: #fff; }
.note--lang summary { min-height: var(--toque); display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.note--lang p { margin: 4px 0 0; white-space: pre-line; }
.input:disabled { background: #f4efe5; color: var(--suave); }
.input--area { resize: none; overflow: hidden; line-height: 1.35; }
.input--target { font-size: 1.2rem; font-weight: 700; color: var(--anil); }
.select--chip { width: auto; display: inline-block; min-height: var(--toque); padding: 6px 10px; font-size: .9rem; font-weight: 700; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1 1 auto; min-width: 0; }

.charbar { display: grid; grid-template-columns: repeat(4, minmax(var(--toque), 1fr)); gap: 6px; margin-top: 6px; }
.charbar__key {
    min-width: var(--toque); min-height: var(--toque);
    border: 2px solid var(--borde); border-radius: 10px; background: var(--crema);
    font: inherit; font-size: 1.1rem; font-weight: 700; color: var(--anil); cursor: pointer;
    touch-action: manipulation;
}
.charbar__key:active:not(:disabled) { background: var(--maiz); }
.charbar__key:disabled { opacity: .45; }

.variants { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.variants:empty { display: none; }
.variant {
    display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
    padding-left: 12px; border-radius: 999px; background: #e7e8f3; color: var(--anil); font-weight: 700;
}
.variant span { overflow-wrap: anywhere; }
.variant__remove {
    width: var(--toque); height: var(--toque); border: 0; background: none; cursor: pointer;
    font-size: 1.3rem; color: var(--granate);
}

.na-box { margin-top: 8px; }

/* ── Lotes ──────────────────────────────────────────────────────────────────── */
.batch-card { display: block; color: inherit; text-decoration: none; }
.batch-card__top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.batch-card__title { margin: 8px 0; font-size: 1.15rem; color: var(--anil); overflow-wrap: anywhere; }
.batch-card__meta { margin: 6px 0 0; font-size: .9rem; color: var(--suave); }
.batch-head { margin-bottom: 8px; }

.chip {
    display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px;
    border-radius: 999px; background: var(--anil); color: var(--crema); font-size: .8rem; font-weight: 700;
}
.chip--type { background: #e7e8f3; color: var(--anil); }
.chip--open { background: var(--maiz); color: var(--anil); }
.chip--review { background: #dbe8ff; color: var(--anil); }
.chip--closed { background: #ddd; color: #444; }

.progress { position: relative; height: 10px; border-radius: 999px; background: #eadfca; overflow: hidden; }
.progress--big { height: 14px; }
.progress__done, .progress__approved { position: absolute; inset: 0 auto 0 0; border-radius: 999px; transition: width .3s; }
.progress__done { background: var(--maiz); }
.progress__approved { background: var(--verde); }

/* Filtros: envuelven en dos filas si no caben (nada se sale de la pantalla). */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.filter {
    flex: 1 1 auto; min-height: var(--toque); padding: 6px 12px; border-radius: 999px;
    border: 2px solid var(--borde); background: var(--blanco); color: var(--tinta);
    font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.filter span { color: var(--suave); font-weight: 600; }
.filter[aria-pressed="true"] { background: var(--anil); border-color: var(--anil); color: var(--crema); }
.filter[aria-pressed="true"] span { color: var(--maiz); }

/* ── Ítems ──────────────────────────────────────────────────────────────────── */
.theme__title {
    margin: 20px 0 8px; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--granate);
}
.item__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.item__key { color: var(--suave); flex: 1 1 auto; min-width: 0; }
.status { padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.status--pending { background: #eee6d6; color: var(--tinta); }
.status--translated { background: #dbe8ff; color: var(--anil); }
.status--recorded { background: var(--maiz); color: var(--anil); }
.status--approved { background: var(--verde); color: #fff; }
.item--approved, .item[data-status="approved"] { border-color: #b9dcc6; }
.item--na .input--target { text-decoration: line-through; }
.item.is-recording { border-color: var(--granate); box-shadow: 0 0 0 3px rgba(168, 36, 79, .2); }

.recorder { border-top: 1px dashed var(--borde); padding-top: 12px; margin-top: 4px; }
.recorder__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.recorder__timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--granate); min-width: 4ch; }
.meter { flex: 1 1 80px; height: 10px; border-radius: 999px; background: #eadfca; overflow: hidden; }
.meter__level { display: block; height: 100%; background: var(--granate); transform-origin: left; transform: scaleX(0); }

.takes { list-style: none; margin: 10px 0 0; padding: 0; }
.take {
    display: flex; align-items: center; gap: 8px; padding: 6px; margin-bottom: 6px;
    border: 2px solid var(--borde); border-radius: 12px; background: #fff;
}
.take--chosen { border-color: var(--maiz); background: #fff8e3; }
.take__label { flex: 1 1 auto; min-width: 0; font-weight: 700; display: flex; flex-direction: column; line-height: 1.15; }
.take__label small { color: var(--suave); font-weight: 600; }
.take__chosen { font-weight: 700; color: var(--anil); font-size: .9rem; padding: 0 4px; white-space: nowrap; }

.item__foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--borde);
}
.item__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { flex-basis: 100%; margin: 0; font-size: .85rem; color: var(--suave); }
.save { font-size: .85rem; color: var(--suave); min-height: 1em; }
.save[data-save="error"] { color: var(--granate); font-weight: 700; }
.save[data-save="pending"], .save[data-save="saving"] { color: var(--anil); }

.toast {
    position: fixed; left: 12px; right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 30;
    max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
    background: var(--anil); color: var(--crema); font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.toast--error { background: var(--granate); }

/* ── Entrar ─────────────────────────────────────────────────────────────────── */
.login-page { background: var(--anil); }
.login { max-width: 400px; margin: 0 auto; padding-top: 8vh; text-align: center; color: var(--crema); }
.login__bird { font-size: 3rem; }
.login__title { margin: 4px 0; font-size: 1.8rem; }
.login__lead { margin: 0 0 20px; color: #cfd1ea; }
.login__form { text-align: left; color: var(--tinta); }

@media (min-width: 640px) {
    .page { padding: 20px 20px 96px; }
    .card { padding: 18px; }
    .charbar { grid-template-columns: repeat(7, minmax(var(--toque), 1fr)); }
}
