@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Palette C "Warmer Kohle", accent = logo mint. New colors only after the user approved them. */
:root {
    --bg: #161513;
    --surface: #1e1c19;
    --surface-2: #26231f;
    --track: #2e2b26;
    --text: #f0ebe3;
    --muted: #a39b8f;
    --border: rgba(240, 230, 215, 0.10);
    --border-hover: rgba(240, 230, 215, 0.22);
    --accent: #09b682;
    --accent-ink: #04281d;
    --accent-soft: rgba(9, 182, 130, 0.14);
    --accent-border: rgba(9, 182, 130, 0.5);
    --accent-text: #6fe0b8;
    --accent-text-strong: #bff0dd;
    --r-card: 14px;
    --r-ctl: 11px;
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; }
a { color: var(--accent-text); }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.55rem 1rem; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; text-decoration: none; cursor: pointer; transition: border-color 0.15s ease, filter 0.15s ease; }
.btn:hover { border-color: var(--border-hover); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn--primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn--lg { padding: 0.8rem 1.4rem; width: 100%; }
.pill { align-self: flex-start; font-size: 11px; font-weight: 500; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); }
.note { margin: 0; padding: 0.6rem 0.9rem; border: 1px dashed var(--border-hover); border-radius: var(--r-ctl); color: var(--text); background: var(--surface-2); font-size: 0.9rem; }

/* ---------- login ---------- */
.login { min-height: calc(100dvh - 3.5rem); display: grid; place-items: center; padding: 1.5rem; }
.login__card { width: min(26rem, 100%); padding: 2rem; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--r-card) + 4px); display: grid; gap: 1rem; justify-items: center; }
.login__card h1 { margin: 0; font-size: 1.6rem; }
.login__card p { margin: 0; color: var(--muted); }
.login__card .note { color: var(--text); }
.login__note { font-size: 0.8rem; }

/* ---------- app shell: sidebar rail + mobile sheet ---------- */
.app { display: flex; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; width: 16rem; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border-right: 1px solid var(--border); transition: width 0.25s ease; flex-shrink: 0; }
.app[data-sidebar='collapsed'] .side { width: 4.25rem; }
.side__head { padding: 1rem 0.75rem 0.5rem; }
.side__brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.25rem 0.5rem; border-radius: var(--r-ctl); color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; }
.side__brand img { flex-shrink: 0; border-radius: 8px; }
.side__nav { flex: 1; overflow-y: auto; padding: 0 0.75rem; }
.side__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side__group { margin: 0.9rem 0.85rem 0.35rem; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.side__foot { padding: 0.75rem; border-top: 1px solid var(--border); display: grid; gap: 2px; }

.nav { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 2.5rem; padding: 0 0.85rem; border-radius: var(--r-ctl); color: var(--muted); text-decoration: none; white-space: nowrap; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.nav:hover { color: var(--text); }
.nav[aria-current='page'] { background: var(--surface-2); color: var(--text); }
.nav--off { cursor: default; opacity: 0.6; }
.nav--off:hover { color: var(--muted); }
.ico { width: 1.2rem; height: 1.2rem; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav__label, .nav__badge, .side__group { transition: opacity 0.15s ease, transform 0.15s ease; white-space: nowrap; }
.nav__badge { margin-left: auto; font-size: 11px; color: var(--accent-text); background: var(--accent-soft); border-radius: 99px; padding: 0 0.5rem; }
.app[data-sidebar='collapsed'] :is(.nav__label, .nav__badge, .side__group) { opacity: 0; transform: translateX(-4px); pointer-events: none; }

.user { display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 0.5rem; min-width: 0; }
.user__avatar { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text-strong); font-weight: 600; }
.user__text { display: grid; line-height: 1.3; min-width: 0; }
.user__name { overflow: hidden; text-overflow: ellipsis; font-size: 0.92rem; }
.user__role { font-size: 0.75rem; color: var(--muted); }
.logout { margin: 0; }

.main { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; padding: 0.75rem 1rem; }
.icon-btn { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-hover); }
.page { max-width: 64rem; margin: 0 auto; padding: 0.5rem 1.5rem 3rem; }
.page__title { margin: 0 0 1.5rem; font-size: 1.7rem; font-weight: 600; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--r-card); display: grid; gap: 0.5rem; justify-items: center; }
.empty h1, .empty h2 { margin: 0; color: var(--text); font-size: 1.15rem; }
.empty p { margin: 0; }

