@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;700;800&display=swap');
:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --soft: #f8f9fc;
  --hover: #f0f3f9;
  --text: #1c2436;
  --muted: #5a657d; /* WCAG AA >= 5.2:1 on #fff */
  --border: #e4e8f1;
  --primary: #6558df;
  --pdark: #5144c6;
  --psoft: color-mix(in srgb, var(--primary) 14%, var(--surface));
  --green: #1d946c;
  --gsoft: #e7f7f0;
  --orange: #e08d2f;
  --red: #d44d58;
  --shadow: 0 12px 35px rgba(32, 40, 58, .06);
  --grgb: 255, 255, 255;
  --gblur: 22px;
  --galpha: .5;
  --gedge: rgba(255, 255, 255, .55);
  --nd: rgba(160, 172, 198, .38);
  --nl: rgba(255, 255, 255, .95);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --smooth: cubic-bezier(.22, 1, .36, 1);
  --hint: #4d5870;
  /* Syntax colors (light) */
  --syn-tag: #c43d6b;
  --syn-attr: #a05c00;
  --syn-str: #16805a;
  --syn-kw: #6558df;
  --syn-num: #c9581a;
  --syn-com: #7d879b;
  --syn-fn: #2166c2;
}
body.dark {
  color-scheme: dark;
  --bg: #101522;
  --surface: #192131;
  --soft: #202a3c;
  --hover: #283349;
  --text: #edf1fa;
  --muted: #a6b3ca;
  --border: #2b3548;
  --gsoft: #203c36;
  --orange: #ffbd69;
  --red: #ff8087;
  --shadow: 0 12px 35px rgba(0, 0, 0, .24);
  --grgb: 28, 38, 58;
  --gedge: rgba(255, 255, 255, .16);
  --nd: rgba(0, 0, 0, .5);
  --nl: rgba(70, 88, 125, .22);
  --hint: #b4c0d4;
  /* Syntax colors (dark) */
  --syn-tag: #ff7aa8;
  --syn-attr: #ffbe6b;
  --syn-str: #5ce0a8;
  --syn-kw: #a99eff;
  --syn-num: #ffa066;
  --syn-com: #77859f;
  --syn-fn: #7cb6ff;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: background .4s, color .4s;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .42; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 19px;
  transition: transform .4s var(--smooth), box-shadow .4s var(--smooth), background .3s, border-color .3s;
}
.eyebrow, .sidebar-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* background */
.bg-fx { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; display: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.b1 { width: 520px; height: 520px; left: -120px; top: -100px; background: var(--primary); animation: bA 22s ease-in-out infinite; }
.b2 { width: 460px; height: 460px; right: -100px; top: 25%; background: #ff8fd0; animation: bB 26s ease-in-out infinite; }
.b3 { width: 500px; height: 500px; left: 30%; bottom: -200px; background: #4fd1c5; animation: bA 30s ease-in-out infinite reverse; }
@keyframes bA { 50% { transform: translate(180px, 120px) scale(1.2); } }
@keyframes bB { 50% { transform: translate(-200px, 80px) scale(.85); } }
body.glassy .bg-fx { display: block; }
body.glassy { background: linear-gradient(135deg, #e3e9ff, #f4e9ff 50%, #e1f6ef) fixed; }
body.glassy.dark { background: linear-gradient(135deg, #0a0e1c, #1a1238 55%, #0c2230) fixed; }
body.dark .blob { opacity: .38; }
body[data-texture=aurora] .blob { opacity: .85; }

/* sidebar */
.sidebar {
  width: 245px; position: fixed; inset: 0 auto 0 0; z-index: 10;
  display: flex; flex-direction: column; padding: 28px 18px 18px;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 11px; padding: 0 9px; margin-bottom: 36px;
  color: var(--text); font-size: 20px; font-weight: 800; text-decoration: none; letter-spacing: -.8px;
}
.brand > span:last-child > span { color: var(--primary); }
.brand-icon {
  display: grid; place-items: center; width: 39px; height: 39px; color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--primary) 82%, #fff), var(--pdark));
  border-radius: 12px; font: 15px 'DM Mono', ui-monospace, monospace;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent);
  transition: transform .5s var(--spring);
}
.brand:hover .brand-icon { transform: rotate(-12deg) scale(1.12); }
.modal-logo { margin-bottom: 20px; }
.sidebar-label { padding: 0 11px; margin-bottom: 10px; }
.second { margin-top: 22px; }
.nav-item {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 13px;
  width: 100%; min-height: 44px; margin: 3px 0; padding: 0 13px;
  color: var(--muted); background: 0; border: 0; border-radius: 11px; text-align: left;
  font-size: 13px; font-weight: 700;
  transition: background .25s, color .25s, transform .35s var(--spring);
  animation: slr .6s var(--spring) backwards;
}
.nav-item:nth-of-type(2) { animation-delay: .05s; }
.nav-item:nth-of-type(3) { animation-delay: .1s; }
.nav-item:nth-of-type(4) { animation-delay: .15s; }
.nav-item:nth-of-type(5) { animation-delay: .2s; }
.nav-item:nth-of-type(6) { animation-delay: .25s; }
@keyframes slr { from { opacity: 0; transform: translateX(-22px); } }
.nav-item:hover { background: var(--soft); color: var(--text); transform: translateX(4px); }
.nav-item.active { color: var(--primary); background: var(--psoft); }
.nav-item::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 0;
  border-radius: 3px; background: var(--primary); transform: translateY(-50%); transition: height .35s var(--spring);
}
.nav-item.active::before { height: 22px; }
.nav-icon { width: 20px; font-size: 18px; text-align: center; transition: transform .35s var(--spring); }
.nav-item:hover .nav-icon { transform: scale(1.2) rotate(-6deg); }
.nav-item.needs-account::after { content: "🔒"; margin-left: auto; font-size: 12px; }
.sidebar-bottom { margin-top: auto; padding-top: 14px; }
.sidebar-xp {
  display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 12px;
  background: var(--soft); border: 1px solid var(--border); border-radius: 13px;
}
.xp-icon { color: var(--orange); font-size: 23px; animation: tw 3s ease-in-out infinite; }
@keyframes tw { 50% { transform: scale(1.18) rotate(15deg); } }
.sidebar-xp strong, .sidebar-xp small { display: block; }
.sidebar-xp strong { font-size: 13px; }
.sidebar-xp small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.streak-button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; text-align: left; transition: .3s var(--spring);
}
.streak-button:hover { transform: translateY(-3px); border-color: var(--orange); }
.streak-button > span:first-child { font-size: 22px; }
.streak-button small { color: var(--muted); }
.streak-arrow { margin-left: auto; color: var(--muted); font-size: 22px; transition: transform .3s var(--spring); }
.streak-button:hover .streak-arrow { transform: translateX(4px); }
.flame, .big-flame { display: inline-block; transform-origin: 50% 90%; animation: fl 1.6s ease-in-out infinite; }
@keyframes fl {
  25% { transform: scale(1.08, 1.12) rotate(2deg); }
  50% { transform: scale(.96, 1.05) rotate(-1deg); }
  75% { transform: scale(1.06, 1.1) rotate(3deg); }
}
.account-area {
  display: flex; align-items: center; gap: 10px; min-height: 65px;
  margin-top: 16px; padding: 10px 4px 0; border-top: 1px solid var(--border);
}
.login-button {
  width: 100%; padding: 11px; color: var(--primary); background: var(--psoft);
  border: 0; border-radius: 10px; font-size: 12px; font-weight: 800; transition: transform .3s var(--spring);
}
.login-button:hover { transform: scale(1.04); }
.avatar-button {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 80%, #fff), var(--pdark));
  border: 0; border-radius: 50%; font-weight: 800; transition: transform .4s var(--spring);
}
.avatar-button:hover { transform: scale(1.12) rotate(8deg); }
.account-caption { color: var(--muted); font-size: 11px; }

/* layout + mobile HUD */
.main-area { max-width: 1500px; min-height: 100vh; margin-left: 245px; padding: 0 43px; min-width: 0; overflow-x: clip; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 92px; border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 5px 0 0; font-size: 22px; }
#pageTitle.swap { animation: ttl .5s var(--spring); }
@keyframes ttl { from { opacity: 0; transform: translateY(10px); } }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-status-wrap { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.online-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; animation: pd 2s infinite; }
.online-dot.offline { background: var(--orange); animation: none; }
@keyframes pd { 70%, 100% { box-shadow: 0 0 0 9px transparent; } 0% { box-shadow: 0 0 0 0 var(--green); } }

.mobile-hud { display: none; align-items: center; gap: 6px; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px;
  border-radius: 99px; font-size: 11px; font-weight: 800;
  color: var(--text); background: var(--soft); border: 1px solid var(--border);
}
.hud-login { color: var(--primary); background: var(--psoft); border-color: transparent; }
.hud-avatar { width: 32px; height: 32px; font-size: 13px; }

.music-quick-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--soft);
  color: var(--text); font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: transform .25s var(--spring), background .25s, border-color .25s, box-shadow .25s, color .25s;
}
.music-quick-btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.music-quick-btn.playing {
  background: var(--psoft); color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.eq-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; opacity: .45; }
.eq-bars i { display: block; width: 2.5px; height: 4px; border-radius: 2px; background: currentColor; transition: height .2s; }
.eq-bars i:nth-child(2) { height: 7px; }
.eq-bars i:nth-child(3) { height: 5px; }
.music-quick-btn.playing .eq-bars { opacity: 1; }
.music-quick-btn.playing .eq-bars i { animation: cbEq 1.05s ease-in-out infinite alternate; }
.music-quick-btn.playing .eq-bars i:nth-child(2) { animation-delay: .22s; }
.music-quick-btn.playing .eq-bars i:nth-child(3) { animation-delay: .44s; }
@keyframes cbEq { 0% { height: 3px; } 100% { height: 11px; } }
.setting-note { margin: -6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.page { display: none; padding: 28px 0 60px; min-width: 0; }
.page.active { display: block; animation: pin .5s var(--smooth); }
@keyframes pin { from { opacity: 0; transform: translateY(16px); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.985); } }
.page.active > *:not(.report) { animation: rise .7s var(--smooth) backwards; }
.page.active > :nth-child(2) { animation-delay: .07s; }
.page.active > :nth-child(3) { animation-delay: .14s; }
.page.active > :nth-child(4) { animation-delay: .21s; }
.page.active > :nth-child(5) { animation-delay: .28s; }
.page.active > :nth-child(6) { animation-delay: .35s; }
.rise-in { animation: rise .6s var(--smooth); }

/* welcome card */
.welcome-card {
  position: relative; display: flex; align-items: center; min-height: 240px; overflow: hidden;
  padding: 35px 43px; color: #fff;
  background: linear-gradient(115deg, color-mix(in srgb, var(--primary) 30%, #12163a), color-mix(in srgb, var(--primary) 78%, #1b1c55) 55%, var(--primary), color-mix(in srgb, var(--primary) 60%, #1b1c55));
  background-size: 220% 220%; animation: gr 14s ease infinite; border-radius: 20px;
  box-shadow: 0 14px 32px color-mix(in srgb, var(--primary) 28%, transparent);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .3s ease-out;
}
@keyframes gr { 50% { background-position: 100% 50%; } }
.page.active > .welcome-card { animation: rise .7s var(--smooth) backwards, gr 14s ease infinite; }
.welcome-content { position: relative; z-index: 2; max-width: 580px; }
.welcome-card .eyebrow { color: rgba(255, 255, 255, .78); }
.welcome-card h2 { margin: 12px 0 9px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -1px; }
.welcome-card p { max-width: 490px; color: rgba(255, 255, 255, .88); font-size: 13px; line-height: 1.75; }
.welcome-actions { display: flex; align-items: center; gap: 17px; margin-top: 22px; flex-wrap: wrap; }
.welcome-note { color: rgba(255, 255, 255, .82); font-size: 12px; }
.welcome-art { position: absolute; right: 9%; top: 50%; width: 230px; height: 210px; transform: translateY(-50%); }
.art-code {
  position: absolute; top: 50%; left: 50%; display: grid; place-items: center;
  width: 110px; height: 110px; background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .3); border-radius: 28px;
  font: 35px 'DM Mono', ui-monospace, monospace;
  transform: translate(-50%, -50%) rotate(-9deg); animation: af 5s ease-in-out infinite;
}
@keyframes af { 50% { transform: translate(-50%, -60%) rotate(-4deg); } }
.orbit { position: absolute; top: 50%; left: 50%; border: 1px solid rgba(255, 255, 255, .25); border-radius: 50%; }
.o1 { width: 190px; height: 135px; animation: sp 18s linear infinite; }
.o2 { width: 230px; height: 175px; animation: sp 26s linear infinite reverse; }
@keyframes sp { from { transform: translate(-50%, -50%) rotate(0); } to { transform: translate(-50%, -50%) rotate(360deg); } }

/* buttons */
.primary-button, .secondary-button, .danger-button, .text-button, .hint-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 39px; padding: 0 15px; border-radius: 9px; font-size: 12px; font-weight: 800;
  text-decoration: none; transition: transform .3s var(--spring), background .2s, border-color .2s, box-shadow .3s;
}
.primary-button, .secondary-button, .login-button, .course-option, .texture-option, .auth-tab, .runner-tab {
  position: relative; overflow: hidden;
}
.primary-button {
  color: #fff; background: var(--primary); border: 1px solid var(--primary);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent);
}
.primary-button::after {
  content: ""; position: absolute; top: 0; left: -80%; width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .4), transparent);
  transform: skewX(-20deg); pointer-events: none;
}
.primary-button:hover::after { animation: shn .7s ease; }
@keyframes shn { to { left: 140%; } }
.primary-button:hover { background: var(--pdark); transform: translateY(-2px); box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 38%, transparent); }
.primary-button:active, .secondary-button:active { transform: scale(.96); }
.welcome-card .primary-button { color: var(--pdark); background: #fff; border-color: #fff; }
.secondary-button { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.secondary-button:hover { background: var(--hover); border-color: var(--primary); transform: translateY(-2px); }
.danger-button { color: var(--red); background: 0; border: 1px solid var(--border); }
.danger-button:hover { border-color: var(--red); transform: translateY(-2px); }
.danger-solid { color: #fff; background: var(--red); border-color: var(--red); }
.danger-solid:hover { opacity: .92; }
.small-danger { min-height: 36px; padding: 0 12px; }
.text-button { padding: 0 4px; min-height: 0; color: var(--muted); background: 0; border: 0; }
.text-button:hover { color: var(--primary); }
.hint-button { padding: 0; min-height: 28px; color: var(--primary); background: 0; border: 0; }
.run-button { color: var(--green); }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; background: currentColor;
  opacity: .25; transform: scale(0); animation: rp .65s ease-out forwards;
}
@keyframes rp { to { transform: scale(1); opacity: 0; } }

/* courses */
.course-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 32px 0 18px; }
.course-heading h2, .page-intro h2 { margin: 7px 0 0; font-size: 22px; }
.course-switch { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px; background: var(--soft); border: 1px solid var(--border); border-radius: 11px; }
.course-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 13px; color: var(--muted);
  background: 0; border: 0; border-radius: 8px; font-size: 12px; font-weight: 800; transition: .35s var(--spring);
}
.course-option:hover { color: var(--text); }
.course-option.active { color: var(--primary); background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); transform: scale(1.04); }
.ci { display: grid; place-items: center; width: 22px; height: 20px; color: #fff; border-radius: 5px; font-size: 9px; }
.c-html { background: #e98c4b; font-size: 11px; }
.c-py { background: #527eae; }
.c-css { background: #3b8fe0; font-size: 8px; }
.c-js { background: #f0c936; color: #2a2400; }
.lock-badge { display: none; font-size: 10px; }
.course-option.locked .lock-badge { display: inline; }
.course-option.locked { opacity: .78; }
.lock-banner {
  display: flex; align-items: center; gap: 18px; margin-bottom: 18px; padding: 20px 23px;
  background: var(--surface); border: 1.5px dashed color-mix(in srgb, var(--orange) 70%, transparent);
  border-radius: 17px; box-shadow: var(--shadow);
}
.guest-banner { border-style: solid; border-color: color-mix(in srgb, var(--primary) 55%, transparent); }
.lock-icon { font-size: 36px; animation: bob 3s ease-in-out infinite; }
.lock-copy { flex: 1; min-width: 0; }
.lock-copy h3 { margin: 0 0 6px; font-size: 15px; }
.lock-copy p { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.progress-overview { padding: 21px 23px; border-radius: 17px; }
.po-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.progress-overview h3 { margin: 5px 0 0; font-size: 14px; }
.progress-percent { color: var(--primary); font-size: 17px; font-weight: 800; }
.progress-track { height: 8px; overflow: hidden; background: var(--hover); border-radius: 20px; }
.progress-fill {
  position: relative; width: 0; height: 100%; overflow: hidden;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #fff));
  border-radius: inherit; transition: width 1s var(--smooth);
}
.progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .55), transparent 80%);
  transform: translateX(-100%); animation: sh 2.4s infinite;
}
@keyframes sh { to { transform: translateX(100%); } }
.unit-list { display: grid; gap: 15px; margin-top: 18px; }
.unit-card { padding: 19px 21px; border-radius: 17px; animation: cin .7s var(--spring) both; animation-delay: calc(var(--i, 0) * 90ms); }
.unit-card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px rgba(32, 40, 58, .1); }
@keyframes cin { from { opacity: 0; transform: translateY(26px) scale(.97); } }
.unit-header { display: flex; align-items: center; gap: 13px; }
.unit-number {
  display: grid; place-items: center; width: 39px; height: 39px; flex: none;
  color: var(--primary); background: var(--psoft); border-radius: 11px;
  font: 500 14px 'DM Mono', ui-monospace, monospace;
}
.unit-header h3 { margin: 0; font-size: 14px; }
.unit-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.unit-status { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.unit-status.on { color: var(--green); }
.level-grid { display: grid; grid-template-columns: repeat(10, minmax(35px, 1fr)); gap: 9px; margin-top: 19px; }
.level-button {
  display: grid; place-items: center; aspect-ratio: 1; color: var(--muted);
  background: var(--soft); border: 1px solid var(--border); border-radius: 9px;
  font-size: 12px; font-weight: 800;
  animation: pop .6s var(--spring) both; animation-delay: calc(var(--i, 0) * 24ms + 120ms);
  transition: transform .3s var(--spring), box-shadow .3s;
}
@keyframes pop { from { opacity: 0; transform: scale(.3); } }
.level-button.available {
  color: var(--primary); background: var(--psoft); border-color: transparent;
  animation: pop .6s var(--spring) calc(var(--i, 0) * 24ms + 120ms) both, avp 2.6s 1.4s ease-in-out infinite;
}
@keyframes avp {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 40%, transparent); }
  50% { box-shadow: 0 0 0 7px transparent; }
}
.level-button.completed { color: #fff; background: var(--green); border-color: var(--green); }
.level-button.test { border-style: dashed; }
.level-button:hover:not(:disabled) { transform: translateY(-5px) scale(1.12) rotate(-3deg); border-color: var(--primary); box-shadow: 0 10px 20px rgba(0, 0, 0, .14); }

/* workspace + syntax-highlighted editor */
.workspace-back { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.level-badge { padding: 7px 10px; color: var(--primary); background: var(--psoft); border-radius: 7px; font-size: 10px; font-weight: 800; }
.lesson-header { margin-bottom: 22px; }
.lesson-header h2 { margin: 7px 0; font-size: 26px; }
.lesson-header p, .page-intro p { margin: 0; color: var(--muted); line-height: 1.7; }
.lesson-layout { display: grid; grid-template-columns: minmax(230px, .78fr) minmax(0, 1.7fr); gap: 18px; align-items: start; }
.lesson-side { display: grid; gap: 13px; }
.kicker { color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.kicker span:first-child { color: var(--orange); }
.task-card h3 { margin: 12px 0 8px; font-size: 15px; }
.task-card > p, .remember-card p, .test-warning p { color: var(--muted); font-size: 13px; line-height: 1.75; }
.divider { height: 1px; margin: 15px 0; background: var(--border); }
.task-help-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.hint-text {
  margin-top: 12px; padding: 10px 12px; color: var(--hint) !important;
  background: rgba(125, 135, 155, .13); border: 1px solid rgba(125, 135, 155, .24);
  border-radius: 8px; animation: hin .45s var(--spring);
}
.example-code {
  margin: 10px 0 0; padding: 12px; border-radius: 8px; overflow-x: auto;
  font: 12px/1.6 'DM Mono', ui-monospace, monospace;
  background: var(--soft); border: 1px solid var(--border); color: var(--text);
  animation: hin .45s var(--spring);
}
@keyframes hin { from { opacity: 0; transform: translateY(-8px) scale(.96); } }
.remember-card { background: var(--soft); box-shadow: none; }
.remember-card p { margin-bottom: 0; }
.test-warning { color: #ad7025; background: #fff8e9; border-color: #f4dfba; }
body.dark .test-warning { color: #ffd28c; background: #3b3022; border-color: #59442b; }
.editor-column { min-width: 0; display: grid; gap: 13px; }
.editor-card { overflow: hidden; padding: 0; transition: box-shadow .3s, border-color .3s; }
.editor-card:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.editor-card.glow { animation: gl 1s; }
@keyframes gl { 40% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 40%, transparent), 0 0 40px color-mix(in srgb, var(--green) 40%, transparent); } }
.shake { animation: shk .5s; }
@keyframes shk { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
.editor-toolbar, .preview-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 45px; padding: 0 15px; background: var(--soft); border-bottom: 1px solid var(--border); overflow-x: auto;
}
.file-label { display: flex; align-items: center; gap: 9px; font: 12px 'DM Mono', ui-monospace, monospace; }
.file-dot { width: 8px; height: 8px; background: #e98c4b; border-radius: 50%; }
.editor-language, .preview-toolbar span { color: var(--muted); font-size: 11px; font-weight: 700; }

/* Code editor shell with line numbers + synchronized highlight layer */
.code-shell {
  display: grid; grid-template-columns: 44px minmax(0, 1fr);
  min-height: 290px; max-height: 520px; background: var(--surface); position: relative;
}
.runner-shell { min-height: 380px; }
.line-gutter {
  padding: 16px 8px 16px 6px; text-align: right; user-select: none; overflow: hidden;
  color: var(--muted); background: var(--soft); border-right: 1px solid var(--border);
  font: 13px/1.75 'DM Mono', ui-monospace, monospace; white-space: pre;
}
.code-stage { position: relative; min-width: 0; overflow: hidden; }
.code-highlight, #codeEditor, #runnerEditor {
  margin: 0; padding: 16px; width: 100%; height: 100%;
  font: 13px/1.75 'DM Mono', ui-monospace, monospace;
  tab-size: 2; white-space: pre; overflow: auto; word-wrap: normal;
  border: 0; outline: 0;
}
.code-highlight {
  position: absolute; inset: 0; pointer-events: none; color: var(--text); background: transparent;
}
#codeEditor, #runnerEditor {
  position: relative; z-index: 1; resize: none; min-height: 290px;
  color: transparent; background: transparent; caret-color: var(--primary);
  -webkit-text-fill-color: transparent;
}
#runnerEditor { min-height: 380px; }
#codeEditor::placeholder, #runnerEditor::placeholder {
  color: var(--muted); -webkit-text-fill-color: var(--muted); opacity: .7;
}
.tok-tag { color: var(--syn-tag); }
.tok-attr { color: var(--syn-attr); }
.tok-str { color: var(--syn-str); }
.tok-kw { color: var(--syn-kw); font-weight: 500; }
.tok-num { color: var(--syn-num); }
.tok-com { color: var(--syn-com); font-style: italic; }
.tok-fn { color: var(--syn-fn); }

.editor-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; padding: 12px 14px; background: var(--soft); border-top: 1px solid var(--border);
}
.result-panel { display: flex; align-items: center; gap: 11px; padding: 12px 15px; box-shadow: none; flex-wrap: wrap; }
.result-icon { color: var(--muted); font-size: 13px; font-weight: 800; }
.result-panel p { margin: 0; flex: 1; color: var(--muted); font-size: 12px; line-height: 1.6; }
.result-panel.success { background: var(--gsoft); border-color: transparent; animation: rpop .5s var(--spring); }
@keyframes rpop { 0% { transform: scale(.94); } 60% { transform: scale(1.02); } }
.result-panel.success .result-icon, .result-panel.success p { color: var(--green); }
.result-panel.error { background: #fff0f0; border-color: transparent; }
body.dark .result-panel.error { background: #3c252d; }
.result-panel.error .result-icon, .result-panel.error p { color: var(--red); }
.next-inline { min-height: 34px; padding: 0 13px; }
.preview-card { overflow: hidden; padding: 0; }
#htmlPreview { display: block; width: 100%; height: 230px; background: #fff; border: 0; }
.py-output {
  min-height: 120px; margin: 0; padding: 17px; color: var(--green); background: var(--surface);
  border-top: 1px solid var(--border); font: 13px/1.7 'DM Mono', ui-monospace, monospace; white-space: pre-wrap;
}

/* runner + multi-project bar */
.project-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 13px 16px; margin-bottom: 16px;
}
.project-select { min-width: 190px; max-width: 280px; }
.runner-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.runner-left, .runner-right { min-width: 0; }
.runner-tabs { display: flex; gap: 4px; }
.runner-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; color: var(--muted);
  background: 0; border: 1px solid transparent; border-radius: 8px;
  font: 11px 'DM Mono', ui-monospace, monospace; white-space: nowrap; transition: .3s var(--spring);
}
.runner-tab i { width: 8px; height: 8px; border-radius: 50%; opacity: .35; transition: .3s; }
.runner-tab.has i { opacity: 1; }
.runner-tab[data-file=html] i { background: #e98c4b; }
.runner-tab[data-file=css] i { background: #3b8fe0; }
.runner-tab[data-file=js] i { background: #f0c936; }
.runner-tab[data-file=py] i { background: #527eae; }
.runner-tab.active { color: var(--text); background: var(--surface); border-color: var(--border); }
.runner-note { margin: 12px 4px 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
#runnerPreview { display: block; width: 100%; height: 290px; background: #fff; border: 0; }
.console-bar { border-top: 1px solid var(--border); }
.runner-console {
  min-height: 150px; max-height: 260px; overflow: auto; padding: 14px 16px; background: var(--surface);
  border-top: 1px solid var(--border); font: 12px/1.7 'DM Mono', ui-monospace, monospace;
}
.runner-console:empty::before { content: attr(data-empty); color: var(--muted); }
.cl { color: var(--green); white-space: pre-wrap; word-break: break-word; animation: cl .3s ease both; }
@keyframes cl { from { opacity: 0; transform: translateX(-6px); } }
.cl.error { color: var(--red); }
.cl.info { color: var(--muted); }
.console-off .runner-console { display: none; }
.console-off .console-bar { border-bottom: 0; }
.fs-btn {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 9px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-weight: 800; white-space: nowrap; transition: .3s var(--spring);
}
.fs-btn:hover { color: var(--primary); border-color: var(--primary); transform: scale(1.08); }
.fs-btn.on { color: var(--red); border-color: var(--red); font-size: 11px; }
body.fs-open { overflow: hidden; }
.runner-fs {
  position: fixed !important; inset: 0; z-index: 90; display: flex !important; flex-direction: column;
  width: 100vw; height: 100vh; max-width: none; margin: 0 !important; border: 0 !important; border-radius: 0 !important;
  background: var(--surface) !important; box-shadow: none !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important; animation: rise .35s var(--smooth);
}
.runner-fs .code-shell { flex: 1; max-height: none; min-height: 0; }
.runner-fs #runnerEditor { height: 100%; min-height: 0; font-size: 14px; }
.runner-fs .code-highlight, .runner-fs .line-gutter { font-size: 14px; }
.runner-fs #runnerPreview { flex: 1; min-height: 0; height: auto; }
.runner-fs .runner-console { flex: none; height: 26vh; max-height: none; }
.runner-fs .yt-frame { flex: 1; min-height: 0; aspect-ratio: auto; }

/* report */
.report { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 24px; width: 100%; min-width: 0; animation: cin .7s var(--spring); }
.report > * { min-width: 0; max-width: 100%; overflow: hidden; overflow-wrap: anywhere; }
.report h4 { margin: 0; }
.report-top { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; }
.score-ring { position: relative; flex: none; width: 134px; height: 134px; }
.score-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: color-mix(in srgb, var(--muted) 24%, transparent); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1.5s var(--smooth); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center strong { font-size: 36px; line-height: 1; }
.ring-center small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.report-headline { flex: 1 1 220px; min-width: 0; }
.report-headline h3 { margin: 7px 0 6px; font-size: 23px; }
.report-headline p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.report-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.grade-badge {
  display: inline-grid; place-items: center; min-width: 38px; height: 29px; padding: 0 10px;
  color: var(--primary); background: var(--psoft); border-radius: 8px; font-size: 14px; font-weight: 800;
}
.delta { font-size: 12px; font-weight: 800; color: var(--muted); }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.report-meta { color: var(--muted); font-size: 12px; }
.problem-card h4 { color: var(--red); font-size: 14px; }
.problem-item { margin-top: 12px; padding: 12px 14px; background: color-mix(in srgb, var(--red) 10%, transparent); border-radius: 10px; }
.problem-item strong { display: block; margin-bottom: 5px; font: 12px/1.6 'DM Mono', ui-monospace, monospace; word-break: break-word; }
.problem-item small { color: var(--muted); font-size: 12px; line-height: 1.7; }
.meter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter small { font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-size: 10px; }
.meter strong { font-size: 24px; }
.meter strong em { color: var(--muted); font-size: 12px; font-style: normal; font-weight: 600; }
.meter .progress-track { height: 7px; }
.meter p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.report-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.report-box h4 { margin-bottom: 14px; font-size: 14px; }
.good h4 { color: var(--green); }
.improve h4 { color: var(--orange); }
.report-box ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.report-box li { position: relative; padding-left: 24px; font-size: 12px; line-height: 1.7; }
.report-box li::before { position: absolute; left: 0; font-weight: 800; }
.good li::before { content: "✓"; color: var(--green); }
.improve li::before { content: "→"; color: var(--orange); }
.learn-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.learn-head h4 { margin: 7px 0 5px; font-size: 22px; }
.learn-head p { margin: 0; color: var(--muted); font-size: 12px; }
.level-emoji { font-size: 38px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-7px) rotate(4deg); } }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip { padding: 6px 12px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.chip.on { color: var(--green); background: var(--gsoft); }
.chip.off { color: var(--muted); background: var(--soft); border: 1px dashed var(--border); }
.learn-next { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 18px; }
.learn-next small { color: var(--muted); font-size: 12px; }

/* youtube + quick links */
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-form input {
  flex: 1; min-width: 180px; min-height: 42px; padding: 0 14px; color: var(--text);
  background: var(--soft); border: 1px solid var(--border); border-radius: 10px; outline: 0;
  font-size: 13px; transition: border-color .25s, box-shadow .3s;
}
.inline-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.form-error { min-height: 15px; margin: 8px 4px 6px; color: var(--red); font-size: 12px; }
.yt-card { padding: 0; overflow: hidden; margin-bottom: 16px; }
.yt-section { margin-bottom: 16px; }
.yt-frame { display: block; width: 100%; aspect-ratio: 16/9; border: 0; background: #000; }
.yt-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 13px; margin-top: 14px; }
.yt-item {
  position: relative; overflow: hidden; color: var(--text); background: var(--soft);
  border: 1px solid var(--border); border-radius: 12px; padding: 0; text-align: left;
  cursor: pointer; transition: transform .35s var(--spring), box-shadow .35s, border-color .25s;
}
.yt-item:hover { transform: translateY(-5px) scale(1.02); border-color: var(--primary); box-shadow: 0 14px 28px rgba(0, 0, 0, .15); }
.yt-item img, .yt-ph { display: grid; place-items: center; width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--hover); font-size: 30px; }
.yt-item span { display: block; padding: 9px 11px; color: var(--text); font-size: 12px; font-weight: 700; }
.yt-x {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center;
  width: 26px; height: 26px; color: #fff; background: rgba(0, 0, 0, .65);
  border: 0; border-radius: 50%; font-size: 14px; opacity: 0; transition: opacity .25s, transform .3s var(--spring);
}
.yt-item:hover .yt-x { opacity: 1; }
.yt-x:hover { transform: scale(1.2) rotate(90deg); background: var(--red); }
.empty { grid-column: 1 / -1; padding: 26px; color: var(--muted); text-align: center; font-size: 13px; }
.link-list { display: grid; gap: 12px; }
.link-item { display: flex; align-items: center; gap: 14px; padding: 15px 18px; }
.link-item:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(32, 40, 58, .1); }
.link-ico {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px;
  color: var(--primary); background: var(--psoft); border-radius: 12px; font-size: 17px; font-weight: 800;
}
.link-copy { flex: 1; min-width: 0; }
.link-copy b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-copy small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* stats */
.page-intro { margin-bottom: 22px; }
.page-intro h2 { font-size: 27px; }
.page-intro p { margin-top: 8px; font-size: 13px; }
.profile-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile-meta { flex: 1; min-width: 180px; }
.profile-avatar { width: 52px; height: 52px; font-size: 19px; }
.profile-card h3 { margin: 0; font-size: 16px; }
.profile-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.sync-badge { display: inline-block; margin-top: 6px; padding: 3px 9px; border-radius: 99px; font-size: 10px; font-weight: 800; color: var(--green); background: var(--gsoft); }
.sync-badge.local { color: var(--muted); background: var(--soft); }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin: 17px 0; }
.stat-card { display: flex; flex-direction: column; gap: 7px; transition: transform .35s var(--spring); }
.stat-card:hover { transform: translateY(-6px) scale(1.02); }
.stat-card > span { color: var(--primary); font-size: 19px; }
.stat-card strong { font-size: 25px; }
.stat-card small { color: var(--muted); font-size: 11px; }
.sc-title { margin: 6px 0 18px; font-size: 16px; }
.stats-course { margin: 17px 0; }
.stats-course-top { display: flex; justify-content: space-between; margin-bottom: 9px; font-size: 12px; }
.stats-course-top span { color: var(--muted); }
.stats-course .progress-track > div { height: 100%; background: var(--primary); border-radius: 20px; transition: width 1.1s var(--smooth); }
.account-danger-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

/* settings */
.settings-list { display: grid; gap: 12px; }
.setting-card { display: flex; align-items: center; gap: 15px; padding: 20px 22px; border-radius: 17px; }
.setting-card.stack { flex-direction: column; align-items: stretch; gap: 18px; }
.setting-card:hover { transform: translateY(-2px); }
.setting-head { display: flex; align-items: center; gap: 15px; }
.setting-icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px;
  color: var(--primary); background: var(--psoft); border-radius: 12px; font-size: 18px; font-weight: 800;
  transition: transform .4s var(--spring);
}
.setting-card:hover .setting-icon { transform: rotate(-8deg) scale(1.08); }
.setting-copy { flex: 1; }
.setting-copy h3 { margin: 0; font-size: 14px; }
.setting-copy p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.setting-select {
  max-width: 230px; min-height: 38px; padding: 0 10px; color: var(--text);
  background: var(--soft); border: 1px solid var(--border); border-radius: 8px; outline: 0;
  font-size: 12px; font-weight: 600; transition: border-color .25s;
}
.setting-select:focus { border-color: var(--primary); }
.footnote { margin-top: 18px; color: var(--muted); font-size: 11px; }
.switch {
  position: relative; flex: none; width: 51px; height: 31px; padding: 0;
  background: color-mix(in srgb, var(--muted) 38%, transparent); border: 0; border-radius: 99px; transition: background .35s;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; background: #fff;
  border-radius: 99px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); transition: transform .4s var(--spring), width .2s;
}
.switch[aria-checked=true] { background: var(--green); }
.switch[aria-checked=true] .knob { transform: translateX(20px); }
.switch:active .knob { width: 34px; }
.switch[aria-checked=true]:active .knob { transform: translateX(13px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.switch-row strong { display: block; font-size: 13px; }
.switch-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.slider-row { display: grid; grid-template-columns: 110px 1fr 52px; align-items: center; gap: 14px; font-size: 12px; font-weight: 700; }
.slider-row output { color: var(--muted); text-align: right; font: 11px 'DM Mono', ui-monospace, monospace; }
.slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px; margin: 0;
  background: linear-gradient(90deg, var(--primary) var(--val, 50%), color-mix(in srgb, var(--muted) 28%, transparent) var(--val, 50%));
  border-radius: 99px; outline: 0; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; background: #fff; border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28); transition: transform .25s var(--spring);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb { width: 26px; height: 26px; background: #fff; border: 0; border-radius: 50%; box-shadow: 0 3px 10px rgba(0, 0, 0, .28); }
.texture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.texture-option {
  display: grid; gap: 9px; justify-items: center; padding: 10px 8px 12px; color: var(--text);
  background: var(--soft); border: 2px solid transparent; border-radius: 14px; font-size: 11px; transition: .35s var(--spring);
}
.texture-option:hover { transform: translateY(-4px); }
.texture-option.active { border-color: var(--primary); background: var(--psoft); transform: scale(1.04); }
.tx { display: grid; place-items: center; width: 100%; height: 62px; border-radius: 10px; }
.tx i { display: block; width: 58%; height: 52%; border-radius: 8px; }
.tx-glass { background: linear-gradient(135deg, var(--primary), #ff8fd0 60%, #ffd27a); }
.tx-glass i { background: rgba(255, 255, 255, .35); border: 1px solid rgba(255, 255, 255, .7); }
.tx-frosted { background: linear-gradient(135deg, #7fb2ff, #c9a6ff); }
.tx-frosted i { background: rgba(255, 255, 255, .72); }
.tx-aurora { background: radial-gradient(circle at 20% 30%, #7c5cff, transparent 55%), radial-gradient(circle at 80% 70%, #2ee6c5, transparent 55%), #ff5fa2; }
.tx-aurora i { background: rgba(255, 255, 255, .28); border: 1px solid rgba(255, 255, 255, .55); }
.tx-flat { background: #e9edf5; }
.tx-flat i { background: #fff; border: 1px solid #dde2ec; }
.tx-soft { background: #e5e9f2; }
.tx-soft i { background: #e5e9f2; box-shadow: 4px 4px 9px rgba(150, 162, 190, .55), -4px -4px 9px #fff; }
.tx-paper { background: #f1e9d8; }
.tx-paper i { background: #fffcf5; border: 1px solid #e2d6bd; }
.accent-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.accent-swatch {
  position: relative; width: 38px; height: 38px; border: 3px solid var(--surface);
  border-radius: 50%; box-shadow: 0 0 0 2px var(--border); transition: .35s var(--spring);
}
.accent-swatch:hover { transform: scale(1.2); }
.accent-swatch.active { box-shadow: 0 0 0 3px var(--text); transform: scale(1.1); }
.accent-swatch.active::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800; }
.footer { display: flex; justify-content: space-between; padding: 17px 0 24px; color: var(--muted); border-top: 1px solid var(--border); font-size: 11px; }

/* modals, toast, effects */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
  background: rgba(12, 17, 29, .55); backdrop-filter: blur(8px); animation: fi .3s;
}
@keyframes fi { from { opacity: 0; } }
.modal-backdrop.closing { animation: fo .2s forwards; }
.modal-backdrop.closing .modal { animation: mo .2s forwards; }
@keyframes fo { to { opacity: 0; } }
@keyframes mo { to { opacity: 0; transform: translateY(14px) scale(.95); } }
.modal {
  position: relative; width: min(100%, 420px); padding: 30px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 25px 80px rgba(0, 0, 0, .28);
  animation: mi .5s var(--spring);
}
@keyframes mi { from { opacity: 0; transform: translateY(30px) scale(.9); } }
.modal-close {
  position: absolute; top: 14px; right: 15px; width: 30px; height: 30px; color: var(--muted);
  background: var(--soft); border: 0; border-radius: 8px; font-size: 20px; transition: .35s var(--spring);
}
.modal-close:hover { transform: rotate(90deg) scale(1.1); }
.modal h2 { margin: 7px 0; font-size: 23px; }
.modal > p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 22px 0; padding: 4px; background: var(--soft); border-radius: 10px; }
.auth-tab { padding: 10px; color: var(--muted); background: 0; border: 0; border-radius: 7px; font-size: 12px; font-weight: 800; transition: .3s var(--spring); }
.auth-tab.active { color: var(--primary); background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.auth-modal label { display: block; margin: 13px 0 6px; font-size: 12px; font-weight: 800; }
.auth-modal input {
  width: 100%; min-height: 42px; padding: 0 12px; color: var(--text); background: var(--soft);
  border: 1px solid var(--border); border-radius: 8px; outline: 0; font-size: 13px;
}
.auth-modal input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.auth-submit { width: 100%; margin-top: 10px; }
.auth-modal .form-error { margin: 8px 0 0; }
.privacy-note { margin-bottom: 0; font-size: 11px !important; }
.streak-modal { text-align: center; }
.big-flame { margin: 2px 0 12px; font-size: 53px; }
.big-flame.celebrate { animation: fp .7s var(--spring), fl 1.6s .7s infinite; }
@keyframes fp { 0% { transform: scale(.2) rotate(-30deg); } 65% { transform: scale(1.35) rotate(8deg); } }
.streak-number { display: flex; align-items: baseline; justify-content: center; gap: 7px; margin: 17px 0 5px; }
.streak-number strong { color: var(--orange); font-size: 47px; }
.streak-number span { color: var(--muted); }
.week-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 23px 0; }
.day-cell { display: grid; gap: 8px; padding: 9px 2px; color: var(--muted); background: var(--soft); border: 1px solid var(--border); border-radius: 9px; font-size: 10px; }
.day-cell b { color: var(--text); font-size: 12px; }
.day-cell.done { color: var(--green); background: var(--gsoft); border-color: transparent; }
.day-cell.done b { color: var(--green); }
.day-cell.today { border-color: var(--primary); }
.streak-done { width: 100%; }
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 95; max-width: min(380px, calc(100vw - 40px));
  padding: 13px 18px; color: #fff; background: rgba(24, 30, 46, .95); border-radius: 12px;
  box-shadow: 0 9px 30px rgba(0, 0, 0, .25); font-size: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transform: translateY(18px) scale(.94);
  transition: opacity .3s, transform .45s var(--spring);
}
.toast.show { opacity: 1; transform: none; }
.confetti { position: fixed; top: -20px; z-index: 96; font-style: normal; pointer-events: none; animation: cf var(--fall) ease-in forwards; }
@keyframes cf { to { transform: translate(var(--drift), 105vh) rotate(var(--rot)); opacity: 0; } }
.float-xp { position: fixed; z-index: 97; pointer-events: none; color: var(--orange); font-size: 18px; font-weight: 800; animation: fu 1.3s ease-out forwards; }
@keyframes fu { 0% { opacity: 0; transform: translate(-50%, 0) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -20px) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -90px); } }
.celebrate-overlay { position: fixed; inset: 0; z-index: 92; display: grid; place-items: center; pointer-events: none; background: radial-gradient(circle, rgba(0, 0, 0, .25), transparent 70%); animation: fi .2s; }
.celebrate-overlay.out { animation: fo .3s forwards; }
.celebrate-card { display: grid; justify-items: center; gap: 8px; padding: 26px 44px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: 0 25px 70px rgba(0, 0, 0, .35); animation: mi .55s var(--spring); }
.celebrate-check { display: grid; place-items: center; width: 68px; height: 68px; color: #fff; background: var(--green); border-radius: 50%; font-size: 36px; }
.celebrate-card h3 { margin: 4px 0 0; font-size: 24px; }
.celebrate-card p { margin: 0; color: var(--orange); font-weight: 800; }

/* textures */
body.glassy :is(.sidebar, .card, .modal, .sidebar-xp, .streak-button, .course-switch, .lock-banner) {
  background: rgba(var(--grgb), var(--galpha));
  -webkit-backdrop-filter: blur(var(--gblur)) saturate(175%);
  backdrop-filter: blur(var(--gblur)) saturate(175%);
  border-color: var(--gedge);
  box-shadow: 0 12px 40px rgba(31, 38, 135, .12), inset 0 1px 0 var(--gedge);
}
body.glassy .modal { background: rgba(var(--grgb), calc(var(--galpha) + .24)); }
body.glassy :is(.topbar, .footer) { border-color: var(--gedge); }
body.glassy :is(.editor-toolbar, .editor-actions, .preview-toolbar, .line-gutter) { background: rgba(var(--grgb), .28); border-color: var(--gedge); }
body.glassy :is(.code-shell, .py-output, .runner-console) { background: rgba(var(--grgb), .18); }
body.glassy :is(.setting-select, .auth-modal input, .inline-form input, .day-cell, .auth-tabs, .texture-option, .yt-item, .level-button:not(.completed):not(.available)) { background: rgba(var(--grgb), .38); }
body.glassy :is(.course-option.active, .auth-tab.active, .runner-tab.active) { background: rgba(var(--grgb), .82); }
body.glassy .nav-item.active { background: rgba(var(--grgb), .58); }

body[data-texture=soft] :is(.sidebar, .card, .modal, .sidebar-xp, .streak-button, .lock-banner) {
  background: var(--bg); border-color: transparent; box-shadow: 9px 9px 20px var(--nd), -9px -9px 20px var(--nl);
}
body[data-texture=soft] :is(.editor-toolbar, .editor-actions, .preview-toolbar, .line-gutter) { background: var(--bg); border-color: transparent; }
body[data-texture=soft] .code-shell { background: var(--bg); box-shadow: inset 5px 5px 12px var(--nd), inset -5px -5px 12px var(--nl); border-radius: 12px; margin: 4px 12px; }
body[data-texture=soft] :is(.setting-select, .auth-modal input, .inline-form input, .course-switch, .auth-tabs, .progress-track) { background: var(--bg); border-color: transparent; box-shadow: inset 3px 3px 7px var(--nd), inset -3px -3px 7px var(--nl); }
body[data-texture=soft] :is(.level-button, .secondary-button, .texture-option, .day-cell, .chip, .yt-item) { background: var(--bg); border-color: transparent; box-shadow: 4px 4px 9px var(--nd), -4px -4px 9px var(--nl); }
body[data-texture=soft] .level-button.completed { background: var(--green); }
body[data-texture=soft] :is(.texture-option.active, .course-option.active, .auth-tab.active, .nav-item.active, .runner-tab.active) { background: var(--bg); box-shadow: inset 3px 3px 7px var(--nd), inset -3px -3px 7px var(--nl); }

body[data-texture=paper] { --bg: #f4eee2; --surface: #fffcf5; --soft: #f8f2e6; --hover: #efe7d6; --border: #e5dac4; --shadow: 0 3px 0 rgba(120, 95, 50, .08), 0 10px 24px rgba(120, 95, 50, .08); }
body[data-texture=paper].dark { --bg: #1a1814; --surface: #24211b; --soft: #2b2821; --hover: #332f26; --border: #3a352b; }
body[data-texture=paper] .card { border-radius: 8px; }
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; }

/* Responsive */
@media (max-width: 1050px) {
  .main-area { padding: 0 24px; }
  .lesson-layout, .runner-grid { grid-template-columns: minmax(0, 1fr); }
  .lesson-side { grid-template-columns: repeat(2, 1fr); }
  .test-warning { grid-column: 1 / -1; }
  .stats-grid, .meter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome-art { right: 3%; opacity: .65; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  .brand { margin: 0 12px 8px 0; width: 100%; }
  .sidebar-label, .sidebar-bottom { display: none; }
  .nav-item { display: inline-flex; width: auto; min-height: 36px; margin: 0 2px 2px 0; padding: 0 11px; }
  .main-area { margin-left: 0; padding: 0 16px; }
  .topbar { min-height: 74px; flex-wrap: wrap; padding: 10px 0; }
  .topbar-status-wrap { display: none; }
  .mobile-hud { display: flex; }
  .music-quick-btn { padding: 6px 10px; gap: 5px; }
  .music-quick-btn .mq-label { display: none; }
  .welcome-card { padding: 24px; }
  .welcome-art { right: -65px; opacity: .28; }
  .course-heading { flex-direction: column; align-items: flex-start; }
  .level-grid { grid-template-columns: repeat(5, 1fr); }
  .lesson-side { grid-template-columns: 1fr; }
  .lock-banner { flex-direction: column; align-items: flex-start; }
  .report-columns { grid-template-columns: minmax(0, 1fr); }
  .setting-card:not(.stack) { flex-wrap: wrap; }
  .slider-row { grid-template-columns: 90px 1fr 44px; }
  .link-item { flex-wrap: wrap; }
}
@media (max-width: 430px) {
  .main-area { padding: 0 12px; }
  .welcome-actions { flex-direction: column; align-items: flex-start; }
  .editor-actions { flex-direction: column; align-items: stretch; }
  .modal { padding: 24px 19px; }
}


/* ===== CodeFlare v1.0 Glass/Aurora, Hub, Paywall & Mini-Player ===== */
.flare-surface {
  border-color: color-mix(in srgb, var(--primary) 26%, var(--gedge));
  box-shadow: 0 16px 46px color-mix(in srgb, var(--primary) 16%, rgba(16, 21, 34, .08)), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.brand-flare {
  background: linear-gradient(135deg, var(--primary), #4fd1c5 55%, #ff8fd0);
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 38%, transparent);
}
.nav-pro-tag, .pro-status-pill {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .8px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #ff8fd0);
}
.pro-sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  text-align: left;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 45%, #4fd1c5));
  border: 0;
  border-radius: 12px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 30%, transparent);
  transition: transform .3s var(--spring), box-shadow .3s;
}
.pro-sidebar-btn:hover { transform: translateY(-2px); }
.pro-sidebar-btn.active-pro {
  color: var(--text);
  background: rgba(var(--grgb), .58);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border));
  box-shadow: none;
}
.pro-sidebar-btn strong, .pro-sidebar-btn small { display: block; line-height: 1.25; }
.pro-sidebar-btn small { opacity: .88; font-size: 11px; }
.pro-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border));
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, transparent), color-mix(in srgb, #ff8fd0 14%, transparent));
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  transition: transform .25s var(--spring);
}
.pro-pill-btn.active-pro {
  background: linear-gradient(135deg, var(--primary), #ff8fd0);
  border-color: transparent;
  color: #fff;
}
.music-anchor { position: relative; }
.music-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  width: 290px;
  padding: 16px;
}
.music-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.music-pop-toggle { min-width: 42px; min-height: 36px; padding: 0 12px; }
.music-pop-tracks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.music-pop-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.music-pop-chip.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--psoft);
}
.music-pop-vol { grid-template-columns: 82px 1fr 38px; margin-top: 4px; }

.hub-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.hub-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.rank-head { display: flex; align-items: center; gap: 14px; margin: 10px 0 14px; }
.rank-badge-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #4fd1c5);
}
.rank-head h3, .quest-head h3 { margin: 0 0 3px; }
.rank-head p, .daily-quest-card p { margin: 0; color: var(--muted); font-size: 13px; }
.quest-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 6px; }
.quest-bonus {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gsoft);
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}
.quest-foot { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.hub-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 14px;
}
.hub-section-head h3 { margin: 0 0 3px; }
.hub-section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.ach-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.ach-card { display: flex; gap: 12px; align-items: flex-start; opacity: .56; }
.ach-card.unlocked {
  opacity: 1;
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}
.ach-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 18px;
  background: var(--psoft);
  color: var(--primary);
}
.ach-card h4 { margin: 0 0 4px; font-size: 14px; }
.ach-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.chip.active { color: var(--primary); border-color: var(--primary); background: var(--psoft); }

