:root {
  --paper: #f4efe6;
  --ink: #23332c;
  --soft: #52645a;
  --line: #ddd6c8;
  --sage: #3f6150;
  --clay: #d8774f;
  --clay-deep: #b85a35;
  --peach: #f6c9a8;
  --card: #fbf8f2;
  --danger: #a3402a;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
  font-family: ui-rounded, 'SF Pro Rounded', 'Avenir Next', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--clay-deep); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.shell { min-height: 100svh; display: flex; flex-direction: column; max-width: 560px; margin: auto; padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom); }
.bar { height: 64px; display: flex; align-items: center; justify-content: space-between; }
.mark img { display: block; width: 30px; height: 30px; }
.mark { padding: 12px; }
.stage { flex: 1; display: flex; flex-direction: column; animation: enter 260ms var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

/* Buttons: one primary circle, small round icon buttons either side. */
.icon { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; color: var(--sage); transition: transform 100ms var(--ease), background 160ms; }
.icon.small { width: 48px; height: 48px; }
.icon.tiny { width: 36px; height: 36px; border: 0; color: var(--soft); }
.icon.tiny[data-armed='yes'] { color: #fff; background: var(--danger); }
.icon:active, .primary:active, .chip:active, .pill:active, .orb:active { transform: scale(.94); }
.primary { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--sage); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px -12px rgba(35, 51, 44, .6); transition: transform 100ms var(--ease), opacity 160ms; }
.primary svg { width: 30px; height: 30px; stroke-width: 2.2; }
.primary:disabled { opacity: .35; cursor: default; }
.primary.busy { animation: breathe 1.2s ease-in-out infinite; }
.actions { display: flex; align-items: center; justify-content: center; gap: 28px; margin-top: auto; padding: 24px 0 28px; }
.actions.single { justify-content: center; }
.pill { border: 0; border-radius: 999px; background: var(--sage); color: #fff; padding: 14px 22px; font-weight: 650; }
#nav-history.received { animation: received 520ms var(--ease); background: var(--peach); }
@keyframes received { 40% { transform: scale(1.18); } }

/* Home: the orb. */
.home { flex: 1; display: grid; place-items: center; align-content: center; gap: 28px; padding-bottom: 60px; }
.orb { position: relative; width: min(72vw, 280px); aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; color: #fff; background: radial-gradient(circle at 34% 28%, #e9a47c 0%, #aa5033 55%, #893c27 100%); box-shadow: 0 30px 60px -28px rgba(184, 90, 53, .75), inset 0 -14px 30px rgba(120, 40, 15, .25); transition: transform 120ms var(--ease); display: grid; place-items: center; }
.orb-glow { position: absolute; inset: -14px; border-radius: 50%; border: 2px solid rgba(216, 119, 79, .25); pointer-events: none; }
.orb-face { display: grid; gap: 2px; text-align: center; text-shadow: 0 1px 2px rgba(80, 30, 10, .25); padding: 0 24px; }
.orb-face small { font-size: 17px; font-weight: 700; }
.orb-face strong { font-size: clamp(30px, 9vw, 40px); font-weight: 800; letter-spacing: -.02em; line-height: 1.05; overflow-wrap: anywhere; }
.orb.is-hit { animation: hit 600ms var(--ease); }
.orb.is-hit .orb-face strong { font-size: clamp(24px, 7vw, 32px); }
.orb.is-hit .orb-glow { animation: ripple 900ms var(--ease) forwards; }
.hint { margin: 0; color: var(--soft); font-size: 15px; }
@keyframes hit { 0% { transform: scale(.9); } 35% { transform: scale(1.06) rotate(-2deg); } 60% { transform: scale(.98) rotate(1.5deg); } 100% { transform: none; } }
@keyframes ripple { to { transform: scale(1.35); opacity: 0; } }
@keyframes breathe { 50% { transform: scale(1.06); } }

/* Grounding. */
.ground { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding-top: 30px; }
.breath { margin-top: auto; width: min(64vw, 240px); aspect-ratio: 1; display: grid; place-items: center; }
.breath span { width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #dbe8de, #9fbfa9 60%, var(--sage)); transform: scale(.55); }
.breath.inhale span { transform: scale(1); transition: transform var(--inhale, 4s) ease-in-out; }
.breath.exhale span { transform: scale(.55); transition: transform var(--exhale, 6s) ease-in-out; }
.breath-label { margin: 0; font-size: 22px; font-weight: 650; color: var(--sage); min-height: 1.3em; }
.dots { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.dots li { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background 300ms; }
.dots li.on { background: var(--clay); }

/* After and log. */
.after, .log { flex: 1; display: flex; flex-direction: column; align-items: center; padding-top: 18vh; }
.log { padding-top: 28px; align-items: stretch; }
.log .actions { margin-top: 16px; padding: 4px 0 24px; }
h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; text-align: center; font-weight: 750; }
.log h1 { margin: 30px 0 22px; }
.log .dots { justify-content: center; }
.answer { display: grid; gap: 16px; }
textarea, input:not([type]), input[type='email'], .field input, #step { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: 16px; font-size: 17px; resize: none; }
textarea:focus, input:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 11px 16px; font-size: 15px; transition: transform 100ms var(--ease), background 160ms, color 160ms; }
.chip[aria-checked='true'] { background: var(--sage); color: #fff; border-color: var(--sage); }
.levels { display: grid; gap: 22px; }
.level { display: grid; grid-template-columns: 64px 1fr 32px; align-items: center; gap: 12px; color: var(--soft); font-weight: 600; }
.level output { color: var(--ink); font-size: 22px; font-weight: 750; text-align: right; }
input[type='range'] { accent-color: var(--clay); width: 100%; height: 30px; }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; text-align: center; font-size: 15px; }
.error:empty { min-height: 0; }

/* History. */
.history { display: grid; gap: 16px; padding: 8px 0 40px; align-content: start; }
.history.empty { justify-items: center; text-align: center; padding-top: 12vh; gap: 22px; }
.history.empty h1 { font-size: 24px; }
.trend-card { background: var(--card); border-radius: 26px; padding: 22px 20px 18px; border: 1px solid var(--line); }
.trend { display: grid; grid-template-columns: repeat(14, 1fr); align-items: end; gap: 5px; height: 96px; }
.trend i { display: block; border-radius: 6px; background: var(--clay); height: calc(8% + var(--h, 0) * 92%); transition: height 400ms var(--ease); }
.trend i.zero { background: var(--line); height: 8%; }
.trend.ghost { width: 220px; opacity: .5; }
.trend.ghost i { background: var(--line); }
.trend.ghost .h0 { height: 20%; } .trend.ghost .h1 { height: 45%; } .trend.ghost .h2 { height: 70%; } .trend.ghost .h3 { height: 35%; } .trend.ghost .h4 { height: 55%; }
.trend-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--soft); font-size: 15px; }
.trend-meta b { color: var(--ink); font-size: 20px; }
.drop { display: flex; align-items: center; gap: 6px; }
.drop svg { width: 18px; height: 18px; color: var(--clay); }
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.entry { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 12px 10px 12px 18px; }
.entry p { margin: 6px 8px 4px 0; line-height: 1.4; overflow-wrap: anywhere; }
.entry-head { display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 14px; }
.entry-head .icon { margin-left: auto; }
.tag { background: #e7eee8; color: var(--sage); border-radius: 999px; padding: 3px 10px; font-weight: 650; font-size: 13px; }
.step { display: flex; align-items: center; gap: 6px; color: var(--sage); font-weight: 600; }
.step svg { width: 16px; height: 16px; flex: none; }
.muted { color: var(--soft); }
.center { text-align: center; }
.loading { width: 46px; height: 46px; margin: 20vh auto; border-radius: 50%; background: var(--peach); animation: breathe 1.2s ease-in-out infinite; }

/* Sheets. */
.sheet { border: 0; padding: 0; width: min(100vw, 560px); max-width: 100vw; margin: auto auto 0; border-radius: 28px 28px 0 0; background: var(--paper); color: var(--ink); max-height: 92svh; }
.sheet::backdrop { background: rgba(35, 51, 44, .35); }
.sheet[open] { animation: rise 260ms var(--ease); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-body { position: relative; padding: 26px 22px calc(26px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.sheet-close { position: absolute; right: 14px; top: 14px; }
.sheet h2 { margin: 6px 0 8px; font-size: 22px; }
.sheet h3 { margin: 14px 0 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.field { display: grid; gap: 6px; color: var(--soft); font-size: 14px; font-weight: 600; }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch input { width: 46px; height: 28px; accent-color: var(--sage); }
.row { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; font-size: 16px; text-decoration: none; color: var(--ink); }
.row.danger { color: var(--danger); }
.row.link { background: transparent; border: 0; color: var(--sage); text-align: center; padding: 8px; }
.provider { display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 16px; border: 1px solid var(--line); background: #fff; padding: 15px; font-size: 17px; font-weight: 650; }
.provider.apple { background: #000; color: #fff; border-color: #000; }
.provider.apple svg { fill: currentColor; stroke: none; }
.provider svg path[fill] { stroke: none; }
.provider.plain { background: var(--sage); color: #fff; border-color: var(--sage); }
.email { display: grid; gap: 10px; margin-top: 6px; }
.provider:disabled { opacity: .5; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .orb.is-hit { outline: 6px solid var(--peach); outline-offset: 6px; }
  .breath span { transform: none !important; opacity: .55; }
  .breath.inhale span { opacity: 1; }
  #nav-history.received { background: var(--peach); }
}

.prose { line-height: 1.55; padding-bottom: 48px; }
.prose h1 { text-align: left; margin: 8px 0 12px; }
.prose h2 { font-size: 18px; margin: 26px 0 6px; }
.prose p { margin: 0 0 12px; color: #3b4a42; }
.prose .row.link { display: inline-block; padding-left: 0; }
