/* The wiki's own layout and the few looks the kit does not draw (the tree, the editor, callouts, the save status). It is loaded after
   ../shared/ui/ui-kit.css and before the customer's brand.css. Every colour, size, radius, shadow, layer and duration is a kit token
   (examples/ui-kit/src/css/tokens.css), and the kit tokens read the customer's --brand-* tokens: this file holds no colour of its own.
   The short names below are aliases of kit tokens, kept so the rules read as before. The shell (sidebar, app bar, canvas, right panel),
   the buttons, fields, menus, dialogs, toasts, banners and the focus ring are the kit's. */
:root {
  --bg: var(--ui-canvas); --surface: var(--ui-surface); --elevated: var(--ui-raised); --well: var(--ui-sunken);
  --ink: var(--ui-ink); --muted: var(--ui-ink-2); --faint: var(--ui-ink-3); --line: var(--ui-line); --line-strong: var(--ui-line-strong);
  --primary: var(--ui-primary); --primary-ink: var(--ui-primary-ink);
  --accent: var(--ui-brand-strong); --accent-soft: var(--ui-brand-subtle); --accent-tint: var(--ui-brand-subtle);
  --chip-bg: var(--ui-sunken); --chip-ink: var(--ui-ink-2);
  --solid: var(--ui-inverse); --solid-ink: var(--ui-inverse-ink);
  --code-bg: var(--ui-sunken); --code-ink: var(--ui-ink); --pre-bg: var(--ui-code-bg); --pre-ink: var(--ui-code-ink);
  --bad: var(--ui-danger-text); --bad-bg: var(--ui-danger-bg); --info-fg: var(--ui-info-text); --info-bg: var(--ui-info-bg);
  --warn-fg: var(--ui-warning-text); --warn-bg: var(--ui-warning-bg);
  --edge-info: var(--ui-info); --edge-warn: var(--ui-warning); --edge-bad: var(--ui-danger);
  --mark: color-mix(in srgb, var(--ui-warning) 30%, transparent);
  /* page covers (seed.js COVERS): calm in both themes; the dark set stays dark instead of being dimmed with a filter */
  --cover-1: color-mix(in srgb, var(--ui-brand-strong) 32%, var(--ui-surface)); --cover-2: var(--ui-brand-strong); --cover-3: var(--ui-ink); --cover-4: var(--ui-line-strong);
  --r: var(--ui-radius-xl); --r-sm: var(--ui-radius-lg); --r-xs: var(--ui-radius-md);
  --pop: var(--ui-shadow-3);
  --hover: background-color var(--ui-duration-fast) var(--ui-ease), color var(--ui-duration-fast) var(--ui-ease), border-color var(--ui-duration-fast) var(--ui-ease);
  --m-outline-width: calc(var(--ui-unit) * 13.75);
  --m-page-width: calc(var(--ui-unit) * 47.5);
}
[data-theme="dark"] {
  --cover-1: color-mix(in srgb, var(--ui-brand) 30%, var(--ui-surface)); --cover-2: color-mix(in srgb, var(--ui-brand) 60%, var(--ui-surface)); --cover-3: var(--ui-raised); --cover-4: var(--ui-line-strong);
}

/* [hidden] always hides, also on elements whose class sets a display (the kit's buttons): the page toggles it a lot */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
body { overflow: hidden; }
.muted { color: var(--muted); }
.pad { padding: var(--ui-space-3); }

