/* Familienwiki – Stylesheet
   Hell und dunkel per data-theme ("hell", "dunkel", "auto" = wie im Gerät eingestellt),
   große Schrift per data-schrift. Keine Inline-Styles und keine externen Ressourcen (CSP).

   Farben: Jede Schriftfarbe erreicht auf ihrem Hintergrund mindestens 4,5 : 1 (WCAG AA),
   Rahmen von Eingabefeldern und der Fokusrahmen mindestens 3 : 1. tests/test_farben.py prüft das.
   Die dunkle Palette steht zweimal (fester Dunkelmodus und Automatik); der Test prüft,
   dass beide Blöcke gleich sind. */

:root {
  --bg: #f7f5f0;
  --flaeche: #ffffff;
  --text: #1c1b19;
  --muted: #4d4842;
  --akzent: #1e5c4b;
  --akzent-text: #ffffff;
  --rand: #d6cfc4;
  --eingabe-rand: #767068;
  --link: #1a5544;
  --fehler: #9b1c1c;
  --fehler-bg: #fbeaea;
  --erfolg: #1d5a2c;
  --erfolg-bg: #e7f4ea;
  --hinweis-bg: #eaf0f5;
  --gefahr: #8a1f1f;
  --fokus: #0b57d0;
  --mark-bg: #ffe27a;
  --mark-text: #1c1b19;
  --code-bg: #efeae2;
  --radius: 10px;
  color-scheme: light;
}

html[data-theme="dunkel"] {
  --bg: #121514;
  --flaeche: #1d2220;
  --text: #f1eee9;
  --muted: #c9c2b8;
  --akzent: #7cc7ad;
  --akzent-text: #0c1a15;
  --rand: #3a413d;
  --eingabe-rand: #8a948f;
  --link: #9ad9c3;
  --fehler: #ffb4b4;
  --fehler-bg: #3d2323;
  --erfolg: #a3e6b6;
  --erfolg-bg: #1d3326;
  --hinweis-bg: #1c2a35;
  --gefahr: #ffb4b4;
  --fokus: #8ab4ff;
  --mark-bg: #5c4b00;
  --mark-text: #fff6d6;
  --code-bg: #2a302d;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #121514;
    --flaeche: #1d2220;
    --text: #f1eee9;
    --muted: #c9c2b8;
    --akzent: #7cc7ad;
    --akzent-text: #0c1a15;
    --rand: #3a413d;
    --eingabe-rand: #8a948f;
    --link: #9ad9c3;
    --fehler: #ffb4b4;
    --fehler-bg: #3d2323;
    --erfolg: #a3e6b6;
    --erfolg-bg: #1d3326;
    --hinweis-bg: #1c2a35;
    --gefahr: #ffb4b4;
    --fokus: #8ab4ff;
    --mark-bg: #5c4b00;
    --mark-text: #fff6d6;
    --code-bg: #2a302d;
    color-scheme: dark;
  }
}

html { font-size: 17px; }
html[data-schrift="gross"] { font-size: 22px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

main:focus { outline: none; }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.9rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.35rem; margin: 1.5rem 0 0.75rem; }

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

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

.sprunglink {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--akzent);
  color: var(--akzent-text);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  z-index: 10;
}
.sprunglink:focus { top: 0.5rem; }

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

