/* ==========================================================================
   Abacus Minds – design system
   ========================================================================== */

:root {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #eef2f9;
    --surface-3: #e3e9f4;
    --text: #13203a;
    --muted: #56637a;
    --border: #dbe2ee;
    --primary: #1d4fb8;
    --primary-hover: #163f95;
    --primary-soft: #e3ecfd;
    --on-primary: #ffffff;
    --accent: #e39b2d;
    --accent-soft: #fdf1dd;
    --success: #18865a;
    --success-soft: #def5ea;
    --danger: #c23a34;
    --danger-soft: #fbe5e3;

    /* abacus */
    --wood-dark: #6b3f1d;
    --wood: #8d5528;
    --wood-light: #b57a43;
    --rod: #3b2a1c;
    --abacus-bg: #f4e6cf;
    --bead: #e7a33e;
    --bead-shade: #b87116;
    --bead-active: #1d4fb8;
    --bead-active-shade: #0f2f73;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;
    --shadow-sm: 0 1px 2px rgba(19, 32, 58, 0.06), 0 1px 3px rgba(19, 32, 58, 0.06);
    --shadow: 0 4px 12px rgba(19, 32, 58, 0.07), 0 1px 3px rgba(19, 32, 58, 0.05);
    --shadow-lg: 0 18px 40px rgba(19, 32, 58, 0.12);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-round: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
    --container: 1160px;
    --header-h: 68px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0c1220;
        --surface: #141c2e;
        --surface-2: #1a2438;
        --surface-3: #233049;
        --text: #e8edf6;
        --muted: #9eabc2;
        --border: #2a3650;
        --primary: #6d9bff;
        --primary-hover: #8eb2ff;
        --primary-soft: #1d2b4b;
        --on-primary: #0c1220;
        --accent: #f0b04d;
        --accent-soft: #3a2c14;
        --success: #3fc48b;
        --success-soft: #133326;
        --danger: #f07670;
        --danger-soft: #3d1a19;
        --abacus-bg: #2a2118;
        --bead-active: #6d9bff;
        --bead-active-shade: #2d58b8;
        --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.45);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0c1220;
    --surface: #141c2e;
    --surface-2: #1a2438;
    --surface-3: #233049;
    --text: #e8edf6;
    --muted: #9eabc2;
    --border: #2a3650;
    --primary: #6d9bff;
    --primary-hover: #8eb2ff;
    --primary-soft: #1d2b4b;
    --on-primary: #0c1220;
    --accent: #f0b04d;
    --accent-soft: #3a2c14;
    --success: #3fc48b;
    --success-soft: #133326;
    --danger: #f07670;
    --danger-soft: #3d1a19;
    --abacus-bg: #2a2118;
    --bead-active: #6d9bff;
    --bead-active-shade: #2d58b8;
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

/* ---------- base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    line-height: 1.2;
    letter-spacing: -0.015em;
    margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 4.4vw, 3.3rem); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.45rem, 2.6vw, 2rem); font-weight: 750; }
h3 { font-size: 1.2rem; font-weight: 700; }

p { margin: 0 0 1em; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
img, svg { max-width: 100%; }

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

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.narrow { max-width: 780px; }

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    background: var(--primary);
    color: var(--on-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}
.skip-link:focus { top: 12px; }

.icon { width: 1.25em; height: 1.25em; flex: none; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    padding: 0.8em 1.35em;
    border-radius: 999px;
    border: 1.5px solid transparent;
    font: inherit;
    font-weight: 650;
    font-size: 0.98rem;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-accent { background: var(--accent); color: #1c1305; }
.btn-accent:hover { filter: brightness(1.06); color: #1c1305; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.55em 1em; font-size: 0.9rem; }
.btn-lg { padding: 1em 1.7em; font-size: 1.05rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-logo {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent);
    transition: transform 0.25s;
}
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand-name {
    display: flex;
    flex-direction: column;
    font-family: var(--font-round);
    font-size: 1.32rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}
.brand-name small {
    margin-top: 3px;
    font-family: var(--font);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: var(--accent);
}

.main-nav { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.main-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.main-nav ul a {
    display: block;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}
.main-nav ul a:hover { color: var(--text); background: var(--surface-2); }
.main-nav ul a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }

.header-actions { display: flex; gap: 8px; }
.nav-toggle { display: none; }
.icon-close, .icon-sun { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-moon { display: none; }
    :root:not([data-theme="light"]) .icon-sun { display: block; }
}

@media (max-width: 1020px) {
    .nav-toggle { display: inline-grid; }
    .main-nav {
        position: fixed;
        inset: var(--header-h) 0 auto 0;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px 20px 24px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        transform: translateY(-8px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
    }
    .main-nav.open { opacity: 1; transform: none; visibility: visible; }
    .main-nav ul { flex-direction: column; }
    .main-nav ul a { padding: 12px 14px; font-size: 1.05rem; border-radius: var(--radius-sm); }
    .header-actions { margin-left: auto; }
}

/* ---------- sections ---------- */