/* ---------- sidebar ---------- */
.m-search { display: flex; align-items: center; gap: var(--ui-space-3); height: var(--ui-control-lg); padding: 0 var(--ui-space-4); color: var(--ui-sidebar-ink); font: inherit; text-align: start; cursor: pointer; transition: var(--hover); }
.m-search:hover { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-ink-active); }
.m-search .ui-kbd { margin-inline-start: auto; }
.pages-tile { flex: 1 1 auto; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr); gap: var(--ui-space-3); }
.tree-head { display: flex; align-items: center; justify-content: space-between; min-height: var(--ui-control-xs); padding: 0 0 0 var(--ui-space-2); color: var(--ui-sidebar-ink); font-size: var(--ui-text-xs); font-weight: var(--ui-weight-semibold); letter-spacing: var(--ui-tracking-wide); text-transform: uppercase; }
.tree-actions { display: flex; align-items: center; gap: var(--ui-space-1); }
.tree-actions .ui-btn { position: relative; }
.ownerless-badge, .shared-badge { position: absolute; top: calc(var(--ui-space-1) * -1.5); right: calc(var(--ui-space-1) * -1.5); min-width: var(--ui-space-4); height: var(--ui-space-4); padding: 0 var(--ui-space-1); border-radius: var(--ui-radius-pill); background: var(--primary); color: var(--primary-ink); font-size: var(--ui-text-2xs); font-weight: var(--ui-weight-semibold); line-height: var(--ui-space-4); text-align: center; pointer-events: none; }
.tree { overflow: auto; min-height: 0; margin: 0 calc(var(--ui-space-1) * -1); padding: 0 var(--ui-space-1); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 var(--ui-space-3); }
.tree > ul { padding-left: 0; }
.tree li { position: relative; }
.tree-row { width: 100%; display: flex; align-items: center; gap: var(--ui-space-2); background: none; border: 0; border-radius: var(--ui-radius-md); padding: 0 var(--ui-space-2); min-height: var(--ui-control-sm); text-align: start; color: var(--ui-sidebar-ink); font: inherit; font-weight: var(--ui-weight-medium); cursor: pointer; transition: var(--hover); }
.tree-row:hover { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-ink-active); }
/* the open page: the kit's current nav item (tint, not a solid block) */
.tree-row.active { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-ink-active); font-weight: var(--ui-weight-semibold); }
/* inside a scrolling list the ring is drawn inside the row, so the list never clips it */
.tree-row:focus-visible { outline-offset: calc(var(--ui-focus-width) * -1); }
.chev { width: var(--ui-space-3); height: var(--ui-space-3); flex: none; display: grid; place-items: center; }
.chev .ui-icon { width: var(--ui-space-3); height: var(--ui-space-3); }
.tree-icon { display: grid; place-items: center; flex: none; }
.tree-icon .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.tree-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-owner { margin-left: auto; flex: none; color: var(--muted); font-size: var(--ui-text-xs); font-weight: var(--ui-weight-medium); }
.tree-row.active .tree-owner, .tree-row.active .tree-shared { color: inherit; }
.tree-note { margin: calc(var(--ui-space-half) * -1) 0 var(--ui-space-1) var(--ui-space-8); color: var(--muted); font-size: var(--ui-text-xs); }
.tree-shared { display: grid; place-items: center; flex: none; margin-left: auto; color: var(--muted); }
.tree-owner + .tree-shared { margin-left: var(--ui-space-1); }
.tree-shared .ui-icon, .tree-lock .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.tree-lock { display: none; flex: none; margin-left: auto; place-items: center; }
.tree-row[data-lock="1"] .tree-lock { display: grid; }
.tree-dot { margin-left: auto; width: var(--ui-space-2); height: var(--ui-space-2); flex: none; border-radius: var(--ui-radius-round); border: var(--ui-border-thick) solid currentColor; display: none; }
.tree-row[data-lock="1"] .tree-dot { margin-left: var(--ui-space-1); }
.tree-row[data-git="unversioned"] .tree-dot { display: block; }
.tree-row[data-git="failed"] .tree-dot, .tree-row[data-git="conflict"] .tree-dot { display: block; background: var(--bad); border-color: var(--bad); }
/* one "⋯" per folder row (the same menu as a right click): it appears on hover and focus, and the row makes room for it instead of being painted over */
.tree-more { position: absolute; top: calc((var(--ui-control-sm) - var(--ui-control-xs)) / 2); right: var(--ui-space-1); width: var(--ui-control-xs); height: var(--ui-control-xs); display: none; place-items: center; padding: 0; border: 0; border-radius: var(--ui-radius-sm); background: none; color: var(--muted); cursor: pointer; transition: var(--hover); }
.tree-more:hover, .tree-more[aria-expanded="true"] { background: var(--ui-hover); color: var(--ui-ink); }
.tree li:hover > .tree-more, .tree li:focus-within > .tree-more, .tree-more[aria-expanded="true"] { display: grid; }
.tree li:has(> .tree-more):hover > .tree-row, .tree li:has(> .tree-more):focus-within > .tree-row { padding-right: calc(var(--ui-control-xs) + var(--ui-space-2)); }
@media (hover: none) {
  .tree-more { display: grid; }
  .tree li:has(> .tree-more) > .tree-row { padding-right: calc(var(--ui-control-xs) + var(--ui-space-2)); }
}
.tree-menu { position: fixed; }
.tree-menu .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }

/* ---------- app bar ---------- */
.shared-flag { flex: none; gap: var(--ui-space-1); }
.shared-flag .ico { display: grid; }
.shared-flag svg { width: var(--ui-icon-sm); height: var(--ui-icon-sm); fill: none; stroke: currentColor; stroke-width: var(--ui-icon-stroke); }
#user .ui-avatar { font-size: var(--ui-text-xs); }
#user b { display: block; font-weight: var(--ui-weight-semibold); white-space: nowrap; }
#user small { display: block; }
#save-version .opt { white-space: pre; }
body.booting #ask-toggle { display: none; }
/* with a panel open the bar is narrower: the crumbs keep their room */
@media (min-width: 80em) {
  body.panel-open .sync { width: var(--ui-control-md); padding: 0; justify-content: center; }
  body.panel-open .sync-label, body.panel-open .shared-flag > span:not(.ico), body.panel-open #save-version .opt { display: none; }
}
/* the page actions are not offered while no page is open (and are hidden as well in the "⋯" menu) */
body.no-page .m-tool, body.no-page #save-version, body.no-page .sync-wrap,
body.booting .m-tool, body.booting #save-version, body.booting .sync-wrap, body.booting .shared-flag,
body.shared-view .m-tool:not(#export), body.shared-view .sync-wrap { display: none; }

/* the one save status: an icon and a word; the steps are in the panel it opens */
.sync-wrap { position: relative; flex: none; }
.sync { gap: var(--ui-space-2); padding-inline: var(--ui-space-3); font-weight: var(--ui-weight-medium); white-space: nowrap; }
.sync .mark { width: var(--ui-icon-md); height: var(--ui-icon-md); display: grid; place-items: center; flex: none; color: var(--faint); }
.sync .mark .ui-spinner { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.sync[data-kind="ok"] .mark { color: var(--ui-success-text); }
.sync[data-kind="draft"] .mark { color: var(--muted); }
.sync[data-kind="bad"] { color: var(--bad); border-color: var(--ui-danger-line); }
.sync[data-unread="1"]::after { content: ""; position: absolute; top: var(--ui-space-1); right: var(--ui-space-1); width: var(--ui-space-2); height: var(--ui-space-2); border-radius: var(--ui-radius-round); background: var(--accent); }
.sync-panel { position: absolute; top: calc(100% + var(--ui-space-2)); right: 0; width: min(calc(var(--ui-unit) * 22.5), calc(100vw - var(--ui-space-8))); }
.sync-panel h4 { margin: 0 0 var(--ui-space-half); font-size: var(--ui-text-lg); font-weight: var(--ui-weight-semibold); }
.sync-panel .msg { margin: 0 0 var(--ui-space-3); color: var(--muted); font-size: var(--ui-text-sm); overflow-wrap: anywhere; }
.sync-panel .legend { margin: var(--ui-space-3) 0 0; color: var(--muted); font-size: var(--ui-text-sm); }
.steps, .facts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--ui-space-1); }
.step { display: grid; grid-template-columns: var(--ui-space-5) 1fr auto; align-items: center; gap: var(--ui-space-2); padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--ui-radius-md); background: var(--well); }
.step .lbl { font-weight: var(--ui-weight-medium); }
.step small { color: var(--muted); font-variant-numeric: tabular-nums; }
.step.wait .lbl { color: var(--muted); }
.step.bad { background: var(--bad-bg); }
.step.bad .lbl { color: var(--bad); }
.facts li { display: grid; grid-template-columns: var(--ui-space-5) 1fr; gap: var(--ui-space-2); padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--ui-radius-md); background: var(--well); }
.facts b { display: block; font-weight: var(--ui-weight-semibold); }
.facts small { color: var(--muted); font-size: var(--ui-text-xs); }
.mark { width: var(--ui-icon-sm); height: var(--ui-icon-sm); flex: none; display: grid; place-items: center; color: var(--faint); }
.mark .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.mark .ui-spinner { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
[data-kind="ok"] > .mark, .mark[data-kind="ok"] { color: var(--ui-success-text); }
[data-kind="bad"] > .mark, .mark[data-kind="bad"] { color: var(--bad); }
.ring { width: var(--ui-space-3); height: var(--ui-space-3); border-radius: var(--ui-radius-round); border: var(--ui-border-thick) solid currentColor; }
.sync-panel .err { margin: var(--ui-space-3) 0 0; padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--ui-radius-md); background: var(--bad-bg); color: var(--bad); font-size: var(--ui-text-sm); }
.sync-panel .row { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); margin-top: var(--ui-space-3); }
.ai-sec { margin-top: var(--ui-space-4); padding-top: var(--ui-space-3); border-top: var(--ui-border) solid var(--line); }
.sec-title { margin-bottom: var(--ui-space-2); color: var(--muted); font-size: var(--ui-text-2xs); font-weight: var(--ui-weight-semibold); letter-spacing: var(--ui-tracking-wide); text-transform: uppercase; }
.sync-panel .small { margin: 0; font-size: var(--ui-text-xs); }
/* administrators only: version id, model, timings */
.tech { margin-top: var(--ui-space-4); padding-top: var(--ui-space-3); border-top: var(--ui-border) solid var(--line); color: var(--muted); font-size: var(--ui-text-sm); }
.tech summary { cursor: pointer; font-weight: var(--ui-weight-medium); }
.tech .props { margin-top: var(--ui-space-2); }
.tech .ui-link { display: inline-block; margin-top: var(--ui-space-2); }

