:root {
  color-scheme: light;
  --bg: #edf5f1;
  --bg-cool: #f7fbff;
  --panel: rgba(255, 255, 255, 0.88);
  --ink: #17221f;
  --muted: #64736e;
  --line: rgba(23, 34, 31, 0.12);
  --line-strong: rgba(23, 34, 31, 0.2);
  --teal: #127c70;
  --coral: #d8644f;
  --gold: #c48a2c;
  --indigo: #4f5fc9;
  --phase: var(--teal);
  --phase-light: #85d7c6;
  --phase-soft: rgba(18, 124, 112, 0.18);
  --breath-scale: 0.72;
  --session-progress: 0;
  --session-offset: 1;
  --shadow: 0 26px 70px rgba(30, 47, 42, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(145deg, rgba(18, 124, 112, 0.13), transparent 34%),
    linear-gradient(325deg, rgba(216, 100, 79, 0.12), transparent 38%),
    linear-gradient(180deg, var(--bg-cool), var(--bg));
  color: var(--ink);
  min-height: 100vh;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(18, 124, 112, 0.26);
  outline-offset: 3px;
}

.app {
  display: grid;
  min-height: 100vh;
  padding: 20px;
  place-items: center;
}

.panel {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 440px;
  overflow: hidden;
  padding: 18px;
  position: relative;
  width: min(100%, 440px);
}

.panel::before {
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral), var(--indigo));
  content: "";
  height: 4px;
  inset: 0 0 auto;
  position: absolute;
}

.topbar {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 42px 1fr auto;
  min-width: 0;
  padding-top: 4px;
}

.home-link,
.icon-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: inline-flex;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.home-link {
  border-radius: 8px;
  text-decoration: none;
}

svg {
  display: block;
  fill: currentColor;
  height: 20px;
  width: 20px;
}

.title-block {
  min-width: 0;
}

.title-block p {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1 {
  font-size: 2rem;
  line-height: 1;
  margin: 0;
}

.cycle-chip {
  align-items: center;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 760;
  justify-content: center;
  min-height: 42px;
  min-width: 74px;
  padding: 7px 10px;
  white-space: nowrap;
}

.breath-area {
  display: grid;
  justify-items: center;
  padding: 4px 0 0;
}

.dial {
  aspect-ratio: 1;
  display: grid;
  max-width: 292px;
  place-items: center;
  position: relative;
  width: min(74vw, 292px);
}

.progress-ring {
  filter: drop-shadow(0 18px 36px rgba(23, 34, 31, 0.12));
  height: 100%;
  inset: 0;
  position: absolute;
  transform: rotate(-90deg);
  width: 100%;
}

.track,
.arc {
  fill: none;
  stroke-linecap: round;
  stroke-width: 9;
}

.track {
  stroke: rgba(23, 34, 31, 0.1);
}

.arc {
  stroke: var(--phase);
  stroke-dasharray: 1;
  stroke-dashoffset: var(--session-offset);
  transition: stroke 180ms ease, stroke-dashoffset 120ms linear;
}

.tick {
  fill: none;
  stroke: rgba(23, 34, 31, 0.2);
  stroke-linecap: round;
  stroke-width: 7;
}

.breath-core {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.28) 28%, transparent 29%),
    linear-gradient(145deg, var(--phase-light), var(--phase));
  border-radius: 999px;
  box-shadow:
    inset 0 1px 3px rgba(255, 255, 255, 0.62),
    0 20px 54px var(--phase-soft);
  height: 64%;
  position: absolute;
  transform: scale(var(--breath-scale));
  transition: background 180ms ease, box-shadow 180ms ease, transform 100ms linear;
  width: 64%;
}

.breath-core::before {
  background: radial-gradient(circle, var(--phase-soft), transparent 66%);
  border-radius: inherit;
  content: "";
  inset: -22%;
  opacity: 0.82;
  position: absolute;
}

.readout {
  align-items: center;
  display: grid;
  justify-items: center;
  min-height: 130px;
  min-width: 156px;
  position: relative;
  text-align: center;
  z-index: 1;
}

.phase,
.cue {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.78rem;
  font-weight: 780;
  text-shadow: 0 1px 10px rgba(23, 34, 31, 0.18);
  text-transform: uppercase;
}

.cue {
  font-size: 0.82rem;
  text-transform: none;
}

.readout strong {
  color: #ffffff;
  font-size: 3.65rem;
  line-height: 0.9;
  text-shadow: 0 2px 18px rgba(23, 34, 31, 0.22);
}

.session-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.88rem;
  font-weight: 700;
  gap: 10px;
  justify-content: space-between;
  min-height: 24px;
}

#statusText {
  color: var(--ink);
}

.meter {
  background: rgba(23, 34, 31, 0.1);
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.meter span {
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  display: block;
  height: 100%;
  transform: scaleX(var(--session-progress));
  transform-origin: left;
  transition: transform 120ms linear;
  width: 100%;
}

.segmented,
.duration {
  background: rgba(23, 34, 31, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 4px;
}

.segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segment,
.duration-button {
  background: transparent;
  color: var(--muted);
  min-height: 54px;
  padding: 8px 6px;
}

.segment span,
.duration-button {
  font-size: 0.78rem;
  font-weight: 780;
}

.segment span,
.segment strong {
  display: block;
  line-height: 1.15;
}

.segment strong {
  color: var(--ink);
  font-size: 0.9rem;
  margin-top: 4px;
}

.segment.is-active,
.duration-button.is-active {
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(23, 34, 31, 0.08);
  color: var(--teal);
}

.controls {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 42px auto;
}

.primary {
  align-items: center;
  background: var(--ink);
  color: #ffffff;
  display: inline-flex;
  font-weight: 820;
  gap: 8px;
  height: 46px;
  justify-content: center;
  padding: 0 18px;
}

.primary svg {
  height: 18px;
  width: 18px;
}

.icon-button:hover,
.home-link:hover,
.segment:hover,
.duration-button:hover {
  border-color: var(--line-strong);
}

.duration {
  grid-template-columns: repeat(3, 40px);
  width: max-content;
}

.duration-button {
  min-height: 36px;
  padding: 0;
}

@media (max-width: 390px) {
  .app {
    padding: 12px;
  }

  .panel {
    gap: 14px;
    padding: 14px;
  }

  .topbar {
    gap: 8px;
    grid-template-columns: 38px 1fr auto;
  }

  .home-link,
  .icon-button {
    height: 38px;
    width: 38px;
  }

  h1 {
    font-size: 1.72rem;
  }

  .cycle-chip {
    min-width: 66px;
    padding-inline: 8px;
  }

  .readout strong {
    font-size: 3.2rem;
  }

  .controls {
    grid-template-columns: 1fr 38px;
  }

  .duration {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
