/* ==========================================================================
   Demalsay — calm design system
   Soft "dawn" (light) and "dusk" (dark) palettes, serif display type,
   generous whitespace, slow eased motion. No web fonts: system serif
   (New York on Apple, Georgia elsewhere) keeps it private and offline.
   ========================================================================== */

@property --accent { syntax: '<color>'; inherits: true; initial-value: #b9a7dc; }
@property --accent-2 { syntax: '<color>'; inherits: true; initial-value: #93b4cf; }

:root {
  --serif: ui-serif, 'New York', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Noto Serif', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-breath: cubic-bezier(0.37, 0, 0.63, 1);
  --radius-lg: 32px;
  --radius: 26px;
  --radius-sm: 16px;

  --accent: #b9a7dc;
  --accent-2: #93b4cf;

  /* Dawn (light) */
  color-scheme: light;
  --bg: #f5f0ea;
  --bg-grad: linear-gradient(180deg, #f8f3ed 0%, #f3ede8 45%, #eeeaf2 100%);
  --warm: #f5cdb8;
  --surface: rgba(255, 255, 255, 0.58);
  --surface-solid: #fcf9f5;
  --surface-2: rgba(84, 68, 58, 0.055);
  --surface-3: rgba(84, 68, 58, 0.11);
  --border: rgba(84, 68, 58, 0.08);
  --border-strong: rgba(84, 68, 58, 0.16);
  --text: #2d2a31;
  --muted: #645f69;
  --faint: #9b95a0;
  --ink: #2a2633;
  --core-center: 16%;
  --core-opacity: 1;
  --tint-base: #2d2a31;
  --tint-amount: 50%;
  --shadow-soft: 0 1px 2px rgba(84, 68, 58, 0.04), 0 14px 40px -12px rgba(84, 68, 58, 0.12);
  --shadow-lift: 0 2px 6px rgba(84, 68, 58, 0.05), 0 30px 60px -20px rgba(84, 68, 58, 0.22);
  --ambient-opacity: 0.42;
  --grain: 0.14;
  --warn: #8a5b20;
  --warn-bg: rgba(226, 176, 100, 0.13);

  transition: --accent 1.2s var(--ease), --accent-2 1.2s var(--ease);
}

/* Dusk (dark) — explicit choice, or system preference when on "auto" */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #161722;
  --bg-grad: linear-gradient(180deg, #1d1f2e 0%, #171825 50%, #121219 100%);
  --warm: #3b2f58;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-solid: #20212f;
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.11);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ece8f1;
  --muted: #a7a2b3;
  --faint: #716c80;
  --tint-base: #ffffff;
  --tint-amount: 82%;
  --core-center: 44%;
  --core-opacity: 0.88;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.2), 0 14px 40px -12px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 30px 60px -20px rgba(0, 0, 0, 0.55);
  --ambient-opacity: 0.24;
  --grain: 0.2;
  --warn: #e8c58a;
  --warn-bg: rgba(232, 190, 110, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #161722;
    --bg-grad: linear-gradient(180deg, #1d1f2e 0%, #171825 50%, #121219 100%);
    --warm: #3b2f58;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-solid: #20212f;
    --surface-2: rgba(255, 255, 255, 0.06);
    --surface-3: rgba(255, 255, 255, 0.11);
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #ece8f1;
    --muted: #a7a2b3;
    --faint: #716c80;
    --tint-base: #ffffff;
    --tint-amount: 82%;
    --core-center: 44%;
    --core-opacity: 0.88;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.2), 0 14px 40px -12px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 30px 60px -20px rgba(0, 0, 0, 0.55);
    --ambient-opacity: 0.24;
    --grain: 0.2;
    --warn: #e8c58a;
    --warn-bg: rgba(232, 190, 110, 0.08);
  }
}

/* Per element, so a card's own --accent also tints its text. */
*, *::before, *::after {
  --accent-text: color-mix(in oklab, var(--accent) var(--tint-amount), var(--tint-base));
}

/* ========================================================================== base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.62 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.in-session { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.3; }
a { color: inherit; }
h1, h2, h3, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent-text) 70%, transparent); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.noscript { padding: 24px; text-align: center; }

/* ========================================================================== atmosphere */

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-grad);
  view-transition-name: ambient;
}
.ambient i {
  position: absolute;
  border-radius: 50%;
  opacity: var(--ambient-opacity);
  animation: drift 52s var(--ease-breath) infinite alternate;
}
.ambient i:nth-child(1) { width: 80vmax; height: 80vmax; top: -40vmax; left: -28vmax; background: radial-gradient(closest-side, var(--accent), transparent); }
.ambient i:nth-child(2) { width: 72vmax; height: 72vmax; bottom: -42vmax; right: -26vmax; background: radial-gradient(closest-side, var(--accent-2), transparent); animation-duration: 66s; animation-direction: alternate-reverse; }
.ambient i:nth-child(3) { width: 55vmax; height: 55vmax; top: 28%; left: 42%; background: radial-gradient(closest-side, var(--warm), transparent); animation-duration: 84s; }
/* Fine film grain — softens gradients and adds a tactile, paper-like calm */
.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: var(--grain);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(7vmax, 5vmax, 0) scale(1.14); }
}

