/* ============================================================ base */
*,
*::before,
*::after {
    box-sizing: border-box;
}
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}
body {
    margin: 0;
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.85;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main {
    flex: 1;
}
h1, h2, h3, h4 {
    line-height: 1.4;
    margin: 0 0 0.6em;
    font-weight: 800;
}
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.75rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
ul, ol { padding-inline-start: 1.4em; margin: 0 0 1em; }
img, video { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
code, pre, kbd { font-family: var(--mono); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}
.sr-only,
.sr-offscreen {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.skip-link {
    position: absolute;
    inset-block-start: -60px;
    inset-inline-start: 12px;
    background: var(--primary);
    color: var(--on-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    z-index: 200;
    transition: inset-block-start 0.2s;
}
.skip-link:focus { inset-block-start: 10px; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.container.narrow { width: min(820px, 100% - 32px); }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }
.view { padding-block: 28px 64px; }

/* ============================================================ buttons / chips */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.5rem 1.2rem;
    border-radius: 12px;
    border: 1.5px solid transparent;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s;
    background: transparent;
    line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 20px -10px var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-sm { min-height: 36px; padding: 0.2rem 0.8rem; font-size: 0.92rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 0.6rem 1.7rem; font-size: 1.1rem; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; text-align: start; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 1.15rem;
}
.icon-btn:hover { border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.7;
}
.chip-done { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.chip-mcq, .chip-tf { background: var(--primary-soft); }
.chip-output, .chip-error { background: var(--accent-soft); }
.chip-complete { background: var(--warn-soft); }
.chip-program { background: var(--success-soft); }
.chip-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.92rem;
    min-height: 36px;
}
.chip-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.input, .code-editor, .chat-input {
    width: 100%;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    min-height: 44px;
}
.input:focus, .code-editor:focus, .chat-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-label { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 4px; }

/* ============================================================ header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.nav-bar { display: flex; align-items: center; gap: 16px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.2rem; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    color: #fff;
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 700;
}
.nav { flex: 1; }
.nav-links { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
    display: block;
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current='page'] { color: var(--text); background: var(--primary-soft); box-shadow: inset 0 -2px 0 var(--primary-hover); }
.nav-tools { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.xp-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    min-height: 44px;
    border-radius: 12px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 0.92rem;
}
.xp-chip:hover { border-color: var(--accent); }
.xp-star { color: var(--warn); }
.xp-lv { background: var(--primary-soft); border-radius: 8px; padding: 0 8px; font-size: 0.82rem; }
.menu-toggle { display: none; }
.burger { display: grid; gap: 4px; }
.burger i { display: block; width: 20px; height: 2.5px; border-radius: 2px; background: currentColor; }

/* ============================================================ hero */
.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(40px, 7vw, 88px) 0 clamp(48px, 7vw, 96px);
    background:
        radial-gradient(60% 60% at 85% 10%, var(--hero-glow-1), transparent 70%),
        radial-gradient(50% 50% at 10% 90%, var(--hero-glow-2), transparent 70%);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
.eyebrow { color: var(--accent); font-weight: 700; letter-spacing: 0.02em; margin-bottom: 0.4em; font-size: 0.98rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.3; }
.hero-lead { font-size: 1.2rem; color: var(--muted); max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 24px; }
.hero-stats { display: flex; gap: 28px; list-style: none; padding: 0; margin: 0; }
.hero-stats li { display: grid; }
.hero-stats strong { font-size: 1.9rem; line-height: 1.2; color: var(--text); }
.hero-stats span { color: var(--muted); font-size: 0.92rem; }

.hero-visual { position: relative; padding: 20px 0 30px; }
.code-window {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 30px 60px -25px rgba(124, 58, 237, 0.55);
    overflow: hidden;
    text-align: left;
    animation: floaty 7s ease-in-out infinite;
}
.window-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); font-family: var(--mono); font-size: 0.8rem; }
.window-bar i { width: 11px; height: 11px; border-radius: 50%; background: #f87171; }
.window-bar i:nth-child(2) { background: #fbbf24; }
.window-bar i:nth-child(3) { background: #34d399; }
.window-bar span { margin-inline-start: auto; }
.code-window pre { margin: 0; padding: 16px 18px; font-size: 0.85rem; line-height: 1.7; overflow-x: auto; color: var(--code-text); }
.window-out { border-top: 1px dashed var(--border); padding: 10px 18px 14px; font-size: 0.85rem; background: color-mix(in srgb, var(--code-bg) 80%, var(--primary) 6%); }
.out-label { display: block; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.window-out code { color: var(--tok-str); line-height: 1.7; }
.float-card {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    line-height: 1.4;
}
.float-card strong { display: block; }
.float-card small { color: var(--muted); }
.fc-icon { font-size: 1.4rem; }
.float-xp { inset-block-start: -2px; inset-inline-end: -10px; animation: floaty 6s 0.5s ease-in-out infinite; }
.float-badge { inset-block-end: 30px; inset-inline-start: -14px; animation: floaty 8s 1s ease-in-out infinite; }
.float-quiz { inset-block-end: -8px; inset-inline-end: 24px; animation: floaty 7s 0.2s ease-in-out infinite; }
@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ============================================================ landing sections */
.section { padding: clamp(44px, 6vw, 80px) 0; }
.section.alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-h { font-size: clamp(1.6rem, 3.4vw, 2.2rem); }
.section-sub { color: var(--muted); max-width: 46em; font-size: 1.08rem; }
.quote {
    margin: 20px 0;
    padding: 20px 24px;
    background: var(--surface);
    border-inline-start: 5px solid var(--primary-hover);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 1.15rem;
}
.pain-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pain-list li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; font-weight: 700; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-block: 24px; }
.feature { transition: transform 0.25s var(--ease), border-color 0.25s; }
.feature:hover { transform: translateY(-4px); border-color: var(--primary-hover); }
.f-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft); font-size: 1.6rem; margin-bottom: 12px; }
.feature p { color: var(--muted); margin: 0; font-size: 0.98rem; }
.journey { list-style: none; padding: 0; counter-reset: j; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-block: 24px; }
.journey li { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.journey p { margin: 0; color: var(--muted); font-size: 0.97rem; }
.j-num { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; font-weight: 800; margin-bottom: 8px; }
.video-frame { aspect-ratio: 16 / 9; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; box-shadow: var(--shadow); }
.video-frame video { width: 100%; height: 100%; background: #000; object-fit: contain; }
.video-soon { text-align: center; padding: 20px; }
.video-soon .soon-icon { font-size: 3rem; display: block; }
.video-soon p { color: var(--muted); margin: 6px 0 0; }
.cta-band { background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); }

.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin-block: 24px; }
.stage-mini h3 { margin-bottom: 6px; }
.stage-mini p { margin-bottom: 6px; font-size: 0.96rem; }
.stage-mini-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stage-icon { font-size: 1.8rem; }
.stage-no { color: var(--accent); font-weight: 700; font-size: 0.9rem; }
.stage-card { display: flex; flex-direction: column; gap: 4px; }
.stage-card h2 { font-size: 1.15rem; }
.stage-card .btn { margin-top: auto; align-self: flex-start; }
.status { font-weight: 700; font-size: 0.92rem; margin: 4px 0 10px; }
.status-ok, .status-done { color: var(--success); }
.status-ready, .status-open { color: var(--accent); }
.status-locked { color: var(--muted); }

/* ============================================================ footer */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--border); padding-top: 40px; margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; }
.footer-h { font-size: 1rem; }
.footer-links { list-style: none; padding: 0; display: grid; gap: 4px; }
.footer-links a { color: var(--muted); text-decoration: none; display: inline-block; padding: 4px 0; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 20px; padding-block: 18px 28px; color: var(--muted); font-size: 0.92rem; }
.footer-bottom p { margin: 0 0 6px; }
.tools-line { color: var(--text); }

/* ============================================================ page chrome */
.page-head { margin-bottom: 24px; }
.page-head.compact { margin-bottom: 12px; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 46em; }
.lead-p { font-size: 1.12rem; }
.back-link, .breadcrumb { font-size: 0.92rem; color: var(--muted); display: inline-block; margin-bottom: 8px; }
.breadcrumb a { color: var(--accent); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 8px 12px; }
.section-title { margin-top: 36px; }
.loading { display: flex; align-items: center; gap: 12px; padding: 60px 0; color: var(--muted); justify-content: center; }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; }
.banner { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface-2); }
.banner-warn { background: var(--warn-soft); border-color: var(--warn); }
.about-card { margin-bottom: 18px; }

