:root {
  --bg: #ffffff;
  --bg-side: #f7f7f5;
  --bg-hover: rgba(55, 53, 47, 0.08);
  --bg-active: rgba(55, 53, 47, 0.12);
  --bg-code: #f6f5f4;
  --text: #37352f;
  --muted: #787774;
  --faint: #b4b3b0;
  --border: rgba(55, 53, 47, 0.12);
  --accent: #2383e2;
  --danger: #e03e3e;
  --ok: #0f7b6c;
  --shadow: 0 8px 28px rgba(15, 15, 15, 0.12), 0 0 0 1px rgba(15, 15, 15, 0.06);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --bg-side: #202020;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-active: rgba(255, 255, 255, 0.1);
    --bg-code: #262626;
    --text: #e6e6e4;
    --muted: #9b9a97;
    --faint: #5a5a58;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #529cca;
    --danger: #ff6b6b;
    --ok: #4dab9a;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, select, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 4px 12px; margin: 0; }

/* Layout */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: var(--side-w, 260px);
  flex: none;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  font-size: 14px;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Drag strip on the sidebar's right edge; a blue line shows while hovered or dragged. */
.side-resize { flex: none; width: 7px; margin: 0 -4px 0 -3px; position: relative; z-index: 10; cursor: col-resize; touch-action: none; }
.side-resize::after { content: ''; position: absolute; inset: 0 2px; border-radius: 2px; transition: background 0.15s; }
.side-resize:hover::after, .side-resize.dragging::after, .side-resize:focus-visible::after { background: var(--accent); }
.side-resize:focus-visible { outline: none; }
body.side-resizing { cursor: col-resize; user-select: none; }
.topbar { display: none; }
.side-close { color: var(--muted); opacity: 0; transition: opacity .15s; font-size: 16px; width: 26px; height: 26px; }
.sidebar:hover .side-close, .side-close:focus-visible { opacity: 1; }
@media (hover: none) { .side-close { opacity: 1; } }
@media (min-width: 761px) {
  body.side-collapsed .sidebar, body.side-collapsed .side-resize { display: none; }
  body.side-collapsed .topbar { display: flex; position: absolute; top: 4px; left: 6px; z-index: 5; }
  body.side-collapsed .nav-toggle { width: 36px; height: 36px; font-size: 18px; color: var(--muted); background: var(--bg); }
  body.side-collapsed .page-top { padding-left: 48px; }
}
.editor { flex: 1; overflow-y: auto; position: relative; }
.scrim { display: none; }

/* Sidebar */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.workspace { font: inherit; font-weight: 600; color: var(--text); border: 0; background: none; padding: 4px 6px; margin: -4px -6px; border-radius: 6px; cursor: pointer; }
.workspace:hover { background: var(--bg-hover); }
.workspace .caret { font-size: 11px; color: var(--muted); }
/* Find in page (Ctrl+F) */
.main { position: relative; }
.find-bar { position: absolute; top: 48px; right: 18px; z-index: 30; display: flex; align-items: center; gap: 4px; padding: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.find-bar .input { width: 200px; padding: 4px 8px; }
.find-count { min-width: 56px; text-align: center; }
::highlight(find) { background: rgba(255, 212, 0, .45); }
::highlight(find-current) { background: rgb(255, 150, 0); color: #000; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg-active); color: var(--muted); }
.side-actions { display: flex; flex-direction: column; gap: 2px; padding: 4px 6px; }
.side-btn {
  border: 0;
  background: none;
  text-align: left;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.side-btn:hover { background: var(--bg-hover); color: var(--text); }
/* Line icons in the text colour, like Notion's sidebar. */
.side-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.side-btn .kbd { margin-left: auto; }
summary.side-btn { font-weight: 400; font-size: 14px; color: var(--text); padding: 5px 8px; margin: 6px 6px 0; }
.side-btn.primary { color: var(--text); font-weight: 500; }
.side-label { font-size: 12px; font-weight: 600; color: var(--muted); padding: 14px 14px 4px; cursor: default; }
summary.side-label { cursor: pointer; list-style: none; }
summary.side-label::-webkit-details-marker { display: none; }
.tree { padding: 0 6px; }
.tree-row { display: flex; align-items: center; gap: 2px; border-radius: 6px; min-height: 30px; padding-right: 4px; }
.tree-row:hover { background: var(--bg-hover); }
.tree-row.active { background: var(--bg-active); font-weight: 500; }
.tree-link { flex: 1; min-width: 0; padding: 4px 2px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-toggle, .tree-btn {
  border: 0;
  background: none;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  flex: none;
  line-height: 1;
}
.tree-toggle.leaf { cursor: default; font-size: 10px; color: var(--faint); }
.tree-btn { opacity: 0; }
.tree-row:hover .tree-btn, .tree-btn.show, .tree-btn:focus-visible { opacity: 1; }
/* Section header with its own actions on hover, like Notion's "Private  +" */
.side-label-row { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; }
.side-label-row:hover .tree-btn, .side-label-row .tree-btn:focus-visible { opacity: 1; }
.side-label-row .tree-btn { font-size: 17px; }
/* Small dark tooltip shown at once on hover */
[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); background: #2f2f2f; color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; padding: 3px 8px; border-radius: 5px; pointer-events: none; z-index: 50; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.tree-toggle:not(.leaf):hover, .tree-btn:hover { background: var(--bg-active); color: var(--text); }
.tree-btn.danger:hover { color: var(--danger); }
.trash { padding: 0 6px; }
.trash .side-label { padding-left: 8px; }
.trash-foot { display: flex; align-items: center; gap: 6px; padding: 4px 6px 8px; flex-wrap: wrap; }
.side-foot { margin-top: auto; padding: 8px 6px 12px; border-top: 1px solid var(--border); }

/* Page */
.page { max-width: 760px; margin: 0 auto; padding: 48px 56px 30vh; }
.page-header { margin-bottom: 8px; }
.breadcrumb { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 28px; min-height: 20px; }
.crumb { text-decoration: none; padding: 0 4px; border-radius: 4px; }
.crumb:hover { background: var(--bg-hover); }
.crumb-sep { color: var(--faint); }
.page-icon { font-size: 56px; line-height: 1.1; margin-bottom: 8px; border: 0; background: none; padding: 0 4px; border-radius: 8px; cursor: pointer; color: inherit; }
.page-icon:hover { background: var(--bg-hover); }
.page-icon[hidden], .page-adds [hidden] { display: none; }
.page-adds { display: flex; gap: 4px; margin-bottom: 8px; opacity: 0; transition: opacity .15s; }
.page-adds .btn { color: var(--muted); }
.page-header:hover .page-adds, .page-adds:focus-within { opacity: 1; }
@media (hover: none) { .page-adds { opacity: 1; } }
.page-cover { height: 30vh; min-height: 140px; max-height: 280px; position: relative; background-size: cover; background-repeat: no-repeat; }
.page-cover[hidden] { display: none; }
.page-cover.repositioning { cursor: ns-resize; }
.cover-actions { position: absolute; right: 16px; bottom: 12px; display: flex; opacity: 0; transition: opacity .15s; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.page-cover:hover .cover-actions, .page-cover.repositioning .cover-actions, .cover-actions:focus-within { opacity: 1; }
@media (hover: none) { .cover-actions { opacity: 1; } }
.cover-actions button { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 5px 10px; cursor: pointer; }
.cover-actions button + button { border-left: 1px solid var(--border); }
.cover-actions button:hover { background: var(--bg-hover); color: var(--text); }
.popover { position: fixed; z-index: 60; width: 340px; max-width: calc(100vw - 16px); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; }
.cover-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-bottom: 4px; }
.cover-swatch { height: 40px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 0; }
.cover-swatch:hover { outline: 2px solid var(--muted); }
.emoji-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.emoji-search { flex: 1; min-width: 0; }
.emoji-grid { max-height: 300px; overflow-y: auto; color: var(--muted); font-size: 13px; }
.emoji-group { font-size: 12px; color: var(--muted); padding: 6px 2px 2px; }
.emoji-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
.emoji-cell { border: 0; background: none; font-size: 22px; height: 34px; border-radius: 6px; cursor: pointer; padding: 0; }
.emoji-cell:hover { background: var(--bg-hover); }
.text.page-title { font-size: 40px; line-height: 1.2; font-weight: 700; margin: 0 0 16px; }
.page-end { min-height: 120px; cursor: text; }
.empty-state { max-width: 480px; margin: 20vh auto; text-align: center; color: var(--muted); }

/* Blocks */
.block { position: relative; }
.row { display: flex; align-items: flex-start; border-radius: 4px; }
.gutter {
  width: 46px;
  margin-left: -50px;
  display: flex;
  justify-content: flex-end;
  gap: 1px;
  opacity: 0;
  padding-top: 3px;
  flex: none;
}
.row:hover > .gutter, .gutter:focus-within { opacity: 1; }
.icon-btn {
  border: 0;
  background: none;
  color: var(--faint);
  width: 22px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 15px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--muted); }
.icon-btn svg { display: block; margin: auto; pointer-events: none; }
.handle { cursor: grab; width: 18px; }
.body { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 6px; padding: 2px 0; }
.text {
  flex: 1;
  min-width: 0;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1px 2px;
  min-height: 1.5em;
  margin: 0;
  font: inherit;
}
.text:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }
.type-text .text:empty:not(:focus)::before { content: none; }
.page-title:empty::before { content: attr(data-placeholder); color: var(--faint); }
h2.text { font-size: 30px; font-weight: 700; line-height: 1.3; margin-top: 18px; }
h3.text { font-size: 24px; font-weight: 600; line-height: 1.3; margin-top: 12px; }
h4.text { font-size: 20px; font-weight: 600; line-height: 1.3; margin-top: 8px; }
.marker { width: 22px; flex: none; text-align: center; padding-top: 1px; }
.marker.num { text-align: right; padding-right: 2px; }
.check { width: 16px; height: 16px; margin: 5px 4px 0 3px; flex: none; accent-color: var(--accent); cursor: pointer; }
.checked .text { color: var(--muted); text-decoration: line-through; }
.has-bar > .row .body { border-left: 3px solid currentColor; padding-left: 14px; margin: 4px 0; }
.type-quote .text { font-size: 18px; }
textarea.code {
  resize: none;
  overflow: hidden;
  background: var(--bg-code);
  border: 0;
  border-radius: 6px;
  padding: 14px 16px;
  font: 14px/1.6 var(--mono);
  tab-size: 2;
  margin: 4px 0;
}
.type-divider hr { flex: 1; border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.page-link { display: flex; gap: 6px; align-items: center; text-decoration: none; padding: 2px 4px; border-radius: 4px; font-weight: 500; }
.page-link:hover { background: var(--bg-hover); }
.page-link-title { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.children { padding-left: 26px; }
.dragging { opacity: 0.4; }
.block.playing > .row { position: relative; background: rgba(35, 131, 226, 0.13); box-shadow: -10px 0 0 rgba(35, 131, 226, 0.13); }
/* The bar sits 10px left of the text instead of touching it. */
.block.playing > .row::before { content: ''; position: absolute; left: -10px; top: 0; bottom: 0; width: 3px; border-radius: 2px; background: var(--accent); }
.block.moment > .row { position: relative; background: rgba(255, 200, 0, 0.16); box-shadow: -10px 0 0 rgba(255, 200, 0, 0.16); }
/* The star sits at the right end, clear of the + and drag handle on the left. */
.block.moment > .row { padding-right: 24px; }
.block.moment > .row::after { content: '★'; position: absolute; right: 6px; top: 3px; color: #e0a800; font-size: 13px; pointer-events: none; }
.block.flash > .row { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 30% { background: rgba(255, 200, 0, 0.35); } 100% { background: transparent; } }
.page-actions { display: flex; gap: 4px; }
.fav-star .ico { margin-right: 0; }
.fav-star.on { color: #e3a008; }
.fav-star.on .ico { fill: currentColor; }
.fav-row { padding-left: 8px; }
.kbd { margin-left: auto; font-size: 11px; color: var(--faint); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
/* Search looks like a search field: a box with the shortcut on the right. */
#btn-search { border: 1px solid var(--border); background: var(--bg); color: var(--muted); margin: 2px 0 6px; padding: 6px 8px; }
#btn-search:hover { border-color: var(--faint); color: var(--text); }
.search-dialog { width: min(640px, calc(100vw - 32px)); margin-top: 12vh; }
.search-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.search-input { font-size: 16px; padding: 10px 12px; }
.search-results { display: flex; flex-direction: column; max-height: 52vh; overflow-y: auto; }
.search-result { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.search-result.active { background: var(--bg-hover); }
.search-page { font-weight: 600; font-size: 14px; }
.search-line { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
mark { background: rgba(255, 200, 0, 0.45); color: inherit; border-radius: 2px; }
.editor:focus { outline: none; }
.block.selected > .row, .block.selected .row { background: rgba(35, 131, 226, 0.16); }
.editor.has-selection .text { caret-color: transparent; }
.editor.block-dragging, .editor.block-dragging * { user-select: none; }
.text b { font-weight: 600; }
.text a { color: inherit; text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 2px; cursor: text; }
.fmt-bar { position: fixed; z-index: 60; display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--bg); border-radius: 7px; box-shadow: var(--shadow); font-size: 14px; }
.fmt-btn { display: inline-flex; align-items: center; gap: 5px; min-width: 28px; height: 28px; padding: 0 7px; border: 0; border-radius: 5px; background: none; color: var(--text); cursor: pointer; }
.fmt-btn:hover { background: var(--bg-hover); }
.fmt-btn.on { color: var(--accent); background: var(--bg-active); }
.fmt-btn svg { width: 15px; height: 15px; }
.fmt-b { font-weight: 700; }
.fmt-i { font-style: italic; font-family: Georgia, serif; }
.fmt-url { max-width: 260px; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.fmt-input { width: 280px; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); font: inherit; outline: none; }
.ts { color: var(--accent); cursor: pointer; font-variant-numeric: tabular-nums; border-radius: 4px; user-select: none; }
.ts:hover { background: var(--bg-hover); text-decoration: underline; }
.editor.file-over { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--bg-hover); }
.audio-block video { width: 100%; max-height: 360px; border-radius: 6px; background: #000; }
/* Mini player: a playing video docks bottom-right while its place is scrolled away. */
.media-slot { position: relative; }
.mini-on > video { position: fixed; right: 16px; bottom: 16px; width: 360px; max-width: calc(100vw - 32px); max-height: none; z-index: 40; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.mini-bar { position: fixed; right: 20px; bottom: 16px; z-index: 41; display: flex; gap: 4px; }
.mini-btn { width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; }
.mini-btn:hover { background: rgba(0,0,0,.85); }
.drop-marker { position: absolute; height: 3px; background: var(--accent); border-radius: 2px; opacity: 0.7; pointer-events: none; }

/* Audio block */
.audio-block { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 4px 0; display: flex; flex-direction: column; gap: 10px; }
.audio-head { display: flex; gap: 8px; align-items: center; }
/* Long file names (no spaces) wrap instead of widening the box. */
.audio-title { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.audio-block audio { width: 100%; height: 40px; }
.media-note { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audio-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audio-block p { margin: 0; }

/* Buttons and fields */
.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.1); background: var(--danger); }
.select { border: 1px solid var(--border); background: var(--bg); border-radius: 6px; padding: 5px 8px; max-width: 100%; }
.select.small { font-size: 13px; padding: 3px 6px; }

/* Menus */
.menu {
  position: fixed;
  z-index: 50;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  font-size: 14px;
}
.menu-title { font-size: 12px; color: var(--muted); padding: 4px 8px 6px; }
.menu-empty { color: var(--muted); padding: 6px 8px; }
.menu-item { display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 5px 8px; border-radius: 5px; cursor: pointer; text-align: left; }
.menu-item.active { background: var(--bg-hover); }
.menu-item.danger { color: var(--danger); }
.menu-icon { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; flex: none; }
.menu-label { flex: 1; }
.menu-hint { color: var(--muted); font-size: 12px; }

/* Ask AI panel (js/ask-ai.js) */
.fmt-ai { color: var(--accent); font-weight: 600; }
.ai-panel {
  position: fixed;
  z-index: 60;
  width: min(520px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.ai-input { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; outline: none; }
.ai-input:focus { border-color: var(--accent); }
.ai-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.ai-preset { border: 1px solid var(--border); border-radius: 999px; background: none; color: var(--text); padding: 3px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.ai-preset:hover:not(:disabled) { background: var(--bg-hover); }
.ai-preset:disabled { color: var(--faint); cursor: default; }
.ai-answer { max-height: 260px; overflow-y: auto; white-space: pre-wrap; padding: 8px 10px; border-radius: 6px; background: var(--bg-hover); line-height: 1.5; }
.ai-status { min-height: 16px; font-size: 12px; color: var(--muted); }
.ai-status.error { color: var(--danger); }
.ai-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ai-actions:empty { display: none; }
@media (max-width: 520px) { .ai-panel { left: 8px !important; right: 8px; width: auto; } }

/* AI Chat side panel (js/ai-chat.js) */
.ai-chat {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  box-sizing: border-box;
  width: 380px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.ai-chat[hidden] { display: none; }
.ai-chat-top { display: flex; align-items: center; gap: 6px; }
.ai-chat-title { flex: 1; margin: 0; font-size: 16px; font-weight: 600; }
.ai-chat-close { width: 26px; height: 26px; font-size: 14px; }
.ai-chat-scope { display: flex; gap: 4px; padding: 3px; background: var(--bg-hover); border-radius: 7px; }
.ai-chat-seg { flex: 1; border: 0; background: none; color: var(--muted); padding: 4px 8px; border-radius: 5px; font: inherit; font-size: 13px; cursor: pointer; }
.ai-chat-seg.active { background: var(--bg); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.ai-chat-seg:disabled { color: var(--faint); cursor: default; }
.ai-chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; }
.ai-chat-empty { margin: auto; color: var(--muted); text-align: center; }
.ai-chat-msg.user { align-self: flex-end; max-width: 85%; padding: 7px 10px; border-radius: 10px; background: var(--bg-hover); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-chat-msg.assistant { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ai-chat-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.ai-chat-sources { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.ai-chat-sources-title { font-weight: 600; }
.ai-chat-source { border: 0; background: none; padding: 3px 4px; border-radius: 4px; color: inherit; font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.ai-chat-source:hover { background: var(--bg-hover); color: var(--text); }
.ai-chat-src-n { color: var(--accent); font-weight: 600; }
.ai-chat-time { color: var(--accent); font-variant-numeric: tabular-nums; }
.ai-chat-actions { display: flex; gap: 6px; }
.ai-chat-status { min-height: 16px; font-size: 12px; color: var(--muted); }
.ai-chat-status.error { color: var(--danger); }
.ai-chat-compose { display: flex; align-items: flex-end; gap: 6px; }
.ai-chat-input { flex: 1; min-width: 0; box-sizing: border-box; resize: none; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; line-height: 1.4; outline: none; }
.ai-chat-input:focus { border-color: var(--accent); }
.ai-chat-send { flex: none; }
@media (max-width: 700px) { .ai-chat { width: 100%; } }

/* Recorder bar */
.recbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 8px 10px 8px 16px;
  width: min(720px, calc(100vw - 32px));
  font-size: 14px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; flex: none; }
@keyframes pulse { 50% { opacity: 0.3; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-meter { width: 60px; height: 6px; background: var(--bg-active); border-radius: 3px; overflow: hidden; flex: none; }
.rec-meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.1s; }
.rec-mode { color: var(--muted); white-space: nowrap; font-size: 13px; }
.rec-caption { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-style: italic; }
body.recording .page { padding-bottom: 40vh; }
.rec-lines { display: none; }

/* Pop-out caption window (Document Picture-in-Picture) */
body.pip { background: var(--bg); color: var(--text); margin: 0; font: 14px/1.45 var(--font); }
body.pip .recbar { position: static; transform: none; width: 100%; height: 100vh; border-radius: 0; box-shadow: none; flex-wrap: wrap; align-content: flex-start; padding: 10px 12px; }
body.pip .rec-caption { order: 9; flex-basis: 100%; white-space: normal; }
body.pip .rec-lines { display: block; order: 8; flex-basis: 100%; overflow-y: auto; max-height: calc(100vh - 80px); }
.rec-lines p { margin: 0 0 4px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.1); }
.page-top { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; background: var(--bg); }
.page-top .breadcrumb { flex: 1; min-width: 0; flex-wrap: nowrap; overflow: hidden; margin-bottom: 0; }
.page-top .crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.page-top .crumb:last-child { color: var(--text); flex-shrink: 1; }
.page-actions { flex: none; align-items: center; }
.crumb-more { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.page-edited { flex: none; font-size: 13px; color: var(--muted); white-space: nowrap; }
.page-actions .page-more { font-size: 18px; line-height: 1; padding: 2px 8px; letter-spacing: 1px; }
.key-row { display: flex; gap: 6px; }
.key-row .input { flex: 1; min-width: 0; }
.key-mask { -webkit-text-security: disc; }
.key-mask.reveal { -webkit-text-security: none; }
.help.warn { color: var(--danger); }
.input { border: 1px solid var(--border); background: var(--bg); border-radius: 6px; padding: 6px 8px; color: var(--text); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 3px; }
.seg label { flex: 1; text-align: center; border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--bg-active); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.preset span { font-size: 12px; color: var(--muted); }
.preset small { font-size: 11px; color: var(--muted); opacity: .75; }
.preset:hover { background: var(--bg-hover); }
.preset.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
/* Settings: sidebar navigation + one panel at a time */
#settings.dialog { width: min(920px, calc(100vw - 32px)); height: min(660px, calc(100vh - 48px)); height: min(660px, calc(100dvh - 48px)); max-width: none; max-height: none; }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100%; }
.settings-nav { background: var(--bg-side); border-right: 1px solid var(--border); padding: 14px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.settings-nav-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px 8px; }
.settings-tab { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.settings-tab:hover { background: var(--bg-hover); color: var(--text); }
.settings-tab.active { background: var(--bg-active); color: var(--text); font-weight: 600; }
.settings-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.settings-content { position: relative; overflow-y: auto; padding: 32px 40px; }
.settings-panel { display: flex; flex-direction: column; gap: 14px; max-width: 640px; min-width: 0; }
.settings-panel .select, .settings-panel .input { width: 100%; min-width: 0; text-overflow: ellipsis; }
.settings-panel h2 { margin: 0; font-size: 24px; }
.panel-sub { margin: -6px 0 4px; color: var(--muted); font-size: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.settings-x { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; font-size: 14px; }
@media (max-width: 640px) {
  #settings.dialog { width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0; inset: 0; border-radius: 0; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 44px 8px 8px; }
  .settings-nav-title { display: none; }
  .settings-tab { white-space: nowrap; flex: none; }
  .settings-content { padding: 20px 16px; }
}
code { font-family: var(--mono); font-size: 12px; background: var(--bg-hover); padding: 1px 4px; border-radius: 4px; }
@media (max-width: 520px) { .presets { grid-template-columns: 1fr; } .find-bar { left: 8px; right: 8px; } .find-bar .input { flex: 1; width: auto; min-width: 0; } }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }

/* Dialog */
.dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: var(--shadow); background: var(--bg); color: var(--text); width: min(520px, calc(100vw - 32px)); }
/* Page history */
.history-dialog { width: min(920px, calc(100vw - 32px)); }
.history-layout { display: flex; height: min(640px, calc(100vh - 80px)); }
.history-side { width: 240px; flex: none; border-right: 1px solid var(--border); padding: 18px 10px 10px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.history-side h2 { padding: 0 8px; }
.history-side .help { padding: 0 8px; margin: 0; }
.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.history-item { border: 0; background: none; color: var(--text); text-align: left; padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; font: inherit; font-size: 14px; }
.history-item:hover { background: var(--bg-hover); }
.history-item.active { background: var(--bg-active); }
.history-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-preview { flex: 1; overflow-y: auto; padding: 20px 24px; user-select: text; line-height: 1.6; white-space: pre-wrap; }
.history-main .row-btns { padding: 12px 16px; border-top: 1px solid var(--border); align-items: center; }
.history-tip { margin: 0 auto 0 0; }
.history-title { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.h-header { font-size: 20px; font-weight: 600; margin-top: 10px; }
.h-sub_header, .h-tab { font-size: 17px; font-weight: 600; margin-top: 8px; }
.h-sub_sub_header { font-weight: 600; }
.h-quote { border-left: 3px solid var(--border); padding-left: 10px; }
@media (max-width: 640px) {
  .history-layout { flex-direction: column; height: calc(100vh - 60px); height: calc(100dvh - 60px); }
  .history-side { width: auto; max-height: 34%; border-right: 0; border-bottom: 1px solid var(--border); }
  .history-tip { display: none; }
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { margin: 0; font-size: 20px; }
.dialog h3 { margin: 10px 0 0; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field .select { color: var(--text); font-size: 14px; }
.help { margin: 0; font-size: 13px; color: var(--muted); }
.status { margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--bg-hover); font-size: 13px; }
.status.ok { color: var(--ok); }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
/* Voice memo upload (recorder.js uploadProgress, memos.js paintMemoProgress). */
.memo-progress { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 4px 0 8px; }
.memo-progress progress { height: 6px; appearance: none; -webkit-appearance: none; border: none; border-radius: 3px; background: var(--bg-hover); overflow: hidden; }
.memo-progress progress::-webkit-progress-bar { background: var(--bg-hover); border-radius: 3px; }
.memo-progress progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
.memo-progress progress::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
.memo-progress progress[hidden] { display: none; }
.memo-progress .memo-progress-text { margin: 0; }
.memo-progress .memo-retry[hidden] { display: none; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns.end { justify-content: flex-end; }

/* Toasts */
.toasts { position: fixed; top: 52px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); }
.toast { touch-action: pan-y; user-select: none; cursor: grab; transition: opacity 0.15s; }
.toast-close { border: 0; background: none; color: inherit; opacity: 0.6; cursor: pointer; padding: 2px 4px; margin-left: auto; font-size: 13px; line-height: 1; }
.toast-close:hover { opacity: 1; }
.toast-action { border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; }

/* Phone / narrow */
@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(280px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  body.nav-open .sidebar { transform: none; }
  .side-resize { display: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.3); }
  /* ☰ floats in the corner instead of taking a row of its own. */
  .main { position: relative; }
  .topbar { display: flex; position: absolute; top: 6px; left: 4px; z-index: 5; }
  .nav-toggle { width: 36px; height: 36px; font-size: 20px; color: var(--muted); background: var(--bg); }
  .page { padding: 12px 14px 30vh 28px; }
  .page-top { padding-left: 46px; }
  /* Phone: only the current page in the breadcrumb, icon-only actions. */
  .page-top .crumb:not(:last-child), .page-top .crumb-sep { display: none; }
  .page-top .crumb:last-child { max-width: none; }
  .page-edited { display: none; }
  .page-actions .btn { padding: 4px 8px; }
  .page-icon { font-size: 44px; }
  .text.page-title { font-size: 28px; }
  h2.text { font-size: 24px; }
  h3.text { font-size: 20px; }
  h4.text { font-size: 18px; }
  .children { padding-left: 18px; }
  /* Handles only on the block being edited, not on every line. */
  .gutter { width: 22px; margin-left: -26px; }
  .row:focus-within > .gutter { opacity: 1; }
  .gutter .add { display: none; }
  .tree-btn { opacity: 1; }
  .recbar { flex-wrap: wrap; gap: 8px; bottom: 10px; }
  .rec-caption { order: 5; flex-basis: 100%; }
}

/* ---- Meeting block: recording + Summary / Notes / Transcript tabs ---- */
.block.type-meeting { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 10px; margin: 8px 0; }
.block.type-meeting { display: flex; flex-direction: column; }
/* Order inside a meeting: recording, then the tab bar, then the open tab. */
.block.type-meeting > .children { display: contents; }
.block.type-meeting > .children > .type-audio { order: 1; }
.block.type-meeting > .row { order: 2; margin-top: 6px; }
.block.type-meeting > .children > .type-tab { order: 3; }
.meeting-tabs { display: flex; gap: 2px; flex-wrap: wrap; width: 100%; border-bottom: 1px solid var(--border); }
.meeting-tab { display: inline-flex; align-items: center; gap: 6px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 6px 6px 0 0; cursor: pointer; }
.meeting-tab:hover { background: var(--bg-hover); color: var(--text); }
.meeting-tab[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab-count { font-size: 12px; color: var(--faint); font-weight: 400; }
.block.type-tab > .row { display: none; }
.block.type-tab.empty > .row { display: flex; }
.block.type-tab > .row > .gutter { visibility: hidden; }
.block.type-tab > .children { padding-left: 0; }
.tab-empty { color: var(--muted); padding: 10px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tab-empty p { margin: 0; }
.cites { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: 2px; user-select: none; }
.cite { min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-hover); color: var(--muted); font-size: 11px; line-height: 16px; cursor: pointer; font-variant-numeric: tabular-nums; }
.cite:hover { color: var(--accent); border-color: var(--accent); }
/* + and ⋮⋮ of the meeting, its recording and its tabs' top blocks sit outside its border, in line with other blocks' gutters. */
.block.type-meeting > .row > .gutter,
.block.type-meeting > .children > .block > .row > .gutter,
.block.type-tab > .children > .block > .row > .gutter { margin-left: -63px; margin-right: 17px; }
@media (max-width: 760px) {
  .block.type-meeting { padding: 6px 8px 8px; }
  .block.type-meeting > .row > .gutter,
  .block.type-meeting > .children > .block > .row > .gutter,
  .block.type-tab > .children > .block > .row > .gutter { margin-left: -35px; margin-right: 13px; }
  .meeting-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .meeting-tab { padding: 8px 9px; gap: 4px; white-space: nowrap; }
  .audio-block { padding: 10px; }
}
/* Room below a short tab, so switching tabs never has to scroll the page up. */
.block.type-meeting > .children > .type-tab { min-height: 70vh; }

/* Summary being made: spinner and progress in the Summary tab. */
.block.type-tab.busy > .row { display: flex; }
.block.type-tab.busy > .row > .body { align-items: center; gap: 10px; color: var(--muted); padding: 10px 0; }
.busy-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.busy-text { font-size: 14px; }
.busy-meter { position: relative; display: flex; align-items: center; padding: 4px 0; cursor: default; }
.busy-bar { height: 6px; }
.busy-pct { position: absolute; bottom: 100%; transform: translateX(-50%); padding: 1px 6px; border-radius: 4px; background: var(--text); color: var(--bg); font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0; pointer-events: none; transition: opacity 0.1s; }
.busy-meter:hover .busy-pct { opacity: 1; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Line icons (js/icons.js) inside buttons, tabs and menus. */
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; margin-right: 6px; }
.menu-icon .ico, .tab-icon .ico, .audio-icon .ico { margin-right: 0; }
.audio-icon .ico { width: 20px; height: 20px; }
.settings-tab .ico { width: 18px; height: 18px; margin-right: 4px; }

/* Home dashboard (#/) */
.home { flex: 1; overflow-y: auto; }
.home-wrap { max-width: 960px; margin: 0 auto; padding: 48px 56px 64px; display: flex; flex-direction: column; gap: 24px; }
.home-title { margin: 0; font-size: 32px; line-height: 1.2; }
.home-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.home-action { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; }
.home-action .ico { width: 18px; height: 18px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.home-section { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.home-h { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.home-empty { margin: 0; }
.home-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.home-link { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; padding: 2px 0; }
.home-link:hover, .home-todo-title:hover { text-decoration: underline; }
.home-meta { flex: none; white-space: nowrap; }
.home-meeting { padding: 4px 0; }
.home-meeting + .home-meeting { border-top: 1px solid var(--border); padding-top: 8px; }
.home-preview { margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.home-todo { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; cursor: pointer; }
.home-todo input { margin-top: 5px; flex: none; }
.home-todo-text { display: flex; flex-direction: column; min-width: 0; }
.home-todo-title { text-decoration: none; overflow-wrap: anywhere; }
.home-favs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.home-fav { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; min-width: 0; }
.home-fav:hover { background: var(--bg-hover); }
.home-fav-icon { font-size: 22px; line-height: 1; }
.home-fav-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.home-warn { color: var(--danger); }
.side-btn.active { background: var(--bg-active); }
a.side-btn { text-decoration: none; }
@media (max-width: 760px) {
  .home-wrap { padding: 16px 16px 48px; gap: 18px; }
  .home-title { font-size: 26px; padding-left: 30px; }
  .home-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-action { justify-content: flex-start; min-width: 0; padding: 8px 10px; gap: 6px; font-size: 13px; }
  .home-action span, .home-action { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Template picker on an empty page */
.template-picker { margin: 4px 0 8px; }
.template-label { color: var(--faint); font-size: 14px; margin-bottom: 8px; }
.template-list { display: flex; flex-wrap: wrap; gap: 6px; }
.template-chip { border: 1px solid var(--border); background: none; color: var(--muted); border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 14px; cursor: pointer; }
.template-chip:hover { background: var(--bg-hover); color: var(--text); }
.template-chip.mine { color: var(--text); }

/* Toggle */
.toggle-arrow { border: 0; background: none; color: var(--muted); width: 22px; height: 24px; flex: none; cursor: pointer; border-radius: 4px; padding: 0; font-size: 13px; transition: transform 0.12s; }
.toggle-arrow:hover { background: var(--bg-hover); }
.toggle-arrow.open { transform: rotate(90deg); }

/* Callout */
.block.type-callout { background: var(--bg-code); border-radius: 6px; padding: 10px 12px 10px 6px; margin: 4px 0; }
.callout-icon { border: 0; background: none; font-size: 18px; line-height: 1.3; width: 26px; flex: none; cursor: pointer; border-radius: 4px; padding: 0; }
.callout-icon:hover { background: var(--bg-hover); }
.block.type-callout > .children { padding-left: 32px; }

/* Columns */
.block.type-column_list > .row { height: 0; overflow: visible; }
.block.type-column_list > .row > .body { display: none; }
.block.type-column_list > .children { display: flex; gap: 32px; padding-left: 0; }
.block.type-column { flex: 1; min-width: 0; }
.block.type-column > .row { display: none; }
.block.type-column:not(:has(> .children)) > .row { display: flex; }
.block.type-column > .row > .gutter { visibility: hidden; }
.block.type-column > .children { padding-left: 0; }
.col-empty { border: 1px dashed var(--border); background: none; color: var(--faint); border-radius: 6px; padding: 8px; width: 100%; text-align: left; font: inherit; font-size: 14px; cursor: text; }
@media (max-width: 640px) {
  .block.type-column_list > .children { flex-direction: column; gap: 0; }
}

/* Simple table */
.table-wrap { flex: 1; min-width: 0; overflow-x: auto; margin: 4px 0; }
.simple-table { border-collapse: collapse; font-size: 14px; }
.simple-table td { border: 1px solid var(--border); padding: 6px 8px; min-width: 110px; vertical-align: top; outline: none; white-space: pre-wrap; word-break: break-word; }
.simple-table td:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.simple-table.has-header tr:first-child td { background: var(--bg-code); font-weight: 600; }
.table-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; opacity: 0; transition: opacity 0.12s; }
.block.type-table:hover .table-tools, .block.type-table:focus-within .table-tools { opacity: 1; }
@media (hover: none) { .table-tools { opacity: 1; } }

/* Image */
.image-block { max-width: 100%; border-radius: 4px; display: block; margin: 4px 0; }

/* Backlinks */
.backlinks { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.backlinks-title { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.backlink { padding: 3px 4px; border-radius: 4px; text-decoration: none; }
.backlink:hover { background: var(--bg-hover); }
.text a.page-ref { cursor: pointer; }

/* Database */
.block.type-collection > .row > .body { display: block; }
.db { width: 100%; margin: 8px 0; font-size: 14px; }
.db-title { border: 0; background: none; color: var(--text); font: inherit; font-size: 20px; font-weight: 700; padding: 2px 0; width: 100%; outline: none; }
.db-title::placeholder { color: var(--faint); }
.db-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; border-bottom: 1px solid var(--border); margin: 4px 0 6px; padding-bottom: 4px; }
.db-tabs, .db-actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.db-tab { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.db-tab:hover { background: var(--bg-hover); }
.db-tab.on { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--text); border-radius: 0; }
.db-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.db-filter { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 14px; padding: 2px 4px 2px 10px; color: var(--accent); }
.db-filter.sort { color: var(--muted); }
.db-filter select, .db-filter input { border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; max-width: 140px; outline: none; }
.db-filter-name { font-weight: 500; }
.db-filter-mode { border: 1px solid var(--border); background: none; color: var(--muted); border-radius: 14px; padding: 2px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.db-scroll { overflow-x: auto; }
.db-table { border-collapse: collapse; width: max-content; min-width: 100%; }
.db-table th, .db-table td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: left; vertical-align: middle; padding: 0; min-width: 120px; max-width: 320px; }
.db-table th:last-child, .db-table td:last-child { border-right: 0; min-width: 36px; }
.db-table thead th { border-top: 1px solid var(--border); }
.db-th { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; padding: 6px 8px; width: 100%; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-th:hover { background: var(--bg-hover); }
.db-td { position: relative; }
.db-td.t-title { min-width: 200px; }
.db-input { border: 0; background: none; color: var(--text); font: inherit; padding: 6px 8px; width: 100%; outline: none; min-width: 0; }
.t-title .db-input { font-weight: 500; padding-right: 56px; }
.db-input:focus { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 2px; }
.db-row-btn { position: absolute; top: 50%; transform: translateY(-50%); border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: 12px; border-radius: 4px; padding: 1px 5px; cursor: pointer; opacity: 0; }
.db-row-btn:nth-of-type(1) { right: 30px; }
.db-row-btn:nth-of-type(2) { right: 4px; }
tr:hover .db-row-btn, .db-row-btn:focus { opacity: 1; }
@media (hover: none) { .db-row-btn { opacity: 1; } }
.db-check { margin: 6px 8px; width: 16px; height: 16px; accent-color: var(--accent); }
.db-select { border: 0; font: inherit; font-size: 13px; padding: 2px 6px; margin: 4px 6px; border-radius: 4px; color: var(--text); background: var(--bg-hover); max-width: calc(100% - 12px); }
.db-select.c-none { background: none; color: var(--faint); }
.db-multi { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 6px; align-items: center; }
.db-chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: 4px; font-size: 13px; white-space: nowrap; }
.db-chip-x { border: 0; background: none; color: inherit; opacity: 0.6; cursor: pointer; padding: 0 2px; font-size: 13px; }
.db-add { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 15px; padding: 0 4px; border-radius: 4px; }
.db-add:hover { background: var(--bg-hover); color: var(--muted); }
.db-ro { display: block; padding: 6px 8px; color: var(--muted); white-space: nowrap; }
.late { color: var(--danger) !important; font-weight: 600; }
.db-url { display: flex; align-items: center; }
.db-open { padding: 0 8px; text-decoration: none; color: var(--muted); }
.db-calc td { border-bottom: 0; }
.db-calc-btn { border: 0; background: none; color: transparent; font: inherit; font-size: 12px; padding: 4px 8px; width: 100%; text-align: right; cursor: pointer; }
.db:hover .db-calc-btn, .db-calc-btn.on { color: var(--muted); }
.db-new-row { border: 0; background: none; color: var(--faint); font: inherit; font-size: 14px; padding: 6px 8px; cursor: pointer; text-align: left; border-radius: 4px; }
.db-new-row:hover { background: var(--bg-hover); color: var(--muted); }
.db-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.db-col { flex: 0 0 240px; display: flex; flex-direction: column; gap: 6px; border-radius: 6px; padding: 4px; }
.db-col.over { background: var(--bg-hover); }
.db-col-head { display: flex; align-items: center; gap: 8px; padding: 4px; }
.db-count { color: var(--faint); font-size: 13px; }
.db-card { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; cursor: pointer; box-shadow: 0 1px 2px rgba(15, 15, 15, 0.06); display: flex; flex-direction: column; gap: 4px; }
.db-card:hover { background: var(--bg-hover); }
.db-card-title { font-weight: 500; }
.db-card-prop { display: flex; flex-wrap: wrap; gap: 4px; color: var(--muted); font-size: 13px; }
.db-empty { color: var(--muted); }
.db-ask { position: fixed; z-index: 60; background: var(--bg); box-shadow: var(--shadow); border-radius: 6px; padding: 6px; }
.db-ask input { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 4px; padding: 6px 8px; font: inherit; width: 240px; outline: none; }
.db-props { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.db-prop { display: flex; align-items: center; min-height: 34px; }
.db-prop-name { flex: 0 0 160px; color: var(--muted); }
.db-prop > :last-child { flex: 1; min-width: 0; }
.db-back { color: var(--muted); font-size: 13px; text-decoration: none; margin-bottom: 4px; }
.db-back:hover { color: var(--text); }
@media (max-width: 640px) { .db-prop-name { flex-basis: 110px; } }
/* Option colors, readable in light and dark */
.c-gray { background: rgba(120, 119, 116, 0.2); }
.c-brown { background: rgba(159, 107, 83, 0.22); }
.c-orange { background: rgba(217, 115, 13, 0.22); }
.c-yellow { background: rgba(203, 145, 47, 0.24); }
.c-green { background: rgba(68, 131, 97, 0.24); }
.c-blue { background: rgba(51, 126, 169, 0.24); }
.c-purple { background: rgba(144, 101, 176, 0.24); }
.c-pink { background: rgba(193, 76, 138, 0.22); }
.c-red { background: rgba(212, 76, 71, 0.22); }
.c-none { background: none; color: var(--faint); }
.db-card-prop > span:not(.db-chip) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Tracker summary numbers */
.db-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.db-stat { flex: 1 1 120px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.db-stat-n { font-size: 22px; font-weight: 700; line-height: 1.2; }
.db-stat-l { color: var(--muted); font-size: 12px; }
.db-stat.warn .db-stat-n { color: var(--danger); }

/* Habit grid */
.habit-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.habit-month { font-weight: 600; min-width: 130px; text-align: center; }
.habit-scroll { overflow-x: auto; }
.habit-grid { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.habit-grid th { font-weight: 500; color: var(--muted); text-align: center; min-width: 24px; padding: 2px 0; }
.habit-grid th.today, .habit-total.today { color: var(--accent); font-weight: 700; }
.habit-wd { display: block; font-size: 10px; color: var(--faint); }
.habit-name { position: sticky; left: 0; z-index: 1; background: var(--bg); text-align: left; min-width: 150px; max-width: 220px; padding: 0 8px 0 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-name a { text-decoration: none; }
.habit-name a:hover { text-decoration: underline; }
.habit-cell { padding: 0; }
.habit-cell button { display: block; width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 5px; background: none; cursor: pointer; padding: 0; }
.habit-cell button:hover { border-color: var(--accent); }
.habit-cell.on button { background: var(--ok); border-color: var(--ok); }
.habit-cell.on button::after { content: '✓'; color: #fff; font-size: 13px; line-height: 22px; }
.habit-cell.today button { box-shadow: 0 0 0 1.5px var(--accent); }
.habit-cell.future button { opacity: 0.45; }
.habit-sum { color: var(--muted); text-align: right; padding: 0 6px; white-space: nowrap; font-size: 13px; }
.habit-total { text-align: center; color: var(--muted); }
@media (max-width: 640px) { .habit-name { min-width: 110px; max-width: 130px; } }

/* Home: trackers */
.home-trackers { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.home-tracker { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; text-decoration: none; }
.home-tracker:hover { background: var(--bg-hover); }
.home-tracker-title { font-weight: 600; }
.home-tracker-nums { display: flex; flex-wrap: wrap; gap: 14px; }
.home-tracker-n { display: flex; flex-direction: column; }
.home-tracker-n b { font-size: 18px; }
.home-tracker-n.warn b { color: var(--danger); }
.side-label-row [data-tip]:hover::after { left: auto; right: 0; transform: none; } /* stays inside the sidebar */
/* Native dropdown lists take the select's background, which is see-through on
   database selects and filter chips; give the options solid theme colors. */
select option, select optgroup { background-color: var(--bg); color: var(--text); }
