:root {
  --bg0: #070a22;
  --bg1: #0c1238;
  --teal: #3fb8b0;
  --teal-soft: #7fdccf;
  --indigo: #4f46b8;
  --text: #e8ecff;
  --muted: #9aa6d6;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-hi: rgba(255, 255, 255, 0.10);
  --line: rgba(255, 255, 255, 0.10);
  --radius: 22px;
  --breath: 11s; /* 5.5s inhale + 5.5s exhale */
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg0);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(79, 70, 184, 0.45), transparent 60%),
    radial-gradient(900px 700px at 0% 110%, rgba(31, 138, 140, 0.38), transparent 60%),
    radial-gradient(600px 400px at 50% 40%, rgba(63, 184, 176, 0.10), transparent 70%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 70%);
}
.sky::after {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff8, transparent),
    radial-gradient(1px 1px at 72% 12%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 38% 8%, #fff7, transparent),
    radial-gradient(1px 1px at 88% 34%, #fff5, transparent),
    radial-gradient(1px 1px at 22% 52%, #fff4, transparent),
    radial-gradient(1px 1px at 60% 26%, #fff5, transparent),
    radial-gradient(1.5px 1.5px at 5% 30%, #fff5, transparent);
}

.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 16px 24px;
  display: grid;
  gap: 18px;
}
.hero, .mixer { display: grid; gap: 18px; align-content: start; min-width: 0; }

@media (min-width: 960px) {
  .app { max-width: 1080px; grid-template-columns: 1fr 1fr; gap: 36px; padding-top: 56px; }
  .hero { position: sticky; top: 32px; }
}

.brand { text-align: center; }
h1 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(44px, 12vw, 64px);
  letter-spacing: .02em;
  line-height: 1;
  background: linear-gradient(180deg, #fff, var(--teal-soft));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 10px 0 0; color: var(--muted); font-weight: 300; font-size: 17px; }

/* ---------- orb ---------- */
.orb-wrap { display: grid; justify-items: center; gap: 10px; padding: 12px 0 4px; }
.orb {
  position: relative;
  width: min(62vw, 230px); aspect-ratio: 1;
  border: 0; padding: 0; border-radius: 50%;
  background: transparent; color: #fff; cursor: pointer;
  display: grid; place-items: center;
  outline-offset: 10px;
}
.orb:focus-visible { outline: 2px solid var(--teal-soft); }
.orb-halo {
  position: absolute; inset: -14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 184, 176, .45) 0%, rgba(79, 70, 184, .25) 45%, transparent 70%);
  filter: blur(10px);
  opacity: .55;
  animation: breathe var(--breath) ease-in-out infinite;
  transition: opacity 2s ease;
}
.orb-core {
  position: relative;
  width: 100%; height: 100%; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.55), transparent 32%),
    radial-gradient(circle at 50% 55%, #3fb8b0 0%, #2a7f9a 40%, #3b358f 80%, #241f63 100%);
  box-shadow:
    inset 0 -18px 40px rgba(10, 8, 50, .55),
    inset 0 10px 30px rgba(255,255,255,.12),
    0 20px 60px rgba(30, 120, 140, .35);
  animation: breathe-core var(--breath) ease-in-out infinite;
  transition: transform .4s ease;
}
.orb:active .orb-core { transform: scale(.97); }
.ico { width: 30%; height: 30%; filter: drop-shadow(0 2px 6px rgba(0,0,0,.3)); }
.ico-play { transform: translateX(6%); }
.ico-pause { display: none; }
.playing .ico-play { display: none; }
.playing .ico-pause { display: block; }
.playing .orb-halo { opacity: 1; }

@keyframes breathe {
  0%, 100% { transform: scale(.88); }
  50% { transform: scale(1.12); }
}
@keyframes breathe-core {
  0%, 100% { transform: scale(.96); }
  50% { transform: scale(1.03); }
}

.play-label { margin: 6px 0 0; color: var(--muted); font-size: 15px; min-height: 1.4em; }
.breath { position: relative; height: 1.4em; margin: 0; width: 100%; text-align: center; font-size: 14px; letter-spacing: .12em; color: var(--teal-soft); opacity: 0; transition: opacity 2s; }
.playing .breath { opacity: .85; }
.breath span { position: absolute; inset: 0; animation: fade-in var(--breath) ease-in-out infinite; }
.breath .out { animation-name: fade-out; }
@keyframes fade-in { 0%, 45%, 100% { opacity: 0; } 8%, 40% { opacity: 1; } }
@keyframes fade-out { 0%, 50%, 95%, 100% { opacity: 0; } 58%, 90% { opacity: 1; } }

.hint { text-align: center; margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--glass-hi), var(--glass));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
  min-width: 0;
}
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: .03em; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.timer-left { font-variant-numeric: tabular-nums; color: var(--teal-soft); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font: inherit; font-size: 15px;
  min-height: 46px; padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor: pointer;
  transition: background .4s, border-color .4s, box-shadow .4s;
}
.chip:hover { background: rgba(255,255,255,.09); }
.chip:focus-visible { outline: 2px solid var(--teal-soft); outline-offset: 2px; }
.chip[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(63,184,176,.35), rgba(79,70,184,.35));
  border-color: rgba(127, 220, 207, .55);
  box-shadow: 0 0 24px rgba(63,184,176,.25);
}
.modes .chip { display: grid; align-content: center; text-align: center; line-height: 1.15; padding: 8px 14px; flex: 1 1 calc(50% - 10px); }
.chip small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- layers ---------- */
.layers { display: grid; gap: 6px; }
.layer {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "tog name" "tog range";
  column-gap: 14px; row-gap: 4px;
  align-items: center;
  padding: 10px 4px;
  border-top: 1px solid rgba(255,255,255,.06);
  transition: opacity .6s;
}
.layer:first-child { border-top: 0; }
.layer:not(.on) .layer-range { opacity: .45; }
.layer-name { grid-area: name; font-size: 16px; }
.layer-name small { color: var(--muted); font-size: 13px; margin-inline-start: 6px; }
.layer-range { grid-area: range; transition: opacity .6s; }
.toggle {
  grid-area: tog;
  width: 52px; height: 52px; border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  filter: grayscale(.9); opacity: .7;
  transition: all .5s;
}
.toggle:focus-visible { outline: 2px solid var(--teal-soft); outline-offset: 2px; }
.layer.on .toggle {
  filter: none; opacity: 1;
  background: linear-gradient(135deg, rgba(63,184,176,.30), rgba(79,70,184,.30));
  border-color: rgba(127,220,207,.5);
  box-shadow: 0 0 20px rgba(63,184,176,.22);
}