/* Page transitions (View Transitions API) */
::view-transition-old(root) { animation: vt-out 0.35s var(--ease) both; }
::view-transition-new(root) { animation: vt-in 0.6s var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ========================================================================== layout + shared */

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 0 18px;
}
.topbar .theme-btn { margin-left: auto; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent));
  animation: brand-breathe 12s var(--ease-breath) infinite;
}
@keyframes brand-breathe {
  0%, 100% { transform: scale(0.9); }
  40% { transform: scale(1); }
}
.brand-text { display: grid; gap: 3px; min-width: 0; }
.brand-name { font: 500 1.32rem/1 var(--serif); letter-spacing: -0.01em; }
.brand-tag { font: italic 400 0.76rem/1 var(--serif); color: var(--muted); letter-spacing: 0.03em; white-space: nowrap; }

.ghost-btn {
  width: 44px; height: 44px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  transition: background 0.4s var(--ease);
}
.ghost-btn:hover { background: var(--surface-2); }
.ghost-btn svg { width: 21px; height: 21px; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 14px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: 0.005em;
  text-decoration: none;
  transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out), background 0.4s var(--ease);
}
.btn-primary {
  border: 0;
  color: var(--ink);
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 82%, white), color-mix(in oklab, var(--accent-2) 92%, white));
  box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--accent-2) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -14px color-mix(in srgb, var(--accent-2) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.btn-primary:active { transform: scale(0.98); transition-duration: 0.15s; }
.btn-primary svg { width: 17px; height: 17px; }
.btn-ghost { border: 1px solid var(--border-strong); background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }

.link-btn {
  border: 0; background: none; padding: 0;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
  font-size: inherit;
}
.link-btn:hover { color: var(--text); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-soft);
}
.panel > h2, .panel summary h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 400 1.3rem/1.3 var(--serif);
  letter-spacing: -0.005em;
  margin-bottom: 12px;
}
.panel > h2 svg { width: 19px; height: 19px; color: var(--warn); flex: none; }

.footer {
  display: grid;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 0 max(36px, env(safe-area-inset-bottom));
  color: var(--faint);
  font-size: 0.86rem;
  text-align: center;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  color: var(--muted);
  font: italic 400 1rem/1.5 var(--serif);
  padding-bottom: 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.footer-brand b { font-style: normal; font-weight: 500; color: var(--text); }
.footer-mark { width: 44px; height: 44px; flex: none; }
.footer-note { display: flex; gap: 10px; text-align: left; color: var(--muted); }
.footer-note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--accent-text); }
.footer-meta { text-align: center; }

.fineprint { color: var(--faint); font-size: 0.85rem; }

/* Small breathing auras (cards, hero, setup preview) */
.aura-mini {
  --size: 48px;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  will-change: transform;
}
.aura-glow {
  position: absolute;
  inset: -42%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent-2) 18%, transparent) 55%, transparent);
}
.aura-body {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 36%, color-mix(in oklab, var(--accent) 22%, white) 0%, color-mix(in oklab, var(--accent) 75%, white) 38%, var(--accent) 70%, var(--accent-2) 100%);
  box-shadow: inset 0 0 calc(var(--size) * 0.18) rgba(255, 255, 255, 0.5);
}
.aura-sm { --size: 46px; }
.aura-lg { --size: 120px; }
.aura-xl { --size: clamp(150px, 24vw, 240px); }

