/* Farben: hell als Grundlage, dunkel automatisch nach dem Gerät oder fest über data-theme */
:root {
  --bg: #f4f2ee;
  --karte: #ffffff;
  --text: #1d2321;
  --leise: #66706c;
  --rand: #dcd8d0;
  --akzent: #1f6f5c;
  --akzent-text: #ffffff;
  --akzent-hell: #e3f1ec;
  --stopp: #b4432f;
  --stopp-hell: #f8e6e2;
  --schatten: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --b0: #1f6f5c;
  --b0-hell: #dcefe8;
  --b1: #4a5fb0;
  --b1-hell: #e2e7f7;
  --ueber: #1f7a4f;
  --unter: #b26a12;
  --unter-hell: #fbefdc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816;
    --karte: #1d2321;
    --text: #e9ece9;
    --leise: #9aa49f;
    --rand: #2f3734;
    --akzent: #4fb596;
    --akzent-text: #0d1f19;
    --akzent-hell: #1c3a31;
    --stopp: #e0735e;
    --stopp-hell: #3d221d;
    --schatten: none;
    --b0: #4fb596;
    --b0-hell: #1c3a31;
    --b1: #8a9cf0;
    --b1-hell: #262d4d;
    --ueber: #5cc58d;
    --unter: #e5a14a;
    --unter-hell: #3a2c17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141816;
  --karte: #1d2321;
  --text: #e9ece9;
  --leise: #9aa49f;
  --rand: #2f3734;
  --akzent: #4fb596;
  --akzent-text: #0d1f19;
  --akzent-hell: #1c3a31;
  --stopp: #e0735e;
    --stopp-hell: #3d221d;
  --schatten: none;
  --b0: #4fb596;
  --b0-hell: #1c3a31;
  --b1: #8a9cf0;
  --b1-hell: #262d4d;
  --ueber: #5cc58d;
  --unter: #e5a14a;
  --unter-hell: #3a2c17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
[hidden] { display: none !important; }
h2 { font-size: 1.25rem; margin: 18px 0 14px; }

.titel { font-size: 1.6rem; margin: 12vh 0 24px; text-align: center; }
form { display: grid; gap: 14px; background: var(--karte); padding: 20px; border-radius: 16px; box-shadow: var(--schatten); }
label { display: grid; gap: 6px; font-size: .95rem; color: var(--leise); }
input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--rand); border-radius: 10px; padding: 12px; width: 100%; min-width: 0;
}
input:focus { outline: 2px solid var(--akzent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; color: inherit; }
.primaer { background: var(--akzent); color: var(--akzent-text); border: 0; border-radius: 10px; padding: 13px; font-weight: 600; }
.sekundaer { background: transparent; color: var(--akzent); border: 1px solid var(--akzent); border-radius: 10px; padding: 12px; font-weight: 600; }
.gefahr { background: transparent; color: var(--stopp); border: 1px solid var(--stopp); border-radius: 10px; padding: 12px; }
.breit { width: 100%; margin: 4px 0 18px; }
.fehler { color: var(--stopp); min-height: 1.2em; margin: 0; }
.hinweis { color: var(--leise); font-size: .88rem; margin: -6px 0 0; }

/* Kopf und Menü */
.kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.link-titel { background: none; border: 0; padding: 6px 0; font-weight: 650; font-size: 1.05rem; }
.menue-knopf {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--rand);
  background: var(--karte); display: grid; place-content: center; gap: 4px; padding: 0;
}
.menue-knopf span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.menue-knopf.offen span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menue-knopf.offen span:nth-child(2) { opacity: 0; }
.menue-knopf.offen span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.menue {
  position: relative; z-index: 5; margin-top: 10px; padding: 10px;
  background: var(--karte); border: 1px solid var(--rand); border-radius: 16px; box-shadow: var(--schatten);
  display: grid; gap: 2px;
}
.menue-wer { color: var(--leise); font-size: .9rem; padding: 6px 10px 10px; border-bottom: 1px solid var(--rand); margin-bottom: 4px; }
.menue-wer strong { color: var(--text); }
.menue-punkt { text-align: left; background: none; border: 0; border-radius: 10px; padding: 11px 10px; }
.menue-punkt:hover, .menue-punkt.aktiv { background: var(--akzent-hell); }
.menue-punkt.leise { color: var(--leise); }
.menue-gruppe { padding: 10px; display: grid; gap: 8px; border-top: 1px solid var(--rand); border-bottom: 1px solid var(--rand); margin: 4px 0; }
.menue-label { color: var(--leise); font-size: .9rem; }
.segment { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--rand); border-radius: 10px; padding: 3px; gap: 3px; }
.segment button { border: 0; background: none; border-radius: 8px; padding: 8px 4px; font-size: .9rem; }
.segment button.aktiv { background: var(--karte); box-shadow: var(--schatten); font-weight: 600; color: var(--akzent); }