.row { display: grid; gap: 10px; }
.row-name { font-size: 15px; color: var(--muted); }

/* ---------- range ---------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 36px; margin: 0;
  background: transparent; cursor: pointer;
  direction: ltr; /* consistent fill across engines */
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 6px;
  background: linear-gradient(to right, var(--teal) var(--p), rgba(255,255,255,.14) var(--p));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: rgba(255,255,255,.14); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--teal); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: #eafffb; border: 0;
  box-shadow: 0 0 0 5px rgba(63,184,176,.25), 0 2px 8px rgba(0,0,0,.4);
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: #eafffb; box-shadow: 0 0 0 5px rgba(63,184,176,.25);
}
input[type="range"]:focus-visible { outline: 2px solid var(--teal-soft); outline-offset: 4px; border-radius: 8px; }

/* ---------- guided voice ---------- */
.voice .card-head h2 { margin-bottom: 14px; }
.voices { margin-bottom: 14px; }
.voices .chip { min-height: 40px; padding: 0 14px; font-size: 14px; }
/* sessions: 2-column grid of tiles (name + duration), scales to many sessions on a 360px phone */
.sessions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.session {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px;
  width: 100%; min-height: 68px; text-align: start; padding: 10px 14px; line-height: 1.25;
  border-radius: 18px; font-size: 15px;
}
.session span { overflow-wrap: anywhere; }
.session small { margin: 0; font-size: 12.5px; }
.chip:disabled { cursor: default; opacity: .5; }
.chip:disabled:hover { background: rgba(255,255,255,.04); }
.voice.unready .sessions { filter: saturate(.6); }
.voice-caption {
  margin: 14px 2px 0; color: var(--teal-soft); font-weight: 300; font-size: 15px; line-height: 1.55;
  min-height: 1.55em;
}
.voice-caption[hidden], .soon[hidden] { display: none; }
.soon {
  flex: none; font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(127,220,207,.14); color: var(--teal-soft); border: 1px solid rgba(127,220,207,.3);
}