.section { padding: 88px 0; }
.section-sm { padding: 56px 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--border); }

.section-head { max-width: 720px; margin: 0 auto 48px; text-align: center; }
.section-head p { color: var(--muted); font-size: 1.1rem; }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: color-mix(in srgb, var(--accent) 60%, var(--text));
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.lead { font-size: 1.2rem; color: var(--muted); }

/* ---------- hero ---------- */

.hero {
    position: relative;
    overflow: hidden;
    padding: 72px 0 88px;
    background:
        radial-gradient(900px 420px at 85% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 70%),
        radial-gradient(700px 380px at -10% 110%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; }
.hero h1 span { color: var(--primary); }
.hero .lead { max-width: 540px; margin-bottom: 30px; }
.hero-note { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 26px; color: var(--muted); font-size: 0.95rem; }
.hero-note span { display: inline-flex; align-items: center; gap: 6px; }
.hero-note .icon { color: var(--success); }

.hero-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: var(--shadow-lg);
}
.hero-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.hero-card-head span { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.hero-card-sum { font-family: var(--font-round); font-weight: 800; font-size: 1.6rem; color: var(--primary); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; gap: 40px; }
    .hero { padding: 48px 0 64px; }
}

/* ---------- stats ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-top: -44px;
    position: relative;
}
.stat { padding: 24px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat strong { display: block; font-family: var(--font-round); font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.92rem; font-weight: 600; }
@media (max-width: 700px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(3) { border-left: 0; }
    .stat:nth-child(n + 3) { border-top: 1px solid var(--border); }
}

/* ---------- cards & grids ---------- */

.grid { display: grid; gap: 22px; }
/* Grid children may shrink below their content width, so wide tables scroll inside them instead of stretching the page. */
.grid > *, .lesson-layout > *, .path > *, .steps > *, .contact-grid > *, .footer-grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.card p { color: var(--muted); }
.card p:last-child { margin-bottom: 0; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.card-link { margin-top: auto; padding-top: 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--primary); }

.card-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    margin-bottom: 18px;
    background: var(--primary-soft);
    color: var(--primary);
}
.card-icon .icon { width: 26px; height: 26px; }
.card-icon.amber { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.card-icon.green { background: var(--success-soft); color: var(--success); }
.card-icon.red { background: var(--danger-soft); color: var(--danger); }

/* ---------- learning path ---------- */

.path { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; counter-reset: stage; }
@media (max-width: 900px) { .path { grid-template-columns: 1fr; } }
.stage { padding: 28px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stage-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stage-num { font-family: var(--font-round); font-weight: 800; font-size: 0.85rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.stage ol { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; }
.stage li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}
.stage li a:hover { background: var(--primary-soft); color: var(--primary); }
.stage li .num {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 800;
}
.stage li a.done .num { background: var(--success); border-color: var(--success); color: #fff; }

.badge {
    display: inline-block;
    align-self: center; /* never stretch to the height of a neighbouring icon */
    line-height: 1.5;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.badge-beginner { background: var(--success-soft); color: var(--success); }
.badge-intermediate { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.badge-advanced { background: var(--danger-soft); color: var(--danger); }

/* ---------- steps / faq / cta ---------- */

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; counter-reset: step; }
@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }
.step { counter-increment: step; }
.step::before {
    content: counter(step);
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    font-family: var(--font-round);
    font-weight: 800;
    font-size: 1.15rem;
}
.step p { color: var(--muted); }

.faq { max-width: 800px; margin: 0 auto; display: grid; gap: 12px; }
.faq details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 22px;
}
.faq summary {
    cursor: pointer;
    list-style: none;
    padding: 16px 0;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--primary); transition: transform 0.2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--muted); }

