/* ---------- themes ----------
   Each theme sets a base palette plus one accent per timer mode; the mode
   rules below pick which accent is live. --accent-soft is derived so themes
   only ever declare solid colours. */
:root,
body[data-theme="midnight"] {
  --bg: #12141c;
  --card: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.1);
  --field: rgba(0, 0, 0, 0.25);
  --track: rgba(255, 255, 255, 0.07);
  --text: #f2f4f8;
  --muted: #99a1b3;
  --on-accent: #14161e;
  --accent-focus: #ff7a6b;
  --accent-short: #57c6a0;
  --accent-long: #6aa8ff;
}
body[data-theme="daylight"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: rgba(255, 255, 255, 0.85);
  --line: rgba(20, 24, 40, 0.12);
  --field: #ffffff;
  --track: rgba(20, 24, 40, 0.09);
  --text: #1b1f2a;
  --muted: #6b7280;
  --on-accent: #ffffff;
  --accent-focus: #e2564a;
  --accent-short: #10916f;
  --accent-long: #3b74ea;
}
body[data-theme="forest"] {
  --bg: #0e1a15;
  --card: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.11);
  --field: rgba(0, 0, 0, 0.25);
  --track: rgba(255, 255, 255, 0.07);
  --text: #eaf5ee;
  --muted: #8fae9c;
  --on-accent: #0e1a15;
  --accent-focus: #ffa45c;
  --accent-short: #6ee7a8;
  --accent-long: #4fd1c5;
}
body[data-theme="sunset"] {
  --bg: #1b1220;
  --card: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.12);
  --field: rgba(0, 0, 0, 0.25);
  --track: rgba(255, 255, 255, 0.08);
  --text: #fdeff6;
  --muted: #b598ad;
  --on-accent: #1b1220;
  --accent-focus: #ff6b9d;
  --accent-short: #ffb86c;
  --accent-long: #a78bfa;
}
body[data-theme="paper"] {
  color-scheme: light;
  --bg: #f4efe6;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(60, 45, 30, 0.15);
  --field: #fffdf9;
  --track: rgba(60, 45, 30, 0.11);
  --text: #2c2620;
  --muted: #7b6f60;
  --on-accent: #fffaf3;
  --accent-focus: #c2543f;
  --accent-short: #4f7f52;
  --accent-long: #4a6fa5;
}

body { --accent: var(--accent-focus); --accent-soft: rgba(255, 255, 255, 0.16); }
body[data-mode="short"] { --accent: var(--accent-short); }
body[data-mode="long"] { --accent: var(--accent-long); }

@supports (color: color-mix(in srgb, red 20%, transparent)) {
  body { --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent); }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", Nunito, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 400ms ease, color 400ms ease;
}

.glow {
  position: fixed;
  inset: -30vh auto auto 50%;
  width: 90vmin;
  height: 90vmin;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent-soft), transparent 62%);
  filter: blur(20px);
  pointer-events: none;
  transition: background 400ms ease;
}

.app {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.head-actions { display: flex; align-items: center; gap: 8px; }
.head h1 { font-size: 1.15rem; letter-spacing: 0.02em; margin: 0; font-weight: 700; }

button { font: inherit; cursor: pointer; border-radius: 999px; transition: all 150ms ease; }

.ghost {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 9px 16px;
}
.ghost:hover { color: var(--text); border-color: var(--accent); }
.ghost.small { padding: 6px 12px; font-size: 0.8rem; }

/* Bare icon control — no chip, just the glyph. */
.icon-btn {
  background: none;
  border: 0;
  padding: 4px;
  line-height: 1;
  font-size: 1.25rem;
  color: var(--muted);
  opacity: 0.9;
}
.icon-btn:hover { opacity: 1; transform: scale(1.1); }
.icon-btn[aria-pressed="false"] { opacity: 0.45; }
.icon-btn[aria-pressed="false"]:hover { opacity: 0.75; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

.modes {
  display: flex;
  gap: 6px;
  margin: 22px 0 8px;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.mode {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  font-size: 0.92rem;
  font-weight: 600;
}
.mode:hover { color: var(--text); }
.mode.is-active { background: var(--accent); color: var(--on-accent); }

.dial {
  position: relative;
  width: min(78vw, 340px);
  aspect-ratio: 1;
  margin: 14px auto 4px;
  display: grid;
  place-items: center;
}
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring-track { stroke: var(--track); }
.ring-fill {
  stroke: var(--accent);
  stroke-dasharray: 691.15;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 300ms linear, stroke 400ms ease;
  filter: drop-shadow(0 0 10px var(--accent-soft));
}

.readout { text-align: center; }
.clock {
  font-size: clamp(3.4rem, 17vw, 5.4rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.phase { margin-top: 10px; color: var(--muted); font-size: 0.95rem; }
body.running .clock { animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.82; } }
@media (prefers-reduced-motion: reduce) {
  body.running .clock { animation: none; }
  .ring-fill { transition: none; }
}

.labelrow { margin: 12px 0 18px; }
#label {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: center;
}
#label::placeholder { color: var(--muted); }
#label:focus { outline: none; border-color: var(--accent); }

.controls { display: flex; gap: 10px; justify-content: center; }
.primary {
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  padding: 14px 44px;
  font-size: 1.05rem;
  box-shadow: 0 8px 26px var(--accent-soft);
}
.primary:hover { transform: translateY(-1px); }

.settings { margin: 24px 0 8px; color: var(--muted); }
.settings summary { cursor: pointer; font-size: 0.9rem; padding: 6px 0; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 0.88rem;
}
.settings-grid label { display: flex; align-items: center; gap: 8px; }
.settings-grid .check { grid-column: 1 / -1; }
.settings-grid input[type="number"] {
  width: 68px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--text);
  font: inherit;
}
.settings-grid input[type="number"]:focus { outline: none; border-color: var(--accent); }
.settings-grid input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.history { margin-top: 26px; }
.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-head h2 { font-size: 1rem; margin: 0; }

.stats { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.stat {
  flex: 1 1 100px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.stat b { display: block; font-size: 1.4rem; font-weight: 800; }
.stat span { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 0.9rem;
}
.history-list li.empty { justify-content: center; color: var(--muted); border-style: dashed; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.focus { background: var(--accent-focus); }
.dot.short { background: var(--accent-short); }
.dot.long { background: var(--accent-long); }
.entry-main { flex: 1; min-width: 0; }
.entry-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-sub { color: var(--muted); font-size: 0.78rem; }
.entry-when { color: var(--muted); font-size: 0.8rem; flex: none; font-variant-numeric: tabular-nums; }
.entry-partial { color: var(--muted); font-style: italic; }

/* ---------- theme picker ---------- */
.theme-wrap { position: relative; }
.theme-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 220px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.theme-panel[hidden] { display: none; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
}
.theme-option:hover { background: var(--card); color: var(--text); }
.theme-option[aria-checked="true"] { color: var(--text); border-color: var(--accent); background: var(--card); }
.theme-option .check { margin-left: auto; color: var(--accent); font-size: 0.8rem; }
.theme-option[aria-checked="false"] .check { visibility: hidden; }
.swatch { display: flex; gap: 3px; flex: none; }
.swatch i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(127, 127, 127, 0.35);
}
