:root{--akzent:#2b6cb0;--akzent-hell:#e8f0f9;--akzent-dunkel:#7fb3f0;--akzent-hell-dunkel:#222d34;--marke:#2b6cb0}
/* Grundregeln aller Websites (UI-UX-REGELN 2.–8., 15.): Farben mit Dunkelmodus, Schrift, Kopf mit Menü, Brotkrumen,
   Seitenkopf, Fuß, Fokus, Druck. Davor setzt der Bau die --akzent*-Variablen (kern/basis/stil.mjs),
   danach folgt das Stylesheet der Website und überschreibt, was dort anders ist (z. B. --breite). */
:root {
  --text: #1c1f1d;
  --leise: #5b625d;
  --linie: #dfe3df;
  --flaeche: #ffffff;
  --grund: #f6f7f4;
  --akzent-text: #ffffff;
  --radius: 10px;
  --breite: 1240px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #e8ebe8;
    --leise: #a3aba5;
    --linie: #333a35;
    --flaeche: #1b1f1c;
    --grund: #121513;
    --akzent: var(--akzent-dunkel);
    --akzent-hell: var(--akzent-hell-dunkel); /* Hauch Akzent auf dem dunklen Grund */
    --akzent-text: #0f1310;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--grund);
  /* Fuß immer am unteren Rand, auch bei wenig Inhalt */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--akzent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 3.6vw, 2.1rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.huelle { max-width: var(--breite); margin: 0 auto; padding: 0 16px; }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprunglink { position: absolute; left: 16px; top: -100px; background: var(--flaeche); padding: .5rem 1rem; border-radius: 8px; z-index: 50; }
.sprunglink:focus { top: 8px; }

.kopf { background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.kopf .huelle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.logo-zeichen { width: 22px; height: 22px; flex: none; color: var(--akzent); }
.kopf nav a { color: var(--leise); text-decoration: none; margin-left: 1rem; font-size: .95rem; display: inline-block; padding: .6rem 0; }
.kopf nav a:hover, .kopf nav a[aria-current] { color: var(--akzent); }
.menue-knopf { display: none; }
/* Handy: Kopf in einer Zeile mit Menü-Knopf, Links klappen darunter auf */
@media (max-width: 699px) {
  html { scroll-padding-top: 12px; }
  .kopf .huelle { min-height: 56px; gap: 0 1rem; }
  .js .menue-knopf { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: var(--text); cursor: pointer; border-radius: 8px; }
  .menue-knopf::before, .menue-knopf::after { content: ""; grid-area: 1 / 1; width: 20px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .15s, box-shadow .15s; }
  .menue-knopf::before { box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor; }
  .menue-knopf::after { transform: scaleX(0); }
  .offen .menue-knopf::before { box-shadow: none; transform: rotate(45deg); }
  .offen .menue-knopf::after { transform: rotate(-45deg); }
  .js .kopf nav { display: none; }
  .js .kopf.offen nav { display: flex; flex-direction: column; flex-basis: 100%; padding-bottom: .5rem; }
  .js .kopf nav a { margin: 0; padding: .75rem 0; font-size: 1rem; color: var(--text); border-top: 1px solid var(--linie); }
}

/* Knöpfe: gefüllt = Hauptaktion, umrandet (.zweit) = Nebenaktion (UI-UX-REGELN 9.) */
.knopf { font: inherit; font-weight: 600; padding: .65rem 1rem; border-radius: 8px; border: 1px solid var(--akzent); background: var(--akzent); color: var(--akzent-text); cursor: pointer; text-decoration: none; display: inline-block; }
.knopf.zweit { background: transparent; color: var(--akzent); }
main { flex: 1 0 auto; padding: 1.25rem 0 3rem; }
main.mit-vorspann { padding-top: 0; }
.krumen { font-size: .875rem; color: var(--leise); margin-bottom: .75rem; }
.krumen ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.krumen li + li::before { content: "›"; margin-right: .25rem; }
.krumen a { color: var(--leise); }
/* Handy: aktuelle Seite steht ohnehin in der Überschrift */
@media (max-width: 699px) { .krumen li:nth-child(n+3)[aria-current] { display: none; } }
.einleitung { font-size: 1.05rem; color: var(--leise); max-width: 50rem; }
.seitenkopf { margin-bottom: 1rem; }
.seitenkopf h1 { margin-bottom: .3rem; }
.seitenkopf .einleitung { margin: 0; }
.prosa { max-width: 46rem; }
.prosa li { margin-bottom: .35rem; }

.fuss { border-top: 1px solid var(--linie); background: var(--flaeche); font-size: .875rem; color: var(--leise); padding: 1.5rem 0; }
.fuss .huelle { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; }
.fuss p { margin: 0; }
.fuss a { color: var(--leise); }
.fuss nav a { margin-right: 1rem; }
.fuss .link-knopf { font: inherit; color: var(--leise); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* Tastatur-Fokus überall sichtbar (UI-UX-REGELN 15.). :root davor, damit spätere Regeln wie „all: unset“ ihn nicht entfernen. */
:root :focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
/* Kleine Textlinks mindestens 24 px hoch (UI-UX-REGELN 2.) */
.fuss a, .fuss .link-knopf, .krumen a { display: inline-block; padding-block: 3px; }
/* Finger: Logo und Fußzeilen-Links 44 px hoch (UI-UX-REGELN 2.) */
@media (pointer: coarse) {
  .logo { min-height: 44px; }
  .fuss nav a, .fuss .link-knopf { display: inline-flex; align-items: center; gap: .3em; min-height: 44px; padding-block: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .kopf, .fuss, .krumen, .sprunglink { display: none; }
  body { background: #fff; color: #000; }
}
/* Ausmalwerkstatt: alles, was es nur hier gibt. Grundregeln und Farben kommen aus kern/basis (stylesheet()). */

/* Blätter als Kacheln: Bild, Name, Merkmale, darunter PDF und Online ausmalen untereinander */
.blaetter { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 1.25rem 1rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.blatt { display: flex; flex-direction: column; }
.blatt-bild img, .bereiche img { display: block; width: 100%; height: auto; aspect-ratio: 210 / 297; background: #fff; border: 1px solid var(--linie); border-radius: 6px; }
.blatt h3 { font-size: .95rem; margin: .5rem 0 .15rem; }
.blatt-info { font-size: .85rem; color: var(--leise); margin: 0 0 .5rem; flex: 1; }
.blatt-knoepfe { display: grid; gap: .4rem; margin: 0; }
.blatt-knoepfe .knopf { text-align: center; padding: .55rem .5rem; }
.alle { margin: .75rem 0 0; font-weight: 600; }

/* Startseite: Bereiche als große Kacheln mit dem ersten Blatt */
.bereiche { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.bereiche a { display: grid; gap: .5rem; color: inherit; text-decoration: none; }
.bereiche a:hover b { text-decoration: underline; }
.bereiche span { display: grid; }
.bereiche b { color: var(--akzent); }
.bereiche small { color: var(--leise); font-size: .85rem; }
.werkzeuge { display: grid; gap: .75rem; margin: 1.5rem 0; padding: 1rem; background: var(--akzent-hell); border-radius: var(--radius); }
.werkzeuge p { margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.werkzeuge .knopf { min-width: 12rem; text-align: center; }

/* Mandala-Übersicht: Alter und Malzeit je Gruppe */
.uebersicht { border-collapse: collapse; margin: 1rem 0; font-size: .95rem; width: 100%; max-width: 46rem; }
.uebersicht th, .uebersicht td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--linie); }
.uebersicht thead th { color: var(--leise); font-weight: 600; font-size: .85rem; }
@media (max-width: 499px) { .uebersicht { font-size: .85rem; } .uebersicht th, .uebersicht td { padding: .4rem .3rem; } }

.liste-links { padding-left: 1.2rem; }
.info { color: var(--leise); font-size: .9rem; }
.hinweis { font-size: .85rem; color: var(--leise); margin: 0; }

/* ---------- Online ausmalen ---------- */
/* Höhe der Malleiste unten am Handy und Platz über dem Bild, damit das Bild ganz dazwischen passt */
.malen { --leiste: 162px; --oben: 205px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.malkopf { grid-column: 1 / -1; scroll-margin-top: 8px; }
.malkopf h1 { font-size: 1.3rem; margin: 0; }
.malkopf .info { margin: .2rem 0 0; }
.malblatt { grid-column: 1; justify-self: center; max-width: 100%; background: #fff; border: 1px solid var(--linie); border-radius: 6px; overflow: hidden; }
/* Das ganze Blatt passt ins Fenster, auch am Desktop */
.malblatt canvas { display: block; width: auto; max-width: 100%; max-height: calc(100dvh - 16px); height: auto; touch-action: manipulation; cursor: crosshair; }
/* Die Leiste klebt rechts neben Bild und Vorschauen. Ist das Fenster niedriger als sie, scrollt sie in sich. */
.malen aside { grid-column: 2; grid-row: 2 / span 2; display: grid; gap: 14px; position: sticky; top: 8px; max-height: calc(100dvh - 16px); overflow-y: auto; }
.malen .feld { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: 10px; display: grid; gap: 8px; }
.malen .feld b { font-size: .9rem; }
.malen button, .generator .schalter button { font: inherit; min-height: 44px; border-radius: 6px; border: 1px solid var(--linie); background: var(--flaeche); color: var(--text); padding: 0 12px; cursor: pointer; }
.malen button:disabled { opacity: .45; cursor: default; }
.malen button[aria-pressed="true"], .generator .schalter button[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.malen .reihe { display: flex; flex-wrap: wrap; gap: 6px; }
.malen .reihe > button { flex: 1 1 auto; }
/* Unterste Reihe der Leiste: links Rückgängig, rechts der Umschalter. Steht in beiden Arten an derselben Stelle. */
.malen .unten { display: grid; grid-template-columns: 1fr 2fr; gap: 6px; }
/* Segmente: eine Reihe gleich breiter Knöpfe, am Handy passen vier nebeneinander */
.schalter { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.schalter button { padding: 0 4px !important; border-radius: 0 !important; }
.schalter button + button { border-left: 0 !important; }
.schalter button:first-child { border-radius: 6px 0 0 6px !important; }
.schalter button:last-child { border-radius: 0 6px 6px 0 !important; }
#beispielFarben, #rechnenMehr { display: grid; gap: 8px; }
#beispielFarben[hidden], #rechnenMehr[hidden] { display: none; }
/* 13 Farben und das Schloss in 2 Reihen zu 7: am Handy (343 px breit) noch 45 px je Feld */
.farben { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.malen .farben button { min-width: 0; padding: 0; height: 44px; border: 2px solid var(--linie); }
.malen .farben button[aria-pressed="true"] { outline: 3px solid var(--akzent); outline-offset: 1px; }
.farben svg { width: 24px; height: 24px; display: block; margin: auto; }
#feldSelbst, #feldBeispiel { display: grid; gap: 8px; min-height: 92px; align-content: start; }
#feldSelbst[hidden], #feldBeispiel[hidden] { display: none; }
.palette { display: flex; height: 14px; border-radius: 3px; overflow: hidden; }
.palette span { flex: 1; }
/* Vorschauen: antippen wechselt das Bild, das Ausgemalte bleibt je Bild erhalten */
.mehr { grid-column: 1; }
.mehr h2 { font-size: 1.1rem; margin-top: .5rem; }
.mehr h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.vorschau { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.malen .vorschau button { padding: 0; aspect-ratio: 210 / 297; background: #fff; border: 2px solid var(--linie); overflow: hidden; position: relative; }
.malen .vorschau button[aria-current="true"] { outline: 3px solid var(--akzent); outline-offset: 1px; }
.vorschau img { display: block; width: 100%; height: 100%; object-fit: contain; }
.vorschau .angefangen { position: absolute; right: 4px; bottom: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--akzent); border: 2px solid #fff; }
.malen + #druck + .prosa, .malen + .prosa { margin-top: 2rem; }
/* Handy: Bild oben, darunter die feste Leiste mit allem, was man beim Malen braucht */
@media (max-width: 699px) {
  .malen { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  main:has(.malen) { padding-bottom: calc(var(--leiste, 162px) + 24px); }
  .malkopf h1 { font-size: 1.1rem; }
  .malblatt canvas { max-height: max(300px, calc(100dvh - var(--leiste) - var(--oben))); }
  .malen aside { grid-column: 1; grid-row: auto; position: static; max-height: none; overflow: visible; }
  #werkzeug { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; border-radius: 0; border-width: 1px 0 0; box-shadow: 0 -2px 8px #0003; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
}

/* ---------- Mandala-Generator ---------- */
.generator { display: grid; gap: .75rem; max-width: 30rem; }
.gen-stufen { max-width: 30rem; }
.generator .schalter button { font-size: .9rem; }
.gen-blatt { background: #fff; border: 1px solid var(--linie); border-radius: 6px; overflow: hidden; }
.gen-blatt svg { display: block; width: 100%; height: auto; }
.generator .info { margin: 0; }
.gen-knoepfe { display: flex; flex-wrap: wrap; gap: .5rem; }
.gen-knoepfe .knopf { flex: 1 1 12rem; text-align: center; }

/* ---------- Drucken ---------- */
/* Ausmalen mit Rechenaufgaben: nur #druck (Seite 1 Blatt, Seite 2 Lösung). Generator: nur das Blatt. @page setzen die Skripte. */
#druck { display: none; }
@media print {
  body.druck > *:not(#druck) { display: none !important; }
  body.druck #druck { display: block; }
  #druck svg { display: block; width: 210mm; height: 297mm; break-after: page; }
  body:has(#genBlatt) main .huelle > :not(.generator), body:has(#genBlatt) .generator > :not(.gen-blatt) { display: none !important; }
  body:has(#genBlatt) main { padding: 0; }
  body:has(#genBlatt) .huelle { padding: 0; max-width: none; }
  .gen-blatt { border: 0; border-radius: 0; }
  .gen-blatt svg { width: 210mm; height: 297mm; }
}
