:root {
  --grund: #f4f5f7;
  --flaeche: #ffffff;
  --rand: #dfe2e8;
  --text: #1c1f26;
  --text-leise: #5d6472;
  --akzent: #4f63d2;
  --akzent-text: #ffffff;
  --balken: #4f63d2;
  --balken-leise: #c9d0f2;
  --spur: #e8eaf0;
  --gut: #1f7a4d;
  --warn: #a8530b;
  --fehler: #b3261e;
  --schatten: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 14px rgba(20, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #15171c;
    --flaeche: #1f222a;
    --rand: #323743;
    --text: #eceef3;
    --text-leise: #a3aaba;
    --akzent: #8496f0;
    --akzent-text: #12141a;
    --balken: #8496f0;
    --balken-leise: #3b4470;
    --spur: #2c303b;
    --gut: #5fce98;
    --warn: #f0a45c;
    --fehler: #f2867f;
    --schatten: none;
  }
}

* { box-sizing: border-box; }

/* Eigene display-Regeln schlagen sonst das hidden-Attribut des Browsers. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p { margin: 0; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 92px);
}

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.kopf h1 { font-size: 1.5rem; letter-spacing: -.01em; }

.tagwahl { display: flex; align-items: center; gap: 4px; }
.rund {
  width: 40px; height: 40px;
  border: 1px solid var(--rand); border-radius: 50%;
  background: var(--flaeche);
  font-size: 1.3rem; line-height: 1;
}
.rund:disabled { opacity: .35; cursor: default; }
.tagname {
  min-width: 112px; height: 40px; padding: 0 12px;
  border: 1px solid var(--rand); border-radius: 20px;
  background: var(--flaeche);
  font-weight: 600;
}

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--schatten);
}
.karte + .karte, .raster + .karte, .karte + .raster { margin-top: 12px; }
.raster > .karte { margin-top: 0; }
.karte h2 { font-size: 1rem; margin-bottom: 10px; }
.karte h2 small { font-weight: 400; color: var(--text-leise); }

.raster { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .raster { grid-template-columns: repeat(3, 1fr); } }

.kachel .name { color: var(--text-leise); font-size: .9rem; }
.kachel .wert { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: 2px 0 8px; }
.kachel .wert.leer { color: var(--text-leise); font-weight: 500; font-size: 1.2rem; padding: 8px 0; }
.kachel .stand { font-size: .88rem; color: var(--text-leise); margin-top: 8px; }
.kachel .stand.gut { color: var(--gut); }
.kachel .stand.warn { color: var(--warn); }

.spur { height: 8px; border-radius: 4px; background: var(--spur); overflow: hidden; }
.spur > i { display: block; height: 100%; border-radius: 4px; background: var(--balken); }

.schlafkarte { border-color: var(--akzent); }
.schlafkarte .zeiten { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.schlafkarte label { display: grid; gap: 4px; font-size: .85rem; color: var(--text-leise); }
.schlafkarte .dauer { font-weight: 700; font-size: 1.15rem; padding-bottom: 9px; }
.schlafkarte .knoepfe { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

input[type="time"], input[type="number"], input[type="password"], input[type="text"] {
  height: 44px; padding: 0 12px;
  border: 1px solid var(--rand); border-radius: 10px;
  background: var(--grund);
  min-width: 0;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

.knopf {
  height: 44px; padding: 0 18px;
  border: 1px solid var(--rand); border-radius: 12px;
  background: var(--flaeche);
  font-weight: 600;
}
.knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf:disabled { opacity: .5; cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--akzent); font-weight: 600; text-decoration: underline; }

.wahl { display: inline-flex; border: 1px solid var(--rand); border-radius: 12px; overflow: hidden; background: var(--flaeche); margin-bottom: 12px; }
.wahl button { border: 0; background: none; height: 40px; padding: 0 14px; font-weight: 600; color: var(--text-leise); }
.wahl button.aktiv { background: var(--akzent); color: var(--akzent-text); }

.diagramm svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.diagramm .achse { fill: var(--text-leise); font-size: 11px; }
.diagramm .gitter { stroke: var(--rand); stroke-width: 1; }
.diagramm .ziel { stroke: var(--text-leise); stroke-width: 1.5; stroke-dasharray: 4 4; }
.diagramm .zieltext { fill: var(--text-leise); font-size: 11px; }
.diagramm .balken { fill: var(--balken); }
.diagramm .balken.offen { fill: var(--balken-leise); }
.diagramm .treffer { fill: transparent; }
.diagramm .treffer.an { fill: var(--text); opacity: .07; }
.diagramm .schnitt { color: var(--text-leise); font-size: .88rem; margin-top: 6px; }

details { margin-top: 8px; }
summary { color: var(--text-leise); font-size: .88rem; cursor: pointer; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .9rem; }
th, td { text-align: right; padding: 5px 4px; border-bottom: 1px solid var(--rand); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-leise); font-weight: 600; }

.appliste { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.appliste .zeile { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.appliste .app { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appliste .zahl { color: var(--text-leise); white-space: nowrap; }

.felder { display: grid; gap: 12px; }
.felder label { display: grid; gap: 4px; font-size: .9rem; color: var(--text-leise); }
.felder .paar { display: flex; align-items: center; gap: 8px; color: var(--text); }
.felder .paar input { width: 110px; }
.kopierzeile { display: flex; gap: 8px; }
.kopierzeile input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.hinweis { color: var(--text-leise); font-size: .9rem; margin-top: 8px; }
.schritte-liste { margin: 8px 0 0; padding-left: 20px; color: var(--text-leise); font-size: .9rem; }
.schritte-liste li + li { margin-top: 4px; }

.meldung { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.meldung.schlecht { border-color: var(--fehler); color: var(--fehler); }
.fehler { color: var(--fehler); font-size: .9rem; }
.leer-text { color: var(--text-leise); }

.leiste {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--flaeche);
  border-top: 1px solid var(--rand);
}
.leiste button {
  flex: 1; max-width: 160px;
  display: grid; justify-items: center; gap: 2px;
  border: 0; background: none; padding: 6px 4px;
  border-radius: 10px;
  font-size: .78rem; font-weight: 600; color: var(--text-leise);
}
.leiste button span { font-size: 1.25rem; line-height: 1; }
.leiste button.aktiv { color: var(--akzent); }

.anmeldung { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.anmeldung .karte { width: 100%; max-width: 360px; display: grid; gap: 12px; }
a.knopf { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.anmeldung h1 { font-size: 1.5rem; margin-bottom: 6px; }

.tipp {
  position: fixed; z-index: 5; pointer-events: none;
  background: var(--text); color: var(--grund);
  padding: 6px 10px; border-radius: 8px;
  font-size: .85rem; line-height: 1.3;
  transform: translate(-50%, -100%);
  white-space: nowrap;
}

@media (hover: hover) {
  .knopf:not(:disabled):hover, .rund:not(:disabled):hover, .tagname:hover { border-color: var(--akzent); }
  .leiste button:hover { color: var(--text); }
}

@media (prefers-reduced-motion: no-preference) {
  .spur > i { transition: width .3s ease; }
}
