:root {
  --bg: #14161a;  /* page, surface and text as in Баланс and Калории */
  --surface: #1c1c1e;
  --text: #ffffff;
  --muted: #bdbdbd;
  --accent: #e3b873;
  --on-accent: #000000;
  --sound-on: #7fbf8e;
  --sound-off: #6b6f76;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  transition: background-color 1.2s ease;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
}

button {
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.presets {
  display: flex;
  gap: 12px;
}

.presets button {
  width: 64px;
  height: 44px;
  border-radius: 22px;
  background: var(--surface);
  font-size: 18px;
}

.presets button[aria-pressed="true"] {
  outline: 2px solid var(--accent);
}

.dial {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  font-size: 28px;
  color: var(--muted);
}

#clock {
  min-width: 5ch;
  text-align: center;
  font-size: clamp(56px, 18vw, 88px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.start {
  width: 100%;
  max-width: 240px;
  height: 56px;
  border-radius: 28px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 20px;
  font-weight: 600;
}

.hint {
  min-height: 2.6em;
  margin: -12px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.total {
  margin: 0;
  font-size: 16px;
}

.sound {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  color: var(--sound-on);
}

.sound[aria-pressed="false"] {
  color: var(--sound-off);
}

.sound[aria-pressed="true"] .off,
.sound[aria-pressed="false"] .on {
  display: none;
}

.about {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 16px max(48px, env(safe-area-inset-bottom));
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.about h2 {
  margin: 24px 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.about ol {
  margin: 0;
  padding-left: 20px;
}

.about p {
  margin: 0 0 8px;
}

.about a {
  color: inherit;
}

.promo {
  width: min(340px, calc(100% - 32px));
  padding: 28px 24px 16px;
  border: none;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

/* Focus goes to the card itself, not the button, so it opens without a focus ring. */
.promo:focus {
  outline: none;
}

.promo::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.promo img {
  border-radius: 12px;
}

.promo h2 {
  margin: 12px 0 8px;
  font-size: 18px;
  font-weight: 600;
}

.promo p {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.promo .start {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  text-decoration: none;
}

.promo form {
  margin-top: 4px;
}

.close {
  background: transparent;
  font-size: 15px;
  color: var(--muted);
  padding: 12px 16px;
}

/* During a session the page goes black in either scheme, the clock stays bright and the rest
   fades to a trace: Stop and the sound switch still work. */
body.running {
  --bg: #000000;
  --surface: #1c1c1e;
  --text: #ffffff;
  --muted: #bdbdbd;
  --sound-on: #7fbf8e;
  --sound-off: #6b6f76;
  color-scheme: dark;
}

h1,
.start,
.hint,
.footer {
  transition: opacity 1.2s ease;
}

.running .presets,
.running .step,
.running .about {
  visibility: hidden;
}

.running h1,
.running .start,
.running .hint,
.running .footer {
  opacity: 0.2;
}

/* Keyboard and mouse bring a control back; a tap doesn't, so the screen stays dark. */
.running .start:focus-visible,
.running .footer:has(:focus-visible) {
  opacity: 0.6;
}

@media (hover: hover) {
  .running .start:hover,
  .running .footer:hover {
    opacity: 0.6;
  }
}

.running .start {
  background: var(--surface);
  color: var(--text);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