.breath-caption {
  font: italic 400 1.15rem/1 var(--serif);
  color: var(--muted);
  letter-spacing: 0.04em;
  min-height: 1.2em;
  text-align: center;
}

/* ========================================================================== home */

.hero {
  display: grid;
  gap: 32px;
  align-items: center;
  padding: clamp(8px, 4vw, 40px) 0 clamp(28px, 5vw, 56px);
}
.hero-aura { display: grid; justify-items: center; gap: clamp(36px, 5vw, 56px); padding-top: 28px; }
.hero-text { display: grid; gap: 14px; justify-items: center; text-align: center; }
.hero h1 {
  font: 400 clamp(2.5rem, 8vw, 4.4rem)/1.04 var(--serif);
  letter-spacing: -0.02em;
  max-width: 13ch;
}
.hero h1 em { font-style: italic; color: var(--accent-text); }
.hero-lead { color: var(--muted); font-size: clamp(1.02rem, 2.4vw, 1.15rem); max-width: 46ch; }

.stats {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 22px;
  color: var(--muted);
  font-size: 0.92rem;
}
.stats b { font: 500 1.25rem/1 var(--serif); color: var(--text); margin-right: 2px; }

.resume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
}
.resume svg { width: 17px; height: 17px; transition: transform 0.5s var(--ease-out); }
.resume:hover svg { transform: translateX(4px); }

@media (min-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; }
  .hero-aura { order: 2; }
  .hero-text { justify-items: start; text-align: left; }
  .stats { justify-content: flex-start; }
}

.featured {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: 'aura body' 'actions actions';
  gap: 20px 26px;
  align-items: center;
  padding: clamp(22px, 4vw, 34px);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    radial-gradient(100% 120% at 100% 100%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.featured > .aura-mini { grid-area: aura; --size: clamp(72px, 14vw, 112px); margin: 10px; }
.featured-body { grid-area: body; display: grid; gap: 6px; }
.featured h2 { font: 400 clamp(1.6rem, 4.5vw, 2.2rem)/1.15 var(--serif); letter-spacing: -0.015em; }
.featured-why { color: var(--muted); max-width: 48ch; }
.featured-meta { color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.featured-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 10px; }
.featured-actions > * { flex: 1 1 160px; }
@media (min-width: 760px) {
  .featured { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'aura body actions'; }
  .featured-actions { flex-direction: column; }
  .featured-actions > * { flex: none; min-width: 190px; }
}
.rhythm { color: var(--accent-text); font-weight: 600; font-variant-numeric: tabular-nums; }

.library { padding-top: clamp(44px, 7vw, 72px); }
.library-head { display: grid; gap: 16px; margin-bottom: 22px; }
.library-head h2 { font: 400 clamp(1.7rem, 4vw, 2.2rem)/1.15 var(--serif); letter-spacing: -0.015em; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 9px 18px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.93rem;
  transition: background 0.4s var(--ease), color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.chip:hover { color: var(--text); }
.chip[aria-pressed='true'] {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 24%, var(--surface-solid));
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}
.is-entering .grid > li { animation: rise 0.9s var(--ease-out) both; animation-delay: calc(var(--i) * 60ms + 150ms); }
.is-entering .hero, .is-entering .featured { animation: rise 1s var(--ease-out) both; }
.is-entering .featured { animation-delay: 0.1s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: transform 0.6s var(--ease-out), box-shadow 0.6s var(--ease-out), border-color 0.6s var(--ease);
}
.card::before {
  content: '';
  position: absolute;
  z-index: -1;
  width: 280px; height: 280px;
  right: -130px; top: -150px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 24%, transparent), transparent);
  transition: transform 0.8s var(--ease-out);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card:hover::before { transform: scale(1.2); }
.card:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px 4px; }
.card-tags { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em; text-align: right; }
.card h3 { font: 400 1.42rem/1.2 var(--serif); letter-spacing: -0.01em; }
.card-link { text-decoration: none; }
.card-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.card-link:focus-visible { outline: none; }
.card:has(.card-link:focus-visible) { outline: 2px solid color-mix(in srgb, var(--accent-text) 70%, transparent); outline-offset: 3px; }
.card-en { color: var(--faint); font-size: 0.84rem; margin-top: -4px; }
.card-text { color: var(--muted); font-size: 0.96rem; flex: 1; margin-top: 4px; }
.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.card-min { color: var(--muted); }
.card-play {
  position: relative;
  z-index: 1;
  margin-left: auto;
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 80%, white), var(--accent-2));
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent-2) 80%, transparent);
  transition: transform 0.5s var(--ease-out);
}
.card-play:hover { transform: scale(1.08); }
.card-play svg { width: 15px; height: 15px; margin-left: 2px; }

