/* ============ Thrive — mobile-first wellness PWA ============ */
:root {
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-900: #134e4a;
  --water: #0284c7;
  --water-light: #e0f2fe;
  --move: #059669;
  --move-light: #d1fae5;
  --sleep: #4f46e5;
  --sleep-light: #e0e7ff;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --rose: #e11d48;
  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #f1f5f7;
  --text: #0f2027;
  --text-muted: #5b6b73;
  --border: #e2e8f0;
  --shadow: 0 4px 16px rgba(15, 32, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 32, 39, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --teal-50: #0b3b38;
    --teal-100: #134e4a;
    --water-light: #0c2e44;
    --move-light: #053526;
    --sleep-light: #1e1b4b;
    --amber-light: #3a2a08;
    --bg: #0b1416;
    --surface: #121f22;
    --surface-2: #1a2a2e;
    --text: #e6f0ef;
    --text-muted: #93a8ac;
    --border: #23363b;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0 0 6px; line-height: 1.2; }
p { margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }
.right { text-align: right; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-600));
  color: #fff;
  box-shadow: var(--shadow);
}
.app-header__brand { display: flex; align-items: center; gap: 10px; }
.app-header__logo { width: 40px; height: 40px; border-radius: 10px; display: block; }
.app-header h1 { font-size: 20px; margin: 0; }
.app-header__date { font-size: 12px; opacity: 0.85; margin: 0; }

/* ---------- Permission banner ---------- */
.perm-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--amber-light); color: var(--text);
  padding: 10px 14px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.perm-banner__text { display: flex; flex-direction: column; flex: 1; }
.perm-banner__text span { color: var(--text-muted); font-size: 12px; }