/* Erfassen */
.uhr {
  margin: 22px 0 18px; padding: 26px 16px; text-align: center;
  background: var(--karte); border-radius: 20px; box-shadow: var(--schatten);
  border: 2px solid transparent; transition: border-color .3s;
}
.uhr-zeit { font-size: clamp(2.8rem, 15vw, 4.4rem); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.uhr-text { color: var(--leise); margin-top: 4px; }
.uhr.aktiv { border-color: var(--akzent); }
.uhr.aktiv .uhr-text::before {
  content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .45em;
  border-radius: 50%; background: var(--akzent); vertical-align: .05em;
  animation: puls 1.4s ease-in-out infinite;
}
.knoepfe { display: grid; gap: 14px; }
@media (min-width: 520px) { .knoepfe { grid-template-columns: 1fr 1fr; } }
.knopf {
  position: relative; display: grid; gap: 6px; justify-items: center;
  padding: 26px 14px; min-height: 150px; align-content: center;
  background: var(--karte); color: var(--text);
  border: 2px solid var(--rand); border-radius: 20px; box-shadow: var(--schatten);
  transition: transform .08s, background .2s, border-color .2s;
}
.knopf:active { transform: scale(.98); }
.knopf:disabled { opacity: .6; }
.knopf-name { font-size: 1.25rem; font-weight: 650; }
.knopf-zeit { font-variant-numeric: tabular-nums; color: var(--leise); min-height: 1.3em; }
.knopf-aktion { margin-top: 6px; padding: 8px 26px; border-radius: 999px; background: var(--akzent); color: var(--akzent-text); font-weight: 650; }
.knopf.aktiv { background: var(--akzent-hell); border-color: var(--akzent); }
.knopf.aktiv .knopf-aktion { background: var(--stopp); color: #fff; }
.knopf.aktiv::after {
  content: ""; position: absolute; inset: -2px; border-radius: 20px;
  border: 2px solid var(--akzent); animation: ring 1.8s ease-out infinite; pointer-events: none;
}
.heute { text-align: center; color: var(--leise); margin: 20px 0 6px; white-space: pre-line; font-variant-numeric: tabular-nums; }

/* Übersicht */
.monat-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin-top: 14px; }
.monat-nav h2 { text-align: center; margin: 0; }
.rund { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rand); background: var(--karte); font-size: 1.4rem; line-height: 1; }
.rund:disabled { opacity: .35; cursor: default; }
.summen { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.summe { background: var(--karte); border-radius: 14px; padding: 12px 14px; box-shadow: var(--schatten); display: grid; gap: 2px; }
.summe.gesamt { background: var(--akzent-hell); }
.summe-name { color: var(--leise); font-size: .88rem; }
.summe-wert { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.liste { display: grid; gap: 14px; }
.leer { color: var(--leise); text-align: center; margin: 24px 0; }
.tag { background: var(--karte); border-radius: 16px; box-shadow: var(--schatten); overflow: hidden; }
.tag-kopf { display: flex; justify-content: space-between; padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--rand); }
.tag-summe { font-variant-numeric: tabular-nums; color: var(--leise); }
.eintrag {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rand); padding: 11px 14px;
}
.eintrag:last-child { border-bottom: 0; }
.eintrag:hover { background: var(--akzent-hell); }
.eintrag-links, .eintrag-rechts { display: grid; gap: 1px; min-width: 0; }
.eintrag-rechts { justify-items: end; text-align: right; flex-shrink: 0; }
.eintrag-zeit { font-variant-numeric: tabular-nums; font-weight: 600; }
.eintrag-bereich, .eintrag-notiz { color: var(--leise); font-size: .9rem; overflow-wrap: anywhere; }
.eintrag-notiz { font-style: italic; }
.eintrag-dauer { font-variant-numeric: tabular-nums; font-weight: 600; }
.eintrag-marke { font-size: .78rem; color: var(--leise); }
.status-storniert .eintrag-zeit, .status-storniert .eintrag-dauer { text-decoration: line-through; color: var(--leise); }
.status-laeuft .eintrag-dauer { color: var(--akzent); }

