/* ==========================================================================
   Lernseite Wirtschaftsinformatik - zentrales Stylesheet
   Aufbau: 1 Farben/Basis  2 Layout  3 Navigation  4 Textbausteine
           5 Lernbausteine  6 Interaktive Module  7 Hilfsklassen  8 Druck
   ========================================================================== */

/* --- 1 Farben und Basis --------------------------------------------------- */

:root {
  --bg:            #f6f7f9;
  --bg-elevated:   #ffffff;
  --bg-sunken:     #eceef2;
  --text:          #1a1d23;
  --text-muted:    #5b6472;
  --border:        #d8dce3;
  --border-strong: #b9c0cb;

  --accent:        #0a6ed1;
  --accent-hover:  #0857a6;
  --accent-soft:   #e4effb;
  --accent-text:   #ffffff;

  --ok:            #157f4b;
  --ok-soft:       #e2f4ea;
  --warn:          #9a6300;
  --warn-soft:     #fdf1dc;
  --bad:           #b3261e;
  --bad-soft:      #fbe6e5;
  --info:          #1b6b7a;
  --info-soft:     #e0f2f5;

  --code-bg:       #f0f2f5;
  --code-text:     #23272e;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg:     0 4px 8px rgba(16, 24, 40, .07), 0 16px 32px rgba(16, 24, 40, .09);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 1120px;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #14171c;
    --bg-elevated:   #1c2027;
    --bg-sunken:     #0f1216;
    --text:          #e6e9ef;
    --text-muted:    #a0a9b8;
    --border:        #2c323c;
    --border-strong: #414a58;

    --accent:        #63a9f0;
    --accent-hover:  #8cc2f7;
    --accent-soft:   #16283d;
    --accent-text:   #0b1220;

    --ok:            #63c795;
    --ok-soft:       #122b1f;
    --warn:          #e0ac4e;
    --warn-soft:     #2e2413;
    --bad:           #f2867e;
    --bad-soft:      #331a1a;
    --info:          #6ec6d6;
    --info-soft:     #10282e;

    --code-bg:       #11151a;
    --code-text:     #dee3ea;

    --shadow:        0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
    --shadow-lg:     0 4px 8px rgba(0, 0, 0, .45), 0 16px 32px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --bg:            #14171c;
  --bg-elevated:   #1c2027;
  --bg-sunken:     #0f1216;
  --text:          #e6e9ef;
  --text-muted:    #a0a9b8;
  --border:        #2c323c;
  --border-strong: #414a58;

  --accent:        #63a9f0;
  --accent-hover:  #8cc2f7;
  --accent-soft:   #16283d;
  --accent-text:   #0b1220;

  --ok:            #63c795;
  --ok-soft:       #122b1f;
  --warn:          #e0ac4e;
  --warn-soft:     #2e2413;
  --bad:           #f2867e;
  --bad-soft:      #331a1a;
  --info:          #6ec6d6;
  --info-soft:     #10282e;

  --code-bg:       #11151a;
  --code-text:     #dee3ea;

  --shadow:        0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg:     0 4px 8px rgba(0, 0, 0, .45), 0 16px 32px rgba(0, 0, 0, .4);
}

*, *::before, *::after { box-sizing: border-box; }

