/* Jeeves: one paper, one ink, one accent.

   Every screen is built from the same few parts and the same colours; no screen has a
   colour of its own. The accent means "this is yours to press or look at" (the main
   button, a link, the tab you are on, something waiting for you). Red means something is
   wrong or late, green that something was accepted. Titles are set in the system serif,
   everything else in the system sans.

   The shell is one flex column (header, scrolling page, tab bar) pinned to the viewport's
   edges. The page does not ask iOS for full-screen (see base.html), so the viewport is the
   area iOS really gives it and its bottom edge is the screen's. */

:root {
  --bg: #f5efe6; --card: #fffcf7; --card2: #ece4d8; --text: #26201a; --muted: #766a5e;
  --line: #e5dbce; --accent: #c2531c; --ink-on-accent: #fff; --danger: #b8382a; --ok: #2f7d4f;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--card));
  --accent-line: color-mix(in srgb, var(--accent) 42%, var(--line));
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 18px; --r-control: 12px; --control: 44px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --tabs-h: 58px;
  /* Room under the tab bar and the composer. In the installed app the page reaches the
     bottom edge and iOS may report no inset there, so keep clear of the home indicator. */
  --pad-b: var(--safe-b);
  color-scheme: light;
}
@media (display-mode: standalone) { :root { --pad-b: max(var(--safe-b), 14px); } }
:root.standalone { --pad-b: max(var(--safe-b), 14px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1815; --card: #25211e; --card2: #332d28; --text: #f0e8dd; --muted: #a69a8d;
    --line: #3a322c; --accent: #f08b54; --ink-on-accent: #1d130c; --danger: #f26d70; --ok: #74c292;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1815; --card: #25211e; --card2: #332d28; --text: #f0e8dd; --muted: #a69a8d;
  --line: #3a322c; --accent: #f08b54; --ink-on-accent: #1d130c; --danger: #f26d70; --ok: #74c292;
  color-scheme: dark;
}

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); overflow: hidden; height: 100%; }
p, li, small, h1, h2, h3, .bubble, .meta, td, summary { overflow-wrap: anywhere; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
  /* Pinned to the screen's edges instead of given a height: no viewport unit or reported
     height is involved, so none of iOS's differing answers can push the bars around. The
     script only lifts the bottom edge by the keyboard's height while it is open. */
  position: fixed; inset: 0 0 var(--kb, 0px) 0; overflow: hidden; display: flex; flex-direction: column;
}

/* --- type ------------------------------------------------------------------------ */
a { color: var(--accent); text-decoration: none; }
h1, h2 { font-family: var(--display); letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; margin: 0; }
h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.25; margin: 0 0 .3rem; }
h3 { font-size: 1.02rem; font-weight: 650; line-height: 1.3; margin: 0 0 .45rem; }
p { margin: .3rem 0 .6rem; }
pre { white-space: pre-wrap; word-break: break-word; font-size: .82rem; background: var(--bg); padding: .7rem .8rem; border-radius: var(--r-control); margin: .5rem 0; }
code { background: var(--card2); padding: .1rem .4rem; border-radius: 6px; font: .86em var(--mono); overflow-wrap: anywhere; }
s { color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .9rem; } .warn-text { color: var(--danger); }
.center { text-align: center; } .hidden { display: none !important; } .grow { flex: 1; }
/* A small label over a group: between cards, or over a second list inside one. */
.sources-label { color: var(--muted); font-size: .74rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; margin: 1rem 0 .3rem; }
.page > .sources-label { margin: 1.2rem .2rem .5rem; }
.page > h2 { margin: 1.5rem .2rem .6rem; }
/* The line or two under a page's title that says what the page is. */
.dateline, .page > .goal, .page > p.muted { color: var(--muted); font-size: .92rem; line-height: 1.45; margin: 0 .2rem .9rem; }

