:root {
    --paper: #f3ecdf;
    --side: #e7dccb;
    --ink: #1c2430;
    --muted: #5e675f;
    --line: #ddcfbb;
    --card: #fffaf3;
    --accent: #9c3b28;
    --accent-dark: #7c2e1f;
    --good: #1f6b45;
    --good-soft: #e5f3eb;
    --warn: #8a4b12;
    --warn-soft: #f8ead7;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    color: var(--ink);
    background: var(--paper);
    font-family: Outfit, "Segoe UI", sans-serif;
    font-size: 1rem;
    line-height: 1.4;
}

h1, h2, .brand { font-family: Fraunces, Georgia, serif; font-weight: 560; letter-spacing: -0.03em; }
h1 { font-size: clamp(1.7rem, 2.4vw, 2.5rem); line-height: 1.05; margin: 0 0 0.35rem; }
p { margin: 0 0 0.55rem; }
a { color: inherit; }

.topbar {
    height: 56px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem 0 1.15rem;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}
body { display: flex; flex-direction: column; }
.brand { color: var(--ink); text-decoration: none; font-size: 1.35rem; }
.who { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }

.workspace { flex: 1; min-height: 0; display: flex; }
.side {
    width: 300px;
    flex: none;
    overflow: auto;
    background: var(--side);
    border-right: 1px solid var(--line);
    padding: 0.75rem 0.7rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: #cfc0ab transparent;
}
.side-tools {
    display: grid;
    gap: 0.12rem;
    padding-bottom: 0.65rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid #d4c6b2;
}
.side-units { display: grid; gap: 0.12rem; }
.side-exam {
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid #d4c6b2;
}
.nav-link, .subs a, .subs span {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    border-radius: 0.65rem;
    padding: 0.38rem 0.55rem;
}
.nav-link:hover, .subs a:hover, .unit summary:hover { background: rgba(255, 250, 243, 0.62); }
.nav-link.active, .subs a.active {
    background: var(--card);
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: 600;
}
.nav-link.locked, .subs .locked, .tile.locked { color: var(--muted); }
.nav-label {
    margin: 0.55rem 0 0.35rem;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
}
.unit summary {
    display: grid;
    grid-template-columns: 1.55rem minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.35rem;
    border-radius: 0.7rem;
    cursor: pointer;
    list-style: none;
}
.unit summary::-webkit-details-marker { display: none; }
.unit summary::after {
    content: "";
    width: 0.38rem;
    height: 0.38rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    justify-self: end;
}
.unit[open] > summary::after { transform: rotate(45deg) translate(-1px, -1px); }
.unit-no {
    width: 1.55rem;
    height: 1.55rem;
    display: grid;
    place-items: center;
    border-radius: 0.45rem;
    background: rgba(255, 250, 243, 0.72);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-dark);
}
.unit[open] .unit-no, .unit.current .unit-no {
    background: var(--accent);
    color: #fffaf3;
}
.unit-name {
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}
.unit-meta { display: flex; }
.pill {
    font-style: normal;
    font-size: 0.66rem;
    font-weight: 600;
    padding: 0.12rem 0.38rem;
    border-radius: 999px;
    background: rgba(28, 36, 48, 0.07);
    color: var(--muted);
}
.pill.ok { background: var(--good-soft); color: var(--good); }
.subs {
    display: grid;
    gap: 0.08rem;
    margin: 0.1rem 0 0.35rem 0.75rem;
    padding: 0.15rem 0 0.15rem 0.65rem;
    border-left: 2px solid #d4c6b2;
}
.subs a, .subs span { font-size: 0.88rem; padding: 0.28rem 0.45rem; }
.subs a::before, .subs span::before {
    content: "";
    width: 0.38rem;
    height: 0.38rem;
    border-radius: 50%;
    background: #cfc0ab;
    flex: none;
}
.subs a.done::before { background: var(--good); }
.subs a.active::before { background: var(--accent); }
.subs .locked::before { background: transparent; box-shadow: inset 0 0 0 1.5px #cfc0ab; }
.stage {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem 1.1rem;
}

.fill, .player, .summary {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.form-only { max-width: 28rem; }
.lead, .meta { color: var(--muted); }
.eyebrow {
    margin: 0 0 0.2rem;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.row, .summary-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.stack { display: grid; gap: 0.65rem; align-content: start; }

label { display: grid; gap: 0.25rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 0.7rem;
    padding: 0.65rem 0.75rem;
    font: inherit;
    color: inherit;
}
textarea { resize: none; min-height: 5.5rem; }

[hidden] { display: none !important; }
.button, button.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    border: 0;
    border-radius: 999px;
    padding: 0.62rem 1rem;
    background: var(--accent);
    color: #fffaf3;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button .icon { width: 1.05rem; height: 1.05rem; flex: none; }
.button:disabled { opacity: 0.65; cursor: default; }
.button.tiny { padding: 0.32rem 0.7rem; font-size: 0.88rem; }
.check { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; }
.field-error { color: var(--accent); margin: 0; }
.banner { margin: 0 0 0.6rem; padding: 0.55rem 0.75rem; border-radius: 0.7rem; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--good-soft); color: var(--good); }
.admin {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.admin-grid {
    display: grid;
    grid-template-columns: minmax(14rem, 0.8fr) minmax(16rem, 1.2fr);
    gap: 0.7rem;
    flex: none;
}
.admin-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    padding: 0.9rem 1rem;
}
.admin h2 { margin: 0; font-size: 1.2rem; }
.table-wrap { overflow: auto; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td {
    text-align: left;
    padding: 0.55rem 0.45rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.user-table th {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
.user-table td:nth-child(2) { word-break: break-word; }

.stage-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
.skills { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: flex-end; }
.skills li { display: grid; gap: 0.15rem; min-width: 7.2rem; font-size: 0.78rem; color: var(--muted); }
.skills strong { color: var(--ink); }
.bar { display: block; height: 0.35rem; background: #efe4d4; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--value); background: var(--good); }

.unit-grid, .choice-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.7rem;
    align-content: stretch;
}
.unit-grid.six, .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; }
.choice-grid .button { grid-column: 1 / -1; justify-self: start; }
.tile {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    justify-content: space-between;
    text-decoration: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 0.8rem 0.9rem;
    min-height: 0;
    overflow: hidden;
}
.unit-grid > .tile { padding: 0; gap: 0; }
.tile-art {
    flex: 1 1 0;
    min-height: 4.2rem;
    position: relative;
    overflow: hidden;
    background: #f6efe4;
}
.tile-art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
}
.tile.locked .tile-art img { filter: grayscale(0.65); opacity: 0.72; }
.tile-copy {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.65rem 0.85rem 0.75rem;
    flex: none;
}
.unit-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: none;
    margin-bottom: 0.85rem;
}
.unit-hero img {
    width: 11rem;
    height: 7.2rem;
    object-fit: cover;
    border-radius: 0.9rem;
    flex: none;
}
.unit-hero h1 { margin-bottom: 0.2rem; }
.unit-hero .lead { margin-bottom: 0.45rem; }
.player-head { display: flex; align-items: center; gap: 1rem; flex: none; margin-bottom: 0.7rem; }
.player-art { width: 6.4rem; height: 6.4rem; object-fit: cover; border-radius: 0.9rem; flex: none; }
.player-title { margin-bottom: 0.15rem; }
.tile.static { cursor: default; }
.tile.done { background: var(--good-soft); }
.tile em { font-style: normal; color: var(--muted); }
.tile strong { font-size: 1rem; }
.tile span, .tile em { color: var(--muted); font-size: 0.9rem; }
.tile input { position: absolute; opacity: 0; }
.tile:has(input:checked) { outline: 2px solid var(--accent); }

#player-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.step { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.7rem; overflow: auto; }
.step-top { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.9rem; }
.prompt { font-size: clamp(1.4rem, 2vw, 2rem); margin: 0; }
.passage {
    background: #fffdf8;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    padding: 0.85rem 1rem;
    max-height: 28%;
    overflow: auto;
}
.choices { display: grid; gap: 0.45rem; align-content: start; }
.choices button, .choice-btn {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 0.8rem;
    padding: 0.72rem 2.8rem 0.72rem 0.9rem;
    min-height: 3.05rem;
    font: inherit;
    line-height: 1.35;
    color: inherit;
    cursor: pointer;
    outline: none;
    box-shadow: none;
}
.choice-btn:hover:not(:disabled) {
    background: #fffdf9;
    border-color: #cbbba6;
}
.choice-btn:focus-visible {
    border-color: var(--ink);
}
.choice-btn:disabled { cursor: default; }
.choice-label { display: block; }
.choice-btn.picked:not(.good):not(.bad) { border-color: var(--ink); }
.choice-btn.good,
.choice-btn.good:hover { background: var(--good-soft); border-color: #7eae93; }
.choice-btn.bad,
.choice-btn.bad:hover { background: var(--warn-soft); border-color: #e2b089; }
.choice-mark {
    position: absolute;
    right: 0.7rem;
    bottom: 0.5rem;
    width: 1.4rem;
    height: 1.4rem;
    display: none;
    pointer-events: none;
}
.choice-btn.good .choice-mark,
.choice-btn.bad .choice-mark { display: block; }
.choice-btn.good .choice-mark { color: var(--good); }
.choice-btn.bad .choice-mark { color: #b4332a; }
.choice-mark svg { width: 1.4rem; height: 1.4rem; display: none; }
.choice-btn.good .mark-check,
.choice-btn.bad .mark-x { display: block; }
.feedback { margin: 0; font-weight: 600; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--warn); }
.feedback .why { display: block; margin-top: 0.25rem; color: var(--ink); font-weight: 500; }
.word-step { align-items: start; }
.word-card {
    flex: none;
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr);
    width: min(100%, 42rem);
    margin: 0.15rem 0 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.05rem;
    overflow: hidden;
}
.word-art {
    width: 100%;
    height: 100%;
    min-height: 11.2rem;
    object-fit: cover;
    object-position: center 28%;
    background: #f6efe4;
}
.word-numeral {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 11.2rem;
    padding: 0.75rem;
    background: #f6efe4;
    color: var(--accent);
    font-family: Fraunces, Georgia, serif;
    font-weight: 560;
    font-size: 7rem;
    letter-spacing: -0.045em;
    line-height: 0.9;
}
.word-numeral.digits-3 { font-size: 5.4rem; }
.word-numeral.digits-4 { font-size: 3.7rem; }
.word-numeral.digits-7 { font-size: 2.05rem; letter-spacing: -0.05em; }
.word-copy { display: flex; flex-direction: column; justify-content: center; gap: 0.15rem; padding: 1rem 1.15rem 1.05rem; }
.word-en { margin: 0; font-size: clamp(1.7rem, 2.4vw, 2.25rem); line-height: 1.05; }
.word-en.long { font-size: clamp(1.2rem, 1.7vw, 1.5rem); line-height: 1.2; }
.word-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 11.2rem;
    background: #f6efe4;
    color: var(--accent);
}
.word-badge svg { width: 4.5rem; height: 4.5rem; }
.phrase-art {
    flex: none;
    height: 6.4rem;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.phrase-art svg { width: 2.8rem; height: 2.8rem; }
.word-es { margin: 0 0 0.65rem; color: var(--muted); font-size: 1.02rem; }
.word-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.word-bank { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0.28rem 0.7rem; font-weight: 600; }
.order-input { width: min(100%, 36rem); }
.step-actions { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.vocab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.vocab-grid li { display: flex; justify-content: space-between; gap: 0.8rem; background: var(--card); border: 1px solid var(--line); border-radius: 0.7rem; padding: 0.45rem 0.7rem; }
.examples { margin: 0; padding-left: 1.1rem; }
.speak-lines { list-style: none; padding-left: 0; display: grid; gap: 0.35rem; }
.speak-lines li { display: flex; align-items: center; gap: 0.5rem; }
.button.icon-button { width: 2.15rem; height: 2.15rem; padding: 0; }

.summary-head { flex: none; }
.review {
    list-style: none;
    margin: 0.4rem 0;
    padding: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.8rem;
    align-content: start;
}
.review li { display: flex; flex-direction: column; padding: 0.35rem 0.5rem; border-radius: 0.6rem; background: var(--card); }
.review .yes { background: var(--good-soft); }
.review .no { background: var(--warn-soft); }
.review .why { color: var(--ink); font-weight: 500; }
.summary-actions { flex: none; margin-top: 0.6rem; }

@media (max-width: 900px) {
    .unit-grid, .unit-grid.six, .choice-grid, .review, .vocab-grid { grid-template-columns: 1fr; }
    .stage-head { flex-direction: column; align-items: stretch; }
    .skills {
        display: grid;
        grid-template-columns: 1fr 1fr;
        justify-content: stretch;
        gap: 0.45rem 0.9rem;
    }
    .skills li { min-width: 0; }
    .eyebrow, .lead, .prompt, .word-en, .player-title { overflow-wrap: anywhere; }
    .word-card { grid-template-columns: 1fr; width: 100%; }
    .word-art, .word-numeral, .word-badge { min-height: 9.5rem; max-height: 12rem; }
    .word-actions .button { max-width: 100%; white-space: normal; text-align: center; }
    .player-head { align-items: flex-start; }
    .player-head > div, .unit-hero > div { min-width: 0; }
    .player-art { width: 4.4rem; height: 4.4rem; }
    .unit-hero { flex-direction: column; align-items: stretch; }
    .unit-hero img { width: 100%; height: 8.5rem; }
    .tile-art { flex: none; height: 7.6rem; min-height: 7.6rem; }
    .tile .button,
    .unit-hero .button,
    .form-only .button,
    .admin .button,
    .choice-grid .button,
    .summary-actions .button {
        width: 100%;
        max-width: 100%;
        white-space: normal;
        text-align: center;
    }
    .summary-actions { flex-direction: column; }
    .passage { max-height: 12rem; }
    .speak-lines li { align-items: flex-start; }
    .speak-lines li span { min-width: 0; flex: 1; }
    .admin-grid { grid-template-columns: 1fr; }
    .user-table thead { display: none; }
    .user-table, .user-table tbody, .user-table tr, .user-table td { display: block; width: auto; }
    .user-table tr + tr { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
    .user-table td { border: 0; padding: 0.12rem 0; }
    .user-table td:first-child { font-weight: 600; font-size: 1.02rem; }
    .user-table td::before {
        content: attr(data-label);
        display: block;
        margin-top: 0.28rem;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--muted);
    }
    .user-table td:first-child::before { content: none; }
    .user-table td[data-label="Correo"] { overflow-wrap: anywhere; }
}