/* Muss die display-Regeln der Komponenten schlagen, sonst bleiben
   mit [hidden] versteckte Knöpfe sichtbar. */
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { max-width: 100%; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: .6rem 1rem;
  z-index: 200;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* --- 2 Layout ------------------------------------------------------------- */

.wrap {
  width: min(100% - 2.5rem, var(--wrap));
  margin-inline: auto;
}

main { padding-block: 2.5rem 4rem; }

.layout {
  display: grid;
  gap: 2.5rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1040px) {
  .layout.has-toc { grid-template-columns: minmax(0, 1fr) 250px; }
  .layout.has-toc > .toc { order: 2; }
}

.prose { max-width: var(--measure); }
.prose.wide { max-width: none; }

section.block {
  margin-block: 3rem;
  scroll-margin-top: 5rem;
}
section.block:first-of-type { margin-top: 1.5rem; }

/* --- 3 Kopfzeile und Navigation ------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand .mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: -.02em;
}
.brand small {
  display: block;
  font-weight: 500;
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.nav { margin-left: auto; }
.nav ul {
  display: flex;
  align-items: center;
  gap: .15rem;
  list-style: none;
  margin: 0; padding: 0;
}
.nav a {
  display: block;
  padding: .4rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { background: var(--bg-sunken); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

#menu-toggle { display: none; }

@media (max-width: 900px) {
  #menu-toggle { display: grid; }
  .nav {
    display: none;
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: .5rem 0 .9rem;
  }
  .nav.open { display: block; }
  .nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: min(100% - 2.5rem, var(--wrap));
    margin-inline: auto;
  }
  .nav a { padding: .65rem .7rem; font-size: .95rem; }
}

/* --- Kontobereich in der Kopfzeile ---------------------------------------- */

.konto-bereich { flex: none; }
.konto-chip { position: relative; }

.konto-name {
  display: flex;
  align-items: center;
  gap: .45rem;
  max-width: 150px;
  padding: .35rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.konto-name:hover { border-color: var(--border-strong); }
.konto-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.konto-punkt {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.konto-punkt.warn { background: var(--warn); }

.konto-menue {
  position: absolute;
  right: 0;
  top: calc(100% + .4rem);
  min-width: 210px;
  padding: .4rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 120;
}
.konto-menue a,
.konto-menue button {
  display: block;
  width: 100%;
  text-align: left;
  padding: .5rem .6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  text-decoration: none;
  cursor: pointer;
}
.konto-menue a:hover,
.konto-menue button:hover { background: var(--bg-sunken); }

@media (max-width: 900px) {
  .konto-name { max-width: 110px; }
}

/* --- Formulare für Anmeldung und Registrierung ---------------------------- */

.auth-form {
  display: grid;
  gap: 1rem;
  max-width: 26rem;
  margin-bottom: 2rem;
}
.auth-form label {
  display: grid;
  gap: .3rem;
  font-size: .92rem;
  font-weight: 600;
}
.auth-form input {
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
}
.auth-form input:invalid:not(:placeholder-shown) { border-color: var(--bad); }
.auth-form .notice { margin-bottom: 0; }
.notice.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

/* --- Inhaltsverzeichnis --------------------------------------------------- */

.toc { font-size: .88rem; }
.toc-inner {
  position: sticky;
  top: 5rem;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}
.toc h2 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  margin: 0 0 .7rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: .1rem; }
.toc a {
  display: block;
  padding: .25rem .4rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
}
.toc a:hover { background: var(--bg-sunken); color: var(--text); }
.toc a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

@media (max-width: 1039px) { .toc { display: none; } }

/* --- 4 Textbausteine ------------------------------------------------------ */

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.015em;
  margin: 0 0 .6rem;
  text-wrap: balance;
}
h1 { font-size: clamp(1.85rem, 1.2rem + 2vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 1.1rem + 1.1vw, 1.75rem); margin-top: 2.5rem; }
h3 { font-size: 1.17rem; margin-top: 1.9rem; }
h4 { font-size: 1rem; margin-top: 1.4rem; }

p, ul, ol { margin: 0 0 1.05rem; }
li { margin-bottom: .35rem; }
li > ul, li > ol { margin-top: .35rem; }

.lead {
  font-size: 1.12rem;
  color: var(--text-muted);
  max-width: var(--measure);
}

strong { font-weight: 650; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .35em;
  overflow-wrap: break-word;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: .875rem;
  line-height: 1.6;
  margin: 0 0 1.05rem;
}
pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.code-figure { margin: 0 0 1.2rem; }
.code-figure figcaption {
  font-size: .8rem;
  color: var(--text-muted);
  padding: .4rem .2rem;
  font-family: var(--mono);
}

/* Tabellen */
.table-scroll { overflow-x: auto; margin-bottom: 1.2rem; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: .93rem;
}
th, td {
  text-align: left;
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-weight: 650;
  background: var(--bg-sunken);
  white-space: nowrap;
}
tbody tr:hover { background: var(--bg-sunken); }

/* Merkkaesten */
.box {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 1rem 1.15rem;
  margin: 1.4rem 0;
}
.box > :last-child { margin-bottom: 0; }
.box .box-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 650;
  font-size: .93rem;
  margin-bottom: .45rem;
}
.box.merke     { border-left-color: var(--accent); background: var(--accent-soft); }
.box.analogie  { border-left-color: var(--info);   background: var(--info-soft); }
.box.tipp      { border-left-color: var(--ok);     background: var(--ok-soft); }
.box.achtung   { border-left-color: var(--warn);   background: var(--warn-soft); }
.box.sap       { border-left-color: var(--accent); background: var(--bg-elevated); }

