/* Theme tokens. <html data-theme> is set before first paint by the inline script in
   index.html: "Auto" follows the OS setting, the header button overrides it.
   Entity colours and heatmap ramps are validated per theme (CVD separation, contrast);
   text pairs all clear WCAG 4.5:1. */
:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --day-h-bg: #eef1f5;
  --day-h-weekend: #e4eaf3;
  --line: #dde2e9;
  --tag-line: #c9d0da;
  --text: #1b1f24;
  --text-2: #3f4752;
  --muted: #5c6470;
  --accent: #256abf;
  --accent-ink: #ffffff;
  --chip-bg: #eef1f5;
  --row-hover: #f8fafc;
  --header-bg: rgba(243, 245, 248, .95);
  --mark-bg: #ffe58a;
  --overlay: rgba(243, 245, 248, .9);
  --danger-bg: #fdecee;
  --danger-ink: #b4232f;
  --danger-line: #f1c0c6;
  /* entity identity: dots on chips + Insights bars */
  --c-act: #eb6834;
  --c-place: #1baf7a;
  --c-person: #4a3aa7;
  /* the same, as text (names in notes): 4.5:1 or more on the panel; the chip green is too light for text */
  --ink-place: #0f7a54;
  --ink-person: #4a3aa7;
  --bar: #2a78d6;
  /* calendar: 0 = no entries, 1..4 = busier, light -> dark */
  --hm-0: #e8ebef;
  --hm-1: #86b6ef;
  --hm-2: #3987e5;
  --hm-3: #1c5cab;
  --hm-4: #0d366b;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e232b;
  --day-h-bg: #1f252e;
  --day-h-weekend: #262d39;
  --line: #2a313b;
  --tag-line: #3a4250;
  --text: #e6e9ee;
  --text-2: #c3cad4;
  --muted: #9aa3b0;
  --accent: #6aa9ff;
  --accent-ink: #08111f;
  --chip-bg: #222832;
  --row-hover: #1a1f26;
  --header-bg: rgba(15, 18, 22, .95);
  --mark-bg: #5b4a12;
  --overlay: rgba(10, 14, 20, .85);
  --danger-bg: #3a1d22;
  --danger-ink: #ff9aa5;
  --danger-line: #5a2a31;
  --c-act: #d95926;
  --c-place: #199e70;
  --c-person: #9085e9;
  --ink-place: #199e70;
  --ink-person: #9085e9;
  --bar: #3987e5;
  /* dark flips the ramp: busier = lighter */
  --hm-0: #232933;
  --hm-1: #184f95;
  --hm-2: #2a78d6;
  --hm-3: #5598e7;
  --hm-4: #86b6ef;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
mark { background: var(--mark-bg); color: inherit; border-radius: 2px; padding: 0 1px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; background: var(--header-bg); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.tabs button:hover { color: var(--text); background: var(--panel-2); }
/* the open tab: filled with the accent colour, like the chosen half of a switch (.seg) */
.tabs button.active { color: var(--accent-ink); background: var(--accent); }
.actions { margin-left: auto; display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px;
  padding: 6px 12px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger-line); }
.btn:hover { filter: brightness(1.08); }
#themeBtn { min-width: 84px; justify-content: center; }
.btn .lbl { margin-left: 5px; } /* flex layout drops the space between icon and label */

