/* ═══════════════════════════════════════════
   Base — Reset + App Shell
   ═══════════════════════════════════════════ */

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

/* 383 A-001 — Hell/Dunkel springt, statt zu überblenden (app.js `_applyTheme`). */
.thema-wechsel *, .thema-wechsel *::before, .thema-wechsel *::after { transition: none !important; }

html {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overscroll-behavior: none;
  padding-top: var(--safe-top);
  background: var(--c-bg);
  color: var(--c-text);
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  outline: none;
}
button { cursor: pointer; }

/* ⛔ **231 §C.1 — der Doppeltipp-Zoom, an genau einer Stelle.**
 *
 * Gemessen gegen Prod (Cowork, 30.08.): das PIN-Feld hat **kein Eingabefeld**,
 * die Ziffern sind zwölf `<button>`; die bekannte 16-px-Mechanik greift hier
 * gar nicht. Ursache ist `touch-action: auto` — damit behält iOS Safari die
 * **Doppeltipp-zum-Zoomen**-Geste, und zwei Ziffern in schneller Folge liegen
 * unter dem Doppeltipp-Fenster.
 *
 * > ***Deshalb passiert es beim schnellen Eingeben und beim langsamen nicht.***
 *
 * `manipulation` nimmt **genau** diese Geste und lässt das Aufziehen mit zwei
 * Fingern unberührt — der Unterschied ist der ganze Punkt.
 *
 * ⛔ **Kein `user-scalable=no`, kein `maximum-scale`.** *Wer das Hineinzoomen
 * abschaltet, weil es an der falschen Stelle passiert, nimmt es auch dem, der
 * es braucht. Das ist keine Reparatur, das ist ein zweiter Fehler mit ruhigerem
 * Symptom.*
 *
 * ⚠️ **Warum die Liste länger ist als `button`:** die vier Fundstellen, die
 * `manipulation` schon trugen, hängen nicht alle an einem Knopf — gemessen ist
 * `.bnav-more-item` ein `<a>` und `.calendar-view-btn` **auch** ein `<div>`.
 * *Ein reines `button { … }` hätte sie stillschweigend verloren, und die
 * Reparatur wäre an zwei Stellen verschwunden, wo sie vorher stand.*
 */
button,
[role="button"],
.bnav-more-item,
.calendar-view-btn {
  touch-action: manipulation;
}
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── 379 — der Rahmen kommt aus dem Design System ──
   `AppShell` (React, `src/utils/ds.js`) zeichnet Seitenleiste, Kopf, Fuß und untere Leiste
   in `.notes-rahmen`; `.wd-shell` füllt ihn (`height: 100%`) und scrollt in `.wd-shell__main`.
   Unter 1024 px schaltet `.wd-shell` selbst auf die Handy-Form (untere Leiste mit Beschriftung,
   C.1 „600–1024 px mit Beschriftung“). Hier steht nur, was Notes um den Rahmen herum braucht. */
#app {
  display: block;
  min-height: 100dvh;
}

notes-app {
  display: block;
  width: 100%;
  min-height: 100dvh;
}

.notes-rahmen {
  height: calc(100dvh - var(--safe-top));
}

.notes-rahmen > .wd-shell {
  height: 100%;
}

/* Der Knoten, den der Rahmen hält (`wdMount`-children, DS 2.0.1), und darin der Inhalt der App. */
.notes-inhalt {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.app-content > [data-page] {
  flex: 1;
}

.app-content-status:empty {
  display: none;
}

.app-init-fehler {
  display: block;
  margin-bottom: var(--sp-md);
}

/* 237 A-006 T2 — geparkte Offline-Queue-Einträge, jetzt im Kopf des Rahmens (`headerAction`):
   Anzeige, kein Knopf, nicht wegklickbar. Wie ein Kennzeichen (`.wd-tag`), kein Status. */
.header-parked-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

/* 399 S4n2 (Q-031 c) — Kopf-Zusatz (Modulleiste, „Offline“, „N geparkt“). Ab 600 px unsichtbar als Kasten
   (`contents`): der Kopf bleibt eine Zeile wie bisher. */
.header-zusatz {
  display: contents;
}

/* Unter 600 px bricht der Kopf um: Zeile 1 Titel, Speicheranzeige, Nutzermenü; Zeile 2 der Zusatz.
   Gemessen (Q-031): mit Leiste (127 px) und beiden Plaketten lief die Seite bei 390 px auf 483 px über und der
   Titel schrumpfte auf 0. Die Zeilenhöhe des DS (`52px` fest) muss mit, sonst überlappt Zeile 2 den Inhalt.
   Die doppelte Klasse hebt die Spezifität über die Regeln des DS, ohne `!important`. */
@media (max-width: 599px) {
  .wd-shell.wd-shell:not(.wd-shell--desktop) {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .wd-shell.wd-shell:not(.wd-shell--desktop) .wd-shell__header {
    flex-wrap: wrap;
    min-height: 52px;
    row-gap: var(--space-1, 4px);
    padding-block: var(--space-1, 4px);
  }

  .wd-shell.wd-shell:not(.wd-shell--desktop) .wd-shell__header > .wd-shell__msave,
  .wd-shell.wd-shell:not(.wd-shell--desktop) .wd-shell__header > .wd-usermenu {
    order: 1;
  }

  .wd-shell.wd-shell:not(.wd-shell--desktop) .wd-shell__header > .header-zusatz {
    order: 2;
    display: flex;
    flex: 1 0 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2, 8px);
  }
}

/* ── Die ständige Freizeichnung (227 §C.3) — seit 379 / P-27 (a) an Anmeldung, Hilfe und Beleg,
   nicht mehr auf jeder Seite (`_standards/freizeichnung.md` §C.3). Nicht wegklickbar. */
.freizeichnung {
  margin-top: var(--sp-md);
  padding-top: var(--sp-sm);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* ── Toast Container ── */
#toast-container {
  position: fixed;
  top: calc(var(--safe-top) + var(--sp-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  pointer-events: none;
  width: calc(100% - var(--sp-xl));
  max-width: 400px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: var(--r-full); }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
