/* Arbeitszeit - bewusst gross, ruhig und mit wenig Bedienelementen.
   Handy zuerst; ab 700px wird daraus ein zweispaltiges Layout. */

:root {
  --papier: #f5f2ec;
  --karte: #fffdf9;
  --rand: #e3ddd1;
  --text: #23262a;
  --text-leise: #6d7178;
  --gruen: #4f7a5b;
  --gruen-hell: #e7f0e8;
  --rot: #a6462f;
  --rot-hell: #f7e7e2;
  --schatten: 0 1px 2px rgba(35, 38, 42, .06), 0 8px 24px rgba(35, 38, 42, .05);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier: #16181a;
    --karte: #1e2124;
    --rand: #32373c;
    --text: #eceae5;
    --text-leise: #9aa0a7;
    --gruen: #7fb08d;
    --gruen-hell: #22302a;
    --rot: #e08a72;
    --rot-hell: #33231f;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

/* Muss vor den Layoutregeln stehen: sonst gewinnt z. B. .hintergrund{display:grid}
   gegen das hidden-Attribut und der Dialog ist beim Laden sichtbar. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--papier);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Der Bereich hinter der Notch bleibt frei, sonst klebt die Kopfzeile darunter. */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.ladeschirm {
  display: grid;
  place-items: center;
  min-height: 70vh;
  color: var(--text-leise);
}

main {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

/* ------------------------------------------------------------------ Kopfzeile */

.kopf {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px 18px;
}

.kopf h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
  flex: 1;
}

.kopf-knopf {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-leise);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.kopf-knopf:hover { background: var(--rand); color: var(--text); }
.kopf-knopf svg { width: 22px; height: 22px; fill: currentColor; }

/* --------------------------------------------------------------- Hauptbereich */

.buehne {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 28px 20px;
  text-align: center;
}

.buehne.laeuft {
  border-color: var(--gruen);
  background: var(--gruen-hell);
}

.buehne-hinweis {
  margin: 0 0 18px;
  color: var(--text-leise);
  font-size: 15px;
}

.buehne.laeuft .buehne-hinweis {
  color: var(--gruen);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Der Punkt pulsiert, damit auf einen Blick klar ist: es laeuft gerade. */
.punkt {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gruen);
  animation: pulsieren 2s ease-in-out infinite;
}

@keyframes pulsieren {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.uhr {
  margin: 0 0 6px;
  font-size: clamp(46px, 15vw, 68px);
  font-weight: 300;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.uhr-zusatz {
  margin: 0 0 24px;
  color: var(--text-leise);
  font-size: 15px;
}

/* ------------------------------------------------------------------- Knöpfe */

.knopf {
  border: 1px solid var(--rand);
  border-radius: 12px;
  background: var(--karte);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 12px 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.knopf:hover { border-color: var(--text-leise); }
.knopf.leise { background: transparent; color: var(--text-leise); }
.knopf.leise:hover { color: var(--text); }
.knopf.haupt { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.knopf.gefahr { color: var(--rot); border-color: transparent; background: transparent; }
.knopf.gefahr:hover { background: var(--rot-hell); }
.knopf.breit { width: 100%; }
.knopf:disabled { opacity: .5; cursor: default; }

/* Der wichtigste Knopf der App - bewusst sehr gross und mit dem Daumen erreichbar. */
.riese {
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 14px;
  background: var(--gruen);
  color: #fff;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.riese.stopp { background: var(--rot); }
.riese:active { transform: scale(.99); }

.buehne-fuss {
  margin: 14px 0 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wahl {
  width: 100%;
  margin: 0 0 16px;
  padding: 13px 14px;
  border: 1px solid var(--rand);
  border-radius: 12px;
  background: var(--karte);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  text-align: center;
  text-align-last: center;
}

/* --------------------------------------------------------------- Summenzeile */

.summen {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 28px;
}

.summe {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}

.summe small {
  display: block;
  color: var(--text-leise);
  font-size: 13px;
  margin-bottom: 4px;
}

.summe b {
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------- Liste */

.liste-kopf {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.liste-kopf h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.tag {
  margin-top: 18px;
}

.tag-kopf {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 4px 8px;
}

.tag-kopf b { font-size: 15px; font-weight: 600; }
.tag-kopf span { color: var(--text-leise); font-size: 14px; }
.tag-kopf .fueller { flex: 1; }
.tag-kopf em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
}

.eintrag {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 8px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.eintrag:hover { border-color: var(--text-leise); }

.eintrag-farbe {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--gruen);
  flex: none;
}

.eintrag-text { flex: 1; min-width: 0; }
.eintrag-text b { display: block; font-weight: 500; font-size: 16px; }
.eintrag-text small {
  display: block;
  color: var(--text-leise);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eintrag-dauer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 16px;
  flex: none;
}

.leer {
  text-align: center;
  color: var(--text-leise);
  padding: 36px 20px;
  border: 1px dashed var(--rand);
  border-radius: var(--radius);
}

/* -------------------------------------------------------------------- Dialog */

.hintergrund {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 24, .45);
  display: grid;
  place-items: end center;
  z-index: 50;
  padding: 0;
}

.dialog {
  background: var(--karte);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
}

@media (min-width: 700px) {
  .hintergrund { place-items: center; padding: 20px; }
  .dialog { border-radius: 20px; }
}

.dialog-kopf {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.dialog-kopf h2 { margin: 0; font-size: 19px; font-weight: 600; flex: 1; }

.dialog-hilfe { margin: 0 0 16px; color: var(--text-leise); font-size: 15px; }

.feld { display: block; margin-bottom: 14px; }
.feld > span { display: block; font-size: 14px; color: var(--text-leise); margin-bottom: 6px; }
.feld > span small { font-weight: 400; }

.feld input,
.feld select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--rand);
  border-radius: 11px;
  background: var(--papier);
  color: var(--text);
  font: inherit;
  min-height: 46px;
}

.feld input:focus,
.feld select:focus { outline: 2px solid var(--gruen); outline-offset: 1px; }

.feld-paar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.dialog-dauer {
  margin: 4px 0 0;
  text-align: center;
  color: var(--text-leise);
  font-size: 15px;
}

.dialog-fehler {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--rot-hell);
  color: var(--rot);
  font-size: 15px;
}

/* Auf dem Handy sitzt die Hauptaktion voll breit oben, darunter die beiden
   Nebenaktionen nebeneinander - sonst bricht die Zeile unschoen um. */
.dialog-fuss {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.dialog-fuss .knopf.haupt {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
}

.dialog-fuss .knopf.leise,
.dialog-fuss .knopf.gefahr { flex: 1; }

/* Der Platzhalter schiebt auf dem Handy nur die Knoepfe auseinander. */
.dialog-fuss .fueller { display: none; }

@media (min-width: 520px) {
  .dialog-fuss { align-items: center; }
  .dialog-fuss .fueller { display: block; }
  .dialog-fuss .knopf.haupt { width: auto; order: 3; }
  .dialog-fuss .knopf.leise { flex: none; order: 2; margin-left: auto; }
  .dialog-fuss .knopf.gefahr { flex: none; order: 1; }
}

.fueller { flex: 1; }

/* -------------------------------------------------------------- Kategorien */

.kategorien-liste { margin-bottom: 12px; }

.kategorie-zeile {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.kategorie-zeile input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--rand);
  border-radius: 11px;
  background: var(--papier);
  color: var(--text);
  font: inherit;
  min-height: 46px;
}

.kategorie-zeile input[type="color"] {
  width: 46px;
  height: 46px;
  padding: 2px;
  border: 1px solid var(--rand);
  border-radius: 11px;
  background: var(--papier);
  flex: none;
  cursor: pointer;
}

/* ------------------------------------------------------------------- Analyse */

.kopf-text { padding: 8px 14px; font-size: 15px; }

.analyse-schalter {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 12px;
  margin-bottom: 14px;
}

.analyse-schalter button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-leise);
  font: inherit;
  font-weight: 500;
  padding: 9px;
  cursor: pointer;
}

.analyse-schalter button.aktiv { background: var(--gruen); color: #fff; }

.analyse-navi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.analyse-navi b { font-size: 17px; font-weight: 600; }
.analyse-navi .kopf-knopf { font-size: 30px; }
.analyse-navi .kopf-knopf:disabled { opacity: .25; cursor: default; background: none; }

.kacheln {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 26px;
}

.kachel {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 14px;
}

.kachel small { display: block; color: var(--text-leise); font-size: 13px; margin-bottom: 3px; }
.kachel b { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }

.analyse-titel {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-leise);
}

/* Balkendiagramm: eine Spalte je Tag, Segmente je Kategorie. */
.diagramm {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 190px;
  padding: 0 2px;
  margin-bottom: 28px;
}

.diagramm.schmal { gap: 3px; }

.saeule-spalte {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.saeule-spalte em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-leise);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  height: 14px;
}

/* Die Spur ist immer sichtbar; ein Tag ohne Zeiten zeigt nur sie. */
.saeule {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--rand);
  border-radius: 5px;
  overflow: hidden;
}

.diagramm.schmal .saeule { border-radius: 3px; }

/* Die Fuellung stapelt die Kategorien von unten nach oben. */
.saeule-fuellung {
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  min-height: 0;
}

.saeule-fuellung span { display: block; width: 100%; min-height: 2px; }

.saeule-spalte small {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-leise);
  height: 14px;
  white-space: nowrap;
}

.saeule-spalte.wochenende small { opacity: .55; }
.saeule-spalte.heute small { color: var(--gruen); font-weight: 700; }

/* Kategorien-Aufteilung */
.kat-balken {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--rand);
}

.kat-balken span { display: block; }

.kat-liste { margin-bottom: 12px; }

.kat-zeile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--rand);
}

.kat-zeile:last-child { border-bottom: 0; }

.kat-punkt { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.kat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kat-anteil { color: var(--text-leise); font-variant-numeric: tabular-nums; font-size: 15px; }
.kat-dauer { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 62px; text-align: right; }

@media (min-width: 560px) {
  .kacheln { grid-template-columns: repeat(4, 1fr); }
}

/* ------------------------------------------------------------------- Hinweis */

.hinweis {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--papier);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 90;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: var(--schatten);
}

.hinweis.fehler { background: var(--rot); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
