/* Informatik-Challenge · Stein auf Stein – shared styles (tokens as on the model pages) */
:root {
  --bg: #ECEEEC; --surface: #F8F9F7; --fg: #1B2A34; --muted: #56636A; --line: #CBD1CF;
  --accent: #8C6420; --accent-soft: #AA7F2E; --stage: #D9DCD8; --plinth: #1B2A34; --plinth-fg: #E6E3E0;
  --ok: #237841; --bad: #B3261E; --code-bg: #FBFBF9; --code-fg: #1B2A34; --gutter: #8A969C; --sel: #E8DDC6;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11181D; --surface: #18232B; --fg: #E6E3E0; --muted: #9AA6AB; --line: #2A3943;
    --accent: #D6AA55; --accent-soft: #C79A45; --stage: #0D1317; --plinth: #0A0F12; --plinth-fg: #E6E3E0;
    --ok: #6CC287; --bad: #F2867C; --code-bg: #0F161B; --code-fg: #E6E3E0; --gutter: #5F6E75; --sel: #3A3220;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11181D; --surface: #18232B; --fg: #E6E3E0; --muted: #9AA6AB; --line: #2A3943;
  --accent: #D6AA55; --accent-soft: #C79A45; --stage: #0D1317; --plinth: #0A0F12; --plinth-fg: #E6E3E0;
  --ok: #6CC287; --bad: #F2867C; --code-bg: #0F161B; --code-fg: #E6E3E0; --gutter: #5F6E75; --sel: #3A3220;
  color-scheme: dark;
}
/* language: every text exists twice, <x lang="de"> and <x lang="en"> */
html[data-ui="de"] [lang="en"]:not(html), html[data-ui="en"] [lang="de"]:not(html) { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom, 0px); }
img, svg, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px 0; }
.topbar a { font-size: 13.5px; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
header.plate { padding-block: 10px 18px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(32px, 5.6vw, 60px); line-height: 1; letter-spacing: -0.02em; margin: 6px 0 0; text-wrap: balance; }
h1 .gold, h2 .gold { color: var(--accent); }
.lede { max-width: 70ch; color: var(--muted); margin: 12px 0 0; font-size: 16px; }
section { padding-block: 36px 4px; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(23px, 3vw, 31px); letter-spacing: -0.01em; margin: 0 0 6px; text-wrap: balance; }
h3 { font: 600 16px var(--font-body); margin: 22px 0 6px; }
.sub { color: var(--muted); margin: 0 0 18px; max-width: 72ch; }
p { max-width: 78ch; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
code, kbd, pre, textarea, .sig, .mono, .log { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
p code, li code, td code { background: color-mix(in srgb, var(--line) 45%, transparent); padding: 1px 4px; border-radius: 3px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; font-size: 12px; }

button.chip, a.chip { font: 500 12.5px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; cursor: pointer; text-decoration: none; display: inline-block; }
button.chip:hover, a.chip:hover { border-color: var(--accent-soft); }
.btn { font: 600 14px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--accent-soft); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button:focus-visible, input:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

/* level tabs */
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
.levels button { font: 600 14px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 14px; cursor: pointer; text-align: left; line-height: 1.25; }
.levels button small { display: block; font: 500 11.5px var(--font-mono); color: var(--muted); letter-spacing: 0.03em; }
.levels button[aria-selected="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.levels button[aria-selected="true"] small { color: color-mix(in srgb, var(--bg) 75%, transparent); }
.levels button .done { color: var(--ok); margin-left: 4px; }
.levels button[aria-selected="true"] .done { color: #8FE0A8; }

.task { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-top: 14px; }
.task h3 { margin-top: 0; font: 700 19px var(--font-display); }
.task p, .task ul { margin: 6px 0; }
.task ul { padding-left: 20px; }
.sig { font-family: var(--font-mono); font-size: 13.5px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; display: inline-block; margin: 4px 0; overflow-x: auto; max-width: 100%; }

/* workbench: editor left, results right */
.bench { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 18px; margin-top: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; min-width: 0; }
.panel > h3:first-child { margin-top: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .grow { flex: 1; }
.toolbar .note { font-size: 12px; color: var(--muted); }

.editor { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--line); border-radius: 4px;
  background: var(--code-bg); height: 460px; overflow: hidden; }
.editor .gutter, .editor textarea { font: 13.5px/1.5 var(--font-mono); margin: 0; padding: 10px 0; tab-size: 2; }
.editor .gutter { color: var(--gutter); text-align: right; padding-left: 8px; padding-right: 8px; user-select: none; overflow: hidden;
  border-right: 1px solid var(--line); white-space: pre; min-width: 3.2em; }
.editor .gutter span { display: block; }
.editor .gutter span.err { color: #fff; background: var(--bad); border-radius: 2px; }
.editor textarea { border: 0; outline: 0; resize: none; background: transparent; color: var(--code-fg); padding-left: 10px; padding-right: 10px;
  white-space: pre; overflow: auto; width: 100%; height: 100%; caret-color: var(--accent); }
.editor textarea::selection { background: var(--sel); }
.editor:focus-within { border-color: var(--accent-soft); }
.log { font: 12.5px/1.45 var(--font-mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px;
  margin: 10px 0 0; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.log .e { color: var(--bad); }

/* tests */
ul.tests { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
ul.tests li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 6px; font-size: 13.5px; padding: 5px 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--line) 22%, transparent); }
ul.tests li .ic { font-weight: 700; text-align: center; }
ul.tests li.pass .ic { color: var(--ok); }
ul.tests li.fail .ic { color: var(--bad); }
ul.tests li.wait .ic { color: var(--muted); }
ul.tests li .why { display: block; color: var(--muted); font-size: 12.5px; word-break: break-word; }
.score { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin: 12px 0 2px; padding: 10px 12px; border-radius: var(--r);
  background: var(--plinth); color: var(--plinth-fg); }
.score strong { font: 800 26px var(--font-display); color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.score span { font-size: 13px; }
.status { font-size: 13px; color: var(--muted); min-height: 1.4em; margin: 8px 0 0; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }

/* views */
.views { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.views.prog { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.view { min-width: 0; }
.view canvas { display: block; width: 100%; height: auto; background: var(--stage); border-radius: var(--r); touch-action: none; }
.view canvas.grab { cursor: grab; }
.view figcaption, .cap { font-size: 12.5px; color: var(--muted); padding-top: 5px; }
.view .ctl { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.view .ctl input[type=range] { flex: 1; min-width: 60px; accent-color: var(--accent-soft); }
.view .ctl output { font-family: var(--font-mono); font-variant-numeric: tabular-nums; min-width: 6ch; text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; border: 1px solid color-mix(in srgb, var(--fg) 25%, transparent); }
table.stat { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.stat th, table.stat td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.stat th:first-child, table.stat td:first-child { text-align: left; }
table.stat th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }

/* hints and solutions */
.hints { margin-top: 14px; display: grid; gap: 6px; }
details.hint { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; }
details.hint summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details.hint[open] summary { margin-bottom: 4px; }
details.hint p, details.hint pre { margin: 6px 0; }
pre.snip { font: 12.5px/1.5 var(--font-mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; overflow-x: auto; }

/* teacher box */
.teacher { border: 1px solid var(--line); border-left: 4px solid var(--accent-soft); background: var(--surface); border-radius: var(--r); padding: 14px 18px; }
.teacher h2 { font-size: 22px; }
.teacher dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 16px; margin: 8px 0 0; }
.teacher dt { font-weight: 600; }
.teacher dd { margin: 0; color: var(--muted); }
.teacher ul { margin: 0; padding-left: 18px; }

/* overview cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card h2 { margin: 0; }
.card canvas { display: block; width: 100%; height: auto; background: var(--stage); border-radius: var(--r); touch-action: none; cursor: grab; }
.card ol { margin: 0; padding-left: 20px; }
.card ol li { margin: 3px 0; }
.card .grade { font: 500 11.5px var(--font-mono); color: var(--muted); letter-spacing: 0.03em; }
.card .btns { margin-top: auto; padding-top: 6px; }
.pill { display: inline-block; font: 500 11.5px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }

/* maths figures */
.math { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.math figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.math figure svg { display: block; width: 100%; height: auto; max-height: 190px; }
.math figcaption { font-size: 13.5px; color: var(--muted); }
.math figcaption strong { color: var(--fg); display: block; font-size: 14.5px; margin-bottom: 2px; }
.math .f { font-family: var(--font-mono); font-size: 13px; color: var(--fg); background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 7px; display: inline-block; margin: 4px 0; }
svg .ink { stroke: var(--fg); fill: none; }
svg .inkf { fill: var(--fg); }
svg .acc { stroke: var(--accent); fill: none; }
svg .accf { fill: var(--accent); }
svg .mut { stroke: var(--muted); fill: none; }
svg .mutf { fill: var(--muted); }
svg .soft { fill: color-mix(in srgb, var(--accent-soft) 22%, transparent); stroke: var(--accent-soft); }
svg text { font: 12px var(--font-body); fill: var(--fg); }
svg text.m { font-family: var(--font-mono); font-size: 11.5px; }

/* pipeline strip */
ol.pipe { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
ol.pipe li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
ol.pipe li::before { content: counter(s); font: 700 14px var(--font-display); width: 24px; height: 24px; border-radius: 4px; display: inline-grid;
  place-items: center; background: var(--plinth); color: var(--accent-soft); margin-right: 8px; }
ol.pipe li strong { font-weight: 600; }
ol.pipe li p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
ol.pipe li .tag { display: inline-block; font: 500 11px var(--font-mono); color: var(--accent); margin-top: 4px; }

footer { padding-block: 40px 48px; color: var(--muted); font-size: 13px; }
footer p { max-width: 95ch; }
.nameplate { display: inline-block; background: var(--plinth); color: var(--accent-soft); font: 500 12px var(--font-mono); letter-spacing: 0.3em; padding: 4px 10px; border-radius: 3px; }
.legal { display: flex; gap: 16px; flex-wrap: wrap; }
noscript p { background: var(--surface); border: 1px solid var(--bad); padding: 10px; border-radius: var(--r); }

@media (max-width: 920px) {
  .bench { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .editor { height: 380px; }
}
@media (max-width: 560px) {
  .views, .views.prog { grid-template-columns: 1fr; }
  .teacher dl { grid-template-columns: 1fr; }
  .teacher dt { margin-top: 6px; }
  .levels button { flex: 1 1 100%; }
}
@media print {
  .editor { height: auto; }
  .btns, .toolbar, .levels { display: none; }
}
