/* daily.css — 1 Oración al Día */

:root {
    --navy: #1b1464;
    --navy-dark: #110e40;
    --blue: #1cb0f6;
    --green: #58cc02;
    --green-dark: #46a302;
    --green-cta: #2c8801;       /* was #2e8b03 = 4.37:1 on white, below AA. This is
                               two steps darker and measures 4.54:1, so the
                               white CTA label passes in BOTH themes */
    /* hover was #359d04 = 3.51:1 on white. Darken it by the same proportion
       so the label keeps its ratio when hovered */
    --green-cta-hover: #2a7c01;
    --green-cta-shadow: #1f5f02;
    --red: #ff4b4b;
    --red-dark: #e63939;
    --gold: #ffc200;
    --gold-text: #8a6d00;
    --purple: #a560e8;
    --orange: #ff9600;
    --bg: #f7f7f7;
    --card: #ffffff;
    --line: #e5e5e5;
    --text: #3c3c3c;
    --muted: #595959;
    --correct-bg: #d7ffb8;
    --wrong-bg: #ffdfe0;

    /* --- roles split out for dark mode ---
       Each of these holds the exact light value it replaced, so light mode is
       unchanged. Dark mode is free to give each one its own value, which is the
       point: a single token cannot serve two roles across two themes. */
    --heading: #1b1464;            /* text, was --navy */
    --topbar: #fff;                /* sticky bar surfaces */
    --surface-2: #f7f9fc;
    --surface-3: #f8fafc;
    --surface-warm: #fff8e1;
    --hover: #f1f5f9;
    --hover-2: #eef2f7;
    --locked-bg: #d7dce4;
    --track: #e8edf4;
    --track-2: #e2e8f0;
    --focus-ring: #1b1464;
    /* text on the green CTA. #fff today; must not follow --card, which becomes
       a dark surface and would put dark text on a dark green button */
    --on-cta: #ffffff;
    --streak-chip: #fff3e0;
    --gems-chip: #e3f2fd;
    --hearts-chip: #fce4ec;
    /* text on a gold surface (goal button, completed nodes). #7a5c00 measured
       3.86:1 on --gold, below AA; #725000 measures 4.53:1 and keeps the bronze */
    --on-gold: #725000;
    /* the hover state is a darker gold, so it needs a darker bronze to stay
       readable: #5f3500 measures 4.60:1 where #725000 drops to 3.21:1 */
    --on-gold-hover: #5f3500;
    /* the 3D bottom edge under gold surfaces. separate from --on-gold so the
       button keeps its raised look while the label stays readable */
    --gold-edge: #d4a500;
    --gold-hover: #ffd233;

    /*
     * The three top-bar stat values.
     *
     * Each was a hardcoded hex with no dark rule, so in dark mode they were
     * measured at 3.33:1 (gems), 3.50:1 (streak) and 4.43:1 (hearts) against
     * the dark topbar. All three are darkened here to clear 4.5:1 on BOTH the
     * light topbar and the dark one, since they share a light value.
     */
    --streak-ink: #9a5800;   /* was #b36b00 = 4.18:1 on white */
    --gems-ink: #0a6ea8;     /* was #0b7ec2 = 4.40:1 on white */
    --hearts-ink: #c62828;   /* was --red #ff4b4b = 3.30:1 on white */
    --orange-ink: #a03408;   /* was #c2410c, 2.18:1 at 28px */

    /*
     * TEXT-role tokens for the brand accents.
     *
     * --blue, --green and --orange are FILL colours: they are what a disc or a
     * progress bar is painted with, and they are chosen to be vivid, not legible.
     * Used as lettering they fail badly — blue on a pale blue tint measured
     * 2.20:1, and orange on the active calendar day measured 1.91:1. Both were
     * live failures on the light theme that no gate saw, because the shop and
     * calendar modals were never opened by any measurement.
     *
     * These are the same one-token-two-roles split that --green needed, and the
     * lighter of each pair is discarded once the value below clears AA on every
     * surface it actually lands on.
     */
    --blue-ink: #0a6ea8;    /* 5.51:1 on white, 4.97:1 on the blue tint */
    --green-ink: #25750a;   /* 5.79:1 on white */

    /*
     * The focus ring. WCAG 2.4.7 needs 3:1 against BOTH the page and the card.
     *
     * No single colour does it: --gold (#ffc200) is 1.51:1 on the light page
     * and 9.03:1 on the dark one; #725000 is the reverse at 6.85 and 1.99. So
     * this is a per-theme token, like --hearts-ink. Five rules used --gold or
     * --blue here and all failed in light mode, and no gate could see it because
     * no scene ever focused anything.
     */
    --focus-ring-strong: #0a6ea8;

    /* node labels on the coloured discs. white on --green measured 2.09:1 and
       white on --blue 2.44:1, both on a 17.6px/900 numeral. */
    --on-node: #1b1464;
    --on-node-blue: #082f49;

    /*
     * The unit banner sits on --green-cta, so its labels are white on green.
     * Measured 3.89:1 and 4.09:1 with a translucent white, because the 0.88 and
     * 0.92 alphas composite toward the green underneath. Full --on-cta white
     * measures 4.54:1 on #2c8801, which clears AA.
     */
    --on-green-band: #ffffff;

    /*
     * Green used as TEXT on the page background. --green (#58cc02) is a bright
     * lime that only works as a fill, not as lettering: it measured 2.09:1 on
     * white as the ladder labels and 3.23:1 for the node tooltip. #25750a
     * measures 5.79:1 on white while staying recognisably the same green.
     */
    --green-ink: #25750a;

    /*
     * The locked badge dims itself with opacity, which multiplies whatever text
     * colour it uses. At the original 0.42 opacity, --muted composited down to
     * 1.96:1 on white and 2.17:1 on the dark card. The label needs its own
     * token because no existing muted grey survives the multiplier.
     */
    --badge-locked-ink: #3d4450;
    --blue-tint: #eaf2ff;
    --blue-tint-2: #e8f5fe;
    --blue-tint-3: #e0f2fe;
    --blue-line: #dbeafe;
    --blue-line-2: #bfdbfe;
    --amber-tint: #fff8db;
    --amber-tint-2: #fdeeb0;
    --amber-tint-3: #ffe9a8;
    --amber-tint-4: #fffbeb;
    --amber-tint-5: #ffedd5;
    --correct-tint: #effbe6;
    --correct-tint-soft: #f6fbf1;
    --correct-line: #d7efc2;
    --correct-fill: #a4ec73;
    --wrong-tint: #fff1f1;
    /* feedback TEXT, checked by check-contrast.js against the tint it sits on */
    --correct-text: #2d6a00;
    --wrong-text: #b91c1c;
    --wrong-line: #ffb2b4;
    --amber-text: #7a5c00;
    /* 3D bottom edges and outline colours. Audited by audit-dark-risk: a pale
       hairline is still a bright hairline on a dark surface. */
    --edge-raised: #cbd5e1;
    --edge-arrow: #ffffff;
    --blue-edge: #bce1fb;
    --blue-edge-2: #bae6fd;
    --blue-edge-3: #1499d6;   /* the 3D bottom edge under the blue discs */
    --amber-edge: #f2d675;
    --amber-edge-2: #fed7aa;
    --amber-edge-3: #e3c55a;
    --shadow-ambient: rgba(0, 0, 0, 0.25);
    /* the scrim behind a modal. near-black with alpha, so it dims the same way
       over a light and a dark page and needs no theme override */
    --scrim: rgba(15, 23, 42, 0.5);
    --scrim-strong: rgba(15, 23, 42, 0.75);
}