/* ========================================================================== setup */

.setup {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: 'hero' 'side' 'details';
  padding-bottom: 104px; /* room for the fixed start button on mobile */
}
.setup-hero { grid-area: hero; display: grid; gap: 28px; justify-items: center; text-align: center; padding: 8px 0 14px; }
.setup-side { grid-area: side; display: grid; gap: 16px; align-content: start; }
.setup-details { grid-area: details; display: grid; gap: 16px; align-content: start; }

.setup-aura { display: grid; justify-items: center; gap: 34px; padding-top: 26px; }
.setup-aura .aura-mini { --size: clamp(110px, 26vw, 150px); }
.setup-intro { display: grid; gap: 10px; justify-items: center; min-width: 0; }
.setup-intro h1 { font: 400 clamp(2.2rem, 7vw, 3.3rem)/1.06 var(--serif); letter-spacing: -0.02em; }
.setup-en { color: var(--faint); margin-top: -4px; }
.lead { color: var(--muted); font-size: 1.04rem; max-width: 58ch; }
.best { font-size: 0.95rem; color: var(--muted); }
.best b { color: var(--accent-text); font-weight: 600; }

@media (min-width: 920px) {
  .setup {
    grid-template-columns: minmax(0, 1fr) 410px;
    grid-template-areas: 'hero side' 'details side';
    column-gap: 40px;
    padding-bottom: 0;
  }
  .setup-hero { grid-template-columns: auto minmax(0, 1fr); justify-items: start; text-align: left; align-items: center; }
  .setup-intro { justify-items: start; }
  .setup-aura { padding: 30px 26px 0 10px; }
  .setup-side { position: sticky; top: 20px; align-self: start; }
}

.params { display: grid; }
.param {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
}
.param:first-child { border-top: 0; padding-top: 2px; }
.param-wrap { flex-wrap: wrap; }
.param-text { min-width: 0; }
.param-label { font-weight: 500; }
.param-sub { color: var(--muted); font-size: 0.84rem; line-height: 1.4; }

.stepper {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.stepper button {
  width: 38px; height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  transition: background 0.3s var(--ease);
}
.stepper button:not(:disabled):hover { background: var(--surface-3); }
.stepper output { min-width: 88px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  transition: background 0.4s var(--ease), color 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.segmented button:hover { color: var(--text); }
/* On its own row a choice spans the full width, with equal segments on one line */
.param-wrap .segmented { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.param-wrap .segmented button { padding-inline: 6px; white-space: nowrap; }
.segmented button[aria-pressed='true'] {
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.12), inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.switch {
  position: relative;
  flex: none;
  width: 50px; height: 30px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.4s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.45s var(--ease-out);
}
.switch[aria-checked='true'] { background: color-mix(in oklab, var(--accent) 85%, var(--accent-2)); }
.switch[aria-checked='true']::after { transform: translateX(20px); }

.range {
  --val: 0.5;
  -webkit-appearance: none;
  appearance: none;
  width: min(190px, 50%);
  height: 30px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent) calc(var(--val) * 100%), var(--surface-3) calc(var(--val) * 100%));
}
.range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface-3); }
.range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
.range::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22); }

.pattern {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.pchip {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pchip-inhale, .pchip-retention { color: var(--accent-text); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.pchip-repeat { background: transparent; color: var(--muted); padding-left: 2px; }
.parrow { color: var(--faint); }

.panel-collapsible { padding: 0; }
.panel-collapsible summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
}
.panel-collapsible summary::-webkit-details-marker { display: none; }
.panel-collapsible summary h2 { margin: 0; }
.summary-hint { color: var(--muted); font-size: 0.86rem; text-align: right; }
.summary-hint::after { content: '⌄'; display: inline-block; margin-left: 8px; transition: transform 0.4s var(--ease); }
.panel-collapsible[open] .summary-hint::after { transform: rotate(180deg); }
.panel-collapsible .params { padding: 0 24px 14px; }

.start-bar { padding-top: 2px; }
.btn-start { width: 100%; min-height: 60px; font-size: 1.08rem; }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 14px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 14px; align-items: start; }
.steps li::before {
  content: counter(step);
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-text);
  font: 500 0.95rem/1 var(--serif);
}

