@font-face { font-family: "Geist"; src: url("../assets/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

/* ESGmax DS — brand-agnostic: a brand change is a swap of these variables. Brand green is logo-only, never used here.
   The customer's colours arrive as --brand-<token> (GET /api/v1/public/brand.css, linked from index.html AFTER this stylesheet). Every colour of the tool is read
   through a semantic variable below, and each semantic variable takes the brand's token when there is one and the product colour otherwise, so a customer
   without a palette sees the product exactly as before. The ONLY hard-coded colours of this file are the two "product palette" blocks; nothing else may
   carry a literal colour value (brand-coverage test). A status text colour is the brand's status colour mixed toward the ink (darker in the light theme, lighter in the
   dark one), because the kit guarantees the contrast of the ink pairs, not of the status colours. Same tokens as the dashboard, so every tool reads as one product. */

/* product palette: begin (light) */
:root {
  --ds-primary-100: #D9E2EC; --ds-primary-300: #9FB3C8; --ds-primary-700: #1C3A5B; --ds-primary-800: #0F2B45; --ds-primary-900: #00203F; --ds-primary-950: #001324;
  --ds-accent-50: #F3F6F9; --ds-accent-100: #DDE7F0; --ds-accent-200: #BAD0E6; --ds-accent-400: #5F99D1; --ds-accent-600: #2E6CA8; --ds-accent-800: #214F7A; --ds-accent-900: #1A3A59;
  --ds-neutral-0: #FFFFFF; --ds-neutral-50: #F9FAFB; --ds-neutral-100: #F2F4F7; --ds-neutral-200: #E9ECEF; --ds-neutral-300: #D5DAE0; --ds-neutral-700: #5C6772;
  --ds-on-colour: #FFFFFF;
  --ds-mark: rgba(245, 158, 11, .3);
  --ds-bad: #A13636; --ds-bad-bg: #FEF2F2; --ds-info-bg: #EFF6FF; --ds-info-fg: #1D4ED8; --ds-warn-bg: #FFFBEB; --ds-warn-fg: #92400E;
  --ds-edge-info: #3B82F6; --ds-edge-warn: #F59E0B; --ds-edge-bad: #DC2626;
  --ds-shadow: 0 1px 2px rgba(0, 32, 63, .05);
  --ds-pop: 0 16px 40px rgba(0, 20, 36, .18);
  --ds-scrim: rgba(0, 19, 36, .45);
}
/* product palette: end (light) */
/* product palette: begin (dark) */
[data-theme="dark"] {
  --ds-mark: rgba(245, 158, 11, .35);
  --ds-bad: #f4a5a5; --ds-bad-bg: #3a1f22; --ds-info-bg: #14284f; --ds-info-fg: #93c5fd; --ds-warn-bg: #3b2a0a; --ds-warn-fg: #fcd34d;
  --ds-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --ds-pop: 0 16px 40px rgba(0, 0, 0, .5);
  --ds-scrim: rgba(0, 19, 36, .45);
}
/* product palette: end (dark) */

:root {
  --bg: var(--brand-canvas, var(--ds-neutral-50)); --surface: var(--brand-surface, var(--ds-neutral-0)); --ink: var(--brand-ink, var(--ds-primary-900)); --muted: var(--brand-ink-secondary, var(--ds-neutral-700)); --line: var(--brand-line, var(--ds-neutral-200));
  --elevated: var(--brand-surface-elevated, var(--surface)); --well: var(--brand-surface-sunken, var(--bg)); --faint: var(--brand-ink-muted, var(--muted)); --line-strong: var(--brand-line-strong, var(--line));
  --primary: var(--brand-brand, var(--ds-primary-900)); --primary-hover: var(--brand-brand-hover, var(--primary)); --primary-active: var(--brand-brand-active, var(--primary-hover)); --primary-ink: var(--brand-ink-on-brand, var(--ds-on-colour));
  --accent: var(--brand-brand-strong, var(--deploy-accent, var(--ds-accent-600))); --accent-ink: var(--brand-surface, var(--ds-on-colour)); --accent-soft: var(--brand-brand-subtle, var(--ds-accent-50)); --accent-tint: var(--brand-brand-subtle, var(--ds-accent-100));
  --chip-bg: var(--brand-surface-sunken, var(--ds-neutral-100)); --chip-ink: var(--brand-ink-secondary, var(--ds-neutral-700));
  --solid: var(--brand-brand, var(--ds-primary-900)); --solid-ink: var(--brand-ink-on-brand, var(--ds-on-colour));
  --code-bg: var(--brand-surface-sunken, var(--ds-neutral-100)); --code-ink: var(--brand-ink, var(--ds-primary-900)); --pre-bg: var(--brand-ink, var(--ds-primary-900)); --pre-ink: var(--brand-canvas, var(--ds-primary-100));
  --cover-1: var(--brand-brand-subtle, var(--ds-accent-200)); --cover-2: var(--brand-brand-strong, var(--ds-accent-600)); --cover-3: var(--brand-ink, var(--ds-primary-900)); --cover-4: var(--brand-line-strong, var(--ds-neutral-300));
  /* the sidebar: its tokens, else the product look (the tree rows keep it) */
  --side-bg: var(--brand-sidebar, var(--surface)); --side-line: var(--brand-sidebar-border, var(--line)); --side-ink: var(--brand-sidebar-ink, var(--muted)); --side-ink-strong: var(--brand-sidebar-ink, var(--ink));
  --side-hover: var(--brand-sidebar-hover, var(--accent-soft)); --side-hover-ink: var(--brand-sidebar-ink-active, var(--accent));
  --side-active: var(--brand-sidebar-hover, var(--accent)); --side-active-ink: var(--brand-sidebar-ink-active, var(--accent-ink)); --side-page: var(--brand-sidebar, var(--bg));
  /* status: the brand's colour mixed toward the ink for text (a mix over a missing token is invalid, so the product colour is used instead) */
  --bad-text: color-mix(in srgb, var(--brand-danger) 68%, var(--ink)); --info-text: color-mix(in srgb, var(--brand-info) 68%, var(--ink)); --warn-text: color-mix(in srgb, var(--brand-warning) 55%, var(--ink));
  --bad: var(--bad-text, var(--ds-bad)); --bad-bg: var(--brand-danger-bg, var(--ds-bad-bg));
  --info-fg: var(--info-text, var(--ds-info-fg)); --info-bg: var(--brand-info-bg, var(--ds-info-bg)); --warn-fg: var(--warn-text, var(--ds-warn-fg)); --warn-bg: var(--brand-warning-bg, var(--ds-warn-bg));
  --edge-info: var(--brand-info, var(--ds-edge-info)); --edge-warn: var(--brand-warning, var(--ds-edge-warn)); --edge-bad: var(--brand-danger, var(--ds-edge-bad));
  --mark-brand: color-mix(in srgb, var(--brand-warning) 30%, transparent); --mark: var(--mark-brand, var(--ds-mark));
  --scrim-brand: color-mix(in srgb, var(--brand-ink) 45%, transparent); --scrim: var(--scrim-brand, var(--ds-scrim));
  --r: 16px; --r-sm: 12px; --r-xs: 10px; --gap: 16px;
  --shadow: var(--ds-shadow); --pop: var(--ds-pop);
  --f: var(--brand-font-family, "Geist", system-ui, -apple-system, "Segoe UI", sans-serif);
  --f-mono: ui-monospace, "SF Mono", Menlo, monospace;
}
[data-theme="dark"] {
  --bg: var(--brand-canvas, var(--ds-primary-950)); --surface: var(--brand-surface, var(--ds-primary-800)); --ink: var(--brand-ink, var(--ds-neutral-50)); --muted: var(--brand-ink-secondary, var(--ds-primary-300)); --line: var(--brand-line, var(--ds-primary-700));
  --primary: var(--brand-brand, var(--ds-accent-600));
  --accent: var(--brand-brand-strong, var(--deploy-accent, var(--ds-accent-400))); --accent-ink: var(--brand-canvas, var(--ds-primary-950)); --accent-soft: var(--brand-brand-subtle, var(--ds-accent-900)); --accent-tint: var(--brand-brand-subtle, var(--ds-accent-900));
  --chip-bg: var(--brand-surface-sunken, var(--ds-primary-700)); --chip-ink: var(--brand-ink-secondary, var(--ds-primary-100));
  --solid: var(--brand-brand, var(--ds-accent-800));
  --code-bg: var(--brand-surface-sunken, var(--ds-primary-700)); --code-ink: var(--brand-ink, var(--ds-primary-100)); --pre-bg: var(--brand-surface-sunken, var(--ds-primary-950)); --pre-ink: var(--brand-ink, var(--ds-primary-100));
  --cover-3: var(--brand-surface-elevated, var(--ds-primary-900));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f); -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; overflow: hidden; }
body { font-weight: var(--brand-font-weight, 400); } /* the customer's body weight (typography); 400 is what the shorthand above gives */
button, input, textarea { font: inherit; color: inherit; }
/* a placeholder is muted ink (the brand's --brand-ink-muted via --faint), not the browser's default grey */
input::placeholder, textarea::placeholder { color: var(--faint); }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.pad { padding: 14px; }
svg { flex: none; }

/* The outline track is `auto` (0 wide while the outline is hidden) so the content fills the viewport; a fixed 220px track left an empty strip on the right. */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr) auto; height: 100vh; height: 100dvh; width: 100%; }