/*
 * DARK THEME
 *
 * Deep slate, slightly blue. Kept separate from the palette above so a reader
 * can see at a glance what changes.
 *
 * Brand accents (--blue --green --gold --purple --orange --red) are deliberately
 * NOT redefined: they are already vivid enough on a dark background and holding
 * them constant preserves recognition.
 */
[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0f172a;
    --card: #1e293b;
    --surface-2: #172033;
    --surface-3: #131c2e;
    --surface-warm: #1d2436;
    --topbar: #16203c;
    --line: #334155;

    --text: #e2e8f0;
    --muted: #94a3b8;
    --heading: #f1f5f9;

    /* --navy stays a surface colour only; every text use is --heading now */
    --navy: #24304f;
    --navy-dark: #16203c;

    --correct-bg: #14351c;
    --correct-tint: #16311d;
    --correct-tint-soft: #142a1a;
    --correct-line: #1f4a2a;
    --correct-fill: #4fbf3a;
    --correct-text: #a4ec73;

    --wrong-bg: #3b1214;
    --wrong-tint: #351416;
    --wrong-text: #ffb2b4;

    --amber-tint: #3a2f12;
    --amber-tint-2: #332a10;
    --amber-tint-3: #2f2810;
    --amber-tint-4: #2a2411;
    --amber-tint-5: #352b12;
    --amber-text: #ffd75e;

    --blue-tint: #14263f;
    --blue-tint-2: #12263c;
    --blue-tint-3: #152a3f;
    --blue-line: #1e4a7a;
    --blue-line-2: #1b4270;

    --locked-bg: #263449;
    --track: #263449;
    --track-2: #2b3a52;
    --focus-ring: #f1f5f9;

    --hover: #24334a;
    --hover-2: #223047;

    /* the stat chips were pale pastels; they become muted dark tints */
    --streak-chip: #3a2a12;
    --gems-chip: #12283d;
    --hearts-chip: #3a1620;

    /*
     * The stat values on the dark topbar. #9a5800 measures 4.5:1 on --topbar
     * and #0a6ea8 clears 7:1; --hearts-ink already clears both, so the
     * darkening from :root carries over.
     */
    --streak-ink: #f0a44a;
    --gems-ink: #5cc0f5;
    /* no single red can clear 4.5:1 on both white and dark navy: white needs
       luminance <= 0.172 and the dark topbar is 0.015, so the window is empty.
       --hearts-ink must therefore differ per theme, unlike the other two. */
    --hearts-ink: #ff6b6b;
    --orange-ink: #ff9a5c;
    --green-ink: #7ed957;
    /* the blue TEXT role in dark. The fill stays #1cb0f6, which is unreadable as
       lettering on the dark surfaces. */
    --blue-ink: #5cc0f5;
    /* the focus ring in dark: 8.77:1 on the dark page, 7.18:1 on the dark card */
    --focus-ring-strong: #5cc0f5;
    /* the locked badge is dimmed by opacity, so its label must start brighter
       than a normal muted grey to survive the multiplier */
    --badge-locked-ink: #cbd5e1;
    /* dark gold on hover, with its own label colour to match */
    --gold-hover: #d4a500;
    --on-gold-hover: #5f3500;

    /* edges on dark: a pale hairline reads as a bright hairline */
    --edge-raised: #3d4a63;
    --edge-arrow: #e2e8f0;
    --blue-edge: #1e4a7a;
    --blue-edge-2: #1b4270;
    --blue-edge-3: #1499d6;
    --amber-edge: #6b5518;
    --amber-edge-2: #7a5f1c;
    --amber-edge-3: #6b5518;

    --shadow-ambient: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/*
 * Comfort preferences, applied by theme.js before paint. Scaling the root font
 * size moves every rem in the app together, which is safer than overriding
 * dozens of component sizes. Capped at 125% so the fixed-width lesson footer
 * still fits a phone.
 */
html[data-text="large"] { font-size: 112.5%; }
html[data-text="xlarge"] { font-size: 125%; }

:focus-visible {
    outline: 3px solid var(--focus-ring-strong);
    outline-offset: 2px;
}

body {
    margin: 0;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3 { font-family: 'Nunito', sans-serif; font-weight: 800; color: var(--heading); margin: 0; }

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

.skip-link:focus-visible {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    width: auto;
    height: auto;
    clip: auto;
    padding: 0.75rem 1.25rem;
    background: var(--navy);
    color: #fff;
    border-radius: 0.75rem;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ---------- decorative background ---------- */
/* blobs removed — clean background instead of AI-looking gradient circles */
.bg-blob { display: none; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: var(--card);
    border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.65rem; text-decoration: none; }
.brand-img { width: 2.5rem; height: 2.5rem; border-radius: 50%; object-fit: cover; border: 2px solid var(--navy); }
.brand-name { font-family: 'Nunito', sans-serif; font-weight: 800; color: var(--heading); font-size: 1.05rem; }

.stats { display: flex; align-items: center; gap: 0.5rem; }
.theme-toggle {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.theme-toggle:hover { background: var(--hover); }

.stat { display: flex; align-items: center; gap: 0.3rem; font-weight: 800; font-size: 1rem; }
.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    font-size: 0.85rem;
    line-height: 1;
}
.stat-streak .stat-icon { background: var(--streak-chip); }
.stat-streak .stat-value { color: var(--streak-ink); }
.stat-gems .stat-icon { background: var(--gems-chip); }
.stat-gems .stat-value { color: var(--gems-ink); }
.stat-hearts .stat-icon { background: var(--hearts-chip); }
.stat-hearts .stat-value { color: var(--hearts-ink); }
.stat-hearts.hurt { animation: shake 0.4s ease; }

.stat-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0.4rem 0.65rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.85rem;
    transition: background-color 0.15s ease, transform 0.1s ease;
}
.stat-btn:hover { background: var(--hover); }
.stat-btn:active { transform: scale(0.95); }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ---------- screens ---------- */
.screen { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1.25rem 5rem; }
.hidden { display: none !important; }

/*
 * The hidden attribute must win over component display rules below
 * (.modal sets display:grid). Without this, the nickname dialog covers
 * the app permanently and setting el.hidden has no visible effect.
 */
[hidden] { display: none !important; }

/* ---------- daily goal strip ---------- */
.goal-strip {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 1rem 1.25rem;
}
.goal-ring-wrap { position: relative; width: 3.5rem; height: 3.5rem; flex: 0 0 auto; }
.goal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: #e2e8f0; stroke-width: 5; }
.ring-fill {
    fill: none;
    stroke: var(--gold);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 113;
    stroke-dashoffset: 113;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.goal-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--muted);
}
.goal-total { font-size: 0.6rem; }
.goal-copy { flex: 1; min-width: 0; }
.goal-title { margin: 0; font-weight: 700; font-size: 0.95rem; color: var(--heading); }
.goal-sub { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--muted); line-height: 1.35; }

