html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  touch-action: none;
  user-select: none;
}

.topbar { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; }
.backlink {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.backlink:active { color: var(--ink); }
.rep-count {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-soft);
}

.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.ring-wrap { position: relative; width: min(64vw, 280px); height: min(64vw, 280px); }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.4s ease;
}
.ring-fill.relaxing { stroke: var(--relax); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.phase-label {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.phase-count {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 44px;
  font-weight: 700;
  color: var(--accent-bright);
}

.stage-meta {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 30ch;
}

.actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; }
button.primary {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #0B1516;
}
button.primary:active { filter: brightness(0.92); }
button.ghost {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-family: inherit;
  padding: 8px;
  cursor: pointer;
}

.state-message {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 40px 20px;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  .ring-fill { transition: stroke-dashoffset 0.05s linear, stroke 0.05s linear; }
}
