/* werkbank.css
 *
 * Fusion aus zwei Stilen, die er beide schon gebaut hat:
 *  - STRUKTUR aus den Elektrotechnik-Guides: DIN-Schriftfeld als Kopf, ruhige
 *    Callout-Klassen, keine Schatten, keine Gradienten, druckbar.
 *  - TOKENS + Theming aus pace-pipeline-phasen.html: dreifaches Theming,
 *    semantische Akzente mit -ink/-soft, prefers-reduced-motion-Notausschalter.
 *
 * v1 benutzt den System-Font-Stack: null Bytes, null Minuten. woff2 (Archivo,
 * Source Sans 3, IBM Plex Mono - alle OFL) kommt in v2.
 */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eaeff3;
  --surface-3: #dfe6ec;
  --border: #cdd8e0;
  --border-strong: #9fb0bd;
  --text: #16222e;
  --text-2: #44556380;
  --text-3: #5b6a77;

  --cyan: #1257c4;
  --cyan-ink: #0b3d8f;
  --cyan-soft: #e7eefb;
  --green: #1d6b3a;
  --green-ink: #12492633;
  --green-soft: #eaf3ec;
  --red: #c23a1d;
  --red-ink: #8f2a13;
  --red-soft: #fbeae6;
  --orange: #a05a06;
  --orange-ink: #7a4405;
  --orange-soft: #fbf2e2;

  --radius: 5px;
  --maxw: 940px;
  --pad-x: clamp(16px, 4vw, 40px);

  --font: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1418;
    --surface: #151d23;
    --surface-2: #1c262e;
    --surface-3: #24313a;
    --border: #2b3841;
    --border-strong: #465865;
    --text: #e6edf3;
    --text-2: #a8b6c2;
    --text-3: #8695a2;

    --cyan: #6ba6ff;
    --cyan-ink: #a8ccff;
    --cyan-soft: #16283d;
    --green: #5cc98b;
    --green-ink: #9be0b8;
    --green-soft: #14291d;
    --red: #ff8f75;
    --red-ink: #ffb4a1;
    --red-soft: #2e1811;
    --orange: #e0a350;
    --orange-ink: #f0c88c;
    --orange-soft: #2b2010;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1418;
  --surface: #151d23;
  --surface-2: #1c262e;
  --surface-3: #24313a;
  --border: #2b3841;
  --border-strong: #465865;
  --text: #e6edf3;
  --text-2: #a8b6c2;
  --text-3: #8695a2;
  --cyan: #6ba6ff;
  --cyan-ink: #a8ccff;
  --cyan-soft: #16283d;
  --green: #5cc98b;
  --green-ink: #9be0b8;
  --green-soft: #14291d;
  --red: #ff8f75;
  --red-ink: #ffb4a1;
  --red-soft: #2e1811;
  --orange: #e0a350;
  --orange-ink: #f0c88c;
  --orange-soft: #2b2010;
}

/* --------------------------------------------------------------------------
   Grundlagen
   -------------------------------------------------------------------------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.62;
}

main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad-x) 96px; }

h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -0.01em; font-weight: 700; }
h1 { font-size: clamp(1.5rem, 4vw, 2.05rem); margin: 0; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); margin: 0 0 0.6em; }
h3 { font-size: 1.08rem; margin: 1.8em 0 0.5em; }

p { margin: 0 0 1em; }
a { color: var(--cyan); text-decoration-thickness: 1px; text-underline-offset: 2px; }

code, pre, .mono { font-family: var(--mono); font-size: 0.9em; }

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.08em 0.32em;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1em;
}
pre code { background: none; border: 0; padding: 0; font-size: 0.86em; }

/* Breite Inhalte scrollen in sich, der Body niemals horizontal. */
.tbl-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.tbl { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
.tbl th, .tbl td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.tbl th { background: var(--surface-2); font-family: var(--mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--text-3);
  margin: 0 0 0.3em;
}

.hint { font-weight: 400; color: var(--text-3); font-size: 0.9em; }

/* --------------------------------------------------------------------------
   Schriftfeld (DIN-Titleblock) - Sektion 1
   -------------------------------------------------------------------------- */

.sf {
  border: 2px solid var(--text);
  border-radius: 2px;
  background: var(--surface);
  margin: 40px 0 44px;
}

.sf__title { padding: 18px 20px 14px; border-bottom: 2px solid var(--text); }

.sf__nr {
  display: block;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  color: var(--text-3);
  margin-bottom: 4px;
}

.sf__grid { display: grid; grid-template-columns: repeat(4, 1fr); }

.sf__cell {
  padding: 8px 12px;
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
  min-width: 0;
}
.sf__cell:nth-child(4n) { border-right: 0; }
.sf__cell:nth-child(-n + 4) { border-top: 0; }

.sf__k {
  display: block;
  font-family: var(--mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
}
.sf__v {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .sf__grid { grid-template-columns: repeat(2, 1fr); }
  .sf__cell:nth-child(2n) { border-right: 0; }
  .sf__cell:nth-child(-n + 2) { border-top: 0; }
  .sf__cell:nth-child(3), .sf__cell:nth-child(4) { border-top: 1px solid var(--border); }
}

/* --------------------------------------------------------------------------
   Bloecke
   -------------------------------------------------------------------------- */

.block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px var(--pad-x) 24px;
  margin: 0 0 30px;
}

.block--frage { border-left: 3px solid var(--cyan); }
.block--schloss { border-left: 3px solid var(--orange); }

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.74rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  margin-right: 5px;
}
.chip--leer { color: var(--text-3); }