/* ---------- canvas: cover, page, outline ---------- */
.m-canvas { position: relative; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.cover { position: relative; height: calc(var(--ui-unit) * 7.5); }
.cover .ui-btn { position: absolute; right: var(--ui-space-5); bottom: var(--ui-space-3); opacity: 0; transition: opacity var(--ui-duration-fast) var(--ui-ease); }
.cover:hover .ui-btn, .cover .ui-btn:focus-visible { opacity: 1; }
@media (hover: none) { .cover .ui-btn { opacity: 1; } }
.cover .ui-btn:disabled { cursor: not-allowed; }
.cover:hover .ui-btn:disabled { opacity: var(--ui-opacity-muted); }
.doc { display: grid; grid-template-columns: minmax(0, 1fr); }
.page { width: 100%; max-width: var(--m-page-width); margin: 0 auto; padding: 0 var(--ui-space-8) var(--ui-space-16); position: relative; }
.outline { display: none; }
/* the outline has its own column from the first paint at >= 1280 (reserved even while empty), so nothing moves when it fills */
@media (min-width: 80em) {
  .doc { grid-template-columns: minmax(0, 1fr) var(--m-outline-width); }
  .outline { display: block; position: sticky; top: 0; align-self: start; max-height: 100%; overflow: auto; padding: var(--ui-space-8) var(--ui-space-6) var(--ui-space-6) 0; scrollbar-width: thin; }
  body.panel-open .doc { grid-template-columns: minmax(0, 1fr); }
  body.panel-open .outline { display: none; }
}
.outline h2 { margin: 0 0 var(--ui-space-3); }
.outline-item { display: block; width: 100%; padding: var(--ui-space-1) var(--ui-space-3); border: 0; border-left: var(--ui-border-thick) solid var(--line); background: none; color: var(--muted); font: inherit; font-size: var(--ui-text-sm); text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; transition: var(--hover); }
.outline-item:hover { color: var(--accent); border-left-color: var(--accent); }
.outline-item:focus-visible { outline-offset: calc(var(--ui-focus-width) * -1); }
.outline-item.level-2 { padding-left: var(--ui-space-6); }
.outline-item.level-3 { padding-left: var(--ui-space-8); }
.icon-wrap { position: relative; margin-top: calc(var(--ui-space-8) * -1); height: var(--ui-space-16); }
#icon { width: var(--ui-space-16); height: var(--ui-space-16); display: grid; place-items: center; padding: 0; background: var(--surface); border: var(--ui-border) solid var(--line); border-radius: var(--r); color: var(--accent); font-size: var(--ui-text-2xl); line-height: 1; cursor: pointer; transition: var(--hover); }
#icon:hover { background: var(--ui-hover); }
#icon .ui-icon { width: var(--ui-icon-xl); height: var(--ui-icon-xl); }
#icon:disabled { cursor: not-allowed; }
#icon:disabled:hover { background: var(--surface); }
#icon-picker { position: absolute; top: calc(var(--ui-space-16) + var(--ui-space-2)); left: 0; width: auto; padding: var(--ui-space-2); display: grid; grid-template-columns: repeat(8, 1fr); gap: var(--ui-space-half); }
#icon-picker button { width: var(--ui-control-md); height: var(--ui-control-md); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--ui-radius-md); background: none; color: var(--muted); cursor: pointer; transition: var(--hover); }
#icon-picker button:hover { background: var(--ui-hover); color: var(--accent); }
#icon-picker .ui-icon { width: var(--ui-icon-lg); height: var(--ui-icon-lg); }
#title { width: 100%; padding: var(--ui-space-3) 0 0; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; color: var(--ink); font: inherit; font-size: var(--ui-text-3xl); font-weight: var(--ui-weight-bold); line-height: var(--ui-leading-tight); letter-spacing: var(--ui-tracking-tight); }
#title::placeholder { color: var(--faint); }
#title[readonly] { cursor: default; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-space-2) var(--ui-space-3); min-height: var(--ui-space-6); margin: var(--ui-space-2) 0 var(--ui-space-6); color: var(--muted); font-size: var(--ui-text-sm); }
.meta-chip { display: inline-flex; align-items: center; gap: var(--ui-space-1); min-height: var(--ui-space-6); padding: var(--ui-space-half) var(--ui-space-3); border-radius: var(--ui-radius-pill); background: var(--chip-bg); color: var(--chip-ink); font-size: var(--ui-text-xs); font-weight: var(--ui-weight-medium); vertical-align: middle; }
.meta-chip.mine { background: var(--accent-soft); color: var(--accent); }
.meta-chip .ico { display: grid; place-items: center; }
.meta-chip .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.chip-btn { flex: none; height: var(--ui-space-5); margin: 0 calc(var(--ui-space-1) * -1) 0 var(--ui-space-half); padding: 0 var(--ui-space-2); border: var(--ui-border) solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: var(--ui-radius-pill); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--ui-text-xs); font-weight: var(--ui-weight-medium); white-space: nowrap; cursor: pointer; transition: var(--hover); }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
#raw { display: none; width: 100%; min-height: 60vh; padding: var(--ui-space-4); border: var(--ui-border) solid var(--line-strong); border-radius: var(--r-sm); background: var(--code-bg); color: var(--code-ink); font-family: var(--ui-font-mono); font-size: var(--ui-text-sm); line-height: var(--ui-leading-relaxed); resize: vertical; }
body.raw #raw { display: block; }
body.raw #editor { display: none; }