/* filters */
.filters { position: sticky; top: 49px; z-index: 19; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 18px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.filters input, .filters select { background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font: inherit; }
.q-box { position: relative; display: flex; flex: 1 1 180px; } /* takes the room that's left (the row fits on one line at 1280px) */
.filters .q-box #q { flex: 1; min-width: 0; padding-right: 32px; }
#q::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; } /* ours works in every browser */
/* × in the search box, once there's something to clear */
.q-clear { position: absolute; top: 50%; right: 3px; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); font: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.q-clear:hover { background: var(--panel-2); color: var(--text); }
#q:placeholder-shown + .q-clear { display: none; }
.more-filters { display: contents; } /* desktop: its fields sit in the filter row as before */
#filtersToggle { display: none; } /* phone layout only */
.mobile-only { display: none; }
.filters input[list] { width: 120px; }
.filters .notes-too { font-size: 13px; font-weight: 500; white-space: nowrap; }
.filters input:focus, .filters select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.summary { padding: 8px 18px; color: var(--muted); font-size: 13px; }
.summary b { color: var(--text); font-weight: 600; }
.summary .clear-f { color: var(--accent); cursor: pointer; margin-left: 6px; }

main { padding: 0 18px 60px; max-width: 1280px; margin: 0 auto; }

/* empty state */
.empty { margin: 60px auto; max-width: 560px; text-align: center; border: 2px dashed var(--line); border-radius: 14px;
  padding: 48px 28px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 8px; }
.empty code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* journal */
/* clip, not hidden: "hidden" would keep the day's heading from staying at the top */
.day { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin: 16px 0; overflow: clip; }
/* A day's heading stays at the top while you scroll through that day: just under the header (and the filter
   bar, where that stays too), measured by app.js into --stick-top. Above the day's rows. */
.day-h { display: flex; align-items: baseline; gap: 10px; padding: 9px 14px; background: var(--day-h-bg); border-bottom: 1px solid var(--line);
  position: sticky; top: var(--stick-top, 0px); z-index: 2; }
.day.weekend .day-h { background: var(--day-h-weekend); }
.day-h .d { font-weight: 600; font-size: 15px; cursor: pointer; }
.day-h .d:hover { color: var(--accent); }
.day-h .ago { margin-left: auto; font-size: 13px; }
.tag { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--tag-line); border-radius: 999px; padding: 0 6px; }
.row { display: grid; grid-template-columns: minmax(110px, 160px) minmax(140px, 1fr) minmax(140px, 1fr) minmax(180px, 1.5fr);
  gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line); align-items: start; }
.row:first-of-type { border-top: 0; }
.row:hover { background: var(--row-hover); }
.c-notes { color: var(--text-2); }
.note-line { display: block; }
.note-line + .note-line { margin-top: 2px; }
/* people and places named in a note: the name in its colour, a little bolder; tap to see its entries */
.nm { color: var(--ink-person); font-weight: 600; cursor: pointer; }
.nm.place { color: var(--ink-place); }
.nm:hover { text-decoration: underline; text-underline-offset: 2px; }
.nm mark { color: var(--text); } /* a search match reads the same everywhere (and stays legible in dark mode) */
.extra { color: var(--muted); font-size: 13px; }

/* chips: neutral text; the dot carries the type (activity / place / person) */
.chip { display: inline-block; padding: 1px 8px; margin: 1px 4px 1px 0; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; font-size: 13px; color: var(--text); background: var(--chip-bg); }
.chip:hover { border-color: var(--dot, var(--accent)); }
.chip.act { --dot: var(--c-act); font-weight: 600; }
.chip.place { --dot: var(--c-place); }
.chip.person { --dot: var(--c-person); }
.chip.act::before, .chip.place::before, .chip.person::before {
  content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px; background: var(--dot); }
