@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500&display=swap');
:root {
  color-scheme: light;
  --ink: #171d19; --muted: #465247; --subtle: #53614e;
  --yellow: #ffcf39; --paper: #fffef8; --surface: #fff;
  --soft: #f4f6ef; --line: #d4dace; --hint: #fff4ca;
  --keyword: #78249a; --string: #25631b; --number: #164db2;
  --function: #007549; --type: #8a4513; --comment: #53634e;
  --operator: #3d4b55; --selection: #c3dafa; --selection-ink: #14233b;
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'Manrope', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --ink: #f2f6ed; --muted: #c2cdbb; --subtle: #b2c1a9;
  --paper: #141815; --surface: #1b211c; --soft: #222a23;
  --line: #455142; --hint: #3b331b;
  --keyword: #dfadff; --string: #b4dc86; --number: #a4c5ff;
  --function: #96d4f4; --type: #ffd08f; --comment: #acbca2;
  --operator: #d5dfdb; --selection: #304c73; --selection-ink: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.65 var(--font-body); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { border: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, a, input, select, textarea { outline-offset: 4px; }
button:focus-visible, a:focus-visible { outline: 3px solid #4a83ce; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -60px; left: 16px; background: var(--surface); padding: 10px; z-index: 10; }
.skip-link:focus { top: 10px; }
.site-header { height: 88px; padding: 0 5%; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 11px; font: 800 26px var(--font-display); letter-spacing: -1px; }
.brand img { border-radius: 13px; }
.brand-dot, .tiny-foot { color: #a57300; }
[data-theme=dark] .brand-dot, [data-theme=dark] .tiny-foot { color: var(--yellow); }
.header-note { font-size: 13px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 26px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.theme-toggle { display: grid; place-items: center; padding: 0; line-height: 1; width: 38px; height: 38px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--soft); color: var(--ink); }
.theme-toggle svg { display: block; width: 20px; height: 20px; }
.theme-toggle .theme-sun, [data-theme=dark] .theme-toggle .theme-moon { display: none; }
[data-theme=dark] .theme-toggle .theme-sun { display: block; }
.profile-button { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 6px 13px 6px 6px; color: var(--ink); font-weight: 600; font-size: 13px; min-width: 0; }
.profile-chevron { display: block; width: 16px; height: 16px; flex-shrink: 0; }
.avatar { background: var(--hint); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-weight: 700; flex-shrink: 0; }
.profile-button.verified .avatar { background: #dcefd9; color: #265636; }
.page-shell { max-width: 1660px; margin: auto; padding: 0 5%; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 40px 0 32px; }
.eyebrow { font-size: 11px; letter-spacing: 1.8px; font-weight: 700; color: var(--subtle); }
.tiny-foot { margin-right: 6px; font-size: 16px; }
.intro h1 { font: 800 clamp(32px,3.7vw,46px)/1.2 var(--font-display); color: var(--ink); letter-spacing: -1.8px; margin: 7px 0 8px; }
h1 span { color: #a66c00; }
[data-theme=dark] h1 span { color: var(--yellow); }
.intro p { color: var(--muted); margin: 0; font-size: 15px; }
.progress-card { width: 260px; flex-shrink: 0; padding-top: 12px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; }
.progress-label strong { font-weight: 600; }
.progress-track { height: 7px; border-radius: 6px; background: var(--line); margin: 9px 0 8px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: #d8a500; border-radius: 6px; transition: width .3s; }
.progress-card>span { color: var(--muted); font-size: 12px; }
.workbench { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); overflow: hidden; box-shadow: 0 12px 35px #16221a08; }
.exercise-toolbar { display: flex; align-items: center; padding: 16px 21px; gap: 15px; border-bottom: 1px solid var(--line); min-height: 73px; }
.exercise-picker { display: flex; align-items: center; gap: 13px; }
.exercise-picker label { font-size: 11px; letter-spacing: 1.2px; color: var(--subtle); font-weight: 700; }
.exercise-picker select { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; max-width: 280px; min-width: 200px; padding: 8px 28px 8px 10px; color: var(--ink); font-size: 14px; font-weight: 600; }
.topic-label { font-size: 12px; color: var(--subtle); }
.exercise-navigation { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.exercise-navigation>span { font: 12px var(--font-mono); color: var(--muted); white-space: nowrap; }
.icon-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 32px; height: 32px; border-radius: 6px; }
.icon-button:hover { background: var(--hint); }
.split-panes { display: grid; grid-template-columns: 1fr 1fr; }
.exercise-pane { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.pane-heading { height: 49px; border-bottom: 1px solid var(--line); padding: 0 20px; display: flex; align-items: center; justify-content: space-between; }
.file-tab { font: 13px var(--font-mono); display: flex; align-items: center; gap: 9px; }
.file-dot { width: 7px; height: 7px; background: #b58a00; border-radius: 50%; }
.editable-badge, .readonly-label { font-size: 10px; color: var(--subtle); letter-spacing: 1px; }
.editable-badge { background: var(--soft); border-radius: 3px; padding: 2px 5px; }
.editor-shell { display: flex; min-height: 390px; flex: 1; padding: 22px 0 18px; background: var(--surface); }
.line-numbers { font: 13px/27px var(--font-mono); color: var(--subtle); text-align: right; flex: 0 0 48px; margin: 0; padding-right: 13px; overflow: hidden; user-select: none; height: 380px; }
.editor-viewport { position: relative; flex: 1; min-width: 0; }
#editor, #editor-highlight { font: 15px/27px var(--font-mono); font-variant-ligatures: none; letter-spacing: normal; tab-size: 4; white-space: pre; padding: 0 18px 8px 0; margin: 0; border: 0; border-radius: 0; text-align: left; }
#editor { resize: vertical; display: block; width: 100%; min-height: 340px; height: 380px; outline: none !important; box-shadow: none !important; background: transparent; color: var(--ink); caret-color: var(--ink); overflow: auto; position: relative; z-index: 1; }
#editor-highlight { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; user-select: none; color: var(--ink); visibility: hidden; }
#editor-highlight code { display: block; width: max-content; min-width: 100%; font: inherit; white-space: inherit; padding: 0; background: none; transform-origin: top left; }
.highlighting #editor-highlight { visibility: visible; }
.highlighting #editor { color: transparent; -webkit-text-fill-color: transparent; }
#editor::selection { background: var(--selection); color: var(--selection-ink); -webkit-text-fill-color: var(--selection-ink); }
.token-keyword { color: var(--keyword); font-weight: 500; }
.token-string { color: var(--string); }
.token-number { color: var(--number); }
.token-type { color: var(--type); }
.token-function, .token-builtin { color: var(--function); }
.token-comment { color: var(--comment); }
.token-operator { color: var(--operator); }
.editor-actions { border-top: 1px solid var(--line); padding: 13px 16px; display: flex; align-items: center; gap: 12px; min-height: 67px; }
.editor-helpers { display: flex; gap: 12px; }
.text-button { background: none; color: var(--muted); padding: 3px 0; font-size: 13px; white-space: normal; }
.text-button:hover { text-decoration: underline; }
.muted { color: var(--subtle); }
.save-state { font-size: 11px; color: var(--subtle); margin-left: auto; white-space: nowrap; }
.run-button { display: flex; align-items: center; gap: 8px; background: var(--yellow); padding: 10px 14px; color: #1d230e; border-radius: 7px; font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 0 #b68d19; }
.run-button:hover { background: #f4c326; }
.run-button kbd { font: 11px var(--font-body); color: #4b421b; margin-left: 4px; }
.hint-box { background: var(--hint); margin: 0 16px 14px; padding: 14px 16px; font-size: 14px; border-left: 3px solid #b58a00; border-radius: 5px; }
.hint-box p { white-space: pre-wrap; margin: 5px 0 0; }
.solution-pane { background: var(--soft); position: relative; min-width: 0; }
.solution-pane .pane-heading { background: var(--soft); }
.solution-icon { color: var(--subtle); font-size: 18px; }
.solution-cover { min-height: 447px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 25px; text-align: center; }
.solution-illustration { position: relative; width: 185px; height: 140px; display: grid; place-items: center; margin-bottom: 12px; }
.solution-illustration img { z-index: 1; transform: rotate(-7deg); border-radius: 32px; box-shadow: 0 9px 0 #76836318; }
.orbit { position: absolute; border: 1px dashed var(--line); border-radius: 50%; width: 177px; height: 105px; transform: rotate(-25deg); }
.orbit-two { transform: rotate(40deg); width: 142px; height: 145px; }
.sparkle { position: absolute; color: var(--subtle); right: -3px; top: 5px; font-size: 24px; }
.solution-cover h2 { font: 700 23px var(--font-display); color: var(--ink); letter-spacing: -.6px; margin: 10px 0; }
.solution-cover p { font-size: 14px; color: var(--muted); line-height: 1.8; margin: 0; }
.reveal-button { display: flex; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 9px 17px; margin: 19px 0 14px; font-weight: 600; color: var(--ink); font-size: 13px; }
.reveal-button:hover { border-color: #a87900; background: var(--hint); }
.solution-cover small { color: var(--subtle); font-size: 11px; }
.solution-content { min-height: 447px; padding: 14px 20px; }
.solution-notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.solution-content pre { white-space: pre; overflow: auto; max-height: 390px; font: 15px/27px var(--font-mono); margin: 20px 0; color: var(--ink); background: transparent; }
.solution-content code { font: inherit; background: transparent; padding: 0; }
.results-panel { border-top: 1px solid var(--line); background: var(--soft); }
.results-heading { display: flex; justify-content: space-between; align-items: center; padding: 16px 21px 0; }
.results-heading>div { display: flex; align-items: center; gap: 10px; }
.terminal-symbol { font: 700 16px var(--font-mono); color: var(--muted); }
.results-heading h2 { font-size: 13px; font-weight: 600; margin: 0; color: var(--ink); }
.result-badge { font-size: 11px; color: var(--muted); padding: 3px 9px; background: var(--surface); border-radius: 4px; }
.result-badge.passed { color: #23572b; background: #dcefd9; }
.result-badge.failed { color: #89321e; background: #fce1d8; }
.result-badge.running { color: #624b00; background: #ffedab; }
#duration { font: 11px var(--font-mono); color: var(--subtle); }
#output { margin: 0; padding: 15px 22px 20px; color: var(--ink); font: 13px/1.85 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 290px; overflow: auto; min-height: 100px; background: transparent; }
.results-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface); }
#result-help { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.yellow-dot { width: 6px; height: 6px; border-radius: 50%; background: #aa7b00; flex-shrink: 0; }
.next-button { display: flex; gap: 20px; align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 9px 15px; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.next-button:enabled { background: var(--yellow); border-color: #d5a91d; color: #292600; }
.site-footer { display: flex; justify-content: space-between; gap: 25px; padding: 23px 0 28px; color: var(--muted); font-size: 12px; }
.site-footer>span>span { color: #a97e00; margin-right: 6px; }
.site-footer a:hover { text-decoration: underline; }
.notice { background: var(--hint); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
dialog { width: 450px; max-width: calc(100% - 32px); padding: 34px; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); box-shadow: 0 25px 120px #0005; background: var(--paper); }
dialog::backdrop { background: #14201988; backdrop-filter: blur(4px); }
.dialog-close { position: absolute; right: 16px; top: 13px; background: none; font-size: 26px; color: var(--muted); }
.dialog-close:hover { color: var(--ink); }
dialog>img { display: block; margin-bottom: 20px; }
dialog h2 { font: 800 26px/1.3 var(--font-display); letter-spacing: -.7px; margin: 8px 0 12px; color: var(--ink); }
dialog p { font-size: 14px; color: var(--muted); }
.local-note { background: var(--hint); border-radius: 7px; padding: 12px; font-size: 13px; color: var(--ink); margin: 17px 0 20px; }
dialog label { font-size: 13px; display: block; margin-bottom: 7px; font-weight: 600; }
dialog input { border: 1px solid var(--line); border-radius: 7px; width: 100%; padding: 12px; color: var(--ink); background: var(--surface); margin-bottom: 12px; }
.primary-button { background: var(--yellow); color: #282b0e; border-radius: 7px; padding: 12px 17px; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
form .primary-button { width: 100%; }
.secondary-button { background: var(--soft); border: 1px solid var(--line); border-radius: 7px; padding: 10px 14px; color: var(--ink); font-size: 14px; }
.login-message { min-height: 20px; }
.login-message.error { color: #b93c2b; }
[data-theme=dark] .login-message.error { color: #ffb6a6; }
#otp { font: 24px var(--font-mono); letter-spacing: 10px; text-align: center; }
.export-button { border-top: 1px solid var(--line); padding-top: 15px; width: 100%; text-align: center; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); box-shadow: 0 7px 25px #0002; border-radius: 8px; padding: 12px 20px; font-size: 14px; z-index: 20; }
@media(max-width:1200px) {
  .header-note, .save-state, .topic-label, .run-button kbd { display: none; }
  .run-button { margin-left: auto; }
  .page-shell, .site-header { padding-left: 3%; padding-right: 3%; }
  .editor-actions { padding: 13px 12px; }
  .editor-helpers { gap: 9px; }
  .pane-heading { padding: 0 14px; }
  .editable-badge { display: none; }
}
@media(max-width:760px) {
  .site-header { height: 72px; gap: 12px; }
  .brand { font-size: 23px; gap: 8px; }
  .brand img { width: 36px; height: 36px; }
  .header-actions { gap: 8px; }
  .profile-button { max-width: 160px; font-size: 12px; gap: 6px; padding-right: 10px; }
  #username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .theme-toggle { width: 34px; height: 34px; }
  .intro { padding: 28px 5px 24px; display: block; }
  .intro h1 { font-size: 36px; }
  .intro p { font-size: 14px; }
  .progress-card { width: 100%; padding-top: 22px; }
  .progress-card>span { display: none; }
  .page-shell { padding: 0 12px; }
  .exercise-toolbar { padding: 12px; gap: 8px; }
  .exercise-picker { display: block; min-width: 0; }
  .exercise-picker label { display: block; font-size: 10px; margin-bottom: 5px; }
  .exercise-picker select { max-width: 195px; min-width: 155px; font-size: 13px; }
  .exercise-navigation { gap: 7px; }
  .exercise-navigation>span { font-size: 11px; }
  .icon-button { width: 28px; height: 28px; }
  .split-panes { grid-template-columns: 1fr; }
  .exercise-pane { border-right: 0; }
  .solution-pane { border-top: 1px solid var(--line); }
  .solution-cover { min-height: 310px; padding: 22px; }
  .solution-illustration { height: 105px; margin-bottom: 8px; transform: scale(.8); }
  .solution-cover h2 { font-size: 22px; }
  .solution-cover small { display: none; }
  .solution-cover br { display: none; }
  .solution-cover p { max-width: 280px; }
  .reveal-button { margin-bottom: 0; }
  .solution-content { min-height: 220px; }
  .solution-content pre { max-height: 330px; }
  .editor-shell { min-height: 340px; }
  #editor { height: 340px; }
  .editor-actions { padding: 13px; }
  .results-footer { padding: 12px; align-items: flex-start; }
  #result-help { font-size: 11px; line-height: 1.6; }
  .next-button { gap: 10px; padding: 8px 10px; font-size: 12px; }
  .site-footer { display: block; text-align: center; padding: 22px 12px; }
  .site-footer a { display: block; margin-top: 8px; }
  .result-badge { font-size: 10px; }
  dialog { padding: 28px; }
  .dialog-actions { flex-wrap: wrap; }
}
@media(max-width:380px) {
  .brand { font-size: 20px; }
  .brand img { width: 30px; height: 30px; }
  .profile-button { max-width: 140px; }
  .exercise-navigation>span { display: none; }
}
@media(prefers-reduced-motion:reduce) { * { transition: none !important; animation: none !important; } }
/* Keep native dialogs centered when the shared stylesheet sets margin: 0. */
dialog { position: fixed; inset: 0; margin: auto; }
