:root {
  --paper: #f6f4ee;
  --paper-warm: #ece5d7;
  --panel: rgba(255, 255, 252, 0.9);
  --ink: #17211e;
  --muted: #68746e;
  --line: rgba(23, 33, 30, 0.12);
  --track: #dedbd2;
  --phase-color: #0f766e;
  --phase-soft: #dcefeb;
  --phase-progress: 0deg;
  --breath-scale: 0.7;
  --shadow: 0 24px 70px rgba(34, 37, 30, 0.17);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background:
    linear-gradient(140deg, rgba(15, 118, 110, 0.14), transparent 34%),
    linear-gradient(320deg, rgba(196, 83, 66, 0.16), transparent 32%),
    linear-gradient(180deg, var(--paper), var(--paper-warm));
  color: var(--ink);
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--phase-color) 32%, white);
  outline-offset: 3px;
}

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

.timer {
  width: min(100%, 480px);
  display: grid;
  gap: 18px;
  padding: clamp(18px, 5vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.header,
.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.eyebrow,
h1 {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin-top: 3px;
  font-size: clamp(1.45rem, 7vw, 2rem);
  line-height: 1;
  letter-spacing: 0;
}

.session-clock {
  min-width: 112px;
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.divider {
  color: #9aa39e;
}

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

.tab {
  min-width: 0;
  min-height: 58px;
  display: grid;
  gap: 2px;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tab span,
.tab strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.tab strong {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.tab:hover {
  border-color: color-mix(in srgb, var(--phase-color) 34%, var(--line));
  background: rgba(255, 255, 255, 0.78);
}

.tab:active,
.controls button:active {
  transform: translateY(1px);
}

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

.dial {
  position: relative;
  width: min(74vw, 310px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 252, 0.97) 0 54%, transparent 55%),
    conic-gradient(var(--phase-color) var(--phase-progress), var(--track) 0);
  box-shadow:
    inset 0 0 0 1px rgba(23, 33, 30, 0.08),
    0 20px 48px rgba(15, 118, 110, 0.15);
  transition: background 120ms linear;
}

.dial::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(23, 33, 30, 0.1);
  border-radius: inherit;
  pointer-events: none;
}

.pulse {
  position: absolute;
  width: 54%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.22)),
    var(--phase-soft);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.78),
    0 16px 38px color-mix(in srgb, var(--phase-color) 24%, transparent);
  transform: scale(var(--breath-scale));
  transition: transform 140ms linear, background 160ms linear, box-shadow 160ms linear;
}

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

.phase,
.cue {
  min-height: 1.35em;
}

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

.seconds {
  font-size: clamp(3.3rem, 17vw, 4.45rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 0.96;
}

.cue {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 720;
}

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

.session-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #c45342, #b27a16, #4f6f8f);
  transition: width 120ms linear;
}

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

.phase-strip li {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

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

.phase-strip span,
.phase-strip strong {
  overflow-wrap: anywhere;
}

.phase-strip span {
  font-size: 0.78rem;
  font-weight: 850;
}

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

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

.controls button,
.minutes {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls button {
  background: rgba(255, 255, 255, 0.64);
  color: var(--ink);
  font-weight: 850;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.controls button:hover {
  border-color: rgba(23, 33, 30, 0.22);
  background: rgba(255, 255, 255, 0.86);
}

.controls .primary {
  border-color: transparent;
  background: var(--ink);
  color: #fffdf7;
}

.controls .primary:hover {
  background: color-mix(in srgb, var(--ink) 88%, var(--phase-color));
}

.minutes {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.54);
}

.minutes span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.minutes input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.minutes input::-webkit-inner-spin-button,
.minutes input::-webkit-outer-spin-button {
  opacity: 1;
}

@media (max-width: 420px) {
  .shell {
    padding: 10px;
  }

  .timer {
    gap: 14px;
  }

  .header {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .session-clock {
    justify-content: center;
  }

  .pattern-tabs,
  .phase-strip {
    gap: 6px;
  }

  .tab {
    min-height: 54px;
  }

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

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

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

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