/* ---------- Themes ----------
   html[data-theme][data-mode] picks the colours; appearance.js sets the accent and fonts
   (--accent, --accent-fg, --font-head, --font-read). Same layout in every theme. */
:root {
  --radius-s: 8px;
  --radius: 16px;
  --radius-l: 20px;
  --font-ui: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font: var(--font-ui);
  --font-head: 'Fraunces', Georgia, serif;
  --head-weight: 500;
  --font-read: 'Newsreader', Georgia, serif;
  --accent: #A9541E;
  --accent-fg: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--surface));
  --deco-side: none;
  --deco-main: none;
}
html[data-mode="light"] {
  --shadow: 0 1px 2px rgba(30,24,18,.05), 0 16px 36px -26px rgba(30,24,18,.28);
  --tag-bg: #e2ecfb; --tag-fg: #2456a6;
  --hl-yellow: #fde68a; --hl-green: #bbf7d0; --hl-blue: #bfdbfe; --hl-pink: #fbcfe8; --hl-orange: #fed7aa; --hl-purple: #ddd6fe;
  --tx-red: #c62828; --tx-orange: #c2410c; --tx-green: #2b8a3e; --tx-blue: #1c64c8; --tx-purple: #7048e8; --tx-gray: #6c6a64;
}
html[data-mode="dark"] {
  --shadow: 0 24px 48px -30px rgba(0,0,0,.75);
  --tag-bg: #1d2c42; --tag-fg: #9fc3f5;
  --hl-yellow: #5c4a12; --hl-green: #1e4d33; --hl-blue: #1e3a5f; --hl-pink: #5b2140; --hl-orange: #5c3317; --hl-purple: #3b2d63;
  --tx-red: #ff8a80; --tx-orange: #ffb37a; --tx-green: #8ce99a; --tx-blue: #8fbcff; --tx-purple: #c4b5fd; --tx-gray: #a8a69e;
}
/* Nokavi: forest black, sage and warm ivory (the brand) */
html[data-theme="nokavi"][data-mode="dark"] {
  --bg: #202622; --side: #1B201D; --surface: #262D29; --surface-2: #2F3732; --border: rgba(201,219,206,.13);
  --text: #F1EEE6; --soft: #D5DBD3; --muted: #A3B2A8;
  --milestone: #E2C07A; --milestone-soft: #3A3626; --danger: #EE9A86; --decision: #B9C8F2;
}
html[data-theme="nokavi"][data-mode="light"] {
  --bg: #F1EEE6; --side: #EAE6DC; --surface: #FAF8F3; --surface-2: #E8E4DA; --border: #D9D4C7;
  --text: #202622; --soft: #3A433D; --muted: #5C6961;
  --milestone: #835C12; --milestone-soft: #F3E7CC; --danger: #A3342C; --decision: #3F55A8;
}
html[data-theme="nokavi"] .page-title-h, html[data-theme="nokavi"] .side-brand { letter-spacing: -.025em; }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark svg { width: 1.15em; height: 1.15em; flex: none; }
.side-brand, .wrap .side-brand { font-family: 'Manrope', var(--font-ui); font-weight: 800; letter-spacing: -.025em; text-transform: lowercase; }
.gate-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 4px; }
.gate-brand .brand-mark { font-family: 'Manrope', var(--font-ui); font-weight: 800; font-size: 1.9rem; letter-spacing: -.02em; }
.gate-tagline { margin: 0; color: var(--muted); }

