:root {
  color-scheme: dark;
  --bg: #101315;
  --panel: rgba(244, 240, 229, 0.078);
  --panel-strong: rgba(244, 240, 229, 0.13);
  --line: rgba(244, 240, 229, 0.18);
  --text: #f6f1e6;
  --muted: #a8aaa0;
  --accent: #72dfbf;
  --accent-soft: rgba(114, 223, 191, 0.2);
  --amber: #f2c66d;
  --rose: #ef8b79;
  --blue: #8bb7ff;
  --shadow: 0 26px 76px rgba(0, 0, 0, 0.38);
  --breath-scale: 0.74;
  --phase-progress: 0;
  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(150deg, rgba(114, 223, 191, 0.16), transparent 34%),
    linear-gradient(330deg, rgba(239, 139, 121, 0.14), transparent 42%),
    linear-gradient(180deg, #191d1f 0%, var(--bg) 58%, #090b0d 100%);
  color: var(--text);
  min-height: 100svh;
}

button,
output {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

.timer {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 420px;
  overflow: hidden;
  padding: clamp(18px, 5vw, 28px);
  position: relative;
  width: min(100%, 420px);
}

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

.timer-header {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.2rem, 12vw, 4rem);
  letter-spacing: 0;
  line-height: 0.9;
  margin: 0;
}

.session-clock {
  background: rgba(244, 240, 229, 0.09);
  border: 1px solid rgba(244, 240, 229, 0.15);
  border-radius: 999px;
  color: var(--text);
  display: inline-grid;
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  min-width: 74px;
  padding: 8px 12px;
  place-items: center;
}

.breath-stage {
  align-items: center;
  aspect-ratio: 1;
  display: grid;
  justify-items: center;
  margin: 4px auto 0;
  position: relative;
  width: min(74vw, 304px);
}

.progress-ring {
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.34));
  grid-area: 1 / 1;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
  width: 100%;
}

.ring-track {
  fill: rgba(255, 255, 255, 0.025);
  stroke: rgba(244, 240, 229, 0.15);
  stroke-width: 8;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  stroke-linecap: round;
  stroke-width: 8;
  transition: stroke 160ms ease;
}

.breath-orb {
  align-content: center;
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.34), transparent 22%),
    radial-gradient(circle at 68% 70%, rgba(239, 139, 121, 0.18), transparent 28%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.045)),
    var(--accent-soft);
  border: 1px solid rgba(244, 240, 229, 0.22);
  border-radius: 50%;
  box-shadow:
    0 0 0 16px rgba(244, 240, 229, 0.035),
    0 0 64px var(--accent-soft),
    inset 0 1px 18px rgba(255, 255, 255, 0.09);
  display: grid;
  grid-area: 1 / 1;
  justify-items: center;
  min-width: 0;
  padding: 26px;
  text-align: center;
  transform: scale(var(--breath-scale));
  transition:
    transform 120ms linear,
    background 160ms ease,
    box-shadow 160ms ease;
  width: 72%;
  z-index: 1;
}

.phase-label,
.phase-cue {
  color: var(--muted);
  font-size: clamp(0.72rem, 2.5vw, 0.86rem);
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.phase-count {
  color: var(--text);
  font-size: clamp(4rem, 22vw, 7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  letter-spacing: 0;
  line-height: 0.88;
  margin: 8px 0;
}

.phase-meter {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.phase-meter span {
  background: linear-gradient(90deg, var(--accent), var(--amber));
  border-radius: inherit;
  display: block;
  height: 100%;
  transform: scaleX(var(--phase-progress));
  transform-origin: left;
  transition: transform 110ms linear;
}

.phase-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.phase-list li {
  background: rgba(244, 240, 229, 0.065);
  border: 1px solid rgba(244, 240, 229, 0.12);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 10px;
}

.phase-list span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 720;
}

.phase-list strong {
  color: var(--text);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.phase-list .is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent), white 16%);
}

.duration-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chip,
.controls button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.chip {
  background: rgba(244, 240, 229, 0.075);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.chip.is-selected {
  background: rgba(242, 198, 109, 0.18);
  color: var(--text);
  outline: 1px solid rgba(242, 198, 109, 0.42);
}

.controls {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 0.62fr;
}

.controls button {
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 800;
  padding: 0 16px;
}

.controls .primary {
  background: linear-gradient(135deg, var(--accent), #bff3d8);
  color: #08120f;
}

.controls button:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

body[data-phase="hold"] {
  --accent: var(--amber);
  --accent-soft: rgba(242, 198, 109, 0.19);
}

body[data-phase="exhale"] {
  --accent: var(--rose);
  --accent-soft: rgba(239, 139, 121, 0.19);
}

body[data-phase="done"] {
  --accent: var(--blue);
  --accent-soft: rgba(139, 183, 255, 0.2);
}

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

  .timer {
    gap: 14px;
    padding: 18px;
  }

  .timer-header {
    align-items: stretch;
    flex-direction: column;
  }

  .session-clock {
    justify-self: start;
  }
}

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