* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--farbe-hintergrund);
  color: var(--farbe-text);
  font-family: var(--schrift);
  font-size: var(--schrift-normal);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

#app {
  position: fixed;
  inset: 0;
  background: var(--farbe-hintergrund);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

#ansicht {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.monat-bereich {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tag-bereich {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--farbe-hintergrund);
}

.wochentage {
  flex: 0 0 var(--wochentage-hoehe);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--zelle-abstand);
  padding: 0 var(--rand-aussen);
  font-size: var(--wochentage-schrift);
  color: var(--farbe-text-leise);
  text-align: center;
  line-height: var(--wochentage-hoehe);
  user-select: none;
}

.monat {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--zelle-abstand);
  padding: 0 var(--rand-aussen) var(--rand-aussen);
  touch-action: pan-y;
}

.woche {
  position: relative;
  flex: 1 0 auto;
  min-height: calc(var(--zahl-hoehe) + var(--termine-pro-tag) * (var(--balken-hoehe) + var(--balken-abstand)) + var(--mehr-hoehe) + 4px);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--zelle-abstand);
}

.tag {
  position: relative;
  background: var(--farbe-zelle);
  border-radius: var(--zelle-radius);
  cursor: pointer;
  user-select: none;
  min-width: 0;
}

.tag.wochenende { background: var(--farbe-zelle-wochenende); }
.tag.fremd { background: var(--farbe-zelle-fremd); }

.tag .zahl {
  height: var(--zahl-hoehe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--zahl-schrift);
  font-weight: var(--zahl-gewicht);
}

.tag.fremd .zahl { color: var(--farbe-text-fremd); }

.tag.heute .zahl span {
  background: var(--farbe-heute);
  color: var(--farbe-heute-text);
  border-radius: 999px;
  min-width: calc(var(--zahl-hoehe) - 3px);
  height: calc(var(--zahl-hoehe) - 3px);
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tag .kw {
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: var(--kw-schrift);
  color: var(--farbe-text-leise);
  font-weight: 400;
}

.tag .mehr {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--zahl-hoehe) + var(--termine-pro-tag) * (var(--balken-hoehe) + var(--balken-abstand)));
  height: var(--mehr-hoehe);
  line-height: var(--mehr-hoehe);
  text-align: center;
  font-size: var(--mehr-schrift);
  color: var(--farbe-text-leise);
  letter-spacing: -1px;
}

.tag .mehr::before { content: var(--mehr-zeichen); }