/* shared pieces */
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.icon-btn { position: relative; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); width: 40px; height: 40px; display: grid; place-items: center; transition: background .2s; }
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: block; }
[data-theme="dark"] .icon-btn .i-moon { display: none; }
kbd { font: 500 11px var(--f); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 6px; background: var(--well); color: var(--muted); }

.user { display: flex; align-items: center; gap: 10px; flex: none; }
.user b { display: block; line-height: 1.2; white-space: nowrap; }
.user small { color: var(--muted); }
.user[hidden], .icon-btn[hidden] { display: none; }
/* the "..." menu of the toolbar, only on small screens (the media query below shows the button) */
.icon-btn.more-toggle { display: none; }
.more-menu { position: fixed; z-index: 70; min-width: 190px; max-width: calc(100vw - 16px); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 6px; display: grid; gap: 2px; }
.more-menu[hidden] { display: none; }
.more-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-xs); background: none; color: var(--ink); font-weight: 500; text-align: left; }
.more-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.more-item:hover, .more-item:focus-visible { background: var(--accent-soft); outline: none; }
.more-item.on { color: var(--accent); }
.more-item:disabled { opacity: .5; cursor: not-allowed; background: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 600; font-size: 12px; flex: none; }

/* sidebar */
.sidebar { padding: var(--gap) 0 var(--gap) var(--gap); display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.sidebar .tile { background: var(--side-bg); border-color: var(--side-line); }
/* the brand row is exactly as tall as the top bar and starts at the same y: logo and controls share one centre line */
.brand { height: 40px; padding: 0 12px; margin-bottom: 12px; display: flex; align-items: center; flex: none; }
.logo { display: block; height: auto; width: 120px; }
.logo.on-dark, [data-theme="dark"] .logo.on-light { display: none; }
[data-theme="dark"] .logo.on-dark { display: block; }
.search-open { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 44px; color: var(--side-ink); text-align: left; flex: none; transition: background .2s, color .2s; }
.search-open:hover { background: var(--side-hover); color: var(--side-hover-ink); }
.search-open svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search-open kbd { margin-left: auto; }
.pages-tile { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px; gap: 10px; }
.tree-head { display: flex; align-items: center; justify-content: space-between; color: var(--side-ink); font: 600 12px/1 var(--f); text-transform: uppercase; letter-spacing: .04em; padding: 2px 2px 0 6px; }
.tree-actions { display: flex; align-items: center; gap: 6px; }
.tree-filter { height: 36px; border: 1px solid var(--side-line); background: var(--well); border-radius: var(--r-xs); padding: 0 12px; outline: none; flex: none; }
.tree-filter:focus { border-color: var(--accent); }
.tree { overflow: auto; flex: 1; min-height: 0; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree > ul { padding-left: 0; }
.tree-row { width: 100%; display: flex; align-items: center; gap: 6px; background: none; border: 0; border-radius: var(--r-xs); padding: 0 8px; height: 34px; text-align: left; color: var(--side-ink); font-weight: 500; transition: background .2s, color .2s; }
.tree-row:hover { background: var(--side-hover); color: var(--side-hover-ink); }
.tree-row.active { background: var(--side-active); color: var(--side-active-ink); }
.chev { width: 12px; height: 12px; color: inherit; flex: none; display: grid; place-items: center; }
.chev svg, .tree-icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chev svg { width: 12px; height: 12px; stroke-width: 2; }
.tree-icon { display: grid; place-items: center; flex: none; }
.tree-icon svg { width: 16px; height: 16px; }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* content */
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: var(--gap) 24px 0 var(--gap); margin-bottom: 28px; flex: none; }
/* nothing in the bar may be squeezed into a distorted shape: the crumbs give way first, and when the actions no longer fit beside them they move as a
   group to a second row on the right (never shrunk, never cut). A group that is wider than the whole bar wraps inside its own row, so it can never run
   out of the column over the outline and the right edge of the window */
.topbar > * { flex: none; }
.topbar > .crumbs { flex: 1 1 200px; }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 12px; flex: 0 1 auto; min-width: 0; max-width: 100%; margin-left: auto; }
.topbar-actions > * { flex: none; }
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs i { display: grid; place-items: center; color: var(--muted); }
.crumbs i svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.crumb { background: none; border: 0; padding: 4px 6px; border-radius: 8px; color: var(--muted); }
button.crumb:hover { background: var(--accent-soft); color: var(--accent); }
.crumb.current { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* sync chip: two segments, one per destination of a save (database, Gitea) */
.sync-wrap { position: relative; flex: none; }
.sync { display: flex; align-items: center; height: 40px; padding: 0 4px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); font: 500 12px/1 var(--f); color: var(--ink); transition: background .2s, border-color .2s; }
.sync:hover, .sync[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.seg { display: flex; align-items: center; gap: 6px; padding: 0 10px; white-space: nowrap; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg small { font: 600 10px/1 var(--f); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.seg .st { min-width: 0; }
.mark { width: 16px; height: 16px; flex: none; display: grid; place-items: center; color: var(--faint); }
.mark svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-kind="ok"] > .mark, .mark[data-kind="ok"] { color: var(--accent); }
[data-kind="bad"] > .mark, .mark[data-kind="bad"] { color: var(--bad); }
[data-kind="bad"] > .st { color: var(--bad); }
.ring { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid currentColor; }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-tint); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-panel { position: absolute; top: 48px; right: 0; z-index: 40; width: min(360px, calc(100vw - 32px)); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 16px; }
.sync-panel[hidden] { display: none; }
.sync-panel h4 { margin: 0 0 2px; font: 600 15px/1.3 var(--f); }
.sync-panel .msg { margin: 0 0 12px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.steps, .facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.step { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-xs); background: var(--well); }
.step .lbl { font-weight: 500; }
.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: 20px 1fr; gap: 8px; padding: 8px 10px; border-radius: var(--r-xs); background: var(--well); }
.facts b { display: block; font-weight: 600; }
.facts small { color: var(--muted); font-size: 12.5px; }
.sync-panel .err { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-xs); background: var(--bad-bg); color: var(--bad); font-size: 13px; }
.sync-panel .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sync-panel a.ghost { text-decoration: none; color: var(--ink); display: inline-block; }
.tool:disabled, .tool.primary:disabled { background: var(--chip-bg); border-color: var(--line); color: var(--muted); cursor: not-allowed; filter: none; }
.tree-dot { margin-left: auto; width: 8px; height: 8px; flex: none; border-radius: 50%; border: 1.5px solid currentColor; display: none; }
.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); }
.history li.empty { display: block; color: var(--muted); }
.history small a { color: var(--accent); }
#save-version { white-space: nowrap; }
.seg { position: relative; }
#seg-ai[data-unread="1"]::after { content: ""; position: absolute; top: 6px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.ai-sec { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sec-title { font: 600 11px/1 var(--f); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.sync-panel .small { font-size: 12.5px; margin: 0; }
#info-body h5 { margin: 18px 0 8px; font: 600 11px/1 var(--f); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
#info-body h5 span { text-transform: none; letter-spacing: 0; font-weight: 500; }
#info-body .summary { margin: 0; line-height: 1.55; }
#info-body .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 10px; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink); font-size: 12.5px; font-weight: 500; }
#info-body ul { margin: 0; }
#info-body li button.rel, #shared-body li button.rel { text-align: left; background: none; border: 0; padding: 0; color: inherit; flex: 1; min-width: 0; }
#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: 28px; height: 28px; display: grid; place-items: center; border: 0; background: none; border-radius: var(--r-xs); color: var(--muted); }
#info-body li .x:hover { background: var(--accent-soft); color: var(--accent); }
#info-body li .x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#info-body li.gone { color: var(--muted); }
#info-body li.gone button { border: 0; background: none; color: var(--accent); font-weight: 500; }
#info-body .props { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
#info-body .props dt { color: var(--muted); }
#info-body .props dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
#info-body .empty-note { color: var(--muted); font-size: 13px; margin: 0; }
#info-body .err-row { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-xs); background: var(--bad-bg); color: var(--bad); font-size: 13px; }
.modal .hint { margin: -4px 0 0; font-size: 12.5px; }
.modal .audience { margin: 0; font-size: 13px; }
.modal .audience[hidden] { display: none; }
@media (max-width: 700px) { #save-version .opt { display: none; } .sync-panel { position: fixed; left: 16px; right: 16px; top: 72px; width: auto; } }
/* the save state is three marks at every width (the words are in the panel the button opens) */
.seg .st, .seg small { display: none; } .seg { padding: 0 8px; }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } }
.tool { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); font-weight: 500; transition: background .2s, color .2s, border-color .2s; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--accent-soft); }
.tool.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tool.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
/* "Salva" and " versione" are two pieces of one word group: the gap of the button would double the space between them */
#save-version { gap: 0; }
.tool.primary:hover { filter: brightness(1.12); }
[data-brand] .tool.primary:hover, [data-brand] .lb-btn.primary:hover, [data-brand] .modal .primary:not(.danger):hover:not(:disabled),[data-brand] #sharing .primary-btn:hover:not(:disabled) { filter: none; background: var(--primary-hover); border-color: var(--primary-hover); }
[data-brand] .tool.primary:active, [data-brand] .lb-btn.primary:active, [data-brand] .modal .primary:not(.danger):active:not(:disabled),[data-brand] #sharing .primary-btn:active:not(:disabled) { filter: none; background: var(--primary-active); border-color: var(--primary-active); }
.nav-toggle { display: none; }

