:root {
  --ink: #1c2230;
  --muted: #697181;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(28, 34, 48, 0.12);
  --focus: #16836d;
  --focus-soft: #dff3ea;
  --reset: #d45a3d;
  --reset-soft: #ffe6dc;
  --amber: #f0ad31;
  --shadow: 0 24px 70px rgba(42, 54, 70, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(22, 131, 109, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(212, 90, 61, 0.07) 1px, transparent 1px),
    #eef4f0;
  background-size: 42px 42px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
}

.home-link,
.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(42, 54, 70, 0.08);
}

.home-link svg,
.icon-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.home-link:hover,
.icon-button:hover {
  border-color: rgba(22, 131, 109, 0.34);
  transform: translateY(-1px);
}

.title-block p,
.title-block h1,
.status {
  margin: 0;
}

.title-block p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.title-block h1 {
  font-size: 1.85rem;
  line-height: 1.04;
}

.cycle-chip {
  min-width: 112px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 24px rgba(42, 54, 70, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.72fr);
  gap: 16px;
  align-items: stretch;
}

.timer-panel,
.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.timer-panel {
  min-height: 560px;
  padding: 34px;
  display: grid;
  place-items: center;
  gap: 24px;
}

.dial {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ring-track,
.ring-arc {
  fill: none;
  stroke-width: 12;
}

.ring-track {
  stroke: rgba(28, 34, 48, 0.09);
}

.ring-arc {
  stroke: var(--focus);
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transform: rotate(-90deg);
  transform-origin: 120px 120px;
  transition: stroke 180ms ease, stroke-dashoffset 220ms linear;
}

.tick {
  fill: none;
  stroke: rgba(28, 34, 48, 0.22);
  stroke-linecap: round;
  stroke-width: 5;
}

.dial-core {
  position: relative;
  width: 72%;
  aspect-ratio: 1;
  border: 1px solid rgba(28, 34, 48, 0.1);
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7)),
    var(--focus-soft);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.4);
}

.phase-pill {
  min-width: 88px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--focus);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

#timeDisplay {
  font-size: 5.2rem;
  line-height: 0.94;
  font-variant-numeric: tabular-nums;
}

.cue {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
}

.controls {
  width: min(100%, 380px);
  display: grid;
  grid-template-columns: 1fr 48px 48px;
  gap: 10px;
}

.primary {
  height: 48px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #ffffff;
  background: var(--ink);
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(28, 34, 48, 0.22);
}

.primary:hover {
  transform: translateY(-1px);
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid #ffffff;
}

.primary.is-running .play-icon {
  width: 14px;
  height: 14px;
  border: 0;
  background:
    linear-gradient(90deg, #ffffff 0 35%, transparent 35% 65%, #ffffff 65% 100%);
}

.settings-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.preset {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 4px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  text-align: left;
}

.preset span,
.rhythm-block span,
.range-stack label > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.preset strong {
  font-size: 1.18rem;
}

.preset.is-active {
  border-color: rgba(22, 131, 109, 0.42);
  background: var(--focus-soft);
}

.range-stack {
  display: grid;
  gap: 14px;
}

.range-stack label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.range-stack output {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--focus);
}

.rhythm {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: center;
  background: rgba(255, 255, 255, 0.66);
}

.rhythm-block {
  min-height: 84px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
}

.focus-block {
  background: var(--focus-soft);
}

.reset-block {
  background: var(--reset-soft);
}

.rhythm-block strong {
  font-size: 2rem;
  line-height: 1;
}

.rhythm-line {
  height: 4px;
  background: linear-gradient(90deg, var(--focus), var(--amber), var(--reset));
}

.cue-list {
  min-height: 146px;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.cue-list li {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-weight: 750;
}

.cue-list li::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(28, 34, 48, 0.18);
  flex: 0 0 auto;
}

.cue-list li.is-active {
  color: var(--ink);
  border-color: rgba(22, 131, 109, 0.36);
  background: rgba(223, 243, 234, 0.84);
}

.cue-list li.is-active::after {
  background: var(--focus);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 750;
  text-align: center;
}

.app[data-phase="reset"] .ring-arc {
  stroke: var(--reset);
}

.app[data-phase="reset"] .phase-pill {
  background: var(--reset);
}

.app[data-phase="reset"] .dial-core {
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.72)),
    var(--reset-soft);
}

.app[data-phase="reset"] input[type="range"] {
  accent-color: var(--reset);
}

.app[data-phase="reset"] .cue-list li.is-active {
  border-color: rgba(212, 90, 61, 0.38);
  background: rgba(255, 230, 220, 0.9);
}

.app[data-phase="reset"] .cue-list li.is-active::after {
  background: var(--reset);
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 520px);
    justify-content: start;
    padding: 14px 0 18px;
  }

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

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

  .cycle-chip {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

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

  .timer-panel {
    min-height: auto;
    padding: 20px 16px;
  }

  .dial {
    width: min(100%, 340px);
  }

  #timeDisplay {
    font-size: 3.45rem;
  }

  .cue {
    font-size: 0.92rem;
  }

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

  .preset {
    min-height: 56px;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

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