.chip.year { color: var(--accent); font-weight: 600; }
/* a line from your notes (a place's usuals): no type dot, and long ones end in "…" */
.chip.note { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
/* a couple ("Papa & Mama"): its chips joined into one pill, a dot for each name, a line between them */
.pair { display: inline-flex; margin: 1px 4px 1px 0; vertical-align: top; }
.pair .chip { margin: 0; border-radius: 0; padding: 1px 7px; }
.pair .chip:first-child { border-radius: 999px 0 0 999px; padding-left: 8px; }
.pair .chip:last-child { border-radius: 0 999px 999px 0; padding-right: 8px; }
/* One line between two names: the right chip's left border (the left chip has no right border), lit up
   with whichever side you point at. */
.pair .chip:not(:last-child) { border-right-width: 0; }
.pair .chip + .chip { border-left-color: var(--line); }
.pair .chip + .chip:hover, .pair .chip:hover + .chip { border-left-color: var(--dot); }
/* cells written "-" (left blank on purpose), and blank items in lists ("Alone") */
.blank { color: var(--muted); }
.blank-sum { display: none; } /* phones only */
.blank-name { color: var(--muted); }
.chip.blank { background: transparent; border-color: var(--tag-line); color: var(--muted); }
.more { text-align: center; color: var(--muted); padding: 22px; }
/* "+ 12 more" / "40 in all" under a cut-short list: tap to see it all, "Show fewer" to fold it back */
.list-foot { margin-top: 6px; font-size: 12px; }
.list-more { font-size: 12px; }
@media (max-width: 760px) {
  .row { grid-template-columns: 1fr 1fr; }
  .filters { top: 0; position: static; }
}

/* insights */
.ins-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 0; font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; } /* hidden but still focusable */
.switch .track { position: relative; flex: none; width: 36px; height: 20px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.card h3 .unit { text-transform: none; letter-spacing: 0; font-weight: 400; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; overflow: hidden; }
.grid .card { margin: 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.bl { display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr 48px; gap: 8px; align-items: center; padding: 3px 4px; border-radius: 5px; cursor: pointer; }
.bl:hover { background: var(--panel-2); }
.bl-k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bl-bar i { display: block; height: 100%; background: var(--bar); border-radius: 4px; }
.bl[data-f="activity"] .bl-bar i { background: var(--c-act); }
.bl[data-f="place"] .bl-bar i { background: var(--c-place); }
.bl[data-f="person"] .bl-bar i { background: var(--c-person); }
.bl-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bl.static { cursor: default; }
.scroll-x { overflow-x: auto; }
svg text { fill: var(--muted); font-size: 12px; }
svg .axis { stroke: var(--line); }
svg .mbar { fill: var(--bar); }
svg .clk { cursor: pointer; }
svg .clk:hover { stroke: var(--text); stroke-width: 1; }
/* the line above each monthly chart: "58% of days this year · 57% overall" */
.chart-head { margin: -4px 0 8px; color: var(--text-2); }
.chart-head b { font-size: 20px; color: var(--text); }
/* With people: a grey column per month (alone), filled from the bottom with the days with someone */
svg .share-bg { fill: var(--panel-2); }
svg .share-bar { fill: var(--c-person); }
svg .share-m { cursor: pointer; }
svg .share-m:hover .share-bg { stroke: var(--text); stroke-width: 1; }
rect.l0 { fill: var(--hm-0); }
rect.l1 { fill: var(--hm-1); }
rect.l2 { fill: var(--hm-2); }
rect.l3 { fill: var(--hm-3); }
rect.l4 { fill: var(--hm-4); }
.hm-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.hm-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-left: 6px; }
.hm-legend i.l0 { background: var(--hm-0); }
.hm-legend i.l1 { background: var(--hm-1); }
.hm-legend i.l2 { background: var(--hm-2); }
.hm-legend i.l3 { background: var(--hm-3); }
.hm-legend i.l4 { background: var(--hm-4); }
.otd-item { padding: 6px 0; border-top: 1px solid var(--line); }
.otd-item:first-of-type { border-top: 0; }

/* files */
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.card a, .empty a { color: var(--accent); cursor: pointer; }
code { background: var(--panel-2); padding: 0 4px; border-radius: 4px; font-size: 12.5px; }

/* dropbox */
.dbx p { margin: 0 0 8px; }
.dbx details { margin: 4px 0 10px; }
.dbx .steps { margin: 8px 0 4px; padding-left: 20px; line-height: 1.8; }
.dbx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 10px 0; }
.dbx-row > span:first-child { margin-right: auto; }
.dbx-row input { flex: 1 1 320px; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font: inherit; }
.dbx-row input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.dbx-status { margin-top: 8px; font-size: 13px; color: var(--muted); }
.dbx-status.error { color: var(--danger-ink); }
.dbx-files { list-style: none; margin: 6px 0; padding: 0; }
.dbx-files li { display: flex; gap: 12px; align-items: baseline; padding: 3px 0; }
.dbx-files li a { font-size: 13px; }
.dbx-browser { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dbx-crumbs { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--panel-2);
  border-bottom: 1px solid var(--line); font-size: 13px; }
.dbx-list { max-height: 360px; overflow: auto; }
.dbx-item { display: flex; gap: 8px; align-items: baseline; padding: 6px 12px; border-top: 1px solid var(--line); }
.dbx-item:first-child { border-top: 0; }
.dbx-item[data-dbx-path], .dbx-item[data-dbx-add] { cursor: pointer; }
.dbx-item[data-dbx-path]:hover, .dbx-item[data-dbx-add]:hover { background: var(--row-hover); }
.dbx-item.synced { color: var(--muted); }
.dbx-item .meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