/* Formular Nachtragen */
.karte-form fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.karte-form legend { color: var(--leise); font-size: .95rem; margin-bottom: 6px; padding: 0; }
.wahl { display: block; position: relative; }
.wahl input { position: absolute; opacity: 0; pointer-events: none; }
.wahl span {
  display: block; text-align: center; padding: 12px 6px; border-radius: 10px; border: 1px solid var(--rand);
  background: var(--bg); color: var(--text); font-weight: 600;
}
.wahl input:checked + span { background: var(--akzent-hell); border-color: var(--akzent); color: var(--akzent); }
.wahl input:focus-visible + span { outline: 2px solid var(--akzent); outline-offset: 1px; }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Kalender */
.modus { margin-top: 16px; }
.k-kopf { display: grid; justify-items: center; gap: 2px; }
.k-kopf h2 { font-size: 1.08rem; text-align: center; margin: 0; }
.link-klein { background: none; border: 0; color: var(--akzent); padding: 2px 4px; font-size: .9rem; text-decoration: underline; }
.text-leise { color: var(--leise); margin: -4px 0 14px; }
.bilanz { margin: 14px 0; }
.bilanz-zeile { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bilanz-teil { background: var(--karte); border-radius: 14px; padding: 10px 12px; box-shadow: var(--schatten); display: grid; gap: 2px; }
.bilanz-name { color: var(--leise); font-size: .8rem; }
.bilanz-wert { font-size: 1.08rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bilanz-klein { color: var(--leise); font-size: .72rem; }
.bilanz-teil.ueber .bilanz-wert, .bilanz-saldo.ueber { color: var(--ueber); }
.bilanz-teil.unter .bilanz-wert, .bilanz-saldo.unter { color: var(--unter); }
.bilanz-saldo { text-align: center; font-size: .9rem; font-weight: 600; margin-top: 8px; }
.bilanz-leer { background: var(--karte); border-radius: 14px; padding: 12px 14px; color: var(--leise); box-shadow: var(--schatten); }

.raster { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.raster-kopf { text-align: center; color: var(--leise); font-size: .8rem; padding: 2px 0; }
.raster-tag {
  display: grid; align-content: start; justify-items: center; gap: 1px; min-height: 62px; padding: 5px 2px;
  border-radius: 10px; border: 1px solid var(--rand); background: var(--karte);
}
.raster-nr { font-size: .85rem; color: var(--leise); }
.raster-ist { font-weight: 650; font-size: .9rem; font-variant-numeric: tabular-nums; }
.raster-diff { font-size: .7rem; font-variant-numeric: tabular-nums; }
.raster-tag.ueber { background: var(--b0-hell); }
.raster-tag.ueber .raster-diff { color: var(--ueber); }
.raster-tag.unter, .raster-tag.leer-soll { background: var(--unter-hell); }
.raster-tag.unter .raster-diff, .raster-tag.leer-soll .raster-diff { color: var(--unter); }
.raster-tag.zukunft { opacity: .55; }
.raster-tag.feiertag .raster-nr { color: var(--stopp); font-weight: 650; }
.raster-tag.heute { outline: 2px solid var(--akzent); outline-offset: -1px; }

.woche { display: grid; gap: 6px; }
.woche-tag {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; width: 100%;
  text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--rand); background: var(--karte);
}
.woche-tag.heute { border-color: var(--akzent); }
.woche-tag.zukunft { opacity: .6; }
.woche-links, .woche-rechts { display: grid; gap: 1px; }
.woche-rechts { justify-items: end; text-align: right; font-variant-numeric: tabular-nums; }
.woche-name { font-weight: 650; font-size: .95rem; }
.woche-datum { color: var(--leise); font-size: .8rem; }
.woche-feiertag { font-size: .72rem; color: var(--stopp); }
.woche-ist { font-size: .9rem; font-weight: 600; }
.woche-diff { font-size: .78rem; }
.woche-tag.ueber .woche-diff { color: var(--ueber); }
.woche-tag.unter .woche-diff, .woche-tag.leer-soll .woche-diff { color: var(--unter); }
.balken { position: relative; height: 14px; border-radius: 7px; background: var(--bg); overflow: hidden; }
.balken-block { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.balken-block.b0, .leiste-block.b0, .punkt.b0 { background: var(--b0); }
.balken-block.b1, .leiste-block.b1, .punkt.b1 { background: var(--b1); }
.balken-block.laeuft { animation: puls 1.4s ease-in-out infinite; }
.skala { display: grid; grid-template-columns: repeat(5, 1fr); margin: 0 calc(12px + 10px + 70px) 0 calc(12px + 48px + 10px); color: var(--leise); font-size: .7rem; }
.skala span:last-child { text-align: right; }
@media (max-width: 420px) { .woche-tag { gap: 8px; } .skala { display: none; } }

.tagesansicht { display: grid; gap: 10px; }
.tag-bilanz { text-align: center; color: var(--leise); margin: 0; font-variant-numeric: tabular-nums; }
.feiertag-hinweis { text-align: center; color: var(--stopp); margin: 0; font-weight: 600; }
.leiste { position: relative; margin-left: 46px; border-left: 1px solid var(--rand); cursor: copy; background: var(--karte); border-radius: 0 12px 12px 0; }
.leiste-linie { position: absolute; left: 0; right: 0; border-top: 1px solid var(--rand); }
.leiste-zeit { position: absolute; left: -46px; top: -9px; width: 40px; text-align: right; color: var(--leise); font-size: .75rem; font-variant-numeric: tabular-nums; }
.leiste-block {
  position: absolute; left: 6px; right: 6px; border: 0; border-radius: 8px; color: #fff; text-align: left;
  padding: 3px 8px; display: flex; gap: 8px; align-items: flex-start; overflow: hidden; font-size: .85rem; cursor: pointer;
}
.leiste-block.status-storniert { opacity: .35; text-decoration: line-through; }
.leiste-block.status-laeuft { animation: puls 2s ease-in-out infinite; }
.block-zeit { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.block-name { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.punkt { display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .45em; vertical-align: .05em; }
.liste-tag { margin-top: 4px; }

/* Freie Tage */
.raster-frei { font-size: .7rem; color: var(--b1); font-weight: 650; }
.raster-tag.frei-tag { background: repeating-linear-gradient(135deg, var(--karte), var(--karte) 6px, var(--b1-hell) 6px, var(--b1-hell) 12px); }
.woche-frei { font-size: .72rem; color: var(--b1); font-weight: 600; }
.frei-leiste { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.frei-marke { background: var(--b1-hell); color: var(--b1); border-radius: 999px; padding: 4px 12px; font-weight: 650; }
.sekundaer.klein { padding: 7px 12px; font-size: .88rem; }
h2.abstand { margin-top: 30px; }
.f-urlaub { margin: 12px 0 4px; font-weight: 600; color: var(--text); }

/* Mein Soll */
.tage-wahl { grid-template-columns: repeat(7, 1fr) !important; gap: 5px !important; }
.tag-wahl span { padding: 10px 0; font-size: .9rem; }
.wahl input:checked + span.b1 { background: var(--b1-hell); border-color: var(--b1); color: var(--b1); }
.verlauf { margin-top: 18px; }
.verlauf h3 { font-size: 1rem; margin: 0 0 8px; color: var(--leise); }
.verlauf-zeile { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--karte); border-radius: 12px; margin-bottom: 6px; box-shadow: var(--schatten); font-size: .92rem; }
select { appearance: auto; }

/* Meldung unten */
.meldung {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(528px, calc(100% - 32px)); margin: 0; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); text-align: center; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 10;
}
.meldung.sichtbar { opacity: 1; }
.meldung.fehler-meldung { background: var(--stopp); color: #fff; }

@keyframes puls { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes ring { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) {
  .uhr.aktiv .uhr-text::before, .knopf.aktiv::after { animation: none; }
}