/* the page is one big tile */
.scroll { flex: 1; overflow: auto; min-height: 0; margin: 0 24px var(--gap) var(--gap); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); scroll-behavior: smooth; }
.cover { height: 120px; position: relative; }
[data-theme="dark"] .cover { filter: brightness(.7); }
.cover button { position: absolute; right: 20px; bottom: 12px; opacity: 0; transition: opacity .2s; border: 1px solid var(--line); border-radius: var(--r-xs); padding: 5px 12px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 500; }
.cover:hover button, .cover button:focus-visible { opacity: 1; }
.page { max-width: 760px; margin: 0 auto; padding: 0 32px 120px; position: relative; }
.icon-wrap { position: relative; margin-top: -32px; height: 64px; }
#icon { width: 64px; height: 64px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--accent); font-size: 30px; line-height: 1; transition: background .2s; }
#icon:hover { background: var(--accent-soft); }
#icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#icon-picker { position: absolute; top: 72px; left: 0; z-index: 30; background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
#icon-picker[hidden] { display: none; }
#icon-picker button { background: none; border: 0; border-radius: var(--r-xs); width: 38px; height: 38px; display: grid; place-items: center; color: var(--muted); }
#icon-picker button:hover { background: var(--accent-soft); color: var(--accent); }
#icon-picker svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#title { width: 100%; border: 0; outline: none; resize: none; background: transparent; font: 700 36px/1.15 var(--f); letter-spacing: -.035em; padding: 12px 0 0; overflow: hidden; color: var(--ink); }
#title::placeholder { color: var(--faint); opacity: .5; }
.meta { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
#raw { display: none; width: 100%; min-height: 60vh; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 16px; background: var(--code-bg); color: var(--code-ink); font: 13px/1.6 var(--f-mono); resize: vertical; outline: none; }
body.raw #raw { display: block; }
body.raw #editor { display: none; }

/* editor */
.tiptap { outline: none; min-height: 40vh; font-size: 15px; line-height: 1.7; }
.tiptap > * + * { margin-top: .7em; }
.tiptap h1 { font: 700 1.85em/1.2 var(--f); letter-spacing: -.03em; margin: 1.5em 0 .3em; }
.tiptap h2 { font: 600 1.45em/1.25 var(--f); letter-spacing: -.025em; margin: 1.4em 0 .3em; }
.tiptap h3 { font: 600 1.15em/1.35 var(--f); letter-spacing: -.015em; margin: 1.2em 0 .2em; }
.tiptap p { margin: 0; }
.tiptap a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.tiptap mark { background: var(--mark); color: inherit; border-radius: 4px; padding: 0 2px; }
.tiptap code { background: var(--code-bg); color: var(--code-ink); border-radius: 6px; padding: .12em .4em; font: .88em var(--f-mono); }
.tiptap pre { background: var(--pre-bg); color: var(--pre-ink); border-radius: var(--r-sm); padding: 14px 16px; overflow: auto; }
.tiptap pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.tiptap blockquote { margin-left: 0; padding: 2px 0 2px 16px; border-left: 3px solid var(--accent); color: var(--muted); }
.tiptap hr { border: 0; border-top: 1px 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: 2px; }
.tiptap ul[data-type="taskList"] li { display: flex; gap: 10px; 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: 16px; height: 16px; 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); opacity: .6; }
.tiptap ::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.ProseMirror-selectednode { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* table */
.tiptap table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; margin: .9em 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.tiptap th, .tiptap td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px 12px; vertical-align: top; position: relative; min-width: 60px; }
.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: 600; }
.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: -2px; top: 0; bottom: 0; width: 4px; background: var(--accent); pointer-events: none; }
.tableWrapper { overflow-x: auto; }
.resize-cursor { cursor: col-resize; }