/* --- shell: header, page, tabs ---------------------------------------------------- */
.top {
  flex: none; display: flex; align-items: center; gap: .4rem;
  padding: calc(var(--safe-t) + .4rem) calc(var(--safe-r) + 1rem) .5rem calc(var(--safe-l) + 1rem);
  background: var(--bg);
}
.top .title { line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .title small { font: 500 .82rem var(--sans); letter-spacing: 0; color: var(--muted); margin-left: .35rem; }
.top .icon, .top .back {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; color: var(--muted); flex: none;
}
.top .icon:active, .top .back:active { background: var(--card2); }
.top .back { color: var(--accent); margin-left: -12px; margin-right: -4px; }
.top .button { min-height: 36px; padding: 0 .85rem; font-size: .9rem; white-space: nowrap; }
.page {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: .2rem calc(var(--safe-r) + 1rem) 1.4rem calc(var(--safe-l) + 1rem);
  transition: opacity .16s ease-out;
}
/* A page swapped in by a tap fades in; a partial that refreshes itself does not. */
.page.htmx-added { opacity: 0; }
.page > :first-child { margin-top: 0; }
.tabs {
  flex: none; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 0 var(--safe-r) var(--pad-b) var(--safe-l); height: calc(var(--tabs-h) + var(--pad-b));
}
.tabs a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: .66rem; font-weight: 500; letter-spacing: .01em; }
.tabs a svg { position: relative; opacity: .85; }
.tabs a span { position: relative; }
.tabs a.on { color: var(--accent); font-weight: 650; } .tabs a.on svg { opacity: 1; }
.tabs a.on::before { content: ""; position: absolute; top: 5px; left: 50%; width: 56px; height: 30px; margin-left: -28px; border-radius: 999px; background: var(--accent-soft); }
.tabs a b { position: absolute; top: -27px; left: calc(50% + 7px); min-width: 17px; text-align: center; background: var(--accent); color: var(--ink-on-accent); border-radius: 999px; padding: 0 .3rem; font-size: .62rem; font-weight: 700; line-height: 17px; box-shadow: 0 0 0 2px var(--card); }
body[data-screen="chat"] .tabs, body.kb .tabs { display: none; }
@media (min-width: 720px) { .page { padding-left: calc(50% - 340px); padding-right: calc(50% - 340px); } .top { padding-left: calc(50% - 340px); padding-right: calc(50% - 340px); } }

/* --- cards and what goes in them --------------------------------------------------- */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.05rem; margin: 0 0 .75rem; }
.card > :first-child { margin-top: 0; } .card > :last-child { margin-bottom: 0; }
/* Something here waits for you. */
.card.accent { border-color: var(--accent-line); background: var(--accent-soft); }
.card.accent button:not(.primary):not(.quiet):not(.link):not(.icon):not(.tick), .card.accent .button:not(.primary) { background: color-mix(in srgb, var(--accent) 14%, var(--card2)); }
.card.narrow { max-width: 360px; margin: 3rem auto; }
.card.banner { display: flex; align-items: center; gap: .65rem; padding: .75rem 1.05rem; }
.card.banner form { margin-left: auto; }
/* Nothing here yet. */
.quiet-card { background: color-mix(in srgb, var(--card) 45%, var(--bg)); border-style: dashed; color: var(--muted); }
.quiet-card p { margin: 0; font-size: .95rem; }
.card.link { color: inherit; } .card.link:active { background: var(--card2); }
.card.link h2, .card.link h3 { margin: 0; flex: 1; }
.card.link .row.between { flex-wrap: nowrap; align-items: baseline; gap: .8rem; }
.card.link p { margin: .35rem 0 0; }
.card.link .chip { margin-top: .35rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: .6rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: .15rem; } .list li:last-child { padding-bottom: .15rem; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; font-size: .8rem; color: var(--muted); margin: 0 0 .5rem; }
.meta .date, .rowlink .date, .row .date, .mails .head .date { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }
.page > .meta { margin: 0 .2rem .8rem; }
.chip, .pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .16rem .6rem; border-radius: 999px; background: var(--card2); color: var(--muted); letter-spacing: .01em; line-height: 1.35; white-space: nowrap; vertical-align: middle; }
.chip.lang { font-family: var(--mono); letter-spacing: .05em; }
.chip.accent { background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent); }
.chip svg { width: 13px; height: 13px; }
.pill.warn { background: var(--danger); color: #fff; }
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; font-weight: 600; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.review, .status.queued, .status.running { color: var(--accent); }
.status.accepted { color: var(--ok); } .status.failed, .status.rejected { color: var(--danger); }
.caution, .tasks .sub .late { color: var(--danger); font-weight: 600; }
p.caution { margin: .3rem 0; }

/* A row that leads somewhere ends in the same small arrow everywhere. */
.rowlink { display: flex; align-items: center; gap: .6rem; color: inherit; }
.rowlink > span:first-child { display: flex; flex-direction: column; gap: .1rem; }
.rowlink::after, .menu a::after {
  content: ""; flex: none; width: .5em; height: .5em; margin-left: auto; border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg); opacity: .75;
}
.rowlink:has(.date)::after { margin-left: 0; }
.menu { padding-top: .25rem; padding-bottom: .25rem; }
.menu a { display: flex; align-items: center; gap: .9rem; padding: .8rem 0; color: inherit; border-top: 1px solid var(--line); }
.menu a:first-child { border-top: 0; }
.menu a span { flex: 1; display: flex; flex-direction: column; gap: .12rem; }
.menu a b { font-weight: 600; }
.menu a small { color: var(--muted); font-size: .86rem; line-height: 1.35; }

