/* Sleeptimer — dunkles Schlafzimmer-Theme.
   Warmer Bernstein statt Blau: die App wird im Dunkeln angeschaut. */

:root {
  --bg:        #0b0c0e;
  --surface:   #15171b;
  --surface-2: #1d2026;
  --line:      #272b33;
  --text:      #ebe7e0;
  --muted:     #8b8880;
  --faint:     #5c5a56;
  --accent:    #e8a33d;
  --accent-sw: #3b2a12;
  --warn:      #e0813f;
  --danger:    #d75f4e;
  --radius:    18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 100dvh;
  max-width: 26rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 20px calc(env(safe-area-inset-bottom) + 18px);
}

/* ── Kopf ──────────────────────────────────────────────── */

.head { display: flex; align-items: center; justify-content: space-between; }

.head h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--muted);
}

.head-state {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-sw);
  border-radius: 999px;
  padding: 4px 11px;
}

/* ── Hinweisbänder ─────────────────────────────────────── */

.banners { display: flex; flex-direction: column; gap: 8px; }
.banners:empty { display: none; }

.banner {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 13px;
  font-size: 14.5px;
  line-height: 1.35;
  border: 1px solid;
}
.banner-warn { color: #f0b48d; background: #241710; border-color: #47291a; }
.banner-info { color: var(--muted); background: var(--surface); border-color: var(--line); }
.banner b { font-weight: 600; }

/* ── Bühne ─────────────────────────────────────────────── */

/* flex-basis muss auto bleiben: mit `flex: 1` (basis 0) wuchs der Container
   nicht mit dem Inhalt mit, die Fusszeile lag unerreichbar unter dem Rand. */
.stage { flex: 1 0 auto; display: flex; align-items: center; }
.panel { width: 100%; }

.prompt {
  margin: 0 0 14px;
  font-size: 19px;
  color: var(--muted);
}
.prompt-small { font-size: 14px; margin-bottom: 10px; }

/* Dauer-Auswahl */

.durations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.dur {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 92px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.dur:active { transform: scale(.97); }
.dur-num { font-size: 30px; font-weight: 300; letter-spacing: -.02em; }
.dur-unit { font-size: 13px; color: var(--muted); }
.dur[aria-pressed="true"] {
  background: var(--accent-sw);
  border-color: var(--accent);
  color: var(--accent);
}
.dur[aria-pressed="true"] .dur-unit { color: var(--accent); opacity: .75; }

.durations-compact .dur { min-height: 62px; }
.durations-compact .dur-num { font-size: 22px; }

/* Countdown */

.countdown {
  font-size: clamp(76px, 25vw, 104px);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text);
}

.sub {
  margin: 14px 0 0;
  text-align: center;
  font-size: 14.5px;
  letter-spacing: .02em;
  color: var(--muted);
}
.sub-fading { color: var(--accent); }

.fadebars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin-top: 16px; height: 26px; }
.fadebars span {
  width: 5px;
  align-self: flex-end;
  border-radius: 2px;
  background: var(--accent);
  animation: fadebar 1.1s ease-in-out infinite;
}
.fadebars span:nth-child(1) { height: 24px; animation-delay: 0s; }
.fadebars span:nth-child(2) { height: 18px; animation-delay: .15s; }
.fadebars span:nth-child(3) { height: 13px; animation-delay: .30s; }
.fadebars span:nth-child(4) { height:  8px; animation-delay: .45s; }
@keyframes fadebar { 0%, 100% { opacity: 1; } 50% { opacity: .35; transform: scaleY(.6); } }
@media (prefers-reduced-motion: reduce) { .fadebars span { animation: none; } }

/* Pausiert */

.paused {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  margin-bottom: 14px;
}
.paused svg { fill: var(--faint); }
.paused span { font-size: 22px; font-weight: 300; letter-spacing: .01em; }

.watchcard {
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-sw);
  margin-bottom: 18px;
}
.watchcard-title { margin: 0 0 6px; font-size: 15.5px; color: var(--accent); }
.watchcard-title b { font-weight: 600; }
.watchcard-body { margin: 0; font-size: 14.5px; line-height: 1.4; color: #c9a877; }

/* Fehler */

.errmark {
  width: 46px; height: 46px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 24px; font-weight: 300;
}
.errtitle { margin: 0 0 8px; text-align: center; font-size: 19px; }
.errbody  { margin: 0; text-align: center; font-size: 15px; line-height: 1.45; color: var(--muted); }

/* ── Hauptaktion ───────────────────────────────────────── */

.action {
  appearance: none;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: 500 17px/1 inherit;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.action:active { transform: scale(.985); }
.action-strong { border-color: var(--accent); color: var(--accent); background: var(--accent-sw); }

/* ── Einstellungen ─────────────────────────────────────── */

.settings { border-top: 1px solid var(--line); }
.settings > .row:last-child { border-bottom: none; }

.summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  list-style: none;
  cursor: pointer;
}
.summary::-webkit-details-marker { display: none; }
.summary-label { font-size: 15.5px; color: var(--muted); flex: none; }
.summary-value { font-size: 13px; }
.summary-value {
  flex: 1;
  text-align: right;
  font-size: 14px;
  color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.summary-chev {
  flex: none;
  width: 9px; height: 9px;
  border-right: 1.6px solid var(--faint);
  border-bottom: 1.6px solid var(--faint);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .18s;
}
.settings[open] .summary-chev { transform: rotate(225deg) translate(-2px, -2px); }
.settings[open] .summary { border-bottom: 1px solid var(--line); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row-label { flex: 1; font-size: 15.5px; color: var(--muted); }
.row-label b { font-weight: 500; color: var(--text); }

.switch { position: absolute; opacity: 0; pointer-events: none; }
.track {
  flex: none;
  width: 46px; height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background .18s, border-color .18s;
}
.track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--faint);
  transition: transform .18s, background .18s;
}
.switch:checked + .track { background: var(--accent-sw); border-color: var(--accent); }
.switch:checked + .track::after { transform: translateX(18px); background: var(--accent); }
.switch:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Fuss ──────────────────────────────────────────────── */

.foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--faint);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #3f7a4e; flex: none; }
.dot.is-stale { background: var(--warn); }

/* ── Zustandsumschalter (nur im Mock-Modus) ────────────── */

.mockbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; gap: 6px; justify-content: flex-start; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
  padding: 9px 10px calc(env(safe-area-inset-bottom) + 9px);
  background: #000c;
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.mockbar::-webkit-scrollbar { display: none; }
.mockbar a {
  flex: none;
  font-size: 12px; text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
}
.mockbar a.is-on { color: var(--accent); border-color: var(--accent); }
body.has-mockbar .app { padding-bottom: 64px; }

/* ── PIN-Abfrage ───────────────────────────────────────── */

.pinform { display: flex; flex-direction: column; gap: 12px; }

.pininput {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 400 22px/1 inherit;
  letter-spacing: .25em;
  text-align: center;
}
.pininput:focus { outline: none; border-color: var(--accent); }
