/* familytodo - phone-first, two users, no framework.
   Hand-written because a build step buys nothing at this size. */

:root {
  color-scheme: light dark;

  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --border: #e2e2e6;
  --text: #16161a;
  --text-dim: #6b6b76;
  --text-faint: #9a9aa6;
  --accent: #3b6ef5;
  --accent-soft: #e8eeff;
  --private: #8b5cf6;
  --private-soft: #f1ebfe;
  --danger: #d64545;
  --overdue: #c2410c;

  --radius: 14px;
  --radius-sm: 9px;
  --tap: 44px;
  --shadow: 0 1px 2px rgba(16, 16, 24, 0.06), 0 4px 14px rgba(16, 16, 24, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --surface: #18181d;
    --surface-2: #202027;
    --border: #2c2c34;
    --text: #f2f2f5;
    --text-dim: #a0a0ad;
    --text-faint: #6e6e7c;
    --accent: #7d9dff;
    --accent-soft: #1c2540;
    --private: #a78bfa;
    --private-soft: #251d3d;
    --danger: #f87171;
    --overdue: #fb923c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Room for the fixed composer at the bottom. */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* The Done view has no composer, so it does not need the room. */
body.no-composer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

a { color: var(--accent); text-decoration: none; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* --- header ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.topbar h1 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

.topbar h1 .count {
  color: var(--text-faint);
  font-weight: 500;
  margin-left: 6px;
}

/* The count is of open todos. Beside the word "Done" it would read as a
   count of done ones, so hide it there - the element stays in the DOM
   because the out-of-band swap after a toggle needs something to replace. */
.topbar h1.is-done-view .count { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 2px; }
.topbar-actions .iconbtn { padding: 0 8px; }
.topbar h1, .whoami, .iconbtn { white-space: nowrap; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

.whoami {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px 0 5px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}

.avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* --- filter chips ------------------------------------------------------ */

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 12px 16px;
  margin: 0 -16px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip[aria-current="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chip .n { color: var(--text-faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip[aria-current="true"] .n { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.chip.is-private { border-style: dashed; }

/* Divides the Open/Done pair from the tags - they filter different things
   and running them together reads as one long list of tags. */
.chip-sep {
  flex: 0 0 auto;
  align-self: center;
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 3px;
}

/* --- list -------------------------------------------------------------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
/* A row folding away once it no longer belongs on this list - see list.js. */
.row.is-leaving {
  overflow: hidden;
  opacity: 0;
  height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-width: 0;
  transition: opacity 200ms ease, height 280ms ease 120ms, padding 280ms ease 120ms;
}
.row.is-done .row-title { color: var(--text-faint); text-decoration: line-through; }

/* The checkbox is a form so it works with JS off, and a big tap target. */
.check {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.check:hover { border-color: var(--accent); }
.check[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.check svg { width: 14px; height: 14px; }

.row-main { flex: 1 1 auto; min-width: 0; }

.row-title {
  display: block;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  word-wrap: break-word;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 550;
  /* Fixed height, so never more than one line. */
  white-space: nowrap;
}
/* What a todo is filed under. Titles can be long; one line, cut short. */
.pill.topic { max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.is-tag { max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.pill.private { background: var(--private-soft); color: var(--private); }
.pill.due { background: var(--surface-2); }
.pill.due.is-overdue { background: color-mix(in srgb, var(--overdue) 14%, transparent); color: var(--overdue); }
/* A reminder is quiet until its moment arrives, then it is the loudest
   thing on the row - nothing else is going to tell you. */
/* Outlined with a bell, so it never reads as the due date beside it. */
.pill.remind {
  background: transparent;
  color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--border);
  gap: 4px;
}
.pill-icon { width: 12px; height: 12px; flex: none; }
/* Read out, not shown: the bell says it to the eye. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pill.remind.is-now {
  box-shadow: none;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-weight: 650;
}
.pill.sensitive { background: var(--surface-2); color: var(--text-dim); }

.row-chevron {
  flex: 0 0 auto;
  align-self: center;
  color: var(--text-faint);
  padding: 6px;
  margin: -6px -4px -6px 0;
}

/* --- composer ---------------------------------------------------------- */

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}

.composer form { display: flex; align-items: center; gap: 8px; }

.composer input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  /* 16px keeps iOS from zooming the viewport on focus. */
  font-size: 16px;
}
.composer input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toggle-private {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-faint);
  cursor: pointer;
}
.toggle-private:has(input:checked) {
  background: var(--private-soft);
  border-color: var(--private);
  color: var(--private);
}
.toggle-private input { position: absolute; inset: 0; opacity: 0; margin: 0; }
/* Without this the icon swallows taps meant for the label. */
/* 24 rather than 18: the mask's viewBox is cropped to its artwork, so this
   is the width of the mask itself rather than of a square box it sits in. */
.toggle-private svg { width: 24px; height: 24px; pointer-events: none; }

.send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.send:disabled { opacity: 0.4; }
/* While a turn runs the send button stops it instead. */
.send .icon-stop { display: none; }
.send.is-stop .icon-send { display: none; }
.send.is-stop .icon-stop { display: block; }
.send.is-stop { background: var(--text); color: var(--bg); }
.bubble.stopped { color: var(--text-faint); font-style: italic; }
/* Takes back everything the latest turn changed. */
.undo-turn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: -2px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.undo-turn:hover { color: var(--text); }
.undo-turn svg { width: 14px; height: 14px; }

/* A slash command and the app's answer to it - not the assistant's. */
.bubble.user.command { background: var(--surface-2); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.command-output {
  align-self: stretch;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.command-output { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.command-summary { flex: 1 1 auto; min-width: 0; color: var(--text-dim); font-size: 13.5px; }
.command-output details, .command-output > pre { flex: 1 0 100%; }
.command-output summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
.command-output details pre { margin-top: 8px; max-height: 50vh; overflow: auto; }
.command-output pre {
  margin: 0 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}
/* Waiting to be sent, under the conversation. */
.queue { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.queue:empty { display: none; }
.bubble.user.queued {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--text-dim);
  border: 1px dashed var(--border);
}
.queued-label { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.bubble.user.queued .cancel {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
}
.send svg { width: 18px; height: 18px; }

/* --- generic ----------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 24px 0 8px;
}

/* An htmx insert puts a row above the empty state; this retires it without
   a second request. */
.list:has(.row) .empty { display: none; }

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-faint);
}
.empty strong { display: block; color: var(--text-dim); font-size: 17px; margin-bottom: 4px; }

label.field { display: block; margin-bottom: 14px; }
/* Rules like the one above set display, which would beat the hidden
   attribute and leave a hidden element showing. */
[hidden] { display: none !important; }
/* Hints sit under their input, not wrapped around it. */
label.field > small { display: block; margin-top: 6px; font-size: 12px; }
div.field { margin-bottom: 14px; }
/* A grid rather than flex: minmax(0, 1fr) makes the input's column give
   way to the button, whatever width the input thinks it needs. */
/* The first item takes what is left; anything after it (a time, a Clear)
   gets its own width. Hidden items make no column, so a hidden Clear
   leaves no gap. */
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: auto;
  gap: 8px;
  align-items: center;
}
/* A date and a time side by side: the date gets the larger share. */
.field-row-pair { grid-auto-flow: row; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); }
.field-row-pair input { width: 100%; }

/* A label with a small action at the far end of its line. */
.field-head { display: flex; align-items: baseline; justify-content: space-between; }
.field-head .field-label { margin-bottom: 5px; }
.linkbtn {
  border: 0;
  background: none;
  padding: 0 2px;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* iOS Safari draws date and time inputs as native controls with a minimum
   width of their own, which ignores width and min-width - so they ran past
   the edge of the card. Dropping the native appearance makes them size
   like any other input. Without it an empty one also collapses, hence the
   min-height, and its value centres, hence the text-align. */
input[type="date"], input[type="datetime-local"], input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
}
.field-label,
label.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}

input[type="text"], input[type="date"], input[type="datetime-local"], input[type="time"], textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 88px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-size: 15px;
}
.checkbox-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.checkbox-row .hint { display: block; font-size: 13px; color: var(--text-faint); font-weight: 400; }

.tagpick { display: flex; flex-wrap: wrap; gap: 7px; }
.tagpick label {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.tagpick label:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.tagpick input { position: absolute; inset: 0; opacity: 0; margin: 0; }

.notes { list-style: none; margin: 0; padding: 0; }
.note {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.note:last-child { border-bottom: 0; }
.note-meta { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }
.note-body { white-space: pre-wrap; word-wrap: break-word; }

.toast {
  margin: 12px 0 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 550;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: var(--tap);
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 550;
}

/* Splits the account page into its two concerns: who you are, and what
   gets to interrupt you. */
.section-heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 20px 0 8px;
}

.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.rowlist li:last-child { border-bottom: 0; }
.rowlist .grow { flex: 1 1 auto; min-width: 0; }
.rowlist form { display: contents; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.muted { color: var(--text-faint); font-size: 13.5px; }

/* htmx sets this while a request is in flight. */
.htmx-request.check { opacity: 0.45; }

/* --- chat -------------------------------------------------------------- */

.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 8px;
}

.bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
  position: relative;
}

/* Sits in the gutter to the left of your latest message; bubbles stop at
   86% of the width, which leaves room for it. */
.redo {
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.redo:hover { color: var(--accent); }
.redo svg { width: 15px; height: 15px; }
.thread.is-busy .redo { display: none; }
/* Earlier messages can be gone back to as well; quieter than the latest. */
.redo.older { opacity: 0.5; }
.redo.older:hover, .redo.older:focus-visible { opacity: 1; }

.bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 5px;
}

/* Rendered Markdown in a reply - see markdown.js. Paragraphs and lists set
   their own spacing, so the bubble stops preserving raw newlines. */
.bubble.md { white-space: normal; }
.bubble.md p { margin: 0; }
.bubble.md p + p, .bubble.md p + ul, .bubble.md p + ol,
.bubble.md ul + p, .bubble.md ol + p { margin-top: 8px; }
.bubble.md ul, .bubble.md ol { margin: 0; padding-left: 1.25em; }
.bubble.md li + li { margin-top: 4px; }
.bubble.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}
.bubble.md a { color: var(--accent); word-break: break-word; }
.bubble.md .md-domain { color: var(--text-faint); font-size: 0.85em; }

/* Which model wrote a reply: there when you look for it, easy to ignore. */
.model-note {
  align-self: flex-start;
  margin-top: -6px;
  padding: 0 6px;
  color: var(--text-faint);
  font-size: 11px;
  opacity: 0.8;
}

/* What the assistant did, between the bubbles: quiet, but always there -
   above all what it searched the web for. */
.activity {
  align-self: flex-start;
  max-width: 86%;
  padding: 0 4px 0 calc(4px + 1.25em);
  text-indent: -1.25em;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.35;
}
.activity::before { content: "\21B3\00a0"; }

.bubble.failed {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  color: var(--danger);
}

.working {
  color: var(--text-faint);
  font-size: 14.5px;
}
.working::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { to { content: "…"; } }

@media (prefers-reduced-motion: reduce) {
  .working::after { animation: none; }
}



/* --- sign in ----------------------------------------------------------- */

.centred {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding-bottom: 0;
}

.signin {
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.signin h1 {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.signin .muted { margin: 0 0 26px; }
.signin-note { margin: 14px 0 0 !important; font-size: 13px; }

.btn-wide { width: 100%; }

.signin-error {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 14px;
  font-weight: 550;
  text-align: left;
}

code {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- blocked ----------------------------------------------------------- */

.pill.blocked {
  background: color-mix(in srgb, var(--overdue) 14%, transparent);
  color: var(--overdue);
  /* A reason is free text, so its length is anyone's guess, and the row is
     narrower whenever it carries a drag handle. Pills are one line tall: cut
     it at the width there is rather than letting it wrap out of its pill.
     inline-block because text-overflow does nothing on a flex container. */
  display: inline-block;
  line-height: 20px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stuck items stay legible but visibly recede - they are not what you can
   act on right now. */
.row.is-blocked .row-title { color: var(--text-dim); }
/* Waiting for a date rather than stuck on something: quieter than blocked,
   since there is nothing to do about it. */
.pill.unblocks { background: var(--accent-soft); color: var(--accent); }
.pill.later {
  display: inline-block;
  line-height: 20px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-2);
  color: var(--text-dim);
}
.row.is-blocked .check { opacity: 0.55; }

.later-banner {
  margin: 0 0 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 14.5px;
  font-weight: 550;
}

.blocked-banner {
  margin: 0 0 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--overdue) 12%, transparent);
  color: var(--overdue);
  font-size: 14.5px;
  font-weight: 550;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.inline-form input[type="text"], .inline-form input[type="datetime-local"], .inline-form select { flex: 1 1 auto; min-width: 0; }

.struck { text-decoration: line-through; color: var(--text-faint); }

/* --- priority reordering ----------------------------------------------- */

.drag-handle {
  flex: 0 0 auto;
  align-self: center;
  display: grid;
  place-items: center;
  width: 28px;
  height: 36px;
  /* Into the row's left padding, so the handle costs the title as little
     width as it can. */
  margin: -6px -6px -6px -10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: grab;
  /* The handle is the one place a vertical drag means "move this" instead
     of "scroll the page". */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.drag-handle:hover { color: var(--text-dim); }

/* The list clips its rounded corners with overflow: hidden, which would
   also clip a row lifted past its edge. */
.list.is-reordering { overflow: visible; }
.list.is-reordering, .list.is-reordering * { cursor: grabbing; -webkit-user-select: none; user-select: none; }

.row.is-dragging {
  position: relative;
  z-index: 5;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  border-radius: var(--radius);
}
.row.is-dragging .drag-handle { color: var(--accent); }


/* --- memory page -------------------------------------------------------- */

.memlist { list-style: none; margin: 0 0 6px; padding: 0; }
.memlist li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.memlist li:first-child { padding-top: 0; }
.memlist textarea, .memory-add textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.memory-add { padding-top: 12px; }
.memory-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
}
.memory-actions .grow { flex: 1 1 auto; }
.memory-add .memory-actions { justify-content: space-between; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13.5px; }

/* --- usage page --------------------------------------------------------- */

.usage-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.usage-totals div { display: flex; flex-direction: column; gap: 2px; }
.usage-totals strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.usage-chart { display: flex; align-items: flex-end; gap: 2px; height: 110px; }
.usage-bar { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; }
.usage-bar span { display: block; width: 100%; min-height: 1px; background: var(--accent); border-radius: 2px 2px 0 0; }
.usage-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.usage-table th { text-align: left; padding: 12px 0 4px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.usage-table tr:first-child th { padding-top: 0; }
.usage-table td { padding: 4px 0; border-top: 1px solid var(--border); }
.usage-table td:nth-child(2) { color: var(--text-faint); padding: 4px 8px; }
.usage-table td:last-child { text-align: right; }

/* --- search ------------------------------------------------------------- */

.search-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
  padding: calc(10px + env(safe-area-inset-top)) 12px 12px;
}
body.is-searching { overflow: hidden; }
.search-box {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(16, 16, 24, 0.18);
  overflow: hidden;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}
.search-field input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.search-field input[type="search"]:focus { outline: none; box-shadow: none; }
.search-results { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; overscroll-behavior: contain; }
.search-results:empty { display: none; }
.search-results a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 14px;
  color: var(--text);
}
.search-results a.is-active, .search-results a:hover { background: var(--surface-2); }
.search-title mark { background: none; color: var(--accent); font-weight: 650; }
.search-meta { font-size: 12.5px; color: var(--text-faint); }
.search-note { padding: 10px 14px; color: var(--text-faint); font-size: 14px; }
/* Cancel is right there; the browser's own clear button only duplicates it. */
.search-field input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

/* --- offline (offline.js) ------------------------------------------------ */

.offline-bar {
  position: fixed;
  left: 50%;
  top: calc(60px + env(safe-area-inset-top));
  z-index: 55;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow);
}
.offline-bar.is-problem { background: var(--danger); color: #fff; }
.offline-bar button {
  border: 0;
  border-radius: 999px;
  padding: 2px 10px;
  background: color-mix(in srgb, currentColor 22%, transparent);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.is-pending { opacity: 0.8; }
.pending-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--text-faint);
  font-size: 11.5px;
  white-space: nowrap;
}

/* --- images in the chat ------------------------------------------------ */

.attach {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.attach input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.attach svg { width: 20px; height: 20px; pointer-events: none; }
.attach.is-full { opacity: 0.4; pointer-events: none; }

/* Waiting to go with the next message. */
/* Padded at the top and right: overflow-x clips the x buttons otherwise,
   since they sit half outside their image. */
.attach-tray { display: flex; gap: 10px; padding: 8px 8px 10px 0; overflow-x: auto; }
.attach-tray[hidden] { display: none; }
.attach-item { position: relative; flex: none; }
.attach-item img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.attach-item .cancel {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
}

/* In a sent message, above its words. */
.bubble .shots { display: flex; flex-wrap: wrap; gap: 6px; }
.bubble .shots:not(:only-child) { margin-bottom: 8px; }
/* Images with no words: a thin frame rather than a full bubble's padding. */
.bubble.user.only-images { padding: 4px; }
.bubble .shots img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 12px;
  background: color-mix(in srgb, #fff 15%, transparent);
}
.bubble .shots:has(img + img) img { width: 120px; height: 120px; object-fit: cover; }
