/* 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); }

/* ---------- the navigation panel: the tree of the wiki, in the panel the platform draws as tall as the page (data-ui-rail="content") ---------- */
/* its head («Pagine», «Nuova cartella», «Nuova pagina», the tree's own filter) is the kit's createTreeHead: its sizes, its place while the panel scrolls and
   its distance from the tree are the kit's (treehead.css). Here: the tree that scrolls, the two lists that are places */
.tree { margin: 0 calc(var(--ui-space-1) * -1); padding: 0 var(--ui-space-1); }
/* the parts of the tree are items of the panel's grid: they take its width and never widen it (a long title ends in "…") */
.tree, .tree-skeleton { min-width: 0; }
/* the tree itself is the kit's (createTree, variant «panel»): the wiki styles nothing of its rows */

/* ---------- the header row of the content panel (kit createPageHeader): where the page stands; its tools, the assistant, ONE primary, «⋯» ---------- */
.m-top { position: sticky; top: 0; z-index: var(--ui-z-sticky); background: var(--surface); }
.m-head { align-items: center; flex-wrap: nowrap; margin: 0; padding: var(--ui-space-3) var(--ui-space-4) var(--ui-space-3) var(--ui-space-5); }
.m-head .ui-page-header__text { display: flex; align-items: center; gap: var(--ui-space-2); min-width: 0; }
.m-head .ui-page-header__actions { flex-wrap: nowrap; }
.m-head-state { display: flex; align-items: center; gap: var(--ui-space-2); min-width: 0; }
.m-head-state > span:empty { display: none; }
.m-head-primary { display: contents; }
/* the page's own tools: square icons of the kit, 40 like every control, a quiet line before the assistant */
.m-tools { display: flex; align-items: center; gap: var(--ui-space-1); padding-inline-end: var(--ui-space-2); margin-inline-end: var(--ui-space-1); border-inline-end: var(--ui-border) solid var(--line); }
.shared-flag .ico { display: inline-grid; place-items: center; }
.shared-flag .ui-icon { width: var(--ui-icon-sm); height: var(--ui-icon-sm); }
#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; }
/* the page is saved as a version: the button keeps its place and is not seen, so the controls beside it do not move when it comes back (head.js saveSlot) */
#save-version.is-reserved { visibility: hidden; }
.shared-flag { flex: none; }
/* nothing of a page is offered while the first round with the server is on */
body.booting .m-head .ui-page-header__actions, body.booting .m-head-state { visibility: hidden; }

/* 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-2); color: var(--muted); 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); }
.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; z-index: var(--ui-z-dropdown); top: calc(100% + var(--ui-space-2)); left: 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); }

/* ---------- the content panel: cover, page, outline (the panel itself is the kit's) ---------- */
.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 { display: none; } } /* a touch screen has no tooltip to say why it is off */
.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: 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 side panel: History, Info, Sharing, Ask (one at a time, inside the kit's ui-aside__panel, which is the panel) ---------- */
.m-panel { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; outline: none; }
body.history-open #history, body.info-open #info, body.sharing-open #sharing, 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; }
body:not(.ask-open) #ask { display: none; } /* the shared panel sets its own display */
.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 { overflow-wrap: anywhere; }

/* Info */
#info-body 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 { 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 { color: var(--accent); }
#info-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); }
#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); }
.row { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); }
.row.end { justify-content: flex-end; }

/* Without an owner (the owner picker uses the kit: ui-input, ui-menu, ui-avatar). The Sharing drawer is drawn with the kit alone (see main.js renderSharing), nothing of it is styled here. */
#ownerless-body li { display: grid; justify-content: stretch; align-items: start; gap: var(--ui-space-2); }
#ownerless-body .who b { overflow-wrap: anywhere; }
#ownerless-body .who small { display: block; }

/* ---------- 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 .palette-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 .palette-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 .palette-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); }

/* ---------- the places that are not a page: a folder (or the top of the wiki), the pages shared with me, what has no owner ---------- */
.m-view { display: none; max-width: var(--m-page-width); margin: 0 auto; padding: var(--ui-space-2) var(--ui-space-8) var(--ui-space-16); }
body[data-place="folder"] #folder-view, body[data-place="shared-list"] #shared, body[data-place="ownerless"] #ownerless { display: block; }
body[data-place="folder"] :is(.doc, .cover, .empty-state), body[data-place="shared-list"] :is(.doc, .cover, .empty-state), body[data-place="ownerless"] :is(.doc, .cover, .empty-state) { display: none; }
.m-view__note { margin-bottom: var(--ui-space-4); color: var(--muted); font-size: var(--ui-text-sm); }
.m-view__note p { margin: 0; }
.m-rows, #ownerless-body ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--ui-space-1); }
.m-row { display: flex; align-items: center; gap: var(--ui-space-3); min-height: calc(var(--ui-unit) * 3.5); padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; transition: var(--hover); }
.m-row:hover { background: var(--ui-hover); }
.m-row:focus-visible { outline-offset: calc(var(--ui-focus-width) * -1); }
.m-row__icon { width: var(--ui-control-md); height: var(--ui-control-md); flex: none; display: grid; place-items: center; border-radius: var(--ui-radius-md); background: var(--chip-bg); color: var(--chip-ink); }
.m-row__icon .ui-icon { width: var(--ui-icon-md); height: var(--ui-icon-md); }
.m-row__text { min-width: 0; display: grid; }
.m-row__text b { font-weight: var(--ui-weight-semibold); line-height: var(--ui-leading-snug); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-row__text small { color: var(--muted); font-size: var(--ui-text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ownerless-body li { padding: var(--ui-space-3); border-radius: var(--r-sm); background: var(--well); }
#shared-body .empty-note, #folder-empty { margin-top: var(--ui-space-3); }

/* ---------- 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 { 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) {
  #save-version .opt { display: none; }
}
@media (max-width: 53.75em) {
  .page, .m-view { padding: 0 var(--ui-space-8) var(--ui-space-16); }
  .m-head { padding: var(--ui-space-2) var(--ui-space-2) var(--ui-space-2) var(--ui-space-3); }
  /* a phone: the page's tools are items of «⋯» (main.js moreItems) */
  #page-tools { display: none; }
  #title { font-size: var(--ui-text-2xl); }
  .cover { height: calc(var(--ui-unit) * 6.25); }
  .lock-banner .ui-banner__actions { width: 100%; }
}
@media (max-width: 35em) {
  .page, .m-view { padding: 0 var(--ui-space-4) var(--ui-space-12); }
  /* a phone: the state keeps its icon (its word is its name and tooltip), «Nuova pagina» its plus */
  .sync { width: var(--ui-control-md); padding: 0; justify-content: center; }
  .sync-label, #folder-new-page > span { display: none; }
  #folder-new-page { width: var(--ui-control-md); padding: 0; justify-content: center; }
  .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; }
}