.benefits { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.benefits li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; }
.benefits svg { width: 19px; height: 19px; margin-top: 3px; color: var(--accent-text); }

.caution { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 22%, transparent); box-shadow: none; }
.caution p { color: var(--text); opacity: 0.88; }

@media (max-width: 919px) {
  .start-bar {
    position: fixed;
    z-index: 5;
    left: 0; right: 0; bottom: 0;
    padding: 22px max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    background: linear-gradient(to top, var(--bg) 55%, color-mix(in srgb, var(--bg) 0%, transparent));
  }
  .start-bar .btn-primary { max-width: 560px; margin: 0 auto; display: flex; }
  /* Keep the page's last lines (footer links) clear of the fixed start button */
  .setup { padding-bottom: 0; }
  .setup ~ .footer { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .panel { padding: 18px; }
  .panel-collapsible { padding: 0; }
  .panel-collapsible summary { padding: 18px; }
  .panel-collapsible .params { padding: 0 18px 12px; }
  .stepper output { min-width: 76px; }
  .summary-hint { display: none; }
}

/* ========================================================================== session */

.session {
  --level: 0;
  --stage: min(80vw, 48vh, 440px);
  position: fixed;
  inset: 0;
  z-index: 20;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
  overflow: hidden;
}
@supports (height: 1dvh) {
  .session { --stage: min(80vw, 48dvh, 440px); }
}
/* A wash of light that fills the room on the inhale and recedes on the exhale */
.session::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%; top: 44%;
  width: 160vmax; height: 160vmax;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 30%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent) 40%, transparent 68%);
  opacity: calc(0.35 + var(--level) * 0.65);
  pointer-events: none;
}

.chrome { transition: opacity 1.4s var(--ease); }
.session.is-idle .chrome { opacity: 0; pointer-events: none; }
.session.is-idle { cursor: none; }
.session.is-idle .progress { opacity: 0.35; }

.session-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 12px; }
.session-title { text-align: center; min-width: 0; }
.session-name { font: 400 1.08rem/1.3 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-info { color: var(--muted); font-size: 0.84rem; min-height: 1.3em; font-variant-numeric: tabular-nums; }

.mute-btn[aria-pressed='false'] .i-off,
.mute-btn[aria-pressed='true'] .i-on { display: none; }
.mute-btn[aria-pressed='true'] { color: var(--muted); }

.stage-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 5vh, 48px);
  min-height: 0;
}
.stage {
  position: relative;
  width: var(--stage);
  height: var(--stage);
  flex: none;
  display: grid;
  place-items: center;
  -webkit-user-select: none;
  user-select: none;
}
.guide {
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--text) 7%, transparent);
}
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: color-mix(in srgb, var(--text) 6%, transparent); stroke-width: 0.5; }
.ring-progress {
  fill: none;
  stroke: color-mix(in oklab, var(--accent-text) 55%, var(--accent-2));
  stroke-opacity: 0.75;
  stroke-width: 0.9;
  stroke-linecap: round;
}

.aura { position: absolute; inset: 0; pointer-events: none; }
.aura > div { position: absolute; inset: 5%; will-change: transform; }
.aura-halo {
  border-radius: 50%;
  transform: scale(0.63);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 38%, transparent), color-mix(in srgb, var(--accent-2) 14%, transparent) 55%, transparent);
}
/* Slightly irregular shapes that slowly rotate read as soft, living forms */
.aura-corona {
  border-radius: 53% 47% 45% 55% / 47% 55% 45% 53%;
  transform: scale(0.49);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, transparent) 55%, color-mix(in srgb, var(--accent-2) 22%, transparent) 85%, transparent);
}
/* Lit from within (centred gradient), so the slow rotation never "spins" a highlight */
.aura-core {
  border-radius: 48% 52% 51% 49% / 52% 48% 52% 48%;
  transform: scale(0.42);
  opacity: var(--core-opacity);
  background: radial-gradient(circle at 50% 50%, color-mix(in oklab, var(--accent) var(--core-center), white) 0%, color-mix(in oklab, var(--accent) 72%, white) 38%, var(--accent) 72%, var(--accent-2) 100%);
  box-shadow:
    inset 0 0 calc(var(--stage) * 0.07) rgba(255, 255, 255, 0.5),
    0 0 calc(var(--stage) * 0.1) color-mix(in srgb, var(--accent) 30%, transparent);
}

