/* Mathe bewegt: kariertes Heft, Füllertinte, Textmarker */
@font-face { font-family: "Bricolage"; src: url(../fonts/bricolage.woff2) format("woff2"); font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: "Stix"; src: url(../fonts/stix-latin-400-normal.woff2) format("woff2"); font-style: normal; unicode-range: U+0000-00FF, U+2212; font-display: swap; }
@font-face { font-family: "Stix"; src: url(../fonts/stix-latin-400-italic.woff2) format("woff2"); font-style: italic; unicode-range: U+0000-00FF, U+2212; font-display: swap; }
@font-face { font-family: "Stix"; src: url(../fonts/stix-greek-400-normal.woff2) format("woff2"); font-style: normal; unicode-range: U+0370-03FF; font-display: swap; }
@font-face { font-family: "Stix"; src: url(../fonts/stix-greek-400-italic.woff2) format("woff2"); font-style: italic; unicode-range: U+0370-03FF; font-display: swap; }

:root {
  --papier: #f5f8fd;
  --blatt: #ffffff;
  --karo: #d7e3f3;
  --tinte: #1a2bb8;
  --tinte-hell: #dfe3ff;
  --graphit: #1c2030;
  --bleistift: #5c6478;
  --gelb: #ffe44d;
  --gelb-text: #1c2030;
  --pink: #e8176e;
  --pink-hell: #ffd3e4;
  --tuerkis: #008f7d;
  --tuerkis-flaeche: #17c8b0;
  --tuerkis-hell: #c6f4ec;
  --gut: #00705f;
  --schlecht: #b80f55;
  --thema: var(--tinte);
  --schatten: var(--tinte);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #10143a; --blatt: #171c4a; --karo: #262c63; --tinte: #a9b4ff; --tinte-hell: #2b3280;
    --graphit: #f1f3ff; --bleistift: #a9b0d0; --gelb: #ffe44d; --gelb-text: #1c2030;
    --pink: #ff5c9f; --pink-hell: #5c1b45; --tuerkis: #3ee0c8; --tuerkis-flaeche: #1aa897; --tuerkis-hell: #124f55;
    --gut: #3ee0c8; --schlecht: #ff7fb4; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papier: #10143a; --blatt: #171c4a; --karo: #262c63; --tinte: #a9b4ff; --tinte-hell: #2b3280;
  --graphit: #f1f3ff; --bleistift: #a9b0d0; --gelb: #ffe44d; --gelb-text: #1c2030;
  --pink: #ff5c9f; --pink-hell: #5c1b45; --tuerkis: #3ee0c8; --tuerkis-flaeche: #1aa897; --tuerkis-hell: #124f55;
  --gut: #3ee0c8; --schlecht: #ff7fb4; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--graphit); font-family: "Bricolage", system-ui, sans-serif; font-size: 17px; line-height: 1.45;
  background-color: var(--papier);
  background-image: linear-gradient(var(--karo) 1px, transparent 1px), linear-gradient(90deg, var(--karo) 1px, transparent 1px);
  background-size: 24px 24px;
}
a { color: var(--tinte); }
.m { font-family: "Stix", serif; font-style: italic; font-size: 1.1em; }
button, input, select { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 2px solid var(--graphit); background: var(--blatt); border-radius: 6px; padding: .42em .9em; font-weight: 650;
  transition: transform .08s ease, background-color .12s ease;
}
button:hover { background: var(--tinte-hell); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.primaer { background: var(--tinte); color: var(--blatt); border-color: var(--tinte); }
.primaer:hover { background: var(--tinte); filter: brightness(1.15); }
.k-neu { background: var(--gelb); color: var(--gelb-text); border-color: var(--gelb-text); }
.k-neu:hover { background: var(--gelb); filter: brightness(.96); }
.k-neu.primaer { box-shadow: 0 0 0 3px var(--tinte); }
.k-loesung { background: var(--blatt); border-color: var(--pink); color: var(--pink); }
.k-loesung:hover { background: var(--pink-hell); }
.t-geometrie { --thema: var(--tuerkis); --schatten: var(--tuerkis-flaeche); }
.t-algebra { --thema: var(--pink); --schatten: var(--pink); }
.t-zahlen { --thema: var(--tinte); --schatten: var(--gelb); }

/* ---------- Kopf der Startseite ---------- */
.kopf { max-width: 1240px; margin: 0 auto; padding: 44px 24px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 56px; align-items: end; }
.wortmarke {
  position: relative; margin: 0; font-size: clamp(3.4rem, 10.5vw, 7.4rem); line-height: .86; font-weight: 800; letter-spacing: -.012em;
  color: var(--tinte); font-stretch: 82%; padding-bottom: .2em; padding-right: 1.02em; white-space: nowrap;
}
.wortmarke span { display: inline-block; }
.wortmarke span + span { transform: translateY(.02em); }
.strich { position: absolute; left: 0; bottom: .07em; height: .055em; width: 100%; background: var(--pink); transform-origin: left; border-radius: 2px; animation: ziehen 1.1s .35s cubic-bezier(.65,0,.35,1) both; }
.geo { position: absolute; width: .98em; bottom: .125em; left: 0; animation: lineal 1.5s .1s cubic-bezier(.65,0,.35,1) both; pointer-events: none; }
.geo-koerper { fill: var(--gelb); fill-opacity: .6; stroke: var(--graphit); stroke-width: 3; stroke-linejoin: round; }
.geo-loch { fill: var(--papier); stroke: var(--graphit); stroke-width: 2.5; stroke-linejoin: round; }
.geo-skala path { stroke: var(--graphit); stroke-width: 2; }
@keyframes ziehen { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes lineal { from { left: -8%; opacity: 0; } 12% { opacity: 1; } to { left: calc(100% - .98em); } }
.vorspann { margin: 0 0 .5em; max-width: 34em; font-size: 1.14rem; background: var(--papier); padding: .2em .1em; }

.filter { max-width: 1240px; margin: 0 auto; padding: 10px 24px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter button { border-color: var(--graphit); }
.filter button.aktiv { background: var(--graphit); color: var(--papier); }
.klasse-knopf { margin-left: auto; border-style: dashed !important; }

/* ---------- Wand mit Tafeln ---------- */
.wand { max-width: 1240px; margin: 0 auto; padding: 8px 24px 40px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 26px 22px; }
.tafel { grid-column: span 6; background: var(--blatt); border: 2px solid var(--graphit); border-radius: 4px; box-shadow: 7px 7px 0 var(--schatten); display: flex; flex-direction: column; min-width: 0; }
.tafel-parallelen { grid-column: span 7; }
.tafel-waage { grid-column: span 5; }
.tafel-kreis { grid-column: span 5; }
.tafel-abbildung { grid-column: span 7; }
.wand.gefiltert .tafel { grid-column: span 6; }
.tafel header { padding: 12px 16px 2px; display: flex; gap: 12px; align-items: baseline; justify-content: space-between; }
.tafel h2 { margin: 0; font-size: 1.42rem; line-height: 1.1; font-stretch: 85%; font-weight: 750; letter-spacing: -.01em; }
.tafel h2 a { color: var(--graphit); text-decoration: none; }
.tafel h2 a:hover { text-decoration: underline; text-decoration-color: var(--thema); text-decoration-thickness: 3px; }
.stufe-info { color: var(--bleistift); font-size: .86rem; white-space: nowrap; }
.tafel .buehne { width: 100%; height: auto; display: block; flex: 1 1 auto; min-height: 0; }
.frage { margin: 0; padding: 4px 16px 6px; font-size: 1.02rem; min-height: 3.2em; }
.antwort { margin: 0 16px 8px; padding: 6px 10px; background: var(--gelb); color: var(--gelb-text); border-radius: 3px; font-weight: 650; animation: einblenden .25s ease; }
.tafel footer { padding: 4px 16px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.k-oeffnen { margin-left: auto; font-weight: 650; }
.zaehler { font-size: .85rem; color: var(--bleistift); width: 100%; text-align: right; }

.bruch { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-family: "Stix", serif; line-height: 1.05; font-size: .95em; margin: 0 .12em; }
.bruch > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .2em; }
.bruch > span:last-child { padding: 0 .2em; }

/* ---------- Bühne ---------- */
.buehne { user-select: none; -webkit-user-select: none; }
.buehne text { font-family: "Bricolage", system-ui, sans-serif; }
.t { fill: var(--graphit); font-size: 20px; font-weight: 600; }
.t-klein { fill: var(--bleistift); font-size: 15px; font-weight: 500; }
.t-m { fill: var(--graphit); font-family: "Stix", serif !important; font-style: italic; font-size: 24px; }
.t-zahl { fill: var(--graphit); font-family: "Stix", serif !important; font-size: 24px; }
.t-tinte { fill: var(--tinte); }
.t-pink { fill: var(--pink); }
.t-tuerkis { fill: var(--tuerkis); }
.t-papier { fill: var(--blatt); }
.t-gl { fill: var(--graphit); font-family: "Stix", serif !important; font-size: 30px; }
.t-zeile { fill: var(--graphit); font-size: 21px; font-weight: 700; text-anchor: middle; }
.mitte { text-anchor: middle; dominant-baseline: central; }
.l-graphit { stroke: var(--graphit); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.l-duenn { stroke: var(--bleistift); stroke-width: 1.5; fill: none; }
.l-karo { stroke: var(--karo); stroke-width: 1; fill: none; }
.l-achse { stroke: var(--bleistift); stroke-width: 2; fill: none; }
.l-tinte { stroke: var(--tinte); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.l-pink { stroke: var(--pink); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.l-tuerkis { stroke: var(--tuerkis); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.l-gestrichelt { stroke-dasharray: 6 6; }
.f-tinte { fill: var(--tinte); }
.f-pink { fill: var(--pink); }
.f-tuerkis { fill: var(--tuerkis-flaeche); }
.f-gelb { fill: var(--gelb); }
.f-blatt { fill: var(--blatt); }
.f-graphit { fill: var(--graphit); }
.f-pink-hell { fill: var(--pink-hell); }
.f-tuerkis-hell { fill: var(--tuerkis-hell); }
.f-tinte-hell { fill: var(--tinte-hell); }
.griff { cursor: grab; }
.griff:active { cursor: grabbing; }
.klickbar { cursor: pointer; }

/* ---------- Werkzeugseite ---------- */
.wz { max-width: 1400px; margin: 0 auto; padding: 14px 24px 28px; }
.wz-kopf { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 12px; }
.wz-kopf h1 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.05; font-stretch: 82%; font-weight: 800; letter-spacing: -.02em; color: var(--tinte); background: var(--papier); padding: 0 .1em; }
.zurueck { font-weight: 650; background: var(--papier); padding: 0 .15em; }
.zurueck::before { content: "‹ "; }
.modus { margin-left: auto; display: inline-flex; }
.modus button { border-radius: 0; }
.modus button:first-child { border-radius: 6px 0 0 6px; border-right: 0; }
.modus button:last-child { border-radius: 0 6px 6px 0; }
.modus button.aktiv { background: var(--graphit); color: var(--papier); }
.wz-raum { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 22px; align-items: start; }
.wz-raum .buehne { width: 100%; height: auto; background: var(--blatt); border: 2px solid var(--graphit); border-radius: 4px; box-shadow: 7px 7px 0 var(--schatten); display: block; }
.pult { background: var(--blatt); border: 2px solid var(--graphit); border-radius: 4px; padding: 14px 16px 16px; }
.stufen { display: flex; gap: 0; margin-bottom: 12px; }
.stufen button { flex: 1; border-radius: 0; border-right-width: 0; padding: .32em .3em; font-size: .95rem; }
.stufen button:first-child { border-radius: 6px 0 0 6px; }
.stufen button:last-child { border-radius: 0 6px 6px 0; border-right-width: 2px; }
.stufen button.aktiv { background: var(--thema); border-color: var(--graphit); color: var(--blatt); }
.t-zahlen .stufen button.aktiv { background: var(--gelb); color: var(--gelb-text); }
.aufgabe { font-size: 1.22rem; line-height: 1.34; margin: 0 0 12px; font-weight: 550; }
.felder { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.feld { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feld .f-text { font-weight: 600; }
.feld input { width: 7em; padding: .34em .5em; border: 2px solid var(--graphit); border-radius: 4px; background: var(--papier); font-family: "Stix", serif; font-size: 1.22rem; }
.feld-text input { width: 100%; }
.feld select { padding: .4em; border: 2px solid var(--graphit); border-radius: 4px; background: var(--papier); min-width: 12em; }
.stapel { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.stapel input { width: 4.2em; text-align: center; }
.stapel input + input, .nenner { border-top: 3px solid var(--graphit); padding-top: 4px; }
.stapel input + input { border-top-width: 2px; }
.nenner { font-family: "Stix", serif; font-size: 1.3rem; width: 100%; text-align: center; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.knoepfe .primaer { flex: 1; min-width: 6em; }
.rueckmeldung { margin: 12px 0 0; min-height: 1.4em; font-weight: 600; }
.rueckmeldung.gut { color: var(--gut); }
.rueckmeldung.schlecht { color: var(--schlecht); }
.marker { color: var(--gelb-text); background: linear-gradient(var(--gelb), var(--gelb)) no-repeat left / 100% 100%; padding: .05em .3em; animation: markieren .45s cubic-bezier(.65,0,.35,1) both; }
@keyframes markieren { from { background-size: 0 100%; } to { background-size: 100% 100%; } }
.schritte { margin: 12px 0 0; padding-left: 1.3em; }
.schritte li { margin-bottom: .45em; animation: einblenden .35s ease both; }
@keyframes einblenden { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.serie { margin: 10px 0 0; color: var(--bleistift); font-weight: 600; }
.werkzeugleiste { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.werkzeugleiste:empty { display: none; }
.werkzeugleiste button { padding: .3em .7em; }
.werkzeugleiste .titel { width: 100%; font-weight: 600; font-size: .95rem; color: var(--bleistift); }
.shake { animation: wackeln .3s ease; }
@keyframes wackeln { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Entdecken */
.pult-entdecken { display: flex; flex-direction: column; gap: 14px; }
.regler { display: block; }
.regler-kopf { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 2px; }
.regler b { font-family: "Stix", serif; font-size: 1.1em; font-weight: 400; }
.regler input { width: 100%; accent-color: var(--tinte); }
.wahl { display: flex; flex-wrap: wrap; gap: 6px; }
.wahl button { padding: .3em .65em; }
.wahl button.aktiv { background: var(--graphit); color: var(--papier); }
.notiz { margin: 0; color: var(--bleistift); }
.seite-teil { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seite-teil > div { display: flex; flex-wrap: wrap; gap: 6px; align-content: start; }
.seite-teil .titel { width: 100%; font-weight: 600; }

/* Vollbild */
.wz.voll { position: fixed; inset: 0; z-index: 50; max-width: none; background-color: var(--papier); overflow: auto; padding: 10px 16px; }
.wz.voll .wz-raum { grid-template-columns: minmax(0, 1fr) 400px; }
.wz.voll .buehne { max-height: calc(100vh - 86px); }
.wz.voll .aufgabe { font-size: 1.5rem; }

/* ---------- Fuß, Lehrkräfte, Dialog ---------- */
.fuss { max-width: 1240px; margin: 0 auto; padding: 8px 24px 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--bleistift); font-size: .92rem; }
.fuss span, .fuss a { background: var(--papier); padding: 0 .2em; }
.schmal { max-width: 620px; margin: 32px auto; padding: 22px 24px 28px; background: var(--blatt); border: 2px solid var(--graphit); border-radius: 4px; }
.schmal.breit { max-width: 1120px; }
.schmal h1 { margin: 0 0 .4em; font-stretch: 82%; font-size: 2.3rem; color: var(--tinte); line-height: 1.05; }
.schmal h2 { margin: 1.4em 0 .4em; font-size: 1.3rem; }
.formular { display: flex; flex-direction: column; gap: 12px; }
.formular.reihe { flex-direction: row; flex-wrap: wrap; align-items: end; }
.formular label, .dialog label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.formular input, .dialog input { padding: .45em .6em; border: 2px solid var(--graphit); border-radius: 4px; background: var(--papier); font-weight: 400; min-width: 16em; max-width: 100%; }
.formular > button { align-self: flex-start; }
.meldung { padding: .6em .8em; border-radius: 4px; font-weight: 600; }
.meldung.gut { background: var(--tuerkis-hell); }
.meldung.schlecht { background: var(--pink-hell); }
.config { width: 100%; font-family: ui-monospace, monospace; font-size: .85rem; background: var(--papier); color: var(--graphit); }
.klasse { border-top: 2px solid var(--graphit); margin-top: 22px; }
.code b { font-size: 1.2em; background: var(--gelb); color: var(--gelb-text); padding: .05em .4em; border-radius: 3px; letter-spacing: .03em; }
.tabelle-rahmen { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border: 1px solid var(--karo); padding: .4em .55em; text-align: left; vertical-align: top; }
thead th { background: var(--papier); font-size: .85rem; }
td small { display: block; color: var(--bleistift); }
.leer { color: var(--bleistift); }
.klasse-aktionen { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.klasse-aktionen button, .abmelden button { font-size: .9rem; }
.abmelden { margin-top: 22px; }
.dialog { border: 2px solid var(--graphit); border-radius: 4px; background: var(--blatt); color: var(--graphit); padding: 20px 22px; max-width: min(460px, calc(100vw - 32px)); box-shadow: 7px 7px 0 var(--tinte); }
.dialog::backdrop { background: rgba(16, 20, 58, .45); }
.dialog h2 { margin: 0 0 .3em; font-stretch: 85%; }
.dialog p { margin: 0 0 .8em; }
.dialog label { margin-bottom: 10px; }
.dialog input { min-width: 0; width: 100%; }
.dialog-meldung { color: var(--schlecht); font-weight: 600; min-height: 1.2em; }
.dialog-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 1040px) {
  .wz-raum { grid-template-columns: minmax(0, 1fr); }
  .wand .tafel, .wand.gefiltert .tafel { grid-column: span 12; }
  .kopf { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 700px) and (max-width: 1040px) {
  .wand .tafel, .wand.gefiltert .tafel { grid-column: span 6; }
}
@media (max-width: 600px) {
  .kopf, .filter, .wand, .wz, .fuss { padding-left: 16px; padding-right: 16px; }
  .kopf { padding-top: 26px; }
  .wortmarke { font-size: clamp(2.5rem, 13.2vw, 4.2rem); }
  .wand { gap: 22px 0; }
  .tafel { box-shadow: 4px 4px 0 var(--schatten); }
  .modus { margin-left: 0; }
  .vollbild { display: none; }
  .wz-raum .buehne { box-shadow: 4px 4px 0 var(--schatten); }
  .klasse-knopf { margin-left: 0; }
  .schmal { margin: 16px; padding: 16px; }
  .formular input { min-width: 0; width: 100%; }
  .formular.reihe label { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .strich, .geo, .marker, .schritte li, .antwort { animation: none; }
  .geo { left: calc(100% - .98em); }
}

/* Beschriftungen bleiben auf Linien und Gitter lesbar */
.t-zeile, .t-klein { paint-order: stroke; stroke: var(--blatt); stroke-width: 5px; stroke-linejoin: round; }
