/* Kirrautomat – Farben stammen aus dem Revier: Moos, Birkenrinde, Warnorange */
:root {
  --bg: #e7eae1;
  --flaeche: #f5f6f1;
  --tinte: #17231a;
  --leise: #586a5a;
  --linie: #c3cbbd;
  --moos: #2d4a33;
  --moos-hell: #4f7a58;
  --warn: #d4470f;
  --warn-schrift: #b53706;
  --warn-text: #ffffff;
  --ok: #2c7a4b;
  --korn: #d9a63f;
  --kopf-text: #f1f4ec;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1510;
    --flaeche: #172119;
    --tinte: #e4eadd;
    --leise: #94a692;
    --linie: #2a3a2d;
    --moos: #1c3322;
    --moos-hell: #8fb996;
    --warn: #ff7a3b;
    --warn-schrift: #ff9560;
    --warn-text: #1a0d05;
    --ok: #6fc28d;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1510;
  --flaeche: #172119;
  --tinte: #e4eadd;
  --leise: #94a692;
  --linie: #2a3a2d;
  --moos: #1c3322;
  --moos-hell: #8fb996;
  --warn: #ff7a3b;
  --warn-schrift: #ff9560;
  --warn-text: #1a0d05;
  --ok: #6fc28d;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--tinte);
  font: 17px/1.45 "Segoe UI Variable Text", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .35rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 2rem 0 .6rem; }
p { margin: 0 0 .75rem; }

