:root {
  --bg: #11162b; --card: #1b2340; --ink: #eef0fa; --muted: #98a0c0; --line: #2b3558;
  --moon: #f4e3a1; --accent: #7686f0; --accent-ink: #11162b; --danger: #ef7480; --block: #6b7bd8; --track: #26305a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
header small { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 12px; }
.link { background: none; border: 0; color: var(--muted); font: inherit; padding: 8px; cursor: pointer; }

/* moon: a crescent that glows while she sleeps */
.moon { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px; box-shadow: inset -20px -9px 0 0 var(--moon); opacity: .28; transition: opacity .4s, filter .4s; }
.moon.on { opacity: 1; filter: drop-shadow(0 0 14px rgba(244, 227, 161, .35)); }
.moon.sm { width: 34px; height: 34px; margin: 0; box-shadow: inset -11px -5px 0 0 var(--moon); }
.moon.sm.on { filter: drop-shadow(0 0 8px rgba(244, 227, 161, .35)); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 10px; border-radius: 9px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

.card { background: var(--card); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.hero { text-align: center; padding: 26px 18px 18px; }
.sub { color: var(--muted); font-size: 14px; }
.sub.right { text-align: right; }
.big { font-size: 56px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 6px 0 2px; }
.hero.awake .big { font-size: 44px; }
.total { display: flex; justify-content: space-between; align-items: flex-end; }
.tot { font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.muted { color: var(--muted); }

.track { position: relative; height: 18px; background: var(--track); border-radius: 5px; margin: 14px 0 4px; overflow: hidden; }
.blk { position: absolute; top: 0; bottom: 0; background: var(--block); border-radius: 4px; }
.blk.live { background: var(--moon); opacity: .85; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.btn { display: block; width: 100%; border: 0; border-radius: 16px; padding: 18px; font: inherit; font-size: 18px; font-weight: 600; background: var(--accent); color: var(--accent-ink); cursor: pointer; text-align: center; text-decoration: none; margin-top: 14px; }
.btn:active { transform: scale(.98); }
.btn.moonbtn { background: var(--moon); color: #1b2340; }
.btn.secondary { background: none; border: 2px solid var(--line); color: var(--ink); font-size: 16px; padding: 14px; font-weight: 500; }
.btn.danger { background: none; color: var(--danger); border: 2px solid var(--line); font-size: 16px; padding: 14px; font-weight: 500; }
.btn:disabled { opacity: .5; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border: 0; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.row:first-of-type { border-top: 0; }
.row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--block); margin-top: 6px; }
.day { border-top: 1px solid var(--line); padding: 10px 0; }
.day:first-of-type { border-top: 0; }
.day-head { display: block; width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 0; }
.day-head div { display: flex; justify-content: space-between; }
.banner { background: var(--card); border: 2px dashed var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; font-size: 14px; }
.error { color: var(--danger); min-height: 1.4em; font-size: 14px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input { width: 100%; font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); }
input:focus { outline: none; border-color: var(--accent); }
input { min-width: 0; max-width: 100%; }
/* iOS Safari gives date inputs their own intrinsic width and centred text; pin them to the dialog. */
input[type="datetime-local"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; width: 100%; height: 50px; text-align: left; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; }
input[type="datetime-local"]::-webkit-datetime-edit { padding: 0; }
dialog { overflow-x: hidden; border: 0; border-radius: 18px; padding: 20px; width: min(92vw, 420px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.login { margin-top: 10vh; text-align: left; }
.login .moon { margin: 0 0 14px; opacity: 1; filter: drop-shadow(0 0 14px rgba(244, 227, 161, .35)); }
.login h1 { font-size: 30px; margin-bottom: 18px; }