/* ---------- buttons ---------- */
.btn {
    border: none;
    border-radius: 1rem;
    padding: 0.85rem 1.75rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.2s ease;
}
.btn:hover:not(:disabled):not(:active) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none !important; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* --on-cta, not --card: the CTA text is white on green in light mode, but
   --card becomes a dark surface in dark mode, which would put dark text on a
   dark green button. This is the same one-token-two-roles trap as --navy. */
.btn-primary { background: var(--green-cta); color: var(--on-cta); box-shadow: 0 5px 0 var(--green-cta-shadow); }
.btn-primary:hover:not(:disabled) { background: var(--green-cta-hover); }
.btn-secondary {
    background: var(--card);
    color: var(--heading);
    border: 2px solid var(--line);
    box-shadow: 0 4px 0 var(--line);
}
.btn-secondary:hover { background: var(--hover); }
.btn-goal { background: var(--gold); color: var(--on-gold); box-shadow: 0 4px 0 var(--gold-edge); white-space: nowrap; }
.btn-goal:hover { background: var(--gold-hover); color: var(--on-gold-hover); }
.btn-check { min-width: 12rem; }

.icon-btn {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 50%;
}
.icon-btn:hover { background: var(--hover-2); color: var(--heading); }

/* ---------- unit intro (Duolingo banner) ---------- */
.unit-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--green-cta);
    color: #fff;
    padding: 1.15rem 1.4rem;
    border-radius: 1.25rem;
    margin: 1.5rem 0 1.75rem;
    border-bottom: 5px solid var(--green-cta-shadow);
}
.unit-intro__text {
    flex: 1;
    min-width: 0;
}
.unit-eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--on-green-band);
}
.unit-title {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -0.01em;
    color: #fff;
}
.unit-sub {
    margin: 0.25rem 0 0;
    color: var(--on-green-band);
    font-size: 0.85rem;
    font-weight: 600;
}
.unit-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    background: var(--card);
    color: var(--heading);
    border: none;
    border-bottom: 3px solid var(--line);
    border-radius: 0.85rem;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.1s ease, background 0.15s ease;
}
.unit-guide-btn:hover {
    background: var(--surface-3);
    transform: translateY(-1px);
}
.unit-guide-btn:active {
    transform: translateY(2px);
    border-bottom-width: 1px;
}

/* ---------- lesson path ---------- */
.path { display: flex; flex-direction: column; gap: 1.1rem; padding: 1rem 0 2.5rem; }
.path-row { display: flex; justify-content: center; }
/* zig-zag by padding, not transform: a translated full-width row spilled past
   the viewport and caused a few pixels of horizontal scroll */
.path-row:nth-child(odd) { padding-right: 8rem; }
.path-row:nth-child(even) { padding-left: 8rem; }
@media (max-width: 640px) {
    .path-row:nth-child(odd) { padding-right: 4.5rem; }
    .path-row:nth-child(even) { padding-left: 4.5rem; }
}

