/* Telag Docs: tool layer on capita-webtools-ui v1. Core tokens come from the shared
   stylesheet and are never redefined here; local values build on them as --doc-*. */
:root { --doc-top: 60px; --doc-text: 68ch; --doc-wide: 772px; --doc-hit: color-mix(in srgb, var(--accent) 18%, transparent);
  --doc-flash: color-mix(in srgb, var(--accent) 7%, transparent); --doc-select: color-mix(in srgb, var(--accent) 14%, transparent); }
html { scroll-padding-top: 84px; }
body { background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 16px; height: 16px; flex: none; }
kbd { font-family: var(--mono); font-size: 11px; font-weight: 600; line-height: 16px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; white-space: nowrap; }
.muted { color: var(--muted); }
.loading { padding: 5rem; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.docs-app { min-height: 100vh; }
.cui-side { z-index: 30; }
.cui-brand img { max-width: 160px; }
.cui-brand img.docs-telag { height: 30px; }
.cui-nav { display: flex; flex-direction: column; padding: 12px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.cui-nav .cui-switcher { margin: 0 2px 12px; }
.cui-switcher .cui-chev { margin-left: auto; opacity: .6; width: 14px; height: 14px; }
.nav-items { display: flex; flex-direction: column; }
.nav-row { position: relative; display: flex; align-items: center; }
.cui-nav .nav-row .nav-link { flex: 1; min-width: 0; margin: 0; min-height: 34px; padding: 7px 28px 7px calc(12px + var(--depth, 0) * 14px); font-size: 13.5px; }
.cui-nav .nav-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cui-nav .nav-link .ic { opacity: .75; }
.cui-nav .nav-link.active .ic { opacity: 1; color: var(--cyan); }
.cui-nav .nav-link.active::before { left: -10px; }
.nav-more, .nav-add { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: rgba(255,255,255,.66); }
.nav-more { position: absolute; right: 5px; opacity: 0; }
.nav-row:hover .nav-more, .nav-more:focus-visible, .nav-row.active .nav-more { opacity: 1; }
.nav-more:hover, .nav-add:hover { background: var(--nav-hover); color: #fff; }
.nav-more .ic, .nav-add .ic { width: 15px; height: 15px; }
.nav-group { margin-top: 10px; }
.nav-sec { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 2px; }
.nav-sec-toggle { flex: 1; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.66); text-align: left; }
.nav-sec-toggle:hover { color: #fff; }
.nav-sec-toggle .ic { width: 13px; height: 13px; }
.nav-sec-actions { display: flex; gap: 1px; opacity: 0; }
.nav-sec:hover .nav-sec-actions, .nav-sec-actions:focus-within { opacity: 1; }
.nav-count { margin-left: auto; font-size: 10px; letter-spacing: 0; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; }
.cui-nav .nav-folder { color: var(--nav-ink); }
.cui-nav .nav-folder .ic { width: 14px; height: 14px; }
.cui-nav a.nav-open { padding: 0; margin: 0; width: 24px; height: 24px; display: grid; place-items: center; color: rgba(255,255,255,.66); }
.cui-nav a.nav-open:hover { background: var(--nav-hover); }
.nav-sub .nav-add { opacity: 0; }
.nav-sub:hover .nav-add { opacity: 1; }
.nav-new { padding: 6px 8px 8px; }
.nav-new input { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; font-size: 13px; }
.nav-new input::placeholder { color: rgba(255,255,255,.6); }
.nav-new small { display: block; margin-top: 4px; font-size: 11px; color: rgba(255,255,255,.64); }
.nav-create { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 8px 12px; border-radius: 8px; color: var(--nav-ink); font-size: 13px; border: 1px dashed rgba(255,255,255,.22); }
.nav-create:hover { background: var(--nav-hover); color: #fff; }
.nav-empty { padding: 8px 12px; color: rgba(255,255,255,.7); font-size: 13px; }
.side-foot { padding: 12px 22px; border-top: 1px solid var(--nav-line); font-size: 11px; letter-spacing: .06em; color: rgba(255,255,255,.64); }

.cui-topbar { height: var(--doc-top); padding: 0 26px; gap: 12px; }
.cui-crumb { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.cui-crumb .ic { width: 13px; height: 13px; opacity: .55; }
.cui-crumb a { color: var(--muted); }
.cui-crumb b { overflow: hidden; text-overflow: ellipsis; }
.search-trigger { display: flex; align-items: center; gap: 10px; width: 300px; height: 36px; padding: 0 8px 0 12px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: 13.5px; text-align: left; }
.search-trigger span { flex: 1; }
.search-trigger:hover { border-color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn .ic { width: 18px; height: 18px; }
.avatar-btn { display: flex; align-items: center; gap: 4px; padding: 2px 4px 2px 2px; border-radius: 999px; color: var(--muted); }
.avatar-btn:hover { background: var(--hover); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  font-size: 12px; font-weight: 700; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  padding: 3px 10px; border-radius: 999px; }
:root[data-theme="dark"] .mode-pill { color: var(--accent); }
.mode-pill .ic { width: 13px; height: 13px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.status-pill .ic { width: 14px; height: 14px; }
.status-pill.is-dirty, .status-pill.is-local, .status-pill.is-uploading { background: var(--warn-bg); color: var(--warn-ink); }
.status-pill.is-saved { background: var(--ok-bg); color: var(--ok-ink); }
.status-pill.is-saving { background: var(--info-bg); color: var(--info-ink); }
.status-pill.is-conflict { background: var(--bad-bg); color: var(--bad-ink); }
.cui-btn { gap: 7px; }
.cui-btn .ic { width: 16px; height: 16px; }
.cui-btn kbd { margin-left: 2px; }
.cui-btn-primary kbd { background: transparent; color: var(--on-accent); border-color: color-mix(in srgb, var(--on-accent) 45%, transparent); }
.cui-btn-danger { color: var(--bad-ink); }
.is-editing .cui-topbar { box-shadow: inset 0 -2px 0 var(--accent); }
.docs-main { outline: none; }

/* ---------- Page ---------- */
.page-layout { display: flex; justify-content: center; align-items: flex-start; gap: 32px; padding: 26px 32px 96px; }
.page-layout.single { display: block; max-width: 924px; margin: 0 auto; }
.sheet { flex: 0 1 860px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 44px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.title-input { flex: 1; min-width: 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; border: 0; border-bottom: 1px dashed var(--border);
  background: transparent; padding: 0 0 4px; color: var(--ink); }
.title-input:focus { outline: none; border-bottom-color: var(--accent); }
.head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.page-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.page-meta span { display: inline-flex; align-items: center; gap: 6px; }
.page-meta .ic { width: 14px; height: 14px; }
.page-meta b { font-weight: 600; color: var(--ink-2); }
.page-meta .dot { color: var(--faint); }
.page-meta .reviewed { color: var(--ok-ink); }
.link-btn { color: var(--accent); font-weight: 500; padding: 0; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-sm); border: 1px solid; margin-bottom: 20px; font-size: 14px; }
.banner > .ic { margin-top: 2px; width: 18px; height: 18px; }
.banner p { margin: 4px 0 10px; color: var(--ink-2); }
.banner-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn-ink); }
.banner-bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad-ink); }

.format-bar { position: sticky; top: var(--doc-top); z-index: 8; display: flex; align-items: center; flex-wrap: nowrap; gap: 2px; min-height: 44px; overflow: hidden;
  margin: 0 -44px 20px; padding: 5px 40px; background: var(--surface-2); border-block: 1px solid var(--line); }
.format-bar select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--surface); font-size: 13px; }
.fmt { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-xs); color: var(--ink-2); }
.fmt:hover { background: var(--hover); color: var(--ink); }
.fmt.is-active { background: var(--accent-soft); color: var(--accent); }
.bar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.bar-hint { margin-left: auto; min-width: 0; padding-left: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmt, .format-bar select, .bar-sep { flex: none; }
.template-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 18px; font-size: 13px; color: var(--muted); }
.template-chips .cui-chip { display: inline-flex; align-items: center; gap: 6px; }
.template-chips .ic { width: 14px; height: 14px; }

