/* BlackOut — ruhig, warm, Sand- und Erdtöne. iPhone zuerst. */

:root {
  color-scheme: light dark;

  --grund: #f5efe4;
  --flaeche: #fffaf2;
  --flaeche-2: #efe5d4;
  --linie: #e4d7c2;
  --text: #2e261e;
  --leise: #7a6c5c;
  --ton: #b35d37;          /* Lehm / Terrakotta */
  --ton-hell: #f3dccd;
  --ton-text: #fffaf2;
  --oliv: #6f7f3c;
  --oliv-hell: #e3e6cd;
  --spur: #eadfcb;

  --ampel-rot: #c0462e;
  --ampel-gelb: #b7840e;
  --ampel-gruen: #6c8f3a;

  --faellig-grund: #f8e4d6;
  --faellig-linie: #ecc5ac;

  --schatten: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 14px rgb(60 40 20 / 6%);
  --radius: 18px;
  --radius-klein: 12px;
  --tipp: 44px;
  --breite: 1160px;        /* größte Inhaltsbreite (iPad Pro quer) */

  --schrift: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --schrift-rund: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #1b1713;
    --flaeche: #26201a;
    --flaeche-2: #2f2820;
    --linie: #3b3229;
    --text: #f1e7d8;
    --leise: #b2a38f;
    --ton: #e08a5f;
    --ton-hell: #4a2f22;
    --ton-text: #1b1713;
    --oliv: #a9bb6a;
    --oliv-hell: #3a3d26;
    --spur: #3a3128;

    --ampel-rot: #f07a5e;
    --ampel-gelb: #e9bd4c;
    --ampel-gruen: #9cc265;

    --faellig-grund: #3a261c;
    --faellig-linie: #5a3a2a;

    --schatten: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font-family: var(--schrift);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.mit-aktionen { padding-bottom: calc(156px + env(safe-area-inset-bottom)); }

h1, h2, h3, h4 { font-family: var(--schrift-rund); margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: inherit; }

.leise { color: var(--leise); }
.unsichtbar {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Kopf ---------- */

.kopf {
  max-width: var(--breite);
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 6px
    max(20px, env(safe-area-inset-left));
}
.kopf-marke { display: flex; align-items: center; gap: 12px; }
.kopf-marke img { border-radius: 9px; flex: none; }
.kopf h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.kopf-zeile { color: var(--leise); font-size: 14px; }

/* ---------- Inhalt ---------- */

.inhalt {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

h2 { font-size: 19px; font-weight: 700; }
.hinweis { color: var(--leise); font-size: 14px; margin-top: 2px; }

.tafel {
  background: var(--flaeche);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--schatten);
}

/* ---------- Fällig ---------- */

.faellig {
  background: var(--faellig-grund);
  border: 1px solid var(--faellig-linie);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.faellig.ruhig {
  background: var(--oliv-hell);
  border-color: transparent;
}
.faellig.ruhig h2::before { content: "✓ "; color: var(--oliv); }
.faellig h2 { display: flex; align-items: center; gap: 8px; }

.zahl-chip {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: 13px;
  background: var(--ton); color: var(--ton-text);
  font-size: 14px; font-weight: 700;
}

.faellig-liste { list-style: none; margin: 12px 0 0; padding: 0; }
.faellig-liste li {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tipp);
  padding: 6px 0;
  border-top: 1px solid var(--faellig-linie);
}
.faellig-liste li:first-child { border-top: 0; }
.faellig-name { flex: 1; font-weight: 600; min-width: 0; }

/* ---------- Balken ---------- */

.balken-liste { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 14px; }
.balken {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 6px;
  align-items: baseline;
}
.balken-name { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.balken-wert { font-size: 15px; color: var(--leise); font-variant-numeric: tabular-nums; }
.balken-spur {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 5px;
  background: var(--spur);
  overflow: hidden;
}
.balken-spur > span {
  display: block; height: 100%;
  border-radius: 5px;
  background: var(--ton);
  min-width: 0;
}
.balken.voll .balken-spur > span { background: var(--oliv); }
.balken.voll .balken-wert { color: var(--oliv); font-weight: 600; }
.balken.voll .balken-wert::after { content: " ✓"; }

/* ---------- Ort-Filter ---------- */

.orte {
  display: flex; gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 4px -16px 0;
  padding: 2px 16px;
}
.orte::-webkit-scrollbar { display: none; }
.ort-chip {
  flex: none;
  display: inline-flex; align-items: center;
  min-height: var(--tipp);
  padding: 0 18px;
  border-radius: 22px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  text-decoration: none;
  font-size: 15px; font-weight: 600;
  color: var(--leise);
}
.ort-chip.aktiv {
  background: var(--text);
  border-color: var(--text);
  color: var(--grund);
}

/* ---------- Gruppen und Karten ---------- */

#liste { display: flex; flex-direction: column; gap: 22px; }
.gruppe { display: flex; flex-direction: column; gap: 10px; }
.gruppe-kopf {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--leise);
  padding: 0 4px;
}

.karte {
  display: flex; align-items: center; gap: 12px;
  background: var(--flaeche);
  border-radius: var(--radius);
  padding: 14px 12px 14px 14px;
  box-shadow: var(--schatten);
}
.symbol {
  flex: none;
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 15px;
  background: var(--flaeche-2);
  font-size: 28px;
  line-height: 1;
}
.symbol.klein { width: 36px; height: 36px; border-radius: 11px; font-size: 20px; background: var(--flaeche); }

.karte-meta .teil { white-space: nowrap; }
.karte-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.karte-name {
  font-family: var(--schrift);
  font-size: 17px; font-weight: 650;
  overflow-wrap: anywhere;
}
.karte-meta {
  font-size: 14px; color: var(--leise);
  overflow-wrap: anywhere;
}

.mhd {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.punkt {
  display: inline-block; flex: none;
  width: 10px; height: 10px; border-radius: 50%;
  background: currentColor;
}
.ampel-rot   { color: var(--ampel-rot); }
.ampel-gelb  { color: var(--ampel-gelb); }
.ampel-gruen { color: var(--ampel-gruen); }
.karte .mhd.ampel-gruen { color: var(--leise); }
.karte .mhd.ampel-gruen .punkt { background: var(--ampel-gruen); }

.zaehler { flex: none; display: flex; align-items: center; gap: 0; }
.zaehler form { margin: 0; }
.anzahl {
  min-width: 28px;
  text-align: center;
  font-family: var(--schrift-rund);
  font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rund {
  width: var(--tipp); height: var(--tipp);
  border-radius: 50%;
  border: 1px solid var(--linie);
  background: var(--grund);
  color: var(--text);
  font: 600 22px/1 var(--schrift-rund);
  display: grid; place-items: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.rund:active { background: var(--flaeche-2); transform: scale(0.94); }
.htmx-request .rund, .htmx-request.rund { opacity: 0.5; }

.leer {
  text-align: center;
  padding: 36px 20px;
  background: var(--flaeche);
  border-radius: var(--radius);
  display: grid; gap: 6px;
}
.leer-symbol { font-size: 40px; }

/* ---------- Unten: Aktionen + Leiste ---------- */

.unten {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--grund) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}

.aktionen {
  max-width: 640px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 16px 4px;
}
.knopf {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px;
  border-radius: 16px;
  font-family: var(--schrift-rund);
  font-size: 18px; font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}
.knopf.haupt { background: var(--ton); color: var(--ton-text); }
.knopf.zweit { background: var(--flaeche); color: var(--text); border: 1.5px solid var(--linie); }
.knopf:active { transform: scale(0.98); }

.leiste {
  max-width: 640px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 58px;
  text-decoration: none;
  font-size: 12px; font-weight: 600;
  color: var(--leise);
}
.tab svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.tab.aktiv { color: var(--ton); }
.tab.aktiv svg { fill: var(--ton-hell); }

/* ---------- Ein- und Auschecken ---------- */

.zurueck {
  align-self: flex-start;
  display: inline-flex; align-items: center;
  min-height: var(--tipp);
  text-decoration: none; color: var(--ton);
  font-weight: 600;
}
.stapel { display: flex; flex-direction: column; gap: 14px; }
.abstand { margin-top: 14px; }
.knopf.breit { width: 100%; border: 0; font-size: 18px; cursor: pointer; }
.knopf.haupt.breit:disabled { opacity: 0.6; }

.meldung {
  background: var(--ton-hell);
  border-radius: var(--radius-klein);
  padding: 12px 14px;
  font-weight: 600;
}
.meldung.fehler { background: var(--faellig-grund); border: 1px solid var(--ampel-rot); color: var(--ampel-rot); }

.foto-feld {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px;
  border: 1.5px dashed var(--linie);
  border-radius: var(--radius-klein);
  background: var(--grund);
}
.foto-feld.zweit { border-style: solid; }
.foto-titel { font-weight: 600; font-size: 15px; }
.foto-feld input[type=file] { font-size: 16px; max-width: 100%; }

.feld { display: flex; flex-direction: column; gap: 6px; }
.feld > span { font-size: 14px; font-weight: 600; color: var(--leise); }
.feld small { font-weight: 400; }
.feld input, .feld select {
  min-height: var(--tipp);
  padding: 0 12px;
  border: 1.5px solid var(--linie);
  border-radius: var(--radius-klein);
  background: var(--grund);
  color: var(--text);
  font: inherit;
  width: 100%;
}
.feld input:focus, .feld select:focus { outline: 2px solid var(--ton); outline-offset: 1px; }
.zwei { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

.wahl {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 12px;
  border: 1.5px solid var(--linie);
  border-radius: var(--radius-klein);
  background: var(--grund);
}
.wahl:has(input:checked) { border-color: var(--ton); background: var(--ton-hell); }
.wahl input { width: 22px; height: 22px; accent-color: var(--ton); }
.wahl-text { display: flex; flex-direction: column; font-size: 15px; }

.laden { display: none; }
.htmx-request .normal, .htmx-request.normal { display: none; }
.htmx-request .laden { display: inline-flex; align-items: center; gap: 10px; }
.dreher {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid currentColor; border-right-color: transparent;
  animation: dreh 0.8s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

/* ---------- Ausrüstung ---------- */

.aktionen.einzeln { grid-template-columns: 1fr; }
.karte-link { text-decoration: none; }
.chip {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 10px;
  border-radius: 12px;
  font-size: 13px; font-weight: 700;
  background: var(--flaeche-2); color: var(--leise);
}
.chip.fehlt { background: var(--faellig-grund); color: var(--ampel-rot); }
.chip.bestellt { background: color-mix(in srgb, var(--ampel-gelb) 22%, var(--flaeche)); color: var(--ampel-gelb); }
.chip.vorhanden { background: var(--oliv-hell); color: var(--oliv); }
.karte.knapp { border: 1.5px solid var(--ampel-rot); }
.anzahl.knapp-zahl { color: var(--ampel-rot); min-width: 64px; }
.zaehler .anzahl { min-width: 28px; white-space: nowrap; padding: 0 4px; }
.pruef-form { margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.knopf-klein {
  min-height: var(--tipp); padding: 0 16px;
  border-radius: 22px;
  border: 1.5px solid var(--oliv); background: var(--oliv-hell); color: var(--oliv);
  font: 700 15px var(--schrift-rund);
  cursor: pointer; touch-action: manipulation;
}
.knopf-klein:active { transform: scale(0.97); }
.knopf-klein.zweit { border-color: var(--linie); background: var(--flaeche); color: var(--text); }
div.pruef-form { flex-direction: row; flex-wrap: wrap; gap: 8px; }

/* ---------- Infos ---------- */

.infos-faellig { display: block; text-decoration: none; }
.infos-einleitung { color: var(--leise); font-size: 16px; margin-bottom: 14px; }

.kapitel-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.kapitel-karte {
  display: flex; align-items: center; gap: 14px;
  min-height: 64px;
  padding: 12px 14px;
  background: var(--flaeche);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  text-decoration: none;
}
.kapitel-karte:active { transform: scale(0.99); }
.kapitel-nr {
  flex: none;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--flaeche-2);
  font: 700 18px var(--schrift-rund);
  font-variant-numeric: tabular-nums;
}
.kapitel-karte.erstes .kapitel-nr { background: var(--ton); color: var(--ton-text); }
.kapitel-titel { flex: 1; min-width: 0; font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.kapitel-pfeil { flex: none; font-size: 26px; color: var(--leise); line-height: 1; }

.zurueck-link {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tipp);
  margin: -6px 0 -10px;
  color: var(--ton); font-weight: 600; text-decoration: none;
}
.zurueck-link span { font-size: 24px; line-height: 1; }

/* Lesetext: groß, ruhig, viel Luft */
.lesetext {
  background: var(--flaeche);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 20px 18px 24px;
  font-size: 18px;
  line-height: 1.6;
  overflow-wrap: break-word;
}
.lesetext > :first-child { margin-top: 0; }
.lesetext p, .lesetext ul, .lesetext ol, .lesetext table { margin: 0 0 14px; }
.lesetext h1, .lesetext h2 {
  font-size: 22px; margin: 30px 0 12px;
  padding-top: 18px; border-top: 1px solid var(--linie);
}
.lesetext > h2:first-child { padding-top: 0; border-top: 0; }
.lesetext h3 { font-size: 20px; margin: 26px 0 8px; }
.lesetext h4 { font-size: 18px; margin: 20px 0 6px; }
.lesetext ul, .lesetext ol { padding-left: 1.4em; }
.lesetext li { margin: 6px 0; padding-left: 4px; }
.lesetext ol > li::marker { font-weight: 700; color: var(--ton); }
.lesetext strong { font-weight: 700; }
.lesetext a { color: var(--ton); }
.lesetext table { border-collapse: collapse; width: 100%; font-size: 16px; display: block; overflow-x: auto; }
.lesetext th, .lesetext td { border: 1px solid var(--linie); padding: 6px 8px; text-align: left; }
.lesetext blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 3px solid var(--linie); color: var(--leise); }

/* Kästen aus Obsidian-Callouts */
.lesetext div.gefahr,
.lesetext div.hinweis {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: var(--radius-klein);
  color: var(--text);
  font-size: inherit;
}
.lesetext div.gefahr > :last-child,
.lesetext div.hinweis > :last-child { margin-bottom: 0; }
.lesetext div.gefahr {
  border: 3px solid var(--ampel-rot);
  background: var(--faellig-grund);
}
.lesetext div.gefahr > p:first-child strong {
  color: var(--ampel-rot);
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lesetext div.hinweis {
  border-left: 5px solid var(--oliv);
  background: var(--oliv-hell);
}
.lesetext div.hinweis > p:first-child strong { color: var(--oliv); }

.kapitel-blaettern { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.blaettern {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 64px; padding: 10px 14px;
  background: var(--flaeche);
  border-radius: var(--radius-klein);
  box-shadow: var(--schatten);
  text-decoration: none; font-weight: 600; font-size: 15px;
}
.blaettern .leise { font-size: 13px; font-weight: 500; }
.blaettern.weiter { grid-column: 2; text-align: right; }

/* ---------- Offline-Hinweis, Anmeldung ---------- */
.offline-banner {
  position: sticky; top: 0; z-index: 50;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--ampel-gelb); color: #1b1713;
  font-weight: 600; font-size: 0.95rem; text-align: center;
}
.offline-banner[hidden] { display: none; }
.ist-offline [disabled] { opacity: 0.45; cursor: not-allowed; }
.abmelden { margin-top: 28px; text-align: center; }
.link-klein {
  background: none; border: 0; padding: 12px; min-height: var(--tipp);
  color: var(--leise); font: inherit; font-size: 0.9rem; text-decoration: underline;
}
.login { max-width: 420px; margin: 0 auto; padding: 48px 16px; }
.login h1 { text-align: center; }
.fehler-text { color: var(--ampel-rot); font-weight: 600; margin: 0 0 12px; }
.version-zeile { margin-top: 18px; text-align: center; color: var(--leise); font-size: 13px; }

.drucken { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

/* ---------- iPad und breite Fenster ----------
   iPhone (bis 430 px) bleibt einspaltig. Ab 700 px (iPad hoch, Split View breit) wird der Inhalt
   breiter, Karten stehen im Raster, Formulare zweispaltig; ab 1100 px drei Spalten. */

@media (min-width: 700px) {
  .kopf { padding-left: 28px; padding-right: 28px; }
  .inhalt { max-width: var(--breite); padding: 14px 24px 32px; gap: 22px; }

  .balken-liste { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 36px; }

  .gruppe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .gruppe-kopf { grid-column: 1 / -1; }
  /* In schmalen Rasterspalten rutscht der Zähler unter den Text, statt Namen zu zerhacken */
  .gruppe .karte { flex-wrap: wrap; row-gap: 8px; }
  .gruppe .karte-text { flex: 1 1 150px; }
  .gruppe .zaehler { margin-left: auto; }
  .karte-name { overflow-wrap: break-word; hyphens: auto; }

  .kapitel-liste { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .infos-einleitung { max-width: 70ch; }
  .drucken { max-width: 560px; }

  /* Formulare: zwei Felder nebeneinander, Knöpfe und Hinweise über die ganze Breite */
  .formular-seite .inhalt, .formular-seite .kopf { max-width: 920px; }
  .formular { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
  .formular > :not(.feld, .zwei) { grid-column: 1 / -1; }
  .foto-formular { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .foto-formular > :not(.foto-feld), .foto-formular > .foto-feld:only-of-type { grid-column: 1 / -1; }

  /* Lesetext: höchstens etwa 70 Zeichen je Zeile */
  .lese-seite .inhalt, .lese-seite .kopf { max-width: 820px; }
  .lesetext { padding: 32px 44px 36px; }
}

@media (min-width: 1100px) {
  .gruppe { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kapitel-liste { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Ab 1024 px (iPad quer, iPad Pro): Bereiche und Aktionen in einer flachen Zeile unten statt
   zwei Etagen – weniger Höhe, gleiche Stelle wie am iPhone. */
@media (min-width: 1024px) {
  .unten {
    display: flex; justify-content: center; align-items: center; gap: 32px;
    padding-left: 24px; padding-right: 24px;
    background: var(--grund);  /* deckend: sonst scheinen Filter-Chips durch die leere linke Hälfte */
  }
  .leiste { margin: 0; width: 400px; max-width: none; }
  .aktionen { order: 1; margin: 0; width: 440px; max-width: none; padding: 8px 0; }
  .aktionen.einzeln { width: 220px; }
  .aktionen .knopf { min-height: 48px; font-size: 17px; }
  body.mit-aktionen { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}

.login-hinweis { margin-top: 18px; text-align: center; font-size: 14px; }
.version-zeile a { color: inherit; }