.cta-band {
    border-radius: var(--radius-lg);
    padding: 56px 40px;
    text-align: center;
    color: #fff;
    background:
        radial-gradient(600px 300px at 90% 0%, rgba(255, 255, 255, 0.16), transparent 60%),
        linear-gradient(135deg, #1d4fb8, #12306f);
}
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255, 255, 255, 0.82); font-size: 1.1rem; max-width: 560px; margin: 0 auto 26px; }
.cta-band .btn-row { justify-content: center; }
.cta-band .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.cta-band .btn-ghost:hover { border-color: #fff; color: #fff; }

/* ---------- page header ---------- */

.page-hero {
    padding: 56px 0 40px;
    border-bottom: 1px solid var(--border);
    background: radial-gradient(800px 300px at 90% -20%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 70%);
}
.page-hero p { color: var(--muted); font-size: 1.15rem; max-width: 680px; margin-bottom: 0; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; font-size: 0.9rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 0.92rem; font-weight: 600; }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- prose ---------- */

.prose h2 { margin-top: 1.8em; }
.prose h2:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: 0.4em; }
.prose .def-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.prose .quiz-list, .prose .tips { padding-left: 0; }
@media (max-width: 560px) {
    .lesson-block { padding: 20px 16px; margin: 28px 0; }
    .aside-card { padding: 18px; }
}
.prose .def-list li { padding: 12px 16px; background: var(--surface-2); border-radius: var(--radius-sm); margin: 0; }

.callout {
    margin: 1.6em 0;
    padding: 18px 20px;
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
}

.worked {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
}
.worked-inline {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 10px;
    border-radius: 6px;
    background: var(--primary-soft);
    font-family: var(--mono);
    font-size: 0.92em;
}

table.pairs {
    border-collapse: collapse;
    margin: 1.2em 0;
    width: 100%;
    font-variant-numeric: tabular-nums;
    display: block;
    overflow-x: auto;
}
table.pairs th, table.pairs td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: center;
}
table.pairs th { background: var(--surface-2); text-align: left; white-space: nowrap; }
table.pairs td { font-weight: 700; min-width: 44px; }

/* Diagrams line up along the top so captions of different lengths do not shift them. */
.figure-row { display: flex; flex-wrap: wrap; gap: 20px 18px; margin: 1.5em 0; align-items: flex-start; }
.figure-row .abacus-figure { min-width: 150px; }
.figure-row.chart { justify-content: center; margin-top: 36px; gap: 16px 12px; }
.figure-row.chart .abacus-figure { min-width: 0; }
@media (max-width: 560px) {
    .figure-row { gap: 18px 8px; }
    .figure-row .abacus-figure { min-width: 0; flex: 1 1 120px; }
    .figure-row.chart .abacus-figure { flex: 0 0 auto; }
}

/* ---------- lesson layout ---------- */