/* ---------- Document ---------- */
.doc { font-size: 16px; line-height: 1.7; color: var(--ink); }
.doc .ProseMirror { outline: none; }
.doc .ProseMirror[contenteditable="true"] { min-height: 380px; }
.doc .ProseMirror > * { max-width: var(--doc-text); }
.doc .ProseMirror > .tableWrapper, .doc .ProseMirror > .code-block, .doc .ProseMirror > figure, .doc .ProseMirror > .uploading { max-width: var(--doc-wide); }
.doc p { margin: 0 0 14px; }
.doc h1, .doc h2, .doc h3 { position: relative; scroll-margin-top: 84px; letter-spacing: -.01em; color: var(--ink); }
.doc h1 { font-size: 22px; font-weight: 750; line-height: 1.3; margin: 40px 0 12px; }
.doc h2 { font-size: 20px; font-weight: 700; line-height: 1.3; margin: 36px 0 12px; }
.doc h3 { font-size: 16.5px; font-weight: 700; line-height: 1.4; margin: 26px 0 8px; }
.doc .ProseMirror > :first-child { margin-top: 0; }
.permalink { position: absolute; left: -28px; top: 50%; translate: 0 -50%; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  color: var(--faint); opacity: 0; transition: opacity var(--dur) var(--ease); }
.permalink .ic { width: 15px; height: 15px; }
.doc h1:hover .permalink, .doc h2:hover .permalink, .doc h3:hover .permalink, .permalink:focus-visible { opacity: 1; }
.permalink:hover { color: var(--accent); background: var(--hover); }
.ProseMirror[contenteditable="true"] .permalink { display: none; }
.doc ul, .doc ol { margin: 0 0 14px; padding-left: 24px; }
.doc li { margin: 4px 0; }
.doc li > p { margin: 0 0 4px; }
.doc li::marker { color: var(--muted); }
.doc a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.doc a:hover { text-decoration-color: currentColor; }
.doc .broken-link { text-decoration: line-through wavy var(--bad); }
.doc blockquote { margin: 14px 0 18px; padding: 2px 0 2px 16px; border-left: 3px solid var(--border); color: var(--ink-2); }
.doc hr { border: 0; height: 1px; background: var(--line); margin: 28px 0; }
.doc strong { font-weight: 650; }
.doc code { font-family: var(--mono); font-size: .875em; font-weight: 500; background: var(--surface-3); color: var(--ink); border: 1px solid transparent;
  border-radius: var(--r-xs); padding: 1px 6px; white-space: nowrap; overflow-wrap: normal; }
