* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #151120; --line: #686a82; --panel: #211a30; --editor: #171221;
  --border: #463a5c; --text: #f7f3fb; --muted: #c4b9d1; --accent: #c0abff;
  --action: #d6fa72; --selected: #332551; --success: #9bf6af;
  --keyword: #a9caff; --string: #96e1b2; --number: #f9c987; --error: #a85560;
  font: 16px/1.55 "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fffcf8; --panel: #fff; --editor: #f7f9ff;
  --border: #d8d9df; --line: #92969c; --text: #111213; --muted: #525761; --accent: #1335cb;
  --selected: #ebf1ff; --success: #166346; --action: #1035d6;
  --keyword: #164cb3; --string: #176d48; --number: #8b4804; --error: #c3424f;
}
body { margin: 0; display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
button, input, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 2; top: .5rem; left: .5rem; transform: translateY(-150%); padding: .5rem 1rem; background: var(--panel); }
.skip:focus { transform: none; }
.masthead, main, .site-footer {
  width: min(100%, 1680px); margin-inline: auto; padding-inline: clamp(1rem, 2.4vw, 2.5rem);
}
.masthead {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 1.1rem; min-height: clamp(70px, 5.4vw, 86px); margin-bottom: 0;
}
.masthead::after { content: ""; position: absolute; inset: auto clamp(1rem, 2.4vw, 2.5rem) 0; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; justify-self: start; align-items: center; gap: .5em; color: var(--text); text-decoration: none; font-size: clamp(1.25rem, 2.22vw, 2.2rem); font-weight: 850; letter-spacing: -.045em; line-height: 1; }
.brand-mark { width: 1.25em; height: 1em; display: flex; justify-content: space-between; color: var(--accent); }
.brand-mark::before, .brand-mark::after { content: ""; width: .32em; border: .15em solid currentColor; }
.brand-mark::before { border-right: none; }
.brand-mark::after { border-left: none; }
.primary-nav { display: flex; gap: clamp(1rem, 2.6vw, 2.7rem); }
.primary-nav a { padding: .5em .08em; color: var(--text); border-bottom: 3px solid transparent; text-decoration: none; font-size: clamp(1rem, 1.52vw, 1.5rem); font-weight: 600; }
.primary-nav a[aria-current] { border-color: var(--accent); }
.primary-nav a:hover { color: var(--accent); }
.masthead-tools { display: flex; align-items: center; justify-content: end; gap: clamp(.6rem, 2.2vw, 2.3rem); min-width: 0; }
.language-switch { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: .55rem; }
.language-switch button { background: transparent; border: none; padding: .35em .85em; font-weight: 600; border-radius: 0; }
.language-switch button:first-of-type { border-radius: .48rem 0 0 .48rem; }
.language-switch button:last-of-type { border-radius: 0 .48rem .48rem 0; }
.language-switch button[aria-pressed="true"] { color: white; background: #1237d5; }
.account-menu { position: relative; min-width: 0; margin: 0; }
.account-menu summary { color: var(--accent); font-weight: 700; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-items { position: absolute; right: 0; top: calc(100% + .6rem); z-index: 4; min-width: 14rem; display: grid; gap: .45rem; padding: .8rem; background: var(--panel); border: 1px solid var(--border); border-radius: .55rem; box-shadow: 0 6px 18px #131e351a; }
.site-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: auto; padding-block: 1rem; color: var(--muted); font-size: .9rem; }
.footer-progress { display: flex; align-items: center; gap: .6rem; }
.footer-progress progress { width: 4.5rem; margin: 0; height: .45rem; }
main { padding-block: clamp(1.25rem, 2.15vw, 2.25rem); }
@media (max-width: 930px) {
  .masthead { grid-template-columns: 1fr auto; padding-top: .8rem; row-gap: .25rem; }
  .primary-nav { grid-area: 2 / 1 / 3 / -1; justify-content: center; }
}
@media (max-width: 540px) {
  .masthead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .55rem; }
  .primary-nav { order: 3; flex-basis: 100%; justify-content: space-around; }
  .masthead-tools { flex-wrap: wrap; }
  .language-switch button, .masthead-tools .button { font-size: .8rem; padding: .35em .5em; }
  .brand { font-size: 1.13rem; gap: .35em; }
  .account-menu summary { max-width: 6rem; }
}
header { margin-bottom: 1.3rem; }
header h1 { font-weight: 720; letter-spacing: -.025em; line-height: 1.15; font-size: clamp(1.75rem, 3vw, 2.5rem); margin: .3rem 0; }
header p, .muted, .lesson-state, .label-row span { color: var(--muted); }
h2 { font-size: 1.17rem; margin: 0 0 .45rem; }
p { margin: .35rem 0 .7rem; }
ul, ol { margin: .45rem 0 .75rem; padding-left: 1.45rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: .65rem; padding: 1.1rem 1.25rem; min-width: 0; }
main > .card + .card { margin-top: 1rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.metrics p { color: var(--muted); margin: 0; }
.metrics strong { font-size: clamp(1.15rem, 3vw, 1.9rem); }
progress { display: block; width: 100%; height: .7rem; margin: .7rem 0 1.05rem; accent-color: var(--accent); }
button, .button {
  display: inline-block; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: .38rem; padding: .4rem .75rem; cursor: pointer; text-decoration: none; white-space: normal;
}
button:hover:not(:disabled), .button:hover { background: var(--selected); }
button:disabled { opacity: .55; cursor: default; }
.primary { color: #06191c; background: var(--action); border-color: transparent; font-weight: 700; }
.primary:hover:not(:disabled) { background: #e4ff9e; }
:root[data-theme="light"] .primary { color: #fff; }
:root[data-theme="light"] .primary:hover:not(:disabled) { background: #092495; }
.course-list { list-style-position: inside; padding: 0; display: grid; gap: .55rem; }
.course-list li { list-style: none; }
.course-list a { display: flex; justify-content: space-between; gap: .7rem; text-decoration: none; color: var(--text); }
.course-list a:hover { border-color: var(--accent); }
.lesson-state { font-size: .88rem; flex-shrink: 0; }
.workspace { display: grid; gap: 1rem; max-width: 1050px; align-items: start; }
.workspace.with-lesson { grid-template-columns: minmax(0, 4.2fr) minmax(0, 7fr); max-width: none; }
.reading section { padding-top: .8rem; margin-top: .8rem; border-top: 1px solid var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
dt { font-family: Consolas, monospace; color: var(--accent); }
dd { margin: .1rem 0 .45rem; }
pre, code, #code, #stdin { font-family: Consolas, ui-monospace, monospace; }
pre, textarea { overflow: auto; background: var(--editor); color: var(--text); border-radius: .4rem; border: 1px solid var(--border); }
pre { padding: .65rem .8rem; margin: .5rem 0; tab-size: 4; }
.path { overflow-wrap: anywhere; }
.crumbs { color: var(--muted); }
.crumbs a { font-weight: 650; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.lesson-header { border-bottom: 1px solid var(--border); padding-bottom: 1.15rem; }
.lesson-header h1 { margin: .65rem 0 0; }
.reading { padding: .1rem .25rem; min-width: 0; }
.reading > h2 { font-size: 1.35rem; }
.reading > p { font-size: 1.06rem; }
.reading .assignment { padding: 1rem; margin: 1.5rem 0 .9rem; border-top: 1px solid var(--border); }
.hint { padding: .55rem .75rem; border: 1px solid var(--border); border-radius: .4rem; }
.hint summary { font-weight: 650; }
.hint p { margin: .5rem 0 0; color: var(--muted); }
.lesson-links { margin-top: 1rem; justify-content: space-between; }
.coding { position: sticky; top: 1rem; padding: 0; }
.editor-toolbar, .editor-status, .editor-panel { padding: .65rem 1rem; }
.editor-toolbar, .editor-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.editor-toolbar { padding-bottom: 0; }
.editor-toolbar .actions { padding-bottom: .65rem; }
.file-tab { align-self: stretch; display: flex; align-items: center; padding: .4rem .9rem; background: var(--selected); border-radius: .35rem .35rem 0 0; border-bottom: .22rem solid var(--accent); font-weight: 650; }
.editor-status, .editor-panel { border-top: 1px solid var(--border); }
.editor-status button { font-size: .8rem; padding: .2rem .5rem; }
.editor-status span { color: var(--muted); font-size: .8rem; }
.editor-panel label { font-weight: 650; }
.editor-panel label[for="stdin"], .editor-panel .console-title { margin-top: 0; }
.editor-panel .console { min-height: 3rem; }
.positive { color: var(--success); font-weight: 650; }
.quiz fieldset { border: 0; padding: 0; margin: .75rem 0 1rem; }
.quiz legend { margin-bottom: .45rem; }
.quiz-option { display: block; padding: .5rem; border-bottom: 1px solid var(--border); }
.quiz-option input { accent-color: var(--accent); }
.quiz-result { margin-top: .9rem; }
.translation dd { margin-bottom: .7rem; }
.label-row { display: flex; justify-content: space-between; gap: .5rem; margin: .75rem 0 .35rem; }
.coding label, .label-row span { font-size: .9rem; }
textarea { width: 100%; padding: .5rem; display: block; }
.editor { display: grid; grid-template-columns: auto minmax(0, 1fr); border-top: 1px solid var(--border); background: var(--editor); }
.editor:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.editor-body { display: grid; min-width: 0; position: relative; }
.editor-body > *, #line-numbers {
  font: 15px/1.6 Consolas, ui-monospace, monospace; white-space: pre; letter-spacing: 0; tab-size: 4;
  border: 0; border-radius: 0; margin: 0; padding: .55rem .65rem; min-width: 0;
}
.editor-body > * { grid-area: 1 / 1; }
#line-numbers { height: 0; min-height: 100%; overflow: hidden; color: var(--muted); text-align: right; border-right: 1px solid var(--border); }
#highlight { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#code { resize: vertical; outline: none; background: transparent; caret-color: var(--text); }
.editor.enhanced #code { color: transparent; }
.editor.enhanced #code::selection { color: var(--text); background: var(--selected); }
.token-keyword { color: var(--keyword); }
.token-string { color: var(--string); }
.token-number { color: var(--number); }
.token-comment { color: var(--muted); }
.diagnostic { text-decoration: underline wavy var(--error); }
#suggestions { margin-top: .45rem; }
label[for="stdin"] { display: block; margin: .65rem 0 .15rem; }
.console-title { margin-top: .65rem; font-size: 1rem; }
.console { min-height: 5rem; max-height: 14rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
details { margin: .5rem 0; }
summary { cursor: pointer; color: var(--accent); }
@media (max-width: 1000px) {
  .workspace.with-lesson { grid-template-columns: minmax(0, 1fr); }
  .coding { position: static; }
}
@media (max-width: 610px) {
  .metrics { grid-template-columns: 1fr; }
}



.account-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: stretch; max-width: 1080px; margin: clamp(0rem, 3vw, 3rem) auto; }
.account-card { padding: clamp(1rem, 3vw, 2.5rem); }
.account-card header h1 { font-size: clamp(1.8rem, 3vw, 3.2rem); }
.account-form, .feedback-form { display: grid; gap: .85rem; }
.account-form input { display: block; width: 100%; background: var(--editor); color: var(--text); border: 1px solid var(--border); border-radius: .4rem; padding: .68rem .8rem; margin-top: .25rem; }
.account-form label, .feedback-form label { font-weight: 650; }
.account-form ul { padding-left: 1rem; font-size: .86rem; color: var(--muted); }
.account-form button, .feedback-form button { justify-self: start; }
.account-switch { margin: 1rem 0 0; }
.errorlist, .account-form .errorlist { color: #ffabb3; padding-left: 1rem; }
:root[data-theme="light"] .errorlist { color: #9e2549; }
.theme-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: .75rem; max-width: 500px; }
.theme-choice { text-align: left; padding: .55rem; border-radius: .7rem; }
.theme-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-choice strong { display: block; padding: .45rem .25rem .15rem; }
.theme-sample { display: grid; grid-template-columns: 24% 1fr; gap: .5rem; height: 65px; padding: .45rem; border: 1px solid; border-radius: .4rem; overflow: hidden; }
.theme-sample span, .theme-sample i { border-radius: .25rem; }
.sample-light { background: #fffcf8; color: #d8d9df; }
.sample-light span { background: #1439d2; }
.sample-light i { background: #bce5ff; }
.sample-dark { background: #151120; color: #463a5c; }
.sample-dark span { background: #332551; }
.sample-dark i { background: #46317a; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .5rem; border-bottom: 1px solid var(--border); }
.feedback-note { padding: .7rem 0; border-top: 1px solid var(--border); }
.feedback-note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-note time { color: var(--muted); font-size: .85rem; }
@media (max-width: 850px) {
  .account-layout { grid-template-columns: minmax(0, 1fr); }
  .account-art { display: none; }
}

