/* Tagessystem — warm, ruhig, dunkel zuerst */

:root {
  --grund: #221711;
  --flaeche: #2f2119;
  --flaeche-2: #3b2a20;
  --linie: #4a3529;
  --text: #fdf7e7;
  --leise: #ab867c;
  --gold: #fbc64b;
  --orange: #f67a31;
  --rot: #ec483c;
  --auf-gold: #221711;
  --gold-text: #fbc64b;
  --orange-text: #f67a31;
  --rot-text: #ff7a6e;
  --gruen: #b9d97a;
  --schatten: 0 1px 0 rgb(0 0 0 / 0.25);
  --radius: 16px;
  --radius-klein: 10px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --grund: #fdf7e7;
    --flaeche: #fffcf3;
    --flaeche-2: #f4e8d0;
    --linie: #e3d1b3;
    --text: #221711;
    --leise: #7a5a50;
    --gold: #fbc64b;
    --orange: #e0651c;
    --rot: #c9362b;
    --auf-gold: #221711;
    --gold-text: #8a5d00;
    --orange-text: #b24c10;
    --rot-text: #b52c22;
    --gruen: #4f7a1c;
    --schatten: 0 1px 2px rgb(34 23 17 / 0.08);
    color-scheme: light;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 36rem;
  margin: 0 auto;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5rem;
}
h1 { font-size: 1.35rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; color: var(--leise); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.8rem; }
p { margin: 0 0 0.6rem; }
h2:focus, h1:focus { outline: none; }

.leise { color: var(--leise); }
.klein { font-size: 0.875rem; }
.mitte { text-align: center; }
.fehler { color: var(--rot-text); }
.fehler:empty { display: none; }
.stapel > * + * { margin-top: 12px; }

/* ------------------------------------------------------------ Kopf */

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 48px;
}
.kopf .datum { font-size: 0.95rem; color: var(--leise); margin: 0; }
.kopf h1 { margin: 0; }

/* ----------------------------------------------------------- Karten */

.karte {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--schatten);
}
.karte + .karte,
.abschnitt + .abschnitt { margin-top: 12px; }
.abschnitt:empty { display: none; }
.abschnitt:empty + .abschnitt { margin-top: 0; }

.karte.hervor {
  border-color: var(--gold);
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 14%, var(--flaeche)), var(--flaeche));
}

.zustand { text-align: center; padding: 20px 16px; }
.zustand .label { color: var(--leise); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 4px; }
.zustand .titel { font-size: 1.3rem; font-weight: 650; margin: 0 0 6px; overflow-wrap: anywhere; }
.countdown {
  font-size: clamp(3rem, 18vw, 4.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 8px 0 14px;
  color: var(--gold-text);
}
.zustand.abgelaufen { border-color: var(--rot); background: color-mix(in srgb, var(--rot) 14%, var(--flaeche)); }
.zustand.abgelaufen .countdown { color: var(--rot-text); }
.zustand.termin .gross { font-size: 1.6rem; font-weight: 700; color: var(--orange-text); margin: 6px 0 0; }
.zustand.frei .gross { font-size: 2rem; font-weight: 700; color: var(--gold-text); margin: 0; }

.marke {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--flaeche-2);
  color: var(--text);
  border: 1px solid var(--linie);
  vertical-align: middle;
  white-space: nowrap;
}
.marke.vorlesung { border-color: var(--orange); color: var(--orange-text); }
.marke.gut { border-color: var(--gruen); color: var(--gruen); }

/* --------------------------------------------------------- Knoepfe */

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

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--radius-klein);
  border: 1px solid var(--linie);
  background: var(--flaeche-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  user-select: none;
}
.knopf:hover { border-color: var(--leise); }
.knopf:active { transform: translateY(1px); }
.knopf[disabled],
.knopf[aria-busy="true"] { opacity: 0.55; cursor: progress; }
.knopf.primaer { background: var(--gold); border-color: var(--gold); color: var(--auf-gold); }
.knopf.orange { background: var(--orange); border-color: var(--orange); color: #221711; }
.knopf.gefahr { color: var(--rot-text); border-color: color-mix(in srgb, var(--rot) 60%, var(--linie)); background: transparent; }
.knopf.scharf { background: var(--rot); border-color: var(--rot); color: #fff; }
.knopf.flach { background: transparent; border-color: transparent; color: var(--leise); }
.knopf.flach:hover { color: var(--text); }
.knopf.breit { width: 100%; }
.knopf.klein { min-height: 44px; padding: 6px 12px; font-size: 0.9rem; }
.knopf.icon { min-width: 44px; padding: 0; font-size: 1.3rem; }

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.knopfreihe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.knopfreihe.drei { grid-template-columns: repeat(3, 1fr); }
.knopfreihe .ganz { grid-column: 1 / -1; }
.zeile { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.zeile.zwischen { justify-content: space-between; }

/* --------------------------------------------------------- Formulare */

label.feld { display: block; font-size: 0.9rem; color: var(--leise); margin-bottom: 4px; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-klein);
  border: 1px solid var(--linie);
  background: var(--grund);
  color: var(--text);
}
input::placeholder { color: var(--leise); opacity: 0.8; }
input:focus-visible { outline: 3px solid var(--orange); outline-offset: 0; border-color: var(--orange); }

.eingabe-zeile {
  display: grid;
  grid-template-columns: 1fr 5.5rem;
  gap: 8px;
  align-items: end;
}
.eingabe-zeile .einheit-wrap { position: relative; }
.einheit { color: var(--leise); font-size: 0.9rem; }

.schritt-zeile {
  display: grid;
  grid-template-columns: 1fr 4.5rem auto 44px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.schritt-zeile.ohne-entfernen { grid-template-columns: 1fr 4.5rem auto; }

/* Chips als Radio/Checkbox/Toggle */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--linie);
  background: var(--flaeche-2);
  font-weight: 600;
  cursor: pointer;
}
button.chip[aria-pressed="true"],
.wahl input:checked + .chip {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--auf-gold);
}
.wahl { position: relative; display: inline-flex; }
.wahl input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.wahl input:focus-visible + .chip { outline: 3px solid var(--orange); outline-offset: 2px; }