/* ============================================================ code */
.code-block { margin: 14px 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 4px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 0.82rem; color: var(--muted); }
.code-title { font-family: var(--mono); }
pre.code, .code-editor {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.92rem;
    line-height: 1.75;
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
    overflow-x: auto;
    tab-size: 4;
    color: var(--code-text);
}
.code-block pre.code { padding: 14px 16px; white-space: pre; }
.code-block.is-output pre.code { color: var(--tok-str); }
pre.code code { font-family: inherit; }
.inline-code {
    font-family: var(--mono);
    font-size: 0.9em;
    direction: ltr;
    unicode-bidi: isolate;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 6px;
    white-space: nowrap;
}
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-type { color: var(--tok-type); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-pp { color: var(--tok-pp); }
.tok-fn { color: var(--tok-fn); }
.tok-io { color: var(--tok-io); }
.code-editor { background: var(--code-bg); resize: vertical; min-height: 220px; padding: 14px 16px; margin: 10px 0; white-space: pre; }
.io-pair { margin-block: 8px; }
.io-label { display: block; font-size: 0.88rem; color: var(--muted); font-weight: 600; }

/* ============================================================ lesson */
.lesson-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.lesson-toc { position: sticky; top: 88px; padding: 16px; box-shadow: none; }
.lesson-toc ol { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 2px; font-size: 0.95rem; }
.lesson-toc .link-btn { text-decoration: none; color: var(--muted); padding: 4px 0; min-height: 32px; }
.lesson-toc .link-btn:hover { color: var(--accent); }
.lesson-section { margin-bottom: 40px; scroll-margin-top: 90px; }
.lesson-section > h2 { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.sec-num { display: inline-grid; place-items: center; min-width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft); color: var(--accent); font-size: 0.95rem; }
.terms { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; align-items: baseline; }
.terms dt { font-family: var(--mono); font-weight: 700; color: var(--accent); direction: ltr; text-align: left; }
.terms dd { margin: 0; }
.walk { counter-reset: w; list-style: none; padding: 0; display: grid; gap: 10px; }
.walk li { counter-increment: w; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px 12px 16px; padding-inline-start: 52px; }
.walk li::before { content: counter(w); position: absolute; inset-inline-start: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; }
.walk-code { display: block; background: var(--code-bg); border-radius: 8px; padding: 6px 12px; margin-bottom: 6px; font-size: 0.9rem; overflow-x: auto; white-space: pre; text-align: left; }
.walk p { margin: 0; }
.more-example { margin-top: 20px; }
.mistake { margin-bottom: 14px; box-shadow: none; }
.mk-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tag { display: inline-block; font-size: 0.85rem; font-weight: 700; padding: 0 10px; border-radius: 8px; }
.tag-bad { background: var(--danger-soft); color: var(--danger); }
.tag-good { background: var(--success-soft); color: var(--success); }
.tips li { margin-bottom: 6px; }
.ex-title { margin-top: 0; }
.next-bar { margin-top: 24px; text-align: center; }
.next-bar.is-done { border-color: var(--success); background: var(--success-soft); }
.next-title { font-weight: 800; font-size: 1.1rem; color: var(--success); }
.next-bar .q-actions { justify-content: center; }
.lesson-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ============================================================ visuals */
.viz { margin: 18px 0; box-shadow: none; padding: 18px; }
.viz-title { font-weight: 700; margin-bottom: 12px; }
.viz-caption { color: var(--muted); font-size: 0.93rem; margin-top: 12px; }
.viz-array { display: flex; flex-wrap: wrap; gap: 6px; }
.cell { display: grid; text-align: center; min-width: 58px; }
.cell-idx { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); }
.cell-val { font-family: var(--mono); font-weight: 700; border: 2px solid var(--primary-hover); border-radius: 8px; padding: 6px 10px; background: var(--primary-soft); white-space: pre; min-height: 40px; display: grid; place-items: center; }
.cell.is-hl .cell-val { background: var(--warn-soft); border-color: var(--warn); }
.table-wrap { overflow-x: auto; }
.viz-table th, .viz-table td { border: 1px solid var(--border); padding: 8px 12px; text-align: start; }
.viz-table thead th { background: var(--surface-2); }
.viz-table tbody th { background: var(--surface-2); font-weight: 600; }
.viz-table.matrix th, .viz-table.matrix td { text-align: center; font-family: var(--mono); }
.viz-table.matrix .corner { background: transparent; border-color: transparent; }
.viz-flow { list-style: none; padding: 0; margin: 0; display: grid; gap: 22px; }
.viz-flow li { position: relative; background: var(--surface-2); border: 1.5px solid var(--primary-hover); border-radius: 12px; padding: 10px 16px; text-align: center; }
.viz-flow li:not(:last-child)::after { content: '↓'; position: absolute; inset-inline: 0; bottom: -24px; color: var(--accent); font-weight: 800; line-height: 22px; }
.viz-vars { display: flex; flex-wrap: wrap; gap: 14px; }
.var-box { display: grid; text-align: center; min-width: 96px; border: 2px solid var(--accent); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.var-name { font-family: var(--mono); font-weight: 700; padding: 2px 10px; background: var(--accent-soft); }
.var-value { font-family: var(--mono); font-size: 1.15rem; font-weight: 800; padding: 8px 10px; }
.var-type { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); padding: 2px; border-top: 1px dashed var(--border); }