.node {
    position: relative;
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    border: none;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 900;
    /* the numeral sits on a coloured disc, so it needs a token rather than
       white: white on --green measured 2.09:1 and white on --blue 2.44:1 at
       this size and weight. --on-node is overridden per disc below. */
    color: var(--on-node);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    box-shadow: 0 8px 0 var(--navy-dark);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.node:hover:not(.locked) { transform: translateY(-3px); }
.node:active:not(.locked) { transform: translateY(4px); box-shadow: 0 2px 0 var(--navy-dark); }
.node.current {
    background: var(--green);
    color: var(--on-node);
    box-shadow: 0 8px 0 var(--green-dark), 0 0 0 8px rgba(88, 204, 2, 0.18);
    animation: bounce-node 2s ease-in-out infinite;
}
@keyframes bounce-node {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
.node.done { background: var(--gold); color: var(--on-gold); box-shadow: 0 8px 0 var(--gold-edge); }
.node.perfect { background: var(--purple); box-shadow: 0 8px 0 #7b3db8; }
.node.locked { background: var(--locked-bg); color: #9aa5b1; box-shadow: 0 8px 0 #c3cad4; cursor: not-allowed; }
.node-star { position: absolute; top: -0.35rem; right: -0.35rem; font-size: 0.9rem; }

/* floating tooltip above active next node */
.node-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    color: var(--green-ink);
    border: 2px solid var(--line);
    border-bottom: 3px solid var(--edge-raised);
    border-radius: 0.85rem;
    padding: 0.35rem 0.85rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 8px 20px rgba(0, 39, 102, 0.12);
    white-space: nowrap;
    pointer-events: none;
    animation: tooltip-bob 1.6s ease-in-out infinite;
    z-index: 10;
}
.node-tooltip__arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--edge-raised);
}
.node-tooltip__arrow::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--edge-arrow);
}
@keyframes tooltip-bob {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -6px); }
}

.unit-marker {
    text-align: center;
    margin: 1.5rem auto 0.25rem;
    display: inline-block;
    background: var(--navy);
    color: #fff;
    border-radius: 1rem;
    padding: 0.5rem 1.25rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
/* wrap unit-marker in a centered container since it's inline-block now */
.path .unit-marker { display: block; text-align: center; background: transparent; color: var(--heading); padding: 0; margin: 1.5rem auto 2.5rem; }
.unit-marker span { display: block; font-family: 'Nunito', sans-serif; font-size: 0.72rem; font-weight: 800;
    letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 0.2rem; }

/* ---------- nickname chip ---------- */
.nick-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 9rem;
    padding: 0.5rem 0.85rem;
    min-height: 44px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--heading);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}
.nick-chip:hover { background: var(--hover); border-color: var(--blue-line-2); }
.nick-chip__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nick-chip__pencil { font-size: 0.6875rem; color: var(--muted); flex: 0 0 auto; }

@media (max-width: 30rem) {
    /* the settings modal carries the theme choice on narrow screens */
    #theme-toggle { display: none; }
    /* stats move to their own row instead of being clipped by the gear */
    .topbar { flex-wrap: wrap; row-gap: 0.4rem; }
    .stats { flex: 1 0 100%; justify-content: space-between; }
}
@media (max-width: 26rem) {
    .brand-name { display: none; }
    .nick-chip { max-width: 6rem; }
}

/* ---------- nickname modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: var(--scrim);
    backdrop-filter: blur(4px);
    animation: fade-in 0.25s ease;
}
.modal[data-mandatory="true"] {
    background: var(--scrim-strong);
    backdrop-filter: blur(8px);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal__panel {
    width: 100%;
    max-width: min(24rem, calc(100vw - 2.5rem));
    /* a grid item's automatic min-width is min-content, which let a wide
       inner grid push the dialog past the viewport edge on a phone */
    min-width: 0;
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    padding: 1.75rem;
    text-align: center;
    background: var(--card);
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    animation: modal-pop 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes modal-pop {
    from { transform: scale(0.94) translateY(0.5rem); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal__title {
    margin: 0 0 0.5rem;
    font-family: inherit;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--heading);
}
.modal__desc {
    margin: 0 0 1.5rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
}
.modal__input {
    width: 100%;
    padding: 0.8rem 1rem;
    margin-bottom: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: 0.75rem;
}
.modal__input:focus { outline: none; border-color: var(--navy); background: var(--card); }
/* the TEXT role: --red is a fill and measured 3.13:1 on --surface-2 */
.modal__error { margin: 0 0 0.75rem; font-size: 0.75rem; font-weight: 600; color: var(--wrong-text); }
.modal__submit { width: 100%; }

/* ---------- modal head + close ---------- */
.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.modal__head .modal__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 900;
}
.modal__close {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hover);
    border: none;
    border-radius: 50%;
    color: var(--muted);
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.modal__close:hover { background: var(--track-2); color: var(--heading); }

/* ---------- shop modal ---------- */
.shop-panel {
    max-width: min(26rem, calc(100vw - 2.5rem));
    min-width: 0;
    text-align: left;
    padding: 1.5rem;
}
.shop-balance {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--blue-tint-2);
    border: 2px solid var(--blue-edge);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}
.shop-balance__icon { font-size: 1.5rem; line-height: 1; }
.shop-balance__val { font-size: 1.4rem; font-weight: 900; color: var(--blue-ink); }
.shop-balance__lbl { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-left: auto; }

.shop-items { display: flex; flex-direction: column; gap: 0.85rem; }
.shop-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 1rem;
}
.shop-item__icon { font-size: 2.2rem; line-height: 1; flex-shrink: 0; }
.shop-item__info { flex: 1; min-width: 0; }
.shop-item__name { margin: 0 0 0.2rem; font-size: 0.95rem; font-weight: 900; color: var(--heading); }
.shop-item__desc { margin: 0 0 0.35rem; font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
.shop-item__status { display: inline-block; font-size: 0.72rem; font-weight: 800; color: var(--green-ink); }
.shop-item__btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 900;
    white-space: nowrap;
    flex-shrink: 0;
    border-radius: 0.85rem;
}

