:root {
  --bg: #0b0d10;
  --card: #151a21;
  --card-2: #1d242d;
  --fg: #eef2f6;
  --muted: #8b97a6;
  --line: #28313c;
  --accent: #ff4d2e;
  --prep: #f5c518;
  --work: #22c55e;
  --rest: #3b82f6;
  --warn: #ef4444;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  touch-action: manipulation;
}
#app { padding: 16px 16px calc(var(--nav-h) + 24px); max-width: 720px; margin: 0 auto; }
body.fullscreen #app { max-width: none; padding: 0; }

h1 { font-size: 1.5rem; margin: 0 0 12px; letter-spacing: .02em; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0; }
.error { color: var(--warn); margin: 8px 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); cursor: pointer; user-select: none; -webkit-user-select: none;
}
button:active { filter: brightness(1.2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { border-color: var(--warn); color: var(--warn); background: transparent; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .fixed { flex: 0 0 auto; }
.stack > * + * { margin-top: 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.list { display: grid; gap: 8px; margin-top: 12px; }
.item { text-align: left; width: 100%; display: block; background: var(--card); }
.item .title { font-weight: 600; }
.item .meta { color: var(--muted); font-size: .85rem; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: .9rem; }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--card-2); font-size: .75rem; color: var(--muted); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  border-radius: 999px; min-height: 52px; padding: 0 20px; box-shadow: 0 6px 20px #0008;
}

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #0f1317; border-top: 1px solid var(--line);
}
#nav[hidden] { display: none; }
#nav a {
  flex: 1; display: grid; place-items: center; color: var(--muted); text-decoration: none; font-size: .9rem;
}
#nav a.on { color: var(--fg); font-weight: 600; box-shadow: inset 0 3px 0 var(--accent); }

.editor { padding-bottom: 80px; }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 8px 16px; background: #0f1317ee; border-top: 1px solid var(--line);
}
.actionbar > * { flex: 1; }
.warnband { background: #3a1c1c; color: #ffb4a8; border: 1px solid var(--warn); border-radius: 10px; padding: 6px 10px; font-size: .9rem; }
input.sec { flex: 0 0 84px; text-align: center; }
button.picker { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; }
.overlay-inner { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; }
.login { min-height: 70dvh; display: grid; align-content: center; gap: 12px; }
.brand { font-size: 2rem; font-weight: 800; letter-spacing: .08em; }
.brand span { color: var(--accent); }

/* ---------- Anzeige ---------- */
.display {
  min-height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; padding: 12px 20px 16px;
  background: var(--bg); color: var(--fg); position: relative;
}
.display.phase-prep { background: var(--prep); color: #111; }
.display.phase-work { background: #15803d; }
.display.phase-rest { background: #1d4ed8; }
.display.phase-warn { background: #b91c1c; }
.display.paused { filter: saturate(.4) brightness(.8); }
.d-top { display: flex; align-items: center; gap: 12px; }
.d-top > .d-round { flex: 1; font-size: clamp(1rem, 3vw, 2rem); font-weight: 700; letter-spacing: .04em; }
.d-top button { color: inherit; font-size: 1.4rem; }
.d-main { display: grid; align-content: center; justify-items: center; text-align: center; gap: 4px; }
.d-roundtitle { font-size: clamp(1rem, 3.2vw, 2.2rem); opacity: .85; min-height: 1.2em; }
.d-time { font-size: min(34vw, 40vh); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.d-now { font-size: clamp(1.6rem, 6vw, 5rem); font-weight: 700; line-height: 1.1; }
.d-next { font-size: clamp(1rem, 3vw, 2rem); opacity: .8; }
.d-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; width: 100%; margin-top: 12px; text-align: left; }
.d-overview[hidden] { display: none; }
.d-overview .cell { background: #0003; border-radius: 10px; padding: 8px 10px; font-size: .95rem; }
.d-overview .cell.current { outline: 3px solid currentColor; }
.d-overview .cell.done { opacity: .45; }
.d-overview .meta { opacity: .75; font-size: .8rem; }
.d-strip { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.d-strip .sc { min-width: 26px; padding: 2px 6px; text-align: center; border-radius: 6px; background: #0003; font-size: .8rem; }
.d-strip .sc.current { background: #fff; color: #111; font-weight: 700; }
.d-strip .sc.done { opacity: .4; }
.d-banner { display: flex; justify-content: center; }
.d-banner[hidden], .d-msg[hidden], .d-sheet[hidden] { display: none; }
.d-banner button { font-size: 1.1rem; }
.d-msg { text-align: center; padding: 8px 12px; background: #0006; border-radius: 10px; }
.d-sheet { position: absolute; right: 12px; top: 56px; z-index: 5; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 10px; min-width: 220px; }
.d-sheet h2 { margin: 0; font-size: 1rem; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 1rem; color: var(--fg); margin: 0; }
.switch input { width: 22px; min-height: 0; height: 22px; }
.display.display-off { background: #000; color: #666; }
.display.display-off .d-main, .display.display-off .d-strip { visibility: hidden; }

/* ---------- Fernbedienung ---------- */
.remote { padding-bottom: 8px; }
.r-top { align-items: center; }
.r-code { font-size: 1.2rem; letter-spacing: .08em; }
.r-code b { font-size: 1.6rem; }
.r-phase { font-weight: 700; letter-spacing: .03em; }
.r-readout { display: grid; gap: 4px; text-align: center; }
.r-readout[hidden] { display: none; }
.r-time { font-size: 4.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.r-now { font-size: 1.6rem; font-weight: 700; }
.r-next { color: var(--muted); }
button.big { min-height: 64px; font-size: 1.1rem; }
.r-sheet[hidden] { display: none; }
.remote .d-banner[hidden], .remote .d-msg[hidden] { display: none; }