/* ---------- Layout / views ---------- */
.views {
  max-width: 560px; margin: 0 auto;
  padding: 16px 14px calc(var(--nav-h) + var(--safe-bottom) + 24px);
}
.view { animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card--water { border-left: 4px solid var(--water); }
.card--move { border-left: 4px solid var(--move); }
.card--sleep { border-left: 4px solid var(--sleep); }
.card--amber { border-left: 4px solid var(--amber); }
.card__title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.card__title .emoji { font-size: 20px; }
.card__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.card__row + .card__row { border-top: 1px solid var(--border); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 12px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 44px;
  transition: transform 0.08s ease, filter 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--teal-600); color: #fff; }
.btn--water { background: var(--water); color: #fff; }
.btn--move { background: var(--move); color: #fff; }
.btn--sleep { background: var(--sleep); color: #fff; }
.btn--outline { background: transparent; border-color: currentColor; color: inherit; }
.btn--light { background: #fff; color: var(--teal-700); }
.btn--ghost { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--rose); color: #fff; }
.btn--sm { padding: 8px 14px; min-height: 36px; font-size: 13px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 14px; padding: 12px 6px; text-align: center; cursor: pointer;
  font-family: inherit; color: var(--text); min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.chip strong { font-size: 16px; }
.chip small { color: var(--text-muted); }
.chip:active { background: var(--teal-100); }

/* ---------- Progress ring ---------- */
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; }
.ring { position: relative; width: 190px; height: 190px; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring__track { stroke: var(--surface-2); }
.ring__fill { stroke: var(--water); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.ring__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring__center strong { font-size: 30px; }
.ring__center span { font-size: 12px; color: var(--text-muted); }

/* ---------- Bars / charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding-top: 8px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars__bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: var(--water); min-height: 4px; transition: height 0.4s ease; }
.bars__bar--sleep { background: var(--sleep); }
.bars__label { font-size: 10px; color: var(--text-muted); }
.bars__value { font-size: 10px; color: var(--text-muted); }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--teal-500); transition: width 0.5s ease; }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; font-family: inherit; min-height: 44px;
}
input[type="time"], input[type="number"] { min-height: 44px; }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-block { margin-bottom: 14px; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; inset: 0; background: #94a3b8; border-radius: 999px; transition: 0.2s; cursor: pointer;
}
.switch__slider::before {
  content: ""; position: absolute; height: 24px; width: 24px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .switch__slider { background: var(--teal-600); }
.switch input:checked + .switch__slider::before { transform: translateX(20px); }

/* stepper */
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 20px; cursor: pointer; font-family: inherit;
}
.stepper span { min-width: 64px; text-align: center; font-weight: 700; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 16px rgba(15, 32, 39, 0.06);
}
.bottom-nav__btn {
  flex: 1; background: none; border: none; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; min-height: var(--nav-h);
  font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.bottom-nav__btn.is-active { color: var(--teal-600); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 18, 16, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease;
}
.modal {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + var(--safe-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: sheet-up 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  position: relative;
}
@media (min-width: 620px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 22px; margin: 20px; }
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal__close {
  position: absolute; top: 10px; right: 14px;
  background: var(--surface-2); border: none; width: 36px; height: 36px;
  border-radius: 50%; font-size: 20px; cursor: pointer; color: var(--text);
}
.modal h2 { font-size: 19px; padding-right: 40px; }

/* ---------- Stretch / timer ---------- */
.timer-circle { position: relative; width: 200px; height: 200px; margin: 14px auto; }
.timer-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-circle__track { stroke: var(--surface-2); }
.timer-circle__fill { stroke: var(--move); stroke-linecap: round; }
.timer-circle__text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.timer-circle__text strong { font-size: 38px; font-variant-numeric: tabular-nums; }
.stretch-hero { font-size: 44px; text-align: center; margin: 6px 0; }
.stretch-steps { padding-left: 18px; margin: 10px 0; }
.stretch-steps li { margin-bottom: 8px; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; background: var(--teal-100); color: var(--teal-700);
}
.pill--water { background: var(--water-light); color: var(--water); }
.pill--move { background: var(--move-light); color: var(--move); }
.pill--sleep { background: var(--sleep-light); color: var(--sleep); }
.pill--amber { background: var(--amber-light); color: var(--amber); }

/* ---------- Breathing ---------- */
.breath-circle {
  width: 150px; height: 150px; border-radius: 50%; margin: 24px auto;
  background: radial-gradient(circle at 35% 30%, var(--teal-500), var(--teal-700));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
  transition: transform 4s ease;
  box-shadow: 0 0 40px rgba(13, 148, 136, 0.45);
}
.breath-circle.inhale { transform: scale(1.35); }
.breath-circle.hold { transform: scale(1.35); }
.breath-circle.exhale { transform: scale(0.85); }

/* ---------- Stars (sleep quality / mood) ---------- */
.stars { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.stars button, .mood button {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; width: 52px; height: 52px; font-size: 26px; cursor: pointer;
}
.stars button.is-selected, .mood button.is-selected {
  border-color: var(--teal-600); background: var(--teal-100); transform: scale(1.08);
}
.mood { display: flex; gap: 6px; justify-content: space-between; margin: 10px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
  transform: translateX(-50%); z-index: 80;
  background: var(--teal-900); color: #fff;
  padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Misc ---------- */
.stat-pill { text-align: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 8px; }
.stat-pill strong { display: block; font-size: 20px; }
.stat-pill span { font-size: 11px; color: var(--text-muted); }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.kbd-hint { font-size: 12px; color: var(--text-muted); background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; margin: 18px 4px 8px; }
.big-emoji { font-size: 34px; }
.next-list { margin: 0; padding: 0; list-style: none; }
.next-list li { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.next-list li:last-child { border-bottom: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.dot--water { background: var(--water); }
.dot--move { background: var(--move); }
.dot--sleep { background: var(--sleep); }
.dot--amber { background: var(--amber); }

/* ---------- Phase 2: tools, sync, fuel, badges, insights ---------- */
.card--sync { border-left: 4px solid var(--teal-600); }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool-tile {
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 16px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: inherit; color: var(--text); min-height: 96px; text-align: center;
}
.tool-tile:active { background: var(--teal-100); }
.tool-tile strong { font-size: 14px; }
.tool-tile small { color: var(--text-muted); font-size: 11px; }

.sync-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.sync-dot--ok { background: var(--move); }
.sync-dot--sync { background: var(--amber); animation: pulse 1.2s infinite; }
.sync-dot--off { background: #94a3b8; }
.sync-dot--err { background: var(--rose); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.auth-tabs { display: flex; gap: 8px; }
.auth-tabs .btn { flex: 1; }
.form-error { font-size: 13px; margin: 6px 0; min-height: 18px; }

.fuel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.fuel-grid .chip.is-selected, .chip.act-type.is-selected {
  border-color: var(--teal-600); background: var(--teal-100);
}

.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.badge {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 10px; text-align: center; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.badge strong { font-size: 13px; }
.badge small { color: var(--text-muted); font-size: 11px; }
.badge__emoji { font-size: 28px; }
.badge--locked { opacity: 0.55; filter: grayscale(0.8); }
.badge__date { font-weight: 700; color: var(--teal-700) !important; }

.delta { font-size: 12px; white-space: nowrap; }
.delta--up { color: var(--move); }
.delta--down { color: var(--rose); }
.delta--flat { color: var(--text-muted); }
