:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #efeae0;
  --ink: #172633;
  --ink-2: #4a5866;
  --muted: #7a8590;
  --line: #e0d9cc;
  --accent: #122f43;
  --accent-ink: #f6f3ec;
  --warm: #b8643a;
  --warm-soft: #f3e2d5;
  --mark: #f6dc9b;
  --bar: #c9c1b1;
  --bar-hit: #122f43;
  --shadow: 0 1px 2px rgb(18 47 67 / .06), 0 4px 16px rgb(18 47 67 / .05);
  --serif: "Newsreader", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --chat-w: clamp(440px, 42vw, 680px); /* the Ask panel: wider on big screens; phones use the full width */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --surface: #182029; --surface-2: #212b35; --ink: #e9e6de; --ink-2: #b9bec6;
    --muted: #8a929c; --line: #2b3540; --accent: #9dbbd6; --accent-ink: #0d1d2b; --warm: #e0a174;
    --warm-soft: #3a2b21; --mark: #6b5520; --bar: #38444f; --bar-hit: #9dbbd6;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  }
}
:root[data-theme="dark"] {
  --bg: #11161c; --surface: #182029; --surface-2: #212b35; --ink: #e9e6de; --ink-2: #b9bec6;
  --muted: #8a929c; --line: #2b3540; --accent: #9dbbd6; --accent-ink: #0d1d2b; --warm: #e0a174;
  --warm-soft: #3a2b21; --mark: #6b5520; --bar: #38444f; --bar-hit: #9dbbd6;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
}