/* ---------- courses, steps, lessons ---------- */
.muted { color: var(--muted); }
.section-title { margin: 2rem 0 1rem; font-size: 1.15rem; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); gap: 1rem; }
.course { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); color: var(--text); text-decoration: none; transition: transform 0.2s ease, border-color 0.2s ease; }
.course:hover { transform: translateY(-2px); border-color: var(--border-hover); }
.course__title { margin: 0; font-size: 1.05rem; font-weight: 600; }
.course__desc { margin: 0; color: var(--muted); font-size: 0.92rem; }
.course__meta, .course__foot { margin: 0; color: var(--muted); font-size: 0.85rem; }
.course__foot { display: flex; justify-content: space-between; margin-top: auto; }
.course__cta { color: var(--accent-text); }
.progress { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress > i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.5s ease; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.tile { padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.tile__label { margin: 0; font-size: 0.8rem; color: var(--muted); }
.tile__value { margin: 0.25rem 0 0; font-size: 1.7rem; font-weight: 600; }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.1rem 1.25rem; background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--r-card); }
.resume p { margin: 0; }
.resume__title { font-size: 1.1rem; font-weight: 600; color: var(--accent-text-strong); }

.crumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.course-head { display: grid; gap: 0.5rem; justify-items: start; margin-bottom: 2rem; }
.course-head .page__title { margin: 0; }
.course-head p { margin: 0; }
.course-head .progress { width: min(24rem, 100%); }

.acc { border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--surface); }
.acc + .acc { margin-top: 0.5rem; }
.acc summary { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; cursor: pointer; list-style: none; font-weight: 500; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: ''; margin-left: auto; width: 0.5rem; height: 0.5rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.2s ease; }
.acc[open] summary::after { transform: rotate(225deg); }
.acc__body { padding: 0 0.5rem 0.75rem; }

.steps { list-style: none; margin: 0; padding: 0; }
.step { position: relative; padding-left: 2rem; }
.step a { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0.6rem; border-radius: var(--r-ctl); color: var(--muted); text-decoration: none; }
.step a:hover { color: var(--text); background: var(--surface-2); }
.step__min { font-size: 0.8rem; white-space: nowrap; opacity: 0.8; }
.step__dot { position: absolute; left: 0.45rem; top: 0.85rem; width: 0.8rem; height: 0.8rem; border-radius: 50%; border: 2px solid var(--track); background: var(--surface); z-index: 1; }
.step:not(:last-child)::before { content: ''; position: absolute; left: 0.83rem; top: 1.6rem; bottom: -0.6rem; width: 2px; background: var(--track); }
.step[data-state='done'] .step__dot { background: var(--accent); border-color: var(--accent); }
.step[data-state='done']:not(:last-child)::before { background: var(--accent-border); }
.step[data-state='current'] a { color: var(--text); background: var(--surface-2); }
.step[data-state='current'] .step__dot { border-color: var(--accent); }

.lesson { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 2rem; align-items: start; }
.lesson__side { position: sticky; top: 1rem; max-height: calc(100dvh - 2rem); overflow-y: auto; }
.lesson__pos { margin: 0 0 0.25rem; font-size: 0.85rem; }
.lesson__done { margin-top: 2rem; }
.lesson-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }

