/* Habit Tracker - Phase 1 visual foundation.
   Glass over drifting color fields. Native system fonts. Quiet motion.
   This file implements the "Look and feel: how to build it" recipe. */

:root {
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --person: #0A84FF;            /* replaced at runtime by chosen person color */
  --partner: #FF9F0A;
  --canvas: #05060A;
  --ink: #F5F5F7;
  --ink-60: rgba(235, 235, 245, 0.6);
  --ink-30: rgba(235, 235, 245, 0.3);
  --glass-hi: rgba(255, 255, 255, 0.13);
  --glass-lo: rgba(255, 255, 255, 0.05);
  --hairline: rgba(255, 255, 255, 0.24);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.40);
  --orb-opacity: 0.38;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --person: #007AFF;
    --partner: #FF9500;
    --canvas: #EEF0F6;
    --ink: #1C1C1E;
    --ink-60: rgba(60, 60, 67, 0.6);
    --ink-30: rgba(60, 60, 67, 0.3);
    --glass-hi: rgba(255, 255, 255, 0.78);
    --glass-lo: rgba(255, 255, 255, 0.46);
    --hairline: rgba(255, 255, 255, 0.95);
    --shadow: 0 16px 40px rgba(30, 30, 70, 0.10);
    --orb-opacity: 0.30;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-text);
  background: var(--canvas);
  color: var(--ink);
  font-size: 17px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Wallpaper: three drifting orbs ---------- */
#wallpaper {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--orb-opacity);
  will-change: transform;
}

.orb-you {
  width: 380px; height: 380px;
  background: var(--person);
  top: -120px; left: -120px;
  animation: drift-a 17s ease-in-out infinite alternate;
}

.orb-partner {
  width: 360px; height: 360px;
  background: var(--partner);
  top: 12%; right: -140px;
  animation: drift-b 19s ease-in-out infinite alternate;
}

.orb-accent {
  width: 360px; height: 360px;
  background: #A259FF;
  bottom: -140px; left: -100px;
  animation: drift-c 16s ease-in-out infinite alternate;
}

@keyframes drift-a { from { transform: translate(0, 0); } to { transform: translate(40px, 36px); } }
@keyframes drift-b { from { transform: translate(0, 0); } to { transform: translate(-38px, 40px); } }
@keyframes drift-c { from { transform: translate(0, 0); } to { transform: translate(36px, -38px); } }

/* ---------- Glass ---------- */
.glass {
  background: linear-gradient(135deg, var(--glass-hi) 0%, var(--glass-lo) 45%, var(--glass-hi) 100%);
  border: 0.5px solid var(--hairline);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -0.5px 0 rgba(255, 255, 255, 0.06),
    var(--shadow);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 24px;
}

/* ---------- App frame ---------- */
#app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.screen {
  padding: 24px 20px 120px;
  min-height: 100dvh;
}

.hidden { display: none !important; }

.placeholder {
  margin-top: 40px;
  padding: 40px 28px;
  text-align: center;
}

.placeholder h1 {
  font-size: 40px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
}

.placeholder p { color: var(--ink-60); margin: 0; }

/* ---------- Tab bar ---------- */
#tabbar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  max-width: 576px;
  margin: 0 auto;
  border-radius: 28px;
  display: flex;
  padding: 8px;
  z-index: 20;
}

.tab {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink-60);
  font-family: var(--font-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 8px;
  min-height: 56px;
  border-radius: 20px;
  cursor: pointer;
}

.tab svg { width: 24px; height: 24px; }
.tab span { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.tab.active { color: var(--person); background: rgba(127, 127, 140, 0.12); }

/* ---------- Buttons (shared by sheets and load-error states) ---------- */
.btn {
  display: block;
  width: 100%;
  max-width: 340px;
  min-height: 52px;
  border: 0;
  border-radius: 18px;
  background: var(--person);
  color: #fff;
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; }

.btn-ghost {
  background: none;
  color: var(--person);
  margin-top: 8px;
}

/* ---------- Onboarding ---------- */
.onb {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 32px 28px calc(40px + env(safe-area-inset-bottom));
  gap: 0;
}

.onb-top {
  width: 100%;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.onb-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0.5px solid var(--hairline);
  background: linear-gradient(135deg, var(--glass-hi), var(--glass-lo));
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  padding: 0;
}

.onb-back svg { width: 20px; height: 20px; }
.onb-back-sp { width: 40px; flex: none; }

.onb-progress {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--ink-30);
  overflow: hidden;
}