/* Hearth: warm espresso and cream */
html[data-theme="hearth"][data-mode="dark"] {
  --bg: #17130F; --side: #1B1612; --surface: #201A15; --surface-2: #2A231C; --border: rgba(255,230,200,.11);
  --text: #F1E8DC; --soft: #D9CDBE; --muted: #B3A594;
  --milestone: #E8B65A; --milestone-soft: #3A2E1E; --danger: #EE8F78; --decision: #C3B8FF;
}
html[data-theme="hearth"][data-mode="light"] {
  --bg: #FAF6EF; --side: #F4EEE4; --surface: #FFFDF9; --surface-2: #F2EBDF; --border: #E7DDCD;
  --text: #2A211A; --soft: #4A3E33; --muted: #6E6152;
  --milestone: #8C5A12; --milestone-soft: #F6E9D2; --danger: #A3342C; --decision: #6D5BD0;
}
/* Observatory: ink navy, a faint star field in the sidebar */
html[data-theme="observatory"][data-mode="dark"] {
  --bg: #0B0E1A; --side: #0D1121; --surface: #121729; --surface-2: #1A2138; --border: rgba(169,180,255,.13);
  --text: #E8EAF4; --soft: #C9CDE0; --muted: #9AA1BD;
  --milestone: #F2C14E; --milestone-soft: #2E2A1C; --danger: #F08A80; --decision: #C9B7FF;
  --deco-side: radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,.55) 50%, transparent 51%), radial-gradient(1px 1px at 140px 90px, rgba(200,210,255,.4) 50%, transparent 51%), radial-gradient(1.5px 1.5px at 90px 160px, rgba(255,255,255,.35) 50%, transparent 51%), radial-gradient(1px 1px at 200px 220px, rgba(255,255,255,.3) 50%, transparent 51%);
}
html[data-theme="observatory"][data-mode="light"] {
  --bg: #F5F6FA; --side: #EEF0F7; --surface: #FFFFFF; --surface-2: #EEF0F7; --border: #E1E4EE;
  --text: #151827; --soft: #343A52; --muted: #5B6178;
  --milestone: #8A5A00; --milestone-soft: #FBF1D9; --danger: #B3261E; --decision: #5B45D6;
}
/* Studio: neutral graphite, crisp hairlines */
html[data-theme="studio"] { --radius: 14px; --radius-l: 18px; }
html[data-theme="studio"][data-mode="dark"] {
  --bg: #0D0D0F; --side: #111114; --surface: #151518; --surface-2: #1C1C20; --border: #26262B;
  --text: #F4F4F5; --soft: #D4D4D8; --muted: #A1A1AA;
  --milestone: #FFC46B; --milestone-soft: #2B2418; --danger: #F28B82; --decision: #C4B5FD;
}
html[data-theme="studio"][data-mode="light"] {
  --bg: #FAFAFA; --side: #FFFFFF; --surface: #FFFFFF; --surface-2: #F2F2F4; --border: #E7E7EA;
  --text: #18181B; --soft: #3F3F46; --muted: #5F5F69;
  --milestone: #92600A; --milestone-soft: #FBF0DC; --danger: #B3261E; --decision: #5B3FD0;
}
/* Orbit: aubergine with a soft aurora at the top */
html[data-theme="orbit"][data-mode="dark"] {
  --bg: #100C1C; --side: #130F22; --surface: #18132A; --surface-2: #221B38; --border: rgba(196,180,255,.13);
  --text: #EEEAF8; --soft: #D2CCE6; --muted: #A79FC2;
  --milestone: #FFC46B; --milestone-soft: #33281A; --danger: #F28B9A; --decision: #5ED1BE;
  --deco-main: radial-gradient(60% 420px at 18% -80px, rgba(124,92,255,.26), transparent 70%), radial-gradient(50% 360px at 85% -100px, rgba(64,201,180,.15), transparent 70%);
}
html[data-theme="orbit"][data-mode="light"] {
  --bg: #F7F5FC; --side: #F1EEF9; --surface: #FFFFFF; --surface-2: #EFEBFA; --border: #E3DDF2;
  --text: #1B1530; --soft: #3C3456; --muted: #5E5677;
  --milestone: #8C5A00; --milestone-soft: #FBF0DC; --danger: #B3261E; --decision: #13786A;
  --deco-main: radial-gradient(60% 420px at 18% -80px, rgba(124,92,255,.13), transparent 70%), radial-gradient(50% 360px at 85% -100px, rgba(64,201,180,.10), transparent 70%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; margin: 0 0 8px; }
h2 { font-size: 1.125rem; margin: 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, input, select, textarea { font: inherit; color: inherit; }
input[type="text"], input[type="password"], input[type="datetime-local"], select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  min-height: 40px;
}
textarea { width: 100%; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button { cursor: pointer; border-radius: var(--radius-s); min-height: 40px; padding: 0 14px; border: 1px solid transparent; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.ghost { background: transparent; border-color: var(--border); }
.ghost:hover { background: var(--surface-2); }
.link { background: none; border: none; padding: 0 4px; color: var(--accent); min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
.danger { color: var(--danger); }

.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.error { color: var(--danger); margin: 0; }
.warn { background: var(--milestone-soft); border-radius: var(--radius-s); padding: 10px 12px; margin: 4px 0; font-size: .9rem; }

/* Gate screens */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; display: flex; flex-direction: column; gap: 10px;
}
.gate-card label:not(.check) { font-weight: 600; font-size: .9rem; margin-top: 4px; }
.gate-card .primary { margin-top: 8px; }

/* Banner */
.banner { background: var(--danger); color: #fff; padding: 10px 16px; text-align: center; }


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

/* Capture */
.capture { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.capture-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.capture:focus-within { border-color: var(--accent); }
#cap-milestone-title { flex: 1 1 200px; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: .8rem; }
@media (hover: none) { .hint { display: none; } }

/* Rich editor (TipTap) */
.ProseMirror { position: relative; white-space: pre-wrap; white-space: break-spaces; word-wrap: break-word; font-variant-ligatures: none; }
.ProseMirror [contenteditable="false"] { white-space: normal; }
.ProseMirror pre { white-space: pre-wrap; }
.ProseMirror img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; }
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
.cap-editor, .edit-editor { cursor: text; }
.rich-editor { outline: none; min-height: 96px; padding: 4px 2px; overflow-wrap: break-word; }
.edit-editor .rich-editor { min-height: 120px; border: 1px solid var(--border); border-radius: var(--radius-s); padding: 8px 10px; background: var(--surface); }
.edit-editor .rich-editor:focus-within { border-color: var(--accent); }
.rich-editor p.is-empty::before {
  content: attr(data-placeholder); color: var(--muted); opacity: .8;
  float: left; height: 0; pointer-events: none;
}
/* The open @/# suggestion is shown by the list, not by colouring the text. */
.rich-editor .tableWrapper { overflow-x: auto; margin: 0 0 .6em; }
.rich-editor .tableWrapper table { margin: 0; }
.rich-editor td, .rich-editor th { min-width: 80px; position: relative; }
.rich-editor .selectedCell::after { content: ""; position: absolute; inset: 0; background: var(--accent-soft); opacity: .6; pointer-events: none; }
.rich-editor hr.ProseMirror-selectednode { border-top-color: var(--accent); }
.ProseMirror-gapcursor { display: none; }

/* To-do lists (editor and list view) */
.md ul[data-type="taskList"] { list-style: none; padding-left: 0; }
.md ul[data-type="taskList"] li { display: flex; gap: .5em; align-items: flex-start; }
.md ul[data-type="taskList"] li > label { flex: none; margin-top: .2em; user-select: none; }
.md ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.md ul[data-type="taskList"] li > div > p { margin: 0; }
.md ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--muted); text-decoration: line-through; }
.md ul[data-type="taskList"] input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }

/* Slash menu */
.slash-menu {
  position: absolute; z-index: 40; width: 260px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px;
}
.slash-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 8px;
  background: none; border: none; border-radius: var(--radius-s); text-align: left;
}
.slash-item.is-active, .slash-item:hover { background: var(--surface-2); }
.slash-icon {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface);
  font-size: .8rem; font-weight: 700; color: var(--muted);
}
.slash-text { display: flex; flex-direction: column; line-height: 1.25; }
.slash-title { font-size: .9rem; }
.slash-hint { font-size: .75rem; color: var(--muted); }
.slash-empty { padding: 8px; color: var(--muted); font-size: .875rem; }

/* Selection bubble */
.bubble {
  position: absolute; top: 0; left: 0; width: max-content;
  z-index: 40; display: flex; align-items: center;
  background: var(--text); color: var(--bg); border-radius: var(--radius-s);
  box-shadow: 0 8px 24px rgba(0,0,0,.22); padding: 3px;
}
.bubble-buttons { display: flex; gap: 2px; }
.bubble-btn { min-width: 32px; min-height: 32px; padding: 0 8px; background: none; border: none; color: inherit; font-weight: 700; font-size: .875rem; }
.bubble-btn:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); }
.bubble-btn.is-on { color: var(--accent); background: var(--bg); }
.bubble-italic { font-style: italic; font-family: Georgia, serif; }
.bubble-strike { text-decoration: line-through; }
.bubble-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .75rem; }
.bubble-link { display: flex; align-items: center; gap: 4px; padding: 2px; }
.bubble-link input { min-height: 32px; width: 220px; padding: 4px 8px; font-size: .875rem; background: var(--bg); color: var(--text); border: none; }
.bubble-link button { min-height: 32px; padding: 0 8px; background: none; border: none; color: inherit; font-size: .8rem; font-weight: 600; }
.bubble-err { font-size: .75rem; padding: 0 6px; color: #ffb4ab; }

/* Rendered Markdown */
.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin: 0 0 .6em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: .9em 0 .35em; line-height: 1.3; }
.md h1 { font-size: 1.25rem; }
.md h2 { font-size: 1.125rem; }
.md h3, .md h4, .md h5, .md h6 { font-size: 1rem; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .15em 0; }
.md li > ul, .md li > ol { margin: .15em 0 0; }
.md li > p, .md td > p, .md th > p { margin: 0; }
.md li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.3em; }
.md input[type="checkbox"] { margin: 0 .45em 0 0; vertical-align: -2px; accent-color: var(--accent); }
.md a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
.md blockquote { margin-left: 0; padding: .4em .8em; background: var(--surface-2); border-radius: var(--radius-s); color: var(--muted); font-style: italic; }
.md code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em;
  background: var(--surface-2); border-radius: 4px; padding: .1em .35em;
}
.md pre { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: .85rem; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: .9rem; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 600; }
.md th[align="center"], .md td[align="center"] { text-align: center; }
.md th[align="right"], .md td[align="right"] { text-align: right; }