.orb-count {
  position: relative;
  z-index: 1;
  color: var(--ink);
  opacity: 0.78;
  font: 400 calc(var(--stage) * 0.15) / 1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  pointer-events: none;
  transition: opacity 0.8s var(--ease);
}
.orb-count.is-stopwatch { font-size: calc(var(--stage) * 0.1); }
.session.hide-count:not([data-phase='retention']) .orb-count { opacity: 0; }

.ripples { position: absolute; inset: 0; pointer-events: none; }
.ripples i {
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 0;
  transform: scale(0.42);
}

.phase { text-align: center; min-height: 6.4em; max-width: 36ch; }
.phase-label {
  font: 400 clamp(2.1rem, 7vw, 3rem)/1.1 var(--serif);
  letter-spacing: -0.01em;
  min-height: 1.1em;
}
.phase-hint { margin-top: 10px; color: var(--muted); min-height: 1.5em; font-size: 1.02rem; }
.session[data-phase='inhale'] .phase-label { color: var(--accent-text); }
.session[data-phase='retention'] .stage { cursor: pointer; }
.session[data-phase='retention'] .ripples i { animation: ripple 5.5s var(--ease-out) infinite; }
.session[data-phase='retention'] .ripples i:nth-child(2) { animation-delay: 1.83s; }
.session[data-phase='retention'] .ripples i:nth-child(3) { animation-delay: 3.66s; }
.session[data-phase='retention'] .ring-progress { transform-box: fill-box; transform-origin: center; animation: spin 9s linear infinite; }
.session.is-paused .ripples i,
.session.is-paused .ring-progress { animation-play-state: paused; }

