/* HA-Helfer – Schulheft-Look in Dunkelgrau: dunkles Karopapier, roter Rand, blaue Tinte, Textmarker */
@font-face { font-family: "Grundschrift"; src: url(fonts/playwrite-de-grund-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Grundschrift"; src: url(fonts/playwrite-de-grund-latin-300-normal.woff2) format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
/* Ziffern aus der Systemschrift: Atkinson zeichnet die Null durchgestrichen (wirkt wie Ø) */
@font-face { font-family: "Ziffern"; src: local("Helvetica Neue"), local("HelveticaNeue"), local("Segoe UI"), local("Roboto"), local("Arial"), local("Liberation Sans"), local("DejaVu Sans"); unicode-range: U+0030-0039; }

:root {
  color-scheme: dark;
  /* Flächen */
  --papier: #25272B;        /* Hintergrund */
  --karo: #2F3237;          /* Karolinien */
  --flaeche: #303338;       /* Heftblatt */
  --feld: #2A2C31;          /* Eingabefelder */
  --hover: #3A3D44;
  --linie: #464A51;
  --linie-stark: #5A5F68;
  /* Schrift */
  --graphit: #E7E8EB;       /* Haupttext */
  --blei: #A3A9B3;          /* Nebentext */
  --dunkel: #1F2023;        /* Text auf hellen Flächen */
  /* Akzente */
  --tinte: #8EA6FF;         /* Tinte: Überschriften, Links, Rahmen */
  --knopf: #4664E0;         /* Knopf-Hintergrund (weißer Text) */
  --knopf-hover: #3651C4;
  --rand: #E06A70;          /* roter Heftrand, Warnungen */
  --marker: #E9D54A;        /* Textmarker für Neues */
  --hinweis: #3A3725;
  --hinweis-rand: #8C7F2C;

  --kasten: 5mm;            /* echte Karogröße wie im Schulheft */
  --hand: "Grundschrift", "Segoe Script", cursive;
  --text: "Ziffern", "Atkinson", system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 17px/1.5 var(--text);
  color: var(--graphit);
  background-color: var(--papier);
  background-image:
    linear-gradient(var(--karo) 1px, transparent 1px),
    linear-gradient(90deg, var(--karo) 1px, transparent 1px);
  background-size: var(--kasten) var(--kasten);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--tinte); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Grundgerüst ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100%; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: #2B2D32; border-top: 2px solid var(--knopf);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.nav button {
  flex: 1; border: 0; background: none; padding: 6px 2px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; color: var(--blei); cursor: pointer; position: relative;
}
.nav button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav button[aria-current="page"] { color: var(--tinte); font-weight: 700; }
.nav .badge {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--marker); color: var(--dunkel); border-radius: 9px; font-size: 11px; font-weight: 700; line-height: 18px;
}
.brand { display: none; }

main { padding: 20px 16px calc(96px + var(--safe-b)); max-width: 760px; width: 100%; margin: 0 auto; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 232px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; flex-direction: column; justify-content: flex-start; gap: 4px;
    border-top: 0; border-right: 2px solid var(--knopf); padding: 24px 12px;
  }
  .nav button { flex: none; flex-direction: row; gap: 12px; font-size: 16px; padding: 12px 14px; justify-content: flex-start; }
  .nav button[aria-current="page"] { background: var(--hover); }
  .nav .badge { position: static; margin-left: auto; }
  .brand { display: block; font-family: var(--hand); color: var(--tinte); font-size: 24px; padding: 0 14px 24px; }
  main { padding: 40px 48px 48px; }
}

/* ---------- Typografie ---------- */
h1 { font-family: var(--hand); font-weight: 400; color: var(--tinte); font-size: 30px; line-height: 1.35; margin: 4px 0 18px; }
h2 { font-size: 19px; margin: 28px 0 10px; }
p { margin: 0 0 12px; max-width: 62ch; }
.leise { color: var(--blei); font-size: 15px; }
a { color: var(--tinte); }
summary { cursor: pointer; color: var(--tinte); }

/* ---------- Heftblatt: Blatt mit rotem Rand ---------- */
.blatt {
  position: relative; background: var(--flaeche);
  border: 1px solid var(--linie); border-radius: 4px;
  padding: 16px 16px 16px 44px; margin: 0 0 16px;
  box-shadow: 0 1px 0 var(--linie), 0 3px 0 -1px var(--flaeche), 0 4px 0 -1px var(--linie); /* Blätterstapel */
}
.blatt::before { content: ""; position: absolute; top: 0; bottom: 0; left: 28px; border-left: 2px solid var(--rand); opacity: .85; }
.blatt.fehler::before { border-left-width: 5px; }
.blatt h3 { font-family: var(--hand); font-weight: 400; font-size: 20px; color: var(--tinte); margin: 0 0 8px; line-height: 1.5; }
.marker { color: var(--dunkel); background: linear-gradient(100deg, transparent 2%, var(--marker) 4%, var(--marker) 96%, transparent 98%); padding: 0 4px; }