/* ---------- calendar / streak modal ---------- */
.cal-panel {
    max-width: min(26rem, calc(100vw - 2.5rem));
    min-width: 0;
    text-align: center;
    padding: 1.5rem;
}
.cal-hero { display: flex; flex-direction: column; align-items: center; margin-bottom: 1.1rem; }
.cal-flame {
    font-size: 3.25rem;
    line-height: 1;
    margin-bottom: 0.25rem;
    animation: flame-pulse 2s ease-in-out infinite;
}
@keyframes flame-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.cal-streak-count { margin: 0; font-size: 1.75rem; font-weight: 900; color: var(--orange-ink); }
.cal-streak-desc { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); font-weight: 600; max-width: 20rem; }

.cal-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.1rem; }
.cal-stat-pill {
    background: var(--surface-3);
    border: 2px solid var(--line);
    border-bottom-width: 3px;
    border-radius: 0.9rem;
    padding: 0.65rem 0.75rem;
    text-align: center;
}
.cal-stat-lbl { display: block; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.2rem; }
.cal-stat-val { display: block; font-size: 1.05rem; font-weight: 900; color: var(--heading); }

.cal-week { margin-bottom: 0.85rem; text-align: left; }
.cal-week__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--muted);
}
.cal-week__head strong { color: var(--heading); font-size: 0.8rem; }
.cal-week__track {
    height: 0.55rem;
    overflow: hidden;
    background: var(--track);
    border-radius: 999px;
}
.cal-week__fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--green);
    border-radius: inherit;
    transition: width 240ms ease;
}
.cal-repair {
    margin-bottom: 0.85rem;
    padding: 0.75rem;
    text-align: left;
    background: var(--amber-tint);
    border: 2px solid var(--amber-edge-2);
    border-radius: 0.8rem;
}
.cal-repair[hidden] { display: none; }
.cal-repair__text {
    margin: 0 0 0.55rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text);
}
.cal-repair .btn {
    width: 100%;
    padding: 0.55rem 0.7rem;
    font-size: 0.75rem;
}

.cal-grid-wrap {
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: 1rem;
    padding: 0.9rem;
}
.cal-month-header { font-size: 0.95rem; font-weight: 900; color: var(--heading); margin-bottom: 0.65rem; text-transform: capitalize; }
.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--muted);
    margin-bottom: 0.45rem;
}
.cal-days-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}
.cal-days-grid > * { min-width: 0; }
.cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0.65rem;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--muted);
    background: var(--surface-3);
    position: relative;
    user-select: none;
}
.cal-day--empty { background: transparent; }
.cal-day.active {
    background: var(--amber-tint-5);
    /* the TEXT role: --orange is a fill, and as lettering on the amber tint it
       measured 1.91:1. --orange-ink clears 6.13:1 on the same surface. */
    color: var(--orange-ink);
    border: 1px solid var(--amber-edge-2);
    font-weight: 900;
}
.cal-day.active::after {
    content: '🔥';
    font-size: 0.55rem;
    line-height: 1;
    position: absolute;
    bottom: 2px;
}
.cal-day.frozen {
    background: var(--blue-tint-3);
    /* the TEXT role: --blue is a fill and measured 2.13:1 on this tint */
    color: var(--blue-ink);
    border: 1px solid var(--blue-edge-2);
}
.cal-day.frozen::after {
    content: '🧊';
    font-size: 0.55rem;
    line-height: 1;
    position: absolute;
    bottom: 2px;
}
.cal-day.today { box-shadow: 0 0 0 2px var(--navy); }

/* backup / restore, deliberately inside the progress calendar */
.cal-data {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    text-align: left;
}
.cal-data__title {
    margin: 0 0 0.3rem;
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--heading);
}
.cal-data__note {
    margin: 0 0 0.7rem;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
}
.cal-data__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.cal-data__actions .btn {
    flex: 1 1 8rem;
    padding: 0.6rem 0.7rem;
    font-size: 0.72rem;
}
.cal-data__paste { margin-top: 0.6rem; }
.cal-data__paste[hidden] { display: none; }
.cal-data__textarea {
    width: 100%;
    min-height: 4.5rem;
    padding: 0.55rem 0.65rem;
    font: inherit;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: 0.6rem;
    resize: vertical;
}
.cal-data__paste .btn {
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.75rem;
}
.cal-data__status {
    min-height: 1.1rem;
    margin: 0.55rem 0 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--heading);
}