/* callout — semantic colors from the DS: note=info, tip=accent, important=ink, warning=warning, caution=error */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid color-mix(in srgb, var(--c-edge) 35%, var(--surface)); background: var(--c-bg); margin: .9em 0; }
.callout > .callout-body { flex: 1; min-width: 0; }
.callout-icon { border: 0; background: none; padding: 0; margin-top: 2px; align-self: flex-start; color: var(--c-fg); width: 22px; height: 22px; display: grid; place-items: center; user-select: none; transition: transform .15s; }
.callout-icon:hover { transform: scale(1.12); }
.callout-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; 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); }

/* drag handle */
.drag-handle { display: grid; place-items: center; width: 22px; height: 26px; border-radius: 6px; color: var(--muted); cursor: grab; transition: background .15s; }
.drag-handle:hover { background: var(--accent-soft); color: var(--accent); }
.drag-handle:active { cursor: grabbing; }
.drag-handle.hide { opacity: 0; pointer-events: none; }

/* bubble menu */
.bubble { visibility: hidden; position: absolute; top: 0; left: 0; display: flex; gap: 2px; background: var(--solid); color: var(--solid-ink); border-radius: var(--r-sm); padding: 4px; box-shadow: var(--pop); z-index: 40; }
.bubble button { border: 0; background: none; color: inherit; min-width: 30px; height: 30px; border-radius: 8px; font-size: 13px; display: grid; place-items: center; }
.bubble button:hover { background: color-mix(in srgb, var(--solid-ink) 16%, transparent); }
.bubble button.on { background: var(--accent); color: var(--accent-ink); }
.bubble svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bubble .b-bold { font-weight: 700; } .bubble .b-italic { font-style: italic; } .bubble .b-underline { text-decoration: underline; } .bubble .b-strike { text-decoration: line-through; }
.bubble .b-code { font-family: var(--f-mono); font-size: 12px; }