/* Kopfzeile */
.kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}
.marke { font-weight: 700; font-size: 1.2rem; color: var(--akzent); text-decoration: none; }
.navliste { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.navliste a { text-decoration: none; padding: 0.25rem 0.1rem; }
.navliste a:hover { text-decoration: underline; }
.konto { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.konto span { color: var(--muted); }

/* Schaltflächen */
.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.knopf:hover { border-color: var(--akzent); }
.knopf.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.knopf.primaer:hover { text-decoration: underline; text-underline-offset: 0.15em; }
.knopf.klein { min-height: 2rem; padding: 0.2rem 0.6rem; font-size: 0.9em; }
.knopf.gefahr { border-color: var(--gefahr); color: var(--gefahr); }
html[data-schrift="gross"] .knopf { min-height: 3.25rem; font-size: 1.05em; }
html[data-schrift="gross"] .knopf.klein { min-height: 2.5rem; }

form.inline { display: inline; margin: 0; }

/* Hinweise */
.hinweis {
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--rand);
  background: var(--hinweis-bg);
}
.hinweis-erfolg { background: var(--erfolg-bg); color: var(--erfolg); border-color: var(--erfolg); }
.hinweis-fehler { background: var(--fehler-bg); color: var(--fehler); border-color: var(--fehler); }

/* Karten und Abschnitte */
.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.karte.schmal, .schmal { max-width: 34rem; margin-left: auto; margin-right: auto; }
.anmeldung { margin-top: 2rem; }
.meta { color: var(--muted); font-size: 0.92em; margin: 0.25rem 0; }
.kennung { color: var(--muted); }
.liste { padding-left: 1.2rem; }
.liste li { margin-bottom: 0.4rem; }
.artwahl { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.artwahl li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.schritte li { margin-bottom: 0.5rem; }
.geheimnis { font-size: 1.1em; word-break: break-all; background: var(--code-bg); color: var(--text); padding: 0.1rem 0.4rem; border-radius: 6px; }
.link-feld { width: 100%; font-family: ui-monospace, monospace; }

/* Formulare */
.formular { display: grid; gap: 1rem; }
.feld { display: grid; gap: 0.3rem; }
.feld label { font-weight: 600; }
.feld-hinweis { margin: 0; color: var(--muted); font-size: 0.9em; }
.pflicht { font-weight: 400; color: var(--muted); font-size: 0.85em; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  min-height: 2.6rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--eingabe-rand);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
}
.feld input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.feld select,
.feld textarea { width: 100%; }
::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--akzent); }
.feld textarea { min-height: 8rem; font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 0.95em; }
.feld-check { display: flex; align-items: center; gap: 0.5rem; }
.feld-check input { width: 1.3rem; height: 1.3rem; }
.aktionen { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }
.aktionen-zelle { white-space: nowrap; }
.aktionen-zelle .knopf { margin: 0.15rem 0.2rem 0.15rem 0; }

/* Tabellen */
.tabelle-rahmen { overflow-x: auto; border: 1px solid var(--rand); border-radius: var(--radius); background: var(--flaeche); }
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle caption { text-align: left; padding: 0.6rem 0.8rem; color: var(--muted); }
.tabelle th, .tabelle td { padding: 0.55rem 0.8rem; border-top: 1px solid var(--rand); text-align: left; vertical-align: top; }
.tabelle thead th { border-top: none; }

/* Seiten */
.seite .seitenkopf { margin-bottom: 1rem; }
.seiteninhalt { max-width: 46rem; }
.seiteninhalt img { max-width: 100%; height: auto; border-radius: var(--radius); }
.seiteninhalt table { border-collapse: collapse; margin: 1rem 0; }
.seiteninhalt th, .seiteninhalt td { border: 1px solid var(--rand); padding: 0.4rem 0.6rem; }
.seiteninhalt blockquote { margin: 1rem 0; padding: 0.2rem 1rem; border-left: 4px solid var(--akzent); color: var(--muted); }
.seiteninhalt hr { border: 0; border-top: 1px solid var(--rand); }
.seiteninhalt code { font-family: ui-monospace, monospace; background: var(--code-bg); color: var(--text); padding: 0.05rem 0.3rem; border-radius: 4px; }
.seiteninhalt pre code { display: block; padding: 0.75rem; overflow-x: auto; }
.seiteninhalt a.fehlt { color: var(--fehler); text-decoration-style: dashed; }

.feldgruppe { border: 1px solid var(--rand); border-radius: var(--radius); padding: 0.75rem 1rem 1rem; display: grid; gap: 1rem; }
.feldgruppe legend { font-weight: 700; padding: 0 0.3rem; }
.profil-kopf { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; margin-bottom: 1rem; }
.profilfoto { width: 12rem; max-width: 60vw; height: auto; border-radius: var(--radius); border: 1px solid var(--rand); }
.daten { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0; }
.daten dt { font-weight: 600; color: var(--muted); }
.daten dd { margin: 0; }
.beziehungen { margin-bottom: 0.75rem; }
.beziehungen h3 { font-size: 1.05rem; margin: 0.5rem 0 0.25rem; }
.beziehungen .liste { margin: 0; }
.personen-profil .karte { margin-top: 1rem; }
.baum { list-style: none; padding-left: 1.2rem; border-left: 2px solid var(--rand); margin: 0.4rem 0; }
.baum > li { margin: 0.35rem 0; }
.rueckverweise { margin-top: 2rem; }

