/* Pages, the page tree, databases and popovers. Colours come from the theme tokens in style.css/themes.css. */

:root {
  /* Notion's palette: text and background per colour (light). Dark themes override below. */
  --c-default: var(--text); --c-default-bg: color-mix(in srgb, var(--text) 8%, transparent);
  --c-gray: #787774; --c-gray-bg: #f1f1ef;
  --c-brown: #9f6b53; --c-brown-bg: #f4eeee;
  --c-orange: #d9730d; --c-orange-bg: #fbecdd;
  --c-yellow: #cb912f; --c-yellow-bg: #fbf3db;
  --c-green: #448361; --c-green-bg: #edf3ec;
  --c-blue: #337ea9; --c-blue-bg: #e7f3f8;
  --c-purple: #9065b0; --c-purple-bg: #f6f3f9;
  --c-pink: #c14c8a; --c-pink-bg: #faf1f5;
  --c-red: #d44c47; --c-red-bg: #fdebec;
  --hover: color-mix(in srgb, var(--text) 6%, transparent);
  --shadow-pop: 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent), 0 3px 6px rgb(15 15 15 / .1), 0 9px 24px rgb(15 15 15 / .18);
}
:root[data-brand="terminal"], :root[data-brand="orbit"] {
  --c-gray: #9b9b9b; --c-gray-bg: #3a3a3a;
  --c-brown: #ba856f; --c-brown-bg: #4a3328;
  --c-orange: #e8823c; --c-orange-bg: #5c3b23;
  --c-yellow: #dfab4b; --c-yellow-bg: #56452a;
  --c-green: #5aa47b; --c-green-bg: #243d30;
  --c-blue: #5ba5d6; --c-blue-bg: #143a4e;
  --c-purple: #a983d0; --c-purple-bg: #3c2d49;
  --c-pink: #d76ea4; --c-pink-bg: #4e2c3c;
  --c-red: #e56d67; --c-red-bg: #522e2a;
}