/* ---------- word bank helpers ---------- */
.bank-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.bank-counter {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.bank-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

/* the TEXT role: --red is a fill and measured 2.65:1 on --wrong-bg */
.bank-clear:hover { color: var(--wrong-text); border-color: var(--red); }

/* per-word result after a wrong attempt */
.word-chip.slot-ok {
    background: var(--correct-bg);
    border-color: var(--correct-fill);
    color: var(--correct-text);
}

.word-chip.slot-bad {
    background: var(--wrong-bg);
border-color: var(--wrong-line);
    /* the TEXT role. A hardcoded #c92a2a bypassed --wrong-text, which exists
       precisely for this and clears AA on the tint it sits on. */
    color: var(--wrong-text);
}

.bank-hint {
    margin: 0.9rem 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

/* ---------- level ladder ---------- */
.level-card {
    padding: 1.35rem;
    margin-bottom: 1.5rem;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
}
.level-card__head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.1rem; }
.level-card__emoji { font-size: 2.1rem; line-height: 1; }
.level-card__who { flex: 1; min-width: 0; }
.level-card__label {
    margin: 0;
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}
.level-card__name { margin: 0.1rem 0 0; font-family: inherit; font-weight: 900; font-size: 1.375rem; color: var(--heading); }
.level-card__xp { font-size: 1.1rem; font-weight: 800; color: var(--heading); white-space: nowrap; }
.level-card__xp-max { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

.level-track { height: 0.7rem; background: var(--track); border-radius: 999px; overflow: hidden; }
.level-track__fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #58cc02, var(--correct-fill));
    transition: width 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}
.level-card__goal { margin: 0.65rem 0 0; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }

.ladder {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
    list-style: none;
    padding: 0.9rem 0 0;
    margin: 0.9rem 0 0;
    border-top: 1px solid var(--line);
}
.ladder li {
    flex: 1;
    text-align: center;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--muted);
    opacity: 0.55;
    transition: opacity 0.3s ease, color 0.3s ease;
}
.ladder li.reached { opacity: 1; color: var(--green-ink); }
.ladder li.current { opacity: 1; color: var(--heading); }
.ladder li.current::after {
    content: '\25B2';
    display: block;
    margin-top: 0.2rem;
    font-size: 0.5rem;
    color: var(--heading);
}

/* ---------- rivals ---------- */
.rivals {
    padding: 1.35rem;
    margin-bottom: 1.5rem;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
}
.rivals__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.rivals__title { margin: 0; font-family: inherit; font-weight: 900; font-size: 1.125rem; color: var(--heading); }
.rivals__note { margin: 0; font-size: 0.6875rem; color: var(--muted); }

.rivals__list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }

.rival {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.75rem;
    background: var(--surface-2);
}
.rival--you { background: var(--blue-tint); border: 1px solid var(--blue-line-2); font-weight: 700; }
.rival--above { background: var(--surface-warm); }

.rival__rank { width: 1.35rem; flex: 0 0 auto; font-size: 0.75rem; font-weight: 800; color: var(--muted); text-align: center; }
.rival__face {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 50%;
}
.rival--you .rival__face { border-color: #93c5fd; }
.rival__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: var(--text);
}
.rival--you .rival__name { color: var(--heading); }
.rival__tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--heading);
    background: var(--blue-line);
    border-radius: 99px;
    vertical-align: middle;
}
.rival__xp { flex: 0 0 auto; font-size: 0.8125rem; font-weight: 800; color: var(--muted); }
.rival--you .rival__xp { color: var(--heading); }

/* ---------- placement test ---------- */
.modal__emoji { font-size: 2.5rem; line-height: 1; margin-bottom: 0.75rem; }

.modal__hint {
    margin: 0 0 1.5rem;
    padding: 0.75rem 0.9rem;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 0.6rem;
    text-align: left;
}

.modal__link {
    display: block;
    width: 100%;
    margin-top: 0.9rem;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.modal__link:hover { color: var(--heading); }

/* ---------- settings modal ---------- */
.settings-panel {
    max-width: min(27rem, calc(100vw - 2.5rem));
    min-width: 0;
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    text-align: left;
    padding: 1.35rem;
}
.settings-group {
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}
.settings-legend {
    margin-bottom: 0.3rem;
    padding: 0;
    font-size: 0.8rem;
    font-weight: 900;
    color: var(--heading);
}
.settings-help {
    margin: 0 0 0.55rem;
    font-size: 0.7rem;
    line-height: 1.45;
    color: var(--muted);
}
.settings-options {
    display: grid;
    gap: 0.4rem;
}
.settings-options--row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.settings-options--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* 125% text needs more room per choice; three across clips the labels */
html[data-text="xlarge"] .settings-options--row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.settings-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    min-height: 44px;
    padding: 0.45rem 0.55rem;
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: 0.65rem;
    cursor: pointer;
}
.settings-option:has(input:checked) {
    border-color: var(--blue);
    background: var(--hover);
}
.settings-option input {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    accent-color: var(--navy);
}
.settings-option span { min-width: 0; }
.settings-option strong {
    display: block;
    font-size: 0.74rem;
    color: var(--heading);
}
.settings-option small {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.65rem;
    line-height: 1.3;
    color: var(--muted);
}
.settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.55rem 0;
    cursor: pointer;
}
.settings-toggle input {
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
    margin-top: 0.15rem;
    accent-color: var(--navy);
}
.settings-toggle strong {
    display: block;
    font-size: 0.76rem;
    color: var(--heading);
}
.settings-toggle small {
    display: block;
    margin-top: 0.12rem;
    font-size: 0.66rem;
    line-height: 1.4;
    color: var(--muted);
}
.settings-select-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--muted);
}
.settings-select {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: 0.65rem;
}
.settings-note {
    margin: 0.75rem 0 0;
    font-size: 0.66rem;
    line-height: 1.4;
    color: var(--muted);
    text-align: center;
}

.placement-tag {
    flex: 0 0 auto;
    padding: 0.3rem 0.7rem;
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-text);
    background: var(--amber-tint-3);
    border-radius: 99px;
    white-space: nowrap;
}

.placement-where {
    margin: 0 0 1.5rem;
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 0.75rem;
    text-align: left;
}

/* diagnostic strip on the path screen */
.diagnostic {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: var(--muted);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
}

.diagnostic__emoji { font-size: 1.25rem; line-height: 1; }
.diagnostic strong { color: var(--heading); }

.diagnostic__btn {
    margin-left: auto;
    flex: 0 0 auto;
    padding: 0.45rem 0.8rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--heading);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 99px;
    cursor: pointer;
}

.diagnostic__btn:hover { background: var(--hover); }

/* ---------- learner profile ---------- */
.learner-card {
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
}
.learner-card[hidden] { display: none; }
.learner-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.learner-eyebrow {
    margin: 0 0 0.15rem;
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}
.learner-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--heading);
}
.learner-settings {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0.35rem 0.65rem;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--heading);
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: 0.6rem;
    cursor: pointer;
}
.learner-settings:hover { background: var(--hover); }

