:root {
  --bg: #07080f;
  --card: rgba(255, 255, 255, 0.045);
  --card-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f1f4fa;
  --muted: #9aa3b8;
  --accent: #7ef0c0;
  --accent-2: #5cc8ff;
  --accent-3: #a98bff;
  --accent-ink: #04231a;
  --grad: linear-gradient(120deg, #7ef0c0 0%, #5cc8ff 50%, #a98bff 100%);
  --warn: #ffc46b;
  --danger: #ff6b81;
  --radius: 22px;
  --display: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Living background: three slow aurora blobs + grain */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(70px); opacity: 0.32; mix-blend-mode: screen;
}
.aurora i:nth-child(1) { background: #1fd69a; top: -30vmax; left: -25vmax; animation: drift1 22s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { background: #2b7bff; bottom: -35vmax; right: -30vmax; animation: drift2 26s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { background: #8a4dff; top: 30%; left: 40%; width: 45vmax; height: 45vmax; opacity: 0.18; animation: drift3 30s ease-in-out infinite alternate; }
.aurora::after {
  content: ""; position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: 0.06;
}
@keyframes drift1 { to { transform: translate(18vmax, 14vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vmax, -12vmax) scale(1.1); } }
@keyframes drift3 { to { transform: translate(-20vmax, 10vmax) scale(0.85); } }

#app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; min-height: 100dvh; padding: 22px 16px 120px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; font-family: var(--display); }
h1 { font-size: 34px; letter-spacing: -0.03em; font-weight: 700; }
h2 { font-size: 26px; letter-spacing: -0.02em; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 12px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* Glass cards with a soft gradient edge */
.card {
  position: relative; background: var(--card); border-radius: var(--radius); padding: 18px;
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.card + .card { margin-top: 12px; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.btn {
  position: relative; overflow: hidden;
  display: block; width: 100%; padding: 16px 18px; border-radius: 16px;
  background: var(--grad); background-size: 200% 100%; color: var(--accent-ink);
  font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
  box-shadow: 0 8px 30px rgba(94, 230, 190, 0.28);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-position 0.6s ease;
}
.btn:hover { background-position: 100% 0; }
.btn:active { transform: scale(0.97); }
.btn::after { /* shine sweep */
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg); animation: shine 4.5s ease-in-out infinite;
}
@keyframes shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
.btn.ghost, .btn.quiet, .btn.danger { box-shadow: none; }
.btn.ghost::after, .btn.quiet::after, .btn.danger::after { display: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.quiet { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 107, 129, 0.3); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled::after { display: none; }
.link { background: none; color: var(--muted); text-decoration: underline; padding: 8px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line);
  font-size: 14px; transition: transform 0.15s ease, background 0.2s ease;
}
.chip:active { transform: scale(0.94); }
.chip[aria-pressed="true"] {
  background: var(--grad); color: var(--accent-ink); border-color: transparent; font-weight: 600;
  box-shadow: 0 4px 18px rgba(94, 230, 190, 0.3); animation: pop 0.3s ease;
}
@keyframes pop { 50% { transform: scale(1.08); } }

input[type="text"], textarea {
  width: 100%; padding: 14px 15px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(126, 240, 192, 0.12); }
textarea { resize: none; }
input[type="range"] { accent-color: var(--accent); }

.steps { display: flex; gap: 6px; margin-bottom: 26px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.steps span.on { background: var(--grad); box-shadow: 0 0 12px rgba(126, 240, 192, 0.6); }

/* Onboarding hero */
.hero-logo { width: 92px; height: 92px; margin: 10px 0 18px; filter: drop-shadow(0 0 24px rgba(126, 240, 192, 0.45)); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.hero-title { font-size: 46px; letter-spacing: -0.04em; }

/* Ring */
.ring-wrap { position: relative; width: 250px; height: 250px; margin: 8px auto 6px; }
.ring-wrap::before { /* glow behind the ring */
  content: ""; position: absolute; inset: 24px; border-radius: 50%;
  background: radial-gradient(circle, rgba(94, 200, 255, 0.22), transparent 70%);
  animation: breatheGlow 5s ease-in-out infinite;
}
@keyframes breatheGlow { 50% { transform: scale(1.12); opacity: 0.7; } }
.ring-wrap svg { position: relative; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-bg { stroke: rgba(255, 255, 255, 0.07); }
.ring-fg { animation: draw 1.4s cubic-bezier(.2, .8, .2, 1) both; filter: drop-shadow(0 0 8px rgba(126, 240, 192, 0.55)); }
@keyframes draw { from { stroke-dashoffset: var(--c); } }
.ring-tip { fill: #fff; filter: drop-shadow(0 0 8px #7ef0c0); animation: tip 2s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes tip { 50% { transform: scale(1.5); } }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-big { font-family: var(--display); font-size: 52px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.ring-label { color: var(--muted); font-size: 14px; margin-top: 8px; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 10px; flex: 1; text-align: center; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.stat b { display: block; font-family: var(--display); font-size: 24px; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12px; }

.bar { height: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.bar i {
  display: block; height: 100%; border-radius: 10px; background: var(--grad); background-size: 200% 100%;
  box-shadow: 0 0 14px rgba(126, 240, 192, 0.55); animation: grow 1.2s cubic-bezier(.2, .8, .2, 1) both, flow 3s linear infinite;
}
@keyframes grow { from { width: 0; } }
@keyframes flow { to { background-position: 200% 0; } }

.dream-card { overflow: hidden; }
.dream-card::before { /* moving light on the dream */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 80% at 0% 0%, rgba(169, 139, 255, 0.28), transparent 60%),
              radial-gradient(90% 70% at 100% 100%, rgba(92, 200, 255, 0.22), transparent 60%);
}
.dream { position: relative; display: flex; gap: 14px; align-items: center; }
.dream .icon {
  font-size: 40px; width: 72px; height: 72px; display: grid; place-content: center; flex: none;
  background: rgba(255, 255, 255, 0.08); border-radius: 20px; border: 1px solid var(--line);
  animation: float 4s ease-in-out infinite;
}

.banner { border-radius: 18px; padding: 16px; background: rgba(126, 240, 192, 0.1); border: 1px solid rgba(126, 240, 192, 0.3); }
.banner.warn { background: rgba(255, 196, 107, 0.1); border-color: rgba(255, 196, 107, 0.35); }

.panic {
  position: fixed; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 5;
  background: linear-gradient(135deg, #ff6b81, #ff9a62); color: #2a0610; font-family: var(--display); font-weight: 800;
  border-radius: 999px; padding: 15px 22px; letter-spacing: -0.01em;
  box-shadow: 0 10px 30px rgba(255, 107, 129, 0.45);
}
.panic::before { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid #ff6b81; animation: ripple 2.4s ease-out infinite; }
@keyframes ripple { from { transform: scale(1); opacity: 0.8; } to { transform: scale(1.35); opacity: 0; } }
.panic:active { transform: scale(0.95); }

nav.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 4;
  display: flex; justify-content: center;
}
nav.tabs .inner {
  display: flex; width: 100%; max-width: 460px; padding: 6px;
  background: rgba(16, 19, 30, 0.72); border: 1px solid var(--line); border-radius: 24px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
nav.tabs button { flex: 1; background: none; color: var(--muted); padding: 8px 4px; font-size: 12px; border-radius: 18px; transition: background 0.2s ease, color 0.2s ease; }
nav.tabs button .ico { display: block; font-size: 19px; line-height: 1.3; }
nav.tabs button[aria-current="page"] { color: var(--text); background: rgba(126, 240, 192, 0.14); }
nav.tabs button[aria-current="page"] .ico { color: var(--accent); text-shadow: 0 0 12px rgba(126, 240, 192, 0.8); }

/* Screen entrance: children rise in one after another */
.enter > * { animation: rise 0.55s cubic-bezier(.2, .8, .2, 1) both; }
.enter > *:nth-child(2) { animation-delay: 0.05s; }
.enter > *:nth-child(3) { animation-delay: 0.1s; }
.enter > *:nth-child(4) { animation-delay: 0.15s; }
.enter > *:nth-child(5) { animation-delay: 0.2s; }
.enter > *:nth-child(6) { animation-delay: 0.25s; }
.enter > *:nth-child(n+7) { animation-delay: 0.3s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Scale for check-in */
.scale { display: flex; gap: 8px; }
.scale button { flex: 1; padding: 12px 0; font-size: 22px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); transition: transform 0.15s ease; }
.scale button:active { transform: scale(0.9); }
.scale button[aria-pressed="true"] { background: var(--grad); box-shadow: 0 4px 18px rgba(94, 230, 190, 0.35); transform: scale(1.06); }

/* Coach */
.coach { display: flex; flex-direction: column; min-height: calc(100dvh - 40px); }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.msg { max-width: 85%; padding: 12px 15px; border-radius: 20px; white-space: pre-wrap; animation: rise 0.35s ease both; }
.msg.bot { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.msg.me { background: var(--grad); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 6px; }
.msg.crisis { background: rgba(255, 107, 129, 0.14); border-color: rgba(255, 107, 129, 0.4); }
.composer { display: flex; gap: 8px; position: sticky; bottom: 0; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.composer textarea { flex: 1; }
.composer .btn { width: auto; padding: 0 20px; }

.breathe { display: grid; place-items: center; padding: 14px 0 6px; }
.breathe .orb {
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #e6fff5, #7ef0c0 35%, #5cc8ff 70%, #6a4dff);
  box-shadow: 0 0 60px rgba(126, 240, 192, 0.55), 0 0 120px rgba(92, 200, 255, 0.3);
  animation: breathe 14s ease-in-out infinite;
}
.breathe .cue { margin-top: 14px; font-family: var(--display); font-size: 16px; min-height: 24px; }
@keyframes breathe {
  0% { transform: scale(0.6); }
  28.5% { transform: scale(1); }
  57% { transform: scale(1); }
  100% { transform: scale(0.6); }
}

.price { font-family: var(--display); font-size: 36px; font-weight: 800; letter-spacing: -0.03em; }
.badge { display: inline-block; padding: 5px 11px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); font-size: 12px; color: var(--muted); backdrop-filter: blur(10px); }
.locked { opacity: 0.55; }
.dev { margin-top: 24px; border: 1px dashed var(--warn); border-radius: 14px; padding: 12px; }
.dev .chips .chip { background: transparent; }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 30; transform: translateX(-50%);
  background: rgba(20, 24, 38, 0.85); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 12px 18px; border-radius: 16px; font-size: 14px; max-width: 90vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); animation: drop 0.35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -16px); } }
canvas.confetti { position: fixed; inset: 0; z-index: 40; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Intro: a calm presence ---------- */
.intro { min-height: calc(100dvh - 44px); display: flex; flex-direction: column; justify-content: space-between; text-align: center; position: relative; }
.presence {
  position: absolute; left: 50%; top: 22%; width: 260px; height: 260px; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(126, 240, 192, 0.55) 18%, rgba(92, 200, 255, 0.25) 42%, transparent 70%);
  filter: blur(6px); animation: presence 6s ease-in-out infinite; pointer-events: none;
}
@keyframes presence { 50% { transform: translate(-50%, -50%) scale(1.18); opacity: 0.75; } }
.intro-text { position: relative; margin-top: 40vh; padding: 0 6px; }
.intro-text h1 { font-size: 38px; line-height: 1.12; animation: reveal 1.2s cubic-bezier(.2, .8, .2, 1) both; }
.intro-text p { font-size: 18px; color: #c9d1e3; line-height: 1.55; margin-top: 16px; animation: reveal 1.2s 0.5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(12px); filter: blur(8px); } }
.intro-cta { position: relative; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: reveal 1s 1.1s both; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.dots span { width: 6px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.2); transition: width 0.3s ease; }
.dots span.on { width: 22px; background: var(--grad); }
.gaps { display: flex; justify-content: center; align-items: baseline; gap: 4px; margin: 22px 0 10px; font-family: var(--display); }
.gaps span {
  font-size: 22px; font-weight: 700; opacity: var(--o); margin-right: calc(var(--k) * 5px);
  animation: reveal 0.8s calc(0.9s + var(--k) * 0.18s) both;
}
.hold {
  position: relative; overflow: hidden; width: 100%; padding: 18px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(126, 240, 192, 0.45);
  font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--text); touch-action: none; user-select: none;
  box-shadow: 0 0 30px rgba(126, 240, 192, 0.18);
}
.hold i { position: absolute; inset: 0; width: 0; background: var(--grad); opacity: 0.9; }
.hold span { position: relative; }
.hold.holding i { width: 100%; transition: width 2.2s linear; }
.hold.holding span { color: var(--accent-ink); transition: color 1s 1s; }

/* ---------- Home: day counter, ring, one sentence ---------- */
.home-top { display: flex; justify-content: space-between; align-items: flex-start; }
.daycount { display: flex; flex-direction: column; line-height: 1; }
.daycount b { font-family: var(--display); font-size: 40px; font-weight: 800; letter-spacing: -0.04em; }
.daycount span { color: var(--muted); font-size: 13px; margin-top: 4px; }
.home { display: flex; flex-direction: column; align-items: center; text-align: center; min-height: calc(100dvh - 205px); justify-content: center; }
.home .ring-wrap { width: 270px; height: 270px; }
.home-words { margin-top: 10px; width: 100%; }
.not-now { font-size: 44px; letter-spacing: -0.04em; margin: 6px 0 4px; }
.when { color: #c9d1e3; font-size: 17px; line-height: 1.55; }
.when b { color: var(--text); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.level-line { margin-top: 26px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 800; font-family: var(--display);
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 10px rgba(126, 240, 192, 0.45)); }

/* Urge button in the middle of the tab bar */
nav.tabs .urge {
  position: relative; flex: 0 0 auto; width: 64px; height: 64px; margin: -22px 4px 0; border-radius: 50%;
  background: linear-gradient(135deg, #ff6b81, #ff9a62); color: #2a0610; font-family: var(--display); font-weight: 800; font-size: 13px;
  box-shadow: 0 10px 30px rgba(255, 107, 129, 0.5); padding: 0;
}
nav.tabs .urge::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #ff6b81; animation: ripple 2.4s ease-out infinite; }
nav.tabs .urge:active { transform: scale(0.94); }

/* ---------- Grow ---------- */
.goal-card {
  position: relative; min-height: 230px; padding: 18px; border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  background: linear-gradient(135deg, rgba(169, 139, 255, 0.35), rgba(92, 200, 255, 0.18)) center / cover no-repeat;
  border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45); margin-bottom: 12px;
}
.goal-card .badge { position: absolute; top: 14px; left: 14px; }
.goal-card h2 { font-size: 28px; margin: 0; }
.goal-card p { margin: 0 0 6px; color: #d6dceb; }
.photo-btn { text-align: center; }
.goal-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.goal-row.done b { opacity: 0.55; text-decoration: line-through; }
.check { width: 30px; height: 30px; flex: none; border-radius: 10px; border: 1.5px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--accent-ink); font-weight: 800; }
.check[aria-pressed="true"] { background: var(--grad); border-color: transparent; animation: pop 0.3s ease; }
nav.tabs .inner { justify-content: space-around; }

.offer { margin-top: 14px; text-align: left; border-color: rgba(126, 240, 192, 0.35); box-shadow: 0 0 40px rgba(126, 240, 192, 0.12); }
.offer h3 { margin: 4px 0; }

.sound-toggle { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 6; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); font-size: 17px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.coach .sound-toggle { position: static; margin-left: 8px; }

.link-code { font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: 0.18em; text-align: center; padding: 10px 0;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