.onb-progress i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: #fff;
  transition: width 400ms ease;
}

.onb h1 {
  font-size: 40px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
}

.onb h1 .grad {
  background: linear-gradient(90deg, #0A84FF, #BF5AF2, #FF9F0A);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.onb .lede {
  color: var(--ink-60);
  font-size: 17px;
  line-height: 24px;
  max-width: 320px;
  margin: 0 0 36px;
}

.onb .footnote {
  color: var(--ink-30);
  font-size: 13px;
  line-height: 18px;
  margin-top: 20px;
  max-width: 300px;
}

.onb-kicker {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-60);
  margin: 0 0 10px;
}

.onb-note {
  font-size: 15px;
  line-height: 21px;
  color: var(--ink);
  background: rgba(255, 159, 10, 0.14);
  border: 0.5px solid rgba(255, 159, 10, 0.4);
  border-radius: 14px;
  padding: 10px 14px;
  max-width: 340px;
  margin: 0 0 18px;
}

/* White capsule buttons on onboarding. No 3D shadow. */
.onb .btn {
  display: block;
  width: 100%;
  max-width: 340px;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #111114;
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.onb .btn:active { transform: scale(0.97); }
.onb .btn:disabled { opacity: 0.45; }

/* Welcome: two orbs orbiting and breathing into each other */
.orbit {
  position: relative;
  width: 190px;
  height: 190px;
  margin-bottom: 30px;
}

.orbit i {
  position: absolute;
  top: 50%; left: 50%;
  width: 92px; height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
}

.orbit .o1 { background: #0A84FF; animation: orbit-a 9s linear infinite; }
.orbit .o2 { background: #FF9F0A; animation: orbit-b 9s linear infinite; }

@keyframes orbit-a {
  0%   { transform: rotate(0deg) translateX(48px) scale(1); }
  50%  { transform: rotate(180deg) translateX(48px) scale(1.12); }
  100% { transform: rotate(360deg) translateX(48px) scale(1); }
}

@keyframes orbit-b {
  0%   { transform: rotate(180deg) translateX(48px) scale(1); }
  50%  { transform: rotate(360deg) translateX(48px) scale(1.12); }
  100% { transform: rotate(540deg) translateX(48px) scale(1); }
}

/* Install step */
.phone-mini {
  position: relative;
  width: 200px;
  height: 170px;
  margin: 6px 0 18px;
}

.pm-phone {
  position: absolute;
  left: 55px; top: 10px;
  width: 90px; height: 150px;
  border-radius: 22px;
  border: 2px solid var(--ink-60);
  background: rgba(127, 127, 140, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pm-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(160deg, #0A84FF, #BF5AF2);
  color: #fff;
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in 2.4s ease-in-out infinite;
}

@keyframes pop-in {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

.pm-share {
  position: absolute;
  left: 78px; bottom: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #111114;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: share-pulse 2.4s ease-in-out infinite;
}

.pm-share svg { width: 22px; height: 22px; }

@keyframes share-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0.35); }
  50% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255,255,255,0); }
}

.pm-arrow {
  position: absolute;
  left: 86px; bottom: 52px;
  width: 28px; height: 28px;
  color: #fff;
  animation: arrow-bounce 1.6s ease-in-out infinite;
}

.pm-arrow svg { width: 28px; height: 28px; }

@keyframes arrow-bounce {
  0%, 100% { transform: translateY(6px); opacity: 0.6; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.install-steps {
  list-style: none;
  margin: 0 0 30px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 17px;
  color: var(--ink-60);
}

.install-steps b { color: var(--ink); font-weight: 600; }

.waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-60);
  margin: 0;
}

.pulse-dots { display: inline-flex; gap: 5px; }

.pulse-dots i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-60);
  animation: pdot 1.2s ease-in-out infinite;
}