/* Anything that opens in place has the same small arrow in front, turning when open. */
summary { cursor: pointer; list-style: none; -webkit-user-select: none; user-select: none; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; display: inline-block; width: .45em; height: .45em; margin: 0 .7em .14em .15em; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg); transition: transform .15s; opacity: .75;
}
details[open] > summary::before { transform: rotate(45deg); margin-bottom: .22em; }
details.card > summary { font-weight: 600; }
details.card[open] > summary { margin-bottom: .7rem; }
details:not(.card) > summary { color: var(--muted); font-size: .9rem; padding: .35rem 0; }
details:not(.card)[open] > summary { margin-bottom: .3rem; }

.flash { list-style: none; padding: 0; margin: 0 0 .75rem; }
.flash li { background: var(--card2); padding: .6rem .9rem; border-radius: var(--r-control); margin-bottom: .35rem; font-size: .95rem; }
.flash li.error { background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); }
#loading { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 20; opacity: 0; transition: width .4s ease, opacity .2s; }
body.loading #loading { width: 70%; opacity: 1; }
.earlier { margin: .2rem 0 .4rem; }
.highlight { animation: glow 1.6s ease-out; }
@keyframes glow { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: none; } }
.spinner { width: 14px; height: 14px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.spinner.inline { display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .page { transition: none; } }

/* --- buttons and fields ------------------------------------------------------------ */
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.row.between { justify-content: space-between; }
.row.between > span:first-child { flex: 1 1 12rem; }
.row.tight { margin-top: 0; }
.row > form { display: flex; margin: 0; }
.row h3 { margin: 0; }
/* The line a card opens with (a title, and something small on the right). */
.card > .row.between:first-child, .card > form > div.row.between:first-of-type { margin-bottom: .6rem; }
.card > .row.between:only-child, .card > form:only-child > .row.between:only-child, .list .row.between { margin-bottom: 0; }
.inline { display: inline; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 550; line-height: 1.2; border: 1px solid transparent; background: var(--card2); color: var(--text);
  padding: 0 1rem; border-radius: var(--r-control); cursor: pointer; min-height: var(--control); -webkit-appearance: none; appearance: none;
  transition: transform .08s, filter .08s;
}
button:active, .button:active { transform: scale(.97); filter: brightness(.96); }
button.primary, .button.primary { background: var(--accent); color: var(--ink-on-accent); font-weight: 650; }
button.quiet, .button.quiet { background: transparent; color: var(--muted); padding: 0 .6rem; }
button.link { display: inline; background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; font-weight: inherit; }
button.icon, a.icon { width: var(--control); padding: 0; color: var(--muted); background: transparent; }
button.icon.on { color: var(--accent); background: var(--accent-soft); }
button:disabled { opacity: .45; cursor: not-allowed; }
.wide { width: 100%; }
.links { margin: .6rem 0 0; text-align: center; } .links .link { font-size: inherit; }

input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])), textarea, select {
  display: block; font: inherit; width: 100%; min-height: var(--control); background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-control); padding: .6rem .8rem; margin: .3rem 0 .6rem;
  -webkit-appearance: none; appearance: none;
}
textarea { line-height: 1.45; resize: vertical; }
::placeholder { color: var(--muted); opacity: .75; }
/* The phone draws date and time fields as a centred grey pill, and an empty one collapses. */
input::-webkit-date-and-time-value { text-align: left; min-height: 1.45em; }
input::-webkit-calendar-picker-indicator { opacity: .55; }
select {
  padding-right: 2.2rem; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23877a6d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center;
}
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
.row input:where(:not([type="checkbox"], [type="radio"])), .row select, .row textarea { width: auto; flex: 1; margin: 0; }
label, .label { display: block; color: var(--muted); font-size: .84rem; font-weight: 600; letter-spacing: .01em; }
.field { margin-bottom: .8rem; }
.field input, .field textarea, .field select { margin: .3rem 0 0; }
.field .help { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.field .error { display: block; color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.stack label { margin: .6rem 0; }
.stack label input, .stack label textarea, .stack label select, .pair label input, .pair label select { margin: .3rem 0 0; font-weight: 400; }
/* Two fields that belong together: side by side when there is room, stacked on the phone. */
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; margin: .2rem 0 .3rem; }

/* A choice between a few things is one bar with the chosen part filled. */
.field > div[id] { display: flex; margin-top: .3rem; border-radius: var(--r-control); background: var(--card2); padding: 3px; gap: 3px; }
.field > div[id] > div { margin: 0; flex: 1; display: flex; }
.field > div[id] label { flex: 1; display: flex; align-items: center; justify-content: center; padding: .45rem .4rem; color: var(--muted); font-size: .9rem; font-weight: 550; border-radius: 9px; text-align: center; min-height: 38px; }
.field > div[id] label:has(input:checked) { background: var(--card); color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgba(40, 25, 10, .14); }
input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }

/* A tick box, and its other shape: a switch, for things that are on or off. */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 22px; height: 22px; margin: 0; padding: 0;
  border: 1.5px solid var(--muted); border-radius: 7px; background: transparent; vertical-align: middle; cursor: pointer; transition: background .15s, border-color .15s;
}
input[type="checkbox"]::after { content: ""; position: absolute; left: 6.5px; top: 2.5px; width: 6px; height: 11px; border: solid var(--ink-on-accent); border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .12s; }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { transform: rotate(45deg) scale(1); }
label.check { display: inline-flex; align-items: center; gap: .55rem; margin: 0; color: var(--text); font-weight: 500; font-size: .95rem; cursor: pointer; }
.switch input[type="checkbox"] { width: 46px; height: 28px; border: 0; border-radius: 999px; background: var(--card2); }
.switch input[type="checkbox"]::after { left: 3px; top: 3px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transform: none; transition: left .15s; }
.switch input[type="checkbox"]:checked { background: var(--accent); }
.switch input[type="checkbox"]:checked::after { left: 21px; transform: none; }
.switch { color: var(--muted); font-size: .86rem; }
.row.between > .switch { flex-direction: row-reverse; }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { color: var(--muted); font-size: .74rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.table th, .table td { text-align: left; padding: .4rem .5rem .4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.small { font-size: .78rem; }

/* --- today -------------------------------------------------------------------------- */
.brief-text { margin: .35rem 0 0; line-height: 1.55; }
.weather { display: flex; align-items: center; gap: 1rem; }
.weather .temp { font: 700 1.5rem/1.1 var(--display); letter-spacing: -.02em; white-space: nowrap; }
.weather .desc { margin: 0; } .weather .desc small { display: block; color: var(--muted); font-size: .9rem; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: .8rem; padding: .45rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.events li:first-child { border-top: 0; padding-top: .1rem; }
.events .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .9rem; min-width: 5.4em; }
.events .where { color: var(--muted); font-size: .9rem; }

/* --- proposals ---------------------------------------------------------------------- */
.proposal h2 a { color: var(--text); } .proposal h2 a::after { content: " ↗"; color: var(--accent); font: 500 .8em var(--sans); }
.proposal .why { margin: 0 0 .4rem; }
.proposal .action { margin: .5rem 0 .2rem; padding: .6rem .8rem; border-radius: var(--r-control); background: var(--accent-soft); }
.proposal .action b { color: var(--accent); }
.proposal .actions { display: flex; gap: .5rem; align-items: center; margin-top: .7rem; }
.proposal .actions .thumbs { margin-left: auto; display: flex; gap: .15rem; }
.proposal .actions button.icon.up.on { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.proposal .actions button.icon.down.on { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--card)); }
.archive li { display: flex; gap: .5rem; align-items: baseline; } .archive li a { flex: 1; color: var(--text); } .archive li .date { margin-left: 0; }

/* --- memory ------------------------------------------------------------------------- */
.facts { list-style: none; margin: 0; padding: 0; }
.facts li { border-top: 1px solid var(--line); padding: .15rem 0; }
.facts li:first-child { border-top: 0; }
.facts details > summary { padding: .55rem 0; display: flex; gap: .6rem; align-items: baseline; color: var(--text); font-size: 1rem; margin: 0; }
.facts details > summary::before { order: 2; margin: 0 .15em 0 auto; align-self: center; }
.facts details form { padding: 0 0 .7rem; }
.facts details textarea { margin-top: 0; }
.facts .proposed p { margin: .1rem 0 .4rem; }
.facts .proposed form { padding: .4rem 0 .6rem; }
.facts .proposed .row { margin-top: 0; }
.list.facts li { padding: .5rem 0; }
.fact-add .row { margin-top: 0; }

/* --- chat ---------------------------------------------------------------------------- */
body[data-screen="chat"] .page { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; padding-top: 0; }
.messages {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: .5rem;
  padding: .3rem .25rem .6rem 0; overscroll-behavior: contain; scrollbar-width: none; touch-action: pan-y;
}
.messages::-webkit-scrollbar { display: none; }
.messages .empty { margin: auto 1rem; }
.msg { max-width: 84%; display: flex; flex-direction: column; } .msg.user { align-self: flex-end; align-items: flex-end; } .msg.assistant, .msg.system { align-self: flex-start; align-items: flex-start; }
.msg small { margin-top: 3px; font-size: .7rem; padding: 0 .35rem; }
.bubble { display: inline-block; text-align: left; padding: .6rem .9rem; border-radius: 20px; background: var(--card); border: 1px solid var(--line); }
.msg.user .bubble { background: var(--accent); color: var(--ink-on-accent); border-color: var(--accent); border-bottom-right-radius: 7px; }
.msg.assistant .bubble { border-bottom-left-radius: 7px; }
.msg.system .bubble { border-style: dashed; color: var(--muted); background: transparent; }
.typing { color: var(--muted); font-size: .8rem; padding: .1rem .4rem; flex: none; }
.composer { flex: none; display: flex; gap: .45rem; align-items: flex-end; padding: .45rem 0 calc(.45rem + var(--pad-b)); background: var(--bg); }
body.kb .composer { padding-bottom: .45rem; }
.composer textarea { flex: 1; margin: 0; resize: none; max-height: 120px; border-radius: 22px; padding: .6rem 1rem; background: var(--card); }
.composer button { width: var(--control); height: var(--control); padding: 0; border-radius: 50%; flex: none; }
.mic.recording { background: var(--danger); color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.card-msg { max-width: 94%; }
.plan-card { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius); padding: .9rem 1rem; }
.plan-card .plan-q { margin: 0 0 .4rem; font-weight: 600; }
.plan-card .plan-details p { font-size: .9rem; }
.plan-card .row { margin-top: .6rem; }
.plan-card.declined, .plan-card.superseded { opacity: .7; }

/* --- projects and builds --------------------------------------------------------------- */
.build-row .brief { display: block; color: var(--muted); margin-top: .2rem; font-size: .88rem; }
.row.actions { margin-top: .5rem; } .row.actions button { min-height: 38px; }
/* "More" opens once and has no arrow: what it showed stays. */
details.more > summary::before { display: none; }
details.more > summary:not(.muted) { color: var(--accent); }
details.more[open] > summary { display: none; }
.preview { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: var(--r-control); background: #fff; margin-top: .6rem; }
.steps { padding-left: 1.2rem; margin: 0; font-size: .88rem; } .steps li { margin: .3rem 0; }
.steps li.command code, .steps li.file code { font-size: .8rem; }
.steps li.file { color: var(--muted); }
.lookups li { margin: .5rem 0; } .lookups li span { display: block; }
.sources a { display: block; color: inherit; overflow-wrap: anywhere; }

/* --- tasks ----------------------------------------------------------------------------- */
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks .task { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .7rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.tasks .task:first-child { border-top: 0; padding-top: .2rem; }
.tasks .task > form { margin: 0; display: flex; }
.tasks .tick { width: 26px; height: 26px; min-height: 26px; padding: 0; border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; flex: none; margin-top: -.05rem; }
.tasks .tick:active, .tasks .tick.on { background: var(--accent); border-color: var(--accent); }
.tasks .tick.on::after { content: ""; display: block; width: 6px; height: 11px; margin: -2px auto 0; border: solid var(--ink-on-accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tasks .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .12rem; }
.tasks .task.closed .title { color: var(--muted); text-decoration: line-through; }
.tasks .sub, .mails .sub { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; color: var(--muted); font-size: .82rem; }
.tasks .sub:empty, .mails .sub:empty { display: none; }
.tasks .sub a { color: var(--accent); font-weight: 600; }
.tasks details.more { flex: none; }
.tasks details.more > summary { color: var(--muted); padding: 0 .3rem; font-size: 1.3rem; line-height: 1.5rem; margin: 0; }
.tasks details.more[open] { flex-basis: 100%; order: 3; }
.tasks .edit > input { margin: 0 0 .5rem; }
.task-add { margin-top: .7rem; }
.card > .task-add:first-child { margin-top: 0; }
.task-add details.when { margin-top: .3rem; }
.task-add + p { margin-top: .6rem; }
.rules li form { flex-direction: column; align-items: stretch; gap: .4rem; }
.rules .what { font-weight: 550; }
.rules select { width: 100%; margin: 0; flex: none; }

/* --- mail ------------------------------------------------------------------------------- */
.mails { list-style: none; margin: 0; padding: 0; }
.mails .mail { display: flex; align-items: flex-start; gap: .4rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.mails .mail:first-child { border-top: 0; padding-top: .2rem; } .mails .mail:last-child { padding-bottom: .1rem; }
.mails .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; color: inherit; }
.mails .head { display: flex; align-items: baseline; gap: .5rem; }
.mails .head b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mails .rate { display: flex; margin: -.35rem -.5rem 0 0; flex: none; }
.mails .rate .icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; min-height: 36px; border-radius: var(--r-control); }
.mail-from { margin: 0 0 .5rem; }
.mailtext { max-height: 60vh; overflow: auto; font-family: inherit; font-size: .9rem; }

/* --- skills and written sources ------------------------------------------------------------ */
pre.diff { font-family: inherit; font-size: .9rem; }
pre.diff .add { color: var(--ok); } pre.diff .drop { color: var(--danger); text-decoration: line-through; }
pre.diff span { display: block; white-space: pre-wrap; }
pre.code { max-height: 70vh; overflow: auto; font: .72rem/1.45 var(--mono); white-space: pre; word-break: normal; }