/* Kopf mit Höhenlinien */
.kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(14px + env(safe-area-inset-top)) 20px 18px;
  background-color: var(--moos);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='120' viewBox='0 0 420 120' fill='none' stroke='%23ffffff' stroke-opacity='.13' stroke-width='1.2'%3E%3Cpath d='M-10 96C60 70 110 104 170 82S280 40 340 62 410 80 440 58'/%3E%3Cpath d='M-10 80C55 54 112 88 170 66S282 26 342 46 412 64 440 42'/%3E%3Cpath d='M-10 64C52 38 114 72 170 50S284 12 344 30 414 48 440 26'/%3E%3Cpath d='M-10 112C66 88 108 120 172 98S278 56 338 78 408 96 440 74'/%3E%3C/svg%3E");
  background-size: cover; background-position: right bottom;
  color: var(--kopf-text);
}
.kopf h1 { font-size: 1.35rem; font-weight: 750; }
.verbindung { margin: .15rem 0 0; font-size: .92rem; opacity: .85; }
.verbindung.aus { opacity: 1; font-weight: 650; color: #ffd2bd; }

main { padding: 20px; max-width: 560px; margin: 0 auto; }
.hinweis { color: var(--leise); font-size: .93rem; }
.mitte { text-align: center; }
.leise-titel { font-size: .95rem; font-weight: 650; color: var(--leise); margin-bottom: .6rem; }

/* Warnungen */
.warnung {
  background: var(--warn); color: var(--warn-text);
  padding: 12px 14px; border-radius: 6px; margin-bottom: 10px; font-weight: 650;
}
.warnung span { display: block; font-weight: 450; font-size: .92rem; margin-top: 2px; }

/* Lage: Fass + Werte */
.lage { display: grid; grid-template-columns: 112px 1fr; gap: 18px; align-items: center; margin: 6px 0 28px; }
.fass svg { width: 112px; height: auto; display: block; }
.werte { margin: 0; display: grid; gap: 10px; }
.werte div { display: flex; flex-direction: column; }
.werte dt { font-size: .82rem; color: var(--leise); }
.werte dd { margin: 0; font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.werte dd.schlecht { color: var(--warn-schrift); }
.werte dd small { font-weight: 450; color: var(--leise); font-size: .85rem; }

/* Füttern */
.menge { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.chips { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chips button {
  border: 1.5px solid var(--linie); background: var(--flaeche); color: var(--tinte);
  border-radius: 999px; padding: 10px 0; font: inherit; font-weight: 650; min-height: 44px;
  font-variant-numeric: tabular-nums;
}
.chips button[aria-pressed="true"] { background: var(--moos); border-color: var(--moos); color: var(--kopf-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chips button[aria-pressed="true"] { background: var(--moos-hell); border-color: var(--moos-hell); color: #0e1510; } }
:root[data-theme="dark"] .chips button[aria-pressed="true"] { background: var(--moos-hell); border-color: var(--moos-hell); color: #0e1510; }

.rund-klein {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--linie);
  background: var(--flaeche); color: var(--tinte); font: inherit; font-size: 1.4rem; line-height: 1;
  display: grid; place-items: center; flex: none; padding: 0;
}
.kopf .rund-klein { background: transparent; border-color: rgba(255,255,255,.35); color: var(--kopf-text); }

.halten {
  --p: 0deg;
  position: relative; display: block; width: 188px; height: 188px; margin: 0 auto 10px;
  border: 0; background: none; padding: 0; border-radius: 50%;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.halten-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--warn) var(--p), var(--linie) 0);
}
.halten-innen {
  position: absolute; inset: 12px; border-radius: 50%;
  background: var(--warn); color: var(--warn-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .12s ease, background .2s;
  font-weight: 650;
}
.halten-innen strong { font-size: 2.1rem; font-variant-numeric: tabular-nums; line-height: 1; }
.halten.aktiv .halten-innen { transform: scale(.94); }
.halten:disabled .halten-innen { background: var(--leise); }
.halten.gesendet:disabled .halten-innen { background: var(--ok); color: #fff; }

.meldung { min-height: 1.4em; text-align: center; font-weight: 600; }
.meldung.fehler, .fehler { color: var(--warn-schrift); }

.liste { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.liste li {
  background: var(--flaeche); border-radius: 6px; padding: 10px 12px; font-size: .95rem;
  border-left: 4px solid var(--linie);
}
.liste li.ok { border-left-color: var(--ok); }
.liste li.fehler { border-left-color: var(--warn); color: var(--tinte); }
.liste li.wartet { border-left-color: var(--korn); }
.liste li small { display: block; color: var(--leise); }

/* Formulare */
label { display: block; font-weight: 650; margin: 1.1rem 0 .3rem; font-size: .95rem; }
input {
  width: 100%; font: inherit; font-variant-numeric: tabular-nums; color: var(--tinte);
  background: var(--flaeche); border: 1.5px solid var(--linie); border-radius: 8px;
  padding: 11px 12px; min-height: 48px;
}
input:focus-visible, button:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
.knopf {
  display: block; width: 100%; margin-top: 18px; min-height: 52px; border: 0; border-radius: 8px;
  background: var(--moos); color: var(--kopf-text); font: inherit; font-weight: 700;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .knopf { background: var(--moos-hell); color: #0e1510; } }
:root[data-theme="dark"] .knopf { background: var(--moos-hell); color: #0e1510; }
.knopf.zweit { background: transparent; color: var(--tinte); border: 1.5px solid var(--linie); }
.knopf:disabled { opacity: .5; }

.plan-liste { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.plan-liste li { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; align-items: end; }
.plan-liste label { margin: 0 0 .2rem; font-size: .82rem; color: var(--leise); font-weight: 600; }
.plan-leer { color: var(--leise); padding: 14px 0; }

.info { margin: 12px 0 0; display: grid; gap: 8px; }
.info div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--linie); }
.info dt { color: var(--leise); }
.info dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

/* Navigation unten */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--flaeche); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; color: var(--leise); font: inherit; font-weight: 650;
  min-height: 60px; position: relative;
}
.tabs button[aria-current="page"] { color: var(--tinte); }
.tabs button[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 4px; background: var(--warn);
}

@media (prefers-reduced-motion: reduce) { .halten-innen { transition: none; } }
@media (min-width: 700px) { main { padding-top: 32px; } }

/* Fass-Zeichnung (SVG-Klassen, weil Inline-Styles durch die Sicherheitsregel gesperrt sind) */
.fass .rand { fill: none; stroke: var(--tinte); stroke-width: 3; stroke-linejoin: round; }
.fass .reif { fill: none; stroke: var(--tinte); stroke-width: 2.5; }
.fass .korn { fill: var(--korn); }
.fass .deckel { fill: var(--flaeche); stroke: var(--tinte); stroke-width: 3; }
.fass .leer-rand { fill: none; stroke: var(--warn); stroke-width: 3.5; stroke-dasharray: 7 5; stroke-linejoin: round; }
.fass .zeichen { fill: var(--warn); }
.fass .zeichen-text { fill: var(--warn-text); font: 700 22px system-ui, sans-serif; }
.fass .unklar { fill: var(--linie); }

/* Darstellung wählen */
.wahl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.wahl button {
  border: 1.5px solid var(--linie); background: var(--flaeche); color: var(--tinte);
  border-radius: 999px; min-height: 44px; font: inherit; font-weight: 650;
}
.wahl button[aria-pressed="true"] { background: var(--tinte); border-color: var(--tinte); color: var(--bg); }
:root .knopf.zweit { background: transparent; color: var(--tinte); }