/* Aufklappbare Musterloesungen */
details.solution {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  margin: .8rem 0 1.4rem;
  overflow: hidden;
}
details.solution > summary {
  cursor: pointer;
  padding: .65rem 1rem;
  font-weight: 600;
  font-size: .92rem;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
details.solution > summary::-webkit-details-marker { display: none; }
details.solution > summary::before {
  content: "▸";
  font-size: .8em;
  transition: transform .15s ease;
}
details.solution[open] > summary::before { transform: rotate(90deg); }
details.solution > summary:hover { background: var(--bg-sunken); }
details.solution .solution-body {
  padding: .2rem 1rem 1rem;
  border-top: 1px solid var(--border);
}
details.solution .solution-body > :first-child { margin-top: .9rem; }
details.solution .solution-body > :last-child { margin-bottom: 0; }

/* --- 5 Lernbausteine ------------------------------------------------------ */

.hero {
  padding: 2.5rem 0 1rem;
}
.hero .eyebrow {
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}

.card-grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  margin-bottom: 1.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
a.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.card h3 { margin: .5rem 0 .4rem; font-size: 1.08rem; }
.card p { color: var(--text-muted); font-size: .92rem; margin-bottom: .9rem; }
.card .card-foot { margin-top: auto; }
.card .num {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: .9rem;
}

.tag-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.tag {
  display: inline-block;
  font-size: .74rem;
  font-weight: 600;
  padding: .17rem .5rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.tag.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.tag.bad    { background: var(--bad-soft);    color: var(--bad);    border-color: transparent; }

/* Fortschritt */
.progress {
  height: 8px;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}
.progress.done > span { background: var(--ok); }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .35rem;
}

.progress-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

/* Lernziele / Checklisten */
ul.goals { list-style: none; padding: 0; }
ul.goals li {
  position: relative;
  padding-left: 1.7rem;
  margin-bottom: .5rem;
}
ul.goals li::before {
  content: "";
  position: absolute;
  left: 0; top: .5em;
  width: 15px; height: 15px;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
}

.checklist { list-style: none; padding: 0; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .5rem .1rem;
  border-bottom: 1px solid var(--border);
}
.checklist input[type="checkbox"] {
  margin-top: .35rem;
  width: 17px; height: 17px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}
.checklist li.checked > label { color: var(--text-muted); text-decoration: line-through; }
.checklist label { cursor: pointer; }

/* Lektionskopf mit "erledigt"-Knopf */
.lesson-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.lesson-head h2, .lesson-head h3 { margin-top: 0; }
.lesson-head > .btn { margin-top: .2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .5rem .95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn.small { padding: .3rem .7rem; font-size: .82rem; }
.btn.done  { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.2rem; }

/* --- 6 Interaktive Module ------------------------------------------------- */

.widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 1.6rem 0 2rem;
  overflow: hidden;
}
.widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.widget-head h3, .widget-head h2 {
  margin: 0;
  font-size: .96rem;
  font-weight: 650;
}
.widget-body { padding: 1.1rem; }
.widget-foot {
  padding: .8rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: .88rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.controls label { font-size: .85rem; color: var(--text-muted); }
select, input[type="text"], input[type="number"], input[type="search"] {
  font: inherit;
  font-size: .9rem;
  padding: .4rem .6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
}
input[type="range"] { accent-color: var(--accent); }

/* Quiz */
.quiz-question { margin-bottom: 1.2rem; }
.quiz-question .q-text { font-weight: 600; margin-bottom: .8rem; }
.quiz-meta {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.quiz-options { list-style: none; margin: 0 0 1rem; padding: 0; }
.quiz-options li { margin-bottom: .5rem; }
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  width: 100%;
  text-align: left;
  padding: .7rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: .94rem;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.quiz-option:disabled { cursor: default; }
.quiz-option .marker {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px; height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
}
.quiz-option.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.quiz-option.correct .marker { background: var(--ok); border-color: var(--ok); color: var(--bg-elevated); }
.quiz-option.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.quiz-option.wrong .marker { background: var(--bad); border-color: var(--bad); color: var(--bg-elevated); }

.quiz-feedback {
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  font-size: .92rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}
.quiz-feedback.right { background: var(--ok-soft);  border-color: var(--ok); }
.quiz-feedback.false { background: var(--bad-soft); border-color: var(--bad); }
.quiz-feedback > :last-child { margin-bottom: 0; }
.quiz-feedback strong { display: block; margin-bottom: .2rem; }

.quiz-gap { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quiz-gap input { flex: 1 1 200px; }

.quiz-result { text-align: center; padding: 1rem 0; }
.quiz-score {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
}
.quiz-result .verdict { color: var(--text-muted); margin-bottom: 1.2rem; }

/* Karteikarten */
.flashcard {
  perspective: 1200px;
  margin-bottom: 1rem;
}
.flashcard-inner {
  position: relative;
  min-height: 220px;
  transition: transform .5s;
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-y: auto;
}
.flashcard-face.back {
  transform: rotateY(180deg);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.flashcard-face .face-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  font-weight: 650;
}
.flashcard-face .face-text { font-size: 1.08rem; line-height: 1.5; }
.flashcard-face.front .face-text { font-weight: 600; }
.flashcard-hint { font-size: .8rem; color: var(--text-muted); }

.leitner-boxes {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  font-size: .78rem;
}
.leitner-boxes .lb {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .25rem .55rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.leitner-boxes .lb b { color: var(--text); }

/* Code-Spielwiese */
.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
}
@media (min-width: 860px) {
  .editor-shell.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.editor-pane, .output-pane {
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pane-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 650;
  color: var(--text-muted);
  padding: .5rem .8rem;
  border-bottom: 1px solid var(--border);
}
.code-editor {
  display: flex;
  background: var(--code-bg);
  min-height: 210px;
}
.gutter {
  flex: none;
  padding: .8rem .5rem .8rem .8rem;
  text-align: right;
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.6;
  color: var(--text-muted);
  user-select: none;
  border-right: 1px solid var(--border);
  white-space: pre;
}
.code-editor textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: vertical;
  min-height: 210px;
  padding: .8rem;
  background: transparent;
  color: var(--code-text);
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.console-out {
  margin: 0;
  padding: .8rem;
  min-height: 120px;
  max-height: 340px;
  overflow: auto;
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.55;
  background: var(--code-bg);
  color: var(--code-text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.console-out .l-error { color: var(--bad); }
.console-out .l-warn  { color: var(--warn); }
.console-out .l-info  { color: var(--info); }
.console-out .l-ok    { color: var(--ok); }
.console-out .l-dim   { color: var(--text-muted); }

.test-results { list-style: none; margin: .8rem 0 0; padding: 0; font-size: .9rem; }
.test-results li {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  padding: .35rem 0;
}
.test-results .t-pass { color: var(--ok); font-weight: 700; }
.test-results .t-fail { color: var(--bad); font-weight: 700; }

/* SQL-Konsole */
.sql-schema {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  font-size: .82rem;
  margin-bottom: 1rem;
}
.sql-table-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  background: var(--bg-sunken);
  min-width: 140px;
}
.sql-table-card b { display: block; margin-bottom: .2rem; font-family: var(--mono); }
.sql-table-card span { color: var(--text-muted); font-family: var(--mono); font-size: .76rem; display: block; }

.result-wrap { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.result-wrap table { font-family: var(--mono); font-size: .82rem; }
.result-wrap th { position: sticky; top: 0; z-index: 1; }
.status-line { font-size: .85rem; margin-top: .7rem; }
.status-line.ok  { color: var(--ok); }
.status-line.err { color: var(--bad); font-family: var(--mono); }

/* Visualisierungen */
.viz-stage {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 210px;
}
.bars .bar {
  flex: 1;
  min-width: 6px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height .12s ease, background .12s ease;
  position: relative;
}
.bars .bar.cmp    { background: var(--warn); }
.bars .bar.swap   { background: var(--bad); }
.bars .bar.sorted { background: var(--ok); }
.bars .bar.pivot  { background: var(--info); }

.viz-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .8rem;
}
.viz-stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.bit-row { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.bit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
}
.bit button {
  width: 42px; height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.bit button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.bit .weight { font-size: .68rem; color: var(--text-muted); font-family: var(--mono); }

.value-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  font-family: var(--mono);
  font-size: .92rem;
}
.value-readout div span { color: var(--text-muted); font-size: .76rem; display: block; }

.ds-view {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  min-height: 56px;
  align-items: center;
}
.ds-item {
  padding: .45rem .8rem;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: .88rem;
  font-weight: 600;
  animation: pop .2s ease;
}
.ds-item.head { outline: 2px solid var(--ok); outline-offset: 2px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ds-empty { color: var(--text-muted); font-size: .88rem; font-style: italic; }

.bucket-grid { display: grid; gap: .4rem; }
.bucket {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: .82rem;
}
.bucket .idx {
  flex: none;
  width: 34px;
  text-align: right;
  color: var(--text-muted);
}
.bucket .slots { display: flex; gap: .3rem; flex-wrap: wrap; }
.bucket .slot {
  padding: .2rem .5rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.bucket .slot.collision { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

/* Netzwerk-Visualisierung */
.net-track {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: 2.6rem 0 .5rem;
}
.net-node {
  flex: 1;
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}
.net-node .dot {
  width: 40px; height: 40px;
  margin: 0 auto .4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  font-size: 1.1rem;
}
.net-node.active .dot { border-color: var(--accent); background: var(--accent-soft); }
.net-node.active { color: var(--accent); font-weight: 650; }
.net-line {
  position: absolute;
  left: 6%; right: 6%;
  top: calc(2.6rem + 20px);
  height: 2px;
  background: var(--border);
}
.packet {
  position: absolute;
  top: calc(2.6rem + 4px);
  width: 32px;
  text-align: center;
  font-size: 1.1rem;
  transition: left .6s ease;
  z-index: 2;
}

.layer-stack { display: grid; gap: .35rem; }
.layer {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .6rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: .88rem;
  opacity: .45;
  transition: opacity .3s ease, border-color .3s ease;
}
.layer.on { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.layer .layer-no {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--bg-sunken);
  font-weight: 700;
  font-size: .8rem;
}
.layer b { display: block; }
.layer small { color: var(--text-muted); }

/* Normalisierung */
.nf-stage { display: grid; gap: 1rem; }
.nf-tables { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.nf-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.nf-table > h4 {
  margin: 0;
  padding: .45rem .7rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .85rem;
  font-family: var(--mono);
}
.nf-table table { font-size: .8rem; }
.nf-table td.dup { background: var(--warn-soft); color: var(--warn); }
.nf-table th.key { color: var(--accent); }

/* Glossar */
.glossary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 4.2rem;
  z-index: 20;
  background: var(--bg);
  padding: .6rem 0;
}
.glossary-controls input[type="search"] { flex: 1 1 260px; }
.glossary-list { display: grid; gap: .7rem; }
.glossary-entry {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: .8rem 1rem;
}
.glossary-entry h3 {
  margin: 0 0 .25rem;
  font-size: 1rem;
}
.glossary-entry p { margin: 0; font-size: .93rem; color: var(--text-muted); }
.glossary-entry .tag { margin-top: .5rem; }
.glossary-empty { color: var(--text-muted); padding: 2rem 0; text-align: center; }

/* Lernplan */
.phase {
  position: relative;
  padding-left: 2.6rem;
  padding-bottom: 2rem;
  border-left: 2px solid var(--border);
  margin-left: .9rem;
}
.phase:last-child { border-left-color: transparent; padding-bottom: 0; }
.phase > .phase-no {
  position: absolute;
  left: -1.1rem; top: 0;
  width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: .9rem;
  border: 3px solid var(--bg);
}
.phase h3 { margin-top: .1rem; }

/* Statusmeldungen */
.notice {
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-muted);
}
.notice.err { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 7 Hilfsklassen ------------------------------------------------------- */

.muted { color: var(--text-muted); }
.small { font-size: .87rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.two-col { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Fusszeile */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 2rem 0;
  font-size: .87rem;
  color: var(--text-muted);
}
.site-footer .foot-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.site-footer h4 { margin: 0 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text); }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: .3rem; }
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

/* --- 8 Druck -------------------------------------------------------------- */

@media print {
  .site-header, .toc, .site-footer, .btn, .controls, .widget-foot { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  details.solution[open] > summary { color: #000; }
  details.solution { break-inside: avoid; }
  a { color: #000; }
}
