:root {
  color-scheme: light;
  --ink: #132019;
  --muted: #68736d;
  --line: #d7ded8;
  --surface: #f3f6f1;
  --panel: rgba(255, 255, 255, 0.9);
  --fast: #d64538;
  --easy: #177a62;
  --warm: #d4901c;
  --cool: #2f69a3;
  --track: #e2e8e1;
  --shadow: 0 18px 50px rgba(24, 43, 32, 0.13);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--surface);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(23, 122, 98, 0.13), transparent 34%),
    linear-gradient(315deg, rgba(214, 69, 56, 0.12), transparent 38%),
    var(--surface);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1080px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
}

.run-panel,
.setting-block {
  background: var(--panel);
  border: 1px solid rgba(215, 222, 216, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.run-panel {
  min-height: calc(100vh - 42px);
  padding: 20px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 18px;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 2.4vw, 2.25rem);
  line-height: 1.08;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--ink);
  background: #eef3ed;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.2rem;
}

.icon-button.is-on {
  color: #fff;
  background: var(--easy);
  border-color: var(--easy);
}

.run-face {
  --progress: 0deg;
  --accent: var(--warm);
  display: grid;
  place-items: center;
}

.ring {
  width: min(76vw, 452px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent) var(--progress), var(--track) 0),
    linear-gradient(#fff, #fff);
  box-shadow: inset 0 0 0 1px rgba(19, 32, 25, 0.04), 0 20px 62px rgba(23, 122, 98, 0.17);
  transition: background 180ms linear;
}

.ring-core {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #fff, #f8faf7);
  border: 1px solid rgba(215, 222, 216, 0.92);
  display: grid;
  place-items: center;
  align-content: center;
  padding: 24px;
  text-align: center;
}

.round-label {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.phase-name {
  min-height: 31px;
  color: var(--accent);
  font-size: clamp(1.15rem, 3vw, 1.65rem);
  font-weight: 900;
}

.time-readout {
  width: 100%;
  margin: 10px 0 8px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.4rem, 12vw, 6.3rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

.next-label {
  min-height: 42px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

.timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  min-height: 14px;
}

.timeline span {
  min-width: 7px;
  border-radius: 999px;
  background: var(--track);
  opacity: 0.8;
}

.timeline span.is-active {
  opacity: 1;
  outline: 2px solid rgba(19, 32, 25, 0.25);
  outline-offset: 2px;
}

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

.control {
  min-height: 54px;
  border-radius: 8px;
  font-weight: 850;
}

.control.primary {
  color: #fff;
  background: var(--ink);
}

.control.secondary {
  color: var(--ink);
  background: #edf2ed;
  border: 1px solid var(--line);
}

.settings {
  display: grid;
  align-content: start;
  gap: 14px;
}

.setting-block {
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.preset-grid button {
  min-height: 46px;
  color: var(--ink);
  background: #eef2ed;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.preset-grid button:first-child {
  grid-column: 1 / -1;
}

.preset-grid button.is-selected {
  color: #fff;
  background: var(--easy);
  border-color: var(--easy);
}

.number-grid label,
.select-field,
.range-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 780;
}

.number-grid input,
.select-field select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.number-grid input:focus,
.select-field select:focus,
.range-field input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(212, 144, 28, 0.34);
  outline-offset: 2px;
}

.option-list {
  display: grid;
  gap: 8px;
}

.switch-row {
  min-height: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f3f6f3;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 780;
}

.switch-row input {
  width: 48px;
  height: 28px;
  margin: 0;
  accent-color: var(--easy);
}

.range-field input {
  width: 100%;
  accent-color: var(--fast);
}

.ios-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  padding: 0 2px;
}

@media (max-width: 780px) {
  .app-shell {
    min-height: 100svh;
    grid-template-columns: 1fr;
    padding-inline: 12px;
    gap: 12px;
  }

  .run-panel {
    min-height: auto;
    padding: 16px;
    gap: 16px;
  }

  .ring {
    width: min(88vw, 390px);
  }

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

  .control {
    min-height: 50px;
  }
}

@media (max-width: 390px) {
  .time-readout {
    font-size: 3.15rem;
  }

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

  .preset-grid button:first-child {
    grid-column: auto;
  }
}