.grund {
  display: inline-block;
  font-size: 0.78rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--orange) 18%, transparent);
  color: var(--orange-text);
  margin: 2px 4px 0 0;
}

/* ---------------------------------------------------------- Listen */

.liste { list-style: none; margin: 0; padding: 0; }
.liste > li + li { border-top: 1px solid var(--linie); }
.liste > li { padding: 10px 0; }

.termin-zeile { display: grid; grid-template-columns: 6.8rem 1fr; gap: 8px; align-items: baseline; }
.termin-zeile .zeit { font-variant-numeric: tabular-nums; color: var(--leise); }
.termin-zeile.vorbei { opacity: 0.55; }
.termin-zeile.jetzt .zeit { color: var(--orange-text); font-weight: 700; }

.vorschlag {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}
.vorschlag + .vorschlag { margin-top: 8px; }
.vorschlag-start {
  text-align: left;
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: var(--radius-klein);
  border: 1px solid var(--linie);
  background: var(--flaeche-2);
  cursor: pointer;
}
.vorschlag-start:hover { border-color: var(--gold); }
.vorschlag-start .t { font-weight: 650; display: block; overflow-wrap: anywhere; }
.vorschlag-start .m { color: var(--gold-text); font-weight: 700; font-size: 0.9rem; }
.vorschlag .knopf { height: 100%; }

.auswahl-zeile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--linie);
  border-radius: var(--radius-klein);
  background: var(--flaeche-2);
  cursor: pointer;
}
.auswahl-zeile + .auswahl-zeile { margin-top: 8px; }
.auswahl-zeile input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; }
.auswahl-zeile .t { flex: 1; overflow-wrap: anywhere; }
.auswahl-zeile:has(input:checked) { border-color: var(--gold); }

/* -------------------------------------------------------- Fortschritt */

.balken {
  height: 10px;
  border-radius: 999px;
  background: var(--flaeche-2);
  border: 1px solid var(--linie);
  overflow: hidden;
}
.balken > span {
  display: block;
  height: 100%;
  background: var(--orange);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.balken.voll > span { background: var(--gold); }
.teil + .teil { margin-top: 10px; }
.teil .zeile { justify-content: space-between; font-size: 0.95rem; margin-bottom: 4px; }
.teil .wert { font-variant-numeric: tabular-nums; color: var(--leise); }

.balken-zeile + .balken-zeile { margin-top: 10px; }
.balken-zeile .zeile { justify-content: space-between; flex-wrap: nowrap; margin-bottom: 4px; }
.balken-zeile .name { overflow-wrap: anywhere; }
.balken-zeile .wert { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--leise); }

.satz {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-left: 4px solid var(--gold);
  background: var(--flaeche-2);
  border-radius: 0 var(--radius-klein) var(--radius-klein) 0;
  font-size: 1.05rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.satz.orange { border-left-color: var(--orange); }
.satz.gross { font-size: 1.3rem; font-weight: 600; padding: 16px 18px; }
.satz-label { font-size: 0.8rem; color: var(--leise); margin: 0 0 4px; }

.status-zeile { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }
.erfuellt { color: var(--gruen); font-weight: 700; }
.offen { color: var(--leise); font-weight: 600; }
.serie { font-weight: 700; color: var(--orange-text); }

/* --------------------------------------------------------- Banner */

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--linie);
  background: var(--flaeche);
}
.banner.warn { border-color: var(--rot); background: color-mix(in srgb, var(--rot) 12%, var(--flaeche)); }
.banner.frage { border-color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, var(--flaeche)); }
.banner p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------- Durchsicht */

.schritt-kopf {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--grund);
  padding-top: max(8px, env(safe-area-inset-top));
  margin-top: calc(-1 * max(12px, env(safe-area-inset-top)));
  padding-bottom: 8px;
}
.fortschritt {
  height: 6px;
  border-radius: 999px;
  background: var(--flaeche-2);
  overflow: hidden;
  margin-top: 6px;
}
.fortschritt > span { display: block; height: 100%; background: var(--gold); transition: width 0.3s ease; }
.schritt-fuss { margin-top: 16px; }
.schritt-fuss .fehler { margin-bottom: 8px; }

.getrennt { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--linie); }

/* ------------------------------------------------------------ Sheet */

.sheet {
  width: min(36rem, 100%);
  max-width: 100%;
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 20px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 1px solid var(--linie);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--flaeche);
  color: var(--text);
  overflow-y: auto;
}
.sheet::backdrop { background: rgb(0 0 0 / 0.55); }
@media (min-width: 40rem) {
  .sheet { margin: auto; border-radius: var(--radius); border-bottom: 1px solid var(--linie); }
}

/* ------------------------------------------------------------ Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(32rem, calc(100% - 32px));
  z-index: 50;
  pointer-events: none;
}
.toast > div {
  background: var(--text);
  color: var(--grund);
  padding: 12px 16px;
  border-radius: var(--radius-klein);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3);
  font-weight: 600;
}
.toast > div.fehler-toast { background: var(--rot); color: #fff; }

.fuss { margin-top: 20px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

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

.vorschlag > :only-child { grid-column: 1 / -1; }
.karte > :last-child,
.banner > :last-child { margin-bottom: 0; }