/* slash menu */
.slash-menu { position: fixed; z-index: 60; width: 300px; max-height: 340px; overflow: auto; background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 8px; }
.slash-item { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-sm); }
.slash-item.active { background: var(--accent-soft); }
.slash-glyph { width: 34px; height: 34px; flex: none; border-radius: var(--r-xs); display: grid; place-items: center; background: var(--chip-bg); color: var(--chip-ink); font-weight: 600; font-size: 13px; }
.slash-item.active .slash-glyph { background: var(--accent); color: var(--accent-ink); }
.slash-glyph svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slash-item b { display: block; line-height: 1.2; font-weight: 600; }
.slash-item small { color: var(--muted); }
.slash-empty { color: var(--muted); padding: 10px; }

/* right: outline and history */
.outline { width: 220px; padding: 84px 24px 0 8px; overflow: auto; }
.outline[hidden] { display: none; }
.outline h4 { margin: 0 0 10px; font: 600 12px/1 var(--f); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.outline-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 2px solid var(--line); padding: 4px 10px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s, border-color .2s; }
.outline-item:hover { color: var(--accent); border-left-color: var(--accent); }
.outline-item.level-2 { padding-left: 22px; } .outline-item.level-3 { padding-left: 34px; }

.history { position: fixed; top: var(--gap); right: var(--gap); bottom: var(--gap); width: min(340px, 90vw); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 20px 18px; transform: translateX(calc(100% + 32px)); visibility: hidden; box-shadow: none; transition: transform .25s ease, visibility 0s .25s, box-shadow 0s .25s; z-index: 50; overflow: auto; }
body.history-open #history, body.info-open #info, body.sharing-open #sharing, body.ownerless-open #ownerless, body.shared-open #shared, body.ask-open #ask { transform: none; visibility: visible; box-shadow: var(--pop); transition: transform .25s ease, visibility 0s, box-shadow 0s; }
/* The Ask drawer: the same family as the drawers above; its inside is drawn by examples/shared/ask-panel.js. */
.ask-drawer { position: fixed; top: var(--gap); right: var(--gap); bottom: var(--gap); width: min(420px, 94vw); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); padding: 0; transform: translateX(calc(100% + 32px)); visibility: hidden; transition: transform .25s ease, visibility 0s .25s, box-shadow 0s .25s; z-index: 50; overflow: hidden; }
#ask-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
body.booting #ask-toggle { display: none; }
.history h3 { margin: 0 0 4px; font: 600 16px/1.3 var(--f); }
.history .close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: var(--r-xs); border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; color: var(--ink); }
.history .close:hover { background: var(--accent-soft); }
.history .close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.history ul { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.history li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--well); }
.history li b { display: block; line-height: 1.3; font-weight: 600; }
.history li small { color: var(--muted); }
.ghost { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-xs); padding: 4px 12px; font-size: 13px; font-weight: 500; }
.ghost:hover { background: var(--accent-soft); color: var(--accent); }