.ProseMirror:not([contenteditable="true"]) :not(pre) > code { cursor: copy; }
.ProseMirror:not([contenteditable="true"]) :not(pre) > code:hover { background: var(--hover); border-color: var(--border); }
.doc .code-long code, .doc code .code-long, .doc code.code-long { white-space: normal; overflow-wrap: anywhere; }
.doc td .env-badge { margin-right: 4px; }
.doc .flash { background: var(--doc-flash); box-shadow: -14px 0 0 var(--doc-flash), 14px 0 0 var(--doc-flash); transition: background 1.2s var(--ease); border-radius: 4px; }
::highlight(docs-hit) { background-color: var(--doc-hit); color: inherit; }
::highlight(docs-hit-current) { background-color: color-mix(in srgb, var(--accent) 38%, transparent); }
.doc a[data-target] { position: relative; }

/* Callouts */
.callout { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; margin: 14px 0 18px; padding: 12px 16px; border-radius: var(--r-sm);
  border: 1px solid; border-left-width: 3px; font-size: 15px; line-height: 1.65; }
.callout-icon { padding-top: 3px; }
.callout-icon .ic { width: 18px; height: 18px; }
.callout-head { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.callout-title { font-size: 13.5px; font-weight: 700; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-body p { margin-bottom: 8px; }
.callout-title-input { flex: 1; min-width: 120px; border: 0; border-bottom: 1px dashed currentColor; background: transparent; font-size: 13.5px; font-weight: 700; color: inherit; padding: 1px 0; }
.callout-title-input:focus { outline: none; }
.callout-kinds { display: flex; align-items: center; gap: 2px; }
.callout-kind, .callout-remove { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.callout-kind .ic, .callout-remove .ic { width: 13px; height: 13px; }
.callout-kind:hover, .callout-remove:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.callout-kind.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.callout-kind span { display: none; }
.callout-kind.on span { display: inline; }
.ProseMirror[contenteditable="true"] .callout-title { display: none; }
.ProseMirror:not([contenteditable="true"]) .edit-only { display: none !important; }
.callout-info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); border-left-color: var(--info); }
.callout-info .callout-icon, .callout-info .callout-title, .callout-info .callout-title-input { color: var(--info-ink); }
.callout-tip { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); border-left-color: var(--ok); }
.callout-tip .callout-icon, .callout-tip .callout-title, .callout-tip .callout-title-input { color: var(--ok-ink); }
.callout-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 38%, transparent); border-left-color: var(--warn); }
.callout-warn .callout-icon, .callout-warn .callout-title, .callout-warn .callout-title-input { color: var(--warn-ink); }
.callout-danger { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 32%, transparent); border-left-color: var(--bad); }
.callout-danger .callout-icon, .callout-danger .callout-title, .callout-danger .callout-title-input { color: var(--bad-ink); }
.callout code { background: color-mix(in srgb, var(--surface) 70%, transparent); }

/* Badges, tool chips */
.env-badge { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; line-height: 16px; border-radius: 999px;
  padding: 1px 8px; vertical-align: 1px; white-space: nowrap; user-select: none; }
.env-prod { background: var(--bad-bg); color: var(--bad-ink); }
.env-test { background: var(--warn-bg); color: var(--warn-ink); }
.env-dev { background: var(--info-bg); color: var(--info-ink); }
.ProseMirror[contenteditable="true"] .env-badge { cursor: pointer; }
.tool-chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: .85em; font-weight: 600; color: var(--accent) !important; text-decoration: none !important; vertical-align: baseline; white-space: nowrap; }
.tool-chip .ic { width: 13px; height: 13px; }
.tool-chip:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tool-chip.big { font-size: 13.5px; padding: 6px 12px; background: var(--surface); }
.tool-chip em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--warn-ink); background: var(--warn-bg); padding: 0 6px; border-radius: 999px; }