* { box-sizing: border-box; }
html { scroll-padding-top: 150px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--warm); outline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: 14px max(16px, 4vw); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand h1 { margin: 0; font: 400 25px/1 var(--serif); letter-spacing: -.02em; }
.brand h1 b { font-weight: 700; }
.brand h1 a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
/* The logo is 45% taller than the capital M (cap height; .7em where cap is unsupported), overhanging it equally above and below. */
.brand h1 .logo { height: 1.015em; height: 1.45cap; width: auto; margin-right: .25em; vertical-align: -.16em; vertical-align: -.225cap; }
.brand .sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.search {
  flex: 1; max-width: 640px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  height: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.search svg { color: var(--muted); flex: none; }
@media (min-width: 721px) {
  /* Equal side columns keep the search box centered in the header (unless the brand needs more room). */
  .top { display: grid; grid-template-columns: 1fr minmax(0, 540px) 1fr; }
  .search { max-width: none; }
  .ask-btn { justify-self: end; }
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; height: 100%; font-size: 15px; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; } /* ours is #qClear */
.search-clear {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; margin-right: -6px; padding: 0;
  border: 0; border-radius: 50%; background: var(--bar); color: var(--ink-2); cursor: pointer;
}
.search-clear[hidden] { display: none; }
.search-clear:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bar)); }
.search-clear svg { width: 14px; height: 14px; color: inherit; stroke-width: 2.4; }
.search.has-text kbd { display: none; }
.search kbd { font: 12px var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.ask-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.ask-btn svg { width: 16px; height: 16px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 10px max(16px, 4vw) 18px; border-bottom: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 3px; }
.field span { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field select, .field input {
  height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 120px; max-width: 220px;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: 36px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; color: var(--ink-2); font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.linkish { border: 0; background: none; color: var(--accent); font-weight: 500; height: 36px; padding: 0 4px; }
.linkish:hover { text-decoration: underline; }

/* Timeline */
main { max-width: 900px; margin: 0 auto; padding: 8px max(16px, 4vw) 120px; }
body.chat-open main { margin-right: calc(var(--chat-w) + 24px); margin-left: max(16px, calc((100vw - var(--chat-w) - 900px) / 2)); }
.month-loading { margin: 8px 0 12px; font-size: 13px; color: var(--muted); }
.count { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.year { position: relative; }
.year-head {
  position: sticky; top: var(--header-h, 73px); z-index: 5; margin: 0; font: inherit;
  padding: 18px 0 10px; background: linear-gradient(var(--bg) 75%, transparent);
}
/* Year and month headings open and close their group */
.grp-toggle { display: flex; align-items: baseline; gap: 12px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.grp-toggle .chev { align-self: center; margin-left: auto; }
.grp-sub { font-size: 13px; color: var(--muted); }
.year-head .yr { font: 500 34px/1 var(--serif); letter-spacing: -.02em; }
.grp:not(.collapsed) > .year-head .chev { transform: rotate(180deg); }
.grp.collapsed > .rail, .grp.collapsed > .month-body { display: none; }
.year.collapsed > .year-head { padding-bottom: 4px; }
.mgroup { position: relative; margin: 0 0 6px; }
.month-head {
  position: sticky; top: calc(var(--header-h, 73px) + var(--year-h, 62px) - 8px); z-index: 4; margin: 0; padding: 6px 0 8px;
  font: inherit; background: var(--bg);
}
.month-head .mo { font: 500 22px/1.2 var(--serif); letter-spacing: -.01em; }
/* Months read as folders: closed = a raised bar with a right-pointing chevron; open = a heading over a rule, chevron down */
.month-head .grp-toggle { align-items: center; gap: 8px; padding: 7px 12px 7px 8px; border: 1px solid transparent; border-radius: var(--radius); }
.month-head .chev { order: -1; margin-left: 0; transform: rotate(-90deg); }
.mgroup:not(.collapsed) > .month-head .grp-toggle { border-radius: 0; border-bottom-color: var(--line); }
.mgroup:not(.collapsed) > .month-head .chev { transform: none; color: var(--accent); }
.mgroup.collapsed > .month-head .grp-toggle {
  background: color-mix(in srgb, var(--accent) 9%, var(--bg)); border-color: color-mix(in srgb, var(--accent) 25%, var(--line));
}
.mgroup.collapsed > .month-head .grp-toggle:hover { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.mgroup.collapsed > .month-head .chev { color: var(--accent); }
.month-head .chev { stroke-width: 2.6; }
.mgroup:not(.collapsed) > .month-body { padding-top: 6px; }
/* An open month is a tinted panel behind its days, so they read as one collection. Negative side margins (padding +
   border) keep the days lined up with the cards outside the month. A real border, not an inset shadow: the month heading's
   background would paint over a shadow's top edge. */
.mgroup:not(.collapsed) {
  --month-tint: color-mix(in srgb, var(--accent) 5%, var(--bg));
  margin: 0 -7px 12px; padding: 0 6px 4px; border-radius: calc(var(--radius) + 4px);
  background: var(--month-tint); border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line));
}
/* The heading spans the panel's full inner width; its 1px shadow sits on the panel's top border, so the panel still
   has a top edge while the heading is pinned. */
.mgroup:not(.collapsed) > .month-head {
  margin: 0 -6px; padding: 6px 6px 8px; background: var(--month-tint); border-radius: calc(var(--radius) + 3px) calc(var(--radius) + 3px) 0 0;
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--accent) 16%, var(--line));
}
/* Days on the month panel get a faint warm edge (inset, so nothing shifts). */
.mgroup .day { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warm) 22%, var(--warm-soft)); }
.mgroup.collapsed { margin-bottom: 2px; }
.rail { position: relative; }

.day { margin: 6px 0 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--warm-soft); position: relative; }