.pulse-dots i:nth-child(2) { animation-delay: 0.2s; }
.pulse-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes pdot {
  0%, 100% { opacity: 0.25; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Who step: tall person cards */
.person-pick {
  display: flex;
  gap: 20px;
  margin-bottom: 36px;
}

.person-btn {
  border: 0.5px solid var(--hairline);
  background: linear-gradient(135deg, var(--glass-hi), var(--glass-lo));
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 28px;
  width: 140px;
  height: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-text);
  transition: transform 120ms ease;
}

.person-btn:active { transform: scale(0.96); }

.person-btn .avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 28px;
  font-weight: 600;
  color: #fff;
}

.person-btn span { font-size: 17px; font-weight: 600; }

/* Hello step: color flood + liquid picker */
.flood {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: background-color 1s ease, opacity 1s ease;
}

.flood.enter { animation: flood-in 1s ease; }

@keyframes flood-in {
  from { clip-path: circle(0 at 50% 42%); }
  to { clip-path: circle(150% at 50% 42%); }
}

.liq-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 8px;
  max-width: 340px;
  margin: 6px 0 30px;
}

.liq {
  background: none;
  border: 0;
  padding: 4px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: var(--font-text);
}

.liq-sphere {
  position: relative;
  width: 66px; height: 66px;
  border-radius: 50%;
  overflow: hidden;
  border: 0.5px solid var(--hairline);
  background: linear-gradient(160deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03));
  transition: transform 120ms ease, box-shadow 200ms ease;
}

.liq:active .liq-sphere { transform: scale(0.94); }

.liq-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 66%;
  background: linear-gradient(180deg,
    var(--liq-top) 0%,
    var(--liq-base) 18%,
    var(--liq-bottom) 100%);
}

.liq-wave {
  position: absolute;
  top: -4px; left: -25%;
  width: 150%; height: 9px;
  animation: liq-drift 5s linear infinite;
}

.liq-wave path { fill: var(--liq-top); }

@keyframes liq-drift {
  from { transform: translateX(0); }
  to { transform: translateX(-16.66%); }
}

.liq-gloss {
  position: absolute;
  top: 9px; left: 11px;
  width: 30px; height: 14px;
  border-radius: 50%;
  transform: rotate(-24deg);
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0));
  pointer-events: none;
}

.liq-check {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--liq-text);
}

.liq-check svg {
  width: 24px; height: 24px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

.liq[aria-pressed="true"] .liq-check { display: flex; }

.liq[aria-pressed="true"] .liq-sphere {
  box-shadow: 0 0 0 3px #fff, 0 0 26px var(--liq-base);
}

.liq-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-60);
  line-height: 14px;
}

.liq.dim { opacity: 0.35; }

/* On the color step the flood sits behind everything, so text is always
   white: the 0.50 flood opacity was chosen for white text. */
.onb.flooded h1 { color: var(--flood-ink, #fff); }
.onb.flooded .lede { color: var(--flood-ink, #fff); opacity: 0.8; }
.onb.flooded .liq-name { color: var(--flood-ink, #fff); opacity: 0.85; }
.onb.flooded .onb-progress { background: rgba(128, 128, 128, 0.35); }
.onb.flooded .onb-note {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.9);
  color: #111114;
}

/* Handshake step */
.hs-avatars {
  position: relative;
  width: 220px;
  height: 84px;
  margin: 2px 0 6px;
}

.hs-a {
  position: absolute;
  top: 6px;
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 26px;
  font-weight: 600;
  color: #fff;
  transition: left 600ms cubic-bezier(.22,1,.36,1);
}

#hs-me { left: 0; }
#hs-po { left: 148px; }

.hs-avatars.together #hs-me { left: 52px; }
.hs-avatars.together #hs-po { left: 96px; }

.hs-avatars.together {
  filter: drop-shadow(0 0 18px rgba(255,255,255,0.30));
}

.hs-status {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  min-height: 22px;
  margin: 0 0 14px;
}

.token-card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  margin-bottom: 20px;
  text-align: left;
}

.token-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-60);
  margin: 0 0 6px;
}

.token-card input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 0.5px solid var(--hairline);
  background: rgba(127, 127, 140, 0.12);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  padding: 0 14px;
  user-select: text;
  -webkit-user-select: text;
}

.onb-error {
  color: #FF453A;
  font-size: 15px;
  min-height: 22px;
  margin: 12px 0 0;
}

/* Pour step */
.tumbler {
  position: relative;
  width: 120px;
  height: 150px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  margin: 14px 0 22px;
}

.tumbler:disabled { cursor: default; }

.tumbler-glass {
  position: absolute;
  inset: 0;
  border: 3px solid rgba(255,255,255,0.45);
  border-top: 0;
  border-radius: 0 0 26px 26px;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  animation: tumble-pulse 2s ease-in-out infinite;
}

@keyframes tumble-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.85; }
}

