:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #efefeb;
  --text: #1b1c1f;
  --muted: #6b6d74;
  --border: #e2e2dd;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eceafd;
  --danger: #c2362b;
  --warn: #c76a00;
  --ok: #1f8a4c;
  --urgent: #d93025;
  --high: #e8890c;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1b1d21;
    --surface-2: #25272c;
    --text: #ececef;
    --muted: #9a9ca5;
    --border: #2e3036;
    --accent: #8b85ff;
    --accent-text: #111;
    --accent-soft: #2a2850;
    --danger: #ff6b5e;
    --warn: #ffab40;
    --ok: #4cc47e;
    --urgent: #ff6b5e;
    --high: #ffab40;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.top-row { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.chipbar {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.chipbar::-webkit-scrollbar { display: none; }
.chipbar.more-right { mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
@media (max-width: 767px) {
  .chipbar { transition: max-height .2s ease-out, padding-bottom .2s ease-out, opacity .15s; max-height: 60px; }
  .top.tucked .chipbar { max-height: 0; padding-bottom: 0; opacity: 0; pointer-events: none; }
}
@media (max-width: 767px) and (prefers-reduced-motion: reduce) { .chipbar { transition: none; } }
.chipbar button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.chipbar button .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); }
.chipbar button.on { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.brand { display: flex; align-items: baseline; gap: 8px; margin-right: auto; min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.brand span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; padding: 6px; color: var(--muted); cursor: pointer; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
body.wide main { max-width: 1240px; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabs button {
  flex: 0 1 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 11px; padding: 4px; cursor: pointer;
}
.tabs svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--accent); }
.tabs button { position: relative; }
.tabs .n {
  position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.group.needs-you h2.alert { color: var(--danger); }
.needs-you .prompt-card { margin: 0 0 8px; }
/* Needs you / Happening now: plain sections; the heading and its count carry the meaning. Red is kept for what is
   overdue, blocked or asking, so it still means something when it appears. */
.group.needs-you > .list, .group.happening > .list { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.group.needs-you .row, .group.happening .row { border-bottom-color: color-mix(in srgb, var(--text) 10%, transparent); }

/* buttons */
.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
  padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { border-color: transparent; background: none; color: var(--accent); padding-left: 4px; padding-right: 4px; }
.btn.danger { color: var(--danger); background: none; margin-top: 20px; }
.btn:disabled { opacity: .5; }

/* forms */
input:not([type=checkbox]), select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
/* Keyboard focus is always visible; mouse and touch focus stay quiet. */
:is(a, button, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
textarea { resize: vertical; }
::placeholder { color: var(--muted); opacity: 1; } /* the default grey was 3.7:1 in dark mode */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label > * { color: var(--text); font-size: 16px; }

.quick-add { display: flex; gap: 8px; margin-bottom: 10px; }
.filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 16px; }
.filters select { width: auto; font-size: 14px; }
@media (max-width: 480px) {
  .brand span { display: none; }
}

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.group { margin-bottom: 22px; }
.group > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 0 0 8px 4px; display: flex; gap: 6px; align-items: center;
}
.group > h2 .count { background: var(--surface-2); border-radius: 10px; padding: 0 7px; font-size: 12px; letter-spacing: 0; }
.group > h2.alert { color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; overflow: hidden; }

.row {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px 11px 10px;
  border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.row .body { flex: 1; min-width: 0; }
.row > .check { order: -1; }
.row-link { color: inherit; text-decoration: none; }
.row-link:focus-visible { outline-offset: 3px; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row.closed .title { color: var(--muted); text-decoration: line-through; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.chip { background: var(--surface-2); border-radius: 6px; padding: 1px 7px; }
.chip.over { background: color-mix(in srgb, var(--danger) 12%, transparent); color: color-mix(in srgb, var(--danger) 82%, var(--text)); }
.chip.today { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.agent { background: var(--accent-soft); color: var(--accent); }

.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--border); background: none; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: transparent;
}
.check:hover { border-color: var(--ok); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check svg { width: 14px; height: 14px; }

.pill { flex: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; margin-top: 2px; white-space: nowrap; }
.pill.todo { background: var(--surface-2); color: var(--text); }
.pill.in_progress { background: var(--accent-soft); color: var(--accent); }
.pill.waiting { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.done { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.cancelled { background: var(--surface-2); color: var(--muted); }

/* today */
.hello { margin: 4px 4px 14px; }
.hello h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; }

.md h1, .md h2, .md h3 { font-size: 16px; margin: 14px 0 4px; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md p { margin: 6px 0; }
.md ul { margin: 4px 0; padding-left: 20px; }
.md code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; font-size: 14px; }
.md a { color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* activity */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .who { font-weight: 600; }
.timeline .note { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline a { color: var(--accent); cursor: pointer; text-decoration: none; }

/* dialogs */
dialog.sheet {
  border: 0; padding: 0; background: var(--bg); color: var(--text);
  width: min(640px, 100vw); max-width: 100vw; max-height: 100dvh; border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog.sheet.small { width: min(420px, 100vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
@media (max-width: 640px) {
  dialog.sheet:not(.small) { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}
.sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.sheet-body { padding: 16px; overflow: auto; }
.title-input { font-size: 19px !important; font-weight: 600; line-height: 1.3; margin-bottom: 14px; resize: none; overflow: hidden; field-sizing: content; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
.link-list { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.link-list:empty { display: none; }
.link-list a { text-decoration: none; font-size: 14px; padding: 3px 9px; }
.note-add { display: flex; gap: 8px; margin: 8px 0 16px; }
h3.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
#item-events { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
#item-events:empty { display: none; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.long { border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); cursor: pointer; max-width: min(92vw, 520px); }

/* run with agent */
.run-mini {
  flex: none; width: 28px; height: 28px; margin-top: -2px; border-radius: 50%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--agent, var(--accent)) 16%, transparent); color: var(--agent, var(--accent));
  display: grid; place-items: center;
}
.run-mini:hover { background: var(--agent, var(--accent)); color: #fff; }
.run-mini svg { width: 14px; height: 14px; margin-left: 2px; }
.run-mini.live { cursor: default; background: color-mix(in srgb, var(--agent, var(--accent)) 16%, transparent); }
.run-mini.live .face { animation: rb-pulse 1.6s ease-in-out infinite; }
html[data-anim="off"] .run-mini.live .face { animation: none; }
.chip.run-chip { font-weight: 600; }
.chip.run-chip.running { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.chip.run-chip.queued { background: var(--accent-soft); color: var(--accent); }
.chip-btn.ok { border-style: solid; border-color: transparent; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* permission prompts: a headless run asks, you answer on the phone */
.prompt-card {
  display: flex; flex-direction: column; gap: 8px; margin: -4px 0 14px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 12%, transparent);
}
.prompt-card.answered { opacity: .5; }
.prompt-head { display: flex; align-items: center; gap: 10px; }
.prompt-head .run-bot { flex: none; line-height: 0; animation: rb-pulse 2s ease-in-out infinite; }
html[data-anim="off"] .prompt-head .run-bot { animation: none; }
.prompt-head .run-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.prompt-head .run-txt b { color: var(--agent, var(--text)); font-size: 14px; }
.prompt-head .run-txt .ref { align-self: flex-start; }
.prompt-cmd {
  margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text);
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow: auto;
}
.prompt-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.prompt-actions { display: flex; gap: 8px; margin-left: auto; }
.prompt-actions .btn { min-width: 84px; }
.prompt-actions .btn.deny { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.prompt-actions .btn.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.deny-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.deny-form .deny-why { flex: 1 1 160px; min-width: 0; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.prompts-group .prompt-card { margin: 0 0 8px; }
.prompts-group .prompt-card:last-child { margin-bottom: 0; }
.prompts-group { margin-bottom: 20px; }
.chip.run-chip.asking { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* active run card and recent runs in the sheet */
.run-card {
  display: flex; align-items: center; gap: 10px; margin: -4px 0 14px; padding: 8px 10px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.run-card.live { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.run-card .run-bot { flex: none; line-height: 0; }
.run-card.live .run-bot { animation: rb-pulse 2s ease-in-out infinite; }
html[data-anim="off"] .run-card.live .run-bot { animation: none; }
.run-card .run-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.run-card .run-txt b { color: var(--text); font-size: 14px; }
.run-card .run-txt > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.run-card .btn { flex: none; }
.runs { display: flex; flex-direction: column; gap: 4px; margin: -6px 0 14px; }
.run-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; padding: 3px 0; }
.run-line .run-when { font-size: 12px; }
.run-line .run-sum { flex-basis: 100%; color: var(--text); overflow-wrap: anywhere; }
.run-line .run-full { display: none; flex-basis: 100%; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text); }
.run-line.open .run-sum { display: none; }
.run-line.open .run-full { display: block; }
.runs .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.st-runs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 2px; }
.st-run {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; border: 1px dashed color-mix(in srgb, var(--text) 25%, transparent);
  background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 2px 8px 2px 5px;
  font-size: 12px; cursor: pointer;
}
.st-run.on { border-style: solid; }
.st-run.live { border-style: solid; border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.st-run.err { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.st-run .caret { color: var(--muted); font-size: 11px; }
.st-log { max-height: 300px; margin: 0; }
.steps li.st-log-li { display: block; padding: 0 10px 8px 12px; border-bottom: 1px solid var(--border); } /* a step's log, full row width */
.steps li.st-log-li:last-child { border-bottom: 0; }
/* long agent texts (commands, paths, digests) must wrap instead of widening the page */
.run-card .run-txt, .prompt-head .run-txt, .row .why { overflow-wrap: anywhere; }
.run-line .run-full { min-width: 0; }
.run-log {
  flex-basis: 100%; max-height: 360px; overflow: auto; margin: 6px 0 4px; padding: 6px 8px; border-radius: 10px;
  background: var(--surface-2); font-size: 12.5px; color: var(--text); cursor: default;
}
.run-card + .run-log { margin: -8px 0 14px; }
/* scrolled up in a live log: new lines wait below, this jumps back and follows again */
.log-new {
  position: sticky; bottom: 2px; display: block; margin: 4px 0 0 auto; padding: 3px 10px; border: 0; border-radius: 999px;
  background: var(--text); color: var(--bg); font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.4; cursor: pointer; box-shadow: 0 2px 6px rgb(0 0 0 / .18);
}
.log-new[hidden] { display: none; }
.log-actor { display: flex; align-items: center; gap: 5px; margin: 6px 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.log-actor:first-child { margin-top: 0; }
.log-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 6px; padding: 2px 0; align-items: baseline; }
.log-row .g { color: var(--muted); }
.log-row .t { overflow-wrap: anywhere; white-space: pre-wrap; }
.log-row.tool .t { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.log-row.result .t { color: var(--muted); }
.log-row.text .t { font-style: italic; }
.log-row.done .t, .log-row.done .g { color: var(--ok); font-weight: 600; }
.log-row.err .t, .log-row.err .g { color: var(--danger); }
.log-row .when { font-size: 11px; color: var(--muted); white-space: nowrap; }
.log-row.more { cursor: pointer; }
.log-row .d { display: none; grid-column: 2 / 4; margin: 2px 0 4px; padding: 6px 8px; border-radius: 8px; background: var(--surface); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }
.log-row.open .d { display: block; }
.btn.ghost.small.on { background: var(--accent-soft); }
.pill.run-queued { background: var(--accent-soft); color: var(--accent); }
.pill.run-running { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.run-done { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.run-paused { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.run-failed, .pill.run-lost { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.pill.run-cancelled { background: var(--surface-2); color: var(--muted); }

.chip.age { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.steps-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 4px; margin-left: auto; }
.approve-list { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; }
.approve-row { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: baseline; font-size: 14px; }
.approve-row .num { font-weight: 700; color: var(--muted); }
.approve-row .txt { overflow-wrap: anywhere; }
.approve-row .who { font-size: 12px; color: var(--muted); }
/* run / approve chooser */
.run-dialog .run-body { padding: 20px 18px 16px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.run-dialog .run-face { line-height: 0; }
.run-dialog strong { font-size: 17px; }
.run-dialog .run-step-text { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.run-dialog .run-warn { margin: 0; font-size: 13px; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-radius: 10px; padding: 8px 10px; }
.run-dialog .next-body { text-align: left; align-items: stretch; }
.next-body > strong { text-align: center; }
.next-body p { margin: 0; }
.next-body textarea { width: 100%; resize: vertical; font: inherit; }
.next-row { display: flex; align-items: center; gap: 8px; }
.next-row label { margin: 0; }
.next-row select { flex: 1; width: auto; }
.next-check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; }
.next-check input { width: auto; min-height: 0; margin: 0; }
.run-dialog .run-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 6px; }
.run-dialog .btn.primary { background: var(--agent, var(--accent)); border-color: var(--agent, var(--accent)); }

/* upcoming */
.up-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 4px 14px; flex-wrap: wrap; }
.up-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.up-head .sub { font-size: 13px; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(160px, calc((100% - (var(--days, 5) - 1) * 12px) / var(--days, 5))), 1fr)); gap: 12px; margin-bottom: 22px; align-items: start; }
/* (one column per day when each gets 160px or more, as at full width on the iPad and the Mac; fewer, wrapping, when not) */
.day { overflow: hidden; }
.day > header {
  display: flex; align-items: baseline; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.day > header b { font-size: 15px; }
.day > header .date { color: var(--muted); font-size: 13px; }
.day > header .count { margin-left: auto; background: var(--surface-2); border-radius: 10px; padding: 0 8px; font-size: 12px; color: var(--muted); }
.day.is-today > header { background: var(--accent-soft); }
.day.is-today > header b { color: var(--accent); }
.day.weekend > header b { color: var(--muted); }
.day .free { padding: 14px 12px; color: var(--muted); font-size: 14px; }
.day .row { padding-top: 9px; padding-bottom: 9px; }
.day .row .pill { display: none; }
.load { height: 3px; background: var(--surface-2); }
.load span { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }
.load.busy span { background: var(--warn); }
details.group > summary {
  cursor: pointer; list-style: none; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 0 0 8px 4px; display: flex; gap: 6px; align-items: center;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "▸"; transition: transform .15s; }
details.group[open] > summary::before { transform: rotate(90deg); }
details.group > summary .count { background: var(--surface-2); border-radius: 10px; padding: 0 7px; font-size: 12px; letter-spacing: 0; }

/* dispatch overlay */
.dispatch {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 20, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: d-fade .25s ease-out both;
}
.dispatch.closing { animation: d-fade-out .3s ease-in both; }
dialog.dispatch { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; color: var(--text); }
dialog.dispatch:not([open]) { display: none; }
dialog.dispatch::backdrop { background: transparent; } /* the dim is the dialog's own background */
.dispatch-card {
  width: min(340px, 100%); background: var(--surface); border-radius: 20px; padding: 18px 18px 20px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: d-pop .35s cubic-bezier(.2,1.4,.4,1) both;
}
.stage { position: relative; height: 190px; overflow: hidden; border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--agent) 10%, var(--surface)) 0%, var(--surface) 100%); }
.ground { position: absolute; left: 0; right: 0; bottom: 14px; height: 2px; background: var(--border); }
.bot { position: absolute; left: calc(50% - 60px); bottom: 14px; overflow: visible; }
.bot .fill-agent { fill: var(--agent); }
.bot .fill-dark { fill: color-mix(in srgb, var(--agent) 62%, #111); }
.bot .stroke-dark { stroke: color-mix(in srgb, var(--agent) 62%, #111); }
.bot .arm, .bot .leg, .bot .eyes { transform-box: fill-box; }
.bot .arm, .bot .leg { transform-origin: 50% 8%; }
.bot .eyes { transform-origin: 50% 50%; }
.bubble {
  position: absolute; left: calc(50% + 34px); top: 14px; background: var(--text); color: var(--bg); font-weight: 700; font-size: 13px;
  padding: 5px 10px; border-radius: 12px 12px 12px 3px; opacity: 0;
}
.puff { position: absolute; bottom: 14px; width: 18px; height: 18px; border-radius: 50%; background: var(--border); opacity: 0; }
.puff.p1 { left: calc(50% - 30px); } .puff.p2 { left: calc(50% - 46px); } .puff.p3 { left: calc(50% - 60px); }
.speed { position: absolute; left: calc(50% - 10px); height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--agent) 55%, transparent); opacity: 0; }
.speed.s1 { top: 70px; width: 40px; } .speed.s2 { top: 96px; width: 60px; } .speed.s3 { top: 122px; width: 34px; }
.dispatch-text { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; opacity: 0; }
.dispatch-text strong { font-size: 17px; }
.dispatch-text #dispatch-item { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.dispatch-text .small { margin-top: 6px; }

.dispatch.play .bot { animation: bot-run 2.6s ease-in both; }
.dispatch.play .bot-body { animation: bot-hop 2.6s ease-in-out both; }
.dispatch.play .arm-r { animation: arm-salute 2.6s ease-in-out both; }
.dispatch.play .arm-l { animation: arm-swing 2.6s ease-in-out both; }
.dispatch.play .leg-l { animation: leg-a 2.6s linear both; }
.dispatch.play .leg-r { animation: leg-b 2.6s linear both; }
.dispatch.play .eyes { animation: blink 2.6s linear both; }
.dispatch.play .bubble { animation: bubble 2.6s ease-out both; }
.dispatch.play .puff.p1 { animation: puff 2.6s ease-out both; }
.dispatch.play .puff.p2 { animation: puff 2.6s .08s ease-out both; }
.dispatch.play .puff.p3 { animation: puff 2.6s .16s ease-out both; }
.dispatch.play .speed { animation: speed 2.6s ease-out both; }
.dispatch.play .speed.s2 { animation-delay: .06s; } .dispatch.play .speed.s3 { animation-delay: .12s; }
.dispatch.play .dispatch-text { animation: text-in 2.6s ease-out both; }

@keyframes d-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes d-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes d-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bot-run {
  0%, 50% { transform: translateX(0) rotate(0); }
  56% { transform: translateX(-10px) rotate(-4deg); }
  62% { transform: translateX(4px) rotate(9deg); }
  100% { transform: translateX(270px) rotate(10deg); }
}
@keyframes bot-hop {
  0% { transform: translateY(0); } 6% { transform: translateY(-6px); } 11%, 50% { transform: translateY(0); }
  58% { transform: translateY(-3px); } 64% { transform: translateY(0); } 70% { transform: translateY(-3px); }
  76% { transform: translateY(0); } 82% { transform: translateY(-3px); } 88% { transform: translateY(0); }
  94% { transform: translateY(-3px); } 100% { transform: translateY(0); }
}
@keyframes arm-salute {
  0% { transform: rotate(0); } 12% { transform: rotate(155deg); } 16% { transform: rotate(148deg); } 20%, 44% { transform: rotate(155deg); }
  52% { transform: rotate(0); } 60% { transform: rotate(40deg); } 68% { transform: rotate(-40deg); } 76% { transform: rotate(40deg); }
  84% { transform: rotate(-40deg); } 92% { transform: rotate(40deg); } 100% { transform: rotate(-40deg); }
}
@keyframes arm-swing {
  0%, 52% { transform: rotate(0); } 60% { transform: rotate(-40deg); } 68% { transform: rotate(40deg); } 76% { transform: rotate(-40deg); }
  84% { transform: rotate(40deg); } 92% { transform: rotate(-40deg); } 100% { transform: rotate(40deg); }
}
@keyframes leg-a {
  0%, 54% { transform: rotate(0); } 60% { transform: rotate(32deg); } 68% { transform: rotate(-32deg); } 76% { transform: rotate(32deg); }
  84% { transform: rotate(-32deg); } 92% { transform: rotate(32deg); } 100% { transform: rotate(-32deg); }
}
@keyframes leg-b {
  0%, 54% { transform: rotate(0); } 60% { transform: rotate(-32deg); } 68% { transform: rotate(32deg); } 76% { transform: rotate(-32deg); }
  84% { transform: rotate(32deg); } 92% { transform: rotate(-32deg); } 100% { transform: rotate(32deg); }
}
@keyframes blink { 0%, 28%, 33%, 100% { transform: scaleY(1); } 30% { transform: scaleY(.1); } }
@keyframes bubble {
  0%, 10% { opacity: 0; transform: translateY(6px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.08); }
  18%, 44% { opacity: 1; transform: scale(1); } 50%, 100% { opacity: 0; transform: translateY(-6px) scale(.9); }
}
@keyframes puff {
  0%, 56% { opacity: 0; transform: translate(0, 0) scale(.3); } 62% { opacity: .9; transform: translate(-6px, -4px) scale(1); }
  85%, 100% { opacity: 0; transform: translate(-26px, -14px) scale(1.7); }
}
@keyframes speed {
  0%, 60% { opacity: 0; transform: translateX(40px); } 70% { opacity: 1; } 90%, 100% { opacity: 0; transform: translateX(-120px); }
}
@keyframes text-in { 0%, 55% { opacity: 0; transform: translateY(8px); } 70%, 100% { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .dispatch.play .bot, .dispatch.play .bot-body, .dispatch.play .arm, .dispatch.play .leg, .dispatch.play .eyes,
  .dispatch.play .bubble, .dispatch.play .puff, .dispatch.play .speed { animation: none; }
  .dispatch.play .arm-r { transform: rotate(155deg); }
  .dispatch.play .bubble { opacity: 1; }
  .dispatch.play .dispatch-text { animation: none; opacity: 1; }
}

/* steps */
.steps-block { margin: 2px 0 16px; }
.steps-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 8px; }
.steps-head #steps-progress { white-space: nowrap; }
.steps-head h3.sub { margin-bottom: 6px; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-bottom: 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 4px; transition: width .25s; }
.steps { list-style: none; margin: 0 0 8px; padding: 0; overflow: hidden; }
.steps:empty { display: none; }
.step { display: flex; align-items: flex-start; gap: 10px; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: 0; }
.step .num {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; background: var(--surface-2);
  font-size: 12px; font-weight: 700; display: grid; place-items: center; color: var(--muted); font-variant-numeric: tabular-nums;
}
.step .check { width: 22px; height: 22px; }
.step .st-body { flex: 1; min-width: 0; }
.step .st-title { overflow-wrap: anywhere; cursor: text; border-radius: 6px; }
.step .st-title:hover { background: var(--surface-2); }
.step .st-edit { width: 100%; font-size: 15px; padding: 4px 8px; }
.step.done .st-title { color: var(--muted); text-decoration: line-through; }
.step .meta { margin-top: 5px; align-items: center; }
.step select.who {
  width: auto; border: 0; border-radius: 6px; padding: 1px 22px 1px 7px; font-size: 12px; background-color: var(--surface-2);
  color: var(--muted); appearance: auto;
}
.step select.who.agent { background-color: var(--surface-2); color: var(--text); }
.chip-btn {
  border: 1px dashed var(--border); background: none; border-radius: 6px; padding: 0 7px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.chip-btn.on { border-style: solid; border-color: transparent; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.step .done-at { font-size: 12px; color: var(--muted); }
.step .del {
  flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px;
  opacity: .5; border-radius: 6px;
}
.step .del:hover { opacity: 1; color: var(--danger); background: var(--surface-2); }
.step-add { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.step-add select { width: auto; font-size: 14px; }
@media (max-width: 480px) {
  .step-add { grid-template-columns: 1fr auto; }
  .step-add input { grid-column: 1 / -1; }
  .step-add select { width: 100%; }
}
.add-steps-link { padding-left: 0; }
.chip.steps-chip { font-variant-numeric: tabular-nums; }
.chip.steps-chip.all { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.dispatch-step { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }

/* step reordering */
.step .grip {
  flex: none; border: 0; background: none; color: var(--muted); cursor: grab; padding: 2px 0; margin: 0 -6px 0 -8px;
  width: 18px; height: 26px; display: grid; place-items: center; opacity: .45; border-radius: 5px; touch-action: none;
}
.step .grip svg { width: 16px; height: 16px; }
.step:hover .grip, .step .grip:focus-visible { opacity: 1; }
.step .grip:active { cursor: grabbing; }
.step.dragging { position: relative; z-index: 2; opacity: .85; background: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,.25); border-radius: 10px; }
.step.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.step.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.step .move { display: none; flex: none; flex-direction: column; gap: 4px; }
.step .move button {
  width: 30px; height: 26px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 7px; font-size: 10px; cursor: pointer; padding: 0;
}
.step .move button:disabled { opacity: .3; cursor: default; }
@media (pointer: coarse) {
  .step .grip { display: none; }
  .step .move { display: flex; }
  /* iOS zooms the page into any field under 16px when it gets focus, and the page stays zoomed (the header then
     slides under the status bar, where iPadOS blurs it). The title keeps its larger size. */
  :is(input:not([type=checkbox]), select, textarea):not(.title-input) { font-size: 16px !important; }
}

/* ---------- readable formatted text ---------- */
.md { line-height: 1.55; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4, .md h5 { margin: 16px 0 6px; line-height: 1.3; }
.md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4, .md h5 { font-size: 15px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 4px 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 2px 0 4px; }
.md code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 6px 0 12px; }
.md pre code { background: none; padding: 0; white-space: pre; }
.md blockquote { margin: 6px 0 10px; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md a { color: var(--accent); }
.md .table-wrap { overflow-x: auto; margin: 6px 0 12px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.clampable.clamped {
  max-height: var(--clamp, 320px); overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 56px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 56px), transparent);
}
.btn.ghost.more { padding: 4px 0; font-size: 14px; }
.btn.small { padding: 3px 8px; font-size: 13px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.block-head h3.sub { margin: 0; }
.desc-block { margin-bottom: 16px; }
.desc-block textarea { font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- item links and hover previews ---------- */
a.ref { color: var(--accent); font-weight: 600; text-decoration: none; border-bottom: 1px dotted color-mix(in srgb, var(--accent) 50%, transparent); cursor: pointer; }
a.ref:hover { border-bottom-style: solid; }
a.ref.ref-chip { background: var(--accent-soft); border: 0; border-radius: 6px; padding: 0 6px; font-weight: 500; }
.hovercard {
  position: fixed; z-index: 80; width: min(340px, calc(100vw - 16px)); padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 12px 32px rgba(0,0,0,.28); cursor: pointer;
  font-size: 14px; line-height: 1.45; text-align: left;
}
.hovercard .hc-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.hovercard .hc-id { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.hovercard .pill { margin-top: 0; }
.hovercard .hc-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.hovercard .hc-latest { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--muted); }
.hovercard .hc-latest b { color: var(--text); font-weight: 600; }
.hovercard .hc-hint { margin-top: 8px; font-size: 12px; color: var(--muted); }
.link-copy { border: 0; background: none; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; border-radius: 6px; padding: 2px 6px; }
.link-copy:hover { background: var(--surface-2); }
.link-copy::after { content: " ⧉"; color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------- latest update, notes and history ---------- */
.latest {
  display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.4;
}
.latest > .face { grid-row: span 2; line-height: 0; }
.latest .txt { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.latest .by { font-size: 12px; color: var(--muted); }
.act-tabs { margin: 4px 0 10px; }
.act-tabs .n { color: var(--muted); font-weight: 500; margin-left: 2px; }
.notes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
/* Notes: the robot's face says which agent; the surface says you or the crew (your notes plain, the crew's on a
   neutral grey head). No agent colour on the card itself. */
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.note-card header { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 14px; background: var(--surface-2); }
.note-card.mine header { background: var(--surface); padding-bottom: 0; }
.note-card header b { color: var(--text); }
.note-card > .md { padding: 8px 12px 10px; max-width: 64ch; }
.note-card .when { margin-left: auto; color: var(--muted); font-size: 12px; }
.note-card .md { font-size: 14px; }
.empty-notes { padding: 8px 2px; }
.history { list-style: none; margin: 0 0 8px; padding: 0; overflow: hidden; }
.history li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding: 7px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.history li:last-child { border-bottom: 0; }
.history .what { color: var(--muted); overflow-wrap: anywhere; }
.history .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.who { font-weight: 600; color: var(--text); }
.timeline .note-clip {
  max-width: 72ch;
  font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer;
}
.timeline .note-clip.open { display: block; -webkit-line-clamp: unset; }
.timeline .note-clip p, .timeline .note-clip ul, .timeline .note-clip ol { margin: 0; }

/* ---------- briefing ---------- */

/* ---------- phase 2: structured briefing, step results, mentions ---------- */
.row .title .rid { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.row .why { margin-top: 2px; font-size: 14px; color: var(--text); opacity: .8; }
.st-result { margin-top: 4px; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.st-result .md { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.st-result .md.open { display: block; -webkit-line-clamp: unset; }
.st-result .md p, .st-result .md ul, .st-result .md ol { margin: 0; }
.st-result .st-by { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.step.done .st-result { opacity: .85; }
.mentions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 14px; font-size: 13px; }
.mentions .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.mentions a.ref-chip.closed { opacity: .65; text-decoration: line-through; }

/* ---------- robot crew (robots.js) ---------- */
.rb { display: inline-block; vertical-align: middle; flex: none; overflow: visible; }
.rb .rb-eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: rb-blink 5.5s infinite; }
.rb-sleep .rb-eyes { animation: none; }
.rb .rb-gear { animation: rb-spin 3s linear infinite; }
.rb .rb-wave { transform-origin: 63px 53px; animation: rb-wave 1.1s ease-in-out infinite; }
.rb .rb-z text { animation: rb-z 2.4s ease-in-out infinite; }
.rb .rb-z text:nth-child(2) { animation-delay: .6s; }
.rb .rb-pulse { animation: rb-pulse 1.2s ease-in-out infinite; }
.rb .rb-spark { animation: rb-twinkle 1.4s ease-in-out infinite; }
.rb-celebrate, .rb-done { animation: rb-hop 2.4s ease-in-out infinite; }
@keyframes rb-blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes rb-spin { to { transform: rotate(360deg); } }
@keyframes rb-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-22deg); } }
@keyframes rb-z { 0% { opacity: 0; transform: translateY(4px); } 30%, 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes rb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes rb-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes rb-hop { 0%, 80%, 100% { transform: translateY(0); } 88% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  .rb *, .rb { animation: none !important; }
}
:root[data-anim="off"] .rb, :root[data-anim="off"] .rb * { animation: none !important; }
:root[data-anim="subtle"] .rb .rb-eyes, :root[data-anim="subtle"] .rb-celebrate, :root[data-anim="subtle"] .rb-done,
:root[data-anim="subtle"] .rb .rb-z text, :root[data-anim="subtle"] .rb .rb-spark { animation: none; }

/* ---------- crew in the app ---------- */
.face { display: inline-flex; align-items: center; vertical-align: middle; line-height: 0; }
#toast { display: flex; align-items: center; gap: 8px; }
#toast.show:has(.toast-act) { pointer-events: auto; }
#toast .toast-act { margin-left: 4px; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline;
  text-underline-offset: 3px; padding: 6px 4px; cursor: pointer; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
:root[data-anim="off"] .dispatch.play .bot, :root[data-anim="off"] .dispatch.play .bot-body, :root[data-anim="off"] .dispatch.play .arm,
:root[data-anim="off"] .dispatch.play .leg, :root[data-anim="off"] .dispatch.play .eyes, :root[data-anim="off"] .dispatch.play .bubble,
:root[data-anim="off"] .dispatch.play .puff, :root[data-anim="off"] .dispatch.play .speed { animation: none; }
:root[data-anim="off"] .dispatch.play .arm-r { transform: rotate(155deg); }
:root[data-anim="off"] .dispatch.play .bubble { opacity: 1; }
:root[data-anim="off"] .dispatch.play .dispatch-text { animation: none; opacity: 1; }
.chip.crew-chip { display: inline-flex; align-items: center; gap: 4px; padding-left: 3px; background: var(--surface-2); color: var(--text); }
.ev-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.history .who { display: inline-flex; align-items: center; gap: 5px; }
.note-card header .face { margin-left: -2px; }
.step .meta .face { margin-right: -2px; }

/* crew strip: a grid, so every card stays on screen (4 across, 2x2 on phones); long status text wraps and is clamped */
.who-filter { display: flex; align-items: center; gap: 6px; margin: -6px 0 14px; font-size: 14px; color: var(--muted); }
.who-filter .x { border: 0; background: none; color: inherit; font-size: 16px; line-height: 1; padding: 0 2px; cursor: pointer; }

/* briefing header */
@keyframes brief-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* empty states */
.robot-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; }
.robot-empty .re-text { color: var(--text); font-weight: 600; }
.robot-empty .btn { margin-top: 8px; }
.day .free { display: flex; align-items: center; gap: 8px; }
.empty-notes { display: flex; align-items: center; gap: 10px; padding: 4px 2px 8px; }

/* celebrations */
.check.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.spark { position: fixed; z-index: 90; width: 7px; height: 7px; border-radius: 50%; pointer-events: none; transform: translate(-50%, -50%);
  animation: spark .75s ease-out forwards; }
@keyframes spark { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3); opacity: 0; } }
.allclear { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 20, .35);
  animation: d-fade .25s ease-out both; }
.allclear .ac-card { background: var(--surface); border-radius: 20px; padding: 18px 22px 20px; text-align: center; display: flex; flex-direction: column;
  gap: 4px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: d-pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.allclear .ac-crew { display: flex; justify-content: center; gap: 2px; margin-bottom: 6px; }
.allclear strong { font-size: 18px; }
:root[data-anim="off"] .check.pop, :root[data-anim="off"] .brief-bot.enter, :root[data-anim="off"] .allclear,
:root[data-anim="off"] .allclear .ac-card { animation: none; }
@media (prefers-reduced-motion: reduce) { .check.pop, .brief-bot.enter, .allclear, .allclear .ac-card { animation: none; } }

/* ---------- Today: one deduplicated list and a "since yesterday" line ---------- */
.since {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 22px; text-decoration: none; color: var(--text); font-size: 14px;
}
.since .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.since .go { margin-left: auto; color: var(--accent); font-weight: 500; white-space: nowrap; }
.since:hover { border-color: var(--accent); }
.pill.todo.new { background: var(--accent-soft); color: var(--accent); }
/* Today: the live headline, Nova's picks, one block per working agent, and the link to everything else open */
.hello .live-head { margin-top: 6px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.picks-head { display: flex; align-items: center; gap: 8px; margin: -2px 4px 10px; }
.picks-head .brief-bot { flex: none; line-height: 0; }
.picks-head .brief-bot.enter { animation: brief-in .6s cubic-bezier(.2, 1.3, .4, 1) both; }
.picks-head .by { font-size: 12px; color: var(--muted); }
.picks-head .note { font-size: 14px; margin-top: 1px; }
.pick-star { color: var(--warn); }
.picks-done { margin: 8px 4px 0; font-size: 13px; color: var(--muted); }
.agent-block { margin-bottom: 10px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: var(--surface); }
.agent-block .row { border-bottom-color: color-mix(in srgb, var(--text) 10%, transparent); }
.agent-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 12px 4px 8px; border: 0;
  background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.agent-head .crew-bot { flex: none; line-height: 0; }
.agent-head b { flex: none; font-size: 14px; }
.agent-head .muted { min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-head.active .crew-bot { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--agent) 60%, transparent)); }
.agents-idle { display: flex; flex-wrap: wrap; gap: 6px; }
.agents-idle .agent-head .muted { display: none; }
.agents-none { margin: 0 0 8px; }
.st-runs-more { border: 0; background: none; padding: 6px 2px; color: var(--muted); font-size: 13px; cursor: pointer; text-align: left; }
.st-runs-more:hover { color: var(--text); }
.files-more, .notes-more { margin-top: 4px; }
.agents-idle .agent-head { width: auto; max-width: 100%; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); }
.coming-due .group { margin-bottom: 12px; }
.coming-due .group > h2 { font-size: 12px; margin-left: 4px; }
.more-open { display: flex; align-items: center; gap: 10px; padding: 10px 4px; color: var(--muted); font-size: 14px; text-decoration: none; }
.more-open .go { margin-left: auto; color: var(--accent); font-weight: 500; }
.more-open:hover { color: var(--text); }

/* ---------- item: saves as you go, the next-decision band, folded steps, edit mode, details ---------- */
.save-state { font-size: 13px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.save-state[data-mode="ok"] { color: color-mix(in srgb, var(--ok) 75%, var(--text)); }
.save-state[data-mode="err"] { color: var(--danger); font-weight: 600; }
#item-heading { margin-right: 0; }

.turn {
  --tone: var(--agent, var(--accent));
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 14px; align-items: start;
  margin: 0 0 16px; padding: 14px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--tone) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 28%, var(--border));
}
/* "What is going on?": the hero button next to the title and Claude's answer under it */
.title-row { display: flex; align-items: flex-start; gap: 10px; }
.title-row .title-input { flex: 1; min-width: 0; }
.hero-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; margin-top: -2px;
  border: 1px solid color-mix(in srgb, #d97757 35%, var(--border)); border-radius: 12px;
  background: color-mix(in srgb, #d97757 10%, var(--surface)); cursor: pointer; line-height: 0;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.hero-btn:hover { background: color-mix(in srgb, #d97757 18%, var(--surface)); }
.hero-btn:focus-visible { outline: 2px solid #d97757; outline-offset: 2px; }
.hero-btn:disabled { cursor: default; }
.hero-btn.busy svg { animation: hero-fly 1.1s ease-in-out infinite; }
.hero-btn.busy .hero-cape { animation: hero-cape .55s ease-in-out infinite alternate; transform-origin: 6px 2px; }
@keyframes hero-fly { 0%, 100% { transform: translate(0, 1px) rotate(-4deg); } 50% { transform: translate(1px, -3px) rotate(3deg); } }
@keyframes hero-cape { from { transform: skewX(0deg); } to { transform: skewX(-12deg) scaleX(1.06); } }
.face.hero { line-height: 0; }
.check-card {
  --tone: #d97757;
  margin: 0 0 16px; padding: 12px 14px 14px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--tone) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--border));
}
.check-card.failed { --tone: var(--muted); }
.check-head { display: flex; align-items: center; gap: 10px; }
.check-head .muted { margin-right: auto; }
.check-lbl { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--tone) 75%, var(--text)); }
.check-card.busy .check-lbl .dots { display: inline-block; animation: check-dots 1.2s steps(4) infinite; overflow: hidden; vertical-align: bottom; width: 1.2em; }
@keyframes check-dots { from { width: 0; } to { width: 1.2em; } }
.check-x {
  flex: none; width: 36px; height: 36px; margin: -6px -6px -6px 0; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer;
}
.check-x:hover { background: color-mix(in srgb, var(--tone) 14%, transparent); color: var(--text); }
.check-body { margin-top: 6px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.check-body.md > :first-child { margin-top: 0; font-weight: 600; }
.check-body.md ul { margin: 4px 0; padding-left: 20px; }
.check-body.folded {
  max-height: 170px; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 48px), transparent); mask-image: linear-gradient(#000 calc(100% - 48px), transparent);
}
.check-card .btn.ghost.more { margin-top: 2px; color: color-mix(in srgb, var(--tone) 75%, var(--text)); }
html[data-anim="off"] .hero-btn.busy svg, html[data-anim="off"] .hero-btn.busy .hero-cape, html[data-anim="off"] .check-card .dots { animation: none; }
@media (prefers-reduced-motion: reduce) { .hero-btn.busy svg, .hero-btn.busy .hero-cape, .check-card .dots { animation: none; } }
.turn.you { --tone: var(--danger); } .turn.approve { --tone: var(--warn); } .turn.quiet { --tone: var(--muted); }
.turn.stuck { --tone: var(--muted); }
.turn-face { grid-row: span 4; line-height: 0; padding-top: 2px; }
.turn-lbl { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: color-mix(in srgb, var(--tone) 70%, var(--text)); }
.turn-what {
  font-size: 18px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.turn-sub, .turn-stop { font-size: 14px; line-height: 1.4; max-width: 60ch; }
.turn-sub { color: var(--muted); }
.turn-stop::before { content: "→ "; color: var(--muted); }
.turn-acts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.turn-acts .btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }

.steps-head { align-items: center; justify-content: flex-start; }
.steps-head #steps-progress { margin-right: auto; }
.steps.editing .step { background: var(--surface); }
.step-fold button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 12px; border: 0; border-bottom: 1px solid var(--border);
  background: var(--bg); color: var(--muted); font-size: 14px; text-align: left; cursor: pointer;
}
.step-fold b { color: color-mix(in srgb, var(--ok) 75%, var(--text)); font-weight: 600; }
.step-fold .check { pointer-events: none; }
.step-fold .chev { margin-left: auto; width: 18px; height: 18px; line-height: 0; transition: transform .2s; }
.step-fold .chev svg { width: 18px; height: 18px; }
.step-fold button[aria-expanded="true"] .chev { transform: rotate(90deg); }
.step.next { background: color-mix(in srgb, var(--tone, var(--accent)) 7%, var(--surface)); }
.step.next.you { --tone: var(--danger); } .step.next.approve { --tone: var(--warn); } .step.next.agent { --tone: var(--agent); }
.st-tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: color-mix(in srgb, var(--tone, var(--accent)) 75%, var(--text)); }
.st-who { font-size: 12px; font-weight: 600; color: var(--text); }
.st-who.agent { color: var(--text); }
.step .flag { font-size: 12px; font-weight: 600; color: color-mix(in srgb, var(--warn) 70%, var(--text)); }
.step .flag.ro { color: var(--muted); font-weight: 500; }

.details-block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 18px; }
.details-block > summary {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; cursor: pointer; list-style: none;
}
.details-block > summary::-webkit-details-marker { display: none; }
.details-block > summary #details-sum { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-block > summary .chev { width: 18px; height: 18px; flex: none; margin-left: auto; color: var(--muted); transition: transform .2s; }
.details-block[open] > summary .chev { transform: rotate(90deg); }
.details-block > .grid, .details-block > label { padding: 0 14px; }
.mynotes-block > textarea { display: block; width: calc(100% - 28px); margin: 0 14px; min-height: 96px; resize: vertical; field-sizing: content; }
.mynotes-block > p { margin: 0; padding: 6px 14px 0; }
.mynotes-block > p[data-mode="err"] { color: var(--danger, #c0392b); }
.mynotes-view { padding: 0 14px; overflow-wrap: anywhere; }
.mynotes-view:empty { display: none; }
.mynotes-actions { display: flex; gap: 8px; padding: 8px 14px 12px; }
.details-block > label:last-child { padding-bottom: 4px; }

/* ---------- iPad and wider: the list uses the full width; while an item is open it narrows to a column on the left
   and the item docks on the right ---------- */
@media (min-width: 768px) and (min-height: 600px) {
  :root { --rail: 0px; --list: 340px; }
  .top, main { margin-left: var(--rail); }
  main, body.wide main { max-width: none; margin-right: 0; padding: 20px 28px; }
  .tabs { left: var(--rail); }

  body.item-open .top, body.item-open main { width: var(--list); }
  body.item-open main { padding: 16px; }
  body.item-open .tabs { right: auto; width: var(--list); }
  body.item-open .tabs button { flex: 1 1 0; }
  body.item-open .brand span { display: none; } /* the greeting on Today carries the date */
  /* the list column keeps the phone's compact Today */
  .row.sel { background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
  .group.needs-you .row.sel, .group.happening .row.sel { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }

  dialog#item-dialog {
    position: fixed; inset: 0 0 0 calc(var(--rail) + var(--list)); z-index: 4; margin: 0; width: auto; height: 100dvh;
    max-width: none; max-height: none; border-radius: 0; box-shadow: none; border-left: 1px solid var(--border);
    background: var(--surface); overflow-y: auto; overscroll-behavior: contain;
  }
  #item-dialog .sheet-head { background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  #item-dialog .sheet-body { max-width: 820px; margin: 0 auto; padding: 18px 24px 48px; }
  #item-dialog .grid { grid-template-columns: 1fr 1fr; }
}
/* landscape iPad and the Mac: a side rail replaces the bottom tabs */
@media (min-width: 1000px) and (min-height: 600px) {
  :root { --rail: 84px; --list: 380px; }
  body { padding-bottom: 16px; }
  .tabs {
    top: 0; bottom: 0; left: 0; width: var(--rail); flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: calc(14px + env(safe-area-inset-top)) 8px 14px; border-top: 0; border-right: 1px solid var(--border); background: var(--bg);
  }
  .tabs button { flex: none; min-height: 60px; justify-content: center; font-size: 12px; border-radius: 12px; }
  body.item-open .tabs { width: var(--rail); } /* the rail stays a rail while the list narrows beside an open item */
  body.item-open .tabs button { flex: none; }
  .tabs button.on { background: color-mix(in srgb, var(--accent) 10%, transparent); }
  .tabs .n { left: auto; right: 10px; top: 6px; }
  /* Today on a wide screen with no item open: what needs deciding on the left, the overview on the right */
  body:not(.item-open) .today-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 0 28px; align-items: start; }
  body:not(.item-open) .today-main, body:not(.item-open) .today-side { display: flex; flex-direction: column; min-width: 0; }
}
/* lists of single rows read badly across a whole wide screen: Items and Activity keep a readable width */
@media (min-width: 768px) and (min-height: 600px) {
  body:not(.item-open) #view-items, body:not(.item-open) #view-activity { max-width: 960px; margin: 0 auto; }
}
/* Today's two columns step aside on narrow screens: one column, in the usual order (set inline by renderToday) */
.today-cols { display: flex; flex-direction: column; }
.today-main, .today-side { display: contents; }
@media (min-width: 1280px) and (min-height: 600px) { :root { --list: 420px; } }

/* ---------- touch screens: 44pt targets (iPad, iPhone) ---------- */
@media (pointer: coarse) {
  .check, .run-mini, .chip-btn, .link-copy, .step .del { position: relative; }
  .check::after, .run-mini::after { content: ""; position: absolute; inset: -11px; }
  .run-mini { width: 32px; height: 32px; }
  .run-mini::after { inset: -6px; }
  .chip-btn { min-height: 28px; padding: 0 10px; }
  .chip-btn::after { content: ""; position: absolute; inset: -8px -2px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .link-copy { min-height: 44px; padding: 0 10px; }
  .seg button { min-height: 36px; padding: 6px 12px; }
  .chipbar button { min-height: 36px; padding: 0 14px; }
  .step select.who { min-height: 36px; font-size: 14px; }
  .step .del { width: 44px; height: 44px; margin: -8px -6px -8px 0; opacity: .8; display: grid; place-items: center; }
  .step .move button { width: 44px; height: 40px; font-size: 12px; }
  .approve-row input { width: 22px; height: 22px; }
}
.tabs .n { background: #c62f22; } /* 5.4:1 white on red; the lighter dark-mode red was 2.8:1 */

/* ---------- files: cards in the item and the reader ---------- */
.files-block { margin: 0 0 18px; }
.files-block > h3.sub { margin-bottom: 8px; }
.files-list { display: flex; flex-direction: column; gap: 8px; }
.fv-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; width: 100%; min-height: 56px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  text-align: left; cursor: pointer; font: inherit;
}
.fv-card:active { background: var(--surface-2); }
.fv-card-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.fv-card-ic svg { width: 20px; height: 20px; }
.fv-card-t { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.fv-card-t b { font-weight: 600; overflow-wrap: anywhere; }
.fv-card-t span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-chev { width: 18px; height: 18px; color: var(--muted); line-height: 0; }
.fv-chev svg { width: 18px; height: 18px; }
.fv-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin-top: 6px; padding: 4px 10px 4px 7px; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  color: var(--text); font-size: 13px; cursor: pointer; overflow-wrap: anywhere; text-align: left;
}
.fv-chip svg { width: 15px; height: 15px; color: var(--accent); flex: none; }

/* the reader covers the item: the right pane on the iPad, the whole screen on a phone */
.fv {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--surface); color: var(--text);
}
@media (min-width: 768px) and (min-height: 600px) { .fv { left: calc(var(--rail) + var(--list)); border-left: 1px solid var(--border); } }
.fv-head {
  display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
.fv-icon { width: 44px; height: 44px; flex: none; border: 0; background: none; color: var(--accent); border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.fv-icon svg { width: 22px; height: 22px; }
.fv-icon:active { background: var(--surface-2); }
.fv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fv-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-title span { font-size: 12px; color: var(--muted); }
.fv-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.fv-loading { padding: 48px 20px; text-align: center; color: var(--muted); }
.fv-media { padding: 16px; display: grid; place-items: center; }
.fv-media img { max-width: 100%; height: auto; border-radius: 8px; }
.fv-prose { padding: 16px 20px 40px; max-width: 72ch; }

.fv-tools {
  position: sticky; top: 0; z-index: 2; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.fv-search { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--muted); }
.fv-search svg { width: 18px; height: 18px; flex: none; }
.fv-search input { border: 0; background: none; padding: 0; min-height: 42px; box-shadow: none !important; font-size: 16px; }
.fv-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
.fv-chips::-webkit-scrollbar { display: none; }
.fv-chips button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
}
.fv-chips button i { font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fv-chips button.on { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.fv-chips button.on i { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.fv-about { margin: 10px 14px 0; border: 1px solid var(--border); border-radius: 10px; }
.fv-about > summary { cursor: pointer; padding: 10px 12px; color: var(--muted); font-size: 14px; }
.fv-about > .md { padding: 0 12px 10px; font-size: 14px; }
.fv-count { padding: 10px 16px 4px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.fv-list { list-style: none; margin: 0; padding: 0 0 24px; }
.fv-sec { padding: 14px 16px 6px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.fv-row { border-bottom: 1px solid var(--border); }
.fv-main {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px; min-height: 52px; width: 100%;
  padding: 8px 14px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.fv-label { font-size: 15px; font-weight: 550; overflow-wrap: anywhere; }
.fv-sub { grid-row: 2; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.fv-main .fv-chev { grid-row: 1 / span 2; grid-column: 2; transition: transform .2s; }
.fv-row.open .fv-main .fv-chev { transform: rotate(90deg); }
.fv-dl { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; padding: 0 16px 12px 16px; font-size: 13px; }
.fv-dl dt { color: var(--muted); }
.fv-dl dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.fv-del { color: var(--danger); }

/* ---------- questions from the crew (asks): the card at the top of the item, and the row picker ---------- */
.ask {
  --tone: var(--agent, var(--accent));
  display: flex; flex-direction: column; gap: 12px; margin: 0 0 16px; padding: 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--tone) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 30%, var(--border));
}
.ask-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; }
.ask-face { line-height: 0; }
.ask-lbl { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: color-mix(in srgb, var(--tone) 65%, var(--text)); }
.ask-q { font-size: 18px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; text-wrap: pretty; }
.ask-detail { font-size: 14px; color: var(--text); max-width: 64ch; }
.ask-form { display: flex; flex-direction: column; gap: 8px; }
.ask-hint { font-size: 13px; color: var(--muted); }
.ask-opt {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; min-height: 52px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.ask-opt.on { border-color: color-mix(in srgb, var(--tone) 70%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--tone) 70%, transparent) inset; }
.ask-opt-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ask-opt-t b { font-weight: 600; overflow-wrap: anywhere; }
.ask-opt-t span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ask-mark {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 55%, var(--border));
  display: grid; place-items: center; color: #fff; flex: none;
}
.ask-mark.box { border-radius: 7px; }
.ask-mark svg { width: 16px; height: 16px; }
.ask-opt.on .ask-mark, .fv-row.pick.on .ask-mark { background: var(--tone, var(--accent)); border-color: var(--tone, var(--accent)); }
.ask-other { flex-direction: column; gap: 6px; margin: 4px 0 0; font-size: 13px; }
.ask-other input { min-height: 44px; }
.ask-form textarea { min-height: 110px; }
.ask-pick {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
.ask-pick > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ask-pick span { font-size: 13px; color: var(--muted); }
.ask-foot { display: flex; flex-direction: column; gap: 10px; }
.ask-comment > summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 32px; display: flex; align-items: center; }
.ask-comment textarea { width: 100%; margin-top: 6px; }
.ask-tick { flex-direction: row; align-items: center; gap: 10px; margin: 0; color: var(--text); font-size: 14px; }
.ask-tick input { width: 22px; height: 22px; flex: none; margin: 0; }
.ask-err { font-size: 14px; color: var(--danger); font-weight: 600; }
.ask-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-acts .btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.ask-acts .btn:disabled { opacity: .45; }
.ask-done { display: flex; flex-direction: column; gap: 2px; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.ask-done-q { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ask-done b { overflow-wrap: anywhere; }
.ask-done-tick { display: inline-block; width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; color: color-mix(in srgb, var(--ok) 75%, var(--text)); }
.ask-done-tick svg { width: 15px; height: 15px; }
.ask-done.gone { opacity: .7; }

.ask-picker { --tone: var(--ok); }
.ask-picker.destructive { --tone: var(--danger); }
.pick-btn {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; width: 100%; min-height: 52px;
  padding: 8px 14px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.pick-btn .ask-mark { grid-row: 1 / span 2; }
.pick-btn .fv-sub { grid-column: 2; }
.pick-verb { grid-column: 3; grid-row: 1 / span 2; font-size: 12px; font-weight: 700; color: color-mix(in srgb, var(--tone) 75%, var(--text)); }
.fv-row.pick.on { background: color-mix(in srgb, var(--tone) 8%, var(--surface)); }
.pick-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pick-bulk .seg { margin-right: auto; }
.pick-foot {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px; margin-top: auto; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.pick-tally { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-tally b { font-variant-numeric: tabular-nums; }
.pick-tally span { font-size: 12px; color: var(--muted); }
.pick-foot .btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.ask-opt.none { border-style: dashed; }
.ask-opt.none.on { border-style: solid; }
.step.next.ask { --tone: var(--danger); }
.ask-acts .ask-dismiss { margin-left: auto; color: var(--muted); }

/* ---------- Calendar view: two weeks, Monday to Sunday; a list of days when the view is narrow ---------- */
#view-calendar { container-type: inline-size; }
.cal { display: flex; flex-direction: column; min-height: calc(100dvh - 190px); }
.cal-head { display: flex; align-items: flex-start; gap: 12px; margin: 4px 4px 14px; }
.cal-head > div:first-child { flex: 1; min-width: 0; }
.cal-head h2 { margin: 0; font-size: 24px; letter-spacing: -.015em; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav .icon-btn svg { display: block; }
.cal-over { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); }
.cal-over .lbl { flex: none; padding-top: 5px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--danger); }
.cal-over .cal-items { flex-direction: row; flex-wrap: wrap; }
.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(128px, 1fr);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.cal-day { padding: 6px 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:nth-child(n+8) { border-bottom: 0; }
.cal-day.weekend { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.cal-day.past { background: var(--bg); }
.cal-day.past > header { opacity: .55; }
.cal-day > header { display: flex; align-items: baseline; gap: 5px; padding: 0 2px 6px; font-size: 12px; color: var(--muted); }
.cal-day > header b { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.cal-day > header .tag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--accent); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.today > header b { color: var(--accent); }
.cal-items { display: flex; flex-direction: column; gap: 4px; }
.cal-it {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; width: 100%; min-height: 32px; padding: 5px 7px;
  border: 0; border-radius: 7px; text-align: left; cursor: pointer; overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--agent, var(--accent)) 13%, var(--surface)); color: var(--text); font: inherit; font-size: 12px; line-height: 1.3;
}
.cal-it .rid { color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-it.prio-urgent, .cal-it.prio-high { font-weight: 600; }
.cal-it.waiting { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.cal-it.late { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.cal-over .cal-it { width: auto; max-width: 260px; }
/* mid width (an item open beside it, or the iPad in portrait): narrow day columns, so more lines and no item numbers */
@container (max-width: 760px) {
  .cal-day { padding: 5px 4px 6px; }
  .cal-day > header .tag { display: none; }
  .cal-it { padding: 4px 5px; -webkit-line-clamp: 4; }
  .cal-grid .cal-it .rid { display: none; }
}
/* narrow (a phone, or the list column beside an open item): the two weeks as a list of days */
@container (max-width: 560px) {
  .cal { min-height: 0; }
  .cal-grid { display: block; border: 0; border-radius: 0; background: none; }
  .cal-day { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 8px; padding: 8px 4px; border-right: 0; border-bottom: 1px solid var(--border) !important; background: none !important; }
  .cal-day > header { flex-direction: column; align-items: flex-start; gap: 0; padding: 2px 0 0; }
  .cal-day.today { box-shadow: none; }
  .cal-day.today > header .tag { display: block; margin-left: 0; }
  .cal-day.past:not(:has(.cal-it)) { display: none; } /* a past day stays when it still has overdue items */
  .cal-day:not(.today):not(:has(.cal-it)) .cal-items::before { content: "–"; color: var(--muted); }
  .cal-it { font-size: 13px; -webkit-line-clamp: 2; }
  .cal-grid .cal-it .rid { display: inline; }
}
@media (pointer: coarse) { .st-run, .st-runs-more { min-height: 40px; } }