/* ---------- Popovers and menus ---------- */
.popover {
  position: absolute; z-index: 60; background: var(--surface); color: var(--text); border-radius: 8px; box-shadow: var(--shadow-pop);
  max-height: min(70vh, 520px); overflow: auto; font-size: 14px;
}
:root[data-brand="orbit"] .popover { background: #16133b; }
.menu { padding: 4px; outline: none; }
.menu-search { width: calc(100% - 8px); margin: 4px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: none; border-radius: 6px; text-align: left; cursor: pointer; color: var(--text); font: inherit; }
.menu-item.active, .menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-item.selected { font-weight: 600; }
.menu-icon, .type-icon { display: inline-flex; justify-content: center; width: 20px; color: var(--muted); flex: none; font-size: 13px; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { color: var(--muted); font-size: 12px; }
.menu-check { color: var(--accent); }
.menu-divider { border-top: 1px solid var(--border); margin: 4px 6px; padding-top: 6px; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.menu-divider:empty { padding-top: 0; }

.value-editor { padding: 8px; display: grid; gap: 8px; }
.value-editor input, .value-editor textarea, .value-editor select, .rule-editor select, .rule-editor input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.value-editor textarea { resize: vertical; }
.value-actions { display: flex; justify-content: flex-end; gap: 6px; }
.date-editor label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.date-toggles { display: flex; gap: 12px; font-size: 13px; }
.date-toggles input { width: auto; }
.option-editor { padding: 0; }
.option-editor .menu-search { margin: 6px; width: calc(100% - 12px); }
.option-selected { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px 0; align-items: center; }
.option-selected:empty { display: none; }
.option-list { padding: 0 4px 4px; max-height: 300px; overflow: auto; }
.option-empty { padding: 4px 8px; }
.rule-editor { padding: 10px; display: grid; gap: 8px; }
.rule-editor label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.rule { display: grid; grid-template-columns: 56px 1fr 1fr 1fr 24px; gap: 6px; align-items: center; }
.rule-editor .rule:has(> select:nth-child(2):last-of-type) { grid-template-columns: 1fr 1fr 24px; }
.rule-op { font-size: 13px; color: var(--muted); }
.props-panel { padding: 6px; display: grid; gap: 2px; }
.props-row { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; }
.props-row:hover { background: var(--hover); }
.props-row input:not([type]) { flex: 1; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.props-name { flex: 1; text-align: left; color: var(--text); }
.props-row select { width: auto; padding: 3px; font-size: 12px; }
.chip-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 4px; line-height: 1; }
.chip-x:hover { color: var(--danger); }
.switch { position: relative; display: inline-block; width: 28px; height: 16px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(12px); }

/* Option chips in Notion's colours */
.chip { display: inline-flex; align-items: center; max-width: 100%; padding: 0 7px; border-radius: 4px; font-size: 13px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 1px 4px 1px 0; }
.chip.status { border-radius: 99px; padding-left: 6px; }
.chip.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 5px; opacity: .8; }
.chip.swatch { width: 16px; height: 16px; padding: 0; margin: 0; border: 1px solid color-mix(in srgb, var(--text) 15%, transparent); }
.c-default { background: var(--c-default-bg); color: var(--c-default); }
.c-gray { background: var(--c-gray-bg); color: var(--c-gray); }
.c-brown { background: var(--c-brown-bg); color: var(--c-brown); }
.c-orange { background: var(--c-orange-bg); color: var(--c-orange); }
.c-yellow { background: var(--c-yellow-bg); color: var(--c-yellow); }
.c-green { background: var(--c-green-bg); color: var(--c-green); }
.c-blue { background: var(--c-blue-bg); color: var(--c-blue); }
.c-purple { background: var(--c-purple-bg); color: var(--c-purple); }
.c-pink { background: var(--c-pink-bg); color: var(--c-pink); }
.c-red { background: var(--c-red-bg); color: var(--c-red); }

/* ---------- Emoji picker & icons ---------- */
.emoji-picker { padding: 8px; }
.emoji-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 4px 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.emoji-grid button { border: 0; background: none; font-size: 20px; padding: 3px; border-radius: 5px; cursor: pointer; line-height: 1.2; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-head { align-items: center; }
.icon-tabs { display: flex; gap: 2px; }
.icon-tabs button { border: 0; background: none; padding: 4px 8px; border-radius: 6px; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.icon-tabs button:hover { background: var(--hover); color: var(--text); }
.icon-tabs button.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 6px 6px 0 0; }
.icon-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 12px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 10px; font-size: 13px; transition: border-color .15s, background .15s;
}
.icon-drop:hover, .icon-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.icon-drop .muted { font-size: 12px; }
.icon-recent-label { font-size: 12px; margin: 10px 4px 4px; }
.icon-recent { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.icon-recent button { border: 0; background: none; padding: 4px; border-radius: 6px; cursor: pointer; aspect-ratio: 1; }
.icon-recent button:hover { background: var(--hover); }
.icon-recent img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.icon-link { display: flex; gap: 6px; padding: 8px 2px 2px; }
.icon-link input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.icon-link + .muted { margin: 6px 4px 0; }
.icon-error { color: var(--danger); font-size: 12.5px; margin: 8px 4px 0; }
.page-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.25em; flex: none; font-style: normal; }
img.page-icon { width: 1.1em; height: 1.1em; object-fit: cover; border-radius: 3px; }

/* ---------- Sidebar tree ---------- */
.tree-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tree-head button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 4px; }
.tree-head-actions { display: flex; gap: 2px; }
.tree-head button:disabled { opacity: .5; cursor: progress; }
.tree-head button:hover { background: var(--hover); color: var(--text); }
.tree { font-size: 14px; }
/* Recents and Favorites: tree rows without a caret, icons lined up with the top-level pages below. */
.quick { font-size: 14px; }
.quick .tree-row { padding-left: 24px; }
.quick-more { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 12.5px; padding: 3px 8px 3px 24px; border-radius: 6px; width: 100%; text-align: left; }
.quick-more:hover { background: var(--hover); color: var(--text); }
.quick-empty { color: var(--muted); font-size: 12.5px; margin: 0; padding: 2px 8px; }
.tree-empty { color: var(--muted); font-size: 13px; padding: 4px 8px; }
.tree-row { position: relative; display: flex; align-items: center; gap: 2px; padding: 2px 4px 2px calc(4px + var(--depth) * 14px); border-radius: 6px; min-height: 28px; }
.tree-row:hover { background: var(--hover); }
.tree-row.active, .tree-row.active:hover { background: var(--accent-soft); }
.tree-row.active .tree-title { font-weight: 600; color: var(--accent); }
.tree-caret { border: 0; background: none; color: var(--muted); width: 18px; height: 18px; border-radius: 4px; cursor: pointer; font-size: 10px; flex: none; transition: transform .12s; padding: 0; }
.tree-caret:hover { background: var(--hover); }
.tree-caret.open { transform: rotate(90deg); }
.tree-caret.leaf { visibility: hidden; }
.tree-link { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; color: inherit; text-decoration: none; padding: 2px 0; }
.tree-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions, .tree-row:focus-within .tree-actions { display: flex; }
.tree-actions button { border: 0; background: none; color: var(--muted); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; padding: 0; font-size: 15px; line-height: 1; }
.tree-actions button:hover { background: var(--hover); color: var(--text); }
.tree-row.dragging { opacity: .4; }
.tree-row.drop-inside { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.tree-row.drop-before::before, .tree-row.drop-after::after { content: ""; position: absolute; left: calc(8px + var(--depth) * 14px); right: 4px; height: 2px; background: var(--accent); border-radius: 2px; }
.tree-row.drop-before::before { top: -1px; }
.tree-row.drop-after::after { bottom: -1px; }
:root[data-brand="honeycomb"] .tree-row.active { background: var(--honey); }
:root[data-brand="honeycomb"] .tree-row.active:hover { background: color-mix(in srgb, var(--honey) 88%, #fff); }
:root[data-brand="honeycomb"] .tree-row.active .tree-caret, :root[data-brand="honeycomb"] .tree-row.active .tree-actions button { color: var(--text); }
:root[data-brand="honeycomb"] .tree-row.active .tree-actions button:hover, :root[data-brand="honeycomb"] .tree-row.active .tree-caret:hover { background: rgb(43 33 24 / .12); }
:root[data-brand="honeycomb"] .tree-row.active .tree-title { color: var(--text); }
:root[data-brand="honeycomb"] .tree-row:not(.active):hover { background: rgb(255 255 255 / .08); }
:root[data-brand="honeycomb"] .tree-head, :root[data-brand="honeycomb"] .tree-caret, :root[data-brand="honeycomb"] .tree-actions button, :root[data-brand="honeycomb"] .tree-head button { color: #b99d72; }
:root[data-brand="honeycomb"] .tree-link { color: #f7e7c4; }
:root[data-brand="honeycomb"] .tree-row.active .tree-link { color: var(--text); }

/* ---------- Page ---------- */
main:has(.page), main:has(.page) ~ * { max-width: none; }
main:has(> .page) { padding: 20px 24px 80px; max-width: none; }
/* A page is a sheet of paper on the app's background: readable over patterned styles. Styles tune --sheet*. */
.page {
  --page-w: 760px; --sheet-pad: 64px;
  max-width: calc(var(--page-w) + 2 * var(--sheet-pad)); margin: 0 auto; padding: 0 var(--sheet-pad) 56px;
  background: var(--sheet, var(--surface)); border-radius: var(--sheet-radius, 12px);
  border: var(--sheet-border, 1px solid color-mix(in srgb, var(--text) 7%, transparent));
  box-shadow: var(--sheet-shadow, 0 1px 2px rgb(15 15 15 / .04), 0 12px 32px rgb(15 15 15 / .07));
}
.page.full { --page-w: 100%; max-width: none; }
.page-top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; min-height: 44px;
  position: sticky; top: 61px; z-index: 4; background: var(--sheet, var(--surface));
  margin: 0 calc(-1 * var(--sheet-pad)); padding-inline: var(--sheet-pad); border-radius: var(--sheet-radius, 12px) var(--sheet-radius, 12px) 0 0;
}
/* Full screen (reading mode): the page alone, its top bar (with the exit button) pinned to the top… */
body.reading .layout { grid-template-columns: 1fr; }
body.reading .sidebar, body.reading .topbar { display: none; }
body.reading main { padding-top: 24px; }
body.reading .page-top { top: 0; }
/* …and the whole width, like a full-width page: the point is seeing more of a wide table or database. */
body.reading .page { --page-w: 100%; --sheet-pad: 48px; max-width: none; }
.reading-btn { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.reading-btn:hover { color: var(--text); }
.page-top .crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.page-top .crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; padding: 2px 4px; border-radius: 4px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-top .crumbs a:hover { background: var(--hover); color: var(--text); }
.crumbs .sep { color: var(--muted); opacity: .6; }
.page-top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn.small { font-size: 15px; padding: 3px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); }
.icon-btn .count { font-size: 12px; }
.presence { display: flex; }
.avatar-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; margin-left: -4px; border: 2px solid var(--bg); }

.page-cover { height: 30vh; min-height: 160px; max-height: 280px; margin: 0 calc(-1 * var(--sheet-pad)); background: center / cover no-repeat var(--code-bg); position: relative; }
.page-cover.g1 { background-image: linear-gradient(135deg, #f6d365, #fda085); }
.page-cover.g2 { background-image: linear-gradient(135deg, #a1c4fd, #c2e9fb); }
.page-cover.g3 { background-image: linear-gradient(135deg, #84fab0, #8fd3f4); }
.page-cover.g4 { background-image: linear-gradient(135deg, #fccb90, #d57eeb); }
.page-cover.g5 { background-image: linear-gradient(135deg, #30cfd0, #330867); }
.page-cover.g6 { background-image: linear-gradient(135deg, #2b2118, #f2b418); }
.cover-swatch { display: inline-block; width: 22px; height: 14px; border-radius: 3px; }
.cover-swatch.g1 { background: linear-gradient(135deg, #f6d365, #fda085); } .cover-swatch.g2 { background: linear-gradient(135deg, #a1c4fd, #c2e9fb); }
.cover-swatch.g3 { background: linear-gradient(135deg, #84fab0, #8fd3f4); } .cover-swatch.g4 { background: linear-gradient(135deg, #fccb90, #d57eeb); }
.cover-swatch.g5 { background: linear-gradient(135deg, #30cfd0, #330867); } .cover-swatch.g6 { background: linear-gradient(135deg, #2b2118, #f2b418); }
.cover-actions { position: absolute; right: 16px; bottom: 12px; display: none; gap: 6px; }
.page-cover:hover .cover-actions { display: flex; }
.page-head { max-width: var(--page-w); margin: 0 auto; padding-top: 40px; position: relative; }
.page-head.has-cover { padding-top: 0; }
.page-icon-btn { border: 0; background: none; font-size: 64px; line-height: 1; padding: 4px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; }
.page-head.has-cover .page-icon-btn { margin-top: -38px; position: relative; }
.page-icon-btn:hover { background: var(--hover); }
.page-icon-btn .page-icon { width: auto; }
.page-icon-btn img.page-icon { width: 72px; height: 72px; }
.head-add { display: flex; gap: 12px; opacity: 0; transition: opacity .15s; min-height: 26px; margin: 8px 0 2px; }
.page-head:hover .head-add, .head-add:focus-within { opacity: 1; }
@media (hover: none) { .head-add { opacity: 1; } }
.page-title { font-size: 40px; font-weight: 700; line-height: 1.2; margin: 0 0 8px; outline: none; word-break: break-word; letter-spacing: -.01em; }
.page-title:empty::before { content: attr(data-placeholder); color: var(--muted); opacity: .5; }
.page-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.page-meta:empty { display: none; }
.page-edited { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; text-decoration: none; padding: 2px 8px 2px 2px; border-radius: 99px; }
.page-edited:hover { background: var(--hover); color: var(--text); }
.page-edited strong { font-weight: 600; color: var(--text); }
.page-viewers-slot:empty { display: none; }
.page-viewers { display: inline-flex; align-items: center; padding-left: 4px; }
.viewer { position: relative; display: inline-flex; margin-left: -6px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); cursor: default; outline: none; }
.viewer:first-child { margin-left: 0; }
.viewer .edited-avatar { width: 22px; height: 22px; }
.viewer-more { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 99px; background: var(--code-bg); color: var(--muted); font-size: 11px; font-weight: 600; }
.viewer:hover, .viewer:focus-visible { z-index: 2; }
.viewer:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
/* Mixed into the theme's own colors, so it works in light, dark and every brand. */
.viewer .viewer-initial { background: color-mix(in srgb, hsl(var(--hue) 65% 50%) 24%, var(--surface)); color: color-mix(in srgb, hsl(var(--hue) 65% 40%) 65%, var(--text)); }
/* The tooltip (instant, unlike title=): who, and when they last viewed the page. */
.viewer[data-tip]:hover::after, .viewer[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  white-space: pre; padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg);
  font-size: 12px; font-weight: 500; line-height: 1.45; pointer-events: none; z-index: 20;
}
.edited-avatar { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex: none; object-fit: cover; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 700; }
.page-body, .page .subpages, .page .backlinks, .page .comments { max-width: var(--page-w); margin-left: auto; margin-right: auto; }
.page-body { margin-top: 12px; min-height: 30vh; }
.page .banner { max-width: var(--page-w); margin: 8px auto; }
.page.trashed .page-title { opacity: .7; }

.page-props { display: grid; gap: 2px; margin: 10px 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.prop-row { display: grid; grid-template-columns: 160px minmax(0, 1fr); align-items: start; gap: 8px; min-height: 32px; }
.prop-name { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; padding: 6px 4px; }
.prop-value { padding: 5px 8px; border-radius: 6px; min-height: 32px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 14px; min-width: 0; }
.prop-value > .cell-text, .prop-value > .cell-link { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-value:hover, .prop-value:focus-visible { background: var(--hover); outline: none; }
.prop-value.ro { cursor: default; }
.prop-value.ro:hover { background: none; }
@media (max-width: 640px) { .prop-row { grid-template-columns: 110px minmax(0, 1fr); } }

.subpages, .backlinks { margin-top: 28px; display: grid; gap: 2px; }
.subpages h2, .backlinks h2, .page-comments h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.subpages .subpage, .backlinks a { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; color: var(--text); text-decoration: none; text-decoration-line: underline; text-decoration-color: color-mix(in srgb, var(--text) 25%, transparent); text-underline-offset: 3px; }
.subpages .subpage:hover, .backlinks a:hover { background: var(--hover); }
.subpages .link-btn { justify-self: start; }
.page-comments { margin-top: 28px; }
.save-state { min-width: 56px; text-align: right; }

/* Inline comment rail */
#view.with-rail { padding-right: 340px; }
.comment-rail { position: fixed; right: 0; top: 61px; bottom: 0; width: 320px; background: var(--surface); border-left: 1px solid var(--border); overflow: auto; padding: 12px; z-index: 6; display: grid; align-content: start; gap: 10px; }
.rail-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.rail-head label { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.thread { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; gap: 8px; background: var(--bg); }
.thread.focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thread.resolved { opacity: .65; }
.thread-quote { margin: 0; padding-left: 8px; border-left: 3px solid var(--c-yellow); color: var(--muted); font-size: 13px; }
.thread-comment { font-size: 14px; }
.thread-comment > div { white-space: pre-wrap; }
.thread-reply { display: flex; gap: 6px; }
.thread-reply input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.thread .link-btn { justify-self: start; }
@media (max-width: 1100px) { #view.with-rail { padding-right: 0; } .comment-rail { width: min(340px, 100vw); box-shadow: var(--shadow-pop); } }

/* ---------- Databases ---------- */
.database { margin: 8px 0 24px; }
.db-loading { padding: 12px 0; }
.db-inline-title a { display: inline-flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; margin-bottom: 4px; }
.db-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.db-tabs { display: flex; gap: 2px; overflow-x: auto; }
.db-tab { border: 0; background: none; color: var(--muted); padding: 8px 8px 7px; font: inherit; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; border-radius: 6px 6px 0 0; }
.db-tab:hover { color: var(--text); background: var(--hover); }
.db-tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.db-tools { display: flex; align-items: center; gap: 2px; padding: 4px 0; flex-wrap: wrap; }
.db-tool { border: 0; background: none; color: var(--muted); padding: 4px 8px; border-radius: 6px; font: inherit; font-size: 14px; cursor: pointer; }
.db-tool:hover { background: var(--hover); color: var(--text); }
.db-tool.on { color: var(--accent); }
.db-search { width: 140px; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 14px; }
.db-search:focus { border-color: var(--border); background: var(--surface); outline: none; }
.db-empty { padding: 16px 0; }
.db-count { padding: 6px 2px; }

.table-scroll { overflow-x: auto; }
.db-table { border-collapse: collapse; table-layout: fixed; width: max-content; min-width: 100%; font-size: 14px; }
.db-table th { text-align: left; font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); position: relative; padding: 0; height: 34px; }
.db-table th:last-child { border-right: 0; }
.th-btn { width: 100%; height: 100%; display: flex; align-items: center; gap: 6px; border: 0; background: none; color: inherit; font: inherit; padding: 0 8px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.th-btn:hover { background: var(--hover); }
.col-resize { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 1; }
.col-resize:hover { background: var(--accent); opacity: .5; }
.add-col { width: 44px; }
.db-table td.cell { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 5px 8px; vertical-align: top; min-height: 34px; height: 34px; overflow: hidden; cursor: pointer; }
.db-table td.cell.ro { cursor: default; }
.db-table td.cell:last-child, .db-table td.filler { border-right: 0; }
.db-table td.cell:hover:not(.ro):not(.t-title) { background: var(--hover); }
.db-table td.editing { box-shadow: inset 0 0 0 2px var(--accent); }
.db-table tr:hover td.t-title .row-open { text-decoration: underline; }
.title-cell .row-open { display: flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-weight: 500; }
.cell-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-link { color: var(--text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--text) 30%, transparent); }
.db-table td.t-number, .db-table td.t-unique_id { text-align: right; font-variant-numeric: tabular-nums; }
.db-table tr.dragging { opacity: .4; }
.db-table tr.drop-target td { box-shadow: inset 0 -2px 0 var(--accent); }
.new-row td { border-bottom: 1px solid var(--border); padding: 4px 8px; }
.group-row td { padding: 14px 4px 6px; font-weight: 600; border-bottom: 1px solid var(--border); }
.group-toggle { border: 0; background: none; color: var(--muted); cursor: pointer; }
.checkbox { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1.5px solid var(--muted); border-radius: 3px; font-size: 11px; color: #fff; }
.checkbox.on { background: var(--accent); border-color: var(--accent); }
.person { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.person::before { content: attr(data-initial); }
.relation-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--text) 30%, transparent); margin-right: 8px; white-space: nowrap; }
.file-chip { margin-right: 8px; color: var(--text); white-space: nowrap; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; }
.board-col { flex: 0 0 260px; background: color-mix(in srgb, var(--text) 3%, transparent); border-radius: 8px; padding: 8px; display: grid; gap: 6px; }
.board-col header { display: flex; gap: 6px; align-items: center; padding: 2px 2px 4px; }
.board-cards { display: grid; gap: 6px; min-height: 8px; border-radius: 6px; }
.board-col.drop-target { box-shadow: inset 0 0 0 2px var(--accent); }
.db-card { display: grid; gap: 4px; padding: 8px 10px; background: var(--surface); border-radius: 6px; box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgb(15 15 15 / .06); color: var(--text); text-decoration: none; font-size: 14px; cursor: pointer; overflow: hidden; }
.db-card:hover { background: color-mix(in srgb, var(--surface) 94%, var(--text)); }
.db-card.dragging { opacity: .4; }
.db-card-title { display: flex; gap: 6px; align-items: center; font-weight: 500; }
.db-card-prop { font-size: 12.5px; color: var(--muted); }
.board-new { justify-self: start; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gallery-card { padding: 0; }
.gallery-card > :not(.db-card-cover) { padding: 0 10px; }
.gallery-card > :last-child { padding-bottom: 10px; }
.db-card-cover { height: 120px; background: center / cover no-repeat var(--code-bg); margin-bottom: 6px; }
.db-card-cover.empty { background: color-mix(in srgb, var(--text) 4%, transparent); }
.db-list { display: grid; }
.db-list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 7px 6px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.db-list-row:hover { background: var(--hover); }
.db-list-title { display: flex; gap: 6px; align-items: center; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-list-props { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; flex: none; }
.list-group { margin: 16px 0 4px; font-size: 14px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 10px; }
.cal-head .btn { margin-left: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow { font-size: 12px; color: var(--muted); padding: 4px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; display: grid; align-content: start; gap: 3px; min-width: 0; }
.cal-day.other { background: color-mix(in srgb, var(--text) 3%, transparent); }
.cal-day.other .cal-num { opacity: .5; }
.cal-day.drop-target { background: var(--accent-soft); }
.cal-num { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.cal-day.today .cal-num { color: var(--accent); font-weight: 700; }
.cal-add { border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; padding: 0 4px; border-radius: 4px; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-item { display: flex; gap: 4px; align-items: center; font-size: 12.5px; padding: 2px 6px; border-radius: 4px; background: var(--surface); box-shadow: 0 0 0 1px var(--border); color: var(--text); text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (max-width: 800px) {
  .page-title { font-size: 30px; }
  .page-top { top: 53px; }
  .cal-day { min-height: 64px; }
  .rule { grid-template-columns: 1fr 1fr; }
}

.db-card:focus-visible, .db-list-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.db-list-row { cursor: pointer; }

/* Inline databases stay within the page column; wide tables scroll inside it. */
.page-body .database, .ProseMirror .database { max-width: 100%; min-width: 0; }
.page-body .table-scroll { max-width: 100%; }
.page-body .db-view { max-width: 100%; overflow-x: auto; }

/* ---------- The page sheet per style ---------- */
:root[data-brand="honeycomb"] { --sheet: #ffffff; --sheet-border: 1px solid #f1e0b4; --sheet-radius: 22px; --sheet-shadow: 0 10px 0 -4px #f1e0b4, 0 18px 40px rgb(43 33 24 / .08); }
/* Classic follows the system's light or dark mode: its sheet is the theme's surface (white when light). */
:root[data-brand="classic"] { --sheet: var(--surface); }
:root[data-brand="almanac"] { --sheet: #fbf8f1; --sheet-radius: 0px; --sheet-border: 1px solid var(--text); --sheet-shadow: 6px 6px 0 rgb(27 26 23 / .08); }
:root[data-brand="fieldbook"] { --sheet: #fffefa; --sheet-radius: 4px; --sheet-border: 2px solid var(--text); --sheet-shadow: 5px 6px 0 rgb(0 0 0 / .1); }
:root[data-brand="knowbox"] { --sheet: #ffffff; --sheet-radius: 0px; --sheet-border: 3px solid var(--text); --sheet-shadow: 8px 8px 0 var(--text); }
:root[data-brand="terminal"] { --sheet: #0d150d; --sheet-radius: 0px; --sheet-border: 1px dashed var(--border); --sheet-shadow: 0 0 0 1px rgb(57 255 106 / .05), 0 0 40px rgb(57 255 106 / .06); }
:root[data-brand="orbit"] { --sheet: rgb(18 15 50 / .82); --sheet-radius: 22px; --sheet-border: 1px solid var(--border); --sheet-shadow: 0 20px 60px rgb(0 0 0 / .45); }
:root[data-brand="orbit"] .page { backdrop-filter: blur(14px); }
/* The editor's own boxes (old card styles) shouldn't draw a second card inside the sheet. */
.page .page-body > .content { background: transparent; border: 0; box-shadow: none; padding: 0; }
@media (max-width: 800px) {
  main:has(> .page) { padding: 0 0 48px; }
  .page { --sheet-pad: 16px; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .page-top { border-radius: 0; }
}

/* ---------- Sharing (public/sharing.js) ---------- */
.tree-lock { flex: none; margin-left: 4px; font-size: 11px; opacity: .7; }
.share-btn.private { border-color: var(--accent); }
.share-panel { padding: 14px 16px; display: grid; gap: 10px; }
.share-panel.busy { opacity: .6; pointer-events: none; }
.share-panel h3 { margin: 0; font-size: 14px; }
.share-option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.share-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.share-option input { margin-top: 3px; }
.share-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--hover); font-size: 13px; }
.share-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.share-people li { display: flex; align-items: center; gap: 8px; }
.share-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.share-avatar { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; object-fit: cover; }
.share-add { position: relative; }
.share-add input { width: 100%; box-sizing: border-box; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.share-results { margin-top: 4px; display: grid; gap: 2px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--surface); }
.share-result { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; line-height: 1.25; }
.share-result:hover, .share-result:focus-visible { background: var(--hover); }
.share-copy { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }

/* ---------- Agent activity (agents.js) ---------- */
.agent-request { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; display: grid; gap: 6px; background: var(--surface); }
.agent-request.focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.agent-row-head { font-size: 14px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.agent-summary { font-weight: 600; overflow-wrap: anywhere; }
.agent-reasons { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.agent-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.agent-group { margin-bottom: 16px; display: grid; gap: 6px; }
.agent-change { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.agent-change:last-child { border-bottom: 0; }
.agent-change.undone .agent-change-text > span:first-child { text-decoration: line-through; color: var(--muted); }
.agent-change-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.agent-change-text a { color: inherit; }
.agent-icon { text-align: center; color: var(--muted); }
.agent-past > summary { list-style: none; cursor: pointer; }
.agent-past > summary::-webkit-details-marker { display: none; }
.agent-past > summary h2 { margin: 0; }
.agent-past[open] > summary h2 { margin-bottom: 8px; }
@media (max-width: 640px) { .agent-change { grid-template-columns: 22px minmax(0, 1fr); } .agent-change > time, .agent-change > .agent-actions { grid-column: 2; justify-content: flex-start; } }

/* ---------- @-mentions in comments (mentions.js) and the inbox (inbox.js) ---------- */
.mention-chip { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 2px; font-weight: 600; }
.mention-chip.me { color: var(--text); background: color-mix(in srgb, var(--warn) 30%, transparent); }
.mention-list { position: fixed; z-index: 1000; max-width: 360px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgb(15 15 15 / .14); }
dialog .mention-list { position: absolute; }
.mention-option { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border: 0; border-radius: 6px; background: none; color: var(--text);
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.mention-option.active, .mention-option:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.mention-option img, .mention-initial { width: 20px; height: 20px; border-radius: 50%; flex: none; object-fit: cover; }
.mention-initial { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 700; }
.mention-option .muted { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flash { animation: flash 2.4s ease-out; }
/* A linked block scrolls to the top, just under the app bar (61px) and the page's sticky top bar. */
.page .page-body .sg-editor * { scroll-margin-top: 130px; }
@keyframes flash { from { background: color-mix(in srgb, var(--warn) 35%, transparent); } to { background: transparent; } }

.inbox { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.inbox-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 12px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.inbox-item .edited-avatar { width: 28px; height: 28px; font-size: 12px; }
.inbox-item.unread { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.inbox-item.unread .inbox-text > span:first-child::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.inbox-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 14px; }
.inbox-text .page-icon { margin: 0 3px; }
.inbox-quote { color: var(--muted); border-left: 2px solid var(--border); padding-left: 8px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comments-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.comments-head label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