.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; padding: 48px 0 80px; }
@media (max-width: 980px) { .lesson-layout { grid-template-columns: minmax(0, 1fr); } }
.lesson-aside { position: sticky; top: calc(var(--header-h) + 20px); align-self: start; display: grid; gap: 18px; }
@media (max-width: 980px) { .lesson-aside { position: static; } }
.aside-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.aside-card h2 { font-size: 1rem; margin-bottom: 12px; }
.aside-card ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.aside-card li { display: flex; gap: 10px; color: var(--muted); font-size: 0.95rem; line-height: 1.45; }
.aside-card li .icon { color: var(--success); margin-top: 2px; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #3fa0ff); transition: width 0.4s; }

.lesson-block {
    margin: 40px 0;
    padding: 28px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.lesson-block h2 { display: flex; align-items: center; gap: 10px; margin-top: 0 !important; }
.lesson-block > p { color: var(--muted); }

.quiz-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: q; }
.quiz-item {
    counter-increment: q;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1.5px solid transparent;
}
.quiz-item label { font-weight: 600; }
.quiz-item label::before { content: counter(q) ". "; color: var(--muted); }
.quiz-item input[type="text"] { width: 120px; }
.quiz-item.correct { border-color: var(--success); background: var(--success-soft); }
.quiz-item.wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz-feedback { font-size: 0.85rem; font-weight: 700; grid-column: 1 / -1; }
.quiz-feedback:empty { display: none; }
@media (max-width: 560px) {
    .quiz-item { grid-template-columns: 1fr; gap: 8px; }
    .quiz-item input[type="text"] { width: 100%; }
    table.pairs th, table.pairs td { padding: 6px 8px; }
    table.pairs td { min-width: 30px; }
}
.quiz-item.correct .quiz-feedback { color: var(--success); }
.quiz-item.wrong .quiz-feedback { color: var(--danger); }
.quiz-result { margin-top: 16px; font-weight: 700; }

.tips { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.tips li { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.tips li .icon { color: var(--accent); margin-top: 3px; }

.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; }
.lesson-nav a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
}
.lesson-nav a:hover { border-color: var(--primary); color: var(--primary); }
.lesson-nav small { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.lesson-nav .next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .lesson-nav { grid-template-columns: 1fr; } .lesson-nav .next { grid-column: auto; } }

.complete-btn.is-done { background: var(--success); }

/* ---------- lesson list ---------- */

.lesson-card { gap: 6px; }
.lesson-card .lesson-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.lesson-card .lesson-n { font-family: var(--font-round); font-weight: 800; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.06em; }
.lesson-card h3 { margin-bottom: 6px; }
.lesson-card .done-tick { display: none; align-items: center; gap: 4px; color: var(--success); font-weight: 700; font-size: 0.85rem; }
.lesson-card.done .done-tick { display: inline-flex; }

.progress-panel {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 22px 26px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 32px;
}
.progress-panel .progress { flex: 1; }
.progress-panel strong { white-space: nowrap; }
@media (max-width: 600px) { .progress-panel { flex-wrap: wrap; } .progress-panel .progress { flex-basis: 100%; order: 3; } }

/* ---------- forms ---------- */

.field { display: grid; gap: 6px; }
.field label, .field-label { font-weight: 650; font-size: 0.92rem; }
.field-hint { color: var(--muted); font-size: 0.85rem; }

input[type="text"], input[type="email"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    font: inherit;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
textarea { min-height: 150px; resize: vertical; }
input[type="number"] { font-variant-numeric: tabular-nums; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; border-radius: 12px; background: var(--surface-2); }
.segmented label { position: relative; flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span {
    display: block;
    text-align: center;
    padding: 8px 12px;
    border-radius: 9px;
    font-weight: 650;
    font-size: 0.92rem;
    color: var(--muted);
    white-space: nowrap;
}
.segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); }

.form-grid { display: grid; gap: 18px; }
.form-status { padding: 14px 16px; border-radius: var(--radius-sm); font-weight: 600; }
.form-status.ok { background: var(--success-soft); color: var(--success); }
.form-status.err { background: var(--danger-soft); color: var(--danger); }

/* ---------- abacus ---------- */

.abacus-figure { margin: 0; display: inline-flex; flex-direction: column; align-items: center; gap: 8px; }
.abacus-figure figcaption { font-size: 0.85rem; font-weight: 600; line-height: 1.4; color: var(--muted); text-align: center; max-width: 170px; }

.abacus {
    --bead-h: 22px;
    --bead-w: 44px;
    --rod-gap: 6px;
    display: inline-block;
    max-width: 100%;
}
.abacus.lg { --bead-h: 32px; --bead-w: 62px; --rod-gap: 10px; }
.abacus.md { --bead-h: 26px; --bead-w: 52px; --rod-gap: 8px; }

.abacus-frame {
    position: relative;
    display: inline-flex;
    gap: var(--rod-gap);
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--abacus-bg);
    border: 8px solid var(--wood);
    border-top-color: var(--wood-light);
    border-bottom-color: var(--wood-dark);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), var(--shadow);
    max-width: 100%;
    overflow-x: auto;
}

.rod { position: relative; width: var(--bead-w); flex: none; }
.rod-upper::before,
.rod-lower::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
    background: var(--rod);
    border-radius: 2px;
}
.rod-upper { position: relative; height: calc(var(--bead-h) * 2); }
.rod-lower { position: relative; height: calc(var(--bead-h) * 5); }
.beam {
    position: relative;
    height: 10px;
    margin: 0 calc(var(--rod-gap) / -2 - 1px);
    background: var(--wood);
    border-block: 1px solid var(--wood-dark);
    z-index: 1;
}
.rod:first-child .beam { margin-left: -14px; }
.rod:last-child .beam { margin-right: -14px; }
.beam.unit::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
}