.file { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.file .meta { color: var(--muted); font-size: 13px; }
details summary { cursor: pointer; color: var(--muted); margin-top: 6px; }
details ul { max-height: 260px; overflow: auto; margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* overlays */
.drop { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: flex; align-items: center; justify-content: center; }
.drop div { border: 3px dashed var(--accent); border-radius: 18px; padding: 60px 90px; font-size: 22px; color: var(--accent); }
.progress { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; width: min(380px, calc(100vw - 32px)); font-size: 13px; color: var(--muted); }
.progress .bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s; }

/* adding entries */
.fab { position: fixed; right: 22px; bottom: 26px; z-index: 35; width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28); }
.fab:hover { filter: brightness(1.08); }
.tag.pending { margin-left: 4px; white-space: nowrap; }
.row { position: relative; }
.row.editable { padding-right: 40px; }
.row-edit { position: absolute; top: 6px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); font-size: 15px; cursor: pointer; opacity: .45; }
.row:hover .row-edit, .row-edit:focus-visible { opacity: 1; }
.row-edit:hover { background: var(--panel-2); color: var(--text); }
.chip.template { color: var(--text); }
.quick-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.quick.recent { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.quick.recent .chip { white-space: nowrap; }
.hint { margin-left: 6px; font-size: 12px; color: var(--accent); }
.hint:empty { display: none; }
.sheet input.auto { border-style: dashed; }
.form-actions #addDelete { margin-right: auto; }
.card.banner { border-color: var(--danger-line); background: var(--danger-bg); }
.card.banner .dbx-row { margin: 10px 0 6px; }
dialog.sheet { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; overflow: auto;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet h2:focus { outline: none; } /* the title (tabindex -1, first in the form) takes the focus when it opens, not Clear */
.sheet form { display: grid; gap: 8px; padding: 16px 18px 18px; }
.sheet form > * { min-width: 0; } /* a long row of chips scrolls instead of widening the form */
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
/* the form's title, with "Clear" (new entries only) at the other end */
.sheet-head { display: flex; align-items: baseline; gap: 12px; }
.sheet-head h2 { margin-right: auto; }
.link-btn { border: 0; background: none; padding: 6px 2px; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }
.sheet label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.sheet input, .sheet textarea, .sheet select { background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font: inherit; font-size: 16px; } /* 16px: no zoom-on-focus on phones */
.sheet input:focus, .sheet textarea:focus, .sheet select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.sheet textarea { resize: vertical; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 4px; }
.quick:empty { display: none; }
button.chip { font: inherit; font-size: 13px; }
.people-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 6px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); }
.people-box:focus-within { outline: 1px solid var(--accent); border-color: var(--accent); }
.people-box input { flex: 1 1 140px; min-width: 0; border: 0; padding: 4px; background: transparent; }
.people-box input:focus { outline: 0; }
.people-box .chip { margin: 0; }
.chip-x { margin-left: 6px; padding: 0 2px; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.form-msg { font-size: 13px; color: var(--danger-ink); }
.form-msg:empty { display: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }

/* people & places, recap */
.pp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); color: var(--muted); padding: 6px 12px; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pp-bar input, .pp-bar select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font: inherit; }
.pp-bar input { flex: 1 1 160px; min-width: 0; }
.pp-list { padding: 0; }
.pp-head, .pp-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(100px, 1fr) minmax(130px, 1fr) 106px; gap: 10px; align-items: center; padding: 8px 14px; }
.pp-head { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--line); }
.pp-row { border-top: 1px solid var(--line); cursor: pointer; }
.pp-head + .pp-row { border-top: 0; }
.pp-row:hover, .pp-row.open { background: var(--row-hover); }
.pp-name .chip { margin: 0; }
.pp-detail { padding: 2px 14px 12px; background: var(--row-hover); }
.pp-with { margin: 4px 0; line-height: 2; }
.spark rect { fill: var(--bar); }
.spark.person rect { fill: var(--c-person); }
.spark.place rect { fill: var(--c-place); }
.spark.act rect { fill: var(--c-act); }
/* tidy names */
.btn.ghost.active { border-color: var(--accent); color: var(--accent); }
.card.tidy p { margin: 0 0 8px; }
.tidy-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; border-top: 1px solid var(--line); padding: 10px 0; }
.tidy-group:last-child { padding-bottom: 2px; }
.tidy-why { flex-basis: 100%; }
.tidy-names { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 6px; }
/* haven't seen in a while */
.drift-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 10px; padding: 3px 0; }
.drift-row .chip { margin: 0; }
/* what's changed lately */
.chg-range { font-size: 13px; }
.chg-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: 8px 22px; margin-top: 10px; }
.chg-h { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.chg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 3px 0; }
.chg-row .chip { margin: 0; }
/* journal check */
.btn.small { padding: 2px 10px; font-size: 13px; }
.card.check p { margin: 0 0 8px; }
.check-group { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.check-h { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.check-h .btn { margin-left: auto; }
.check-item { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 4px 0; }
.check-item > a, .check-item > span:first-child { flex: 1 1 240px; min-width: 0; }
.check-item .muted { font-size: 13px; }
.check-gaps { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.check-gaps .chip { margin: 0; }
.check-gaps button.chip { border-color: var(--tag-line); }
.tidy-names .chip { margin: 0; }
.rc-title { min-width: 140px; text-align: center; font-size: 16px; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi .d { margin-top: 2px; font-size: 12px; color: var(--muted); }
.bl-bar i.c-act-bar { background: var(--c-act); }
.bl-bar i.c-place-bar { background: var(--c-place); }
.bl-bar i.c-person-bar { background: var(--c-person); }
.rc-months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 140px; }
.rc-m { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.rc-m .rc-bar { flex: 1; display: flex; align-items: flex-end; width: 100%; max-width: 24px; }
.rc-m .rc-bar i { display: block; width: 100%; min-height: 1px; background: var(--bar); border-radius: 4px 4px 0 0; }
.rc-m span { font-size: 12px; color: var(--muted); }
.rc-m.future { opacity: .4; cursor: default; }
body[data-view="recap"] .filters, body[data-view="recap"] .summary { display: none; } /* filters don't apply to a recap */

/* phone layout */
@media (max-width: 640px) {
  /* No blur here: backdrop-filter would make the header the anchor for the fixed tab bar below. */
  .top { gap: 8px; padding: 8px 12px; backdrop-filter: none; }
  .brand { font-size: 15px; }
  .actions { gap: 6px; }
  .actions .lbl, .desktop-only { display: none !important; } /* icon-only header buttons (theme, sync status) */
  .actions .btn, #themeBtn { min-width: 40px; justify-content: center; padding: 6px 10px; }
  .mobile-only { display: block; }
  /* the tab bar: about 70px tall, its labels well up from the bottom edge */
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 4px; justify-content: space-around;
    padding: 8px 6px calc(14px + env(safe-area-inset-bottom)); background: var(--header-bg);
    border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
  .tabs button { flex: 1; padding: 14px 0; font-size: 13px; }
  .filters { gap: 6px; padding: 8px 10px; }
  .q-box { flex: 1 1 auto; min-width: 0; }
  .q-clear { width: 32px; height: 32px; right: 1px; }
  #filtersToggle { display: inline-flex; }
  .more-filters { display: none; }
  .filters.open .more-filters { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .more-filters > * { flex: 1 1 140px; min-width: 0; }
  .filters input[list] { width: auto; }
  .summary { padding: 6px 12px; }
  .sum-f { display: block; } /* "filtered from … ✕ clear filters" gets its own line */
  .sum-sep { display: none; }
  main { padding: 0 10px 170px; } /* room for the tab bar and + button */
  .day { margin: 10px 0; }
  .day-h { flex-wrap: wrap; gap: 4px 8px; padding: 8px 12px; }
  .row { grid-template-columns: auto 1fr; grid-template-areas: 'act place' 'people people' 'notes notes';
    gap: 4px 8px; padding: 8px 12px; }
  .c-act { grid-area: act; } .c-place { grid-area: place; } .c-people { grid-area: people; } .c-notes { grid-area: notes; }
  .c-place:empty, .c-people:empty, .c-notes:empty { display: none; }
  .row-edit { opacity: .75; } /* no hover on phones */
  /* Blank cells: no lone dashes on their own lines; one short note on the first line instead. */
  .c-place > .blank, .c-people > .blank, .c-notes > .blank { display: none; }
  .c-people:has(> .blank:only-child), .c-notes:has(> .blank:only-child) { display: none; }
  .blank-sum { display: inline; margin-left: 4px; font-size: 12px; color: var(--muted); }
  .blank-sum::before { content: '— '; }
  .c-act > .blank::after { content: ' ' attr(data-what); font-size: 12px; }
  .pp-head { display: none; }
  .pp-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name last' 'days spark'; gap: 4px 10px; }
  .pp-name { grid-area: name; } .pp-last { grid-area: last; text-align: right; }
  .pp-days { grid-area: days; } .pp-spark { grid-area: spark; }
  .rc-bar-top .rc-title { flex: 1; min-width: 0; }
  #recapCopy { flex-basis: 100%; justify-content: center; }
  /* number tiles (Insights, Recap): smaller here */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
  .kpi { padding: 7px 10px; border-radius: 8px; }
  .kpi .v { font-size: 18px; }
  .kpi .v small { font-size: 12px; }
  .kpi .l { font-size: 11px; letter-spacing: .3px; }
  .kpi .d { margin-top: 0; font-size: 11px; }
  .bl { grid-template-columns: minmax(0, 1.4fr) 1fr 44px; }
  .dbx-row input { flex-basis: 100%; }
  .drop div { padding: 40px 24px; font-size: 18px; }
  .fab { right: 16px; bottom: calc(94px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(166px + env(safe-area-inset-bottom)); }
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92vh; }
}
