/* Today — one phone, one user, black screen.
   Colour has exactly one meaning here: how many days a task has been carried. */

:root {
  --bg: #000;
  --fg: #f5f5f5;
  --muted: #9a9a9a;
  --dim: #5c5c5c;
  --line: #2a2a2a;
  --panel: #141414;
  --age1: #ffb020;
  --age2: #ff7a1a;
  --age3: #ff3b3b;
  --tap: 56px;
  --pad: 20px;
  --tabs: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); min-height: 100%; }
body { overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.view {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 16px) var(--pad) calc(var(--tabs) + var(--safe-b) + 24px);
  display: flex;
  flex-direction: column;
}
.view.no-tabs { padding-bottom: calc(var(--safe-b) + 24px); }

/* ------------------------------------------------------------ text */
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-size: 22px; font-weight: 600; margin: 0 0 8px; }
p  { margin: 0 0 12px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 15px; }
.num { font-variant-numeric: tabular-nums; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head .count { font-size: 28px; font-weight: 700; }
.head .count small { font-size: 17px; font-weight: 400; color: var(--muted); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 60px; padding: 14px 20px;
  border: 2px solid var(--fg); border-radius: 14px;
  background: var(--fg); color: var(--bg);
  font-size: 19px; font-weight: 600; text-decoration: none;
  cursor: pointer; user-select: none;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.quiet { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; min-height: 52px; }
.btn.danger { background: transparent; color: var(--age3); border-color: var(--age3); }
.btn.sm { min-height: 48px; font-size: 17px; padding: 10px 16px; }
.btn.inline { display: inline-flex; width: auto; }
.btn-col { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.btn-row { display: flex; gap: 12px; margin-top: 16px; }
.btn-row .btn { flex: 1; }
.bottom { margin-top: auto; padding-top: 24px; }

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

/* ------------------------------------------------------------ fields */
.field {
  width: 100%; min-height: var(--tap); padding: 14px 16px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  color: var(--fg); font-size: 19px;
}
.field:focus { border-color: var(--fg); outline: none; }
.field::placeholder { color: var(--dim); }
textarea.field { resize: none; line-height: 1.3; }
label.lbl { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 15px; }
.row2 { display: flex; gap: 12px; }
.row2 > * { flex: 1; }

/* ------------------------------------------------------------ capture */
.capture { justify-content: flex-start; }
.capture textarea {
  flex: 1; min-height: 40vh; font-size: 26px; font-weight: 500; line-height: 1.25;
  padding: 18px; border-radius: 18px;
}
.capture .status { min-height: 24px; margin: 10px 2px 0; color: var(--muted); font-size: 15px; }
.capture .status.pending { color: var(--age1); }

/* ------------------------------------------------------------ task list */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { border-bottom: 1px solid var(--line); }
.list .row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px;
  width: 100%; min-height: var(--tap); padding: 12px 0;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.list .row:active { background: var(--panel); }
.row .title { font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.row .effort { color: var(--muted); font-size: 15px; white-space: nowrap; }
.row .pick { color: var(--fg); font-weight: 600; }
.row.selected { background: var(--panel); }
.row.selected .pick { color: var(--age1); }

/* the age mark: the one thing on screen that is allowed to be a colour */
.age {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px;
  font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums;
  color: var(--bg);
}
.age.a0 { visibility: hidden; }
.age.a1 { background: var(--age1); }
.age.a2 { background: var(--age2); }
.age.a3 { background: var(--age3); }
.age.big { min-width: 56px; height: 56px; font-size: 26px; border-radius: 14px; }
.age-text.a1 { color: var(--age1); }
.age-text.a2 { color: var(--age2); }
.age-text.a3 { color: var(--age3); }

.empty { padding: 48px 0; color: var(--muted); font-size: 19px; text-align: left; }

/* ------------------------------------------------------------ next */
.next { justify-content: space-between; }
.next .meta { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; color: var(--muted); }
.next .title {
  font-size: clamp(30px, 9vw, 44px); font-weight: 700; line-height: 1.12; letter-spacing: -0.02em;
  margin: 0 0 20px; overflow-wrap: anywhere;
}
.next .notes { color: var(--muted); font-size: 18px; white-space: pre-wrap; max-height: 30vh; overflow: auto; }
.next .blocked { color: var(--age3); font-weight: 600; }

/* ------------------------------------------------------------ detail */
.detail .title { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 6px 0 10px; overflow-wrap: anywhere; }
.detail .notes { white-space: pre-wrap; color: var(--muted); margin-bottom: 16px; }
.detail .facts { color: var(--muted); font-size: 15px; margin-bottom: 16px; }
.detail .facts div { padding: 4px 0; }
.back { display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0 8px -6px; padding: 0 6px; color: var(--muted); text-decoration: none; font-size: 16px; }

/* ------------------------------------------------------------ close-out steps */
.step .progress { display: flex; gap: 6px; margin-bottom: 20px; }
.step .progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.step .progress i.on { background: var(--fg); }
.step .q { font-size: 22px; color: var(--muted); margin-bottom: 8px; }
.step .task-title { font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 12px; overflow-wrap: anywhere; }
.step .warn { color: var(--age2); }

.stat { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); }
.stat b { font-size: 26px; font-weight: 700; }

/* ------------------------------------------------------------ tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--dim); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabs a.on { color: var(--fg); }
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[data-tab="next"].on svg { fill: currentColor; }
.tabs .badge { position: absolute; }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; left: var(--pad); right: var(--pad); bottom: calc(var(--tabs) + var(--safe-b) + 16px); z-index: 20;
  padding: 14px 18px; border-radius: 14px; background: var(--fg); color: var(--bg);
  font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
.toast.err { background: var(--age3); color: #000; }

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: transform .08s; }
}
@media (min-width: 640px) and (max-width: 959px) {
  .view, .tabs, .toast { max-width: 560px; margin-left: auto; margin-right: auto; }
  .tabs { left: 0; right: 0; }
}

/* ============================================================ themes
   Dark is the default (the phone, the evening). Light follows the system or
   the switch on the settings screen. Same eight tokens, nothing else changes. */
:root[data-theme="light"] {
  --bg: #fff; --fg: #111; --muted: #6b6b6b; --dim: #a3a3a3; --line: #e4e4e4; --panel: #f3f3f3;
  --age1: #b96f00; --age2: #c74a00; --age3: #cf1d1d;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fff; --fg: #111; --muted: #6b6b6b; --dim: #a3a3a3; --line: #e4e4e4; --panel: #f3f3f3;
    --age1: #b96f00; --age2: #c74a00; --age3: #cf1d1d;
    color-scheme: light;
  }
}
/* badges keep white numerals on the age colours in both themes */
.age { color: #fff; }
.toast.err { color: #fff; }

.theme-switch { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.theme-switch button {
  flex: 1; min-height: 44px; background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer;
}
.theme-switch button.on { background: var(--fg); color: var(--bg); }

/* ============================================================ desktop
   A sidebar with the clock, the day and a month calendar; the bottom tabs go
   away; the dashboard route lays Next, Today, Capture and Inbox side by side. */
.side { display: none; }
@media (min-width: 960px) {
  body { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
  body.bare { display: block; }
  .side {
    display: flex; flex-direction: column; gap: 28px;
    position: sticky; top: 0; height: 100vh; padding: 32px 24px;
    border-right: 1px solid var(--line); overflow-y: auto;
  }
  .tabs { display: none; }
  .view, .toast { max-width: none; margin: 0; }
  .view { min-height: 0; padding: 36px 44px 48px; max-width: 820px; }
  .view.dashboard { max-width: 1280px; }
  .bottom { margin-top: 28px; }
  .toast { left: auto; right: 28px; bottom: 28px; width: 380px; }
  .capture textarea { min-height: 220px; flex: 0 0 auto; }
  .next { justify-content: flex-start; gap: 24px; }

  .clock .time { font-size: 56px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
  .clock .date { color: var(--muted); font-size: 17px; margin-top: 8px; }

  .sidenav { display: flex; flex-direction: column; gap: 2px; }
  .sidenav a {
    display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px;
    color: var(--muted); text-decoration: none; font-size: 16px;
  }
  .sidenav a:hover { background: var(--panel); color: var(--fg); }
  .sidenav a.on { color: var(--fg); font-weight: 600; }
  .side .theme-switch { margin-top: auto; }

  /* dashboard: two columns, sections divided by rules rather than boxes */
  .dash { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0 56px; align-items: start; }
  .dash .panel { margin-bottom: 40px; }
  .dash .panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
  .dash .panel-head h2 { margin: 0; }
  .dash .panel-head a { color: var(--muted); text-decoration: none; font-size: 15px; }
  .dash .panel-head a:hover { color: var(--fg); }
  .dash .next-title { font-size: 34px; font-weight: 700; line-height: 1.12; letter-spacing: -0.02em; margin: 8px 0 12px; overflow-wrap: anywhere; }
  .dash .btn-row { margin-top: 12px; }
  .dash .btn { min-height: 52px; font-size: 17px; }
  .dash textarea.field { min-height: 112px; font-size: 19px; }
  .dash .status { min-height: 22px; margin: 8px 2px 0; color: var(--muted); font-size: 14px; }
  .dash .status.pending { color: var(--age1); }
  .dash .list .row { min-height: 50px; padding: 9px 0; }
}

/* ------------------------------------------------------------ calendar */
.cal .cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal .cal-head b { font-size: 16px; font-weight: 600; }
.cal .cal-head button { background: none; border: 0; color: var(--muted); font-size: 22px; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; }
.cal .cal-head button:hover { background: var(--panel); color: var(--fg); }
.cal .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal .wd { text-align: center; color: var(--dim); font-size: 11px; padding: 4px 0 6px; }
.cal .day {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 34px; border-radius: 8px; font-size: 14px; font-variant-numeric: tabular-nums;
  background: none; border: 0; color: var(--fg); cursor: default;
}
.cal .day.out { color: var(--dim); }
.cal .day.today { outline: 2px solid var(--fg); outline-offset: -2px; font-weight: 700; }
.cal .day.closed { background: var(--panel); }
.cal .day.has { cursor: pointer; }
.cal .day.has:hover { background: var(--panel); }
.cal .day .dot { position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--age1); }
.cal .day.missed .dot { background: var(--age3); }
.cal .legend { display: flex; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.cal .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.cal .cal-day-list { margin-top: 10px; }
.cal .cal-day-list .row { min-height: 40px; padding: 6px 0; grid-template-columns: 1fr; }
.cal .cal-day-list .title { font-size: 14px; }