.bead {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: var(--bead-h);
    padding: 0;
    border: 0;
    background: transparent;
    transform: translateY(var(--y, 0));
    transition: transform 0.16s ease-out;
    cursor: default;
}
.bead::before {
    content: "";
    position: absolute;
    inset: 1px 0;
    background: radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.55), transparent 55%), var(--bead);
    clip-path: polygon(0 50%, 22% 0, 78% 0, 100% 50%, 78% 100%, 22% 100%);
    box-shadow: inset 0 -4px 0 var(--bead-shade);
}
.bead.active::before {
    background: radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.45), transparent 55%), var(--bead-active);
}
.abacus.interactive .bead { cursor: pointer; }
.abacus.interactive .bead:hover::before { filter: brightness(1.1); }
.bead:focus-visible { outline: none; }
.bead:focus-visible::after {
    content: "";
    position: absolute;
    inset: -2px -4px;
    border: 2px solid var(--accent);
    border-radius: 6px;
}

.rod-label {
    margin-top: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--wood-dark);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
:root[data-theme="dark"] .rod-label { color: #d6b48d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rod-label { color: #d6b48d; } }
.rod-digit {
    margin-top: 2px;
    text-align: center;
    font-family: var(--font-round);
    font-weight: 800;
    font-size: 1rem;
    color: var(--text);
}
.abacus:not(.show-digits) .rod-digit { display: none; }
.abacus:not(.show-labels) .rod-label { display: none; }

@media (max-width: 560px) {
    .tool-panel { padding: 20px 16px; }
    .abacus-frame { padding: 8px 10px; border-width: 6px; }
    .rod:first-child .beam { margin-left: -10px; }
    .rod:last-child .beam { margin-right: -10px; }
}
@media (max-width: 520px) {
    .abacus.lg { --bead-h: 24px; --bead-w: 40px; --rod-gap: 4px; }
    .abacus.md { --bead-h: 22px; --bead-w: 40px; --rod-gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { .bead { transition: none; } }

/* try it */
.try-it { display: grid; gap: 16px; justify-items: start; }
.try-status { font-weight: 700; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.try-status.ok { background: var(--success-soft); color: var(--success); }

/* virtual abacus page */
.tool-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
}
.abacus-display {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.abacus-value {
    font-family: var(--font-round);
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.abacus-value-label { color: var(--muted); font-weight: 650; font-size: 0.9rem; display: block; margin-bottom: 6px; }
.abacus-stage { display: flex; justify-content: center; padding: 8px 0 4px; overflow-x: auto; }
.tool-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--border); }
.tool-controls .inline { display: flex; gap: 8px; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 18px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--primary); }
.challenge-box { margin-top: 22px; padding: 18px 20px; border-radius: var(--radius); background: var(--accent-soft); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.challenge-box strong { font-family: var(--font-round); font-size: 1.4rem; }

/* ---------- practice ---------- */

.practice-shell { max-width: 820px; margin: 0 auto; }
.practice-question {
    text-align: center;
    padding: 18px 0 8px;
}
.practice-question .q-text {
    font-family: var(--font-round);
    font-size: clamp(2.2rem, 7vw, 3.6rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    letter-spacing: -0.01em;
}
.q-stack { display: inline-grid; justify-items: end; gap: 2px; font-family: var(--font-round); font-weight: 800; font-size: clamp(1.8rem, 5vw, 2.6rem); font-variant-numeric: tabular-nums; line-height: 1.2; padding-bottom: 8px; border-bottom: 3px solid var(--text); min-width: 140px; }
.practice-answer { display: flex; gap: 10px; max-width: 360px; margin: 26px auto 0; }
.practice-answer input { font-size: 1.4rem; text-align: center; font-weight: 700; }
.practice-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.practice-feedback { text-align: center; min-height: 1.8em; margin-top: 14px; font-weight: 700; }
.practice-feedback.ok { color: var(--success); }
.practice-feedback.err { color: var(--danger); }
.flash-number {
    display: grid;
    place-items: center;
    min-height: 200px;
    font-family: var(--font-round);
    font-size: clamp(4rem, 14vw, 7rem);
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0; }
.result-grid div { padding: 18px; border-radius: var(--radius); background: var(--surface-2); text-align: center; }
.result-grid strong { display: block; font-family: var(--font-round); font-size: 1.9rem; color: var(--primary); }
.result-grid span { color: var(--muted); font-weight: 600; font-size: 0.88rem; }
.review-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.review-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.review-list li.wrong { background: var(--danger-soft); }
.review-list li.right { background: var(--success-soft); }
.best-scores { display: grid; gap: 8px; }
.best-scores div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.95rem; }
.best-scores div:last-child { border: 0; }
.hidden { display: none !important; }

/* ---------- worksheets ---------- */

.ws-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 26px; }
.sheet {
    background: #fff;
    color: #111;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 40px;
    box-shadow: var(--shadow);
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid #111; padding-bottom: 14px; margin-bottom: 22px; }
.sheet-head h2 { font-size: 1.35rem; margin-bottom: 4px; color: #111; }
.sheet-head p { margin: 0; color: #555; font-size: 0.9rem; }
.sheet-fields { display: grid; gap: 8px; font-size: 0.92rem; min-width: 220px; }
.sheet-fields span { display: flex; gap: 8px; }
.sheet-fields span::after { content: ""; flex: 1; border-bottom: 1px solid #999; }
.sheet-fields .score::after { content: none; }
.sheet-fields .score em { flex: 1; border-bottom: 1px solid #999; }
.sheet-section-title { font-weight: 800; margin: 18px 0 12px; font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase; color: #333; }
.ws-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px 14px; }
.ws-problem {
    border: 1.5px solid #c8ccd4;
    border-radius: 8px;
    padding: 6px 10px 8px;
    font-family: var(--mono);
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    break-inside: avoid;
}
.ws-problem .pn { font-family: var(--font); font-size: 0.72rem; font-weight: 700; color: #777; }
.ws-problem .rows { display: grid; justify-items: end; padding: 2px 4px 4px; }
.ws-problem .ans { border-top: 2px solid #111; height: 34px; display: flex; align-items: center; justify-content: flex-end; padding: 0 4px; font-weight: 700; color: #c23a34; }
.ws-inline { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 30px; }
.ws-inline .ws-line { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 1.05rem; padding: 8px 0; border-bottom: 1px dotted #c8ccd4; }
.ws-line .pn { font-family: var(--font); font-size: 0.75rem; font-weight: 700; color: #777; min-width: 26px; }
.ws-line .blank { flex: 1; text-align: right; font-weight: 700; color: #c23a34; min-height: 1.2em; }
.sheet:not(.show-answers) .ans-val { visibility: hidden; }
.sheet-foot { margin-top: 26px; padding-top: 12px; border-top: 1px solid #ddd; display: flex; justify-content: space-between; font-size: 0.8rem; color: #777; }
@media (max-width: 860px) { .ws-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) {
    .sheet { padding: 22px 18px; }
    .ws-grid { grid-template-columns: repeat(2, 1fr); }
    .ws-inline { grid-template-columns: 1fr; }
    .sheet-head { flex-direction: column; }
}

.level-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.level-tabs a { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--muted); font-weight: 650; font-size: 0.92rem; }
.level-tabs a[aria-current="page"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* ---------- contact / misc ---------- */

.contact-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 40px; align-items: start; }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }
.contact-item { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.contact-item:last-child { border: 0; }
.contact-item h3 { font-size: 1rem; margin-bottom: 2px; }
.contact-item p { margin: 0; color: var(--muted); }

.not-found { text-align: center; padding: 120px 0; }
.not-found .big { font-family: var(--font-round); font-size: 7rem; font-weight: 800; color: var(--primary); line-height: 1; }

.resource-list { display: grid; gap: 14px; }
.resource-row { display: flex; align-items: center; gap: 18px; padding: 18px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.resource-row:hover { border-color: var(--primary); color: var(--text); }
.resource-row .card-icon { margin: 0; }
.resource-row h3 { margin: 0 0 2px; font-size: 1.05rem; }
.resource-row p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.resource-row .icon:last-child { margin-left: auto; color: var(--muted); }

/* ---------- footer ---------- */

.site-footer { margin-top: 40px; background: var(--surface); border-top: 1px solid var(--border); padding-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 36px; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-about { grid-column: 1 / -1; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-about p { color: var(--muted); margin-top: 14px; max-width: 360px; font-size: 0.95rem; }
.footer-title { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 14px; }
.footer-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer-links a { color: var(--text); text-decoration: none; font-size: 0.95rem; }
.footer-links a:hover { color: var(--primary); }
.footer-bottom { margin-top: 44px; padding-top: 22px; padding-bottom: 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; }
.footer-bottom p { margin: 0; }

/* ---------- print (worksheets) ---------- */

@media print {
    @page { margin: 12mm; }
    .js .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .hero-beads, .confetti-piece, .bead-spark, .header-actions { display: none !important; }
    body { background: #fff; font-size: 12pt; }
    .site-header, .site-footer, .page-hero, .ws-toolbar, .no-print, .skip-link { display: none !important; }
    .section, .section-sm { padding: 0; }
    .container { max-width: none; padding: 0; }
    .sheet { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
    .ws-grid { grid-template-columns: repeat(5, 1fr); }
    .ws-inline { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- animation ---------- */

.hero-beads { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.hero > .container { position: relative; z-index: 1; }
.hero-beads span {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: calc(var(--s) * 2);
    height: var(--s);
    border-radius: 999px;
    background: linear-gradient(180deg, #ffd27a, #e58f1c);
    opacity: 0.16;
}
.hero-beads span:nth-child(3n) { background: linear-gradient(180deg, #8eb2ff, #2d58b8); }

@media (prefers-reduced-motion: no-preference) {
    /* hero entrance */
    .hero .eyebrow, .hero h1, .hero .lead, .hero .btn-row, .hero-note, .hero-card {
        animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }
    .hero h1 { animation-delay: 0.08s; }
    .hero .lead { animation-delay: 0.18s; }
    .hero .btn-row { animation-delay: 0.28s; }
    .hero-note { animation-delay: 0.38s; }
    .hero-card { animation: pop-in 0.9s 0.25s cubic-bezier(0.2, 0.8, 0.2, 1.1) both; }
    .page-hero h1, .page-hero p, .page-hero .meta-row { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
    .page-hero p { animation-delay: 0.1s; }
    .page-hero .meta-row { animation-delay: 0.18s; }

    .hero-beads span { animation: drift var(--d) ease-in-out var(--delay) infinite alternate; }

    /* scroll reveal (only once JS has marked the page, so content never stays hidden without JS) */
    .js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--stagger, 0s); }
    .js .reveal.in { opacity: 1; transform: none; }

    /* logo: the bulb gently lights up */
    .brand-logo { animation: glow 3.2s ease-in-out infinite; }

    /* beads spring into place */
    .bead { transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1); }

    /* button shine */
    .btn-primary, .btn-accent { position: relative; overflow: hidden; isolation: isolate; }
    .btn-primary::after, .btn-accent::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
        transform: translateX(-120%);
    }
    .btn-primary:hover::after, .btn-accent:hover::after { transform: translateX(120%); transition: transform 0.7s ease; }
    .btn-primary, .btn-accent { z-index: 0; }

    a.card:hover .card-icon, .card:hover .card-icon { animation: wiggle 0.6s ease; }
    .step:hover::before { animation: bounce 0.6s ease; }

    .progress > span { background-size: 200% 100%; background-image: linear-gradient(90deg, var(--primary), #3fa0ff, var(--primary)); animation: shimmer 2.4s linear infinite; }

    [data-theme-toggle] .icon { transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
    [data-theme-toggle]:hover .icon { transform: rotate(40deg); }
    [data-theme-toggle]:active .icon { transform: rotate(200deg) scale(0.8); }

    .quiz-item.correct, .try-status.ok, .practice-feedback.ok { animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
    .quiz-item.wrong, .practice-feedback.err { animation: shake 0.4s ease; }
    .complete-btn.is-done { animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
    .flash-number { animation: flash-in 0.25s ease-out; }
    .challenge-box:not(.hidden) { animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
    .faq details[open] p { animation: rise 0.35s ease both; }
}

@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(30px) scale(0.94) rotate(-1.5deg); } to { opacity: 1; transform: none; } }
@keyframes drift { from { transform: translate(0, 0) rotate(0deg); } to { transform: translate(var(--dx), var(--dy)) rotate(14deg); } }
@keyframes glow {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 210, 122, 0)); }
    50% { filter: drop-shadow(0 0 9px rgba(255, 210, 122, 0.65)); }
}
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg) scale(1.08); } 60% { transform: rotate(8deg) scale(1.08); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } 70% { transform: translateY(2px); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }
@keyframes pop { 0% { transform: scale(0.96); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes flash-in { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }

.confetti-piece { position: fixed; z-index: 200; pointer-events: none; border-radius: 2px; }

/* ---------- playful abacus ---------- */

.icon-sound-off { display: none; }
[data-sound-toggle][aria-pressed="false"] .icon-sound-on { display: none; }
[data-sound-toggle][aria-pressed="false"] .icon-sound-off { display: block; }
[data-sound-toggle][aria-pressed="false"] { color: var(--muted); }

.bead-spark {
    position: fixed;
    z-index: 150;
    width: 9px;
    height: 9px;
    pointer-events: none;
    background: #ffd27a;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}

@media (prefers-reduced-motion: no-preference) {
    .bead::before { transition: transform 0.18s ease, filter 0.18s ease; }
    .abacus.interactive .bead:hover::before { transform: scale(1.07); filter: brightness(1.12); }
    .abacus.interactive .bead:active::before { transform: scale(0.94); }
    .bead.bump::before { animation: squash 0.42s cubic-bezier(0.34, 1.56, 0.64, 1); }
    .bead.bump.active { animation: bead-glow 0.7s ease-out; }
    .rod-digit.pop { animation: digit-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
    .abacus-value.pop { animation: digit-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); display: inline-block; }
    .abacus-frame { transition: box-shadow 0.3s; }
    .abacus.interactive .abacus-frame:hover { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), 0 10px 30px color-mix(in srgb, var(--accent) 22%, transparent); }
}

@keyframes squash {
    0% { transform: scale(1, 1); }
    30% { transform: scale(1.18, 0.78); }
    55% { transform: scale(0.92, 1.1); }
    100% { transform: scale(1, 1); }
}
@keyframes bead-glow {
    0% { filter: drop-shadow(0 0 0 rgba(255, 210, 122, 0)); }
    35% { filter: drop-shadow(0 0 10px rgba(255, 210, 122, 0.9)); }
    100% { filter: drop-shadow(0 0 0 rgba(255, 210, 122, 0)); }
}
@keyframes digit-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.45); color: var(--accent); }
    100% { transform: scale(1); }
}

/* ---------- page-specific motion ---------- */
@media (prefers-reduced-motion: no-preference) {
    .practice-question.q-enter > * { animation: q-in 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
    .q-stack > div { animation: rise 0.35s ease both; }
    .q-enter .q-stack > div:nth-child(2) { animation-delay: 0.06s; }
    .q-enter .q-stack > div:nth-child(3) { animation-delay: 0.12s; }
    .q-enter .q-stack > div:nth-child(4) { animation-delay: 0.18s; }
    .q-enter .q-stack > div:nth-child(5) { animation-delay: 0.24s; }
    .q-enter .q-stack > div:nth-child(n + 6) { animation-delay: 0.3s; }
    #practice-done:not(.hidden) h2,
    #practice-done:not(.hidden) .result-grid > div { animation: pop-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.15) both; }
    #practice-done:not(.hidden) .result-grid > div:nth-child(1) { animation-delay: 0.1s; }
    #practice-done:not(.hidden) .result-grid > div:nth-child(2) { animation-delay: 0.22s; }
    #practice-done:not(.hidden) .result-grid > div:nth-child(3) { animation-delay: 0.34s; }
    #practice-done:not(.hidden) .review-list li { animation: rise 0.4s ease both; animation-delay: 0.45s; }
    .ws-problem, .ws-line { animation: rise 0.45s ease both; animation-delay: calc(var(--i, 0) * 25ms); }
    .progress > span { transition: width 1s cubic-bezier(0.2, 0.7, 0.2, 1); }
}
@keyframes q-in { from { opacity: 0; transform: translateY(14px) scale(0.92); } to { opacity: 1; transform: none; } }
@media print { .ws-problem, .ws-line { animation: none !important; } }
