:root {
  --paper: #f4f2ec;
  --panel: #fffdf8;
  --ink: #18201d;
  --muted: #68736e;
  --line: #ded7ca;
  --track: #e7e1d7;
  --phase: #0d766e;
  --phase-soft: #d7eee9;
  --progress: 0deg;
  --breath-scale: 0.72;
  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 {
  min-height: 100vh;
  background:
    linear-gradient(140deg, rgba(13, 118, 110, 0.13), transparent 42%),
    linear-gradient(320deg, rgba(199, 87, 65, 0.14), transparent 38%),
    var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(13, 118, 110, 0.28);
  outline-offset: 3px;
}

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

.timer {
  width: min(100%, 520px);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(24, 32, 29, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 24px 70px rgba(42, 38, 29, 0.14);
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--phase);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 5vw, 2.05rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.session {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbf8f0;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

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

.mode {
  min-width: 0;
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fbf8f0;
  text-align: left;
}

.mode span,
.phase-list span,
.length span {
  font-size: 0.78rem;
  font-weight: 750;
}

.mode strong {
  color: var(--ink);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

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

.dial-wrap {
  display: grid;
  place-items: center;
  padding: 8px 0 0;
}

.dial {
  position: relative;
  width: min(78vw, 320px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--panel) 0 55%, transparent 56%),
    conic-gradient(var(--phase) var(--progress), var(--track) 0);
  box-shadow:
    inset 0 0 0 1px rgba(24, 32, 29, 0.06),
    0 18px 45px rgba(13, 118, 110, 0.13);
  transition: background 120ms linear;
}

.dial::after {
  content: "";
  position: absolute;
  inset: 15px;
  border: 1px solid rgba(24, 32, 29, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.breath {
  position: absolute;
  width: 54%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.16)),
    var(--phase-soft);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.82),
    0 15px 36px rgba(13, 118, 110, 0.18);
  transform: scale(var(--breath-scale));
  transition: transform 140ms linear, background 160ms ease;
}

.breath span {
  width: 56%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--phase) 35%, white);
  background: rgba(255, 255, 255, 0.28);
}

.readout {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 3px;
  text-align: center;
}

.phase {
  min-height: 1.25em;
  color: var(--phase);
  font-size: 1rem;
  font-weight: 850;
}

.count {
  color: var(--ink);
  font-size: clamp(3.3rem, 15vw, 4.6rem);
  font-weight: 850;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.cue {
  min-height: 1.25em;
  color: var(--muted);
  font-size: 0.9rem;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d766e, #5b5bd6, #c75741, #b68121);
  transition: width 120ms linear;
}

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

.phase-list li {
  min-width: 0;
  min-height: 55px;
  display: grid;
  gap: 4px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f0;
  text-align: center;
}

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

.phase-list span {
  overflow-wrap: anywhere;
}

.phase-list strong {
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 0.75fr minmax(92px, 0.6fr);
  gap: 8px;
}

.controls button,
.length {
  min-height: 48px;
}

.controls button {
  padding: 0 14px;
  background: #efe9de;
  color: var(--ink);
  font-weight: 800;
}

.controls .primary {
  background: var(--phase);
  color: white;
}

.length {
  display: grid;
  align-items: center;
  grid-template-columns: 1fr 42px;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f0;
  color: var(--muted);
}

.length input {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 5px 3px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 850;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

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

  .timer {
    padding: 18px;
  }

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

  .session {
    width: fit-content;
  }

  .phase-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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