/* ======================================================
   SOSEEKS PYTHON ACADEMY — Learning Platform Styles
   ====================================================== */

:root {
    --bg: #030014;
    --bg-card: rgba(255,255,255,0.03);
    --bg-card-hover: rgba(255,255,255,0.06);
    --bg-code: #0d1117;
    --border: rgba(99,102,241,0.12);
    --border-hover: rgba(99,102,241,0.3);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --accent: #c471ed;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-code: 'Fira Code', monospace;
    --radius: 16px;
    --sidebar-w: 280px;
    --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; width: 100%; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
}
a { color: var(--primary-light); text-decoration: none; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, select { font: inherit; }
code { font-family: var(--font-code); font-size: 0.88em; background: rgba(99,102,241,0.1); padding: 2px 6px; border-radius: 4px; color: var(--primary-light); overflow-wrap: break-word; word-break: break-word; }
strong { color: var(--text); font-weight: 600; }

.app-hidden { display: none !important; }
.view-hidden { display: none !important; }

/* ======== SCROLLBAR ======== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.4); }

/* ============================================================
   ACCESS GATE
   ============================================================ */
#gate {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    transition: opacity 0.6s, visibility 0.6s;
    overflow-y: auto; overflow-x: hidden;
}
@media (max-width: 768px) {
    #gate {
        flex-direction: column; align-items: center; justify-content: flex-start;
        padding: 32px 14px 40px;
        -webkit-overflow-scrolling: touch;
    }
}
#gate.gate-unlocked { opacity: 0; visibility: hidden; pointer-events: none; }

.gate-particles {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(196,113,237,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(6,182,212,0.05) 0%, transparent 50%);
    animation: gateFloat 8s ease-in-out infinite alternate;
}
@keyframes gateFloat {
    0% { transform: scale(1) translate(0,0); }
    100% { transform: scale(1.05) translate(-10px, 10px); }
}

.gate-card {
    position: relative; z-index: 1; text-align: center;
    padding: 48px 40px; width: 420px; max-width: 92vw;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}
.gate-glow {
    position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
    width: 60%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
}
.gate-logo {
    font-family: var(--font-display); font-size: 1.4rem; font-weight: 800;
    background: linear-gradient(135deg, #4a6cf7, #7b5ea7, #c471ed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: 8px;
}
.gate-title {
    font-family: var(--font-display); font-size: 1.8rem; font-weight: 700;
    margin-bottom: 8px;
}
.gate-title span { color: var(--primary-light); }
.gate-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }
.gate-input-group {
    display: flex; gap: 0;
    border: 1px solid var(--border); border-radius: 12px;
    overflow: hidden; transition: border-color 0.3s;
}
.gate-input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 20px rgba(99,102,241,0.15); }
.gate-input-group input {
    flex: 1; padding: 14px 18px; border: none; outline: none;
    background: transparent; color: var(--text);
    font-size: 0.95rem; letter-spacing: 2px;
}
.gate-input-group input::placeholder { color: var(--text-dim); letter-spacing: 1px; }
.gate-input-group button {
    padding: 14px 20px; background: var(--primary); transition: background 0.3s;
}
.gate-input-group button:hover { background: #4f46e5; }
.gate-input-group button svg { width: 20px; height: 20px; color: white; }
.gate-error { color: var(--error); font-size: 0.85rem; min-height: 24px; margin-top: 12px; }
.gate-hint { color: var(--text-dim); font-size: 0.75rem; margin-top: 20px; }

.gate-card.shake {
    animation: shakeCard 0.5s;
}
@keyframes shakeCard {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-12px); }
    40% { transform: translateX(12px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(8px); }
}

/* ============================================================
   TOP BAR
   ============================================================ */
#topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; z-index: 100;
    background: rgba(3,0,20,0.85); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-hamburger {
    width: 32px; height: 32px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px;
    border-radius: 8px; transition: background 0.3s;
}
.topbar-hamburger:hover { background: rgba(99,102,241,0.1); }
.topbar-hamburger span {
    display: block; width: 18px; height: 2px; background: var(--text-muted);
    border-radius: 1px; transition: all 0.3s;
}
.topbar-hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.topbar-hamburger.active span:nth-child(2) { opacity: 0; }
.topbar-hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