/* Code */
.code-block { margin: 10px 0 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }
.code-head { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 6px 4px 14px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.code-lang { font-family: var(--mono); font-weight: 600; text-transform: lowercase; }
.code-title { font-weight: 600; color: var(--ink-2); }
.code-lang:not([hidden]) + .code-title:not([hidden])::before { content: '·'; margin-right: 8px; color: var(--faint); }
.code-language, .code-title-input { height: 26px; border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--surface); font-size: 12px; padding: 0 6px; }
.code-title-input { flex: 1; min-width: 120px; }
.code-copy { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.code-copy:hover { background: var(--hover); color: var(--ink); }
.code-copy .ic { width: 14px; height: 14px; }
.code-block pre { margin: 0; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--ink); white-space: pre; overflow-x: auto; tab-size: 2; }
.code-block code { background: none; border: 0; padding: 0; font-size: inherit; white-space: inherit; }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--muted); font-style: italic; }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-attr, .hljs-attribute, .hljs-property { color: var(--info-ink); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--ok-ink); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--warn-ink); }
.hljs-variable, .hljs-template-variable, .hljs-deletion { color: var(--bad-ink); }
.hljs-title, .hljs-section, .hljs-name { color: var(--ink); font-weight: 600; }

/* Tables */
.tableWrapper { margin: 4px 0 18px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.55; table-layout: auto; }
.doc th, .doc td { position: relative; padding: 10px 14px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; min-width: 60px; overflow-wrap: break-word; }
.doc th { font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border-top: 0; border-bottom: 1px solid var(--border); }
.doc tr:first-child td { border-top: 0; }
.doc td > p, .doc th > p { margin: 0; }
.doc td > p + p, .doc th > p + p { margin-top: 6px; }
.doc .selectedCell::after { content: ''; position: absolute; inset: 0; background: var(--doc-select); pointer-events: none; }
.doc .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; background: var(--accent); pointer-events: none; }
.doc.resize-cursor, .resize-cursor { cursor: col-resize; }

