/* ------------------------------------------------------------------ *
 * Health — Steps dashboard
 * Modern sports/fitness aesthetic: soft blues, gradient cards, bold
 * numerals. Mobile-first, light & dark aware.
 * ------------------------------------------------------------------ */

:root {
  --brand: #2563eb;
  --brand-2: #06b6d4;
  --accent: #38bdf8;

  --bg: #eef2f9;
  --bg-grad-a: #eaf1ff;
  --bg-grad-b: #e7f6ff;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;
  --border: #e2e8f0;
  --ring-track: #e6edf7;
  --shadow: 0 10px 30px -12px rgba(30, 58, 138, .28);
  --shadow-sm: 0 2px 10px -4px rgba(15, 23, 42, .18);
  --radius: 22px;
  --radius-sm: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070b14;
    --bg-grad-a: #0a1120;
    --bg-grad-b: #08131f;
    --surface: #0f1626;
    --surface-2: #131c2e;
    --text: #f1f5f9;
    --text-soft: #b3c0d6;
    --text-mute: #6b7a94;
    --border: #1e293b;
    --ring-track: #1c2740;
    --shadow: 0 18px 40px -18px rgba(0, 0, 0, .7);
    --shadow-sm: 0 2px 12px -6px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 100% -10%, var(--bg-grad-b), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, var(--bg-grad-a), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 18px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .7);
}
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.topbar-actions { display: flex; gap: 8px; }

.ghost-btn {
  font: inherit; font-size: .85rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 12px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .12s ease, color .15s ease, border-color .15s ease;
}
.ghost-btn:hover { color: var(--brand); border-color: var(--accent); }
.ghost-btn:active { transform: scale(.96); }

/* ---------------- Views ---------------- */
.content { flex: 1; display: flex; flex-direction: column; }
.view { flex: 1; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* Loading spinner */
#loading-view { align-items: center; justify-content: center; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--ring-track);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Sign in / locked ---------------- */
#signin-view, #locked-view { align-items: center; justify-content: center; }
.signin-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 26px;
  text-align: center;
}
.signin-glyph {
  width: 66px; height: 66px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 26px -10px rgba(37, 99, 235, .75);
}
.signin-glyph.locked { background: linear-gradient(135deg, #64748b, #94a3b8); box-shadow: none; }
.signin-card h1 { font-size: 1.45rem; letter-spacing: -.02em; margin-bottom: 8px; }
.signin-card p { color: var(--text-soft); font-size: .95rem; line-height: 1.5; }
.google-btn {
  font: inherit; font-weight: 600; font-size: .95rem;
  margin-top: 22px;
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 18px; border-radius: 14px;
  color: #fff; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), #1d4ed8);
  box-shadow: 0 12px 24px -10px rgba(37, 99, 235, .8);
  transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}
.google-btn svg { background: #fff; border-radius: 4px; padding: 2px; }
.google-btn:hover { filter: brightness(1.05); }
.google-btn:active { transform: scale(.98); }
.google-btn.subtle { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }
.google-btn.subtle svg { display: none; }
.fineprint { margin-top: 16px; font-size: .8rem; color: var(--text-mute); }

/* ---------------- Dashboard ---------------- */
#dashboard-view { gap: 16px; animation: rise .4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.today-date {
  text-align: center;
  color: var(--text-soft);
  font-size: .9rem; font-weight: 600;
  letter-spacing: .01em;
  text-transform: capitalize;
}

/* Hero card with progress ring */
.hero-card {
  position: relative;
  border-radius: var(--radius);
  padding: 26px 20px 30px;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 50% -20%, rgba(56, 189, 248, .35), transparent 60%),
    linear-gradient(135deg, #1e3a8a, #2563eb 45%, #0891b2);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-card::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 80% 120%, rgba(255,255,255,.14), transparent 60%);
  pointer-events: none;
}
.ring-wrap { position: relative; width: min(74vw, 262px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255, 255, 255, .18); stroke-width: 14; }
.ring-progress {
  fill: none; stroke: url(#g); stroke-width: 14; stroke-linecap: round;
  stroke: #eafaff;
  stroke-dasharray: 540.35; /* 2*pi*86, updated by JS */
  stroke-dashoffset: 540.35;
  transition: stroke-dashoffset 1s cubic-bezier(.22,.61,.36,1);
  filter: drop-shadow(0 0 6px rgba(234, 250, 255, .55));
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-align: center;
}
.steps-value {
  font-size: clamp(2.9rem, 13vw, 3.8rem);
  font-weight: 800; line-height: 1; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.steps-label { margin-top: 8px; font-size: .82rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.82); }
.goal-label { margin-top: 6px; font-size: .82rem; color: rgba(255,255,255,.72); font-weight: 500; }

/* Stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  display: block;
  font-size: 1.28rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-label { display: block; margin-top: 4px; font-size: .72rem; font-weight: 600; color: var(--text-mute); letter-spacing: .02em; }

/* Trend card */
.trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px 16px;
  box-shadow: var(--shadow-sm);
}
.trend-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.trend-head h2 { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.synced { font-size: .76rem; color: var(--text-mute); font-weight: 500; }

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 132px;
}
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.bar {
  width: 100%;
  border-radius: 8px 8px 4px 4px;
  min-height: 4px;
  background: linear-gradient(180deg, var(--accent), var(--brand));
  transition: height .7s cubic-bezier(.22,.61,.36,1);
}
.bar.today { background: linear-gradient(180deg, #22d3ee, #0891b2); box-shadow: 0 0 0 2px rgba(8,145,178,.18); }
.bar.empty { background: var(--ring-track); }
.bar-day { font-size: .7rem; font-weight: 600; color: var(--text-mute); }
.bar-col.is-today .bar-day { color: var(--brand); }

/* ---------------- Offline banner ---------------- */
.banner {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 12px;
  font-size: .82rem; font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #b45309, #d97706);
}
.banner .dot { width: 8px; height: 8px; border-radius: 50%; background: #fde68a; box-shadow: 0 0 0 3px rgba(253,230,138,.3); }

@media (max-width: 360px) {
  .stat-value { font-size: 1.12rem; }
  .app { padding-left: 14px; padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
