:root {
  --bg: #000;
  --card: #121215;
  --card-border: #1c1c20;
  --text: #e4e4e7;
  --muted: #9f9fa9;
  --faint: #3f3f46;
  --sync: #37373a;
  --green: #00bc7d;  --green-bg: #003428;
  --amber: #fe9a00;  --amber-bg: #322800;
  --red: #ff6467;    --red-bg: rgba(80, 0, 2, 0.7);
  --track: #27272a;
  --font: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums; overscroll-behavior-y: contain;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.home { max-width: 430px; margin: 0 auto; padding: max(env(safe-area-inset-top), 12px) 0 calc(120px + env(safe-area-inset-bottom)); }

/* Top: month picker + sync line */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 0; min-height: 48px; }
.month {
  display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 100px;
  background: #18181b; border: 1px solid #212126; color: var(--muted); font-size: 13px; letter-spacing: 0.26px;
}
.sync { font-size: 13px; letter-spacing: 0.26px; color: var(--sync); }
.sync.warn { color: var(--amber); }

/* Overview */
.overview { display: flex; align-items: center; justify-content: space-between; padding: 32px 16px 12px; }
.hero { font-size: 32px; font-weight: 600; line-height: 1.2; }
.kobo { color: var(--faint); }
.of { margin-top: 6px; font-size: 16px; letter-spacing: 0.32px; color: var(--muted); }
.summary-btn { flex-shrink: 0; }

/* Calendar: two rows of day cells */
.calendar { display: flex; flex-direction: column; gap: 8px; padding: 8px 16px 0; }
.cal-row { display: flex; gap: 8px; }
.day { position: relative; width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; padding: 0; }
.day.outside { background: #0c0c0e; }
.day.none { background: #18181b; }
.day.normal { background: #3987e5; }
.day.heavy { background: var(--amber); }
.day.future { border: 1px solid var(--track); }
.day.today::after { content: ""; position: absolute; inset: -3px; border: 1.5px solid var(--text); border-radius: 6px; }
.day::before { content: ""; position: absolute; inset: -4px; }   /* bigger tap area */
.day-info { min-height: 18px; padding: 10px 16px 0; font-size: 13px; color: var(--muted); letter-spacing: 0.26px; }

/* Groups */
.group-title { padding: 24px 16px 12px; font-size: 18px; font-weight: 600; letter-spacing: 0.72px; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 8px; }

.row, .tile { background: var(--card); border: 1px solid var(--card-border); border-radius: 24px; }
.row { display: flex; align-items: center; justify-content: space-between; padding: 16px; gap: 12px; }
.row-right { display: flex; align-items: center; gap: 24px; flex-shrink: 0; }
.name { font-size: 16px; font-weight: 500; letter-spacing: 0.64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap { margin-top: 6px; font-size: 16px; letter-spacing: 0.32px; color: var(--muted); }
.text { min-width: 0; }

.tile { display: flex; flex-direction: column; justify-content: space-between; gap: 16px; padding: 16px; min-height: 176px; }
.tile .ring-wrap { position: relative; width: 48px; height: 48px; }
.tile .icon { position: absolute; left: 16px; top: 16px; width: 16px; height: 16px; }

.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 100px; font-size: 13px; font-weight: 500; letter-spacing: 0.26px; white-space: nowrap; align-self: flex-start; }
.pill.on-track { background: var(--green-bg); color: var(--green); }
.pill.behind { background: var(--amber-bg); color: var(--amber); }
.pill.over { background: var(--red-bg); color: var(--red); }
.pill.no-cap { background: #1c1c20; color: var(--muted); }
.row .pill { align-self: center; }

.ring { display: block; }
.ring .arc { transition: stroke-dasharray 400ms cubic-bezier(0.22, 1, 0.36, 1); }

/* Pull to sync */
.pull {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; translate: -50% -60px;
  padding: 6px 12px; border-radius: 100px; background: #18181b; border: 1px solid #212126;
  font-size: 13px; color: var(--muted); z-index: 3; transition: translate 200ms ease-out;
}
.pull.show { translate: -50% 0; }

/* Bottom nav (placeholders for now) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.5) 52%);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.nav-group { display: flex; align-items: center; gap: 24px; height: 56px; padding: 4px; border-radius: 100px; }
.nav-btn { display: flex; padding: 12px 24px; border-radius: 100px; }
.nav-btn.active { background: #1b1b1f; border: 1px solid #27272c; box-shadow: inset 0 -4px 6px #242427; }
.nav-profile { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; }
.nav-profile img { border-radius: 50%; }

/* Setup */
.setup { max-width: 430px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 16px 160px; display: flex; flex-direction: column; gap: 8px; }
.setup h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.setup p { color: var(--muted); font-size: 15px; line-height: 1.4; margin-bottom: 16px; }
.setup label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.setup input { font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; padding: 12px; }
.setup input:focus-visible { outline: 2px solid #3987e5; outline-offset: 1px; }
.setup button { margin-top: 16px; padding: 14px; border-radius: 100px; background: var(--text); color: #000; font-weight: 600; }
.setup .error { color: var(--red); font-size: 13px; min-height: 18px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .ring .arc, .pull { transition: none; }
}