.tumbler-fill {
  position: absolute;
  left: 6px; right: 6px; bottom: 6px;
  height: 0;
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  background: linear-gradient(180deg,
    var(--liq-top) 0%,
    var(--liq-base) 25%,
    var(--liq-bottom) 100%);
  transition: height 800ms cubic-bezier(.22,1,.36,1);
}

.tumbler.poured .tumbler-fill { height: calc(100% - 12px); }

.tumbler.poured .tumbler-glass { animation: none; }

.pour-flood {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  transform: translateY(100%);
  background: linear-gradient(180deg,
    var(--liq-top) 0%,
    var(--liq-base) 22%,
    var(--liq-bottom) 100%);
  overflow: hidden;
}

.pour-flood.go { animation: pour-up 1.5s cubic-bezier(.22,1,.36,1) forwards; }

@keyframes pour-up {
  to { transform: translateY(0); }
}

.pour-flood i {
  position: absolute;
  bottom: -20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  animation: bubble-up 1.4s ease-in infinite;
}

.pour-flood i:nth-child(1) { left: 18%; width: 10px; height: 10px; animation-delay: 0.1s; }
.pour-flood i:nth-child(2) { left: 34%; width: 7px; height: 7px; animation-delay: 0.45s; }
.pour-flood i:nth-child(3) { left: 52%; width: 12px; height: 12px; animation-delay: 0.25s; }
.pour-flood i:nth-child(4) { left: 66%; width: 8px; height: 8px; animation-delay: 0.6s; }
.pour-flood i:nth-child(5) { left: 79%; width: 11px; height: 11px; animation-delay: 0.35s; }
.pour-flood i:nth-child(6) { left: 90%; width: 6px; height: 6px; animation-delay: 0.7s; }

@keyframes bubble-up {
  to { transform: translateY(-110vh); }
}

/* Done step */
.done-avatars {
  display: flex;
  justify-content: center;
  margin: 4px 0 22px;
}

.done-a {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 24px;
  font-weight: 600;
  color: #fff;
  border: 3px solid rgba(255,255,255,0.85);
}

.done-a + .done-a { margin-left: -18px; }

/* ---------- Offline banner & toast ---------- */
#offline-banner {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 16px; right: 16px;
  max-width: 568px;
  margin: 0 auto;
  z-index: 40;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 159, 10, 0.92);
  color: #1C1C1E;
}

#toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 20px; right: 20px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 50;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

/* ---------- Numbers ---------- */
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .orb, .orbit i, .pm-icon, .pm-share, .pm-arrow, .pulse-dots i,
  .liq-wave, .tumbler-glass, .pour-flood i { animation: none; }
  .btn, .tab, .person-btn, .liq, .liq-sphere, .tumbler, .hs-a,
  .flood, .tumbler-fill, .pour-flood, .onb-progress i { transition: none; }
  .btn:active, .person-btn:active, .liq:active .liq-sphere { transform: none; }
  .flood { opacity: 1; }
  .pour-flood { transform: none; display: none; }
}

/* ---------- Today screen (Phase 2) ---------- */
#today-root { display: flex; flex-direction: column; gap: 14px; }

.today-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 4px 8px;
  transition: padding 200ms ease;
}