/* ---------- Die Heftzeile (Haupteingabe) ---------- */
.zeile {
  width: 100%; border: 0; border-bottom: 2px solid var(--tinte); background: transparent;
  font-family: var(--hand); font-size: 26px; line-height: 1.6; color: var(--tinte);
  padding: 6px 2px; resize: none; min-height: 64px;
}
.zeile::placeholder { color: #66708A; }
.zeile:focus { outline: none; border-bottom-color: var(--rand); }

/* ---------- Bedienelemente ---------- */
.reihe { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.knopf {
  border: 2px solid var(--knopf); background: var(--knopf); color: #fff; border-radius: 12px;
  padding: 11px 18px; font-weight: 700; cursor: pointer; min-height: 48px;
  display: inline-flex; align-items: center; gap: 8px;
}
.knopf:hover { background: var(--knopf-hover); border-color: var(--knopf-hover); }
.knopf.zweit { background: transparent; color: var(--tinte); border-color: var(--tinte); }
.knopf.zweit:hover { background: var(--hover); }
.knopf.klein { min-height: 38px; padding: 6px 12px; font-size: 15px; border-radius: 10px; }
.knopf.gefahr { border-color: var(--rand); background: transparent; color: var(--rand); }
.knopf.gefahr:hover { background: var(--hover); }
.knopf[disabled] { opacity: .5; cursor: progress; }
.knopf svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.feld { display: block; margin: 0 0 14px; }
.feld span { display: block; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.feld input, .feld select, .feld textarea, .zahl {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--linie-stark); border-radius: 10px; background: var(--feld);
}
.zahl { width: 88px; padding: 8px 10px; }
.feld input:focus, .feld textarea:focus, .zahl:focus { border-color: var(--tinte); outline: none; box-shadow: 0 0 0 3px rgba(142, 166, 255, .25); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--knopf); flex-shrink: 0; }

.umschalter { display: inline-flex; border: 2px solid var(--tinte); border-radius: 12px; overflow: hidden; }
.umschalter button { border: 0; background: none; padding: 8px 14px; cursor: pointer; color: var(--tinte); }
.umschalter button[aria-pressed="true"] { background: var(--knopf); color: #fff; font-weight: 700; }

/* ---------- Lösungstext ---------- */
.loesung { font-size: 17px; }
.loesung h4 { margin: 14px 0 4px; font-size: 17px; color: var(--graphit); }
.loesung strong { color: #fff; }
.loesung ul, .loesung ol { padding-left: 22px; margin: 4px 0 10px; }
.loesung p { margin: 0 0 8px; }

/* ---------- Listen ---------- */
.liste { list-style: none; padding: 0; margin: 0; }
.liste li { border-bottom: 1px dashed var(--linie); }
.liste .eintrag {
  width: 100%; text-align: left; border: 0; background: none; padding: 12px 4px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
}
.liste .titel { font-family: var(--hand); color: var(--tinte); font-size: 18px; }
.liste .zeit { color: var(--blei); font-size: 14px; grid-row: span 2; align-self: center; }
.liste .unter { color: var(--blei); font-size: 14px; }
.wahl { display: flex; gap: 12px; align-items: center; padding: 10px 4px; cursor: pointer; }
.wahl .titel { font-family: var(--hand); color: var(--tinte); font-size: 18px; }

.kasten-code {
  font-family: ui-monospace, Menlo, monospace; background: var(--hover); border-radius: 8px; padding: 8px 10px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 4px 0 10px;
}
.kasten-code > span { min-width: 0; overflow-wrap: anywhere; }
.kasten-code .knopf { font-family: var(--text); flex-shrink: 0; }
.schritte { padding-left: 22px; }
.schritte li { margin-bottom: 8px; }

.vorschau { max-width: 100%; border: 1px solid var(--linie); border-radius: 6px; margin-top: 8px; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 15px; }
.tabelle td, .tabelle th { text-align: left; padding: 8px 6px; border-bottom: 1px dashed var(--linie); vertical-align: top; }

/* ---------- Anmeldung ---------- */
.anmelden { max-width: 420px; margin: 8vh auto 40px; padding: 0 16px; }
.anmelden .blatt { padding: 22px 22px 22px 48px; }
.logo { font-family: var(--hand); color: var(--tinte); font-size: 40px; margin: 0 0 4px; }

/* ---------- Laden & Meldungen ---------- */
.denkt { display: flex; align-items: center; gap: 10px; color: var(--tinte); font-family: var(--hand); font-size: 20px; }
.denkt::after { content: ""; width: 60px; height: 3px; background: linear-gradient(90deg, var(--tinte) 50%, transparent 0) 0 0 / 12px 3px; animation: schreiben 0.8s linear infinite; }
@keyframes schreiben { to { background-position: 12px 0; } }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--graphit); color: var(--dunkel); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; font-weight: 700;
}
#toast.zeigen { opacity: 1; transform: translateX(-50%) translateY(0); }
.hinweis { background: var(--hinweis); border: 1.5px solid var(--hinweis-rand); border-radius: 10px; padding: 10px 12px; margin: 0 0 16px; font-size: 15px; }
.versteckt { display: none !important; }