.topbar-logo {
    font-family: var(--font-display); font-size: 1.1rem; font-weight: 800;
    background: linear-gradient(135deg, #4a6cf7, #c471ed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.topbar-sep { color: var(--text-dim); font-weight: 200; }
.topbar-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }

.topbar-progress { flex: 1; max-width: 300px; display: flex; align-items: center; gap: 10px; margin: 0 24px; }
.topbar-progress-track {
    flex: 1; height: 6px; background: rgba(99,102,241,0.1);
    border-radius: 3px; overflow: hidden;
}
.topbar-progress-fill {
    height: 100%; width: 0%; border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.topbar-progress-label { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; font-weight: 600; }

.topbar-right { display: flex; gap: 4px; }
.topbar-icon-btn {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; transition: all 0.3s;
}
.topbar-icon-btn:hover { background: rgba(99,102,241,0.1); }
.topbar-icon-btn svg { width: 18px; height: 18px; color: var(--text-muted); }

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    width: var(--sidebar-w); z-index: 90;
    background: rgba(3,0,20,0.92); backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    overflow-y: auto; overflow-x: hidden;
    transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
#sidebar.sidebar-open { transform: translateX(0); }

#sidebar-overlay {
    position: fixed; inset: 0; z-index: 92; background: rgba(0,0,0,0.6);
    opacity: 0; visibility: hidden; transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
}
#sidebar-overlay.active { opacity: 1; visibility: visible; }

.sidebar-head {
    padding: 24px 20px; text-align: center;
    border-bottom: 1px solid var(--border);
}
.sidebar-ring-wrap { position: relative; width: 90px; height: 90px; margin: 0 auto 16px; }
.sidebar-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(99,102,241,0.1); stroke-width: 6; }
.ring-bar {
    fill: none; stroke: url(#ringGrad); stroke-width: 6;
    stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4,0,0.2,1);
}
.ring-pct {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--primary-light);
}
.sidebar-stats { display: flex; justify-content: center; gap: 20px; }
.sb-stat { text-align: center; }
.sb-stat strong { display: block; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.sb-stat small { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

#sidebar-nav { padding: 12px 0; }
.nav-module {
    border-bottom: 1px solid rgba(99,102,241,0.06);
}
.nav-module-btn {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 12px 20px; text-align: left; transition: background 0.2s;
    font-size: 0.85rem; font-weight: 500;
}
.nav-module-btn:hover { background: rgba(99,102,241,0.06); }
.nav-module-btn .mod-icon { font-size: 1.1rem; width: 28px; text-align: center; flex-shrink: 0; }
.nav-module-btn .mod-title { flex: 1; color: var(--text-muted); }
.nav-module-btn .mod-chevron {
    width: 16px; height: 16px; color: var(--text-dim); transition: transform 0.3s;
}
.nav-module.open .mod-chevron { transform: rotate(90deg); }
.nav-module-btn .mod-check { color: var(--success); font-size: 0.8rem; }

.nav-topics {
    max-height: 0; overflow: hidden; transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1);
}
.nav-module.open .nav-topics { max-height: 600px; }
.nav-topic-btn {
    width: 100%; display: flex; align-items: center; gap: 8px;
    padding: 8px 20px 8px 52px; text-align: left; font-size: 0.8rem;
    color: var(--text-dim); transition: all 0.2s; border-left: 2px solid transparent;
}
.nav-topic-btn:hover { color: var(--text-muted); background: rgba(99,102,241,0.04); }
.nav-topic-btn.active { color: var(--primary-light); border-left-color: var(--primary); background: rgba(99,102,241,0.06); }
.nav-topic-btn.completed { color: var(--success); }
.nav-topic-btn .topic-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-dim); flex-shrink: 0; transition: background 0.3s;
}
.nav-topic-btn.active .topic-dot { background: var(--primary-light); box-shadow: 0 0 8px var(--primary); }
.nav-topic-btn.completed .topic-dot { background: var(--success); }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
#main {
    margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
    min-height: calc(100vh - var(--topbar-h));
    padding: 32px 40px 60px;
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-x: hidden; max-width: 100%;
}
#main.full-width { margin-left: 0; }

/* ======== DASHBOARD ======== */
.dash-hero {
    text-align: center; padding: 40px 0 48px;
}
.dash-hero h1 {
    font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800; margin-bottom: 12px;
}
.dash-hero h1 .glow { color: var(--primary-light); }
.dash-hero p { color: var(--text-muted); max-width: 500px; margin: 0 auto; font-size: 0.95rem; }

