:root {
    --primary: #e76f51;
    --primary-light: #f4a261;
    --success: #2a9d8f;
    --success-dim: rgba(42,157,143,0.15);
    --danger: #e63946;
    --warning: #e9c46a;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --text: #e0e0e0;
    --text-muted: #888;
    --border: #2d2d44;
    --radius: 12px;
    --radius-sm: 8px;
}
* { box-sizing: border-box; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 900px; margin: 0 auto; padding: 20px; }

.hero {
    text-align: center;
    padding: 48px 20px 20px;
    background: linear-gradient(180deg, #1a1a2e 0%, var(--bg) 100%);
}
.hero .logo { font-size: 3.5em; margin-bottom: 6px; }
.hero h1 { font-size: 2.4em; margin: 0 0 6px; color: white; font-weight: 700; letter-spacing: -0.5px; }
.hero p { color: var(--text-muted); font-size: 1.05em; margin: 0; }

.global-progress { max-width: 680px; margin: 0 auto 36px; padding: 0 20px; }
.gp-header { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.9em; }
.gp-label { color: var(--text-muted); font-weight: 500; }
.gp-count { color: var(--text); font-weight: 600; }
.gp-track { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; position: relative; }
.gp-fill-inner { height: 100%; border-radius: 5px; overflow: hidden; }
.gp-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--primary), var(--success)); transition: width 0.6s ease; box-shadow: 0 0 12px rgba(231,111,81,0.3); }

.path-timeline { max-width: 680px; margin: 0 auto; padding: 0 20px 40px; position: relative; }
.path-timeline::before {
    content: '';
    position: absolute;
    left: 44px;
    top: 12px;
    bottom: 12px;
    width: 3px;
    background: repeating-linear-gradient(to bottom, var(--border) 0px, var(--border) 8px, transparent 8px, transparent 12px);
}

.milestone { display: flex; gap: 24px; margin-bottom: 28px; position: relative; opacity: 0; animation: fadeSlide 0.4s ease forwards; }
.milestone:nth-child(1) { animation-delay: 0.05s; }
.milestone:nth-child(2) { animation-delay: 0.10s; }
.milestone:nth-child(3) { animation-delay: 0.15s; }
.milestone:nth-child(4) { animation-delay: 0.20s; }
.milestone:nth-child(5) { animation-delay: 0.25s; }
.milestone:nth-child(6) { animation-delay: 0.30s; }
.milestone:nth-child(7) { animation-delay: 0.35s; }
.milestone:nth-child(8) { animation-delay: 0.40s; }
.milestone:nth-child(9) { animation-delay: 0.45s; }
.milestone:nth-child(10) { animation-delay: 0.50s; }
.milestone:nth-child(11) { animation-delay: 0.55s; }
.milestone:nth-child(12) { animation-delay: 0.60s; }
.milestone:nth-child(13) { animation-delay: 0.65s; }

@keyframes fadeSlide { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.milestone-circle {
    width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1em; font-weight: 700; position: relative; z-index: 1;
    border: 3px solid; background: var(--bg); transition: transform 0.2s, box-shadow 0.2s;
}
.circle-num { font-size: 0.85em; letter-spacing: 0.5px; }
.circle-check { font-size: 1.3em; }
.circle-complete { border-color: var(--success); color: var(--success); box-shadow: 0 0 16px rgba(42,157,143,0.25); }
.circle-progress { border-color: var(--warning); color: var(--warning); box-shadow: 0 0 12px rgba(233,196,106,0.2); animation: pulse 2s infinite; }
.circle-available { border-color: var(--primary); color: var(--primary-light); }
.circle-locked { border-color: var(--border); color: var(--text-muted); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 8px rgba(233,196,106,0.15); } 50% { box-shadow: 0 0 20px rgba(233,196,106,0.3); } }

.milestone-card {
    flex: 1; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.milestone:hover .milestone-circle { transform: scale(1.05); }
.card-complete { border-color: rgba(42,157,143,0.2); }
.card-progress { border-color: rgba(233,196,106,0.2); }
.card-available:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(231,111,81,0.15); border-color: var(--primary); }
.card-locked { opacity: 0.4; filter: grayscale(0.3); }