/* modal and palette */
dialog { border: 0; padding: 0; background: transparent; color: inherit; }
dialog::backdrop { background: var(--scrim, rgba(0, 19, 36, .45)); } /* lint-allow: ::backdrop does not inherit custom properties in every browser, so it keeps a literal fallback */
.modal form { width: min(440px, 92vw); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 20px; display: grid; gap: 12px; }
.modal h3 { margin: 0; font: 600 16px/1.3 var(--f); }
.modal label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.modal input { height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 12px; background: var(--well); color: var(--ink); outline: none; }
.modal select { height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 10px; background: var(--well); color: var(--ink); outline: none; }
.modal select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal select:disabled { opacity: .75; }
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal .error { margin: 0; color: var(--bad); font-size: 13px; min-height: 1em; }
.row { display: flex; gap: 8px; } .row.end { justify-content: flex-end; }
.modal .primary { background: var(--primary); border: 1px solid var(--primary); color: var(--primary-ink); border-radius: var(--r-sm); height: 40px; padding: 0 16px; font-weight: 600; }
.palette { margin: 14vh auto 0; width: min(560px, 92vw); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); overflow: hidden; }
.palette[open] { display: block; }
#palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 16px 18px; font-size: 16px; outline: none; color: var(--ink); }
#palette-list { max-height: 50vh; overflow: auto; padding: 8px; }
.palette-row { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: none; border: 0; border-radius: var(--r-sm); padding: 9px 12px; }
.palette-row .tree-icon { width: 34px; height: 34px; border-radius: var(--r-xs); background: var(--chip-bg); color: var(--chip-ink); }
.palette-row .tree-icon svg { width: 18px; height: 18px; }
.palette-row.active, .palette-row:hover { background: var(--accent-soft); }
.palette-row.active .tree-icon, .palette-row:hover .tree-icon { background: var(--accent); color: var(--accent-ink); }
.palette-row b { display: block; line-height: 1.2; font-weight: 600; } .palette-row small { color: var(--muted); }

/* thin scrollbars */
.scroll, .tree, .outline, .slash-menu, #palette-list, .history { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* responsive */
/* the tools are icon buttons at every width (the name is the tooltip and the aria label): the whole bar stays on one row beside the outline */
.tool:not(.primary) span { display: none; } .tool:not(.primary) { width: 40px; padding: 0; justify-content: center; }
@media (max-width: 1280px) { .app { grid-template-columns: 248px minmax(0, 1fr); } .outline { display: none; } }
@media (max-width: 1560px) { .user div { display: none; } }
@media (max-width: 1280px) { .topbar-actions { gap: 8px; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 290px; padding: var(--gap); z-index: 55; background: var(--side-page); transform: translateX(-105%); transition: transform .25s; box-shadow: var(--pop); }
  body.nav-open .sidebar { transform: none; }
  .nav-toggle { display: grid; }
  .topbar { padding: 12px 12px 0; margin-bottom: 16px; gap: 8px; }
  .tool:not(.primary) { display: none; } /* their actions live in the "..." menu (overflow.js) */
  .icon-btn.more-toggle { display: grid; }
  body.no-page .icon-btn.more-toggle { display: none; } /* no page open: nothing to offer */
  .status { display: none; }
  .user div { display: none; }
  .scroll { margin: 0 12px 12px; }
  .page { padding: 0 18px 110px; }
  #title { font-size: 28px; }
  .cover { height: 100px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* links: what they point at */
.tiptap a { cursor: pointer; }
.tiptap a:has(.lk-internal) { text-decoration: none; background: var(--accent-soft); border-radius: 6px; padding: 0 5px; 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: .7; }
.tiptap a:has(.lk-broken) { color: var(--bad); text-decoration: underline dashed; text-underline-offset: 3px; }
.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: 70; width: 320px; max-width: calc(100vw - 16px); background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 10px; display: grid; gap: 8px; }
.lc-what { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lc-what .ico { width: 34px; height: 34px; border-radius: var(--r-xs); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.link-card.broken .lc-what .ico { background: var(--bad-bg); color: var(--bad); }
.lc-what .ico svg, .lc-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lc-text { min-width: 0; }
.lc-text b { display: block; font-weight: 600; line-height: 1.25; 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: 6px; }
.lc-btn { flex: 1 1 auto; white-space: nowrap; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-xs); font-weight: 500; font-size: 13px; color: var(--ink); transition: background .2s, color .2s; }
.lc-btn:hover { background: var(--accent-soft); color: var(--accent); }
.lc-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }

.link-dialog form { width: min(480px, 92vw); }
.suggest { list-style: none; margin: -2px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); max-height: 240px; overflow: auto; background: var(--surface); }
.suggest[hidden] { display: none; }
.suggest li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-xs); cursor: pointer; }
.suggest li.active { background: var(--accent-soft); }
.suggest .ico { width: 30px; height: 30px; border-radius: 8px; background: var(--chip-bg); color: var(--chip-ink); display: grid; place-items: center; flex: none; }
.suggest li.active .ico { background: var(--accent); color: var(--accent-ink); }
.suggest .ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.suggest .what { min-width: 0; display: grid; }
.suggest b { font-weight: 600; line-height: 1.25; }
.suggest small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-dialog .row .grow { flex: 1; }
#info-body h6 { margin: 14px 0 6px; font: 600 12px/1 var(--f); color: var(--muted); }
#info-body li.missing b { color: var(--muted); }
#info-body li .ghost { flex: none; }