/* Media */
.media-block { position: relative; margin: 14px 0 18px; }
.media-block.w-s { width: 40%; } .media-block.w-m { width: 60%; } .media-block.w-l { width: 80%; } .media-block.w-full { width: 100%; }
.media-frame { display: flex; justify-content: center; border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.media-frame img { display: block; max-width: 100%; max-height: 640px; height: auto; object-fit: contain; cursor: zoom-in; }
.ProseMirror[contenteditable="true"] .media-frame img { cursor: default; }
.media-block.is-selected .media-frame { outline: 2px solid var(--accent); outline-offset: 2px; }
.media-caption { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 2px 0; font-size: 13px; color: var(--muted); }
.media-caption-text:empty { display: none; }
.ProseMirror[contenteditable="true"] .media-caption-text { display: none; }
.media-caption-input { flex: 1; min-width: 200px; border: 0; border-bottom: 1px dashed var(--border); background: transparent; font-size: 13px; padding: 2px 0; color: var(--ink-2); }
.media-caption-input:focus { outline: none; border-bottom-color: var(--accent); }
.media-actions { display: inline-flex; gap: 4px; margin-left: auto; }
.media-link { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.media-link:hover { background: var(--hover); color: var(--ink); }
.media-link .ic { width: 14px; height: 14px; }
.media-bar { position: absolute; top: 8px; left: 8px; z-index: 3; display: none; align-items: center; gap: 2px; padding: 3px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); }
.ProseMirror[contenteditable="true"] .media-block.is-selected .media-bar, .ProseMirror[contenteditable="true"] .media-block:hover .media-bar { display: flex; }
.media-bar button { height: 28px; min-width: 28px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.media-bar button:hover, .media-bar .on { background: color-mix(in srgb, var(--surface) 22%, transparent); }
.media-bar .bar-sep { background: color-mix(in srgb, var(--surface) 30%, transparent); margin: 0 3px; }
.media-bar .ic { width: 15px; height: 15px; }
:root[data-theme="dark"] .media-bar { background: var(--surface-3); color: var(--ink); border: 1px solid var(--border); }
:root[data-theme="dark"] .media-frame img { filter: brightness(.92); }
.uploading { margin: 14px 0; padding: 22px; border: 2px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: 13px; text-align: center;
  background: repeating-linear-gradient(-45deg, var(--surface-2) 0 10px, var(--surface) 10px 20px); background-size: 200% 100%; animation: upload-stripes 1.4s linear infinite; }
@keyframes upload-stripes { to { background-position: 56px 0; } }
.ProseMirror .is-editor-empty:first-child::before, .ProseMirror p.is-empty:first-child:last-child::before { content: attr(data-placeholder); float: left; height: 0; color: var(--faint); pointer-events: none; }

/* Floating editor UI */
.editor-menu { position: absolute; z-index: 60; width: 320px; max-height: 360px; overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.menu-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border-radius: var(--r-xs); text-align: left; font-size: 13.5px; }
.menu-item.on, .menu-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.menu-item .ic { color: var(--muted); }
.menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-label small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.float-bar { position: fixed; z-index: 40; display: flex; gap: 2px; padding: 3px; border-radius: var(--r-sm); background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); }
.float-bar button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.float-bar button:hover { background: color-mix(in srgb, var(--surface) 22%, transparent); }
.float-bar .ic { width: 15px; height: 15px; }
.float-bar span { display: none; }
.float-bar button:hover span { display: inline; }
:root[data-theme="dark"] .float-bar { background: var(--surface-3); color: var(--ink); border: 1px solid var(--border); }
.pop-menu { position: fixed; z-index: 70; min-width: 230px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.menu-entry { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border-radius: var(--r-xs); font-size: 13.5px; text-align: left; color: var(--ink); }
.menu-entry:hover, .menu-entry:focus-visible { background: var(--hover); outline: none; }
.menu-entry .ic { color: var(--muted); }
.menu-entry span { flex: 1; }
.menu-entry.danger, .menu-entry.danger .ic { color: var(--bad-ink); }
.menu-heading { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.save-pop { width: 340px; padding: 14px; }
.pop-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 12px; }
.field-label { display: block; margin: 14px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-label:first-child { margin-top: 0; }

/* Rail */
.rail { flex: 0 0 220px; position: sticky; top: 86px; max-height: calc(100vh - 110px); overflow-y: auto; display: flex; flex-direction: column; gap: 22px; font-size: 13px; padding-bottom: 12px; scrollbar-width: thin; }
.rail-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.toc { display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 5px 0 5px 12px; margin-left: -1px; border-left: 2px solid transparent; line-height: 1.35; color: var(--muted); }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.lvl-1 { padding-left: 24px; }
.toc a.lvl-2 { padding-left: 36px; }
.toc a.on { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.backlinks { display: flex; flex-direction: column; gap: 6px; }
.backlinks a { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.backlinks .ic { width: 14px; height: 14px; color: var(--faint); }
.rail-hint { font-size: 12px; line-height: 1.8; color: var(--faint); }

/* Home */
.home { max-width: 1240px; margin: 0 auto; padding: 26px 32px 96px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.home-head h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.home-meta { margin-top: 4px; font-size: 14px; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.home-sheet { padding: 26px 32px 30px; }
.home-sheet .format-bar { margin: 0 -32px 20px; padding-inline: 28px; }
.home-sheet-head { margin-bottom: 14px; }
.home-doc-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.home-edit-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); }
.home-doc h2 { font-size: 18px; }
.home-doc .ProseMirror > ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: none; }
.home-doc .ProseMirror > ul > li { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.home-doc .ProseMirror > ul > li > p { margin: 0; }
.home-doc .ProseMirror > ul a { font-weight: 600; text-decoration: none; }
.home-doc .ProseMirror > ul [data-target]::after { content: attr(data-target); display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.home-doc .ProseMirror[contenteditable="true"] > ul { display: block; list-style: disc; padding-left: 24px; }
.home-doc .ProseMirror[contenteditable="true"] > ul > li { border: 0; background: none; padding: 0; }
.home-doc .ProseMirror[contenteditable="true"] > ul [data-target]::after { display: none; }
.home-side { display: flex; flex-direction: column; gap: 22px; }
.side-card { padding: 18px 20px; }
.side-card h2, .sec-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.link-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.link-list a { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.link-list small, .change-list small { display: block; margin-left: 24px; font-size: 12px; color: var(--muted); }
.change-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.change-list li { display: flex; gap: 10px; align-items: flex-start; }
.change-list a { font-weight: 600; color: var(--ink); }
.change-list small { margin-left: 0; }
.empty-note { font-size: 13px; color: var(--muted); }
.home-section { margin-top: 30px; }
.area-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.area-card { padding: 16px 18px; }
.area-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.area-card ul { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.area-card a { color: var(--ink-2); }
.tool-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Namensrechner */
.cui-nav .nav-tools { margin: 0 0 6px; }
.namer .cui-tabs { margin-bottom: 20px; }
.namer-grid { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.namer-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--doc-top) + 16px); }
.namer-form .cui-chips { gap: 6px; }
.namer-form .cui-chip { padding: 4px 10px; font-size: 12px; font-weight: 500; }
.namer-form .cui-chip b, .namer-form .cui-chip code { font-family: var(--mono); font-size: 11.5px; font-weight: 600; }
.namer-form .cui-chip .ic { width: 12px; height: 12px; }
.fld-title { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.mono, .cui-input.mono { font-family: var(--mono); }
.namer-hint { font-size: 12px; color: var(--muted); }
.namer-hint.fix { color: var(--warn-ink); }
.namer-hint code { font-size: 11.5px; }
.namer-custom { display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; gap: 6px; margin-top: 8px; }
.namer-custom .cui-select, .namer-custom .cui-input { padding: 6px 8px; font-size: 13px; }
.namer-options { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.namer-options[open] { gap: 12px; }
.namer-options summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.namer-options .cui-fld { margin-top: 10px; }
.namer-results { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.namer-results .banner { margin-bottom: 0; }
.namer-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 14px 18px; }
.namer-key { font: 700 19px var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.namer-meta { color: var(--muted); font-size: 13px; }
.namer-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 11px 16px 11px 18px; border-bottom: 1px solid var(--line); }
.namer-group-head h2 { font-size: 14.5px; font-weight: 700; }
.namer-pattern { font: 12px var(--mono); color: var(--ink-2); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; overflow-wrap: anywhere; }
.namer-note { padding: 10px 18px 0; font-size: 12.5px; color: var(--muted); max-width: 90ch; }
.namer-rows { padding: 6px 10px 10px; display: flex; flex-direction: column; }
.namer-rows .empty-note { padding: 8px; }
.namer-row { display: grid; grid-template-columns: minmax(130px, 230px) minmax(0, 1fr) auto; gap: 0 12px; align-items: center; padding: 3px 8px; border-radius: var(--r-sm); }
.namer-row:hover { background: var(--hover); }
.namer-label { font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.namer-name { justify-self: start; max-width: 100%; font: 500 13.5px var(--mono); color: var(--ink); text-align: left; overflow-wrap: anywhere; padding: 3px 6px; margin-left: -6px; border-radius: 6px; }
button.namer-name:hover { background: var(--doc-select); }
.namer-name.static { font-family: var(--sans); font-style: italic; color: var(--muted); }
.namer-row .icon-btn { width: 30px; height: 30px; }
.namer-row .icon-btn .ic { width: 15px; height: 15px; }
.namer-row small { grid-column: 2 / -1; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.namer-row.tone-warn .namer-name, .namer-row.tone-warn small { color: var(--warn-ink); }
.namer-check { display: flex; flex-direction: column; gap: 16px; max-width: 980px; }
.namer-check-input { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.namer-check-input .cui-input { font: 500 17px var(--mono); padding: 11px 13px; }
.namer-samples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.namer-samples span { margin-right: 4px; }
.namer-sample { font: 12px var(--mono); color: var(--ink-2); border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; }
.namer-sample:hover { border-color: var(--accent); color: var(--ink); }
.namer-explain { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.namer-explain-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.namer-explain-head h2 { font-size: 17px; font-weight: 700; }
.namer-segs { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 6px; }
.namer-seg { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.namer-seg code { font: 600 15px var(--mono); padding: 6px 10px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--border); overflow-wrap: anywhere; max-width: 100%; }
.namer-seg b { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.namer-seg small { font-size: 11.5px; color: var(--muted); text-align: center; }
.namer-dash { font: 600 15px var(--mono); color: var(--muted); padding-top: 7px; }
.namer-notes { display: flex; flex-direction: column; gap: 6px; padding: 0; margin: 0; list-style: none; }
.namer-notes li { position: relative; padding-left: 16px; font-size: 13.5px; color: var(--ink-2); }
.namer-notes li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.namer-notes li.is-alt::before { background: var(--warn); }
.namer-notes li.is-abw::before { background: var(--bad); }
.namer-key-line { font-size: 13px; color: var(--muted); }
.namer-explain.compact { padding: 12px 0 0; gap: 10px; }
.namer-explain.compact .namer-explain-head h2 { font-size: 14px; }
.namer-explain.compact .namer-seg code { font-size: 13px; padding: 4px 7px; }
.namer-explain.compact .namer-notes li { font-size: 12.5px; }
.namer-rules { display: flex; flex-direction: column; gap: 16px; }
.namer-rules .cui-table td { vertical-align: top; }
.namer-rules .cui-table td code { font-size: 12.5px; overflow-wrap: anywhere; }
.namer-rule-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.namer-rule-cols p { font-size: 13.5px; color: var(--ink-2); }
.namer-mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.namer-mini td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.namer-mini tr:last-child td { border-bottom: 0; }
.namer-mini td:last-child code { white-space: nowrap; }
.namer-legacy { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.namer-legacy code { font-size: 12px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
@media (max-width: 1100px) { .namer-grid { grid-template-columns: minmax(0, 1fr); } .namer-form { position: static; } }

/* Folder, admin */
.folder-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.folder-entry { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink); }
.folder-entry:first-child { border-top: 0; }
.folder-entry:hover { background: var(--hover); text-decoration: none; }
.folder-entry span { flex: 1; display: flex; flex-direction: column; }
.folder-entry small { font-size: 12px; color: var(--muted); }
.admin { max-width: 1180px; margin: 0 auto; padding: 26px 32px 96px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.admin-head h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.admin-head p { margin-top: 4px; color: var(--muted); font-size: 14px; max-width: 70ch; }
.toggle-line { margin-bottom: 14px; font-size: 13px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.asset-card { overflow: hidden; }
.asset-card .thumb { display: grid; place-items: center; width: 100%; height: 180px; background: var(--surface-2); border-bottom: 1px solid var(--line); overflow: hidden; }
.asset-card .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-info { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.asset-info h3 { font-size: 14px; overflow-wrap: anywhere; }
.asset-info p { font-size: 12.5px; color: var(--muted); }
.asset-info .cui-btn { align-self: flex-start; }
.list-card { overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 18px; border-top: 1px solid var(--line); text-align: left; }
.list-row:first-child { border-top: 0; }
.list-row > div { flex: 1; display: flex; flex-direction: column; }
.list-row small { font-size: 12.5px; color: var(--muted); }
.list-row.as-button:hover { background: var(--hover); }
.empty-state { padding: 36px; text-align: center; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 18px; }
.cui-stat p { margin-top: 6px; font-size: 12.5px; }
.cui-val.sm { font-size: 18px; }
.cui-stat.is-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.export-row { display: flex; align-items: center; gap: 18px; padding: 20px 22px; margin-bottom: 14px; }
.export-row > .ic { width: 26px; height: 26px; color: var(--accent); }
.export-row > div { flex: 1; }
.export-row h3 { font-size: 15px; margin-bottom: 4px; }
.export-row p { font-size: 13.5px; color: var(--muted); }
#export-progress:not(:empty) { margin: 14px 0; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 14px; }
#export-progress p { margin-bottom: 10px; }

/* Dialogs */
dialog#modal { margin: auto; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: 88vh; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog#modal::backdrop { background: rgba(10,14,20,.5); backdrop-filter: blur(2px); }
dialog.small-dialog { width: min(460px, calc(100vw - 32px)) !important; }
dialog.wide-dialog { width: min(1100px, calc(100vw - 40px)) !important; }
dialog.lightbox-dialog { width: min(1400px, calc(100vw - 40px)) !important; }
dialog.diagram-dialog { width: 96vw !important; height: 92vh; max-height: 92vh !important; }
.diagram-dialog iframe { display: block; width: 100%; height: calc(92vh - 58px); border: 0; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px 14px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px 22px; max-height: calc(88vh - 130px); overflow: auto; font-size: 14px; }
.modal-body > p { color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lightbox img { display: block; max-width: 100%; max-height: 76vh; margin: 0 auto; object-fit: contain; background: #fff; }
.asset-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.picker-tile { padding: 8px; border: 1px solid var(--border); border-radius: var(--r-sm); text-align: left; }
.picker-tile:hover { border-color: var(--accent); }
.picker-tile img { width: 100%; height: 100px; object-fit: contain; background: var(--surface-2); }
.picker-tile span { display: block; margin-top: 6px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-results { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; max-height: 260px; overflow: auto; }
.link-target { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-xs); text-align: left; }
.link-target:hover { background: var(--hover); }
.link-target span { display: flex; flex-direction: column; }
.link-target small { font-size: 12px; color: var(--muted); }
.shortcut-list { display: flex; flex-direction: column; gap: 8px; }
.shortcut-list div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.snapshot { max-height: 70vh; overflow: auto; }

/* Palette */
.palette-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(10,14,20,.5); backdrop-filter: blur(2px); }
.palette { position: absolute; top: 88px; left: 50%; translate: -50% 0; width: min(880px, calc(100vw - 48px)); max-height: min(580px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input .ic { width: 18px; height: 18px; color: var(--muted); }
.palette-input input { flex: 1; border: 0; background: transparent; font-size: 17px; outline: none; color: var(--ink); }
.palette-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.palette-filters { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.palette-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.palette-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-xs); border-left: 2px solid transparent; text-align: left; }
.palette-item .ic { margin-top: 3px; color: var(--muted); }
.palette-item.on { background: color-mix(in srgb, var(--accent) 8%, transparent); border-left-color: var(--accent); }
.pi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pi-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.pi-sub { font-size: 12.5px; color: var(--muted); }
.pi-text { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.palette mark, .pv-text mark { background: var(--doc-hit); color: inherit; border-radius: 3px; padding: 0 1px; }
.palette-preview { border-left: 1px solid var(--line); background: var(--surface-2); padding: 18px 20px; overflow-y: auto; }
.pv-path { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.pv-path b { color: var(--ink); }
.pv-path .ic { width: 14px; height: 14px; }
.pv-text { font-size: 14px; line-height: 1.65; color: var(--ink-2); white-space: pre-line; }
.pv-foot { margin-top: 14px; font-size: 12px; color: var(--muted); }
.palette-hint { font-size: 13px; color: var(--muted); }
.palette-empty { padding: 18px 12px; font-size: 13px; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.palette-foot kbd { margin-right: 2px; }

/* History drawer and diff */
.drawer-overlay { position: fixed; inset: 0; z-index: 75; background: rgba(10,14,20,.42); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(980px, 94vw); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lg); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head > div { flex: 1; }
.drawer-head h2 { font-size: 18px; font-weight: 700; }
.drawer-head p { font-size: 13px; color: var(--muted); }
.drawer-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.history-list { overflow-y: auto; padding: 8px; border-right: 1px solid var(--line); }
.history-row { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px; border-radius: var(--r-sm); text-align: left; border-left: 2px solid transparent; }
.history-row:hover { background: var(--hover); }
.history-row.on { background: color-mix(in srgb, var(--accent) 8%, transparent); border-left-color: var(--accent); }
.hr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.hr-main small { color: var(--muted); }
.hr-note { font-size: 12.5px; color: var(--ink-2); }
.hr-stats { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; font-style: normal; }
.hr-stats em { font-style: normal; font-weight: 600; }
.plus { color: var(--ok-ink); } .minus { color: var(--bad-ink); }
.history-event { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.history-event .ic { width: 14px; height: 14px; margin-top: 2px; }
.more-history { margin: 8px auto; display: flex; }
.history-detail { overflow-y: auto; padding: 18px 22px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.detail-head small { display: block; font-size: 12.5px; color: var(--muted); }
.diff-legend { display: flex; gap: 14px; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; color: var(--muted); }
.diff { display: flex; flex-direction: column; gap: 4px; }
.diff-block { padding: 8px 12px; border-left: 3px solid transparent; border-radius: 6px; font-size: 14px; line-height: 1.6; }
.diff-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-block.is-heading .diff-text { font-weight: 700; }
.diff-same { color: var(--ink-2); }
.diff-ins { background: var(--ok-bg); border-left-color: var(--ok); }
.diff-del { background: var(--bad-bg); border-left-color: var(--bad); }
.diff-del .diff-text { text-decoration: line-through; color: var(--bad-ink); }
.diff-changed { background: var(--surface-2); border-left-color: var(--warn); }
.diff ins { background: var(--ok-bg); color: var(--ok-ink); text-decoration: none; border-radius: 3px; }
.diff del { background: var(--bad-bg); color: var(--bad-ink); border-radius: 3px; }
.diff-kind { display: inline-block; margin-bottom: 2px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.diff-skip { padding: 4px 12px; font-size: 12px; color: var(--muted); }
.diff-empty { color: var(--muted); }

/* Toasts, banners, hit pill */
#toasts { position: fixed; right: 22px; bottom: 22px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
#toasts .cui-toast { pointer-events: auto; max-width: min(460px, calc(100vw - 44px)); }
.cui-toast .ic { width: 18px; height: 18px; color: var(--ok); }
.cui-toast.err .ic { color: var(--bad); }
.hit-pill { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 50; display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-lg); font-size: 13px; }
.hit-pill .icon-btn { width: 30px; height: 30px; }
.reauth-banner { position: fixed; left: 50%; bottom: 18px; translate: -50% 0; z-index: 1100; display: flex; align-items: center; gap: 16px; padding: 14px 16px;
  background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13.5px; }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: var(--bg); }
.login-card { width: min(480px, 100%); padding: 40px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.login-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.login-card h1 { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 4px; }
.login-message { padding: 18px 0; font-size: 14px; line-height: 1.7; color: var(--muted); }
.login-card .cui-btn { width: 100%; justify-content: center; }

@media (max-width: 1180px) {
  .rail { display: none; }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .search-trigger { width: 220px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print {
  .cui-side, .cui-topbar, .rail, .head-actions, .format-bar, .media-bar, .code-copy, .permalink, #toasts, .hit-pill, .home-side, .home-section, .home-head .head-actions { display: none !important; }
  .cui-app { display: block; }
  .page-layout, .home { padding: 0; }
  .sheet { border: 0; box-shadow: none; padding: 0; }
  .doc .ProseMirror > * { max-width: none; }
  .code-block pre { white-space: pre-wrap; }
}