@keyframes ripple {
  0% { transform: scale(0.42); opacity: 0.55; }
  100% { transform: scale(1.06); opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.nostrils { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.nostrils span {
  padding: 5px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--faint);
  font: italic 400 0.98rem/1.3 var(--serif);
  transition: background 0.6s var(--ease), color 0.6s var(--ease), border-color 0.6s var(--ease);
}
.nostrils span.on { background: color-mix(in srgb, var(--accent) 30%, transparent); border-color: transparent; color: var(--text); }

.session-bottom { display: grid; gap: 16px; width: min(500px, 100%); margin: 0 auto; }
.progress { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; transition: opacity 1.4s var(--ease); }
.progress-bar { height: 100%; transform: scaleX(0); transform-origin: left; background: color-mix(in oklab, var(--accent) 70%, var(--accent-2)); }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.time { color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.time-right { text-align: right; }
.play-btn {
  width: 66px; height: 66px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: background 0.4s var(--ease), transform 0.4s var(--ease-out);
}
.play-btn:hover { background: var(--surface-solid); }
.play-btn:active { transform: scale(0.95); }
.play-btn svg { width: 22px; height: 22px; }

.breathe-btn { width: 100%; min-height: 64px; font-size: 1.12rem; }
.session[data-phase='retention'] .controls { display: none; }
.session:not([data-phase='retention']) .breathe-btn { display: none; }

.kbd-hint { text-align: center; color: var(--faint); font-size: 0.78rem; margin-top: -6px; }
@media (hover: none) { .kbd-hint { display: none; } }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(22px) saturate(1.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
  animation: fade-in 0.5s var(--ease) both;
}
.overlay-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 28px 26px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lift);
  animation: rise 0.6s var(--ease-out) both;
}
.overlay-card h2 { font: 400 2rem/1.1 var(--serif); text-align: center; }
.overlay-card > .btn-primary, .overlay-card > .btn-ghost { width: 100%; }
.overlay-sub { color: var(--muted); text-align: center; margin: -4px 0 8px; font-variant-numeric: tabular-nums; }
.overlay-settings { margin-top: 6px; border-top: 1px solid var(--border); }
.overlay-settings summary {
  padding: 14px 4px 6px;
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  cursor: pointer;
  list-style: none;
}
.overlay-settings summary::-webkit-details-marker { display: none; }
.overlay-settings summary::after { content: '⌄'; display: inline-block; margin-left: 8px; transition: transform 0.4s var(--ease); }
.overlay-settings[open] summary::after { transform: rotate(180deg); }
.overlay-settings .param:first-child { padding-top: 10px; }

@keyframes fade-in { from { opacity: 0; } }

@media (max-height: 560px) {
  .session { --stage: min(56vw, 56vh, 440px); }
  .phase { min-height: 0; }
  .kbd-hint { display: none; }
}

/* ========================================================================== summary */

.summary {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: max(48px, env(safe-area-inset-top)) 0 max(40px, env(safe-area-inset-bottom));
  text-align: center;
}
.summary-aura { --size: clamp(110px, 28vw, 150px); margin-bottom: 26px; }
.summary h1 { font: 400 clamp(2.2rem, 7vw, 3.2rem)/1.08 var(--serif); letter-spacing: -0.02em; max-width: 16ch; }
.summary-lead { color: var(--muted); max-width: 44ch; font: italic 400 1.12rem/1.55 var(--serif); }

.summary-stats {
  display: flex;
  justify-content: center;
  width: min(460px, 100%);
  margin: 14px 0 4px;
}
.summary-stats > div { flex: 1 1 0; max-width: 160px; display: flex; flex-direction: column-reverse; gap: 4px; padding: 6px 8px; }
.summary-stats > div + div { border-left: 1px solid var(--border); }
.summary-stats dd { font: 400 2rem/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.summary-stats dt { color: var(--muted); font-size: 0.82rem; }

.summary-actions { display: flex; flex-wrap: wrap; gap: 10px; width: min(460px, 100%); margin-top: 14px; }
.summary-actions > * { flex: 1 1 180px; }

.retentions { width: min(460px, 100%); text-align: left; display: grid; gap: 12px; }
.retentions > h2 { font-size: 1.15rem; margin-bottom: 4px; }
.ret-row { display: grid; grid-template-columns: 72px 1fr 52px; gap: 12px; align-items: center; font-variant-numeric: tabular-nums; }
.ret-row > span:first-child { color: var(--muted); font-size: 0.9rem; }
.ret-row b { text-align: right; font: 500 1.05rem/1 var(--serif); }
.ret-track { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.ret-bar {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(var(--w));
  transform-origin: left;
  animation: grow 1.2s var(--ease-out) 0.3s both;
}
.ret-row:not(.is-max) .ret-bar { opacity: 0.55; }
.ret-note { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
@keyframes grow { from { transform: scaleX(0); } }

/* ========================================================================== motion preferences */

@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  .ambient i, .brand-mark, .ret-bar, .overlay, .overlay-card,
  .is-entering .grid > li, .is-entering .hero, .is-entering .featured,
  .session[data-phase='retention'] .ripples i,
  .session[data-phase='retention'] .ring-progress { animation: none; }
  .card, .btn-primary, .card-play, .chrome { transition: none; }
  .card:hover, .btn-primary:hover, .card-play:hover { transform: none; }
}

/* ========================================================================== privacy page */

.doc { display: grid; gap: 18px; max-width: 760px; margin: 0 auto; padding: 12px 0 8px; }
.doc h1 { font: 400 clamp(2rem, 6vw, 2.9rem)/1.08 var(--serif); letter-spacing: -0.02em; }
.doc .panel p + p { margin-top: 10px; }
.doc code { font-size: 0.9em; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.doc-list { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }
.doc-list li::marker { color: var(--accent-text); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; }

/* ========================================================================== update toast */

.update-toast {
  position: fixed;
  z-index: 50;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lift);
  font-size: 0.94rem;
  animation: rise 0.6s var(--ease-out) both;
}
.update-apply {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 82%, white), var(--accent-2));
}
.update-dismiss {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.update-dismiss svg { width: 16px; height: 16px; }
body.in-session .update-toast { display: none; }
@media (prefers-reduced-motion: reduce) { .update-toast { animation: none; } }