.dash-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px; max-width: 1100px; margin: 0 auto;
}
.dash-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px; cursor: pointer;
    transition: all 0.4s; position: relative; overflow: hidden;
}
.dash-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--card-accent, var(--primary));
    transform: scaleX(0); transform-origin: left; transition: transform 0.4s;
}
.dash-card:hover { border-color: var(--border-hover); transform: translateY(-4px); box-shadow: 0 12px 40px rgba(99,102,241,0.08); }
.dash-card:hover::before { transform: scaleX(1); }
.dash-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.dash-card-icon { font-size: 1.8rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: rgba(99,102,241,0.06); border-radius: 12px; }
.dash-card-meta { flex: 1; }
.dash-card-meta h3 { font-family: var(--font-display); font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.dash-card-meta small { font-size: 0.72rem; color: var(--text-dim); }
.dash-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; }
.dash-card-progress { height: 4px; background: rgba(99,102,241,0.1); border-radius: 2px; overflow: hidden; }
.dash-card-progress-fill { height: 100%; border-radius: 2px; background: var(--card-accent, var(--primary)); transition: width 0.6s; }
.dash-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.dash-card-footer span { font-size: 0.75rem; color: var(--text-dim); }

/* ======== TOPIC VIEW ======== */
.topic-header {
    max-width: 800px; margin: 0 auto 40px; padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
    overflow-wrap: break-word; word-break: break-word;
}
.topic-breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; color: var(--text-dim); margin-bottom: 16px;
}
.topic-breadcrumb a { color: var(--text-dim); transition: color 0.2s; }
.topic-breadcrumb a:hover { color: var(--primary-light); }
.topic-header h1 {
    font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700; margin-bottom: 8px;
}
.topic-header p { color: var(--text-muted); font-size: 0.95rem; }
.topic-nav-btns {
    display: flex; gap: 12px; margin-top: 20px;
}
.topic-nav-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px; font-size: 0.8rem; font-weight: 500;
    border: 1px solid var(--border); color: var(--text-muted); transition: all 0.3s;
}
.topic-nav-btn:hover { border-color: var(--primary); color: var(--primary-light); }

.topic-section {
    max-width: 800px; margin: 0 auto 48px; overflow-x: hidden;
}
.section-label {
    font-family: var(--font-display); font-size: 0.65rem; font-weight: 600;
    letter-spacing: 3px; text-transform: uppercase; color: var(--primary-light);
    margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* -- Analogy Section -- */
.analogy-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px; overflow: hidden;
    max-width: 100%;
}
.analogy-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.analogy-title .emoji { font-size: 1.4rem; }
.analogy-desc { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 24px; line-height: 1.7; }

/* Analogy animation container */
.analogy-visual {
    min-height: 120px; display: flex; align-items: center; justify-content: center;
    gap: 20px; flex-wrap: wrap; padding: 20px;
    background: rgba(0,0,0,0.2); border-radius: 12px;
    overflow-x: auto; max-width: 100%;
}

/* -- Jar Animation (Variables) -- */
.anim-jar {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    opacity: 0; animation: jarAppear 0.6s forwards;
    animation-delay: var(--d, 0s);
}
@keyframes jarAppear {
    0% { opacity: 0; transform: translateY(-30px); }
    60% { transform: translateY(5px); }
    100% { opacity: 1; transform: translateY(0); }
}
.jar-label {
    font-family: var(--font-code); font-size: 0.75rem;
    padding: 2px 10px; background: var(--primary); border-radius: 4px; color: white;
}
.jar-body {
    width: 70px; height: 80px; border: 2px solid var(--border-hover);
    border-radius: 0 0 16px 16px; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
    background: rgba(99,102,241,0.04);
}
.jar-body::before {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 0%; background: rgba(99,102,241,0.1);
    animation: jarFill 0.8s 0.4s forwards; animation-delay: calc(var(--d, 0s) + 0.4s);
}
@keyframes jarFill { to { height: 70%; } }
.jar-value {
    font-family: var(--font-code); font-size: 0.8rem; color: var(--success);
    position: relative; z-index: 1;
}