.md { max-width: 44rem; }
.md > :first-child { margin-top: 0; }
.md h2 { margin: 2rem 0 0.75rem; font-size: 1.3rem; }
.md h3 { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; }
.md p, .md ul, .md ol { margin: 0 0 1rem; }
.md li { margin: 0.25rem 0; }
.md code { padding: 0.1em 0.4em; border-radius: 6px; background: var(--surface-2); font: 0.9em ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.md blockquote { margin: 1rem 0; padding: 0.25rem 1rem; border-left: 3px solid var(--accent-border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.code { margin: 1rem 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.code__bar { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.6rem 0.4rem 1rem; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.code__pre { margin: 0; padding: 1rem 0; overflow: auto; font: 0.88rem/1.6 ui-monospace, 'Cascadia Mono', Consolas, monospace; counter-reset: n; }
.code__pre code { padding: 0; background: none; font: inherit; }
.line { display: block; padding: 0 1rem; counter-increment: n; }
.line::before { content: counter(n); display: inline-block; width: 2rem; margin-right: 1rem; text-align: right; color: var(--muted); opacity: 0.6; }
.tok-k { color: var(--accent-text); }
.tok-s { color: var(--accent-text-strong); }
.tok-n { color: var(--accent-text-strong); }
.tok-c { color: var(--muted); font-style: italic; }
.btn--sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

.tbl-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tbl th { text-align: left; padding: 0.7rem 1rem; font-weight: 500; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }

@media (max-width: 960px) {
    .lesson { grid-template-columns: minmax(0, 1fr); }
    .lesson__side { position: static; max-height: none; }
}

@media (max-width: 767px) {
    .side { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(18rem, 88vw); transform: translateX(-100%); transition: transform 0.3s ease; }
    .app[data-sidebar='collapsed'] .side { width: min(18rem, 88vw); }
    .app[data-sidebar='open-mobile'] .side { transform: none; }
    .app[data-sidebar='open-mobile'] { overflow: hidden; }
    .app :is(.nav__label, .nav__badge, .side__group) { opacity: 1; transform: none; pointer-events: auto; }
    .page { padding: 0.5rem 1rem 2.5rem; }
}

/* ---------- closed mode, footer, admin ---------- */
.quiet { color: var(--muted); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 3px; }
.quiet:hover { color: var(--text); }
.foot { margin: 0; padding: 0 0 1.5rem; text-align: center; font-size: 0.8rem; }
.foot a { color: var(--muted); }
.tbl th[scope='row'] { width: 16rem; color: var(--muted); font-weight: 500; font-size: 0.85rem; white-space: normal; }
.tbl code { font-size: 0.85em; }

/* ---------- forms ---------- */
.form { display: grid; gap: 1rem; width: 100%; text-align: left; }
.field { display: grid; gap: 0.35rem; }
.field label { font-size: 0.85rem; color: var(--muted); }
.in { width: 100%; padding: 0.65rem 0.85rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-ctl); font: inherit; }
.in:focus { border-color: var(--accent-border); outline: none; box-shadow: var(--focus); }
.in--code { font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.hint { margin: 0; font-size: 0.8rem; color: var(--muted); }
.linkrow { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0; font-size: 0.85rem; }
.linkrow a { color: var(--muted); }
.linkrow a:hover { color: var(--text); }
.divider { display: flex; align-items: center; gap: 0.75rem; width: 100%; margin: 0; color: var(--muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.quiet--btn { background: none; border: 0; padding: 0; font: inherit; font-size: 0.85rem; cursor: pointer; }

/* ---------- legal links ---------- */
.legal-line a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.legal-line a:hover { color: var(--text); }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--text); }
.foot--app { padding: 1.5rem 1rem 1.5rem; }

/* ---------- exercises ---------- */
.exercises { margin-top: 2.5rem; max-width: 44rem; }
.exercises > h2 { margin: 0 0 0.25rem; font-size: 1.3rem; }
.exercises .ex__summary { margin: 0 0 1rem; font-size: 0.9rem; }
.ex { margin: 0 0 1.25rem; padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); display: grid; gap: 0.85rem; }
.ex__head { display: flex; align-items: center; gap: 0.6rem; margin: 0; font-size: 0.85rem; color: var(--muted); }
.ex__solved { margin-left: auto; font-size: 0.8rem; color: var(--accent-text); }
.ex__q { margin: 0; font-size: 1.05rem; font-weight: 600; }
.ex__prompt { margin: 0; }
.ex .hint { margin: 0; }
.ex .code { margin: 0; }
.ex__error { margin: 0; color: var(--text); font-size: 0.9rem; }
.ex__actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.btn--ghost { background: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.ex__result { padding: 0.8rem 1rem; border-radius: var(--r-ctl); background: var(--surface-2); border: 1px solid var(--border); }
.ex__result[data-state='correct'] { border-color: var(--accent-border); background: var(--accent-soft); }
.ex__result[data-state='wrong'] { border-style: dashed; }
.ex__result p { margin: 0; }
.ex__verdict { font-weight: 600; }
.ex__label { margin-top: 0.5rem !important; color: var(--muted); font-size: 0.85rem; }
.ex__solution { margin: 0.25rem 0 0; padding-left: 1.2rem; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.88rem; }
.ex__explain { margin-top: 0.6rem !important; color: var(--text); }
.in--mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; resize: vertical; }

.choices { display: grid; gap: 0.5rem; }
.choice { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-ctl); cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.choice:hover { border-color: var(--border-hover); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text-strong); }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.choice__key { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; flex-shrink: 0; border-radius: 8px; background: var(--track); font-size: 0.8rem; color: var(--muted); }
.choice[data-state='correct'] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.choice[data-state='wrong'] { border-style: dashed; opacity: 0.75; }

.gap { padding: 0 0.4rem; min-width: 4rem; color: var(--accent-text-strong); background: var(--surface-2); border: 0; border-bottom: 2px solid var(--accent-border); border-radius: 6px; font: inherit; }
.gap:focus { outline: none; box-shadow: var(--focus); }
.gap[data-state='correct'] { border-bottom-color: var(--accent); }
.gap[data-state='wrong'] { border-bottom-style: dashed; opacity: 0.8; }

.sort { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.sort__row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-ctl); cursor: grab; touch-action: none; user-select: none; }
.sort__row code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.88rem; }
.sort__row[aria-pressed='true'] { border-color: var(--accent-border); background: var(--accent-soft); }
.sort__row.is-dragging { transform: scale(1.02); box-shadow: 0 10px 24px -14px #000; cursor: grabbing; position: relative; z-index: 1; }
.sort[data-locked] .sort__row { cursor: default; }
.sort__grip { color: var(--muted); letter-spacing: -2px; }

.bugcode { list-style: none; margin: 0; padding: 0.5rem 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-card); }
.bugline { display: flex; gap: 1rem; width: 100%; padding: 0.15rem 1rem; background: none; border: 0; border-left: 3px solid transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.bugline code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.88rem; white-space: pre; }
.bugline__n { width: 1.5rem; text-align: right; color: var(--muted); opacity: 0.7; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.88rem; }
.bugline:hover { background: var(--track); }
.bugline[aria-pressed='true'] { background: var(--accent-soft); border-left-color: var(--accent-border); }
.bugline[data-state='correct'] { background: var(--accent-soft); border-left-color: var(--accent); }
.bugline[data-state='wrong'] { border-left-style: dashed; opacity: 0.8; }
.bugline:disabled { cursor: default; color: var(--text); }

/* ---------- flashcards ---------- */
.deck { display: grid; gap: 1rem; max-width: 38rem; }
.deck__counts { margin: 0; font-size: 0.9rem; }
.deck__hint { margin: 0; text-align: center; }
.deck__error { margin: 0; }
.flash { perspective: 1000px; cursor: pointer; border-radius: var(--r-card); }
.flash[hidden] { display: none; }
.flash__inner { display: grid; transition: transform 0.5s ease; transform-style: preserve-3d; }
.flash[aria-pressed='true'] .flash__inner { transform: rotateY(180deg); }
.flash__face { grid-area: 1 / 1; display: grid; align-content: center; min-height: 16rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flash__face .md { max-width: none; }
.flash__back { transform: rotateY(180deg); background: var(--surface-2); }
.rate { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.rate[hidden] { display: none; }
kbd { margin-left: 0.35rem; font: inherit; font-size: 0.75rem; opacity: 0.7; }