.ev {
  position: relative; margin: 0 0 12px; padding: 14px 16px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s;
}
.ev.flash { border-color: var(--warm); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warm) 30%, transparent); }
.ev .when { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--warm); text-transform: uppercase; }
.ev h3 { margin: 2px 0 6px; font: 500 20px/1.3 var(--serif); letter-spacing: -.01em; }
.ev .summary { margin: 0; color: var(--ink-2); }
.ev .doc-body p { margin: 0 0 8px; }
.ev .doc-body ul, .ev .doc-body ol { margin: 0 0 8px; padding-left: 20px; }
.ev .doc-body h4 { font: 500 16px var(--serif); margin: 10px 0 4px; color: var(--ink); }
.ev .doc-body a { color: var(--accent); overflow-wrap: anywhere; }
.ev .doc-body blockquote { margin: 4px 0 10px; padding: 2px 0 2px 14px; border-left: 3px solid var(--line); color: var(--ink); }
.ev .doc-body blockquote p { margin: 0 0 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 10px; align-items: center; font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; line-height: 1.6;
}
a.chip { text-decoration: none; }
button.chip:hover, a.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.place svg { width: 12px; height: 12px; }
.chip.cat { background: none; }
.chip.status { background: none; border-style: dashed; }
.ev details { margin-top: 8px; font-size: 13.5px; }
.ev summary { cursor: pointer; color: var(--muted); font-size: 12.5px; list-style: none; width: max-content; }
.ev summary::-webkit-details-marker { display: none; }
.ev summary::before { content: "+ "; }
.ev details[open] summary::before { content: "− "; }
.ev details ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.ev .links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ev .links a { font-size: 13px; color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.empty-state { text-align: center; padding: 60px 0; color: var(--muted); }
.empty-state h3 { font: 500 22px var(--serif); color: var(--ink); margin: 0 0 6px; }

/* Chat */
.chat[hidden] { display: none; }
.chat {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--chat-w); z-index: 30; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgb(0 0 0 / .06);
}
.chat-head { display: flex; align-items: flex-start; gap: 6px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.chat-head div { flex: 1; }
.chat-head h2 { margin: 0; font: 500 22px/1.2 var(--serif); }
.chat-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.mem-toggle { display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.mem-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mem-toggle .switch { position: relative; flex: none; width: 26px; height: 15px; border-radius: 8px; background: var(--bar); transition: background .15s; }
.mem-toggle .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.mem-toggle input:checked + .switch { background: var(--accent); }
.mem-toggle input:checked + .switch::after { transform: translateX(11px); }
.chat-toggles { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.mem-toggle .box { position: relative; flex: none; width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--muted); transition: background .15s, border-color .15s; }
.mem-toggle input:checked + .box { background: var(--accent); border-color: var(--accent); }
.mem-toggle input:checked + .box::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.mem-toggle input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.mem-toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }
/* Swipes in the log always scroll the log: they never chain to the page behind (which on iOS can leave the log
   frozen until the page's own momentum ends), and nothing here may claim the gesture. */
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y pinch-zoom;
  padding: 16px 20px; display: flex; flex-direction: column; gap: 14px;
}
.chat-empty p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.suggest { display: block; width: 100%; text-align: left; margin-bottom: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); }
.suggest:hover { border-color: var(--accent); color: var(--ink); }
.msg.user { align-self: flex-end; max-width: 85%; padding: 9px 13px; border-radius: 16px 16px 4px 16px; background: var(--accent); color: var(--accent-ink); white-space: pre-wrap; }
.msg.bot { max-width: 100%; }
.msg.bot .work { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg.bot .work details summary { cursor: pointer; }
.msg.bot .work code { display: block; white-space: pre-wrap; font-size: 11.5px; background: var(--surface-2); padding: 6px 8px; border-radius: 8px; margin-top: 4px; }
.msg.bot .answer p { margin: 0 0 10px; }
.msg.bot .answer a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg.bot .answer ul, .msg.bot .answer ol { margin: 0 0 10px; padding-left: 20px; }
.msg.bot .answer h4 { font: 500 17px var(--serif); margin: 12px 0 4px; }
.msg.bot .error { color: var(--warm); font-size: 13.5px; }
/* "Ask" on an expanded event card, and the chip in the chat showing which event a conversation is about */
.ask-event {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; padding: 3px 8px 3px 6px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-size: 12.5px; font-weight: 500;
}
.ask-event svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.ask-event:hover, .ask-event:focus-visible { background: var(--surface-2); color: var(--accent); }
.chat-focus[hidden] { display: none; }
.chat-focus { display: flex; align-items: center; gap: 6px; margin: 0 16px -4px; padding: 6px 6px 6px 12px; border-radius: 10px; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); }
.chat-focus > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-focus b { font-weight: 600; color: var(--ink); }
.chat-focus button { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); }
.chat-focus button:hover { background: var(--line); color: var(--ink); }
.chat-focus svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* A recorded Ask conversation on its card (lib/chat-records.ts) */
.transcript { margin-top: 10px; }
.transcript summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.transcript .t-q { margin: 12px 0 6px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.transcript .t-who { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.transcript .t-a { font-size: 14px; }
.transcript .t-a p { margin: 0 0 8px; }
.transcript .t-a ul, .transcript .t-a ol { margin: 0 0 8px; padding-left: 20px; }
.transcript .t-a h4 { font: 500 16px var(--serif); margin: 10px 0 4px; }
.transcript .t-a a { color: var(--accent); overflow-wrap: anywhere; }
.chat-del:hover, .chat-del:focus-visible { color: var(--warm); }
/* A Workflowy window: the bullets Mike wrote, under where they sit in his outline */
.wf { margin-top: 10px; font-size: 14px; }
.wf-path { font-size: 12px; color: var(--muted); margin: 10px 0 2px; overflow-wrap: anywhere; }
.wf-path:first-child { margin-top: 0; }
.wf-lines { list-style: none; margin: 0; padding: 0; }
.wf-lines li { position: relative; margin: 3px 0; padding-left: calc(14px + var(--d, 0) * 18px); overflow-wrap: anywhere; }
.wf-lines li::before { content: ""; position: absolute; left: calc(var(--d, 0) * 18px + 2px); top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-2); }
.wf-note { font-size: 13px; color: var(--ink-2); white-space: pre-line; }
.wf-edited { font-size: 11px; color: var(--muted); }
/* Mike's own notes on an event, on its expanded card */
.my-notes { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.my-notes-label { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.my-note { position: relative; padding: 6px 30px 6px 0; }
.my-note + .my-note { border-top: 1px solid var(--line); }
.my-note p { margin: 0; font: 400 15px/1.45 var(--serif); color: var(--ink); white-space: pre-wrap; }
.my-note-meta { font-size: 11.5px; color: var(--muted); }
.my-note-del { position: absolute; top: 4px; right: -4px; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: var(--muted); }
.my-note-del:hover { background: var(--line); color: var(--warm); }
.my-note-del svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* A note the bot offers to save: Save / Discard */
.note-card { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; background: var(--bg); }
.note-card .note-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.note-card .note-corrects { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.note-card blockquote { margin: 8px 0 0; padding: 0; font: 400 15px/1.45 var(--serif); color: var(--ink); white-space: pre-wrap; }
.note-card .note-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.note-card .note-actions button { height: 34px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.note-card .note-actions button.secondary { background: none; border: 1px solid var(--line); color: var(--ink-2); }
.note-card .note-actions button:disabled { opacity: .5; }
.note-card .note-status { font-size: 13px; color: var(--muted); }
.note-card .note-status.error { color: var(--warm); }
.answer-copy { margin-top: 2px; }
.answer-copy button { padding: 0; border: 0; background: none; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.answer-copy button:hover { color: var(--accent); }
.insight-save { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.insight-save button { height: 32px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: none; color: var(--ink-2); font-weight: 500; }
.insight-save button.save { border-color: var(--accent); color: var(--accent); }
.insight-save button:disabled { opacity: .5; }
.insight-status { font-size: 13px; color: var(--muted); }
.insight-status.error { color: var(--warm); }
.note-card.saved { border-left-color: var(--accent); }
.note-card.discarded { opacity: .55; }
.cite {
  display: inline; border: 0; padding: 0 5px; margin: 0 1px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  background: var(--warm-soft); color: var(--warm); vertical-align: 1px;
}
.cite:hover { background: var(--warm); color: var(--surface); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-input textarea {
  flex: 1; resize: none; max-height: 160px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); outline: none; line-height: 1.4;
}
.chat-input textarea:focus { border-color: var(--accent); }
.chat-input button { width: 42px; height: 42px; flex: none; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.chat-input button:disabled { opacity: .4; cursor: default; }

@media (max-width: 1100px) {
  body.chat-open main { margin: 0 auto; }
}
@media (max-width: 720px) {
  html { scroll-padding-top: 120px; }
  .top { flex-wrap: wrap; gap: 10px 12px; padding: 10px 16px; }
  .brand { display: flex; align-items: baseline; gap: 10px; }
  .brand h1 { font-size: 22px; }
  .search { order: 3; flex-basis: 100%; max-width: none; height: 40px; }
  .search kbd { display: none; }
  .ask-btn { height: 36px; padding: 0 14px; }
  .year-head { top: var(--header-h, 108px); }
  .year-head .yr { font-size: 28px; }
  .field { flex: 1 1 40%; }
  .field select, .field input { max-width: none; min-width: 0; width: 100%; }
  .chat { width: 100%; overscroll-behavior: contain; }
  /* The chat covers the whole screen: freeze the page behind it so iOS can't hand a swipe to the hidden page. */
  html:has(body.chat-open), body.chat-open { overflow: hidden; }
}
.filter-toggle { display: none; }
@media (max-width: 720px) {
  .brand { flex: 1; min-width: 0; }
  .brand .sub { white-space: normal; font-size: 11px; }
  .filter-toggle { display: inline-block; }
  .filters:not(.open) .field, .filters:not(.open) .seg { display: none; }
  .filters { padding-bottom: 10px; }
}
html { scroll-padding-top: calc(var(--header-h, 73px) + 70px); }
.top { padding-top: max(14px, env(safe-area-inset-top)); }
.chat { height: 100dvh; bottom: auto; }
.chat-head { padding-top: max(16px, env(safe-area-inset-top)); }
@media (max-width: 720px) {
  /* 16px+ stops iOS Safari from zooming into focused fields */
  .search input, .field select, .field input, .chat-input textarea { font-size: 16px; }
  .top { padding-top: max(10px, env(safe-area-inset-top)); }
  .chip { padding: 4px 11px; font-size: 13px; }
  .meta { gap: 8px; }
  .ev summary { padding: 6px 0; }
  .seg button { padding: 0 14px; }
  .ev .links a { display: inline-block; padding: 4px 0; }
}
.brand h1 { white-space: nowrap; }
@media (max-width: 720px) {
  .brand { flex-direction: column; align-items: flex-start; gap: 2px; }
  .brand .sub { margin: 0; }
}
.refresh { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.refresh:hover { text-decoration: underline; }
@media (max-width: 720px) {
  /* bigger invisible tap area without changing the look */
  .refresh { padding: 6px 4px; margin: -6px -4px; }
}

/* Collapsible cards: only the date and title show until opened */
.ev, .day { padding: 0; margin-bottom: 8px; }
.ev h3, .day h3 { margin: 0; font: inherit; }
.toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px 11px 16px;
  border: 0; background: none; color: inherit; text-align: left; border-radius: var(--radius);
}
.toggle:focus-visible { outline-offset: -2px; }
.toggle .head { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.toggle .title { font: 500 18px/1.3 var(--serif); letter-spacing: -.01em; }
.chev { flex: none; color: var(--muted); transition: transform .2s ease; }
.open > h3 .chev { transform: rotate(180deg); }
/* Child combinators: a day and the events nested inside it open independently. */
.ev > .body, .day > .body { display: none; padding: 0 16px 13px; }
.ev.open > .body, .day.open > .body { display: block; }
.ev:not(.open):hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
@media (max-width: 720px) {
  .toggle { padding: 10px 12px 10px 14px; }
  .toggle .title { font-size: 17px; }
  .ev > .body, .day > .body { padding: 0 14px 12px; }
  .day > .body { padding: 0 8px 8px; }
  .day-overview-text { padding: 0 6px; }
}

/* Photos from the daily Google Photos logs */
.photo-count { display: inline-flex; align-items: center; gap: 3px; flex: none; font-size: 12px; color: var(--muted); }
.photo-count svg { width: 14px; height: 14px; }
.photos { margin-top: 10px; }
.photos-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.photos-label svg { width: 15px; height: 15px; }
.photo-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.photo {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--accent); background: none; text-decoration: none;
}
a.photo:hover, .photo.more:hover { background: var(--accent); color: var(--accent-ink); }
.photos:not(.all) .photo.extra { display: none; }
.photos.all .photo.more { display: none; }
@media (max-width: 720px) { .photo { padding: 5px 11px; } }

/* Chat: web searches */
.msg.bot .work .web-q { margin: 4px 0 0; font-size: 12px; }

/* ---------- Overview: life chapters strip ---------- */
:root { --hue0: #2f6f5e; --hue1: #b8643a; --hue2: #4a6fa5; --hue3: #8a5a9e; --hue4: #9a842a; --hue5: #3a8686; }
.overview { padding: 16px max(16px, 4vw) 6px; }
.life-strip { position: relative; }
.pins { position: relative; height: 16px; }
.pin {
  position: absolute; bottom: 2px; width: 10px; height: 10px; margin-left: -5px; padding: 0; border-radius: 50%;
  border: 2px solid var(--bg); background: var(--warm); transition: transform .15s, opacity .15s;
}
.pin::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 4px; background: var(--warm); opacity: .6; }
.pin:hover { transform: scale(1.35); z-index: 2; }
.pin.dim { opacity: .18; }
.chapters { position: relative; height: 32px; }
.chapter {
  position: absolute; top: 0; bottom: 0; padding: 0 6px; border: 0; border-right: 2px solid var(--bg);
  color: var(--ink); font-size: 12px; font-weight: 500; text-align: left; overflow: hidden; transition: opacity .15s, background .15s;
}
.chapter:first-child { border-radius: 8px 0 0 8px; }
.chapter:last-child { border-radius: 0 8px 8px 0; border-right: 0; }
.chapter span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter.nolabel span { visibility: hidden; }
.chapter.c0 { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.chapter.c1 { background: color-mix(in srgb, var(--accent) 26%, var(--surface-2)); }
.chapter.c2 { background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.chapter.c3 { background: color-mix(in srgb, var(--accent) 20%, var(--surface-2)); }
.chapter:hover { background: color-mix(in srgb, var(--accent) 40%, var(--surface-2)); }
.chapter.active { background: var(--accent); color: var(--accent-ink); }
.chapter.dim { opacity: .45; }
.ticks { position: relative; height: 10px; }
.tick { position: absolute; top: 2px; width: 1px; height: 6px; background: var(--muted); opacity: .7; }
.tick.dim { opacity: .15; }
.daily-mark { position: absolute; top: -34px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--warm); border-radius: 1px; }
.decades { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.decades span { position: absolute; top: 1px; transform: translateX(-50%); }

/* ---------- Overview: daily record strip ---------- */
.record { display: flex; align-items: flex-end; gap: 16px; margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--line); }
.record-label { flex: none; display: flex; flex-direction: column; gap: 1px; padding-bottom: 14px; }
.record-label h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.day-strip-scroll { flex: 1; min-width: 0; overflow: hidden; }
.day-strip { display: flex; gap: 3px; width: max-content; }
.dbar { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 20px; padding: 0; border: 0; background: none; }
.dbar .bar { position: relative; width: 14px; height: 30px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.dbar .bar i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px 3px 0 0; }
.dbar .tot { background: var(--accent); }
.dbar.filtered .tot { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); }
.dbar .hit { background: var(--accent); }
.dbar .dnum { font-size: 10px; line-height: 12px; color: var(--muted); }
.dbar .dnum.month { font-weight: 600; color: var(--ink-2); }
.dbar:hover .bar { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.open-day { margin-top: 6px; height: auto; padding: 4px 0; font-size: 13.5px; }
@media (max-width: 720px) {
  /* Label above the bars, so the strip gets the full width */
  .record { flex-wrap: wrap; gap: 6px; }
  .record-label { padding-bottom: 0; }
  .day-strip-scroll { flex-basis: 100%; }
}

/* ---------- Day view ---------- */
body.day-open { overflow: hidden; }
.dayview-backdrop { position: fixed; inset: 0; z-index: 39; background: rgb(0 0 0 / .35); }
.dayview-backdrop[hidden], .dayview[hidden] { display: none; }
.dayview {
  position: fixed; z-index: 40; top: 4vh; left: 50%; transform: translateX(-50%); width: min(780px, 94vw); height: 92vh;
  display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgb(0 0 0 / .25);
}
.day-head { display: flex; align-items: center; gap: 4px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.day-titles { flex: 1; min-width: 0; text-align: center; }
.day-titles h2 { margin: 0; font: 500 21px/1.2 var(--serif); }
.day-titles p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.day-body { flex: 1; overflow-y: auto; padding: 12px 16px 28px; }
.day-foot { margin-top: 18px; }
.day-overview { margin-bottom: 10px; font-size: 14px; color: var(--ink-2); }
.day-overview summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.day-overview p { margin: 6px 0 0; }
.allday { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.allday > span { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.allday .chip .ct { color: var(--muted); }
.day-empty { color: var(--muted); text-align: center; padding: 24px 0; }
.day-grid-head {
  position: sticky; top: -12px; z-index: 3; display: grid; grid-template-columns: 84px 14px 1fr; gap: 4px; padding: 4px 0 6px 52px;
  background: var(--surface); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.day-grid { position: relative; margin-top: 6px; }
.hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.hour span { position: absolute; left: 0; top: -8px; width: 46px; font-size: 11px; color: var(--muted); background: var(--surface); }
.track { position: absolute; top: 0; bottom: 0; }
.track.places { left: 52px; width: 84px; }
.track.photos { left: 140px; width: 14px; }
.track.events { left: 158px; right: 0; }
.place-seg { position: absolute; left: 0; right: 0; border-radius: 6px; overflow: hidden; border-left: 3px solid; }
.place-seg span { display: block; padding: 3px 5px; font-size: 11px; font-weight: 500; line-height: 1.25; }
.dot { position: absolute; left: 3px; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--warm); }
.dot:hover { transform: scale(1.4); }
.block {
  position: absolute; overflow: hidden; padding: 3px 7px; border: 0; border-left: 3px solid; border-radius: 7px;
  text-align: left; font-size: 12.5px; line-height: 1.3; color: var(--ink); transition: filter .15s;
}
.block:hover { filter: brightness(.95); z-index: 2; }
.block .bt { display: block; font-size: 11px; color: var(--muted); }
.block .bn { font-weight: 500; }
.block.short .bt { display: inline; }
.block.short { white-space: nowrap; text-overflow: ellipsis; padding-top: 2px; }
.now { position: absolute; left: 46px; right: 0; height: 2px; background: var(--warm); z-index: 2; }
.now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--warm); }
.place-seg.p0, .block.k0 { background: color-mix(in srgb, var(--hue0) 16%, var(--surface)); border-color: var(--hue0); }
.place-seg.p1, .block.k1 { background: color-mix(in srgb, var(--hue1) 16%, var(--surface)); border-color: var(--hue1); }
.place-seg.p2, .block.k2 { background: color-mix(in srgb, var(--hue2) 16%, var(--surface)); border-color: var(--hue2); }
.place-seg.p3, .block.k3 { background: color-mix(in srgb, var(--hue3) 16%, var(--surface)); border-color: var(--hue3); }
.place-seg.p4, .block.k4 { background: color-mix(in srgb, var(--hue4) 16%, var(--surface)); border-color: var(--hue4); }
.place-seg.p5, .block.k5 { background: color-mix(in srgb, var(--hue5) 16%, var(--surface)); border-color: var(--hue5); }

@media (max-width: 720px) {
  .overview { padding-top: 12px; }
  .chapters { height: 28px; }
  .chapter { font-size: 11px; padding: 0 4px; }
  .dayview { inset: 0; top: 0; left: 0; transform: none; width: 100%; height: 100dvh; border-radius: 0; }
  .day-head { padding-top: max(10px, env(safe-area-inset-top)); }
  .day-body { padding: 10px 12px calc(24px + env(safe-area-inset-bottom)); }
  .day-grid-head { grid-template-columns: 62px 14px 1fr; padding-left: 44px; }
  .hour span { width: 40px; font-size: 10px; }
  .track.places { left: 44px; width: 62px; }
  .track.photos { left: 110px; }
  .track.events { left: 128px; }
  .now { left: 40px; }
}

/* Day view: details for a tapped event, without leaving the day */
.day-detail {
  flex: none; max-height: 48%; overflow-y: auto; padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 -8px 24px rgb(0 0 0 / .08); border-radius: 0 0 18px 18px;
}
.day-detail[hidden] { display: none; }
.dd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px -8px 0 0; }
.dd-time { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--warm); }
.day-detail h3 { margin: 2px 0 6px; font: 500 19px/1.3 var(--serif); }
.dd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.dd-meta svg { width: 13px; height: 13px; }
.dd-summary { margin: 0 0 4px; font-size: 14px; color: var(--ink-2); }
.dd-jump { margin-top: 8px; height: auto; padding: 4px 0; font-size: 14px; }
.block.sel, .allday .chip.sel { outline: 2px solid var(--warm); outline-offset: 1px; z-index: 3; }
@media (max-width: 720px) { .day-detail { border-radius: 0; max-height: 55%; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); } }

/* Day view: slide when moving between days */
.day-body.slide-next { animation: day-in-next .22s ease-out; }
.day-body.slide-prev { animation: day-in-prev .22s ease-out; }
@keyframes day-in-next { from { transform: translateX(28px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes day-in-prev { from { transform: translateX(-28px); opacity: .3; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .day-body.slide-next, .day-body.slide-prev { animation: none; } }
.dayview { touch-action: pan-y pinch-zoom; }
.chip .rel { margin-left: 5px; font-size: 11px; color: var(--muted); }

/* Day groups: events nested inside their day */
.day-count { display: block; font: 13px/1.45 var(--sans); color: var(--ink-2); margin-top: 1px; }
.day-count svg { display: inline; width: 12px; height: 12px; margin-right: 3px; vertical-align: -1px; }
.day-overview-text { margin: 0 0 2px; font-size: 14px; color: var(--ink-2); }
.day > .body > .open-day { margin: 2px 0 0; }
.day-events { margin-top: 10px; }
.day-events .ev { margin-bottom: 6px; box-shadow: none; }