/* ============================================================ questions */
.question { margin-block: 16px; box-shadow: none; }
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.q-count { color: var(--muted); font-size: 0.9rem; }
.q-prompt { font-weight: 700; font-size: 1.1rem; }
.options { border: 0; padding: 0; margin: 12px 0; display: grid; gap: 10px; min-width: 0; }
.opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface-2); transition: border-color 0.15s, background 0.15s; min-height: 50px; }
.opt:hover { border-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--primary-hover); background: var(--primary-soft); }
.opt input { width: 20px; height: 20px; accent-color: var(--primary-hover); flex-shrink: 0; margin: 0; }
.opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt-text.mono { font-family: var(--mono); white-space: pre-wrap; text-align: left; }
.opt-mark { font-weight: 800; font-size: 1.1rem; }
.opt.is-correct { border-color: var(--success); background: var(--success-soft); }
.opt.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt.is-correct .opt-mark { color: var(--success); }
.opt.is-wrong .opt-mark { color: var(--danger); }
.options:disabled .opt { cursor: default; }
.q-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.q-actions.wrap { flex-wrap: wrap; }
.q-feedback:empty { display: none; }
.q-feedback { margin-top: 14px; padding: 14px 18px; border-radius: 12px; border: 1.5px solid var(--border); }
.q-feedback.is-correct { border-color: var(--success); background: var(--success-soft); }
.q-feedback.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.fb-title { font-weight: 800; margin-bottom: 6px; }
.fb-explain { margin-bottom: 6px; }
.fb-xp { font-weight: 700; color: var(--accent); margin: 6px 0 0; }
.fb-xp.muted { font-weight: 400; color: var(--muted); }
.complete-code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin: 12px 0; font-size: 0.92rem; }
.blank { font-family: var(--mono); background: var(--surface); border: 2px dashed var(--accent); border-radius: 6px; color: var(--tok-num); padding: 0 8px; min-width: 7ch; width: 10ch; text-align: left; line-height: 1.5; }
.blank.is-correct { border-style: solid; border-color: var(--success); }
.blank.is-wrong { border-style: solid; border-color: var(--danger); }
.check-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.check-list .ok { color: var(--success); }
.check-list .bad { color: var(--danger); font-weight: 700; }
.hint-box, .solution-box { margin-top: 10px; padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid var(--warn); }
.solution-box { background: var(--surface-2); border-color: var(--border); }
.test-intro .meta-list { margin-bottom: 18px; }
.result-card { text-align: center; }
.result-card.is-pass { border-color: var(--success); }
.result-card.is-fail { border-color: var(--warn); }
.score { display: grid; margin-bottom: 8px; }
.score-num { font-size: 3.4rem; font-weight: 800; line-height: 1.2; }
.score-sub { color: var(--muted); }
.result-card .q-actions { justify-content: center; }
.xp-table { margin-top: 28px; }
.xp-table th, .xp-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: start; }

