/* Shared app-wide theme — the design tokens, page frame, bottom dock, card panels, verdict
   chips, run-facts grid, form primitives and calendar schedule picker used by every page
   (/all, /edit, /recent, /settings, /you, /login). Each page links this first, then its own
   <page>.css for page-exclusive rules. This is the single site-wide base.

   The look is the light "feed" aesthetic first built for /all from design sample 29: Roboto on
   white, near-black ink, gray chips, a red accent, rounded borderless cards, ink-active toggles.
   A monospace stack (--mono) survives ONLY for code-like content (the API token value, the
   connect-a-client commands, the OTP code, and .mono). Where a rule goes: used on ≥2 pages →
   here; one page only → that page. */

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-hi: #f2f2f2;
  --soft: #f2f2f2;
  --ink: #0f0f0f;
  --muted: #606060;
  --faint: #909090;
  --line: #e5e5e5;
  --line-hi: #cccccc;
  --field: #ffffff;
  --field-focus: #ffffff;
  --chip: #f2f2f2;
  --hover: #f2f2f2;
  --red: #ff0000;
  --red-deep: #cc0000;
  --live: #cc0000;
  --error: #cc0000;
  --ok: #2ba640;
  --r: 12px;
  /* Luna semantic accents repointed to the light theme so any page rule that still references
     them reads sensibly: blues → ink (headings/active), greens → red (primary action),
     soft tints → chip/hover, coral → error. */
  --blue: var(--ink);
  --blue-bright: var(--ink);
  --blue-deep: var(--ink);
  --blue-soft: var(--chip);
  --green: var(--red);
  --green-deep: var(--red-deep);
  --green-soft: var(--chip);
  --amber: var(--muted);
  --amber-soft: var(--chip);
  --coral: var(--error);
  --coral-soft: #fdeaea;
  --sans: "Roboto", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --dock-h: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  /* the custom pull-to-refresh (shared-nav.js) owns the top-edge pull */
  overscroll-behavior-y: contain;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* pull-to-refresh indicator (driven by shared-nav.js) */
.ptr {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 200;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  transform: translateX(-50%) translateY(-56px);
  transition: transform .2s ease;
  pointer-events: none;
}
.ptr-spin {
  width: 20px;
  height: 20px;
  color: var(--ink);
  transition: transform .15s ease;
}
.ptr.ptr-ready .ptr-spin { transform: rotate(180deg); }
.ptr.ptr-run .ptr-spin { animation: ptr-rot .7s linear infinite; }
@keyframes ptr-rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ptr { transition: none; }
  .ptr-spin { transition: none; }
  .ptr.ptr-run .ptr-spin { animation: none; }
}

/* YouTube-style pivot dock — primary nav in the thumb zone, no top bar. Five peer
   destinations (Home / New / Log / Settings / You). Icon-over-label; the active tab swaps
   to the filled glyph. Full-bleed plate, tabs capped to the 560 column. */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.dock-item {
  flex: 1;
  max-width: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: var(--dock-h);
  padding: 8px 4px 6px;
  color: var(--muted);
  text-decoration: none;
  font: 400 10px/1 var(--sans);
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dock-item svg { display: block; width: 24px; height: 24px; }
.dock-item .i-fill { display: none; }
.dock-item.active { color: var(--ink); font-weight: 500; }
.dock-item.active .i-line { display: none; }
.dock-item.active .i-fill { display: block; }
.dock-item:hover { color: var(--ink); }
.dock-item:focus-visible { outline-offset: -4px; }

main {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--dock-h) + 24px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) {
  main { padding-top: 24px; }
}

/* card panels (settings / you / login / edit blocks) — rounded, hairline border, flat */
.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.block-head h2 {
  margin: 0;
  font: 600 15px/1.2 var(--sans);
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}
.block-head .tag {
  font: 400 12px/1 var(--sans);
  color: var(--muted);
  letter-spacing: normal;
}
.block-body { padding: 14px; }

/* verdict chips (shared by the edit run-history cards and the recent-log card feed) */
.verdict {
  font: 500 11px/1 var(--sans);
  letter-spacing: normal;
  text-transform: none;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  white-space: nowrap;
}
/* "inform" reads as green — a positive hit (a spotted match), not an error. Shared by /recent and
   the /edit run history so both chips match. */
