:root {
  color-scheme: light dark;
  --bg: #fafaf8;
  --fg: #1c1d21;
  --muted: #5c606b;
  --card: #ffffff;
  --line: #d3d6dd;
  --accent: #5b46c9;
  --accent-fg: #ffffff;
  --ok: #24803d;
  --warn: #9a4b00;
  --warn-fg: #ffffff;
  --nav-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --fg: #e4e6eb;
    --muted: #a0a4ae;
    --card: #1c1e23;
    --line: #3a3e49;
    --accent: #b5b1ff;
    --accent-fg: #14122b;
    --ok: #7bd88f;
    --warn: #f0b35a;
    --warn-fg: #2a1a00;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* Scrolling to a link target or a focused control must clear the capture bar and the navigation. */
html { -webkit-text-size-adjust: 100%; scroll-padding: 120px 0 calc(var(--nav-h) + 16px); }

body {
  margin: 0;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

button, input, select, textarea { font: inherit; color: inherit; }

button, .more > summary {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 650;
}

button.quiet {
  border-color: transparent;
  background: none;
  color: var(--muted);
}

input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

textarea { min-height: 96px; padding: 10px 14px; resize: vertical; }

a { color: var(--accent); text-underline-offset: 3px; }

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

/* Capture: always on screen, on every view. */

.capture {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: calc(10px + env(safe-area-inset-top)) 14px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

#capture-form, .inline { display: flex; gap: 8px; }

#capture-form { max-width: 640px; margin: 0 auto; }

#capture-form input, .inline label, .inline > input { flex: 1; min-width: 0; }

#capture-form button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 650;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  min-height: 34px;
  margin: 4px auto 0;
  color: var(--muted);
  font-size: 14.5px;
}

.status button { min-height: 32px; padding: 0 12px; font-size: 14.5px; }

/* Views: Now shows unless the address points at another view. */

main { max-width: 640px; margin: 0 auto; padding: 8px 14px 24px; }

.view { display: none; }
.view:target, main:not(:has(.view:target)) #now { display: block; }

h1 { margin: 14px 0 12px; font-size: 15px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }

h2 { margin: 26px 0 10px; font-size: 17px; }

.empty, .summary { color: var(--muted); }

.summary { margin: 0 0 12px; }

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.items > li, .now-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.text { margin: 0 0 2px; overflow-wrap: anywhere; }

.items time, .meta { color: var(--muted); font-size: 13.5px; }

.meta { margin: 0; overflow-wrap: anywhere; }

.meta:empty { display: none; }

.due .meta { color: var(--warn); font-weight: 650; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.inline { margin: 12px 0; }

/* Adding a step: what it is gets a full line; who does it shares the next line with the button. */

form[data-act="add-task"] { flex-wrap: wrap; }

form[data-act="add-task"] input[name="text"] { flex-basis: 100%; }

/* "More", "File it" and "Park" open in place, below the buttons beside them. */

.more > summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
  color: var(--muted);
}

.more > summary::-webkit-details-marker { display: none; }

.more[open] { flex-basis: 100%; order: 1; }

.more[open] > summary { margin-bottom: 4px; border-color: var(--accent); color: var(--fg); }

.more form { display: grid; margin-bottom: 10px; }

.more label > span { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 14.5px; }

.more form button { margin-top: 12px; }

.more > button { margin: 4px 8px 0 0; }

.new-project { display: none; }

form:has(option[value="__new"]:checked) .new-project { display: block; }

/* Projects: the closed card shows the name and the next action. */

.project > details > summary { display: grid; gap: 2px; list-style: none; cursor: pointer; }

.project > details > summary::-webkit-details-marker { display: none; }

.project .name { font-size: 19px; font-weight: 650; overflow-wrap: anywhere; }

.next-line { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }

.next-line.warn { color: var(--warn); font-weight: 650; }

.project[data-state="parked"] .name { color: var(--muted); }

.tasks { list-style: none; margin: 12px 0 0; padding: 0; }

.tasks > li { padding: 12px 0; border-top: 1px solid var(--line); }

#finished { margin-top: 26px; color: var(--muted); }

#finished > summary { cursor: pointer; min-height: 44px; }

/* Now */

.now-text { margin: 0 0 16px; font-size: 24px; line-height: 1.3; font-weight: 650; overflow-wrap: anywhere; }

.now-card > .actions > button { flex: 1; }

.after { margin: 16px 0 0; color: var(--muted); font-size: 14.5px; overflow-wrap: anywhere; }

/* The timer is a 25-minute bar driven by CSS alone. */

.timer label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.timer input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

.timer .on, .timer input:checked + label .off { display: none; }
.timer input:checked + label .on { display: inline; }

.timer .bar { height: 8px; margin-top: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }

.timer .bar span { display: block; width: 0; height: 100%; background: var(--accent); }

.timer input:checked ~ .bar span {
  animation: timer-fill 1500s linear forwards, timer-finished 1s 1500s forwards;
}

@keyframes timer-fill { to { width: 100%; } }
@keyframes timer-finished { to { background: var(--ok); } }

/* Navigation: fixed at the bottom, within thumb reach. */

nav {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-top: 3px solid transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
}

body:has(#inbox:target) nav a[href="#inbox"],
body:has(#projects:target) nav a[href="#projects"],
body:has(#waiting:target) nav a[href="#waiting"],
body:not(:has(.view:target)) nav a[href="#now"],
body:has(#now:target) nav a[href="#now"] {
  border-top-color: var(--accent);
  color: var(--fg);
}

.count:not(:empty) {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 13px;
  text-align: center;
}

.count.warn:not(:empty) { background: var(--warn); color: var(--warn-fg); }