/* ============================================================ progress / dashboard */
.progress { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-block: 6px 14px; }
.progress-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7c3aed, #22d3ee); transition: width 0.6s var(--ease); }
.dashboard { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.dash-main { grid-column: 1; }
.dash-badges { grid-column: 2; grid-row: 1 / span 2; }
.data-tools { grid-column: 1; }
.dash-top { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.dash-name { flex: 1; min-width: 200px; }
.dash-name h2 { margin-bottom: 6px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.5rem; }
.level-badge { display: grid; text-align: center; padding: 6px 16px; border-radius: 14px; background: var(--primary-soft); border: 1.5px solid var(--primary-hover); }
.level-num { font-size: 1.7rem; font-weight: 800; line-height: 1.2; }
.level-title { font-size: 0.85rem; color: var(--muted); }
.xp-row { display: flex; justify-content: space-between; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-block: 8px 16px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; display: grid; border: 1px solid var(--border); }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.3; }
.stat-label { color: var(--muted); font-size: 0.88rem; }
.badges { list-style: none; padding: 0; display: grid; gap: 10px; margin: 0; }
.badge { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.badge.is-locked { opacity: 0.78; border-style: dashed; }
.badge.is-earned { border-color: var(--success); background: var(--success-soft); }
.badge-icon { font-size: 1.7rem; width: 40px; text-align: center; }
.badge-text { display: grid; line-height: 1.5; }
.badge-text small { color: var(--muted); }
.badge-state { font-weight: 700; }
.data-tools summary { cursor: pointer; font-weight: 700; min-height: 32px; }

.roadmap { list-style: none; padding: 0; margin: 0; display: grid; gap: 18px; position: relative; }
.road-item { display: grid; grid-template-columns: 56px 1fr; gap: 16px; position: relative; }
.road-item:not(:last-child)::before { content: ''; position: absolute; inset-inline-start: 27px; top: 56px; bottom: -18px; width: 2px; background: var(--border); }
.road-node { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--surface); border: 2.5px solid var(--border); z-index: 1; }
.is-open .road-node { border-color: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft); }
.is-done .road-node { border-color: var(--success); }
.is-locked .road-node { filter: grayscale(1); opacity: 0.7; }
.road-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.road-head h3 { margin-bottom: 4px; }
.goals { color: var(--muted); font-size: 0.96rem; }
.lesson-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.lesson-list li a, .lesson-list .locked-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; color: var(--text); min-height: 44px; }
.lesson-list li a:hover { border-color: var(--accent); }
.lesson-list .is-done a { border-color: var(--success); }
.lesson-list .locked-item { color: var(--muted); border-style: dashed; }
.li-title { flex: 1; }
.li-meta { color: var(--muted); font-size: 0.85rem; }
.test-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--primary-hover); background: var(--primary-soft); flex-wrap: wrap; }
.test-row.is-locked { border-style: dashed; border-color: var(--border); background: var(--surface-2); }
.test-row.is-done { border-color: var(--success); background: var(--success-soft); }
.unlock-req { padding: 10px 14px; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 10px; margin-bottom: 10px; }

