:root {
  --bg: #fdfcf9; --fg: #1d1d1b; --muted: #6b6a66; --line: #e6e3dc;
  --accent: #b4532a; --accent-soft: #f6e6dd; --tomato: #d9341f;
  /* The page colours itself by what's going on: amber while nothing runs (decide!),
     tomato for focus, green for a short break, blue for a long one. */
  --bg-idle: #fbe9b8; --bg-focus: #f9e0d6; --bg-short: #dff0dc; --bg-long: #dbe8f6;
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614; --fg: #ece9e2; --muted: #9b988f; --line: #2d2c28; --accent: #e8905f; --accent-soft: #3a261c; color-scheme: dark;
    --bg-idle: #3d3010; --bg-focus: #33201a; --bg-short: #1c2e1c; --bg-long: #1a2636;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.5 var(--font-ui);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 600ms ease;
}
body[data-state="idle"] { background: var(--bg-idle); }
body[data-state="focus"] { background: var(--bg-focus); }
body[data-state="short"] { background: var(--bg-short); }
body[data-state="long"] { background: var(--bg-long); }
button { font: inherit; color: inherit; }
a { color: var(--accent); }

.app {
  max-width: 34rem; margin: 0 auto; padding: 32px 16px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}

.top { text-align: center; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.02em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.95rem; }

.phases { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; }
.phases button {
  border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer;
  font-size: 0.9rem; color: var(--muted);
}
.phases button:hover { color: var(--fg); }
.phases button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.phases button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.stage { position: relative; width: min(360px, 82vw); aspect-ratio: 1; }
#tomato { width: 100%; height: 100%; display: block; cursor: grab; position: relative; z-index: 1; }
#tomato.dragging { cursor: grabbing; }
.floor {
  position: absolute; left: 14%; right: 14%; bottom: 4%; height: 10%;
  border-radius: 50%; background: radial-gradient(ellipse at center, rgba(0,0,0,0.22), rgba(0,0,0,0) 70%);
}
@media (prefers-color-scheme: dark) { .floor { background: radial-gradient(ellipse at center, rgba(0,0,0,0.6), rgba(0,0,0,0) 70%); } }
.nogl { color: var(--muted); text-align: center; padding-top: 40%; }
.reorient {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.7; transition: opacity 200ms;
}
.reorient:hover { opacity: 1; background: var(--accent-soft); color: var(--accent); }
.reorient:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; opacity: 1; }
.reorient svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.reorient[hidden] { display: none; }

.readout { text-align: center; }
.time { font: 600 3.6rem/1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.app.running .time { color: var(--accent); }
.set { display: flex; justify-content: center; gap: 7px; margin-top: 12px; min-height: 10px; }
.set i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--accent); opacity: 0.45; }
.set i.full { background: var(--accent); opacity: 1; }
.set i.now { opacity: 1; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.35); } }
.nudge { margin: 10px 0 0; font-size: 0.9rem; color: var(--accent); font-weight: 600; min-height: 1.4em; }
body:not([data-state="idle"]) .nudge { visibility: hidden; }

.controls { display: flex; gap: 10px; align-items: center; }
.controls button {
  border: 1px solid var(--line); background: transparent; border-radius: 12px;
  padding: 10px 18px; cursor: pointer; font-size: 0.95rem;
}
.controls button:hover { background: var(--accent-soft); }
.controls button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.controls .primary { background: var(--accent); color: #fff; border-color: transparent; padding: 12px 30px; font-weight: 600; min-width: 128px; }
.controls .primary:hover { filter: brightness(1.08); background: var(--accent); }
body[data-state="idle"] .controls .primary { animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 50% { transform: scale(1.05); box-shadow: 0 0 0 6px var(--accent-soft); } }
.controls .pip { padding: 10px; display: inline-flex; }
.controls .pip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.controls .pip.on { background: var(--accent-soft); color: var(--accent); }

.settings { width: 100%; max-width: 24rem; border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 0.9rem; }
.settings summary { cursor: pointer; color: var(--muted); }
.settings .grid { display: grid; gap: 10px; padding: 12px 0 6px; }
.settings label { display: flex; align-items: center; gap: 8px; }
.settings label span { flex: 1; }
.settings input[type="number"], .settings select { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; }
.settings input[type="number"] { width: 4.2em; }
.settings .check { gap: 10px; }
.settings .vol { display: flex; align-items: center; gap: 8px; }
.settings .vol label { flex: 1; }
.settings .vol input[type="range"] { width: 7.5em; accent-color: var(--accent); margin: 0; }
.settings .sample { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; font-size: 11px; color: var(--accent); }
.settings .sample:hover { background: var(--accent-soft); }
.settings .clear-set { justify-self: start; border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.settings .clear-set:hover { background: var(--accent-soft); }

.about { color: var(--muted); font-size: 0.85rem; text-align: center; max-width: 28rem; }
.about p { margin: 6px 0; }

@media (prefers-reduced-motion: reduce) { .set i.now, body[data-state="idle"] .controls .primary { animation: none; } body { transition: none; } }