.learner-skills { display: grid; gap: 0.45rem; }
.learner-skill {
    display: grid;
    grid-template-columns: 6.4rem 1fr 2.4rem;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.75rem;
}
.learner-skill__name {
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.learner-skill__track {
    display: block;
    height: 0.55rem;
    overflow: hidden;
    background: var(--track);
    border-radius: 999px;
}
.learner-skill__fill {
    display: block;
    height: 100%;
    background: var(--blue);
    border-radius: inherit;
}
.learner-skill__pct {
    text-align: right;
    font-weight: 800;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
}

.learner-advice {
    margin: 0.8rem 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--muted);
}
.learner-advice strong { color: var(--heading); }
.learner-practice {
    margin-top: 0.75rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.78rem;
}
.learner-focus {
    margin-top: 0.9rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
}
.learner-focus__title {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    color: var(--muted);
}
.learner-focus__title strong { color: var(--heading); }
.learner-focus__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.learner-chip {
    padding: 0.4rem 0.6rem;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--heading);
    background: var(--surface-2);
    border: 2px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
}
.learner-chip:hover { background: var(--hover); }
.learner-focus__empty {
    margin: 0.8rem 0 0;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--muted);
}

/* storage warning: shown only when the browser refuses persistent storage */
.storage-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    font-size: 0.8125rem;
    color: var(--text);
    background: var(--amber-tint);
    border: 1px solid var(--amber-edge);
    border-radius: 0.9rem;
}

.storage-notice[hidden] { display: none; }
.storage-notice__icon { font-size: 1.15rem; line-height: 1.2; }
.storage-notice__text { flex: 1; margin: 0; line-height: 1.45; }
.storage-notice__text strong { color: var(--heading); }

.storage-notice__close {
    flex-shrink: 0;
    padding: 0.35rem 0.7rem;
    font: inherit;
    font-weight: 700;
    color: var(--heading);
    background: transparent;
    border: 1px solid var(--amber-edge-3);
    border-radius: 0.6rem;
    cursor: pointer;
}

.storage-notice__close:hover { background: var(--amber-tint-2); }
.storage-notice__close:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- error notice ----------
   Shown only after a fault was recorded; errors-ui.js fills the text. Styled
   from the same tokens as the storage notice so both read as one system. */
.error-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    font-size: 0.8125rem;
    color: var(--text);
    background: var(--wrong-bg);
    border: 1px solid var(--wrong-line);
    border-radius: 0.9rem;
}

.error-notice[hidden] { display: none; }
.error-notice__icon { font-size: 1.15rem; line-height: 1.2; }
.error-notice__text { flex: 1; min-width: 12rem; margin: 0; line-height: 1.45; }

.error-notice__btn {
    flex-shrink: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    background: var(--card);
}
.error-notice__btn:hover { background: var(--hover); }
.error-notice__btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- stats + badges ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding-bottom: 2rem;
}
.stat-card {
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 1rem 0.5rem;
    text-align: center;
}
.stat-card-value { margin: 0; font-size: 1.2rem; font-weight: 800; color: var(--heading); }
.stat-card-label { margin: 0.25rem 0 0; font-size: 0.72rem; color: var(--muted); font-weight: 600; }

.badges-section { padding-top: 0.5rem; }
.badges-title { font-size: 1.35rem; margin-bottom: 1rem; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: 0.75rem; }
.badge {
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 0.9rem 0.4rem;
    text-align: center;
    /* 0.42 was too dim to read: the opacity multiplies the label colour, so
       the badge name composited down to 1.96:1. The locked signal comes from
       the grayscale filter and the flat border, so it survives at 0.75. */
    opacity: 0.75;
    filter: grayscale(1);
    transition: opacity 0.3s ease, filter 0.3s ease;
}
.badge.earned { opacity: 1; filter: none; border-color: var(--gold); background: var(--amber-tint-4); }
.badge-icon { font-size: 1.5rem; line-height: 1; }
.badge-name { margin: 0.4rem 0 0; font-size: 0.68rem; font-weight: 700; color: var(--badge-locked-ink); line-height: 1.25; }