/* the editing lock: banner on top of the page tile (sticky), chips in the meta line, lock mark in the tree, toast */
.lock-banner { position: sticky; top: 0; z-index: 35; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; padding: 10px 16px; background: var(--accent-soft); border: 0; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, var(--surface)); border-radius: calc(var(--r) - 1px) calc(var(--r) - 1px) 0 0; color: var(--ink); }
.lock-banner[hidden] { display: none; }
.lock-banner[data-kind="took-over"], .lock-banner[data-kind="lost-elsewhere"], .lock-banner[data-kind="draft-changed"], .lock-banner[data-kind="deleted"], .lock-banner[data-kind="unavailable"] { background: var(--warn-bg); border-color: color-mix(in srgb, var(--edge-warn) 45%, var(--surface)); }
.lock-banner .ico { width: 28px; height: 28px; border-radius: var(--r-xs); background: var(--surface); color: var(--accent); display: grid; place-items: center; flex: none; }
.lock-banner[data-kind="took-over"] .ico, .lock-banner[data-kind="lost-elsewhere"] .ico, .lock-banner[data-kind="draft-changed"] .ico, .lock-banner[data-kind="deleted"] .ico, .lock-banner[data-kind="unavailable"] .ico { color: var(--warn-fg); }
.lock-banner .ico svg, .meta-chip .ico svg, .tree-lock svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lock-banner .ico svg { width: 16px; height: 16px; }
.lb-text { flex: 1 1 260px; min-width: 0; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.lb-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; flex: none; }
.lb-pill { flex: none; padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font: 600 11px/1.6 var(--f); letter-spacing: .04em; text-transform: uppercase; }
.lb-btn { flex: none; height: 34px; padding: 0 14px; border-radius: var(--r-xs); font-size: 13px; font-weight: 500; }
.lb-btn.primary { background: var(--primary); border: 1px solid var(--primary); color: var(--primary-ink); font-weight: 600; }
.lb-btn.primary:hover { filter: brightness(1.12); }
.lb-btn:disabled { opacity: .6; cursor: progress; }
.meta-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; margin-left: 8px; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink); font-size: 12px; font-weight: 500; vertical-align: 1px; }
.meta-chip.mine { background: var(--accent-soft); color: var(--accent); }
.meta-chip.mine { height: auto; min-height: 24px; padding-block: 2px; }
.chip-btn { flex: none; white-space: nowrap; height: 20px; margin: 0 -4px 0 2px; padding: 0 9px; border-radius: 999px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); color: var(--ink); font: 500 11px/1 var(--f); cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.meta-chip .ico { display: grid; place-items: center; }
.meta-chip .ico svg { width: 13px; height: 13px; }
.tree-lock { display: none; width: 14px; height: 14px; flex: none; margin-left: auto; place-items: center; }
.tree-lock svg { width: 14px; height: 14px; }
.tree-row[data-lock="1"] .tree-lock { display: grid; }
.tree-row[data-lock="1"] .tree-dot { margin-left: 6px; }
#title[readonly] { cursor: default; }
#icon:disabled, .cover button:disabled { cursor: not-allowed; }
#icon:disabled:hover { background: var(--surface); }
.cover:hover button:disabled { opacity: .65; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; transform: translateX(-50%); max-width: min(480px, calc(100vw - 32px)); padding: 10px 16px; border-radius: var(--r-sm); background: var(--solid); color: var(--solid-ink); box-shadow: var(--pop); font-weight: 500; animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (max-width: 860px) { .lock-banner { padding: 10px 12px; } .lb-actions { width: 100%; justify-content: flex-start; margin-left: 0; } .meta-chip { margin: 6px 8px 0 0; } }

/* where a summary came from: its own line under the heading, wrapping anywhere it has to */
#info-body .provenance { margin: -2px 0 8px; font-size: 12px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }

/* No page open (the last one was deleted): only the way to start a new one. */
.empty-state { display: none; }
.boot-state { display: none; }
body.no-page .empty-state { display: grid; justify-items: center; gap: 8px; padding: 18vh 24px 0; text-align: center; }
.empty-state h2 { margin: 0; font: 600 20px/1.3 var(--f); }
.empty-state p { margin: 0 0 8px; }
body.no-page .page, body.no-page .cover, body.no-page .lock-banner, body.no-page .sync-wrap, body.no-page .topbar .tool { display: none; }

/* department folders: the owner next to the name, the note under an empty one you own, and the hand over action */
.tree li { position: relative; }
.tree-owner { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--muted); flex: none; }
.tree-row.active .tree-owner { color: inherit; }
.tree-note { margin: -2px 0 4px 36px; font-size: 12px; color: var(--muted); }
.tree-action { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; display: none; place-items: center; border: 0; border-radius: var(--r-xs); background: var(--surface); color: var(--muted); }
.tree-action.second { right: 34px; }
.tree-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tree li:hover > .tree-action, .tree li:focus-within > .tree-action { display: grid; }
.tree-action:hover, .tree-action:focus-visible { background: var(--accent-soft); color: var(--accent); }
@media (hover: none) { .tree-action { display: grid; } }
.tool[hidden] { display: none; }

/* deleting a department folder: the right-click menu, the pages listed in the confirmation and the danger button */
.tree-menu { position: fixed; z-index: 60; min-width: 180px; background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 6px; display: grid; }
.tree-menu-item { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-sm); }
.tree-menu-item:hover, .tree-menu-item:focus-visible { background: var(--accent-soft); color: var(--accent); }
.modal .folder-pages { margin: 0; padding-left: 18px; max-height: 40vh; overflow: auto; font-size: 13px; }
.modal .primary.danger { background: var(--bad); border-color: var(--bad); color: var(--bad-bg); }
.modal .primary.danger:hover { filter: brightness(1.12); }
.modal .primary:disabled { opacity: .6; cursor: progress; }

/* sharing: who has access, in the right-hand drawer (read-only); the "Shared" mark on a page and on a folder row */
.meta-chip[hidden] { display: none; }
.tree-action.third { right: 64px; }
.tree-action.fourth { right: 94px; }
.tree-shared { display: grid; place-items: center; flex: none; margin-left: auto; color: var(--muted); }
.tree-owner + .tree-shared { margin-left: 6px; }
.tree-shared svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tree-row.active .tree-shared { color: inherit; }
#sharing-target { margin: 0 0 4px; overflow-wrap: anywhere; }
#sharing-body h5 { margin: 18px 0 8px; font: 600 11px/1 var(--f); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
#sharing-body ul { margin-top: 0; }
#sharing-body li { display: grid; justify-content: stretch; align-items: start; gap: 6px; }
#sharing-body .who b { overflow-wrap: anywhere; }
#sharing-body .who small, #sharing-body .grant small { display: block; }
#sharing-body .chips { display: flex; flex-wrap: wrap; gap: 6px; }
#sharing-body .empty-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
#sharing-body .err-row { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-xs); background: var(--bad-bg); color: var(--bad); font-size: 13px; }
#sharing-body .err-row + .row { margin-top: 10px; }