.today-header .title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.today-header h1 {
  font-size: 40px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
  transition: font-size 200ms ease, line-height 200ms ease;
}

.today-header.compact h1 { font-size: 28px; line-height: 32px; }

.today-header .dateline {
  color: var(--ink-60);
  font-size: 15px;
  margin: 2px 0 0;
}

.date-nav { display: flex; gap: 4px; }

.date-nav button {
  width: 48px; height: 48px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-nav button:disabled { opacity: 0.25; }
.date-nav button:active { background: rgba(127, 127, 140, 0.15); }

.summary-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  border: 0;
  width: 100%;
  color: var(--ink);
  font-family: var(--font-text);
  text-align: left;
}

.summary-strip .rings { display: flex; }
.summary-strip .rings svg { width: 44px; height: 44px; }
.summary-strip .rings svg + svg { margin-left: -12px; }

.summary-strip .who { font-size: 15px; font-weight: 600; }
.summary-strip .sub { font-size: 13px; color: var(--ink-60); }

/* Habit rows */
.habit-row {
  border-radius: 26px;
  padding: 18px;
  display: flex;
  gap: 12px;
  align-items: stretch;
  position: relative;
  overflow: hidden;
  --tint: #0A84FF;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--tint) 16%, transparent) 0%, color-mix(in srgb, var(--tint) 2%, transparent) 60%),
    linear-gradient(135deg, var(--glass-hi) 0%, var(--glass-lo) 45%, var(--glass-hi) 100%);
  border: 0.5px solid var(--hairline);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -0.5px 0 rgba(255, 255, 255, 0.06),
    var(--shadow);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}

.row-main { flex: 1 1 75%; min-width: 0; }
.row-partner {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding-left: 12px;
  border-left: 0.5px solid var(--hairline);
  min-width: 76px;
}

.row-partner .pname { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-60); }
.row-partner .pval { font-family: var(--font-num); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row-partner .pdot { width: 10px; height: 10px; border-radius: 50%; }

.habit-name { font-size: 17px; font-weight: 600; margin: 0 0 2px; }
.habit-sub { font-size: 13px; color: var(--ink-60); margin: 0 0 10px; }

.big-num {
  font-family: var(--font-num);
  font-size: 60px;
  line-height: 64px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.big-num small {
  font-size: 20px;
  line-height: 24px;
  color: var(--ink-60);
  font-weight: 500;
  letter-spacing: 0;
}

.tap-hint { font-size: 13px; color: var(--ink-30); margin: 6px 0 0; }

/* Quiet liquid for water */
.liquid-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin-top: 8px;
  background: rgba(127, 127, 140, 0.12);
  min-height: 96px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  cursor: pointer;
  border: 0;
  width: 100%;
  color: var(--ink);
  font-family: var(--font-text);
  text-align: left;
}

.liquid-fill {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  background: linear-gradient(180deg, #64D2FF, #0A84FF);
  opacity: 0.45;
  transition: height 600ms ease;
}

.liquid-wrap .big-num { position: relative; z-index: 1; }

/* Exercise week dots */
.week-dots { display: flex; gap: 10px; margin-top: 10px; }

.day-dot {
  width: 44px; height: 56px;
  border-radius: 14px;
  border: 0.5px solid var(--hairline);
  background: rgba(127, 127, 140, 0.10);
  color: var(--ink-60);
  font-family: var(--font-text);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.day-dot .dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(127, 127, 140, 0.25);
}

.day-dot.done .dot { background: linear-gradient(135deg, #FF6482, #BF5AF2); }
.day-dot.done { color: var(--ink); }
.day-dot.today { outline: 1.5px solid var(--person); outline-offset: 2px; }
.day-dot.locked { opacity: 0.45; cursor: default; }

/* Pending / error dots */
.pending-dot {
  position: absolute;
  top: 14px; right: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-60);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

/* Bottom sheet */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 60;
  opacity: 0;
  transition: opacity 200ms ease;
}

.scrim.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 576px;
  margin: 0 auto;
  z-index: 61;
  padding: 24px;
  border-radius: 28px;
  transform: translateY(24px);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.sheet.show { transform: translateY(0); opacity: 1; }

.sheet h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.sheet .sheet-sub { color: var(--ink-60); font-size: 15px; margin: 0 0 20px; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
}

.stepper button {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 0.5px solid var(--hairline);
  background: rgba(127, 127, 140, 0.14);
  color: var(--ink);
  font-size: 30px;
  cursor: pointer;
}

.stepper .step-val {
  font-family: var(--font-num);
  font-size: 60px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 120px;
  text-align: center;
}

.chips { display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap; }

.chip {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 24px;
  border: 0.5px solid var(--hairline);
  background: rgba(127, 127, 140, 0.14);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.sheet input[type="number"] {
  width: 100%;
  min-height: 56px;
  border-radius: 16px;
  border: 0.5px solid var(--hairline);
  background: rgba(127, 127, 140, 0.12);
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
  user-select: text;
  -webkit-user-select: text;
}

.sheet-row { display: flex; gap: 12px; }
.sheet-row .btn { margin: 0; }

#toast .toast-action {
  border: 0;
  background: none;
  color: var(--person);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 700;
  margin-left: 12px;
  cursor: pointer;
  padding: 8px;
}

.controls-off .habit-row,
.controls-off .summary-strip {
  opacity: 0.55;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .liquid-fill, .sheet, .scrim, .today-header h1 { transition: none; }
  .pending-dot { animation: none; }
}

/* ---------- Pod screen (Phase 3) ---------- */
#pod-root { display: flex; flex-direction: column; gap: 16px; }

.pod-header h1 {
  font-size: 40px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 12px 0 0;
}

.sync-hero { padding: 32px 24px; text-align: center; }

.sync-hero .hero-num {
  font-family: var(--font-num);
  font-size: 88px;
  line-height: 92px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.sync-hero .hero-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-60);
  margin-top: 4px;
}

.sync-hero .hero-sub { color: var(--ink-60); font-size: 15px; margin: 8px 0 20px; }

.sync-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 20px;
}

.sync-cell {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 0.5px solid var(--hairline);
  position: relative;
}

.sync-cell .cell-day {
  position: absolute;
  bottom: 3px; right: 6px;
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
}

.streaks { padding: 20px; }
.streaks h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.streaks .sec-label {
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--ink-60); margin: 16px 0 8px;
}
.streaks .sec-label:first-of-type { margin-top: 12px; }