/* the read-only banner: the kit's banner, sticky on top of the canvas */
.lock-banner { border-radius: calc(var(--r) - var(--ui-border)) calc(var(--r) - var(--ui-border)) 0 0; }
.lock-banner .ui-banner__icon { display: grid; place-items: center; }

/* ---------- editor ---------- */
.tiptap { outline: none; min-height: 40vh; font-size: var(--ui-text-lg); line-height: var(--ui-leading-relaxed); }
.tiptap > * + * { margin-top: .7em; }
.tiptap h1 { margin: 1.5em 0 .3em; font-size: 1.75em; font-weight: var(--ui-weight-bold); line-height: var(--ui-leading-tight); letter-spacing: var(--ui-tracking-tight); }
.tiptap h2 { margin: 1.4em 0 .3em; font-size: 1.4em; font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); letter-spacing: var(--ui-tracking-tight); }
.tiptap h3 { margin: 1.2em 0 .2em; font-size: 1.15em; font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); }
.tiptap p { margin: 0; }
.tiptap a { color: var(--accent); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.tiptap mark { background: var(--mark); color: inherit; border-radius: var(--ui-radius-xs); padding: 0 .15em; }
.tiptap code { background: var(--code-bg); color: var(--code-ink); border-radius: var(--ui-radius-xs); padding: .12em .4em; font-family: var(--ui-font-mono); font-size: .88em; }
.tiptap pre { background: var(--pre-bg); color: var(--pre-ink); border-radius: var(--r-sm); padding: var(--ui-space-3) var(--ui-space-4); overflow: auto; }
.tiptap pre code { background: none; color: inherit; padding: 0; font-size: var(--ui-text-sm); }
.tiptap blockquote { margin-left: 0; padding: var(--ui-space-half) 0 var(--ui-space-half) var(--ui-space-4); border-left: var(--ui-border-thick) solid var(--accent); color: var(--muted); }
.tiptap hr { border: 0; border-top: var(--ui-border) solid var(--line); margin: 1.8em 0; }
.tiptap img { max-width: 100%; border-radius: var(--r-sm); }
.tiptap ul, .tiptap ol { padding-left: 1.5em; margin-top: .3em; }
.tiptap li > p { margin: 0; }
.tiptap li + li { margin-top: .2em; }
.tiptap ul[data-type="taskList"] { list-style: none; padding-left: var(--ui-space-half); }
.tiptap ul[data-type="taskList"] li { display: flex; gap: var(--ui-space-3); align-items: flex-start; }
.tiptap ul[data-type="taskList"] li > label { margin-top: .4em; flex: none; user-select: none; }
.tiptap ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.tiptap ul[data-type="taskList"] input { width: var(--ui-check-size); height: var(--ui-check-size); accent-color: var(--accent); cursor: pointer; }
.tiptap ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--muted); text-decoration: line-through; }
.tiptap p.is-empty::before, .tiptap h1.is-empty::before, .tiptap h2.is-empty::before, .tiptap h3.is-empty::before { content: attr(data-placeholder); float: left; height: 0; pointer-events: none; color: var(--faint); }
.tiptap ::selection { background: var(--ui-selection); }
.ProseMirror-selectednode { outline: var(--ui-focus-width) solid var(--accent); outline-offset: var(--ui-focus-offset); border-radius: var(--ui-radius-xs); }
.tiptap table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; margin: .9em 0; border: var(--ui-border) solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.tiptap th, .tiptap td { position: relative; min-width: var(--ui-space-16); padding: var(--ui-space-2) var(--ui-space-3); border-bottom: var(--ui-border) solid var(--line); border-right: var(--ui-border) solid var(--line); vertical-align: top; }
.tiptap th:last-child, .tiptap td:last-child { border-right: 0; }
.tiptap tr:last-child td, .tiptap tr:last-child th { border-bottom: 0; }
.tiptap th { background: var(--chip-bg); text-align: left; font-weight: var(--ui-weight-semibold); }
.tiptap .selectedCell::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; }
.tiptap .column-resize-handle { position: absolute; right: calc(var(--ui-space-half) * -1); top: 0; bottom: 0; width: var(--ui-space-1); background: var(--accent); pointer-events: none; }
.tableWrapper { overflow-x: auto; }
.resize-cursor { cursor: col-resize; }