/* sharing: add a person or the whole company, change an access (reuses the drawer's colours and shapes) */
#sharing-add { display: grid; gap: 8px; margin-top: 4px; }
#sharing-add h5 { margin: 14px 0 0; font: 600 11px/1 var(--f); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
#sharing .people-search, #ownerless .people-search { width: 100%; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 12px; background: var(--well); color: var(--ink); outline: none; }
#sharing .people-search:focus, #ownerless .people-search:focus, #sharing .choice-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
#sharing .small, #ownerless .small { font-size: 12.5px; margin: 0; }
#sharing .people-list, #ownerless .people-list { display: grid; gap: 2px; }
#sharing .person, #ownerless .person { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: var(--r-xs); }
#sharing .person:hover, #sharing .person.active, #ownerless .person:hover, #ownerless .person.active { background: var(--accent-soft); color: var(--accent); }
#sharing .avatar, #ownerless .avatar { flex: none; min-width: 28px; height: 28px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink); font-size: 11.5px; font-weight: 600; }
#sharing .picked { display: flex; align-items: center; gap: 10px; }
#sharing .picked b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#sharing .choice { display: grid; gap: 6px; }
#sharing .choice-select { height: 34px; width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r-xs); padding: 0 8px; background: var(--well); color: var(--ink); }
#sharing .caps { display: grid; gap: 4px; }
#sharing .cap { display: flex; align-items: center; gap: 8px; font-size: 13px; }
#sharing .cap:has(input:disabled) { color: var(--muted); }
#sharing .choice small { display: block; }
#sharing .grant-edit { display: grid; gap: 6px; }
#sharing .primary-btn { background: var(--primary); border: 1px solid var(--primary); color: var(--primary-ink); border-radius: var(--r-sm); height: 36px; padding: 0 16px; font-weight: 600; }
#sharing .primary-btn:disabled, #sharing button.ghost:disabled { opacity: .6; cursor: progress; }
#sharing-add .err-row { margin: 0; padding: 10px 12px; border-radius: var(--r-xs); background: var(--bad-bg); color: var(--bad); font-size: 13px; }
.toast-action { margin-left: 12px; border: 0; background: none; padding: 0; color: inherit; font-weight: 600; text-decoration: underline; }

/* items without an owner: the tree-header entry with its count, and the drawer's rows (reuse the sharing drawer's colours and shapes) */
.ownerless-badge, .shared-badge { position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font: 600 10px/16px var(--f); text-align: center; pointer-events: none; }
#ownerless-body li { display: grid; justify-content: stretch; align-items: start; gap: 8px; }
#ownerless-body .who b { overflow-wrap: anywhere; }
#ownerless-body .who small { display: block; }
#ownerless-body .owner-picker { display: grid; gap: 8px; }
#ownerless-body .empty-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
#ownerless-body .err-row { margin: 0; padding: 10px 12px; border-radius: var(--r-xs); background: var(--bad-bg); color: var(--bad); font-size: 13px; }
#ownerless button.ghost:disabled { opacity: .6; cursor: progress; }

/* pages shared with me: the drawer's rows, the read-only view of a page opened by id, and a related page the person may not see */
#shared-body li small { display: block; }
#shared-body li.current { background: var(--accent-soft); }
#shared-body .empty-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
body.shared-view .cover, body.shared-view .icon-wrap, body.shared-view .sync-wrap, body.shared-view .topbar .tool:not(#export) { display: none; }
#info-body li.restricted { justify-content: flex-start; color: var(--muted); font-size: 13px; }
#info-body li.restricted .ico { display: grid; place-items: center; }
#info-body li.restricted .ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* before the server has answered: a neutral loading state, nothing of the wiki (see boot.js) */
body.booting .boot-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 24vh 24px 0; color: var(--muted); }
body.booting .page, body.booting .cover, body.booting .empty-state, body.booting .lock-banner, body.booting .outline, body.booting .tree, body.booting .tree-filter, body.booting .tree-actions, body.booting .sync-wrap, body.booting .shared-flag, body.booting .topbar .tool { display: none; }

/* the full-page screens of a refused sign-in (gate.js): no access to the module, sign-in refused, account disabled */
.auth-screen { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: var(--bg); color: var(--ink); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(440px, 100%); display: grid; gap: 12px; justify-items: center; text-align: center; padding: 32px 24px; background: var(--elevated); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop); }
.auth-card h2 { margin: 0; font-size: 20px; }
.auth-card p { margin: 0; color: var(--muted); }
.auth-card .auth-note { font-size: 12px; }
.auth-card .row { justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.auth-screen[data-kind="disabled"] .auth-card h2, .auth-screen[data-kind="refused"] .auth-card h2 { color: var(--bad); }

/* the buttons of the empty state are text buttons at every width (the toolbar rules above shrink and hide every .tool that is not primary) */
.empty-state .tool:not([hidden]) { display: inline-flex; width: auto; padding: 0 14px; }

/* Dropdown arrow drawn here (the native one sits against the border): a chevron in the text colour with room on the right. */
.modal select, #sharing .choice-select {
  appearance: none;
  padding-inline-end: 2rem;
  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% - 0.8rem) 50%;
  background-size: 0.3rem 0.3rem;
  background-repeat: no-repeat;
}