/* ============================================================ chat */
.chat { padding: 0; overflow: hidden; }
.chat-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.mode-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.mode-btn { min-height: 40px; padding: 4px 14px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 0.93rem; }
.mode-btn:hover { border-color: var(--accent); }
.mode-btn.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ctx-chip { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; background: var(--accent-soft); font-size: 0.9rem; }
.chat-log { height: min(56vh, 560px); overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: min(92%, 780px); display: grid; gap: 2px; }
.msg-who { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.msg-body { padding: 10px 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); overflow-wrap: anywhere; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-user { align-self: flex-start; }
.msg-user .msg-body { background: var(--primary-soft); border-color: var(--primary-hover); }
.msg-assistant { align-self: flex-end; }
.msg.is-error .msg-body { border-color: var(--danger); background: var(--danger-soft); }
.user-text { white-space: pre-wrap; margin: 0; }
.md-h { margin: 0.8em 0 0.3em; font-size: 1.05rem; }
.md-list { margin-block: 0.4em; }
.msg-body .code-block { margin: 10px 0; }
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
.suggestions { padding: 0 16px; margin: 0 0 10px; }
.suggestions:empty { display: none; }
.composer { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.chat-input { resize: none; min-height: 76px; max-height: 220px; }
.composer-bar { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.composer-bar .btn { margin-inline-start: auto; }
.disclaimer { margin-top: 14px; }

/* ============================================================ toasts / celebrate / dialog */
.toasts { position: fixed; inset-block-end: 18px; inset-inline-start: 18px; z-index: 300; display: grid; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 16px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); transition: opacity 0.25s, transform 0.25s var(--ease); font-weight: 600; max-width: min(92vw, 380px); }
.toast.show { opacity: 1; transform: none; }
.toast-xp { border-color: var(--warn); }
.toast-ok { border-color: var(--success); }
.toast-err { border-color: var(--danger); }
.toast-warn { border-color: var(--warn); }
.toast-icon { font-weight: 800; }
.celebrate { position: fixed; inset-block-start: 84px; inset-inline: 0; z-index: 310; display: grid; justify-items: center; gap: 10px; pointer-events: none; padding-inline: 12px; }
.celebrate-card { position: relative; pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--surface); border: 2px solid var(--primary-hover); border-radius: 18px; box-shadow: 0 20px 50px -15px rgba(124, 58, 237, 0.6); animation: pop 0.5s var(--ease); max-width: 480px; }
.celebrate-card.tone-stage, .celebrate-card.tone-unlock { border-color: var(--success); }
.celebrate-card.tone-level { border-color: var(--accent); }
.celebrate-icon { font-size: 2.4rem; animation: wiggle 1s 0.4s ease-in-out 2; }
.celebrate-title { display: block; }
.celebrate-text { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.confetti { position: absolute; inset-inline: 50%; top: 30%; pointer-events: none; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: burst 1.3s var(--d, 0ms) ease-out forwards; }
@keyframes burst { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)); } }
@keyframes pop { 0% { transform: scale(0.7) translateY(-14px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; max-width: min(92vw, 440px); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(5, 8, 20, 0.65); }
.dialog-body { padding: 22px; }
.dialog-title { font-size: 1.2rem; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ============================================================ motion preferences */
@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; }
}

.not-found { padding-block: 80px; text-align: center; }
.not-found .lead { margin-inline: auto; }
