:root {
  color-scheme: dark;
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #f5f6f2;
  --muted-ink: rgba(245, 246, 242, 0.58);
  --background: #19180d;
  --accent: #f2d34f;
  --ring-track: rgba(255, 255, 255, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #10110f;
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  transition: background-color 500ms ease;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body.phase-warmup {
  --background: #19180d;
  --accent: #f2d34f;
}

body.phase-work {
  --background: #0d1a11;
  --accent: #6fdb8b;
}

body.phase-rest {
  --background: #1e0f0e;
  --accent: #ff766d;
}

body.phase-complete {
  --background: #15121f;
  --accent: #aa98ff;
}

button {
  font: inherit;
}

.timer-shell {
  display: flex;
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  flex-direction: column;
  justify-content: center;
}

.timer-card {
  padding: 0 8px;
}

.phase-heading {
  min-height: 54px;
  text-align: center;
}

.phase-heading h2 {
  margin: 0;
}

.phase-heading h2 {
  font-size: clamp(1.65rem, 7vw, 2.25rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1;
  text-transform: capitalize;
}

.clock-wrap {
  position: relative;
  width: min(76vw, 290px);
  aspect-ratio: 1;
  margin: 8px auto 38px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 9;
}

.ring-track {
  stroke: var(--ring-track);
}

.ring-value {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 180ms linear;
}

.clock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.clock span {
  color: var(--ink);
  font-size: clamp(4rem, 19vw, 5.75rem);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.075em;
  line-height: 0.95;
}

.overall {
  padding: 0 4px;
}

.overall-copy {
  display: flex;
  margin-bottom: 10px;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted-ink);
  font-size: 0.8rem;
  font-weight: 700;
}

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

.overall-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--ring-track);
}

.overall-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms linear;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  margin-top: 18px;
  gap: 10px;
}

.button {
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}

.button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.button:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.button .icon-reset {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button-recovery {
  display: flex;
  width: 100%;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.button-recovery[hidden] {
  display: none;
}

.button-recovery svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button-recovery:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--ink);
  color: #11130f;
}

.button-primary .icon-pause {
  display: none;
}

.button-primary.is-running .icon-play {
  display: none;
}

.button-primary.is-running .icon-pause {
  display: block;
}

.button-secondary {
  display: flex;
  padding: 0 18px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.button-secondary:disabled {
  cursor: default;
  opacity: 0.42;
}

@media (max-height: 740px) {
  .timer-shell {
    justify-content: flex-start;
  }

  .timer-card {
    padding-block: 8px;
  }

  .phase-heading {
    min-height: 44px;
  }

  .clock-wrap {
    width: min(57vw, 220px);
    margin-bottom: 12px;
  }
}

@media (max-height: 430px) {
  .timer-shell {
    width: min(100%, 520px);
    padding:
      max(8px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
    justify-content: center;
  }

  .timer-card {
    padding-block: 0;
  }

  .phase-heading {
    min-height: 34px;
  }

  .phase-heading h2 {
    font-size: 1.4rem;
  }

  .clock-wrap {
    width: min(42svh, 170px);
    margin: 0 auto 10px;
  }

  .clock span {
    font-size: clamp(3rem, 15svh, 4.25rem);
  }

  .overall-copy {
    margin-bottom: 6px;
  }

  .overall-track {
    height: 5px;
  }

  .controls {
    margin-top: 10px;
  }

  .button {
    min-height: 46px;
    border-radius: 14px;
  }

  .button-recovery {
    min-height: 42px;
    margin-top: 8px;
  }

  .timer-shell:has(#audio-recovery-button:not([hidden])) .clock-wrap {
    width: min(36svh, 148px);
  }
}

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