:root {
  --bg: #101311;
  --wash: #101311;
  --raise: #191e1b;
  --line: rgba(236, 242, 234, 0.12);
  --text: #f3f7f2;
  --muted: #c5d0c8;
  --faint: #9aab9f;
  --inhale: #8fceb0;
  --exhale: #e4c59a;
  --orb: #8fceb0;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "STSong", "Noto Serif SC", serif;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--wash);
  color: var(--text);
  font-family: var(--sans);
  transition: background 1s linear;
  touch-action: pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body:not([data-ready]) main { visibility: hidden; }

body[data-screen="run"] { overflow: hidden; }

body[data-phase="inhale"] { --orb: #8fceb0; --wash: #101613; }
body[data-phase="exhale"] { --orb: #e4c59a; --wash: #16140f; }
body[data-phase="hold"] { --orb: #b7c4bc; --wash: #121412; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, label:focus-within {
  outline: 2px solid var(--inhale);
  outline-offset: 3px;
}

main { min-height: 100dvh; }

#setup {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 22px calc(96px + env(safe-area-inset-bottom));
}

.start-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 8;
  width: min(100%, 460px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--wash) 88%, transparent);
  backdrop-filter: blur(12px);
}

.mast h1 {
  margin: 4px 0 8px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 52px;
  letter-spacing: 0.08em;
}

.eyebrow, .lead, .meta, .status, small {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.22em;
  font-size: 12px;
}

.lead { margin: 0; line-height: 1.55; font-size: 15px; }

.block { margin-top: 28px; }

.block h2, .block-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.block-head, .switch-row, .custom-minutes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.block-head button, #add-cycle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
}

.breath-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.stepper {
  background: var(--raise);
  border-radius: 18px;
  padding: 14px 12px 12px;
  text-align: center;
}

.stepper > span { display: block; color: var(--muted); font-size: 13px; }
.stepper em, .custom-minutes em { font-style: normal; color: var(--faint); }

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 4px;
}

.stepper-row button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 20px;
}

.stepper input, .custom-minutes input, .num {
  width: 76px;
  border: 0;
  background: transparent;
  text-align: center;
  font-family: var(--serif);
  font-size: 34px;
}

.custom-minutes input {
  width: 72px;
  font-size: 28px;
  background: var(--raise);
  border-radius: 12px;
  padding: 4px 0;
}

.timeline { margin-top: 16px; }
.timeline .bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #2a2824;
}
.timeline .seg.inhale { background: var(--inhale); }
.timeline .seg.hold { background: #8f98a3; }
.marks { position: relative; height: 22px; margin-top: 4px; }
.mark {
  position: absolute;
  width: 7px;
  height: 7px;
  margin-left: -3px;
  border-radius: 50%;
}
.mark.inhale { top: 2px; background: var(--inhale); }
.mark.hold { top: 7px; background: #c5d0c8; }
.timeline-cap { margin: 4px 0 0; color: var(--faint); font-size: 12px; }

.cycles { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.cycle {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.cycle-top, .cycle-times, .cycle-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cycle-top { justify-content: space-between; }
.cycle-name {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  padding: 0;
}
.cycle-times { margin: 10px 0; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.cycle-times input {
  width: 68px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: center;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
}
.cycle-actions { flex-wrap: wrap; align-items: flex-start; }
.scopes { display: flex; gap: 6px; flex: 1 1 auto; flex-wrap: wrap; min-width: min(100%, 150px); }
.scopes button, .try {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  flex: 0 0 auto;
}
.scopes button[aria-pressed="true"] {
  background: var(--text);
  color: #17211b;
  border-color: transparent;
}
.try {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 32px;
  overflow: hidden;
}
.try input, .start-hit input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0.02;
  cursor: pointer;
}
.ghost {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 2px;
  white-space: nowrap;
}

.switch-row { margin-top: 14px; align-items: flex-start; }
.switch-row small { display: block; color: var(--faint); margin-top: 4px; line-height: 1.4; }
.switch-row input {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--inhale);
}

.custom-minutes { justify-content: flex-start; margin-top: 14px; }

.status { margin: 0; color: #e7a194; text-align: center; }
.status:empty { display: none; }

.start-hit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 148px;
  height: 40px;
  border-radius: 999px;
  background: #d7efe3;
  color: #14211b;
  letter-spacing: 0.14em;
  font-size: 15px;
  overflow: hidden;
}

#run, #done {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.orb-wrap {
  position: relative;
  width: min(52vw, 240px, 30vh);
  height: min(52vw, 240px, 30vh);
  display: grid;
  place-items: center;
}

.orb {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.28), transparent 36%),
    radial-gradient(circle at 50% 55%, var(--orb), rgba(0, 0, 0, 0.15) 72%);
  box-shadow: 0 0 70px color-mix(in srgb, var(--orb) 35%, transparent);
}

.orb.bump {
  box-shadow:
    0 0 0 12px color-mix(in srgb, var(--orb) 28%, transparent),
    0 0 80px color-mix(in srgb, var(--orb) 50%, transparent);
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--orb) 65%, transparent);
}

.phase-stack {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 56px;
  margin-top: 22px;
}

.phase-canvas {
  display: block;
  height: 56px;
}

.meta { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

#done { align-items: center; justify-content: center; text-align: center; }
.done-card h2 {
  margin: 8px 0;
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 500;
  letter-spacing: 0.12em;
}
.done-card p { line-height: 1.6; }
#again {
  margin-top: 18px;
  border: 0;
  background: #d7efe3;
  color: #14211b;
  border-radius: 999px;
  padding: 14px 28px;
  letter-spacing: 0.12em;
}

.haptic-anchor {
  position: fixed;
  left: 0;
  top: 0;
  width: 44px;
  height: 28px;
  opacity: 0.02;
  pointer-events: none;
}
