/* 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;
}
#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;
  min-height: 44px;
}
.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;
  z-index: 3;
}
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- 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 rebuild) ---------- */
:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: linear(0, 0.3 8%, 0.75 18%, 1.01 30%, 1.04 40%, 1.01 55%, 1);
}

#today-root { display: flex; flex-direction: column; gap: 16px; }

/* Entrance */
.press-in { opacity: 0; transform: translateY(16px); transition: opacity 500ms var(--ease), transform 500ms var(--ease); transition-delay: var(--enter-d, 0ms); }
.press-in.in { opacity: 1; transform: none; }

/* Top row */
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.date-nav { display: flex; align-items: center; gap: 2px; }
.dnav { width: 44px; height: 48px; border: 0; background: none; color: var(--ink-60); font-size: 26px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 12px; }
.dnav:disabled { opacity: 0.25; }
.dnav:not(:disabled):active { background: rgba(127, 127, 140, 0.15); }
.top-date { font-size: 15px; font-weight: 500; color: var(--ink-60); white-space: nowrap; }
.pair-capsule { display: flex; align-items: center; padding: 4px 10px 4px 4px; border-radius: 22px; flex: 0 0 auto; }
.pair-pair { display: flex; align-items: center; }
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex: 0 0 auto; }
.pair-pair .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px rgba(20, 20, 30, 0.18); }

/* Title */
.title-block { display: flex; flex-direction: column; align-items: flex-start; }
.screen-title { font-size: 40px; line-height: 44px; font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.greeting { font-size: 17px; color: var(--ink-60); margin-top: 4px; }
.back-pill { margin-top: 12px; min-height: 48px; padding: 10px 22px; border-radius: 24px; font-family: var(--font-text); font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; }

.tile-ex .t-cap, .tile-steps .t-cap { color: var(--ink-60); text-shadow: none; }

/* Together card */
.together-card { border-radius: 30px; padding: 16px 18px; overflow: hidden; position: relative; }
.tg-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.tg-label { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-60); }
.tg-status { font-size: 14px; font-weight: 600; color: var(--ink-60); }
.tg-status.is-sync { color: #BF5AF2; }
.tg-mid { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sphere-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sphere { width: 92px; height: 92px; border-radius: 50%; position: relative; overflow: hidden; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04) 60%), rgba(127, 127, 140, 0.10); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.10); transition: box-shadow 800ms var(--ease); }
.together-card.synced .sphere { box-shadow: 0 0 30px var(--glow), inset 0 2px 8px rgba(0, 0, 0, 0.10); }
.sphere-liquid { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--liq-top) 88%, transparent), color-mix(in srgb, var(--liq-base) 88%, transparent) 55%, color-mix(in srgb, var(--liq-bottom) 88%, transparent)); transition: height 1.1s var(--ease); }
.sphere-liquid .wave { position: absolute; top: -5px; left: 0; width: 200%; height: 10px; animation: waveslide 6s linear infinite; }
.sphere-liquid .wave.w7 { animation-duration: 7s; }
.sphere-liquid.empty .wave { display: none; }
.sphere-gloss { position: absolute; top: 12px; left: 14px; width: 38px; height: 18px; border-radius: 50%; background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0)); filter: blur(2px); transform: rotate(-24deg); pointer-events: none; }
.sphere-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-num); font-size: 22px; font-weight: 600; color: var(--ink); }
.sphere-pct.on-liquid { color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.25); }
.sphere-name { font-size: 13px; font-weight: 500; color: var(--ink-60); }

/* Seamless wave loop */
.wave { display: block; }
@keyframes waveslide { to { transform: translateX(-50%); } }

