:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #17211f;
  --muted: #66736e;
  --line: rgba(23, 33, 31, 0.13);
  --line-strong: rgba(23, 33, 31, 0.24);
  --teal: #0d7d72;
  --teal-soft: #ccece5;
  --coral: #d65e51;
  --amber: #c88a24;
  --blue: #4767b2;
  --phase: var(--teal);
  --phase-soft: rgba(13, 125, 114, 0.17);
  --phase-glow: #80d8c7;
  --breath-scale: 0.7;
  --session-angle: 0deg;
  --session-progress: 0%;
  --shadow: 0 24px 72px rgba(20, 31, 29, 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(135deg, rgba(13, 125, 114, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(214, 94, 81, 0.11), transparent 40%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(13, 125, 114, 0.28);
  outline-offset: 3px;
}

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

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

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

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

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

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

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

.title {
  min-width: 0;
}

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

h1 {
  font-size: clamp(1.75rem, 8vw, 2rem);
  line-height: 1;
  margin: 0;
}

.pill {
  align-items: center;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  min-width: 48px;
  padding: 0 10px;
}

.breath-stage {
  display: grid;
  justify-items: center;
  padding: 6px 0 0;
}

.ring {
  aspect-ratio: 1;
  display: grid;
  isolation: isolate;
  max-width: 284px;
  place-items: center;
  position: relative;
  width: min(72vw, 284px);
}

.progress,
.halo,
.breath-ball,
.readout {
  grid-area: 1 / 1;
}

.progress {
  background:
    radial-gradient(circle, transparent 62%, rgba(255, 255, 255, 0.94) 63% 68%, transparent 69%),
    conic-gradient(from -90deg, var(--phase) var(--session-angle), rgba(23, 33, 31, 0.11) 0);
  border-radius: 50%;
  filter: drop-shadow(0 18px 32px rgba(23, 33, 31, 0.13));
  height: 100%;
  position: relative;
  transition: background 160ms linear;
  width: 100%;
  z-index: 0;
}

.progress::after {
  background:
    linear-gradient(var(--phase), var(--phase)) 50% 3% / 8px 18px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) 97% 50% / 18px 8px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) 50% 97% / 8px 18px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) 3% 50% / 18px 8px no-repeat;
  border-radius: 50%;
  content: "";
  inset: 0;
  opacity: 0.65;
  position: absolute;
}

.halo {
  background: radial-gradient(circle, var(--phase-soft), transparent 64%);
  border-radius: 50%;
  height: 76%;
  opacity: 0.95;
  transform: scale(calc(var(--breath-scale) + 0.16));
  transition: transform 90ms linear, background 160ms ease;
  width: 76%;
  z-index: 1;
}

.breath-ball {
  align-items: center;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.25) 28%, transparent 29%),
    linear-gradient(145deg, var(--phase-glow), var(--phase));
  border-radius: 50%;
  box-shadow:
    inset 0 1px 4px rgba(255, 255, 255, 0.64),
    0 22px 56px var(--phase-soft);
  display: flex;
  height: 62%;
  justify-content: center;
  transform: scale(var(--breath-scale));
  transition: transform 90ms linear, background 160ms ease, box-shadow 160ms ease;
  width: 62%;
  z-index: 2;
}

.breath-ball span {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  height: 6px;
  margin-bottom: 23%;
  width: 44%;
}

.readout {
  align-items: center;
  color: #fff;
  display: grid;
  justify-items: center;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 1px 18px rgba(16, 22, 21, 0.22);
  z-index: 3;
}

.phase,
.cue {
  font-size: 0.76rem;
  font-weight: 820;
  line-height: 1.1;
  text-transform: uppercase;
}

.readout strong {
  font-size: clamp(3.2rem, 17vw, 4.9rem);
  line-height: 0.96;
}

.cue {
  opacity: 0.86;
}

.status-line {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.82rem;
  font-weight: 760;
  justify-content: space-between;
  min-height: 20px;
}

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

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

.segmented,
.duration {
  background: rgba(23, 33, 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-width: 0;
}

.segment {
  display: grid;
  gap: 2px;
  min-height: 54px;
  padding: 7px 6px;
}

.segment span {
  font-size: 0.78rem;
  font-weight: 760;
}

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

.segment.is-active,
.duration button.is-active {
  background: #fff;
  box-shadow: 0 8px 20px rgba(23, 33, 31, 0.09);
  color: var(--ink);
}

.controls {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(118px, 1fr) 42px minmax(118px, 1fr);
}

.primary {
  align-items: center;
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  font-weight: 850;
  gap: 8px;
  height: 44px;
  justify-content: center;
  padding: 0 14px;
}

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

.duration {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 44px;
}

.duration button {
  font-size: 0.82rem;
  font-weight: 820;
}

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

  .timer {
    gap: 13px;
    padding: 15px;
  }

  .topbar {
    grid-template-columns: 40px 1fr 44px;
  }

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

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

  .duration {
    grid-column: 1 / -1;
  }
}

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