/* Filters */
.filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: .875rem;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* List */
.day { margin-top: 20px; }
.day-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px 2px; }
.entry { padding: 12px 14px; margin-bottom: 8px; }
.entry.is-milestone { border-color: var(--milestone); background: linear-gradient(var(--milestone-soft), var(--milestone-soft)) padding-box; }
.entry-meta { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.topic-tag { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.ms-title { color: var(--milestone); font-weight: 700; font-size: .95rem; margin: 6px 0 0; }
.entry-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }
.entry-body.md { white-space: normal; overflow-wrap: break-word; }
.entry-actions { margin-left: auto; display: flex; gap: 2px; }
.entry-actions button { min-height: 28px; padding: 0 8px; font-size: .8rem; background: none; border: none; color: var(--muted); }
.entry-actions button:hover { color: var(--text); background: var(--surface-2); }
.entry-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.entry-edit .capture-row { justify-content: flex-end; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.more { display: block; margin: 16px auto 0; }

/* Topics panel */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; }
.panel {
  width: min(420px, 100%); height: 100%; overflow-y: auto;
  background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.topics-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.topic-row { display: flex; align-items: center; gap: 4px; }
.topic-row input { flex: 1; min-width: 0; }
.topic-row button { min-height: 36px; padding: 0 8px; }
.topic-row.is-archived input { color: var(--muted); text-decoration: line-through; }
.topic-add { display: flex; gap: 8px; }
.topic-add input { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); border-radius: var(--radius-s);
  padding: 10px 14px; display: flex; gap: 14px; align-items: center; z-index: 30;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.toast button { background: none; border: none; color: inherit; font-weight: 700; text-decoration: underline; min-height: 0; padding: 0; }

/* ---------- Step 2: tabs, topic status, status board, timeline ---------- */


.filter-toggles { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Open loops ---------- */
.tab-badge { margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #b4442f; color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }
.loops-view { display: grid; gap: 16px; }
.loop-form { display: grid; gap: 8px; padding: 12px 14px; }
.loop-form .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.loop-form input[type=text] { flex: 1 1 220px; min-width: 0; }
.loop-form .loop-text { width: 100%; }
.loop-form .from-entry { font-size: .85rem; }
.loop-group h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.loop-group.overdue h2 { color: #b4442f; }
.loop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.loop { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; }
.loop input[type=checkbox] { margin-top: 3px; flex: none; }
.loop-main { flex: 1; min-width: 0; }
.loop-text-line { overflow-wrap: anywhere; }
.loop.done .loop-text-line { text-decoration: line-through; color: var(--muted); }
.loop-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.loop-meta .due.overdue { color: #b4442f; font-weight: 600; }
.loop-meta a { color: inherit; }
.loop-kind { font-weight: 600; }
.loop-actions { display: flex; gap: 2px; flex: none; }
.loop-actions button { min-height: 1.8rem; padding: 0 6px; }
.loop-actions .bell[aria-pressed="false"] { opacity: .35; }
.loops-done summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.found-list, .ai-result .found-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.found-list label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-s); }
.found-list .dup { opacity: .55; }
.page-title { font-size: 1.25rem; margin: 4px 0 14px; }
.hint-line { color: var(--muted); font-size: .8rem; margin: 0; }
.pill { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
button.small { min-height: 32px; padding: 0 10px; font-size: .85rem; }
button.topic-tag { border: none; font-size: inherit; min-height: 0; cursor: pointer; }
button.topic-tag:hover { background: var(--accent); color: var(--accent-fg); }

/* Topic page header */
#topic-status:not(:empty) { margin: 4px 0 16px; }
.topic-status { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ts-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ts-title { font-size: 1.25rem; margin: 0; }
.ts-sub { font-size: .85rem; margin-top: 2px; }
.status-age { color: var(--muted); }
.status-age.is-stale { color: var(--milestone); font-weight: 600; }
.ts-empty { margin: 0; }
.status-edit { display: flex; flex-direction: column; gap: 8px; }
.ts-history { border-top: 1px solid var(--border); padding-top: 8px; }
.ts-history-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ts-history-list > li { background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 12px; }
.ts-history-meta { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.ts-history-meta .link { font-size: .8rem; margin-left: auto; }

/* Status board */
.status-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.status-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.status-card.is-editing { grid-column: 1 / -1; }
.sc-head { display: flex; flex-direction: column; gap: 2px; }
.sc-title { background: none; border: none; padding: 0; min-height: 0; text-align: left; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.sc-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.sc-head .status-age, .sc-head .muted { font-size: .8rem; }
.sc-empty { margin: 0; }
.sc-foot { display: flex; align-items: center; gap: 8px; font-size: .8rem; margin-top: auto; padding-top: 4px; }

/* Show more / less */
.clamp { max-height: 7.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.clamp.fits, .clamp.is-open { max-height: none; -webkit-mask-image: none; mask-image: none; }
.clamp-toggle { font-size: .8rem; margin-top: 2px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; top: 8px; bottom: 8px; left: 95px; width: 2px; background: var(--border);
}
.tl-month { margin: 22px 0 10px; padding-left: 108px; }
.tl-month:first-child { margin-top: 6px; }
.tl-month h2 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.tl-item { display: grid; grid-template-columns: 76px 24px 1fr; column-gap: 8px; align-items: start; margin-bottom: 10px; }
.tl-when { display: flex; flex-direction: column; align-items: flex-end; padding-top: 10px; line-height: 1.2; }
.tl-day { font-size: .85rem; font-weight: 600; }
.tl-time { font-size: .75rem; color: var(--muted); }
.tl-dot {
  position: relative; z-index: 1; justify-self: center; margin-top: 14px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted);
}
.tl-milestone .tl-dot {
  width: 24px; height: 24px; margin-top: 8px; border: none; background: var(--milestone); color: var(--surface);
  display: grid; place-items: center; font-size: .8rem; line-height: 1;
}
.tl-status .tl-dot { width: 12px; height: 12px; border-radius: 3px; transform: rotate(45deg); border-color: var(--accent); background: var(--accent-soft); }
.tl-card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.tl-milestone .tl-card { border-color: var(--milestone); background: var(--milestone-soft); }
.tl-status .tl-card { background: transparent; border-style: dashed; }
.tl-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.tl-kind { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; }
.tl-milestone .tl-kind { color: var(--milestone); }
.tl-status .tl-kind { color: var(--accent); }
.tl-actions { margin-left: auto; display: flex; gap: 2px; }
.tl-actions button { min-height: 28px; padding: 0 8px; font-size: .8rem; background: none; border: none; color: var(--muted); }
.tl-actions button:hover { color: var(--text); background: var(--surface-2); }
.tl-title { color: var(--milestone); font-weight: 700; font-size: 1.05rem; margin: 2px 0 4px; }
.tl-mark { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.tl-mark input { flex: 1 1 220px; min-width: 0; }
.tl-more { text-align: center; padding: 10px 0 0 108px; }
.timeline .empty { padding-left: 0; }
@media (max-width: 560px) {
  .timeline::before { left: 68px; }
  .tl-item { grid-template-columns: 52px 22px 1fr; column-gap: 6px; }
  .tl-month, .tl-more { padding-left: 80px; }
  .tl-day { font-size: .78rem; }
}

/* ---------- Step 3: search, tags, export ---------- */

.filters { flex-direction: column; align-items: stretch; }
.filters .filter-toggles { align-self: flex-start; }
.search-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#search {
  flex: 1 1 240px; min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; min-height: 40px;
}
#search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.result-count { margin: 0 0 4px 2px; font-size: .85rem; color: var(--muted); font-weight: 600; }
mark { background: var(--milestone-soft); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: 0 0 0 1px var(--milestone); }

/* Tags on entries and timeline */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag {
  min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent;
}
.tag:hover { color: var(--text); border-color: var(--border); }
.tag.is-active { background: var(--accent); color: var(--accent-fg); }

/* Tag field (capture and edit) */
.tag-input {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  border-top: 1px dashed var(--border); padding-top: 8px; cursor: text;
}
.entry-edit .tag-input { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 4px 8px; background: var(--surface); }
.tag-input-label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.tag-input-list { display: contents; }
.tag-input input { flex: 1 1 120px; min-width: 100px; border: none; background: transparent; min-height: 32px; padding: 2px 4px; }
.tag-input input:focus-visible { outline: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 2px; min-height: 26px; padding: 0 4px 0 9px;
  border-radius: 999px; background: var(--accent-soft); font-size: .8rem; font-weight: 600;
}
.tag-chip button { min-height: 22px; min-width: 22px; padding: 0; border: none; background: none; color: var(--muted); font-size: .7rem; border-radius: 999px; }
.tag-chip button:hover { color: var(--text); background: var(--surface); }
.tag-chip.is-filter { background: var(--accent); color: var(--accent-fg); }
.tag-chip.is-filter button { color: var(--accent-fg); }

/* Export panel */
#export-panel .panel > label { font-weight: 600; font-size: .9rem; }
.export-option { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.export-option .muted { margin: 0; font-size: .85rem; }
.export-option button { align-self: flex-start; }

.tag-input input::-webkit-calendar-picker-indicator { display: none !important; }

/* ---------- Step 4: AI summaries ---------- */
.ai-btn { white-space: nowrap; }
.ai-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-btns:not(:has(.ai-btn:not([hidden]))) { display: none; }
.ai-asked { margin: 0 0 10px; font-weight: 600; }
.review-periods { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.review-periods legend { font-weight: 600; margin-bottom: 6px; }
.review-periods label { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-s); cursor: pointer; }
.review-periods label:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }
.review-periods label.empty { opacity: .55; }
.review-periods .muted { margin-left: auto; font-size: .85em; white-space: nowrap; }
.review { display: grid; gap: 14px; }
.review h3 { margin: 0 0 6px; font-size: 1rem; }
.review h4 { margin: 8px 0 2px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.review-area { border-top: 1px solid var(--border); padding-top: 12px; }
.review .md ul { margin: 2px 0; padding-left: 1.2em; }
.review .md p { margin: 0; }
.review-status textarea { width: 100%; font: inherit; margin-top: 4px; }
.review-status .capture-row { margin-top: 6px; }
.ai-ask { display: grid; gap: 10px; }
.ai-ask label[for] { font-weight: 600; }
.ai-ask textarea { width: 100%; font: inherit; }
.ai-ask-note { margin: 0; font-size: .85em; }
.search-row .ai-btn { min-height: 40px; border-radius: 999px; }
.ai-panel { width: min(560px, 100%); }
.ai-scope { margin: 0; }
.ai-sent summary { cursor: pointer; font-size: .9rem; font-weight: 600; }
.ai-sent ol { margin: 8px 0 0; padding-left: 1.2em; font-size: .85rem; max-height: 220px; overflow-y: auto; }
.ai-sent li { margin: 2px 0; overflow-wrap: anywhere; }
.ai-working { margin: 0; font-style: italic; }
.ai-result { background: var(--surface-2); border-radius: var(--radius-s); padding: 12px 14px; min-height: 60px; }
.ai-result:empty { display: none; }

/* ---------- Step 5: home-screen app, Face ID unlock, phone polish ---------- */

/* Sign-in-again banner */
.banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
#banner-action { min-height: 32px; background: #fff; color: var(--danger); font-weight: 700; border: none; }

/* Unlock screen */
.device-unlock { min-height: 48px; font-size: 1rem; }
.unlock-or { text-align: center; margin: 2px 0 0; font-size: .85rem; }

/* Offer card */
.device-offer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; }

/* Small centred dialog */
.overlay.center { align-items: center; justify-content: center; padding: 16px; }
.panel.dialog { height: auto; max-height: calc(100dvh - 32px); width: min(440px, 100%); border-radius: var(--radius); }
.panel.dialog > label { font-weight: 600; font-size: .9rem; }
.panel.dialog .muted { margin: 0; font-size: .9rem; }

/* This device (Topics panel) */
.device-section { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.device-section h2 { font-size: 1rem; }
.device-section p { margin: 0; font-size: .9rem; }
.device-section button { align-self: flex-start; }

/* Fields follow the text size; the viewport's maximum-scale stops iPhone zooming into them */
.bubble-link input, .tl-mark input, .tag-input input, #search, select, textarea, input { font-size: 1rem; }

/* Full-screen (home-screen) mode: keep clear of the notch and the home indicator */
@media (display-mode: standalone) {
  .sidebar { padding-top: max(22px, env(safe-area-inset-top)); }
  .banner { padding-top: max(10px, env(safe-area-inset-top)); }
  .wrap { padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px)); }
  .panel { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .gate { padding-top: max(24px, env(safe-area-inset-top)); }
}
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button, a, .chip, .tab { -webkit-tap-highlight-color: transparent; }
.device-pass-row { display: flex; flex-direction: column; gap: 6px; }
.device-pass-row label { font-weight: 600; font-size: .9rem; }
.device-step2 { margin: 0; background: var(--accent-soft); border-radius: var(--radius-s); padding: 10px 12px; font-size: .9rem; }

/* ---------- Density, text size, wide screens, @people / #tags ---------- */

html { font-size: 14px; }
html[data-text-size="small"] { font-size: 13px; }
html[data-text-size="medium"] { font-size: 14px; }
html[data-text-size="large"] { font-size: 16px; }
body { font-size: 1rem; line-height: 1.45; }

/* Tighter controls (sizes follow the text size) */
button { min-height: 2.35rem; padding: 0 .85rem; }
input[type="text"], input[type="password"], input[type="datetime-local"], select, textarea { min-height: 2.35rem; padding: .35rem .6rem; }
.chip { min-height: 1.9rem; padding: 0 .7rem; font-size: .86rem; }
.capture { padding: 10px; gap: 8px; }
.rich-editor { min-height: 5rem; }
.entry { padding: 10px 12px; margin-bottom: 6px; }
.entry-body { margin-top: 4px; }
.day { margin-top: 14px; }
.filters { margin: 14px 0 6px; gap: 8px; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin-bottom: .45em; }
.tl-item { margin-bottom: 8px; }
.tl-card { padding: 8px 10px; }
.status-card, .topic-status { padding: 12px; }
.md-tool, .bubble-btn { min-height: 2rem; }
.entry-actions button, .tl-actions button { min-height: 1.8rem; }

/* Inline @person / #tag (rendered text and editor) */
.ref {
  display: inline; min-height: 0; padding: 0 .3em; margin: 0; border: none; border-radius: 4px;
  font: inherit; font-weight: 600; font-size: .95em; line-height: inherit; cursor: pointer;
  background: var(--accent-soft); color: var(--accent);
}
.ref-tag { background: var(--surface-2); color: var(--muted); }
span.ref { cursor: text; }
button.ref:hover { text-decoration: underline; text-underline-offset: 2px; }
.tag-person { background: var(--accent-soft); color: var(--accent); }
html[data-mode="dark"] .ref-tag { color: var(--text); }

/* Tags tab */
.page-hint { margin: -6px 0 14px; }
.tags-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.refs-card { padding: 14px; }
.refs-card h2 { font-size: 1rem; margin: 0 0 8px; }
.refs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.refs-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .86rem; }

/* Text size control */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; align-self: flex-start; }
.segmented button { min-height: 1.9rem; border-radius: 999px; background: none; border: none; font-size: .86rem; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* The editor must keep spaces as typed (ProseMirror needs pre-wrap). The general ".md"
   rule sets white-space: normal for rendered text; this wins for the editor itself. */
.md.rich-editor, .ProseMirror.md { white-space: pre-wrap; white-space: break-spaces; }

/* #tags are blue, @people green */
.ref-tag, .tag-tag, .tag-list .tag:not(.tag-person), .tag-input .tag-chip:not(.is-filter) { background: var(--tag-bg); color: var(--tag-fg); }
.tag-tag:hover, .tag-list .tag:not(.tag-person):hover { color: var(--tag-fg); border-color: var(--tag-fg); }
.tag.is-active.tag-tag { background: var(--tag-fg); color: var(--tag-bg); }

/* ---------- Areas and topics ---------- */
#topic-chips { display: flex; flex-direction: column; gap: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-row { padding-left: 10px; margin-left: 4px; position: relative; }
.sub-row::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--border); }
.chip.sub { min-height: 1.75rem; font-size: .8rem; background: transparent; }
.chip.sub[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.sub-topics { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 6px; }
.sub-topics li { display: grid; grid-template-columns: minmax(80px, max-content) 1fr auto; gap: 10px; align-items: baseline; font-size: .86rem; padding: 2px 0; }
.sub-topic-name { background: none; border: none; min-height: 0; padding: 0; font-weight: 600; color: var(--text); text-align: left; }
.sub-topic-name:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.sub-topic-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sub-topic-meta { font-size: .78rem; white-space: nowrap; }

/* Settings: areas with their topics */
.areas-section { border-top: none; padding-top: 0; }
.topics-list { gap: 10px; }
.area-item { display: flex; flex-direction: column; gap: 4px; }
.area-item > .topic-row input { font-weight: 600; }
.sub-list { display: flex; flex-direction: column; gap: 4px; padding-left: 18px; }
.topic-row.is-sub input { font-size: .9rem; }
.sub-add { display: flex; gap: 6px; }
.sub-add input { flex: 1; min-width: 0; font-size: .9rem; }

/* ---------- Compact timeline ---------- */
.timeline::before { left: 76px; }
.tl-month { margin: 14px 0 6px; padding-left: 92px; }
.tl-item { grid-template-columns: 62px 22px 1fr; column-gap: 4px; margin-bottom: 4px; }
.tl-when { padding-top: 6px; }
.tl-day { font-size: .78rem; }
.tl-time { font-size: .7rem; }
.tl-dot { margin-top: 10px; width: 9px; height: 9px; }
.tl-milestone .tl-dot { width: 18px; height: 18px; margin-top: 6px; font-size: .65rem; }
.tl-status .tl-dot { width: 10px; height: 10px; margin-top: 10px; }
.tl-card { padding: 5px 10px 6px; border-radius: var(--radius-s); }
.tl-meta { margin-bottom: 1px; gap: 6px; font-size: .74rem; }
.tl-meta .topic-tag { padding: 0 6px; font-size: .72rem; }
.tl-actions button { min-height: 1.5rem; padding: 0 6px; font-size: .74rem; }
.tl-title { font-size: .92rem; margin: 0 0 2px; }
.timeline .clamp { max-height: 3em; }
.timeline .md { font-size: .92rem; }
.timeline .md p, .timeline .md ul, .timeline .md ol { margin-bottom: .2em; }
.timeline .tag-list { margin-top: 3px; }
.timeline .tag { min-height: 1.35rem; font-size: .7rem; padding: 0 6px; }
.timeline .clamp-toggle { font-size: .74rem; }
.tl-more { padding-left: 92px; }
@media (max-width: 560px) {
  .timeline::before { left: 59px; }
  .tl-item { grid-template-columns: 46px 20px 1fr; column-gap: 4px; }
  .tl-month, .tl-more { padding-left: 72px; }
}
.add-topic-link { align-self: flex-start; font-size: .8rem; padding: 0 2px; min-height: 1.6rem; }
/* Must beat ".timeline .clamp" above: opened / fitting entries show in full. */
.timeline .clamp.fits, .timeline .clamp.is-open { max-height: none; -webkit-mask-image: none; mask-image: none; }

/* ---------- Highlight & text colour (fixed palette) ---------- */
mark[data-color] { color: inherit; border-radius: 3px; padding: 0 .12em; box-shadow: none; }
mark[data-color="yellow"] { background: var(--hl-yellow); }
mark[data-color="green"] { background: var(--hl-green); }
mark[data-color="blue"] { background: var(--hl-blue); }
mark[data-color="pink"] { background: var(--hl-pink); }
mark[data-color="orange"] { background: var(--hl-orange); }
mark[data-color="purple"] { background: var(--hl-purple); }
[data-text-color="red"] { color: var(--tx-red); }
[data-text-color="orange"] { color: var(--tx-orange); }
[data-text-color="green"] { color: var(--tx-green); }
[data-text-color="blue"] { color: var(--tx-blue); }
[data-text-color="purple"] { color: var(--tx-purple); }
[data-text-color="gray"] { color: var(--tx-gray); }

.bubble { flex-wrap: wrap; max-width: min(92vw, 420px); }
.bubble-color { text-decoration: underline; text-decoration-color: #e2b25a; text-decoration-thickness: 3px; text-underline-offset: 2px; }
.bubble-palette { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px 2px; width: 100%; }
.palette-row { display: flex; align-items: center; gap: 4px; }
.palette-label { font-size: .7rem; width: 58px; opacity: .8; }
.swatch { width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent); font-weight: 800; font-size: .8rem; background: var(--bg); }
.swatch-hl[data-c="yellow"] { background: var(--hl-yellow); } .swatch-hl[data-c="green"] { background: var(--hl-green); }
.swatch-hl[data-c="blue"] { background: var(--hl-blue); } .swatch-hl[data-c="pink"] { background: var(--hl-pink); }
.swatch-hl[data-c="orange"] { background: var(--hl-orange); } .swatch-hl[data-c="purple"] { background: var(--hl-purple); }
.swatch-tx[data-c="red"] { color: var(--tx-red); } .swatch-tx[data-c="orange"] { color: var(--tx-orange); }
.swatch-tx[data-c="green"] { color: var(--tx-green); } .swatch-tx[data-c="blue"] { color: var(--tx-blue); }
.swatch-tx[data-c="purple"] { color: var(--tx-purple); } .swatch-tx[data-c="gray"] { color: var(--tx-gray); }
.swatch-none { color: var(--text); background: var(--bg); }

/* ---------- Links between entries ---------- */
a[data-entry] { color: var(--accent); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; cursor: pointer; }
a[data-entry]::before { content: "↗ "; font-size: .85em; }
.backlinks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); font-size: .8rem; }
.backlinks-label { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; }
.backlink { min-height: 0; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: none; font-size: .8rem; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backlink:hover { background: var(--accent-soft); color: var(--accent); }
.entry.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.cal-title { font-size: 1.15rem; margin: 0 6px; min-width: 9.5em; text-align: center; }
.cal-head #cal-today { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-weekday { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px 2px; }
.cal-cell {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-height: 6.4rem; padding: 5px 6px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); color: var(--text); overflow: hidden;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.is-other { opacity: .45; }
.cal-cell.is-today .cal-num { background: var(--accent); color: var(--accent-fg); }
.cal-cell.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-num { align-self: flex-start; font-size: .8rem; font-weight: 700; min-width: 1.6em; height: 1.6em; display: grid; place-items: center; border-radius: 999px; }
.cal-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-item { font-size: .72rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 1px 4px; border-radius: 4px; background: var(--surface-2); }
.cal-item.cal-milestone { background: var(--milestone-soft); color: var(--milestone); font-weight: 700; }
.cal-item.cal-status { background: var(--accent-soft); color: var(--accent); }
.cal-more { font-size: .7rem; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.cal-dot.cal-milestone { background: var(--milestone); }
.cal-dot.cal-status { background: var(--accent); }
.cal-day { margin-top: 16px; }
.cal-day-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cal-day-head h2 { font-size: 1rem; margin: 0; }
.cal-hint { margin: 6px 2px; }
.cal-day .cal-status { border-style: dashed; }
@media (max-width: 700px) {
  .cal-cell { min-height: 3.2rem; padding: 4px; align-items: center; }
  .cal-num { align-self: center; }
  .cal-items, .cal-more { display: none; }
  .cal-dots { display: flex; justify-content: center; }
  .cal-weekday { text-align: center; padding: 0; }
  .cal-title { min-width: 0; flex: 1; }
}

/* ---------- Screenshots and files ---------- */
.att-image { position: relative; display: inline-block; max-width: 100%; vertical-align: bottom; line-height: 0; }
.att-image img, .md img[data-attachment] { max-width: 100%; height: auto; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--surface-2); }
.md img[data-attachment] { display: inline-block; vertical-align: bottom; margin: 2px 0; }
.att-image.is-selected img { outline: 2px solid var(--accent); outline-offset: 2px; }
.att-resize {
  position: absolute; right: -5px; bottom: -5px; width: 14px; height: 14px; border-radius: 4px;
  background: var(--accent); border: 2px solid var(--surface); cursor: nwse-resize; opacity: 0; transition: opacity .15s;
}
.att-image:hover .att-resize, .att-image.is-selected .att-resize { opacity: 1; }
@media (hover: none) { .att-resize { opacity: 1; width: 20px; height: 20px; } }
img.att-loading { min-width: 120px; min-height: 80px; }
img.att-broken { min-width: 120px; min-height: 40px; }
a[data-file], .rich-editor a[href^="attachment:"] { color: var(--accent); background: var(--surface-2); border-radius: 4px; padding: 0 .3em; text-decoration: none; cursor: pointer; }
a[data-file]:hover { text-decoration: underline; }
.attach-btn { white-space: nowrap; }
/* Screenshots on their own line (they're inline nodes, displayed as blocks) */
.att-image { display: block; width: fit-content; margin: 6px 0; }
.md img[data-attachment] { display: block; margin: 6px 0; }

/* ---------- Connection graph ---------- */
.graph-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: .86rem; }
.graph-bar button.small { min-width: 2.2rem; }
.graph-wrap { position: relative; }
.graph-canvas { display: block; width: 100%; height: calc(100vh - 170px); min-height: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); touch-action: none; cursor: grab; }
.graph-detail { position: absolute; top: 10px; right: 10px; width: min(340px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow-y: auto; padding: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.gd-close { position: absolute; top: 6px; right: 6px; min-height: 1.8rem; padding: 0 8px; }
.gd-title { margin: 0 28px 2px 0; font-size: 1rem; }
.gd-list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: .86rem; }
.gd-list .link { text-align: left; }
.gd-actions { margin-top: 8px; display: flex; gap: 6px; }
.graph-help { margin: 6px 2px 0; font-size: .78rem; }
@media (max-width: 700px) {
  .graph-canvas { height: calc(100vh - 290px); }
  .graph-detail { position: static; width: auto; margin-top: 8px; box-shadow: none; }
}
.graph-bar button.small { font-size: 1rem; }
@media (max-width: 700px) { .graph-detail { position: relative; top: auto; right: auto; } }

/* ---------- Recovery key ---------- */
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.recovery-key { font-size: 1.05rem; letter-spacing: .04em; line-height: 1.6; background: var(--surface-2); border-radius: var(--radius-s); padding: 12px 14px; margin: 4px 0; word-break: normal; overflow-wrap: normal; user-select: all; }
.recovery-offer { border-color: var(--milestone); }
.recover-link { align-self: center; font-size: .85rem; margin-top: 4px; }
.dialog-form { display: flex; flex-direction: column; gap: 8px; }
.dialog-form label:not(.check) { font-weight: 600; font-size: .9rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.panel.dialog > h2 { margin-bottom: 4px; }
.export-sub { font-size: .95rem; margin: 6px 0 0; border-top: 1px solid var(--border); padding-top: 12px; }
.backup-option { border-top: none; padding-top: 0; }

/* ---------- Decisions ---------- */
.decision-wrap { border-top: 1px dashed var(--border); padding-top: 8px; }
.decision-fields { display: grid; grid-template-columns: 1fr; gap: 4px; }
.decision-fields label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.decision-fields label.decision-revisit { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: .86rem; font-weight: 600; margin-top: 4px; }
.decision-fields textarea { min-height: 2.6rem; }
.decision-badge { color: var(--decision); font-weight: 700; }
.decision-block { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--decision) 8%, var(--surface)); display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.decision-block ul { margin: 2px 0 0; padding-left: 1.2em; }
.decision-block p { margin: 2px 0 0; }
.decision-label { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.decision-revisit-line.is-due { color: var(--milestone); font-weight: 600; }
.tl-kind-decision { color: var(--decision); }
.tl-decision .tl-dot { width: 18px; height: 18px; margin-top: 6px; border: none; background: var(--decision); color: #fff; display: grid; place-items: center; font-size: .6rem; }
.cal-item.cal-decision { background: color-mix(in srgb, var(--decision) 14%, var(--surface)); color: var(--decision); font-weight: 600; }
.cal-dot.cal-decision { background: var(--decision); }

/* ---------- Person pages ---------- */
.person-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.person-sub { color: var(--muted); font-size: .9rem; }
.person-rel { display: inline-block; margin-top: 4px; }
.person-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 16px; }
.fact { display: flex; flex-direction: column; gap: 1px; font-size: .9rem; }
.person-together { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.person-together .decision-label { margin-right: 4px; }
.person-notes { margin: 0; white-space: pre-wrap; font-size: .9rem; background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 10px; }
.person-form label { font-size: .78rem; font-weight: 700; color: var(--muted); }
.person-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; align-items: center; }
.person-form textarea { width: 100%; }
@media (max-width: 560px) { .person-grid { grid-template-columns: 1fr; } }
.refs-list .person-sub { font-size: .8rem; }
.fact a { color: var(--accent); text-underline-offset: 3px; }

/* ---------- Inbox & quick capture ---------- */
.inbox-card { padding: 12px 14px; margin-bottom: 12px; border-color: var(--accent); }
.inbox-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.inbox-head h2 { font-size: 1rem; margin: 0; }
.inbox-hint { font-size: .8rem; }
.inbox-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.inbox-list li { background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.inbox-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.inbox-photo { margin-left: 6px; }
.inbox-meta { display: flex; align-items: center; gap: 6px; font-size: .8rem; }
#qc-text { width: 100%; min-height: 8rem; }
.qc-photo { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; }
.qc-done { background: var(--accent-soft); border-radius: var(--radius-s); padding: 10px 12px; }
.qc-done p { margin: 0 0 8px; }
.qc-howto summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.qc-howto ol { padding-left: 1.2em; font-size: .88rem; display: flex; flex-direction: column; gap: 4px; }
.qc-howto code { font-size: .78rem; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }

/* ---------- Hearth Studio layout: sidebar, page header, home dashboard ---------- */
body { font-family: var(--font-ui); }
.primary, .ghost { border-radius: 999px; }
input[type="text"], input[type="password"], input[type="datetime-local"], input[type="date"], select, textarea { border-radius: 10px; }
.card { border-radius: var(--radius-l); }

.app { display: flex; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; flex: 0 0 248px; overflow-y: auto; scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 14px; padding: 22px 14px 16px;
  background-color: var(--side); background-image: var(--deco-side); background-size: 260px 260px;
  border-right: 1px solid var(--border);
}
.sidebar .side-brand { font-size: 1.75rem; line-height: 1.1; padding: 2px 10px 4px; letter-spacing: -.01em; }
.new-entry {
  min-height: 2.9rem; border: 0; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.new-entry svg { width: 16px; height: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav .tab {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 2.5rem; padding: 0 10px;
  border-radius: 10px; color: var(--soft); text-decoration: none; font-weight: 500;
}
.side-nav .tab:hover { background: var(--surface-2); color: var(--text); }
.side-nav .tab[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.tab-badge { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.side-label { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 0; }
.side-areas { display: flex; flex-direction: column; gap: 1px; }
.side-area {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 2.3rem; padding: 0 10px;
  border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; font-weight: 400;
}
.side-area:hover { background: var(--surface-2); }
.side-area[aria-current="true"] { background: var(--surface-2); font-weight: 600; }
.side-area .n { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 10px; }
.side-foot button { min-height: 2.4rem; border-radius: 12px; font-size: .85rem; color: var(--soft); padding: 0 8px; }

.wrap { flex: 1; min-width: 0; background-image: var(--deco-main); background-repeat: no-repeat; padding: 34px clamp(16px, 4vw, 48px) 80px; }
.wrap > .page-head, .wrap > .top, .wrap > .side, .wrap > .content { max-width: 1080px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.page-date { color: var(--muted); font-size: .95rem; }
.page-title-h { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 2.5rem; line-height: 1.08; letter-spacing: -.01em; margin: 2px 0 0; }
html[data-theme="observatory"] .page-title-h { font-size: 2.8rem; }
.page-head #search { flex: 0 1 340px; width: 340px; min-height: 2.75rem; padding: 0 18px; background: var(--surface); }

/* Writing box and entries in the reading font */
.top { display: flex; flex-direction: column; }
.capture { padding: 16px 18px; gap: 12px; box-shadow: var(--shadow); margin-bottom: 18px; }
.capture .rich-editor, .edit-editor .rich-editor, .status-edit .rich-editor { font-family: var(--font-read); font-size: var(--read-size, 1.12rem); line-height: 1.6; }
.entry-body.md, .timeline .md, .ts-body, .tl-card .md, .inbox-text, .home-excerpt { font-family: var(--font-read); font-size: var(--read-size, 1.12rem); line-height: 1.6; }
.timeline .md { font-size: calc(var(--read-size, 1.12rem) * .9); }
.page-title, .ts-title, .sc-title, .refs-card h2, .home-card h2, .cal-title, .gd-title, .panel-head h2, .panel.dialog > h2, .review h3 {
  font-family: var(--font-head); font-weight: var(--head-weight); letter-spacing: -.005em;
}
.day-label {
  display: flex; align-items: center; gap: 12px; margin: 0 0 10px;
  font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.15rem; color: var(--soft);
  text-transform: none; letter-spacing: 0;
}
.day-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.day { margin-top: 22px; }
.entry { padding: 16px 18px; margin-bottom: 10px; border-radius: var(--radius); }
.entry-meta { gap: 10px; }
.topic-tag { background: var(--surface-2); padding: 1px 10px; font-weight: 500; }
.ms-title { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.25rem; color: var(--text); margin: 8px 0 0; }
.ms-title::before { content: "★ "; color: var(--milestone); }
.entry.is-milestone { background: var(--surface); border-color: color-mix(in srgb, var(--milestone) 45%, transparent); }
.status-card, .topic-status, .refs-card, .loop, .loop-form { border-radius: var(--radius); }

/* Filters under the page header */
.side { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.side .filters { margin: 0; gap: 10px; }
.chip { background: transparent; }
.chip[aria-pressed="true"], .chip.sub[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.ai-btn { min-height: 2.4rem; }
.ai-btns .ai-btn { background: var(--surface); }
.wrap[data-view="home"] #topic-chips, .wrap[data-view="home"] .filter-toggles, .wrap[data-view="home"] #result-count { display: none; }

/* Home dashboard */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); gap: 16px; }
.home-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.home-card.wide { grid-column: 1 / -1; }
.home-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.home-card h2 { font-size: 1.2rem; margin: 0; }
.home-card .link-btn { background: none; border: 0; min-height: 0; padding: 0; color: var(--muted); font-size: .85rem; }
.home-card .link-btn:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.home-pill { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 600; }
.home-row { border-top: 1px solid var(--border); padding: 10px 0; min-width: 0; }
.home-loop { display: flex; align-items: center; gap: 12px; min-height: 3rem; padding: 4px 0; }
.home-loop input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.home-loop .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.home-loop .d { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.home-loop .d.overdue { color: var(--danger); font-weight: 600; }
.home-status { display: flex; flex-direction: column; gap: 2px; width: 100%; background: none; border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 10px 0; text-align: left; color: var(--text); min-height: 0; }
.home-status:hover .a { color: var(--accent); }
.home-status .top-line { display: flex; justify-content: space-between; gap: 8px; }
.home-status .a { font-weight: 600; }
.home-status .w { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.home-status .s { font-family: var(--font-read); color: var(--soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.home-entry { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; gap: 16px; align-items: baseline; width: 100%; background: none; border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 14px 0; text-align: left; color: var(--text); min-height: 0; }
.home-entry:hover .h { color: var(--accent); }
.home-entry .w { font-size: .8rem; color: var(--muted); }
.home-entry .h { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.1rem; display: block; }
.home-excerpt { color: var(--soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.home-entry .ar { font-size: .78rem; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.home-empty { color: var(--muted); margin: 6px 0; }

/* Phone: the sidebar becomes a drawer, a menu bar sits at the bottom */
.mobile-nav, .scrim { display: none; }
@media (max-width: 899px) {
  .sidebar {
    position: fixed; z-index: 35; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh;
    transform: translateX(-104%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.35);
    padding-top: max(22px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 34; background: rgba(0,0,0,.4); }
  .wrap { padding: max(24px, env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom)); }
  .page-title-h { font-size: 2rem; }
  html[data-theme="observatory"] .page-title-h { font-size: 2.3rem; }
  .page-head #search { flex: 1 1 100%; width: auto; }
  .mobile-nav {
    display: flex; gap: 10px; position: fixed; z-index: 20; left: 14px; right: 14px; bottom: max(14px, env(safe-area-inset-bottom));
  }
  .mobile-nav nav {
    flex: 1; display: flex; justify-content: space-around; align-items: center; height: 3.6rem; border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
    border: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .mobile-nav .tab, .mobile-nav .more-btn {
    min-width: 3.2rem; min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 0 6px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 500;
  }
  .mobile-nav .tab[aria-current="page"] { color: var(--text); font-weight: 700; }
  .mobile-nav .fab {
    flex: none; width: 3.6rem; height: 3.6rem; border-radius: 50%; border: 0; padding: 0;
    background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; box-shadow: var(--shadow);
  }
  .mobile-nav .fab svg { width: 22px; height: 22px; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .home-entry { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .home-entry .ar { justify-self: start; }
}

/* Appearance panel */
.ap-panel { width: min(560px, 100%); }
.ap-body { display: flex; flex-direction: column; gap: 22px; padding-bottom: 8px; }
.ap-section { display: flex; flex-direction: column; gap: 8px; }
.ap-label { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ap-tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.ap-themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ap-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 2.75rem; padding: 10px 12px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left;
}
.ap-tile[aria-pressed="true"] { border: 2px solid var(--accent); padding: 9px 11px; }
.ap-tile .nm { font-weight: 600; }
.ap-tile .sub { font-size: .78rem; color: var(--muted); }
.ap-tile .aa { font-size: 1.5rem; line-height: 1; }
.ap-dots { display: flex; gap: 4px; }
.ap-dots span { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(128,128,128,.35); }
.ap-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.ap-swatch { width: 2.75rem; height: 2.75rem; min-height: 0; padding: 0; border-radius: 50%; border: 0; }
.ap-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px currentColor; }
.ap-preview { padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.ap-preview .ph { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.6rem; line-height: 1.1; }
.ap-preview .pr { font-family: var(--font-read); font-size: var(--read-size, 1.12rem); line-height: 1.6; margin: 0; }
.ap-foot { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--border); padding-top: 14px; }
.ap-foot .muted { flex: 1; font-size: .82rem; margin: 0; }

/* ---------- Events ---------- */
.events-view { display: flex; flex-direction: column; gap: 16px; }
.event-form { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.event-form > input[type="text"] { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.15rem; }
.event-form .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ev-date { display: flex; flex-direction: column; gap: 2px; font-size: .78rem; color: var(--muted); font-weight: 600; }
.ev-date input { color: var(--text); }
.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.event-row {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; padding: 12px 16px;
  text-align: left; color: var(--text); border-radius: var(--radius); border-left-width: 1px;
}
.event-row:hover { border-color: var(--accent); }
.ev-name { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.1rem; }
.event-row .muted { font-size: .85rem; }
.event-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.event-sub { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.15rem; margin: 8px 0 0; }
.event-during { display: flex; flex-direction: column; margin-top: 8px; }
.back-link { align-self: flex-start; text-decoration: none; font-size: .9rem; }
.cal-item.cal-event { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); font-weight: 600; }
.cal-dot.cal-event { background: var(--accent); }
.cal-day .event-row { margin-bottom: 8px; }
.tl-event .tl-dot { width: 18px; height: 18px; margin-top: 6px; border: none; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-size: .65rem; }
.tl-event-card { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%; text-align: left; color: var(--text); min-height: 0; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tl-event .tl-kind { color: var(--accent); }
a[data-event] { color: var(--accent); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
a[data-event]::before { content: "◷ "; font-size: .85em; font-weight: 400; }

/* Sign in */
.signin-note { font-size: .82rem; margin: 6px 0 0; }
#signin-code { font-size: 1.4rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.danger-fill { background: var(--danger); color: #fff; }