.aufbau__artefakt {
  border-left: 2px solid var(--border-strong);
  padding-left: 12px;
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   Callouts
   -------------------------------------------------------------------------- */

.keybox, .trapbox, .res, .beispiel, .check {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 4px;
  margin: 0 0 1.2em;
}
.keybox { background: var(--cyan-soft); border-color: var(--cyan); }
.trapbox { background: var(--orange-soft); border-color: var(--orange); }
.res { background: var(--green-soft); border-color: var(--green); }
.beispiel { background: var(--surface-2); }
.check { background: var(--surface-2); border-color: var(--border-strong); border-style: dashed; }

.keybox__label, .trapbox__label, .res__label, .beispiel__label, .check__label {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  margin: 0 0 0.5em;
  font-weight: 700;
}
.keybox__label { color: var(--cyan-ink); }
.trapbox__label { color: var(--orange-ink); }
.res__label { color: var(--green); }

/* --------------------------------------------------------------------------
   AI-Zonen-Badge
   -------------------------------------------------------------------------- */

.zone {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 1.1em;
  background: var(--surface-2);
}
.zone__badge {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.zone__regel { color: var(--text-3); font-size: 0.94rem; }

.zone--hand { border-color: var(--red); background: var(--red-soft); }
.zone--hand .zone__badge { color: var(--red-ink); }
.zone--lesen { border-color: var(--orange); background: var(--orange-soft); }
.zone--lesen .zone__badge { color: var(--orange-ink); }
.zone--spez { border-color: var(--cyan); background: var(--cyan-soft); }
.zone--spez .zone__badge { color: var(--cyan-ink); }
.zone--delegieren { border-color: var(--green); background: var(--green-soft); }
.zone--delegieren .zone__badge { color: var(--green); }

/* --------------------------------------------------------------------------
   Editor + Drill
   -------------------------------------------------------------------------- */

.editor {
  width: 100%;
  min-height: 220px;
  font-family: var(--mono);
  /* 16px Minimum: darunter zoomt iOS Safari beim Fokus automatisch, und danach
     laesst sich die Seite seitlich schieben. Genau der Bug aus first-app D14. */
  font-size: 16px;
  line-height: 1.5;
  tab-size: 4;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
}
.editor:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }

.drill__leiste { display: flex; align-items: center; gap: 14px; margin: 12px 0; flex-wrap: wrap; }
.drill__status { font-family: var(--mono); font-size: 0.82rem; color: var(--text-3); }

.ausgabe {
  min-height: 2.6em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0 0 1em;
}
.ausgabe:empty { display: none; }

.btn {
  font: inherit;
  font-size: 0.94rem;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--stark { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.btn--stark:hover { opacity: 0.88; background: var(--text); }
.btn--leise { font-size: 0.85rem; padding: 5px 11px; color: var(--text-3); }

/* Faelle */
.faelle { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: 7px; }
.fall {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.92rem;
}
.fall--ok { border-left-color: var(--green); background: var(--green-soft); }
.fall--weh { border-left-color: var(--red); background: var(--red-soft); }
.fall__marke { font-family: var(--mono); font-weight: 700; }
.fall--ok .fall__marke { color: var(--green); }
.fall--weh .fall__marke { color: var(--red-ink); }
.fall__name { font-family: var(--mono); }
.fall__diff { grid-column: 2; font-family: var(--mono); font-size: 0.82rem; color: var(--text-3); white-space: pre-wrap; }

.gate-hinweis {
  font-size: 0.88rem;
  color: var(--text-3);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin: 14px 0 0;
}

/* Hinweis-Leiter */
.hinweise { margin-top: 14px; }
.hinweise__liste { margin: 10px 0 0; padding-left: 22px; font-size: 0.94rem; }
.hinweise__liste .hinweis { margin-bottom: 6px; }
.hinweise__warnung { font-size: 0.82rem; color: var(--text-3); margin: 8px 0 0; }

/* Traces */
.traces { list-style: none; padding: 0; margin: 0 0 1.2em; display: grid; gap: 12px; }
.trace { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.trace pre { margin: 0 0 8px; }
.trace__frage { display: block; font-size: 0.9rem; color: var(--text-3); }
.trace__eingabe, .schloss__text, .repo__text, .lesen__eingabe,
.erklaeren__text, .delta__text, .ab__adr, .ab__artefakt, .ab__intention {
  display: block;
  width: 100%;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 16px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
}
.trace__urteil { font-family: var(--mono); font-size: 0.84rem; margin: 6px 0 0; min-height: 1.2em; }
.trace__urteil--ok { color: var(--green); }
.trace__urteil--weh { color: var(--red-ink); }

/* Lesen & urteilen */
.lesen-liste { list-style: none; padding: 0; margin: 0; display: grid; gap: 20px; }
.lesen { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.lesen__nr { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; color: var(--text-3); margin: 0 0 8px; }
.lesen__frage { display: block; font-size: 0.92rem; margin: 10px 0; }
.lesen__aufloesung { margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }

/* Schloss */
.schloss { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: 8px; }
.schloss__fall { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; border-bottom: 1px dotted var(--border); padding-bottom: 7px; }
.schloss__wahl { display: flex; gap: 14px; font-size: 0.88rem; }
.schloss__wahl label { display: flex; align-items: center; gap: 5px; }
.schloss__warum { display: block; font-size: 0.92rem; margin: 0 0 1em; }
.schloss__notiz { font-size: 0.86rem; color: var(--text-3); }

/* Kalibrierung */
.kal {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin: 0 0 18px;
  background: var(--surface-2);
  font-size: 0.92rem;
}
.kal label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kal__zahl {
  width: 5.5em;
  font-family: var(--mono);
  font-size: 16px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
}

/* Meisterpruefung */
.erklaeren { display: block; margin: 0 0 1em; }
.erklaeren__zaehler { font-family: var(--mono); font-size: 0.8rem; color: var(--text-3); }
.erklaeren__zaehler--zuviel { color: var(--red-ink); font-weight: 700; }
.delta__antwort, .repo__ausgabe { display: block; font-size: 0.92rem; margin: 1em 0; }

section[data-sektion] > label { display: block; margin: 0 0 1em; font-size: 0.94rem; }
.ab__notiz { font-size: 0.88rem; color: var(--text-3); border-top: 1px dashed var(--border); padding-top: 12px; }

/* --------------------------------------------------------------------------
   Ladeanzeige - 5,94 MiB sehen ohne Fortschritt wie "kaputt" aus
   -------------------------------------------------------------------------- */

.laden { font-family: var(--mono); font-size: 0.84rem; color: var(--text-3); }
.laden__balken {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
  max-width: 340px;
}
.laden__fuellung { height: 100%; width: 0%; background: var(--cyan); transition: width 0.2s linear; }

.banner {
  border: 1px solid var(--orange);
  background: var(--orange-soft);
  color: var(--orange-ink);
  border-radius: var(--radius);
  padding: 10px 13px;
  margin: 0 0 1em;
  font-size: 0.92rem;
}

/* --------------------------------------------------------------------------
   Kopf / Fuss / Index
   -------------------------------------------------------------------------- */

.top {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 9px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.top__marke { font-family: var(--mono); font-weight: 700; letter-spacing: 0.04em; text-decoration: none; color: var(--text); }

footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px var(--pad-x) 60px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.84rem;
}

.idx { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.idx__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.idx__link { display: flex; gap: 12px; align-items: baseline; text-decoration: none; color: var(--text); font-weight: 600; }
.idx__link:hover .idx__titel { text-decoration: underline; }
.idx__nr { font-family: var(--mono); color: var(--text-3); font-size: 0.85rem; }
.idx__meta { grid-column: 1; font-size: 0.86rem; color: var(--text-3); }
.idx__zonen { grid-column: 2; grid-row: 1 / span 2; font-family: var(--mono); font-size: 0.72rem; color: var(--text-3); text-align: right; align-self: center; }

@media (max-width: 560px) {
  .idx__row { grid-template-columns: 1fr; }
  .idx__zonen { grid-column: 1; grid-row: auto; text-align: left; }
}

/* --------------------------------------------------------------------------
   Notausschalter + Druck
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media print {
  .top { position: static; }
  .btn, .hinweise, .editor { display: none; }
  .block, .sf { break-inside: avoid; border-color: #999; }
  body { background: #fff; color: #000; font-size: 11pt; }
}
