/* Design tokens, resets, header, buttons, segmented controls. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #86868b;
  --accent: #0071e3;
  --accent-dark: #0060c0;
  --good: #248a3d;
  --good-bg: #e8f6ec;
  --bad: #d70015;
  --bad-bg: #fdeef0;
  --border: #e5e5ea;
  --radius: 18px;
}

html { font-size: 17px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  min-height: 48px;
  border: none;
  border-radius: 980px;            /* Apple pill */
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0 28px;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: rgba(0,113,227,0.08); }
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 0.95rem; font-family: inherit; cursor: pointer; padding: 8px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: 0 auto 12px;
}
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.user-chip { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.9rem; }
#user-name { font-weight: 600; color: var(--ink); }

/* Segmented control (Apple style) */
.segmented {
  display: flex;
  background: #e9e9ec;
  border-radius: 12px;
  padding: 3px;
  max-width: 900px;
  margin: 0 auto;
}
.seg {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.seg.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  font-weight: 600;
}
.segmented.small { max-width: none; width: max-content; margin: 0; }
.segmented.small .seg { flex: none; min-height: 38px; font-size: 0.9rem; padding: 0 26px; }

#stats-bar {
  max-width: 900px;
  margin: 8px auto 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
main { max-width: 900px; margin: 28px auto; padding: 0 20px 60px; }

.panel { display: none; }
.panel.active { display: block; }

@media (max-width: 740px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .segmented.small { width: 100%; }
  .segmented.small .seg { flex: 1; padding: 0; }
}