/* callout: note = info, tip = accent, important = ink, warning, caution = danger */
.callout { display: flex; gap: var(--ui-space-3); margin: .9em 0; padding: var(--ui-space-3) var(--ui-space-4); border: var(--ui-border) solid color-mix(in srgb, var(--c-edge) 35%, var(--surface)); border-radius: var(--r-sm); background: var(--c-bg); }
.callout > .callout-body { flex: 1; min-width: 0; }
.callout-icon { align-self: flex-start; width: var(--ui-icon-lg); height: var(--ui-icon-lg); margin-top: var(--ui-space-half); padding: 0; display: grid; place-items: center; border: 0; background: none; color: var(--c-fg); user-select: none; cursor: pointer; }
.callout-icon svg { width: var(--ui-icon-lg); height: var(--ui-icon-lg); fill: none; stroke: currentColor; stroke-width: var(--ui-icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.callout[data-kind="NOTE"] { --c-bg: var(--info-bg); --c-edge: var(--edge-info); --c-fg: var(--info-fg); }
.callout[data-kind="TIP"] { --c-bg: var(--accent-soft); --c-edge: var(--accent); --c-fg: var(--accent); }
.callout[data-kind="IMPORTANT"] { --c-bg: var(--chip-bg); --c-edge: var(--ink); --c-fg: var(--ink); }
.callout[data-kind="WARNING"] { --c-bg: var(--warn-bg); --c-edge: var(--edge-warn); --c-fg: var(--warn-fg); }
.callout[data-kind="CAUTION"] { --c-bg: var(--bad-bg); --c-edge: var(--edge-bad); --c-fg: var(--bad); }

/* the drag handle of a block: beside it (main.js places it with an offset), never on a touch screen, where dragging is not offered */
.drag-handle { display: grid; place-items: center; width: var(--ui-space-5); height: var(--ui-space-6); border-radius: var(--ui-radius-xs); color: var(--muted); cursor: grab; transition: var(--hover); }
.drag-handle:hover { background: var(--ui-hover); color: var(--accent); }
.drag-handle:active { cursor: grabbing; }
.drag-handle.hide { opacity: 0; pointer-events: none; }
@media (hover: none) { .drag-handle { display: none; } }

/* the text format toolbar: the kit's inverse surface, svg icons, the pressed state from aria-pressed */
.bubble { visibility: hidden; position: absolute; top: 0; left: 0; z-index: var(--ui-z-dropdown); display: flex; gap: var(--ui-space-half); padding: var(--ui-space-1); border-radius: var(--r-sm); background: var(--solid); color: var(--solid-ink); box-shadow: var(--pop); }
.bubble button { width: var(--ui-control-xs); height: var(--ui-control-xs); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--ui-radius-sm); background: none; color: inherit; cursor: pointer; transition: var(--hover); }
.bubble button:hover { background: color-mix(in srgb, var(--solid-ink) 16%, transparent); }
.bubble button[aria-pressed="true"] { background: var(--ui-brand); color: var(--ui-ink-on-brand); }
.bubble button:focus-visible { outline-color: var(--solid-ink); }
.bubble .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }

/* the slash menu */
.slash-menu { position: fixed; z-index: var(--ui-z-dropdown); width: calc(var(--ui-unit) * 18.75); max-height: calc(var(--ui-unit) * 21.25); overflow: auto; padding: var(--ui-space-2); background: var(--elevated); border: var(--ui-border) solid var(--line); border-radius: var(--r); box-shadow: var(--ui-shadow-2); scrollbar-width: thin; }
.slash-item { width: 100%; display: flex; align-items: center; gap: var(--ui-space-3); padding: var(--ui-space-2) var(--ui-space-3); border: 0; border-radius: var(--r-sm); background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.slash-item.active, .slash-item[aria-selected="true"] { background: var(--ui-hover); }
.slash-glyph { width: var(--ui-control-sm); height: var(--ui-control-sm); flex: none; display: grid; place-items: center; border-radius: var(--ui-radius-md); background: var(--chip-bg); color: var(--chip-ink); font-size: var(--ui-text-sm); font-weight: var(--ui-weight-semibold); }
.slash-item.active .slash-glyph, .slash-item[aria-selected="true"] .slash-glyph { background: var(--ui-brand); color: var(--ui-ink-on-brand); }
.slash-glyph svg { width: var(--ui-icon-md); height: var(--ui-icon-md); fill: none; stroke: currentColor; stroke-width: var(--ui-icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.slash-item b { display: block; line-height: var(--ui-leading-tight); font-weight: var(--ui-weight-semibold); }
.slash-item small { color: var(--muted); }
.slash-empty { padding: var(--ui-space-3); color: var(--muted); }

/* links: what they point at */
.tiptap a:has(.lk-internal) { text-decoration: none; background: var(--accent-soft); border-radius: var(--ui-radius-xs); padding: 0 .3em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.tiptap a:has(.lk-internal):hover { background: var(--accent-tint); }
.tiptap a:has(.lk-internal)::before, .tiptap a:has(.lk-external)::after, .tiptap a:has(.lk-broken)::before { content: ""; display: inline-block; width: .9em; height: .9em; vertical-align: -.1em; background: currentColor; -webkit-mask: var(--lk-icon) center / contain no-repeat; mask: var(--lk-icon) center / contain no-repeat; }
.tiptap a:has(.lk-internal)::before { --lk-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z'/%3E%3C/svg%3E"); margin-right: .3em; }
.tiptap a:has(.lk-external)::after { --lk-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25'/%3E%3C/svg%3E"); margin-left: .25em; opacity: var(--ui-opacity-muted); }
.tiptap a:has(.lk-broken) { color: var(--bad); text-decoration: underline dashed; text-underline-offset: .2em; }
.tiptap a:has(.lk-broken)::before { --lk-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z'/%3E%3C/svg%3E"); margin-right: .3em; }
.link-card { position: fixed; z-index: var(--ui-z-dropdown); width: calc(var(--ui-unit) * 20); max-width: calc(100vw - var(--ui-space-4)); display: grid; gap: var(--ui-space-2); padding: var(--ui-space-3); background: var(--elevated); border: var(--ui-border) solid var(--line); border-radius: var(--r); box-shadow: var(--ui-shadow-2); }
.lc-what { display: flex; align-items: center; gap: var(--ui-space-3); min-width: 0; }
.lc-what .ico { width: var(--ui-control-sm); height: var(--ui-control-sm); flex: none; display: grid; place-items: center; border-radius: var(--ui-radius-md); background: var(--accent-soft); color: var(--accent); }
.link-card.broken .lc-what .ico { background: var(--bad-bg); color: var(--bad); }
.lc-what .ui-icon, .lc-btn .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.lc-text { min-width: 0; }
.lc-text b { display: block; font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-text small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-actions { display: flex; gap: var(--ui-space-2); }
.lc-btn { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: var(--ui-space-2); height: var(--ui-control-sm); padding: 0 var(--ui-space-3); border: var(--ui-border) solid var(--line-strong); border-radius: var(--ui-radius-md); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--ui-text-sm); font-weight: var(--ui-weight-medium); white-space: nowrap; cursor: pointer; transition: var(--hover); }
.lc-btn:hover { background: var(--ui-hover); color: var(--accent); }
.lc-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }

/* ---------- the right panel: History, Info, Sharing, Shared with me, Without an owner, Ask (one at a time, in the kit's .ui-aside) ---------- */
.m-panel { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; background: var(--elevated); border: var(--ui-border) solid var(--line); border-radius: var(--r); box-shadow: var(--ui-shadow-1); outline: none; }
body.history-open #history, body.info-open #info, body.sharing-open #sharing, body.shared-open #shared, body.ownerless-open #ownerless, body.ask-open #ask { display: flex; }
.m-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-space-3); padding: var(--ui-space-3) var(--ui-space-3) var(--ui-space-2) var(--ui-space-5); }
.m-panel__title { margin: 0; font-size: var(--ui-text-lg); font-weight: var(--ui-weight-semibold); }
.m-panel__body { flex: 1; min-height: 0; overflow: auto; padding: 0 var(--ui-space-5) var(--ui-space-5); scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.m-panel--ask { padding: 0; --agent-avatar-bg: var(--ui-brand-subtle); --agent-avatar-ink: var(--ui-brand-strong); } /* the ink of Max's mark in the Ask panel (shared/agent-mark.js), painted as in the chat */
body:not(.ask-open) #ask { display: none; } /* the shared panel sets its own display */
/* a column beside the page: its card starts where the canvas starts (y84) */
@media (min-width: 80em) { .m-aside { padding-top: calc(var(--ui-appbar-height) + var(--ui-appbar-gap)); } }
/* the overlay of 861-1279: it floats under the app bar like the canvas, so the bar's controls stay in reach */
@media (min-width: 53.76em) and (max-width: 79.99em) {
  #side-panel { inset-block: calc(var(--ui-appbar-height) + var(--ui-appbar-gap)) var(--ui-space-4); inset-inline-end: var(--ui-space-6); padding: 0; border: 0; background: none; box-shadow: none; }
  .m-panel { box-shadow: var(--pop); }
}
@media (max-width: 53.75em) { .m-panel { border: 0; border-radius: 0; box-shadow: none; background: transparent; } }
.m-list, .m-panel__body ul { list-style: none; margin: var(--ui-space-3) 0 0; padding: 0; display: grid; gap: var(--ui-space-2); }
.m-panel__body li { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-space-3); padding: var(--ui-space-3); border-radius: var(--r-sm); background: var(--well); }
.m-panel__body li b { display: block; font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); }
.m-panel__body li small { color: var(--muted); }
.m-panel__body li.empty { display: block; color: var(--muted); }
#sharing-target { margin: 0 0 var(--ui-space-1); overflow-wrap: anywhere; }

/* Info */
#info-body h5, #sharing-body h5, #sharing-add h5 { margin: var(--ui-space-5) 0 var(--ui-space-2); display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: var(--ui-text-2xs); font-weight: var(--ui-weight-semibold); letter-spacing: var(--ui-tracking-wide); text-transform: uppercase; }
#info-body h5:first-child { margin-top: var(--ui-space-2); }
#info-body h5 span { text-transform: none; letter-spacing: 0; font-weight: var(--ui-weight-medium); }
#info-body h6 { margin: var(--ui-space-3) 0 var(--ui-space-2); color: var(--muted); font-size: var(--ui-text-xs); font-weight: var(--ui-weight-semibold); }
#info-body .summary { margin: 0; line-height: var(--ui-leading-relaxed); }
#info-body .tags { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); }
.tag { padding: var(--ui-space-half) var(--ui-space-3); border-radius: var(--ui-radius-pill); background: var(--chip-bg); color: var(--chip-ink); font-size: var(--ui-text-xs); font-weight: var(--ui-weight-medium); }
#info-body li button.rel, #shared-body li button.rel { flex: 1; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
#info-body li button.rel b, #shared-body li button.rel b { color: var(--accent); }
#info-body li button.rel:hover b, #shared-body li button.rel:hover b { text-decoration: underline; }
#info-body li .x { flex: none; width: var(--ui-control-xs); height: var(--ui-control-xs); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--ui-radius-md); background: none; color: var(--muted); cursor: pointer; transition: var(--hover); }
#info-body li .x:hover { background: var(--ui-hover); color: var(--accent); }
#info-body li .x .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
#info-body li.gone { color: var(--muted); }
#info-body li.gone button { border: 0; background: none; color: var(--accent); font: inherit; font-weight: var(--ui-weight-medium); cursor: pointer; }
#info-body li.missing b { color: var(--muted); }
#info-body li.restricted { justify-content: flex-start; color: var(--muted); font-size: var(--ui-text-sm); }
#info-body li.restricted .ico { display: grid; place-items: center; }
#info-body li.restricted .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.props { display: grid; grid-template-columns: auto 1fr; gap: var(--ui-space-2) var(--ui-space-4); margin: 0; font-size: var(--ui-text-sm); }
.props dt { color: var(--muted); }
.props dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.empty-note { margin: 0; color: var(--muted); font-size: var(--ui-text-sm); }
#sharing-body .empty-note, #ownerless-body .empty-note, #shared-body .empty-note { margin-top: var(--ui-space-3); }
.err-row { margin: var(--ui-space-3) 0 0; padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--ui-radius-md); background: var(--bad-bg); color: var(--bad); font-size: var(--ui-text-sm); }
#sharing-add .err-row, #ownerless-body .err-row { margin: 0; }
#sharing-body .err-row + .row { margin-top: var(--ui-space-3); }
.row { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); }
.row.end { justify-content: flex-end; }

/* Sharing, Without an owner, Shared with me */
#sharing-body ul { margin-top: 0; }
#sharing-body li, #ownerless-body li { display: grid; justify-content: stretch; align-items: start; gap: var(--ui-space-2); }
#sharing-body .who b, #ownerless-body .who b { overflow-wrap: anywhere; }
#sharing-body .who small, #sharing-body .grant small, #ownerless-body .who small, #shared-body li small { display: block; }
#sharing-body .chips { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); }
#sharing-add { display: grid; gap: var(--ui-space-2); margin-top: var(--ui-space-1); }
#sharing .people-search, #ownerless .people-search { width: 100%; height: var(--ui-control-md); padding: 0 var(--ui-space-3); border: var(--ui-border) solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; }
#sharing .people-search:focus-visible, #ownerless .people-search:focus-visible, #sharing .choice-select:focus-visible { border-color: var(--ui-focus-color); }
#sharing .small, #ownerless .small { margin: 0; font-size: var(--ui-text-xs); }
#sharing .people-list, #ownerless .people-list { display: grid; gap: var(--ui-space-half); }
#sharing .person, #ownerless .person { display: flex; align-items: center; gap: var(--ui-space-3); padding: var(--ui-space-2); border: 0; border-radius: var(--ui-radius-md); background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; transition: var(--hover); }
#sharing .person:hover, #sharing .person.active, #ownerless .person:hover, #ownerless .person.active { background: var(--ui-hover); color: var(--accent); }
#sharing .avatar, #ownerless .avatar { flex: none; min-width: var(--ui-control-xs); height: var(--ui-control-xs); padding: 0 var(--ui-space-1); display: grid; place-items: center; border-radius: var(--ui-radius-pill); background: var(--chip-bg); color: var(--chip-ink); font-size: var(--ui-text-2xs); font-weight: var(--ui-weight-semibold); }
#sharing .picked { display: flex; align-items: center; gap: var(--ui-space-3); }
#sharing .picked b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#sharing .choice, #sharing .grant-edit, #ownerless-body .owner-picker { display: grid; gap: var(--ui-space-2); }
#sharing .choice-select { width: 100%; height: var(--ui-control-sm); padding: 0 var(--ui-space-8) 0 var(--ui-space-2); border: var(--ui-border) solid var(--line-strong); border-radius: var(--ui-radius-md); background: var(--surface); color: var(--ink); font: inherit; appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 1.1rem) 50%, calc(100% - .8rem) 50%; background-size: .3rem .3rem; background-repeat: no-repeat; }
#sharing .caps { display: grid; gap: var(--ui-space-1); }
#sharing .cap { display: flex; align-items: center; gap: var(--ui-space-2); font-size: var(--ui-text-sm); }
#sharing .cap:has(input:disabled) { color: var(--muted); }
#sharing .choice small { display: block; }
#shared-body li.current { background: var(--accent-soft); }

/* ---------- dialogs: native <dialog> dressed with the kit's classes (main.js dressDialog) ---------- */
dialog { border: 0; padding: 0; background: transparent; color: inherit; }
dialog::backdrop { background: var(--ui-scrim); }
.m-dialog > form { width: min(var(--ui-dialog-sm), calc(100vw - var(--ui-space-8))); display: grid; gap: var(--ui-space-3); padding: var(--ui-space-5); background: var(--elevated); border: var(--ui-border) solid var(--line); border-radius: var(--r); box-shadow: var(--pop); }
.m-dialog[open] > form { animation: ui-pop var(--ui-duration-slow) var(--ui-ease-out); }
.m-dialog.link-dialog > form { width: min(var(--ui-dialog-md), calc(100vw - var(--ui-space-8))); }
.m-dialog p { margin: 0; }
.m-dialog .audience { font-size: var(--ui-text-sm); }
.m-dialog .error { min-height: 1em; color: var(--bad); font-size: var(--ui-text-sm); }
.m-dialog .error:empty { display: none; }
.m-dialog .folder-pages { margin: 0; padding-left: var(--ui-space-5); max-height: 40vh; overflow: auto; font-size: var(--ui-text-sm); }
.m-dialog .ui-dialog__footer .grow { flex: 1; }
.suggest { list-style: none; margin: calc(var(--ui-space-half) * -1) 0 0; padding: var(--ui-space-1); max-height: calc(var(--ui-unit) * 15); overflow: auto; border: var(--ui-border) solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.suggest li { display: flex; align-items: center; gap: var(--ui-space-3); padding: var(--ui-space-2); border-radius: var(--ui-radius-md); cursor: pointer; }
.suggest li.active { background: var(--ui-hover); }
.suggest .ico { width: var(--ui-control-xs); height: var(--ui-control-xs); flex: none; display: grid; place-items: center; border-radius: var(--ui-radius-sm); background: var(--chip-bg); color: var(--chip-ink); }
.suggest li.active .ico { background: var(--ui-brand); color: var(--ui-ink-on-brand); }
.suggest .ico .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
.suggest .what { min-width: 0; display: grid; }
.suggest b { font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); }
.suggest small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the search palette (⌘K) */
.palette { width: min(calc(var(--ui-unit) * 35), calc(100vw - var(--ui-space-8))); margin: 14vh auto 0; overflow: hidden; background: var(--elevated); border: var(--ui-border) solid var(--line); border-radius: var(--r); box-shadow: var(--pop); }
.palette[open] { display: block; animation: ui-pop var(--ui-duration) var(--ui-ease-out); }
.palette-field { display: flex; align-items: center; gap: var(--ui-space-3); padding: 0 var(--ui-space-5); border-bottom: var(--ui-border) solid var(--line); color: var(--muted); }
#palette-input { flex: 1; min-width: 0; padding: var(--ui-space-4) 0; border: 0; outline: none; box-shadow: none; background: transparent; color: var(--ink); font: inherit; font-size: var(--ui-text-lg); }
/* the box is the whole field row: the focus shows on its bottom line, inside the dialog that clips */
.palette-field:focus-within { border-bottom-color: var(--ui-focus-color); box-shadow: inset 0 calc(var(--ui-border-thick) * -1) 0 var(--ui-focus-color); }
#palette-list { max-height: 50vh; overflow: auto; padding: var(--ui-space-2); scrollbar-width: thin; }
.palette-row { width: 100%; display: flex; align-items: center; gap: var(--ui-space-3); padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--r-sm); cursor: pointer; }
.palette-row .tree-icon { width: var(--ui-control-sm); height: var(--ui-control-sm); border-radius: var(--ui-radius-md); background: var(--chip-bg); color: var(--chip-ink); }
.palette-row .tree-icon .ui-icon { width: var(--ui-icon-md); height: var(--ui-icon-md); }
.palette-row.active, .palette-row:hover { background: var(--ui-hover); }
.palette-row.active .tree-icon { background: var(--ui-brand); color: var(--ui-ink-on-brand); }
.palette-row b { display: block; font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); }
.palette-row small { color: var(--muted); }
.palette-empty { margin: 0; padding: var(--ui-space-4); color: var(--muted); }