.tube { flex: 1 1 auto; min-width: 48px; height: 12px; border-radius: 6px; background: rgba(127, 127, 140, 0.12); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12); position: relative; }
.tube-fill { position: absolute; top: 0; bottom: 0; width: 0; transition: width 1.3s var(--ease); }
.tube-you { left: 0; border-radius: 6px 0 0 6px; }
.tube-partner { right: 0; border-radius: 0 6px 6px 0; }
.tube-sync { position: absolute; inset: 0; border-radius: 6px; opacity: 0; transition: opacity 600ms var(--ease); background: linear-gradient(100deg, transparent 42%, rgba(255, 255, 255, 0.65) 50%, transparent 58%), linear-gradient(100deg, var(--you), #BF5AF2 50%, var(--partner)); background-size: 250% 100%, 100% 100%; }
.together-card.synced .tube-sync { opacity: 1; animation: syncsweep 2.4s linear infinite; }
@keyframes syncsweep { 0% { background-position: 120% 0, 0 0; } 100% { background-position: -120% 0, 0 0; } }

.tg-div { height: 0.5px; background: var(--hairline); margin: 18px 0 14px; }
.tg-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tg-line { font-size: 15px; }
.nudge { min-height: 34px; padding: 6px 18px; border-radius: 20px; border: 0.5px solid var(--hairline); background: color-mix(in srgb, var(--person) 16%, transparent); color: var(--ink); font-family: var(--font-text); font-size: 15px; font-weight: 600; cursor: pointer; }

/* Habits heading */
.habits-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 4px; }
.habits-title { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.habits-corner { font-size: 13px; color: var(--ink-60); }

/* Tile grid */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "water exercise" "water steps"; gap: 12px; grid-auto-rows: 172px; }
.tile { position: relative; border-radius: 30px; overflow: hidden; border: 0.5px solid var(--hairline); padding: 16px; display: flex; flex-direction: column; text-align: left; color: var(--ink); font-family: var(--font-text); cursor: pointer; background: linear-gradient(160deg, color-mix(in srgb, var(--tint) 16%, transparent), color-mix(in srgb, var(--tint) 2%, transparent) 60%), linear-gradient(135deg, var(--glass-hi), var(--glass-lo) 45%, var(--glass-hi)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), var(--shadow); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%); transition: transform 320ms var(--spring); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.tile-water { grid-area: water; }
.tile-ex { grid-area: exercise; }
.tile-steps { grid-area: steps; }
.tile-generic { grid-column: span 1; }
.tile.pressing { transform: scale(0.97); }

.t-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; z-index: 2; }
.t-label { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; }
.t-label svg { width: 16px; height: 16px; }
.deep-water { color: #0A84FF; }
.deep-exercise { color: #BF5AF2; }
.deep-steps { color: #30D158; }

.t-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-60); background: rgba(127, 127, 140, 0.22); border: 0.5px solid var(--hairline); border-radius: 14px; padding: 4px 9px 4px 4px; white-space: nowrap; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.t-chip-val { font-variant-numeric: tabular-nums; }

/* Water tile */
.t-liquid { position: absolute; inset: 0; z-index: 0; }
.t-liquid-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, rgba(100, 210, 255, 0.55), rgba(10, 132, 255, 0.62)); transition: height 1s var(--ease); }
@media (prefers-color-scheme: dark) {
  .t-liquid-fill { background: linear-gradient(180deg, rgba(100, 210, 255, 0.34), rgba(10, 132, 255, 0.42)); }
}
.t-liquid-fill .wave { position: absolute; top: -5px; left: 0; width: 200%; height: 10px; animation: waveslide 7s linear infinite; }
.bub { position: absolute; bottom: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); animation: rise 5s ease-in infinite; }
.bub.b1 { left: 22%; width: 6px; height: 6px; animation-duration: 5s; }
.bub.b2 { left: 48%; width: 4px; height: 4px; animation-duration: 6.2s; animation-delay: 1.1s; }
.bub.b3 { left: 66%; width: 5px; height: 5px; animation-duration: 5.6s; animation-delay: 2s; }
.bub.b4 { left: 82%; width: 7px; height: 7px; animation-duration: 6.5s; animation-delay: 0.6s; }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 0.7; } 100% { transform: translateY(-140px); opacity: 0; } }
.tile-water::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48%; background: linear-gradient(180deg, transparent, rgba(4, 40, 90, 0.28)); z-index: 1; pointer-events: none; }
.t-bottom { margin-top: auto; position: relative; z-index: 2; color: #fff; text-shadow: 0 1px 8px rgba(8, 60, 120, 0.4); }
.w-num { font-family: var(--font-num); font-size: 60px; line-height: 64px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.w-num small { font-size: 20px; font-weight: 500; color: rgba(255, 255, 255, 0.8); }
.t-cap { display: block; font-size: 13px; color: rgba(255, 255, 255, 0.88); margin-top: 2px; }
.t-check { position: absolute; top: 60px; right: 12px; width: 34px; height: 34px; border-radius: 50%; background: #30D158; display: flex; align-items: center; justify-content: center; z-index: 3; box-shadow: 0 2px 10px rgba(48, 209, 88, 0.5); }
.t-check svg { width: 18px; height: 18px; stroke: #fff; }
.t-check.pop { animation: pop 420ms var(--spring); }
@keyframes pop { 0% { transform: scale(0.4); } 100% { transform: scale(1); } }
.float1 { position: absolute; z-index: 4; font-size: 22px; font-weight: 700; color: #fff; text-shadow: 0 1px 6px rgba(8, 60, 120, 0.5); animation: floatup 900ms var(--ease) forwards; pointer-events: none; }
@keyframes floatup { 0% { opacity: 0; transform: translateY(8px) scale(0.8); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-34px) scale(1.05); } }

/* Exercise tile */
.x-num { font-family: var(--font-num); font-size: 40px; font-weight: 600; margin-top: 10px; font-variant-numeric: tabular-nums; }
.x-num small { font-size: 16px; font-weight: 500; color: var(--ink-60); }
.vials { display: flex; gap: 6px; margin-top: auto; }
.vial { width: 13px; height: 48px; border-radius: 7px; border: 0.5px solid var(--hairline); background: rgba(127, 127, 140, 0.12); position: relative; overflow: hidden; }
.vial i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(180deg, #FF6482, #BF5AF2); transition: height 1s var(--ease); display: block; }
.vial.on i { height: 100%; }

/* Steps tile */
.s-num { font-family: var(--font-num); font-size: 32px; font-weight: 600; margin-top: 10px; font-variant-numeric: tabular-nums; }
.trail { width: 100%; height: 64px; margin-top: auto; }
.trail path { transition: stroke-dashoffset 1.2s var(--ease); }

/* Generic tile */
.g-state { font-family: var(--font-num); font-size: 30px; font-weight: 600; margin-top: auto; }

/* Add habit */
.add-habit { width: 100%; min-height: 52px; border-radius: 26px; display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-text); font-size: 16px; font-weight: 600; color: var(--person); cursor: pointer; margin-top: 2px; }
.add-habit svg { width: 20px; height: 20px; }
.add-habit:active { transform: scale(0.98); }

/* Sync moment */
.sync-bloom { position: fixed; inset: 0; z-index: 55; pointer-events: none; opacity: 0; background: radial-gradient(60% 45% at 50% 28%, rgba(142, 124, 255, 0.35), rgba(90, 200, 250, 0.18) 60%, transparent 75%); }
.sync-bloom.go { animation: bloominout 2.6s var(--ease) forwards; }
@keyframes bloominout { 0% { opacity: 0; } 25% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.sync-drop { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -18px); z-index: 56; display: flex; align-items: center; gap: 10px; padding: 10px 20px 10px 12px; border-radius: 26px; font-size: 15px; font-weight: 600; opacity: 0; transition: opacity 560ms var(--ease), transform 560ms var(--spring); pointer-events: none; }
.sync-drop.go { opacity: 1; transform: translate(-50%, 0); }
.sd-avatars { display: flex; align-items: center; }
.sd-avatars .avatar + .avatar { margin-left: -10px; }

/* Bottom sheets (Today) */
.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;
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  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-family: var(--font-text);
  font-size: 30px;
  cursor: pointer;
}
.stepper button:active { transform: scale(0.94); }

.numrow { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0 16px; }
.numrow .num { font-size: 56px; font-weight: 600; line-height: 1.1; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.numcap { font-size: 15px; color: var(--ink-60); }
.chiprow { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }
.qchip { min-height: 48px; padding: 0 18px; border-radius: 22px; 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; }
.qchip:active { transform: scale(0.95); }
.linkbtn { display: block; margin: 0 auto 16px; border: 0; background: none; color: var(--person); font-family: var(--font-text); font-size: 15px; font-weight: 600; cursor: pointer; padding: 12px; min-height: 48px; }
.exactrow { display: flex; gap: 8px; margin-bottom: 16px; }
.exactrow .exactinput { flex: 1; margin: 0; }
.exactrow .btn { margin: 0; max-width: none; width: auto; padding: 0 24px; }
.weeklist { margin-bottom: 8px; }
.weekrow { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 0.5px solid var(--hairline); }
.weekrow:last-child { border-bottom: 0; }
.weekday { font-size: 16px; }
.wtog { width: 48px; height: 48px; border-radius: 50%; border: 0.5px solid var(--hairline); background: rgba(127, 127, 140, 0.12); color: var(--ink); font-size: 20px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wtog svg { width: 20px; height: 20px; }
.wtog.on { background: linear-gradient(135deg, #FF6482, #BF5AF2); border-color: transparent; color: #fff; }
.wtog:disabled { opacity: 0.35; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .press-in { opacity: 1; transform: none; transition: none; }
  .sphere-liquid, .t-liquid-fill, .tube-fill, .vial i, .trail path { transition: none; }
  .wave, .bub, .tube-sync, .sync-bloom.go, .t-check.pop, .float1, .pending-dot { animation: none; }
  .tile.pressing, .add-habit:active { transform: none; }
  .sync-bloom, .sync-drop { transition: 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); }