/* ---------- sleep mode ---------- */
.sleep-card { display: grid; gap: 14px; transition: border-color .8s, box-shadow .8s; }
.sleep-card.on { border-color: rgba(167, 160, 255, .45); box-shadow: 0 0 40px rgba(79, 70, 184, .35); }
.sleep-toggle, .mini-switch {
  font: inherit; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer;
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: start;
}
.sleep-toggle { min-height: 60px; }
.sleep-toggle:focus-visible, .mini-switch:focus-visible { outline: 2px solid var(--teal-soft); outline-offset: 4px; border-radius: 14px; }
.sleep-moon {
  flex: none; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, rgba(79,70,184,.45), rgba(20,24,70,.6)); border: 1px solid var(--line);
}
.sleep-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.sleep-title { font-size: 19px; font-weight: 500; }
.sleep-text small { color: var(--muted); font-size: 13px; }
.switch {
  flex: none; position: relative; width: 50px; height: 30px; border-radius: 999px;
  background: rgba(255,255,255,.14); border: 1px solid var(--line); transition: background .4s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #eafffb; box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: inset-inline-start .35s ease;
}
[aria-checked="true"] > .switch { background: linear-gradient(135deg, var(--teal), var(--indigo)); }
[aria-checked="true"] > .switch::after { inset-inline-start: 23px; }
.sleep-durs .chip { flex: 1 1 0; padding: 0 8px; min-width: 0; }
.mini-switch { justify-content: space-between; min-height: 44px; font-size: 15px; color: var(--muted); }
.mini-switch small { font-size: 12px; opacity: .8; }

.sleep-screen {
  position: fixed; inset: 0; z-index: 50;
  background: #020309;
  display: grid; place-items: center; align-content: center; gap: 28px;
  padding: 24px 16px max(24px, env(safe-area-inset-bottom));
  cursor: pointer; animation: sleep-in 2.5s ease both;
}
.sleep-screen[hidden] { display: none; }
.night {
  margin: 0; font-weight: 300; font-size: 30px; letter-spacing: .06em;
  color: #8f97c9; opacity: .28; animation: night-breathe var(--breath) ease-in-out infinite;
}
.sleep-ctrls {
  display: grid; justify-items: center; gap: 14px;
  opacity: 0; visibility: hidden; transition: opacity .8s, visibility 0s .8s;
}
.sleep-screen.reveal .sleep-ctrls { opacity: .75; visibility: visible; transition: opacity .6s; }
.sleep-left { margin: 0; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; min-height: 1.3em; }
.sleep-ctrls .chip { background: rgba(255,255,255,.03); color: #b9c0e6; }
@keyframes sleep-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes night-breathe { 0%, 100% { opacity: .18; } 50% { opacity: .34; } }
body.sleeping { overflow: hidden; }

.foot { text-align: center; color: var(--muted); opacity: .7; font-size: 12px; padding: 8px 16px max(24px, env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .breath { display: none; }
}