/* ---------- empty, loading and refused states ---------- */
.empty-state, .boot-state { display: none; }
body.no-page .empty-state { display: grid; padding-top: 14vh; }
body.no-page .doc, body.no-page .cover, body.no-page .lock-banner { display: none; }
body.booting .boot-state { display: block; max-width: var(--m-page-width); margin: 0 auto; padding: calc(var(--ui-unit) * 7.5 + var(--ui-space-12)) var(--ui-space-8) 0; }
.tree-skeleton { display: none; padding: var(--ui-space-2); }
body.booting .tree-skeleton { display: grid; }
#empty-icon .ui-icon { width: 100%; height: 100%; }
body.booting .doc, body.booting .cover, body.booting .empty-state, body.booting .lock-banner, body.booting .tree, body.booting .tree-filter, body.booting .tree-actions { display: none; }
body.shared-view .cover, body.shared-view .icon-wrap { display: none; }
.auth-screen { position: fixed; inset: 0; z-index: var(--ui-z-tooltip); display: grid; place-items: center; padding: var(--ui-space-5); background: var(--bg); color: var(--ink); }
.auth-card { width: min(var(--ui-dialog-sm), 100%); display: grid; gap: var(--ui-space-3); justify-items: center; padding: var(--ui-space-8) var(--ui-space-6); text-align: center; background: var(--elevated); border: var(--ui-border) solid var(--line); border-radius: var(--r); box-shadow: var(--pop); }
.auth-card h2 { margin: 0; font-size: var(--ui-text-xl); }
.auth-card p { margin: 0; color: var(--muted); }
.auth-card .auth-note { font-size: var(--ui-text-xs); }
.auth-card .row { justify-content: center; margin-top: var(--ui-space-1); }
.auth-screen[data-kind="disabled"] .auth-card h2, .auth-screen[data-kind="refused"] .auth-card h2 { color: var(--bad); }

/* ---------- narrower screens (the shell itself is the kit's) ---------- */
/* under 1280 the bar keeps its room for the crumbs: the status shows its icon (the word is its name and tooltip), the shared mark its icon */
@media (max-width: 79.99em) {
  .sync { width: var(--ui-control-md); padding: 0; justify-content: center; }
  .sync-label, .shared-flag > span:not(.ico) { display: none; }
  #save-version .opt { display: none; }
}
@media (max-width: 53.75em) {
  .page { padding: 0 var(--ui-space-8) var(--ui-space-16); }
  #title { font-size: var(--ui-text-2xl); }
  .cover { height: calc(var(--ui-unit) * 6.25); }
  .lock-banner .ui-banner__actions { width: 100%; }
  .shared-flag { display: none; }
}
@media (max-width: 35em) {
  .page { padding: 0 var(--ui-space-4) var(--ui-space-12); }
  .drag-handle { display: none; }
  .sync-panel { position: fixed; top: calc(var(--ui-appbar-height-sm) + var(--ui-space-1)); left: var(--ui-space-3); right: var(--ui-space-3); width: auto; }
}