.verdict.inform { background: #e3fbe8; color: #157a37; }
.verdict.watching { background: var(--chip); color: var(--muted); }
.verdict.error { background: var(--coral-soft); color: var(--error); }
.verdict.muted { background: var(--chip); color: var(--muted); }

/* ── run-facts grid (Tokens / Effort / Est. cost) ───────────────────────────────
   The per-run stats shown in an expanded run card on /recent and /edit. Each page positions
   it (recent nests it in a padded .run-body; edit pads it via .watch-result .facts). */
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px 12px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.facts div { min-width: 0; }
.facts dt {
  font: 400 10px/1 var(--sans);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}
.facts dd {
  margin: 0;
  font: 500 13px/1.2 var(--sans);
  letter-spacing: normal;
  color: var(--ink);
  text-transform: none;
}
/* Sub-cent digits of the cost (everything after the 2nd decimal) — underlined, same ink colour. */
.cost-frac { text-decoration: underline; }

/* ── shared form primitives (settings + you + login + edit baseline) ─────────────
   The plain field / button / message pieces those pages compose. /edit links edit.css after
   this base, so its richer field/tile variants override these there. */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font: 500 13px/1.2 var(--sans);
  letter-spacing: normal;
  text-transform: none;
  margin-bottom: 8px;
  color: var(--ink);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-hi);
  background: var(--field);
  padding: 11px 14px;
  font: 400 16px/1.4 var(--sans);
  color: var(--ink);
  outline: none;
  border-radius: 8px;
}
.field textarea { min-height: 128px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--field-focus);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

/* rounded pill button (red primary + neutral gray ghost). Its own class so it never
   collides with /all's card-action `.btn`. */
.formbtn {
  appearance: none;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 22px;
  background: var(--red);
  color: #fff;
  font: 500 14px/1 var(--sans);
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}
.formbtn:hover { background: var(--red-deep); }
.formbtn:active { transform: translateY(1px); }
.formbtn.ghost {
  background: var(--chip);
  color: var(--ink);
}
.formbtn.ghost:hover { background: #e5e5e5; color: var(--ink); }
.formbtn[hidden] { display: none; }

.msg {
  margin: 8px 0 0;
  min-height: 1em;
  font: 400 12px/1.4 var(--sans);
  letter-spacing: normal;
  color: var(--ok);
}
.msg.error { color: var(--error); }

.hint { margin: 0; font: 400 13px/1.5 var(--sans); color: var(--muted); }
.mono { font-family: var(--mono); color: var(--ink); word-break: break-all; }

/* Non-sticky AI disclaimer at the bottom of each page's content (seen on scroll, not pinned). */
.ai-note {
  margin: 24px 4px 0;
  text-align: center;
  font: 400 12px/1.5 var(--sans);
  color: var(--faint);
}

/* Page heading over a stack of .block panels (settings, you). */
.page-title {
  margin: 4px 2px 16px;
  font: 700 20px/1.2 var(--sans);
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
}

/* ── calendar schedule picker (weekday toggles + a 24-button hour grid) ──────
   Shared by the /all watch cards and the /edit schedule block: gray chips, ink-active.
   `.side-head` is the micro-label + current-value row above each control. */
.lbl {
  margin: 0 0 8px;
  font: 500 13px/1.2 var(--sans);
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}
.side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.side-head .lbl { margin: 0; }
.side-head .tz {
  font: 400 12px/1.2 var(--sans);
  color: var(--muted);
  text-align: right;
  word-break: break-word;
}

.sched { display: grid; gap: 12px; }
.hour-head { margin-bottom: 0; }

/* weekday toggle row: seven equal chips */
.day-row { display: flex; gap: 6px; }
.day-btn {
  appearance: none;
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--chip);
  font: 500 13px/1 var(--sans);
  letter-spacing: normal;
  color: var(--ink);
  cursor: pointer;
}

/* the 24 hour toggles: a 6-column grid, any subset selectable */
.hour-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.hour-btn {
  appearance: none;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--chip);
  font: 500 13px/1 var(--sans);
  letter-spacing: normal;
  color: var(--ink);
  cursor: pointer;
}

.day-btn:hover,
.hour-btn:hover { background: #e5e5e5; }
.day-btn.on,
.hour-btn.on {
  background: var(--ink);
  color: #fff;
}