.balken {
  position: absolute;
  pointer-events: none;
  top: calc(var(--zahl-hoehe) + var(--spur) * (var(--balken-hoehe) + var(--balken-abstand)));
  left: calc(var(--spalte) * ((100% - 6 * var(--zelle-abstand)) / 7 + var(--zelle-abstand)) + var(--balken-einzug));
  width: calc(var(--breite) * ((100% - 6 * var(--zelle-abstand)) / 7) + (var(--breite) - 1) * var(--zelle-abstand) - 2 * var(--balken-einzug));
  height: var(--balken-hoehe);
  line-height: var(--balken-hoehe);
  padding: 0 var(--balken-innenabstand);
  letter-spacing: var(--balken-zeichenabstand);
  border-radius: var(--balken-radius);
  background: var(--farbe);
  color: var(--textfarbe);
  font-size: var(--balken-schrift);
  font-weight: var(--balken-gewicht);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.balken.weiter-links { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.balken.weiter-rechts { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.balken .zeit { display: none; opacity: 0.85; margin-right: 4px; }
.mit-uhrzeit .balken .zeit { display: inline; }

.leiste {
  flex: 0 0 auto;
  height: calc(var(--leiste-hoehe) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--farbe-leiste);
  border-top: 1px solid var(--farbe-linie);
  font-size: var(--leiste-schrift);
  user-select: none;
}

.leiste button {
  height: var(--leiste-hoehe);
  min-width: var(--leiste-knopf-breite);
  flex: 0 0 auto;
  border: 0;
  background: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
}

.leiste button:active { background: var(--farbe-zelle); }
.leiste button.pfeil { min-width: var(--leiste-pfeil-breite); }
.leiste button.titel { flex: 1 1 auto; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding: 0 2px; }
.leiste svg { width: var(--leiste-symbol); height: var(--leiste-symbol); stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.abdunkeln {
  position: fixed;
  inset: 0;
  background: var(--farbe-abdunkeln);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}

.panel {
  background: var(--farbe-panel);
  width: 100%;
  max-width: 560px;
  max-height: 92%;
  overflow-y: auto;
  border-radius: 14px 14px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px var(--farbe-schatten);
}

.panel.voll {
  max-width: 720px;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  padding-top: calc(12px + env(safe-area-inset-top));
}

@media (min-width: 600px) {
  .abdunkeln { align-items: center; }
  .panel { border-radius: 14px; }
  .panel.voll { height: 92%; border-radius: 14px; }
}

.panel h2 { font-size: 18px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .luecke { flex: 1; }
.panel h3 { font-size: 15px; margin: 20px 0 8px; color: var(--farbe-text-leise); font-weight: 600; }
.panel p { margin: 8px 0; line-height: 1.4; }
.panel .hinweis { font-size: var(--schrift-klein); color: var(--farbe-text-leise); }

.feld { display: block; margin-bottom: 12px; }
.feld > span { display: block; font-size: var(--schrift-klein); color: var(--farbe-text-leise); margin-bottom: 4px; }

.feld input[type=text], .feld input[type=number], .feld input[type=password], .feld input[type=date], .feld input[type=time], .feld select, .feld textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--farbe-linie);
  border-radius: 8px;
  background: var(--farbe-eingabe);
  font-size: 16px;
}

.feld textarea { min-height: 80px; resize: vertical; }

.zeile { display: flex; gap: 8px; }
.zeile > * { flex: 1; min-width: 0; }

.haken { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-size: 15px; cursor: pointer; }
.haken input { width: 20px; height: 20px; }

.knoepfe { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.knopf {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--farbe-linie);
  background: var(--farbe-eingabe);
  cursor: pointer;
  font-weight: 500;
}
.knopf.haupt { background: var(--farbe-akzent); color: var(--farbe-akzent-text); border-color: transparent; }
.knopf.gefahr { color: var(--farbe-gefahr); }
.knopf.klein { min-height: 32px; padding: 0 10px; font-size: var(--schrift-klein); }
.knopf:disabled { opacity: 0.5; cursor: default; }
.knopf.schliessen { min-height: 32px; min-width: 32px; padding: 0; border: 0; background: none; font-size: 22px; line-height: 1; }

.fehlertext { color: var(--farbe-gefahr); font-size: 14px; min-height: 18px; margin: 4px 0; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--farbe-linie);
}
.liste li.klickbar { cursor: pointer; }
.liste li .haupt { flex: 1; min-width: 0; }
.liste li .haupt .unter { font-size: var(--schrift-klein); color: var(--farbe-text-leise); }
.liste li .titel-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.punkt { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 14px; background: var(--farbe); }

.farbwahl { width: 44px; height: 32px; border: 0; padding: 0; background: none; cursor: pointer; }

.schalter-liste { display: flex; flex-direction: column; gap: 2px; }
.schalter-liste label { display: flex; align-items: center; gap: 12px; padding: 10px 4px; cursor: pointer; font-size: 16px; }
.schalter-liste input { width: 20px; height: 20px; }

.menue button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 6px;
  border: 0;
  border-bottom: 1px solid var(--farbe-linie);
  background: none;
  cursor: pointer;
  font-size: 16px;
}

.schluessel-anzeige {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 18px;
  letter-spacing: 1px;
  padding: 14px;
  border-radius: 8px;
  background: var(--farbe-eingabe);
  text-align: center;
  word-break: break-all;
  user-select: all;
  white-space: pre-line;
  margin: 12px 0;
}

.balken-vorschau {
  height: 32px;
  line-height: 32px;
  padding: 0 10px;
  border-radius: var(--balken-radius);
  background: var(--farbe);
  color: var(--textfarbe);
  font-size: var(--balken-schrift);
  font-weight: var(--balken-gewicht);
  white-space: nowrap;
  overflow: hidden;
}

.start {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: calc(40px + env(safe-area-inset-top)) 20px 40px;
}
.start .karte { width: 100%; max-width: 400px; }
.start h1 { font-size: 22px; margin: 0 0 20px; }
.start .link { background: none; border: 0; color: var(--farbe-akzent); padding: 8px 0; cursor: pointer; font-size: 14px; }

.meldung {
  position: fixed;
  left: 50%;
  bottom: calc(var(--leiste-hoehe) + env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  background: var(--farbe-text);
  color: var(--farbe-hintergrund);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 30;
  max-width: 90%;
  box-shadow: 0 4px 16px var(--farbe-schatten);
}
.meldung.fehler { background: var(--farbe-gefahr); color: #fff; }

.warten { opacity: 0.6; pointer-events: none; }

.wdh-block {
  padding: 10px 10px 0;
  border: 1px solid var(--farbe-linie);
  border-radius: 8px;
  margin-bottom: 12px;
}
.intervall-zeile { align-items: center; }
.intervall-zeile input { flex: 0 0 90px; }
.einheit { flex: 1; }
.wt-zeile { display: flex; gap: 4px; }
.wt-knopf { flex: 1; position: relative; cursor: pointer; }
.wt-knopf input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.wt-knopf span {
  display: block;
  text-align: center;
  padding: 9px 0;
  border: 1px solid var(--farbe-linie);
  border-radius: 6px;
  background: var(--farbe-eingabe);
  font-size: var(--schrift-klein);
}
.wt-knopf input:checked + span { background: var(--farbe-akzent); color: var(--farbe-akzent-text); border-color: transparent; }

.tagesansicht { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.ganztags {
  flex: 0 0 auto;
  max-height: var(--ganztag-max-hoehe);
  overflow-y: auto;
  padding: 4px var(--rand-aussen) 4px calc(var(--zeitspalte-breite) + 2px);
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-bottom: 1px solid var(--farbe-linie);
}
.ganztags.leer { display: none; }

.ganztag-balken, .block {
  border: 0;
  border-radius: var(--block-radius);
  background: var(--farbe);
  color: var(--textfarbe);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: var(--block-schrift);
  line-height: 1.25;
  overflow: hidden;
  min-width: 0;
}
.ganztag-balken { padding: 4px 8px; width: 100%; }

.ganztag-balken .titel-text, .block .titel-text {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ganztag-balken .klein, .block .klein {
  font-size: var(--block-klein-schrift);
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.block .notiz { white-space: normal; }

.zeit-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }

.zeitachse {
  position: relative;
  height: calc(24 * var(--stunde-hoehe));
  margin: 8px var(--rand-aussen) 8px 0;
}

.stunde {
  position: absolute;
  left: var(--zeitspalte-breite);
  right: 0;
  top: calc(var(--s) * var(--stunde-hoehe));
  height: var(--stunde-hoehe);
  border-top: 1px solid var(--farbe-linie);
}
.stunde span {
  position: absolute;
  left: calc(-1 * var(--zeitspalte-breite));
  width: calc(var(--zeitspalte-breite) - 6px);
  top: -7px;
  text-align: right;
  font-size: var(--zeitspalte-schrift);
  color: var(--farbe-text-leise);
}

.block {
  position: absolute;
  top: calc(var(--start) * var(--stunde-hoehe) / 60 + 1px);
  height: calc(var(--dauer) * var(--stunde-hoehe) / 60 - 2px);
  left: calc(var(--zeitspalte-breite) + 2px + var(--spalte) * (100% - var(--zeitspalte-breite) - 2px) / var(--spalten));
  width: calc((100% - var(--zeitspalte-breite) - 2px) / var(--spalten) - 2px);
  padding: 2px 6px;
}
.block.kurz { flex-direction: row; gap: 6px; align-items: center; }

.jetzt {
  position: absolute;
  left: var(--zeitspalte-breite);
  right: 0;
  top: calc(var(--start) * var(--stunde-hoehe) / 60);
  height: 2px;
  background: var(--farbe-jetzt);
  z-index: 2;
  pointer-events: none;
}
.jetzt::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--farbe-jetzt);
}

.tag:has(.mehr) .kw { display: none; }

.tag.feiertag .zahl { color: var(--farbe-feiertag-zahl); }
.tag.feiertag.heute .zahl span { background: var(--farbe-feiertag-zahl); color: #fff; }
.tag.fremd.feiertag .zahl { opacity: 0.6; }

.ferien-streifen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--ferien-streifen-hoehe);
  background: var(--farbe-ferien);
  border-radius: var(--zelle-radius) var(--zelle-radius) 0 0;
}
.tag.fremd .ferien-streifen { opacity: 0.5; }

.ferien-zeile {
  font-size: var(--schrift-klein);
  color: var(--farbe-text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.ferien-zeile::before {
  content: "";
  width: 14px;
  height: 4px;
  border-radius: 2px;
  background: var(--farbe-ferien);
  flex: 0 0 14px;
}
.ganztag-balken.feiertag { cursor: default; }

.anleitung { margin: 4px 0 16px; padding-left: 20px; line-height: 1.45; font-size: 15px; }
.anleitung li { margin-bottom: 4px; }
.import-liste { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.import-eintrag {
  border: 1px solid var(--farbe-linie);
  border-radius: 8px;
  padding: 10px 10px 0;
}
.import-eintrag > .titel-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feld input[type=file] { width: 100%; font-size: 15px; }

.tag .zahl small {
  font-size: var(--monatsname-schrift);
  font-weight: 600;
  margin-left: 3px;
}

html, body { background: var(--farbe-leiste); }

@media (display-mode: standalone) {
  html, body { height: 100lvh; }
  #app { bottom: auto; height: 100lvh; }
}

.farbfelder { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.farbfeld {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  background: var(--farbe);
  cursor: pointer;
  padding: 0;
}
.farbfeld.aktiv { border-color: var(--farbe-text); }
.heute-vorschau {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 17px;
  background: var(--farbe-heute);
  color: var(--farbe-heute-text);
}

.einstellung-zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; }
.einstellung-zeile .farbwahl { width: 60px; height: 36px; }

.kal-farbe { display: flex; align-items: center; gap: 8px; }
.kal-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