/* -- Traffic Light Animation (if/else) -- */
.anim-traffic {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 20px; background: #1a1a2e; border-radius: 12px; border: 2px solid #333;
}
.traffic-light {
    width: 44px; height: 44px; border-radius: 50%;
    background: #222; border: 2px solid #444; transition: all 0.5s;
}
.traffic-light.red.active { background: #ef4444; box-shadow: 0 0 20px rgba(239,68,68,0.6); }
.traffic-light.yellow.active { background: #f59e0b; box-shadow: 0 0 20px rgba(245,158,11,0.6); }
.traffic-light.green.active { background: #10b981; box-shadow: 0 0 20px rgba(16,185,129,0.6); }
.traffic-label {
    font-family: var(--font-code); font-size: 0.75rem; color: var(--text-dim);
    margin-top: 8px;
}

/* -- Train Animation (Lists) -- */
.anim-train {
    display: flex; align-items: center; gap: 0;
    animation: trainSlide 1.5s ease-out forwards;
    opacity: 0;
}
@keyframes trainSlide { 0% { opacity: 0; transform: translateX(-60px); } 100% { opacity: 1; transform: translateX(0); } }
.train-car {
    width: 64px; height: 50px; border: 2px solid var(--border-hover);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-code); font-size: 0.85rem; color: var(--primary-light);
    position: relative; background: rgba(99,102,241,0.04);
}
.train-car:first-child { border-radius: 8px 0 0 8px; }
.train-car:last-child { border-radius: 0 8px 8px 0; }
.train-idx {
    position: absolute; top: -18px; font-size: 0.6rem;
    color: var(--text-dim); font-family: var(--font-code);
}

/* -- Machine Animation (Functions) -- */
.anim-machine {
    display: flex; align-items: center; gap: 16px;
}
.machine-input, .machine-output {
    padding: 10px 18px; border-radius: 8px; font-family: var(--font-code); font-size: 0.85rem;
}
.machine-input { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.machine-output { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.machine-box {
    width: 80px; height: 60px; background: rgba(99,102,241,0.1);
    border: 2px solid var(--primary); border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: 0.6rem; color: var(--primary-light);
    letter-spacing: 1px; position: relative;
}
.machine-arrow { color: var(--text-dim); font-size: 1.4rem; animation: arrowPulse 1s infinite; }
@keyframes arrowPulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* -- Gift Wrap Animation (Decorators) -- */
.anim-wrap {
    display: flex; align-items: center; gap: 24px;
}
.wrap-box {
    position: relative; transition: all 0.6s;
}
.wrap-inner {
    width: 60px; height: 60px; background: rgba(16,185,129,0.15);
    border: 2px solid var(--success); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-code); font-size: 0.75rem; color: var(--success);
}
.wrap-outer {
    position: absolute; inset: -10px; border: 2px dashed var(--warning);
    border-radius: 12px; opacity: 0; animation: wrapAppear 0.6s 0.8s forwards;
}
@keyframes wrapAppear { to { opacity: 1; } }
.wrap-label {
    font-family: var(--font-code); font-size: 0.7rem; text-align: center;
}

/* -- Conveyor Animation (Iterators) -- */
.anim-conveyor {
    display: flex; align-items: center; gap: 6px;
    overflow: hidden; padding: 10px;
}
.conveyor-item {
    width: 44px; height: 44px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-code); font-size: 0.85rem;
    border: 1px solid var(--border);
    animation: conveyorSlide 0.5s forwards;
    animation-delay: var(--d);
    opacity: 0; transform: translateX(20px);
}
@keyframes conveyorSlide { to { opacity: 1; transform: translateX(0); } }
.conveyor-item.consumed {
    background: rgba(16,185,129,0.1); border-color: var(--success); color: var(--success);
}
.conveyor-item.waiting {
    background: rgba(99,102,241,0.06); color: var(--text-dim);
}

/* -- Chef Animation (Multithreading) -- */
.anim-chefs {
    display: flex; gap: 24px; justify-content: center;
}
.chef-lane {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 12px; border-radius: 12px; border: 1px solid var(--border);
    min-width: 80px;
}
.chef-emoji { font-size: 1.8rem; }
.chef-task {
    font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-code);
    padding: 3px 8px; background: rgba(99,102,241,0.06); border-radius: 4px;
    animation: chefBlink 1.2s infinite;
    animation-delay: var(--d);
}
@keyframes chefBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* -- Explanation Section -- */
.theory-content {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px;
    font-size: 0.92rem; line-height: 1.8;
    overflow-wrap: break-word; word-break: break-word; max-width: 100%;
}
.theory-content p { margin-bottom: 16px; color: var(--text-muted); }
.theory-content p:last-child { margin-bottom: 0; }
.theory-content ul, .theory-content ol { margin: 12px 0; padding-left: 4px; }
.theory-content li { position: relative; padding-left: 20px; margin-bottom: 8px; color: var(--text-muted); }
.theory-content li::before { content: '▹'; position: absolute; left: 0; color: var(--primary-light); }
.theory-content h3 { font-size: 1rem; margin: 20px 0 10px; color: var(--text); }

/* -- Code Section -- */
.code-block {
    background: var(--bg-code); border: 1px solid rgba(99,102,241,0.1);
    border-radius: 12px; overflow: hidden; margin-bottom: 16px;
    max-width: 100%;
}
.code-block-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: rgba(99,102,241,0.04);
    border-bottom: 1px solid rgba(99,102,241,0.08);
}
.code-block-title { font-size: 0.78rem; color: var(--text-dim); font-weight: 500; }
.code-block-dots { display: flex; gap: 6px; }
.code-block-dots span { width: 10px; height: 10px; border-radius: 50%; }
.code-block-dots span:nth-child(1) { background: #ef4444; }
.code-block-dots span:nth-child(2) { background: #f59e0b; }
.code-block-dots span:nth-child(3) { background: #10b981; }
.code-body {
    padding: 20px; font-family: var(--font-code); font-size: 0.85rem;
    line-height: 1.8; overflow-x: auto; position: relative;
    max-width: 100%; -webkit-overflow-scrolling: touch;
}
.code-body .line { display: flex; }
.code-body .line-num {
    width: 32px; text-align: right; color: rgba(255,255,255,0.15);
    margin-right: 16px; user-select: none; flex-shrink: 0;
}
.code-body .line-text { white-space: pre; }
.code-body .line.highlight { background: rgba(99,102,241,0.08); padding: 0 4px; border-left: 2px solid var(--primary); }
.code-cursor { display: inline-block; width: 2px; height: 1.1em; background: var(--primary-light); animation: cursorBlink 1s infinite; vertical-align: text-bottom; }
@keyframes cursorBlink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* Syntax Highlighting */
.syn-kw { color: #c792ea; }
.syn-fn { color: #82aaff; }
.syn-str { color: #c3e88d; }
.syn-num { color: #f78c6c; }
.syn-cm { color: #546e7a; font-style: italic; }
.syn-op { color: #89ddff; }
.syn-bi { color: #ffcb6b; }
.syn-cls { color: #ffcb6b; }
.syn-self { color: #f07178; }
.syn-dec { color: #c792ea; }
.syn-bool { color: #f78c6c; }

.code-output {
    margin-top: 0; padding: 14px 20px;
    background: rgba(16,185,129,0.04);
    border-top: 1px solid rgba(16,185,129,0.1);
    font-family: var(--font-code); font-size: 0.82rem;
    color: var(--success);
}
.code-output::before {
    content: '>>> Output'; display: block; font-size: 0.7rem;
    color: var(--text-dim); margin-bottom: 6px; letter-spacing: 1px;
}

/* -- Key Takeaways -- */
.takeaways-card {
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(196,113,237,0.04));
    border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.takeaways-card h3 {
    font-family: var(--font-display); font-size: 0.8rem;
    letter-spacing: 2px; color: var(--primary-light); margin-bottom: 16px;
}
.takeaway-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 0; font-size: 0.88rem; color: var(--text-muted);
}
.takeaway-check {
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(16,185,129,0.15); display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px;
}
.takeaway-check svg { width: 10px; height: 10px; stroke: var(--success); }

/* -- Topic Navigation -- */
.topic-footer {
    max-width: 800px; margin: 48px auto 0;
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 32px; border-top: 1px solid var(--border);
}
.topic-footer-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 24px; border-radius: 10px;
    font-size: 0.85rem; font-weight: 500; transition: all 0.3s;
}
.topic-footer-btn.prev { border: 1px solid var(--border); color: var(--text-muted); }
.topic-footer-btn.prev:hover { border-color: var(--primary); color: var(--primary-light); }
.topic-footer-btn.next { background: var(--primary); color: white; }
.topic-footer-btn.next:hover { background: #4f46e5; }
.topic-footer-btn.quiz-start { background: linear-gradient(135deg, var(--warning), #f97316); color: white; }
.topic-footer-btn.quiz-start:hover { filter: brightness(1.1); }
.topic-footer-btn svg { width: 16px; height: 16px; }
.topic-footer-btn.done { background: var(--success); color: white; }

/* ============================================================
   QUIZ VIEW
   ============================================================ */
.quiz-container { max-width: 700px; margin: 0 auto; overflow-x: hidden; }
.quiz-header { text-align: center; margin-bottom: 40px; }
.quiz-header h2 {
    font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-bottom: 8px;
}
.quiz-header p { color: var(--text-muted); font-size: 0.9rem; }
.quiz-progress {
    display: flex; gap: 4px; margin-top: 20px; justify-content: center;
}
.quiz-dot {
    width: 28px; height: 4px; border-radius: 2px; background: rgba(99,102,241,0.15);
    transition: background 0.3s;
}
.quiz-dot.active { background: var(--primary); }
.quiz-dot.correct { background: var(--success); }
.quiz-dot.wrong { background: var(--error); }

.quiz-question-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 36px; margin-bottom: 24px;
    animation: quizSlideIn 0.4s ease-out;
    overflow-x: hidden; max-width: 100%;
}
@keyframes quizSlideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.quiz-q-num { font-family: var(--font-display); font-size: 0.65rem; letter-spacing: 2px; color: var(--primary-light); margin-bottom: 12px; }
.quiz-q-text { font-size: 1.05rem; font-weight: 500; margin-bottom: 8px; line-height: 1.6; }
.quiz-q-code {
    background: var(--bg-code); padding: 14px 18px; border-radius: 8px; margin: 12px 0 20px;
    font-family: var(--font-code); font-size: 0.85rem; line-height: 1.7;
    overflow-x: auto; white-space: pre; max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px; border-radius: 10px;
    border: 1px solid var(--border); cursor: pointer;
    transition: all 0.3s; font-size: 0.9rem;
}
.quiz-opt:hover { border-color: var(--primary); background: rgba(99,102,241,0.04); }
.quiz-opt .opt-letter {
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(99,102,241,0.08); font-weight: 600; font-size: 0.8rem;
    color: var(--text-muted); flex-shrink: 0;
}
.quiz-opt.selected { border-color: var(--primary); background: rgba(99,102,241,0.08); }
.quiz-opt.correct { border-color: var(--success); background: rgba(16,185,129,0.08); }
.quiz-opt.correct .opt-letter { background: var(--success); color: white; }
.quiz-opt.wrong { border-color: var(--error); background: rgba(239,68,68,0.08); }
.quiz-opt.wrong .opt-letter { background: var(--error); color: white; }
.quiz-opt.disabled { pointer-events: none; }

.quiz-explain {
    margin-top: 16px; padding: 16px; border-radius: 10px;
    font-size: 0.88rem; line-height: 1.6;
    animation: fadeIn 0.3s;
}
.quiz-explain.right { background: rgba(16,185,129,0.06); border-left: 3px solid var(--success); color: var(--text-muted); }
.quiz-explain.wrong-exp { background: rgba(239,68,68,0.06); border-left: 3px solid var(--error); color: var(--text-muted); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.quiz-next-btn {
    display: block; margin: 24px auto 0; padding: 12px 32px;
    border-radius: 10px; font-size: 0.9rem; font-weight: 500;
    background: var(--primary); color: white; transition: background 0.3s;
}
.quiz-next-btn:hover { background: #4f46e5; }

/* Quiz Results */
.quiz-results {
    text-align: center; animation: quizSlideIn 0.5s;
}
.quiz-results-circle {
    width: 140px; height: 140px; margin: 0 auto 24px; position: relative;
}
.quiz-results-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.results-track { fill: none; stroke: rgba(99,102,241,0.1); stroke-width: 8; }
.results-bar { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.5s cubic-bezier(0.4,0,0.2,1); }
.results-bar.great { stroke: var(--success); }
.results-bar.good { stroke: var(--warning); }
.results-bar.poor { stroke: var(--error); }
.quiz-results-pct {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: 1.6rem; font-weight: 800;
}
.quiz-results h2 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 8px; }
.quiz-results p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.quiz-results-badge {
    display: inline-block; padding: 8px 20px; border-radius: 50px;
    font-size: 0.85rem; font-weight: 600;
}
.quiz-results-badge.great { background: rgba(16,185,129,0.1); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.quiz-results-badge.good { background: rgba(245,158,11,0.1); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.quiz-results-badge.poor { background: rgba(239,68,68,0.1); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.quiz-results-actions { display: flex; gap: 12px; justify-content: center; margin-top: 28px; }
.quiz-results-actions button { padding: 12px 24px; border-radius: 10px; font-size: 0.85rem; font-weight: 500; transition: all 0.3s; }

/* ======== TOAST ======== */
.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px);
    padding: 12px 24px; border-radius: 10px; font-size: 0.85rem; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
    backdrop-filter: blur(12px); z-index: 9999;
    opacity: 0; transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); color: var(--success); }

/* ======== CONFETTI ======== */
.confetti-canvas {
    position: fixed; inset: 0; z-index: 10000; pointer-events: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* --- Tablet (1024px) --- */
@media (max-width: 1024px) {
    #sidebar { transform: translateX(-100%); z-index: 95; }
    #sidebar.sidebar-open { transform: translateX(0); }
    #main { margin-left: 0; }
}
@media (max-width: 768px) {
    #sidebar { width: 260px; }
}
@media (max-width: 480px) {
    #sidebar { width: 80vw; max-width: 280px; }
}

/* --- Mobile landscape / small tablet (768px) --- */
@media (max-width: 768px) {
    :root { --topbar-h: 52px; }
    #topbar { padding: 0 12px; height: 52px; }
    #sidebar { top: 52px; }
    .topbar-logo { font-size: 0.95rem; }
    .topbar-sep, .topbar-label { display: none; }
    .topbar-progress { display: none; }
    .topbar-icon-btn { width: 32px; height: 32px; }
    .topbar-icon-btn svg { width: 16px; height: 16px; }

    .sidebar-head { padding: 16px 14px; }
    .sidebar-ring-wrap { width: 70px; height: 70px; margin-bottom: 12px; }
    .ring-pct { font-size: 0.85rem; }
    .sb-stat strong { font-size: 0.95rem; }
    .sb-stat small { font-size: 0.6rem; }
    .sidebar-stats { gap: 14px; }
    .nav-module-btn { padding: 10px 16px; font-size: 0.82rem; }
    .nav-topic-btn { padding: 7px 16px 7px 44px; font-size: 0.78rem; }

    #main { margin-top: 52px; padding: 20px 14px 60px; }

    .dash-hero { padding: 24px 0 28px; }
    .dash-hero h1 { font-size: 1.4rem; }
    .dash-hero p { font-size: 0.85rem; }
    .dash-grid { grid-template-columns: 1fr; gap: 14px; }
    .dash-card { padding: 20px; }
    .dash-card-head { gap: 10px; margin-bottom: 12px; }
    .dash-card-icon { width: 40px; height: 40px; font-size: 1.4rem; border-radius: 10px; }
    .dash-card-meta h3 { font-size: 0.8rem; }
    .dash-card p { font-size: 0.82rem; margin-bottom: 12px; }

    .topic-header { margin: 0 auto 24px; padding-bottom: 20px; }
    .topic-header h1 { font-size: 1.3rem; }
    .topic-header p { font-size: 0.85rem; }
    .topic-nav-btns { flex-wrap: wrap; gap: 8px; }
    .topic-nav-btn { padding: 6px 12px; font-size: 0.75rem; }

    .topic-section { margin: 0 auto 28px; padding: 0; }
    .section-label { font-size: 0.6rem; letter-spacing: 2px; }

    .analogy-card { padding: 20px; }
    .analogy-title { font-size: 0.95rem; }
    .analogy-title .emoji { font-size: 1.2rem; }
    .analogy-desc { font-size: 0.85rem; margin-bottom: 16px; }
    .analogy-visual { gap: 10px; padding: 14px 10px; min-height: 80px; }

    .anim-jar { gap: 4px; }
    .jar-body { width: 54px; height: 62px; }
    .jar-label { font-size: 0.65rem; padding: 2px 6px; }
    .jar-value { font-size: 0.7rem; }

    .anim-traffic { padding: 10px 14px; }
    .traffic-light { width: 34px; height: 34px; }

    .anim-train { flex-wrap: wrap; justify-content: center; gap: 0; }
    .train-car { width: 48px; height: 40px; font-size: 0.75rem; }
    .train-idx { font-size: 0.5rem; top: -14px; }

    .anim-machine { flex-direction: column; gap: 8px; }
    .machine-input, .machine-output { padding: 8px 12px; font-size: 0.75rem; }
    .machine-box { width: 64px; height: 48px; font-size: 0.5rem; }
    .machine-arrow { transform: rotate(90deg); }

    .anim-wrap { flex-direction: column; gap: 16px; align-items: center; }
    .wrap-inner { width: 50px; height: 50px; font-size: 0.7rem; }

    .anim-conveyor { flex-wrap: wrap; justify-content: center; }
    .conveyor-item { width: 36px; height: 36px; font-size: 0.75rem; }

    .anim-chefs { gap: 12px; flex-wrap: wrap; justify-content: center; }
    .chef-lane { min-width: 64px; padding: 8px; }
    .chef-emoji { font-size: 1.4rem; }
    .chef-task { font-size: 0.6rem; }

    .theory-content { padding: 20px; font-size: 0.85rem; }
    .theory-content h3 { font-size: 0.92rem; }

    .code-block-head { padding: 8px 12px; }
    .code-block-title { font-size: 0.72rem; }
    .code-body { padding: 14px 10px; font-size: 0.78rem; line-height: 1.7; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .code-body .line-num { width: 24px; margin-right: 10px; font-size: 0.7rem; }
    .code-output { padding: 10px 14px; font-size: 0.75rem; }
    .code-output::before { font-size: 0.6rem; }

    .takeaways-card { padding: 20px; }
    .takeaways-card h3 { font-size: 0.72rem; }
    .takeaway-item { font-size: 0.82rem; gap: 8px; }

    .topic-footer { flex-direction: column; gap: 10px; margin: 28px auto 0; padding-top: 20px; }
    .topic-footer-btn { width: 100%; justify-content: center; padding: 10px 20px; font-size: 0.82rem; }

    .quiz-container { padding: 0; }
    .quiz-header { margin-bottom: 24px; }
    .quiz-header h2 { font-size: 1.1rem; }
    .quiz-header p { font-size: 0.82rem; }
    .quiz-dot { width: 20px; height: 3px; }
    .quiz-question-card { padding: 20px; margin-bottom: 16px; }
    .quiz-q-text { font-size: 0.92rem; }
    .quiz-q-code { padding: 10px 12px; font-size: 0.78rem; margin: 10px 0 16px; }
    .quiz-opt { padding: 12px 14px; gap: 10px; font-size: 0.85rem; }
    .quiz-opt .opt-letter { width: 24px; height: 24px; font-size: 0.72rem; }
    .quiz-explain { padding: 12px; font-size: 0.82rem; }
    .quiz-next-btn { padding: 10px 24px; font-size: 0.82rem; }

    .quiz-results-circle { width: 110px; height: 110px; }
    .quiz-results-pct { font-size: 1.3rem; }
    .quiz-results h2 { font-size: 1.1rem; }
    .quiz-results p { font-size: 0.82rem; }
    .quiz-results-actions { flex-direction: column; gap: 8px; }
    .quiz-results-actions button { padding: 10px 20px; font-size: 0.82rem; width: 100%; }
}

/* --- Small mobile (480px) --- */
@media (max-width: 480px) {
    #gate { padding: 40px 12px 30px; }
    .gate-card { padding: 24px 16px; width: 100%; max-width: 100%; }
    .gate-logo { font-size: 1.1rem; }
    .gate-title { font-size: 1.2rem; }
    .gate-desc { font-size: 0.8rem; margin-bottom: 18px; }
    .gate-input-group { border-radius: 10px; }
    .gate-input-group input { padding: 12px 12px; font-size: 0.85rem; letter-spacing: 1.5px; }
    .gate-input-group button { padding: 12px 14px; }
    .gate-input-group button svg { width: 18px; height: 18px; }
    .gate-hint { font-size: 0.68rem; }

    #main { padding: 16px 10px 50px; }

    .dash-hero { padding: 16px 0 20px; }
    .dash-hero h1 { font-size: 1.2rem; }
    .dash-hero p { font-size: 0.8rem; padding: 0 8px; }
    .dash-card { padding: 16px; }
    .dash-card-meta h3 { font-size: 0.75rem; }

    .topic-header h1 { font-size: 1.15rem; }
    .topic-breadcrumb { font-size: 0.72rem; flex-wrap: wrap; }

    .analogy-card { padding: 16px; }
    .analogy-title { font-size: 0.88rem; gap: 8px; }
    .analogy-desc { font-size: 0.8rem; }
    .analogy-visual { padding: 10px 8px; }

    .theory-content { padding: 16px; font-size: 0.82rem; line-height: 1.7; }

    .code-body { padding: 12px 8px; font-size: 0.72rem; }
    .code-body .line-num { width: 20px; margin-right: 8px; font-size: 0.65rem; }

    .takeaways-card { padding: 16px; }
    .takeaway-item { font-size: 0.78rem; }

    .quiz-question-card { padding: 16px; }
    .quiz-q-text { font-size: 0.85rem; }
    .quiz-opt { padding: 10px 12px; font-size: 0.8rem; }
    .quiz-explain { font-size: 0.78rem; padding: 10px; }

    .sidebar-stats { gap: 14px; }
    .sb-stat strong { font-size: 0.95rem; }
    .sb-stat small { font-size: 0.6rem; }
}
