/* Float Timer: calm, high-contrast, big targets. Light by default, dark when the system asks. */
:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --ink: #16242c;
  --ink-2: #405560;
  --rule: #d6e0e6;
  --disk: #3a86b4;
  --track: #dfe8ee;
  --accent: #2f6f8f;
  --accent-ink: #ffffff;
  --focus: #1b5e80;
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181c;
    --panel: #19232a;
    --ink: #e8f0f4;
    --ink-2: #b3c3cc;
    --rule: #2c3b44;
    --disk: #6cb6df;
    --track: #26343d;
    --accent: #7cc3e0;
    --accent-ink: #0f1a20;
    --focus: #9fd6ee;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--font);
  padding-inline: clamp(16px, 4vw, 40px);
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { max-width: 720px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; }
.home-link { color: var(--ink-2); font-weight: 700; text-decoration: none; padding: 8px 14px; border: 1px solid var(--rule); border-radius: 999px; white-space: nowrap; }
.home-link:hover { color: var(--ink); border-color: var(--accent); }

main { max-width: 720px; margin: 0 auto; padding-bottom: 40px; }

.modes { display: inline-flex; background: var(--panel); border: 1px solid var(--rule); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 18px; }
.modes button { border: 0; background: transparent; padding: 10px 20px; border-radius: 999px; font-weight: 700; color: var(--ink-2); cursor: pointer; min-height: 44px; }
.modes button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 22px; padding: clamp(18px, 4vw, 32px); }

.face { position: relative; width: min(340px, 100%); margin: 0 auto; aspect-ratio: 1; }
.disk { width: 100%; height: 100%; display: block; }
.disk .track { fill: var(--track); }
.disk .left { fill: var(--disk); }
.disk .hub { fill: var(--panel); }
.readout { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.time {
  font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  background: var(--panel); padding: 6px 14px; border-radius: 14px; margin: 0 auto;
}
.doing { margin-top: 8px; font-weight: 700; color: var(--ink-2); max-width: 220px; background: var(--panel); border-radius: 10px; padding: 0 8px; }
.doing:empty { display: none; }
.status { text-align: center; min-height: 1.6em; margin: 14px 0 6px; color: var(--ink-2); font-weight: 700; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 10px 0 6px; }
.controls button, .presets button, .gate button {
  min-height: 48px; padding: 10px 20px; border-radius: 14px; border: 2px solid var(--rule);
  background: var(--panel); font-weight: 700; cursor: pointer;
}
.controls button:hover, .presets button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); min-width: 120px; }
.presets button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 16%, var(--panel)); }

.setup { border: 0; margin: 18px 0 0; padding: 18px 0 0; border-top: 1px solid var(--rule); display: grid; gap: 16px; }
.field { display: grid; gap: 6px; font-weight: 700; }
.field small { font-weight: 400; color: var(--ink-2); }
.field input[type="text"], .field input[type="time"], .field input[type="number"] {
  min-height: 48px; padding: 8px 12px; border: 2px solid var(--rule); border-radius: 12px; background: var(--bg); font-weight: 400; width: 100%;
}
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.presets button { padding: 8px 14px; min-height: 44px; }
.custom { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.custom input { width: 5.5em; min-height: 44px; padding: 6px 10px; border: 2px solid var(--rule); border-radius: 12px; background: var(--bg); }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px; border: 2px solid var(--rule); border-radius: 12px; font-weight: 400; cursor: pointer; }
.chip input, .check input { width: 20px; height: 20px; accent-color: var(--accent); }

.options { margin-top: 18px; background: var(--panel); border: 1px solid var(--rule); border-radius: 16px; padding: 12px 18px; }
.options summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.fine { color: var(--ink-2); font-size: .92rem; text-align: center; margin-top: 18px; }
.fine a { color: inherit; }

.gate { position: fixed; inset: 0; background: color-mix(in oklab, var(--bg) 92%, transparent); display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; z-index: 5; }
.gate .big { font-size: 1.5rem; min-width: 220px; min-height: 72px; border-radius: 20px; }

/* Compact view (in-page fallback, and the floating window) */
.mini { display: grid; justify-items: center; align-content: center; gap: 6px; padding: 10px; height: 100%; background: var(--panel); color: var(--ink); font-family: var(--font); }
.mini .disk { width: min(64vmin, 180px); height: auto; aspect-ratio: 1; }
.mini-time { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.mini-doing { font-weight: 700; color: var(--ink-2); text-align: center; max-width: 90%; overflow-wrap: anywhere; }
.mini-doing:empty { display: none; }
.mini-toggle { min-height: 40px; padding: 6px 16px; border-radius: 12px; border: 2px solid var(--rule); background: var(--panel); font-weight: 700; cursor: pointer; }
body.pip { margin: 0; padding: 0; height: 100vh; background: var(--panel); }
.mini-host { position: fixed; right: 16px; bottom: 16px; width: 220px; height: 280px; border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; box-shadow: 0 8px 30px rgb(0 0 0 / .15); z-index: 4; }
.mini-host .close { position: absolute; top: 6px; right: 6px; min-height: 32px; border: 0; background: transparent; font-weight: 700; cursor: pointer; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 420px) {
  .controls button { flex: 1 1 40%; }
}
