:root {
  --bg: #0e111c; --bg2: #161a29; --bg3: #20263a; --line: #2b3249;
  --fg: #eef0f7; --mute: #8a91a8; --accent: #ffb03b; --accent-fg: #1b1300;
  --danger: #ff5d5d; --ok: #48d597;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
input, select, button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5em; }
h2 { font-size: 28px; padding-top: 8px; }
h3 { font-size: 17px; }

.view { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tab { padding: calc(var(--sat) + 16px) 18px calc(var(--sab) + 100px); min-height: 100%; }

/* Login */
.login { display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; padding: 32px; gap: 8px; }
.login-icon { width: 96px; height: 96px; border-radius: 22px; }
.login form { width: 100%; max-width: 320px; display: grid; gap: 12px; }
.login input { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); }
.err { color: var(--danger); min-height: 1.4em; text-align: center; margin: 0; }

/* Buttons */
.btn { border: 0; border-radius: 14px; padding: 14px 18px; background: var(--bg3); font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.98); opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.ghost { background: var(--bg2); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #4a2630; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.big { width: 100%; padding: 20px; font-size: 20px; border-radius: 18px; }
.link { background: none; border: 0; color: var(--accent); padding: 8px 4px; }
.link.strong { font-weight: 700; }

/* Startseite */
.hero { text-align: center; padding: 20px 0 18px; }
.clock { font-size: 76px; font-weight: 200; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.sub { color: var(--mute); }
.list { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.alarm { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--bg2); }
.alarm .meta { flex: 1; min-width: 0; }
.alarm .t { font-size: 40px; font-weight: 300; font-variant-numeric: tabular-nums; line-height: 1.1; }
.alarm .d { color: var(--mute); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alarm.off .t, .alarm.off .d { opacity: .4; }
.empty { color: var(--mute); text-align: center; margin-top: 30px; }
.fab { position: fixed; right: 20px; bottom: calc(var(--sab) + 84px); width: 60px; height: 60px; border-radius: 30px;
  border: 0; background: var(--accent); color: var(--accent-fg); font-size: 34px; line-height: 1;
  box-shadow: 0 6px 20px rgba(0,0,0,.45); }

/* Schalter */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--bg3); transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 28px; height: 28px; border-radius: 14px;
  background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(14,17,28,.92);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  padding-bottom: var(--sab); }
.tabbar button { flex: 1; background: none; border: 0; padding: 8px 0 6px; color: var(--mute); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button span { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--accent); }
.tabbar button.active span { filter: none; opacity: 1; }

/* Karten, Formulare */
.card { background: var(--bg2); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.hint { color: var(--mute); font-size: 15px; }
.hint.center { text-align: center; }
.tips { padding-left: 18px; margin: 0; display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); }
.row.small { border: 0; padding: 4px 0; font-size: 14px; color: var(--mute); }
.row input[type=text], .row select { background: var(--bg3); border: 0; border-radius: 10px; padding: 8px 12px;
  max-width: 60%; text-align: right; -webkit-appearance: none; appearance: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* Motive */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.motif { position: relative; border-radius: 16px; overflow: hidden; background: var(--bg2); aspect-ratio: 1; border: 0; padding: 0; }
.motif img { width: 100%; height: 100%; object-fit: cover; display: block; }
.motif .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.8)); font-weight: 600; }
.motif .n { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); border-radius: 10px; padding: 1px 8px; font-size: 13px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph button { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 15px; border: 0;
  background: rgba(0,0,0,.65); color: #fff; }

/* Bottom-Sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; }
.sheet-body { width: 100%; max-height: 92%; overflow-y: auto; background: var(--bg2); border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(var(--sab) + 18px); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 10px; }
.time-input { display: block; width: 100%; font-size: 56px; font-weight: 300; text-align: center; background: var(--bg3);
  border: 0; border-radius: 16px; padding: 10px; margin: 6px 0 14px; -webkit-appearance: none; appearance: none; min-height: 90px; }
.days { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.days button { flex: 1; aspect-ratio: 1; max-width: 44px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--bg3); font-size: 14px; font-weight: 600; }
.days button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Nachttisch */
.night { background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 30; }
.night-clock { font-size: 26vw; font-weight: 100; color: #6b3d00; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.night-sub { color: #4a3210; font-size: 18px; }
.night-warn { color: #8a4040; font-size: 14px; margin-top: 16px; padding: 0 30px; text-align: center; }
.night-exit { position: absolute; bottom: calc(var(--sab) + 24px); background: none; border: 1px solid #2a1a05; color: #4a3210;
  border-radius: 12px; padding: 10px 22px; }

/* Klingeln */
.ring { background: radial-gradient(circle at 50% 30%, #3b2300, #0e111c 70%); z-index: 40; display: flex; align-items: center; justify-content: center; }
.ring-pulse { position: absolute; top: 18%; left: 50%; width: 220px; height: 220px; margin-left: -110px; border-radius: 50%;
  background: var(--accent); opacity: .18; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.35); opacity: .05; } }
.ring-content { position: relative; width: 100%; max-width: 420px; padding: calc(var(--sat) + 30px) 24px calc(var(--sab) + 24px);
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.ring-time { font-size: 88px; font-weight: 200; font-variant-numeric: tabular-nums; }
.ring-label { font-size: 22px; color: var(--accent); margin-top: -10px; }
.ring-tap { background: rgba(255,176,59,.15); color: var(--accent); padding: 6px 14px; border-radius: 12px; font-size: 14px; }
.ring-motif { display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,.35); border-radius: 16px; padding: 10px; width: 100%; text-align: left; }
.ring-motif img { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; }
.ring .btn.big { background: var(--accent); color: var(--accent-fg); }
.ring-result { min-height: 1.4em; margin: 0; color: var(--danger); font-weight: 600; }

.done { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; z-index: 45;
  background: radial-gradient(circle at 50% 35%, #4a3500, #0e111c 70%); }
.done-sun { font-size: 96px; animation: rise .8s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.done p { color: var(--mute); }

.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 96px); transform: translateX(-50%); z-index: 60;
  background: #2c3350; padding: 12px 18px; border-radius: 14px; max-width: 90%; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.busy { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