.cheat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.cheat-card { display: flex; flex-direction: column; gap: 10px; }
.cheat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cheat-track {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--psoft);
  color: var(--primary);
}
.cheat-card h4 { margin: 0; font-size: 15px; }
.cheat-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.cheat-code {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(15, 20, 34, .08);
  border: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}
body.dark .cheat-code { background: rgba(6, 9, 18, .45); }
.cheat-actions { display: flex; gap: 8px; margin-top: auto; }
.hub-links-form { margin-top: 22px; }

.pro-modal { width: min(100%, 490px); }
.pro-features { margin: 16px 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.pro-features li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.45;
}
.pro-features li::before { content: "✦"; color: var(--primary); font-weight: 800; }
.pro-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.pro-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--soft);
  color: var(--text);
  text-align: left;
  transition: .25s var(--spring);
}
.pro-plan.active {
  border-color: var(--primary);
  background: var(--psoft);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 18%, transparent);
}
.pro-save-badge {
  position: absolute;
  top: -9px;
  right: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #ff8fd0);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}
.pro-price { color: var(--muted); font-size: 13px; font-weight: 700; }
.pro-legal-row {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.pro-legal-row a, .footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

.onboard-modal { width: min(100%, 460px); text-align: center; }
.onboard-hero {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  border-radius: 18px;
  font-size: 28px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #4fd1c5 55%, #ff8fd0);
}
.onboard-body { margin: 16px 0; text-align: left; }
.onboard-dots { display: flex; justify-content: center; gap: 7px; margin: 12px 0 4px; }
.onboard-dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--border); transition: .25s; }
.onboard-dots span.active { width: 22px; background: var(--primary); }
.onboard-actions { justify-content: space-between; }
.legal-btn { text-decoration: none; display: inline-flex; align-items: center; }

@media (max-width: 900px) {
  .hub-top-grid, .ach-grid, .cheat-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .pro-plans { grid-template-columns: 1fr; }
  .music-popover { width: min(290px, calc(100vw - 24px)); }
}
