:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1b; --muted: #6b6a66; --line: #e3e1db;
  --accent: #2f5d8a; --accent-text: #ffffff; --me: #e8eef5; --bot: #f3f2ee; --error: #a33a2a;
  --shared: #2e7d4f; --personal: #8a5a2f; --project: #7a2f8a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --card: #201f1d; --text: #ecebe7; --muted: #9c9a94; --line: #34332f;
    --accent: #6f9fd0; --accent-text: #0e1620; --me: #22303d; --bot: #2a2926; --error: #e07a68;
    --shared: #6cc492; --personal: #d9a46f; --project: #c98ad6;
  }
}
* { box-sizing: border-box; }
body { margin: 0 auto; max-width: 1100px; padding: 16px; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, sans-serif; }
header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 10px; font-size: 16px; }
.who { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
main { display: grid; gap: 16px; grid-template-columns: 1fr; }
summary { cursor: pointer; font-weight: 600; }
.chat-area { display: grid; gap: 16px; grid-template-columns: 220px 1fr; align-items: start; }
@media (max-width: 700px) { .chat-area { grid-template-columns: 1fr; } }
.chats { display: flex; flex-direction: column; gap: 8px; }
#chats { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
#chats button { width: 100%; text-align: left; background: transparent; color: var(--text); border-color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chats button.active { background: var(--me); border-color: var(--line); }
details.notes[open] summary, #pairing[open] summary { margin-bottom: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 16px; min-width: 0; }
main .card { margin-bottom: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; margin: 6px 0; }
.row[hidden] { display: none; }
.column { display: flex; flex-direction: column; gap: 6px; }
input, textarea, select, button { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
input, textarea { flex: 1 1 160px; min-width: 0; }
.notes > input, .notes > textarea { width: 100%; margin: 4px 0; }
textarea { resize: vertical; }
button { background: var(--accent); color: var(--accent-text); border-color: var(--accent); cursor: pointer; }
button.quiet { background: transparent; color: var(--muted); border-color: var(--line); }
button:disabled { opacity: 0.5; cursor: default; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
code { font-size: 12px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
#status { padding: 8px 12px; border-radius: 6px; background: var(--card); border: 1px solid var(--error); color: var(--error); }
ol { list-style: none; margin: 0; padding: 0; }
#messages { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
#messages li { padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
#messages li.user { background: var(--me); align-self: flex-end; max-width: 85%; }
#messages li.assistant { background: var(--bot); max-width: 95%; }
.meta { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 10px; border: 1px solid currentColor; margin-left: 4px; }
.badge.shared { color: var(--shared); }
.badge.personal { color: var(--personal); }
.badge.project { color: var(--project); }
details.steps { margin-top: 6px; font-size: 12px; color: var(--muted); }
details.steps summary { font-weight: 400; }
details.steps ol { margin-top: 4px; display: flex; flex-direction: column; gap: 4px; }
#messages details.steps li { background: none; border-radius: 0; max-width: none; padding: 0 0 0 8px; border-left: 2px solid var(--line); }
details.steps pre { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.4 ui-monospace, monospace; max-height: 12em; overflow-y: auto; }
#results li { border-top: 1px solid var(--line); padding: 8px 0; overflow-wrap: anywhere; }
#results .title { font-weight: 600; }
#results .snippet { color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.today-head { justify-content: space-between; align-items: center; margin: 0 0 4px; }
.today-head h2 { margin: 0; }
h3 { margin: 8px 0 4px; font-size: 14px; }
.today-lists { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .today-lists { grid-template-columns: 1fr; } }
.today-lists li { padding: 3px 0; overflow-wrap: anywhere; }
.badge.busy { color: var(--muted); }
#task-items li, #brief-items li { padding: 4px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; overflow-wrap: anywhere; border-top: 1px solid var(--line); }
#task-items li button, #brief-items li button { padding: 2px 8px; font-size: 12px; }
details.notifications[open] summary { margin-bottom: 8px; }
#notify-upcoming li { padding: 6px 10px; margin: 6px 0; border-radius: 10px; background: var(--bot); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; overflow-wrap: anywhere; }
#notify-upcoming li .body { flex-basis: 100%; }
#notify-upcoming li.hint { background: none; padding: 0; }
#task-done { margin: 0 4px 0 0; }

/* Cards (C2): small views under a reply, quieter than the reply itself. */
#messages ol.cards { margin: 8px 0 2px; display: flex; flex-direction: column; gap: 6px; white-space: normal; }
#messages ol.cards[hidden] { display: none; }
#messages ol.cards > li { background: var(--card); border-radius: 10px; padding: 8px 12px; max-width: none; font-size: 14px; box-shadow: 0 0 0 1px var(--line); }
.card-title { font-weight: 500; }
.card-sub, .card-more, .card-time, .card-warn { color: var(--muted); font-size: 12px; }
.card-text { min-width: 0; }
.card-snippet { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.card-more { margin-top: 4px; }
.card-noteref { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; padding: 3px 0; }
.card-noteref + .card-noteref { border-top: 1px solid var(--line); }
.card-warn { margin-top: 4px; color: var(--personal); }
.card-head { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.card-task { display: flex; gap: 10px; align-items: flex-start; padding: 3px 0; }
.card-task + .card-task { border-top: 1px solid var(--line); }
.card-task .tick { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--muted); font-size: 11px; line-height: 13px; text-align: center; color: var(--accent-text); }
.card-task.done .tick { background: var(--accent); border-color: var(--accent); }
.card-task.done .card-title { text-decoration: line-through; color: var(--muted); }
.card-task.event .tick { border: 0; border-radius: 0; font-size: 15px; line-height: 16px; }
.card-event { display: flex; gap: 10px; align-items: baseline; padding: 2px 0; }
.card-event .card-time { flex: none; width: 3.4em; font-variant-numeric: tabular-nums; }
.card-event.busy .card-title { color: var(--muted); font-style: italic; font-weight: 400; }
.card-day { display: flex; gap: 12px; padding: 5px 0; border-top: 1px solid var(--line); }
.card-head + .card-day, .card-month + .card-day { border-top: 0; }
.card-month { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 0 2px; border-top: 1px solid var(--line); }
.card-daylabel { flex: none; width: 2.6em; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.card-daylabel .weekday { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.card-daylabel .date { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-day.today .card-daylabel .date { color: var(--accent); }
.card-day.empty .card-daylabel { opacity: .55; }
.card-dayevents { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
/* A project's instructions keep their line breaks (PI1). */
.projects .instructions { white-space: pre-wrap; }
.projects textarea { display: block; width: 100%; box-sizing: border-box; }
/* D300: a write is one receipt line; a list or search opens in full, live. */
.card-receipt { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.card-all { margin-top: 6px; font-size: 12px; padding: 2px 10px; }