.card-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card-title-link { color: white; font-size: 1.05em; font-weight: 600; }
.card-title-text { color: var(--text-muted); font-size: 1.05em; font-weight: 600; }
.lock-icon { font-size: 0.9em; opacity: 0.6; }
.card-desc { color: var(--text-muted); font-size: 0.85em; margin: 0 0 12px; line-height: 1.4; }

.status-badge { font-size: 0.7em; padding: 2px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-complete { background: var(--success-dim); color: var(--success); }
.badge-progress { background: rgba(233,196,106,0.15); color: var(--warning); }
.badge-available { background: rgba(231,111,81,0.15); color: var(--primary-light); }
.badge-locked { background: rgba(255,255,255,0.05); color: var(--text-muted); }

.steps-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.step-badge { font-size: 0.78em; padding: 3px 10px; border-radius: 6px; font-weight: 500; }
.step-badge.done { background: var(--success-dim); color: var(--success); }
.step-badge.active { background: rgba(231,111,81,0.12); color: var(--primary-light); }
.step-badge.locked { background: rgba(255,255,255,0.04); color: var(--text-muted); }

.segments-bar { display: flex; gap: 4px; height: 5px; }
.seg { flex: 1; background: var(--border); border-radius: 3px; transition: background 0.3s; }
.seg.filled { background: linear-gradient(90deg, var(--primary), var(--success)); }

.complete-msg { margin-top: 8px; font-size: 0.82em; color: var(--success); font-weight: 500; }
.module-card-action { display: flex; justify-content: flex-end; margin-top: 14px; }
.module-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 0.84rem;
    font-weight: 700;
    box-shadow: 0 6px 14px -9px rgba(231,111,81,0.95);
    text-decoration: none;
    transition: transform .15s ease, background .15s ease;
}
.module-start-btn:hover,
.module-start-btn:focus-visible { background: var(--primary-light); color: #fff; text-decoration: none; transform: translateY(-1px); }
.module-start-icon {
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    font-size: 0.65rem;
}

.chapter-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.chapter-header h2 { color: white; margin: 0; }
.back-link { font-size: 0.9em; }

.chapter-stepper {
    display: flex; gap: 0; background: var(--bg-card);
    border-radius: 10px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 25px;
}
.nav-item {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 58px;
    padding: 10px 12px; color: var(--text-muted); font-weight: 500;
    transition: background 0.2s, color 0.2s, border-color 0.2s; border-right: 1px solid var(--border);
}
.nav-item:last-child { border-right: none; }
.nav-item strong, .nav-item small { display: block; text-align: left; }
.nav-item strong { color: inherit; font-size: 0.9rem; }
.nav-item small { margin-top: 2px; font-size: 0.7rem; opacity: 0.82; }
.nav-step-number {
    display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto;
    border: 1px solid currentColor; border-radius: 50%; font-size: 0.75rem; font-weight: 700;
}
.nav-item.available { color: #a9d2ff; background: rgba(88,166,255,0.08); }
.nav-item.done { color: #7ee2a8; background: rgba(46,164,79,0.10); }
.nav-item.locked { color: #777f90; background: rgba(255,255,255,0.018); cursor: not-allowed; }
.nav-item.active { color: white; background: var(--primary); }
.nav-item:hover:not(.locked) { text-decoration: none; background: rgba(231,111,81,0.2); }
.nav-item.active:hover { background: var(--primary); }

.slider { background: var(--bg-card); border-radius: var(--radius); padding: 30px; border: 1px solid var(--border); }
.slide-title { color: white; margin: 0 0 15px; font-size: 1.3em; }
.slide-content { line-height: 1.7; margin-bottom: 15px; }
.slide-content code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; color: var(--primary-light); }
.slide-code { background: var(--bg-input); border-radius: var(--radius-sm); padding: 15px; margin: 15px 0; overflow-x: auto; }
.slide-code pre { margin: 0; }
.slide-code code { background: none; padding: 0; color: #a6e3a1; font-size: 0.95em; }
.slide-code-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slide-code-label { font-size: 0.72em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.dots-container { text-align: center; margin: 20px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border); margin: 0 4px; transition: background 0.2s; }
.dot.active { background: var(--primary); transform: scale(1.2); }
.dot.done { background: var(--success); }

.slider-controls { display: flex; justify-content: space-between; align-items: center; }
.slide-counter { color: var(--text-muted); font-size: 0.9em; }
.btn-nav { background: var(--bg-input); border: 1px solid var(--border); color: var(--text); padding: 8px 20px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.2s; }
.btn-nav:hover:not(:disabled) { background: var(--primary); color: white; }
.btn-nav:disabled { opacity: 0.3; cursor: not-allowed; }

.finish-container { margin-top: 20px; text-align: center; }

.btn-primary { background: var(--primary); color: white; border: none; padding: 12px 30px; border-radius: var(--radius-sm); font-size: 1em; font-weight: 600; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }

.challenge-header { margin-bottom: 20px; }
.challenge-title { color: white; margin: 0 0 10px; }
.challenge-desc { line-height: 1.6; }
.challenge-desc code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; color: var(--primary-light); }
.hint { color: var(--text-muted); font-style: italic; font-size: 0.9em; margin-top: 10px; padding: 8px 12px; background: rgba(233,196,106,0.1); border-radius: 6px; border-left: 3px solid var(--warning); }

.editor-container { margin: 20px 0; }
.code-textarea {
    width: 100%; min-height: 200px; background: var(--bg-input); color: #a6e3a1;
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 15px;
    resize: vertical; outline: none; font-family: 'Courier New', Courier, monospace;
    font-size: 14px; line-height: 1.5; tab-size: 4;
}
.code-textarea:focus { border-color: var(--primary); }
.code-output { background: #0d1117; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 15px; margin-top: 10px; min-height: 60px; font-family: 'Courier New', monospace; font-size: 13px; white-space: pre-wrap; }

.editor-buttons { display: flex; gap: 10px; margin: 15px 0; }
.btn-run { background: var(--success); color: white; border: none; padding: 10px 25px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.btn-run:hover { opacity: 0.85; }
.btn-verify { background: var(--primary); color: white; border: none; padding: 10px 25px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.btn-verify:hover { opacity: 0.85; }

.verify-result { margin-top: 15px; }
.success { background: var(--success-dim); border: 1px solid var(--success); color: var(--success); padding: 15px; border-radius: var(--radius-sm); font-weight: 600; }
.fail { background: rgba(230,57,70,0.15); border: 1px solid var(--danger); color: var(--danger); padding: 15px; border-radius: var(--radius-sm); }
.fail code { display: block; margin-top: 5px; background: var(--bg-input); padding: 8px; border-radius: 4px; font-family: monospace; }
.info { color: var(--text-muted); margin-top: 8px; font-size: 0.9em; }
.loading { color: var(--warning); }
.ready { color: var(--success); }
.stderr { color: var(--danger); }
.stdout { color: var(--text); }
.muted { color: var(--text-muted); }

.quiz-container { max-width: 700px; position: relative; min-height: 300px; }
.quiz-page { display: none; opacity: 0; transition: opacity 0.3s ease; }
.quiz-page.active { display: block; opacity: 1; }

.quiz-progress { margin-bottom: 20px; }
.quiz-step { font-size: 0.85em; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; display: block; }
.qp-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.qp-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--primary), var(--primary-light)); transition: width 0.4s ease; }

.quiz-question-text { font-size: 1.15em; color: white; font-weight: 600; margin-bottom: 20px; line-height: 1.5; white-space: pre-line; }

.quiz-option { display: block; padding: 14px 18px; margin: 8px 0; background: var(--bg-input); border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: background 0.2s, border-color 0.2s, transform 0.15s; font-size: 1em; }
.quiz-option:hover { background: rgba(231,111,81,0.15); border-color: var(--primary); transform: translateX(4px); }
.quiz-option input { margin-right: 10px; accent-color: var(--primary); transform: scale(1.1); }
.quiz-option.selected { background: rgba(42,157,143,0.15); border-color: var(--success); }
.quiz-navigation {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}
.quiz-navigation .btn-secondary { margin-right: auto; }
.quiz-notice {
    margin: 0 0 16px;
    padding: 11px 14px;
    color: #f3cc79;
    background: rgba(243,204,121,0.12);
    border: 1px solid rgba(243,204,121,0.32);
    border-radius: var(--radius);
}

.quiz-result { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 25px; margin-top: 20px; }
.quiz-result h3 { color: white; margin: 0 0 10px; }
.quiz-score { font-size: 2em; font-weight: bold; color: var(--primary-light); }

.complete-page { text-align: center; padding: 60px 20px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.complete-page h2 { color: white; }
.complete-page .big-icon { font-size: 4em; margin-bottom: 15px; }
.next-chapter { display: inline-block; margin-top: 20px; background: var(--primary); color: white; padding: 12px 30px; border-radius: var(--radius-sm); font-weight: 600; transition: background 0.2s; }
.next-chapter:hover { background: var(--primary-light); text-decoration: none; }

.hljs { background: var(--bg-input) !important; }

.user-bar { display: flex; align-items: center; gap: 10px; padding: 8px 20px; background: var(--bg-card); border-bottom: 1px solid var(--border); font-size: 0.85em; }
.ub-logo { font-size: 1.1em; }
.ub-title { font-weight: 600; color: white; }
.ub-spacer { flex: 1; }
.ub-token { color: var(--text-muted); font-family: monospace; font-size: 0.9em; background: var(--bg-input); padding: 3px 8px; border-radius: 4px; cursor: default; }
.ub-logout { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85em; transition: border-color 0.2s, color 0.2s; }
.ub-logout:hover { border-color: var(--danger); color: var(--danger); }
.ub-view-token { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 0.82em; transition: border-color 0.2s, color 0.2s; }
.ub-view-token:hover { border-color: var(--primary); color: var(--primary-light); }

.tomodal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 1000; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; }
.tomodal-overlay.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.tomodal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; max-width: 480px; width: 90%; text-align: center; position: relative; animation: slideUp 0.25s ease; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.tomodal-close { position: absolute; top: 12px; right: 16px; font-size: 1.5em; color: var(--text-muted); cursor: pointer; line-height: 1; }
.tomodal-close:hover { color: white; }
.tomodal-icon { font-size: 2.5em; margin-bottom: 8px; }
.tomodal-title { font-size: 1.2em; color: white; font-weight: 600; margin-bottom: 20px; }
.tomodal-token { font-family: monospace; font-size: 0.8em; color: var(--primary-light); background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; word-break: break-all; user-select: all; line-height: 1.6; margin-bottom: 14px; text-align: center; }
.tomodal-warn { color: var(--warning); font-size: 0.82em; margin-bottom: 20px; line-height: 1.5; }
.tomodal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.copy-btn-tomodal { background: var(--primary); color: white; border: none; padding: 10px 22px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9em; transition: opacity 0.2s; }
.copy-btn-tomodal:hover { opacity: 0.85; }
.tomodal-close-btn { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); padding: 10px 22px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9em; }
.tomodal-close-btn:hover { border-color: var(--text-muted); }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { text-align: center; max-width: 400px; width: 100%; }
.login-icon { font-size: 4em; margin-bottom: 10px; }
.login-title { font-size: 2em; color: white; margin: 0 0 4px; font-weight: 700; }
.login-sub { color: var(--text-muted); margin: 0 0 30px; font-size: 0.95em; }
.login-note { color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; padding: 12px 16px; margin: -14px 0 24px; font-size: 0.9em; line-height: 1.5; }
.login-box { display: flex; flex-direction: column; gap: 15px; }
.login-btn { width: 100%; padding: 14px; font-size: 1.05em; }
.login-or { color: var(--text-muted); font-size: 0.85em; position: relative; text-align: center; }
.login-or::before, .login-or::after { content: ''; display: inline-block; width: 80px; height: 1px; background: var(--border); vertical-align: middle; margin: 0 10px; }
.login-input { width: 100%; padding: 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 1em; outline: none; box-sizing: border-box; font-family: monospace; text-align: center; }
.login-input:focus { border-color: var(--primary); }
.login-error { color: var(--danger); font-size: 0.85em; margin: 0; padding: 10px; background: rgba(230,57,70,0.1); border-radius: 6px; }

.tr-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.tr-card { text-align: center; max-width: 520px; width: 100%; }
.tr-icon { font-size: 3em; margin-bottom: 10px; }
.tr-title { font-size: 1.6em; color: white; margin: 0 0 8px; font-weight: 700; }
.tr-desc { color: var(--text-muted); margin: 0 0 24px; line-height: 1.5; }
.tr-token-row { display: flex; gap: 8px; align-items: center; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.tr-token { font-family: monospace; font-size: 0.85em; color: var(--primary-light); word-break: break-all; flex: 1; text-align: center; line-height: 1.6; user-select: all; }
.copy-btn { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.9em; white-space: nowrap; transition: opacity 0.2s; }
.copy-btn:hover { opacity: 0.85; }
.tr-warn { color: var(--warning); font-size: 0.82em; margin: 0 0 24px; }
.tr-go-row { margin-top: 8px; }
.tr-go { display: inline-block; padding: 14px 40px; }

.editor-container .CodeMirror { height: auto; min-height: 200px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 14px; background: var(--bg-input); color: #a6e3a1; }
.editor-container .CodeMirror-focused { border-color: var(--primary); }
.editor-container .CodeMirror-gutters { background: #0d1117; border-right: 1px solid var(--border); }
.editor-container .CodeMirror-cursor { border-left: 2px solid var(--primary-light); }
.editor-container .CodeMirror-selected { background: rgba(231,111,81,0.3) !important; }
.editor-container .CodeMirror-activeline-background { background: rgba(255,255,255,0.03); }

@media (max-width: 768px) {
    .container { max-width: 100%; padding: 12px; }
    .hero { padding: 28px 14px 14px; }
    .hero h1 { font-size: 1.6em; }
    .hero .logo { font-size: 2.4em; }
    .global-progress { max-width: 100%; padding: 0 12px; }
    .path-timeline { max-width: 100%; padding: 0 12px 24px; }
    .path-timeline::before { left: 28px; }
    .milestone-circle { width: 38px; height: 38px; font-size: 0.8em; }
    .milestone { gap: 12px; margin-bottom: 20px; }
    .milestone-card { padding: 12px 14px; }
    .card-title-link { font-size: 0.95em; }
    .card-desc { font-size: 0.78em; }
    .slider { padding: 16px; }
    .slide-title { font-size: 1.1em; }
    .chapter-stepper { font-size: 0.82em; }
    .nav-item { min-height: 54px; padding: 8px 6px; gap: 6px; }
    .nav-item strong { font-size: 0.8rem; }
    .nav-item small { font-size: 0.65rem; }
    .code-textarea { min-height: 150px; font-size: 13px; }
    .code-output { font-size: 12px; min-height: 40px; }
    .user-bar { flex-wrap: wrap; gap: 6px; padding: 6px 10px; font-size: 0.78em; }
    .editor-buttons { flex-direction: column; }
    .btn-run, .btn-verify { width: 100%; text-align: center; }
    .quiz-container { max-width: 100%; }
    .quiz-option { padding: 12px 14px; font-size: 0.9em; }
    .quiz-navigation { flex-wrap: wrap; }
    .login-card { max-width: 100%; padding: 0 10px; }
    .tomodal-box { padding: 20px; width: 95%; }
    .editor-container .CodeMirror { min-height: 150px; font-size: 13px; }
}
@media (max-width: 480px) {
    .hero h1 { font-size: 1.3em; }
    .milestone { flex-direction: column; align-items: flex-start; }
    .milestone-circle { width: 32px; height: 32px; font-size: 0.7em; }
    .path-timeline::before { left: 16px; }
    .slider-controls { flex-wrap: wrap; gap: 8px; justify-content: center; }
    .dot { width: 8px; height: 8px; margin: 0 3px; }
    .chapter-stepper { flex-wrap: wrap; }
    .nav-item { flex: 1 1 100%; justify-content: flex-start; padding: 8px 12px; font-size: 0.85em; border-right: 0; border-bottom: 1px solid var(--border); }
    .nav-item:last-child { border-bottom: 0; }
    .tr-token-row { flex-direction: column; }
    .steps-row { font-size: 0.72em; }
}

.ub-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    font-size: 0.9em;
}
.ub-link:hover { color: white; background: rgba(255,255,255,0.06); text-decoration: none; }

.editor-full {
    display: flex;
    height: calc(100vh - 45px);
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-width: 0;
}
.output-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.pane-title { font-weight: 600; color: var(--text); font-size: 0.85em; }
.pane-actions { display: flex; align-items: center; gap: 8px; }
.run-hint { font-size: 0.72em; color: var(--text-muted); }

.btn-run-sm {
    background: var(--success);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.82em;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-run-sm:hover { opacity: 0.85; }

.btn-clear {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.78em;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.btn-clear:hover { border-color: var(--text-muted); color: var(--text); }

.free-editor-ta { display: none; }

.pseudo-inputs-box {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 8px 14px;
    flex-shrink: 0;
}
.pseudo-inputs-box label {
    display: block;
    font-size: 0.78em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.pseudo-inputs-box textarea {
    width: 100%;
    min-height: 56px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    padding: 8px;
    box-sizing: border-box;
    resize: vertical;
}
.pseudo-inputs-box textarea:focus { border-color: var(--primary); outline: none; }

.editor-pane .CodeMirror {
    flex: 1;
    height: auto;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 0;
}
.editor-pane .CodeMirror-gutters { background: #0d1117; border-right: 1px solid var(--border); }
.editor-pane .CodeMirror-cursor { border-left: 2px solid var(--primary-light); }
.editor-pane .CodeMirror-selected { background: rgba(231,111,81,0.3) !important; }
.editor-pane .CodeMirror-activeline-background { background: rgba(255,255,255,0.03); }

.free-output {
    flex: 1;
    padding: 14px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-y: auto;
    background: #0d1117;
    color: var(--text);
}

@media (max-width: 768px) {
    .editor-full { flex-direction: column; height: auto; min-height: calc(100vh - 45px); }
    .editor-pane { border-right: none; border-bottom: 1px solid var(--border); min-height: 45vh; }
    .output-pane { min-height: 35vh; }
    .editor-pane .CodeMirror { min-height: 45vh; font-size: 13px; }
    .free-output { font-size: 12px; min-height: 35vh; }
}
@media (max-width: 480px) {
    .pane-header { padding: 6px 10px; font-size: 0.82em; }
    .btn-run-sm { padding: 5px 12px; font-size: 0.78em; }
    .run-hint { display: none; }
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    color: var(--text-muted);
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary-light); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); font-size: 1.1em; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

.hint-toggle {
    background: rgba(233,196,106,0.1);
    border: 1px solid rgba(233,196,106,0.3);
    color: var(--warning);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    margin-top: 10px;
    transition: background 0.2s;
}
.hint-toggle:hover { background: rgba(233,196,106,0.2); }

.next-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--success-dim);
    border: 1px solid rgba(42,157,143,0.3);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    margin-top: 20px;
    font-weight: 500;
    color: var(--success);
    flex-wrap: wrap;
}
.btn-banner {
    padding: 8px 20px;
    font-size: 0.9em;
    white-space: nowrap;
}
.quiz-result-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 25px;
    margin-top: 20px;
}
.quiz-result-box h3 { color: white; margin: 0 0 6px; font-size: 1.3em; }
.quiz-score { font-size: 2em; font-weight: bold; color: var(--primary-light); margin-bottom: 20px; }

.quiz-review { margin: 20px 0; display: flex; flex-direction: column; gap: 16px; }
.review-item {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color 0.2s;
}
.review-correct { border-color: rgba(42,157,143,0.4); }
.review-wrong { border-color: rgba(230,57,70,0.4); }

.review-q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.review-q-num { font-weight: 600; color: var(--text); font-size: 0.9em; }
.review-q-badge {
    font-size: 0.78em;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.review-correct .review-q-badge { background: var(--success-dim); color: var(--success); }
.review-wrong .review-q-badge { background: rgba(230,57,70,0.15); color: var(--danger); }

.review-q-text { color: white; font-weight: 500; margin-bottom: 10px; line-height: 1.5; font-size: 0.95em; }

.review-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 6px;
    font-size: 0.9em;
}
.opt-correct { background: var(--success-dim); color: var(--success); font-weight: 500; }
.opt-chosen { background: rgba(230,57,70,0.15); color: var(--danger); text-decoration: line-through; }
.opt-marker { width: 16px; text-align: center; font-weight: bold; }

.next-banner-inline { margin: 20px 0; text-align: center; }
.quiz-result-actions { margin-top: 20px; text-align: center; }
.btn-secondary {
    display: inline-block;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: border-color 0.2s;
}
.btn-secondary:hover { border-color: var(--text-muted); text-decoration: none; }

@media (max-width: 768px) {
    .next-banner { flex-direction: column; text-align: center; }
    .review-item { padding: 12px; }
}
@media (max-width: 480px) {
    .breadcrumb { font-size: 0.72em; }
    .review-q-header { flex-direction: column; gap: 4px; align-items: flex-start; }
}

/* ===== Presentaciones ===== */
.pres-page { max-width: 1100px; }

.page-header { margin: 22px 0 18px; }
.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.page-header h2 {
    font-size: 1.9rem;
    margin: 0 0 6px;
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.page-subtitle {
    margin: 0;
    font-size: 0.96rem;
    line-height: 1.5;
    color: var(--text-secondary, #8b8ba7);
}
.admin-presentations-link {
    flex: 0 0 auto;
    margin-top: 4px;
    padding: 9px 13px;
    border: 1px solid rgba(88,166,255,0.45);
    border-radius: 8px;
    color: #9ecbff;
    background: rgba(88,166,255,0.09);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
}
.admin-presentations-link:hover { background: rgba(88,166,255,0.17); text-decoration: none; }

/* Selector de asignatura (pills) */
.asignatura-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 26px;
}
.asignatura-tab {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted, #888);
    background: var(--bg-card, #1a1a2e);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.asignatura-tab:hover {
    color: #fff;
    border-color: rgba(88,166,255,0.45);
    text-decoration: none;
}
.asignatura-tab:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
}
.asignatura-tab.is-active {
    color: #fff;
    background: rgba(88,166,255,0.12);
    border-color: #58a6ff;
    box-shadow: 0 0 0 1px rgba(88,166,255,0.25), 0 8px 20px -10px rgba(88,166,255,0.55);
}
.asignatura-tab-icon { font-size: 1.05em; line-height: 1; }
.asignatura-tab-count {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-secondary, #8b8ba7);
    background: rgba(255,255,255,0.06);
    padding: 1px 8px;
    border-radius: 999px;
    line-height: 1.5;
}
.asignatura-tab.is-active .asignatura-tab-count {
    color: #58a6ff;
    background: rgba(88,166,255,0.18);
}

/* Bloque de asignatura */
.asignatura-block {
    padding: 2px 0 8px;
    margin-bottom: 12px;
    animation: presFadeIn .22s ease;
}
.asignatura-block.is-hidden { display: none; }
@keyframes presFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.asignatura-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 4px 4px 20px;
}
.asignatura-icono {
    font-size: 1.9rem;
    line-height: 1;
    flex-shrink: 0;
}
.asignatura-meta { flex: 1; min-width: 0; }
.asignatura-nombre {
    margin: 0 0 4px;
    font-size: 1.2rem;
    color: #fff;
    font-weight: 700;
}
.asignatura-desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary, #8b8ba7);
}

/* Grid de presentaciones */
.presentaciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

/* Card de presentación */
.presentacion-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 16px;
    background: var(--bg-card, #1a1a2e);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.presentacion-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #58a6ff, rgba(88,166,255,0));
    opacity: 0;
    transition: opacity .18s ease;
}
.presentacion-card:hover,
.presentacion-card:focus-visible {
    transform: translateY(-3px);
    border-color: rgba(88,166,255,0.55);
    background: #20203a;
    box-shadow: 0 14px 30px -18px rgba(88,166,255,0.55);
    text-decoration: none;
}
.presentacion-card:hover::before,
.presentacion-card:focus-visible::before { opacity: 1; }
.presentacion-card:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
}

.presentacion-card-body { flex: 1; min-width: 0; }
.presentacion-card-titulo {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 6px;
    font-size: 1.08rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    letter-spacing: -0.005em;
}
.presentacion-card-play {
    font-size: 0.62rem;
    color: #58a6ff;
    transform: translateY(-1px);
    flex-shrink: 0;
}
.presentacion-card-desc {
    margin: 0 0 10px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary, #8b8ba7);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.presentacion-card-tags {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tag-chip {
    font-size: 0.72rem;
    font-weight: 500;
    color: #b9c2e8;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 3px 9px;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
}
.presentacion-card-arrow {
    flex-shrink: 0;
    color: rgba(88,166,255,0.55);
    font-size: 1.05rem;
    line-height: 1;
    transition: transform .18s ease, color .18s ease;
}
.presentacion-card:hover .presentacion-card-arrow,
.presentacion-card:focus-visible .presentacion-card-arrow {
    color: #58a6ff;
    transform: translateX(3px);
}
.presentacion-card-unavailable {
    cursor: not-allowed;
    opacity: 0.7;
    background: rgba(255,255,255,0.025);
}
.presentacion-card-unavailable:hover {
    transform: none;
    border-color: var(--border, #2d2d44);
    background: rgba(255,255,255,0.025);
    box-shadow: none;
}
.presentacion-card-lock { font-size: 0.86rem; flex-shrink: 0; }
.presentacion-unavailable-label {
    display: inline-flex;
    margin-top: 2px;
    padding: 3px 8px;
    border-radius: 999px;
    color: #d5b066;
    background: rgba(213,176,102,0.12);
    border: 1px solid rgba(213,176,102,0.24);
    font-size: 0.72rem;
    font-weight: 600;
}

/* Administración de disponibilidad */
.admin-pres-page { max-width: 900px; }
.admin-pres-section {
    margin: 24px 0;
    padding: 18px;
    border: 1px solid var(--border, #2d2d44);
    border-radius: 14px;
    background: var(--bg-card, #1a1a2e);
}
.admin-pres-section h3 { margin: 0 0 12px; color: #fff; font-size: 1.05rem; }
.admin-pres-list { display: grid; gap: 8px; }
.admin-pres-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px;
    border-radius: 9px;
    background: rgba(255,255,255,0.035);
}
.admin-pres-row strong { display: block; color: #f0f4ff; font-size: 0.93rem; }
.admin-pres-row p { margin: 3px 0 0; color: var(--text-secondary, #8b8ba7); font-size: 0.8rem; line-height: 1.35; }
.availability-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    color: #d7def0;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}
.availability-toggle input { position: absolute; opacity: 0; }
.availability-switch {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #4b5264;
    transition: background .16s ease;
}
.availability-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform .16s ease;
}
.availability-toggle input:checked + .availability-switch { background: #2ea44f; }
.availability-toggle input:checked + .availability-switch::after { transform: translateX(16px); }
.availability-toggle input:focus-visible + .availability-switch { outline: 2px solid #58a6ff; outline-offset: 2px; }

.empty-presentaciones {
    margin: 0;
    padding: 14px 4px;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-secondary, #8b8ba7);
}

/* Responsive */
@media (max-width: 768px) {
    .pres-page { padding: 14px; }
    .page-header { margin: 18px 0 14px; }
    .page-header h2 { font-size: 1.55rem; }
    .asignatura-tab { padding: 9px 14px; font-size: 0.86rem; }
    .asignatura-head { padding-bottom: 16px; }
    .presentacion-card { padding: 16px; }
    .presentacion-card-titulo { font-size: 1rem; }
    .page-header-row { flex-direction: column; }
    .admin-presentations-link { margin-top: 0; }
    .admin-pres-section { padding: 14px; }
    .admin-pres-row { align-items: flex-start; flex-direction: column; gap: 10px; }
}
@media (max-width: 480px) {
    .presentaciones-grid { grid-template-columns: 1fr; gap: 12px; }
    .asignatura-tabs { gap: 8px; }
    .asignatura-tab {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        padding: 9px 10px;
    }
    .asignatura-icono { font-size: 1.6rem; }
    .asignatura-nombre { font-size: 1.08rem; }
}

/* ===== Viewer de presentación ===== */
.viewer-body {
    margin: 0;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.viewer-chrome {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}
.viewer-bar {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 20px;
    background: rgba(0,0,0,0.25);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.viewer-back { color: var(--text-secondary, #8b8ba7); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.viewer-back:hover { color: #fff; }
.viewer-title { flex: 1; font-weight: 600; font-size: 0.98rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-hint { color: var(--text-muted, #6b6b80); font-size: 0.78rem; white-space: nowrap; }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #0d1117; }

@media (max-width: 600px) {
    .viewer-hint { display: none; }
    .viewer-bar { padding: 8px 12px; gap: 8px; }
}

/* Página de bienvenida */
.welcome-hero { padding-bottom: 32px; }
.welcome-progress { margin-top: 10px; color: var(--success); font-size: 0.95em; }
.welcome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 40px;
}
.welcome-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    animation: fadeSlide 0.4s ease forwards;
}
.welcome-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(231,111,81,0.15);
    text-decoration: none;
}
.welcome-icon { font-size: 1.8em; }
.welcome-name { color: white; font-size: 1.1em; font-weight: 600; }
.welcome-desc { color: var(--text-muted); font-size: 0.85em; line-height: 1.45; }