/* ---------- lesson screen ---------- */
.lesson-screen { display: flex; flex-direction: column; min-height: 100vh; max-width: 46rem; padding-bottom: 0; }
.lesson-top { display: flex; align-items: center; gap: 1rem; padding: 0.5rem 0; }
.lesson-progress-track {
    flex: 1;
    height: 1rem;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.lesson-progress-fill {
    height: 100%;
    width: 0;
    background: var(--green);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 60%);
    border-radius: 999px;
    transition: width 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.hearts-live { display: flex; gap: 0.2rem; font-size: 1.1rem; }
.heart-lost { filter: grayscale(1); opacity: 0.35; }

.exercise-area { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 1.5rem 0; }

.ex-prompt { font-size: 1.05rem; font-weight: 700; color: var(--heading); margin: 0 0 1.25rem; }
.ex-sub { display: block; font-size: 0.82rem; font-weight: 500; color: var(--muted); margin-top: 0.3rem; }

.sentence-card {
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    animation: slide-up 0.3s ease-out;
}
.sentence-en { margin: 0; font-size: 1.4rem; font-weight: 700; line-height: 1.4; color: var(--text); }
.sentence-es { margin: 0.9rem 0 0; font-size: 1rem; color: var(--muted); line-height: 1.5; }
.sentence-es.hidden-es { filter: blur(7px); user-select: none; }
.speak-btn {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: var(--blue-tint);
    color: var(--heading);
    font-size: 1.1rem;
    cursor: pointer;
}
.speak-btn:hover { background: var(--blue-line); }
.speak-btn.playing { background: var(--navy); color: var(--card); }
.slow-btn {
    width: auto;
    min-height: 44px;
    border-radius: 999px;
    padding: 0 1rem;
    font-size: 0.85rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* word bank */
.word-bank { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.25rem; min-height: 3rem; }
.word-chip {
    border: 2px solid var(--line);
    background: var(--card);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 0.6rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--heading);
    cursor: pointer;
    transition: transform 0.08s ease;
}
.word-chip:active { transform: translateY(2px); border-bottom-width: 2px; }
.answer-slots { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; min-height: 3.1rem; }
.answer-slots.empty::before {
    content: 'Toca las palabras para formar la oración';
    font-size: 0.82rem;
    color: var(--muted);
    align-self: center;
}

.text-input {
    width: 100%;
    border: 2px solid var(--line);
    border-radius: 0.9rem;
    padding: 0.9rem 1.1rem;
    font-family: inherit;
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 1.25rem;
}
.text-input:focus { outline: none; border-color: var(--focus-ring); }

/* multiple choice */
.choice-list { display: flex; flex-direction: column; gap: 0.75rem; }
.choice {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.15s ease, background-color 0.15s ease;
    animation: slide-up 0.3s ease-out backwards;
}
.choice:nth-child(2) { animation-delay: 0.05s; }
.choice:nth-child(3) { animation-delay: 0.1s; }
.choice:nth-child(4) { animation-delay: 0.15s; }
.choice:hover { background: var(--hover); }
.choice:active { transform: translateY(2px); border-bottom-width: 2px; }
.choice-kbd {
    flex: 0 0 auto;
    width: 1.6rem;
    height: 1.6rem;
    border: 2px solid var(--line);
    border-radius: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--muted);
}
.choice.selected { background: var(--blue-tint); border-color: var(--blue-line-2); color: var(--heading); }
.choice.selected .choice-kbd { border-color: var(--blue); color: var(--blue-ink); }
.choice.correct { background: var(--correct-bg); border-color: var(--correct-fill); color: var(--correct-text); }
.choice.wrong { background: var(--wrong-bg); border-color: var(--wrong-line); color: var(--wrong-text); }

.image-hint { display: flex; justify-content: center; font-size: 2.6rem; margin-bottom: 0.75rem; }

/* ---------- footer / feedback ---------- */
.lesson-footer {
    position: sticky;
    bottom: 0;
    background: var(--card);
    border-top: 2px solid var(--line);
    padding: 0.9rem 0 calc(0.9rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.lesson-footer.ok-state { background: var(--correct-bg); border-top-color: var(--correct-fill); }
.lesson-footer.bad-state { background: var(--wrong-bg); border-top-color: var(--wrong-line); }
.feedback { flex: 1; font-weight: 800; display: flex; align-items: center; gap: 0.55rem; }
/* the TEXT role. --green-dark is a box-shadow edge that dark mode never
   overrides, so it measured 2.91:1 on --correct-bg in light and 4.18:1 in dark
   — failing AA in BOTH themes. --correct-text clears 5.95 and 9.53. */
.feedback.ok { color: var(--correct-text); }
.feedback.bad { color: var(--wrong-text); }
.feedback-detail { display: block; font-weight: 500; font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

/* ---------- result ---------- */
.result-screen { display: flex; align-items: center; justify-content: center; }
.result-card {
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 1.5rem;
    padding: 2.5rem 1.5rem;
    width: 100%;
    text-align: center;
}
.result-burst { font-size: 4rem; animation: pop-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop-bounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    80% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.result-title { font-size: 1.75rem; margin: 0.5rem 0 0.35rem; }
.result-sub { margin: 0 0 1.5rem; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.result-stats { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.result-stats li {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0.25rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}
.rs-label { color: var(--muted); font-weight: 600; }
.rs-value { font-weight: 800; color: var(--heading); }
.rs-gold { color: var(--gold-text); }

.result-review { text-align: left; margin-bottom: 1.5rem; }
.review-item { border-top: 1px solid var(--line); padding: 0.7rem 0.25rem; font-size: 0.88rem; }
.review-en { font-weight: 700; color: var(--text); }
.review-es { color: var(--muted); margin-top: 0.15rem; }
.review-missed { border-left: 3px solid var(--red); padding-left: 0.6rem; }

.result-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ---------- toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translate(-50%, 150%);
    background: var(--navy);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.88rem;
    z-index: 200;
    transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 10px 30px rgba(0, 39, 102, 0.3);
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- micro-interactions ---------- */
@keyframes slide-up {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes wrong-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
.choice.wrong { animation: wrong-shake 0.4s ease; }

@keyframes counter-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.stat-value.pop { animation: counter-pop 0.3s ease; }

/* ---------- confetti ---------- */
@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    z-index: 300;
    pointer-events: none;
    animation: confetti-fall 2.5s ease-in forwards;
}

/* ---------- available node (placement unlocked) ---------- */
.node.available {
    background: var(--blue);
    color: var(--on-node-blue);
    box-shadow: 0 8px 0 var(--blue-edge-3);
}
.node.available:active { box-shadow: 0 2px 0 var(--blue-edge-3); }

/* ---------- mobile overrides ---------- */
@media (max-width: 480px) {
    .screen { padding: 1rem 0.9rem 4rem; }
    .node { width: 4.5rem; height: 4.5rem; font-size: 1.1rem; }
    .sentence-en { font-size: 1.2rem; }
    .btn { padding: 0.75rem 1.25rem; font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .confetti-piece { display: none !important; }
}

/* the in-app override, for learners whose OS setting is not the one they want
   for this app */
html[data-motion="reduce"] {
    scroll-behavior: auto;
}
html[data-motion="reduce"] *,
html[data-motion="reduce"] *::before,
html[data-motion="reduce"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}
html[data-motion="reduce"] .confetti-piece { display: none !important; }