.streak-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--hairline);
  font-size: 17px;
}
.streak-row:last-child { border-bottom: 0; }
.streak-row .sval { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; }

#sync-banner {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 20px; right: 20px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 55;
  padding: 16px;
  border-radius: 20px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(48, 209, 88, 0.85), rgba(48, 209, 88, 0.65));
  color: #fff;
  border: 0.5px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 300ms ease, transform 300ms ease;
  pointer-events: none;
}

#sync-banner.show { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  #sync-banner { transition: none; }
}

/* ---------- Manage screen (Phase 4) ---------- */
#manage-root { display: flex; flex-direction: column; gap: 14px; }

.manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 0;
}

.manage-header h1 {
  font-size: 40px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
}

.add-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--person);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.habit-item {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.habit-item .hname { font-size: 17px; font-weight: 600; margin: 0; }
.habit-item .hmeta { font-size: 13px; color: var(--ink-60); margin: 4px 0 0; }

.habit-item .htarget {
  font-family: var(--font-num);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.seg {
  display: flex;
  background: rgba(127, 127, 140, 0.14);
  border-radius: 14px;
  padding: 3px;
  margin-bottom: 20px;
}

.seg button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  border-radius: 11px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--glass-hi);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.signout-wrap { margin-top: 24px; }

.btn-danger {
  background: none;
  color: #FF453A;
  border: 0.5px solid rgba(255, 69, 58, 0.4);
}

/* ---------- Fallback: no backdrop-filter ---------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .habit-row, .person-btn, .sheet, #tabbar {
    background: var(--canvas);
  }
  .orb { opacity: calc(var(--orb-opacity) * 0.5); }
}

.load-error { padding: 40px 24px; text-align: center; }
.load-error p { margin-bottom: 16px; color: var(--ink-60); }