.filter { margin: 0.5rem 0 1rem; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0.25rem 0; }
.chip {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--rand);
  border-radius: 999px;
  background: var(--flaeche);
  color: var(--text);
  text-decoration: none;
  font-size: 0.92em;
}
.chip:hover { border-color: var(--akzent); }
.chip.aktiv, .chip[aria-current="page"] { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.schlagworte { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0; }
.feld-zeile { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.feld-zeile > .feld { flex: 1 1 8rem; }
.zutaten { padding-left: 1.2rem; }
.zutaten li { margin-bottom: 0.3rem; }
.menge { font-weight: 600; margin-right: 0.25rem; white-space: nowrap; }
.schritte-liste li { margin-bottom: 0.6rem; }
.umrechner { margin: 0.5rem 0 0; }
.rezept-kopf { margin-bottom: 1.5rem; }
a.wikilink { text-decoration-style: solid; }
.seiteninhalt a.wikilink.fehlt { color: var(--fehler); text-decoration-style: dashed; }

.galerie-abschnitt { margin-top: 2rem; }
.galerie { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1rem; }
.galerie img { display: block; max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--rand); }
.galerie p { margin: 0.3rem 0; }

.gefahrenbereich { margin-top: 2rem; border: 1px dashed var(--gefahr); border-radius: var(--radius); padding: 0.75rem 1rem; }
.gefahrenbereich summary { cursor: pointer; color: var(--gefahr); font-weight: 600; }
.gefahrenbereich form { margin-top: 0.75rem; }

.fuss { border-top: 1px solid var(--rand); color: var(--muted); font-size: 0.85em; text-align: center; padding: 0.75rem 1rem; }
.fuss-schalter { margin-bottom: 0.5rem; }

/* Umschalter Hell/Dunkel */
.farbschalter .knopf { gap: 0.4rem; white-space: nowrap; }
.farbschalter-symbol { font-size: 1.1em; line-height: 1; }
.fuss p { margin: 0; }

@media (max-width: 40rem) {
  .konto { margin-left: 0; }
  h1 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Kalender */
.kal-abschnitt { margin-top: 2rem; }
.kal-kopf { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.kal-kopf h2 { margin: 0; font-size: 1.25rem; }
.kal-rahmen { margin-top: 0.5rem; }
.kal-tabelle { width: 100%; min-width: 42rem; border-collapse: collapse; table-layout: fixed; }
.kal-tabelle th { padding: 0.45rem; text-align: center; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--rand); }
.kal-tabelle td { vertical-align: top; height: 6.5rem; padding: 0.35rem; border-top: 1px solid var(--rand); border-left: 1px solid var(--rand); }
.kal-tabelle td.fremd { color: var(--muted); background: var(--bg); }
.kal-tabelle td.heute { box-shadow: inset 0 0 0 2px var(--akzent); }
.kal-nummer { display: block; font-weight: 600; margin-bottom: 0.2rem; }
.kal-liste { list-style: none; margin: 0; padding: 0; font-size: 0.85em; }
.kal-liste li { margin-bottom: 0.25rem; padding-left: 0.4rem; border-left: 3px solid var(--rand); overflow-wrap: anywhere; }
.kal-liste li.kal-geburtstag { border-left-color: var(--akzent); }
.kal-liste li.kal-jahrestag { border-left-color: var(--link); }
.kal-zeit { font-weight: 600; }

/* Zeitstrahl und Erinnerungen */
.zeit-jahr { margin-top: 1.5rem; }
.zeitstrahl { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 3px solid var(--rand); }
.zeit-eintrag { position: relative; margin: 0 0 1rem 0.5rem; }
.zeit-eintrag::before { content: ""; position: absolute; left: -1.45rem; top: 0.45rem; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--akzent); }
.zeit-eintrag time { font-weight: 600; margin-right: 0.4rem; }
.zeit-foto-rahmen { margin-top: 0.4rem; }
.zeit-foto { display: block; max-width: 14rem; height: auto; border-radius: var(--radius); border: 1px solid var(--rand); }
.zeitstrahl-filter { margin-bottom: 1rem; }
.erinnerung-foto { margin: 1rem 0; }
.erinnerung-foto img { display: block; max-width: 22rem; height: auto; border-radius: var(--radius); border: 1px solid var(--rand); }

/* Suche */
.suchform { margin-bottom: 1.5rem; }
.suchtreffer { padding-left: 1.2rem; }
.suchtreffer li { margin-bottom: 1rem; }
.suchausschnitt { margin: 0.25rem 0 0; color: var(--text); }
mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 3px; padding: 0 0.1em; }
