/* Tutorial hint dot (tutorialHints.tsx) — Discord-style pulsing "new!" badge.
   The host element must be position:relative. */
.tut-dot {
  position: absolute; top: -3px; right: -3px; width: 11px; height: 11px;
  border-radius: 50%; background: #f0b232;
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 8px color-mix(in srgb, #f0b232 70%, transparent);
  animation: tut-blink 1.5s ease-in-out infinite;
  z-index: 3; cursor: pointer;
}
@keyframes tut-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.78); }
}
@media (prefers-reduced-motion: reduce) {
  .tut-dot { animation: none; }
}
/* Charts — the team wiki (live co-edited pages). */

/* H3 toolbar button (icon-less; H1/H2 use FA glyphs). */
.ch-tool-h3 { font-size: 11px; font-weight: 800; letter-spacing: -0.5px; }
/* Highlight for a word jumped-to from search (CSS Custom Highlight API). */
::highlight(ch-search-hit) { background-color: #ffe066; color: #111; }

/* Editor images: click opens the lightbox; drag the corner handle to scale. */
.ch-sheet img { cursor: zoom-in; }
.ch-img { display: table; position: relative; max-width: 100%; margin: 8px 0; }
.ch-img img { display: block; max-width: 100%; height: auto; border-radius: 6px; }
.ch-img-handle {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 3px;
  background: var(--accent); border: 2px solid var(--bg-2); cursor: nwse-resize; opacity: 0;
  transition: opacity .12s; touch-action: none;
}
.ch-img:hover .ch-img-handle { opacity: 1; }

/* Page cover banner at the top of the document. */
.ch-cover { position: relative; height: 190px; border-radius: 12px; margin-bottom: 14px; background-size: cover; background-position: center; background-color: var(--bg-1); }
.ch-cover-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .12s; }
.ch-cover:hover .ch-cover-actions { opacity: 1; }
.ch-cover-btn { background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 7px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.ch-cover-btn:hover { background: rgba(0,0,0,.82); }
.ch-add-cover { align-self: flex-start; margin-bottom: 10px; background: transparent; border: none; color: var(--faint); font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.ch-add-cover:hover { background: var(--hover); color: var(--text); }
.ch-recent-cover { flex: none; width: 26px; height: 26px; border-radius: 5px; background-size: cover; background-position: center; background-color: var(--bg-1); }

/* Wiki page-link chip inside the document. */
.ch-plink {
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px; padding: 0 4px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
/* NOTE: the self-hosted Font Awesome is v7 — its family is "Font Awesome 7
   Free" (with v6/v5 alias fallbacks here for safety). Using the wrong family
   silently renders tofu boxes. */
.ch-plink::before { content: '\f0c1'; font-family: 'Font Awesome 7 Free', 'Font Awesome 6 Free', 'Font Awesome 5 Free'; font-weight: 900; font-size: .8em; margin-right: 4px; opacity: .7; }
.ch-plink:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* @mention chip in the page body (same family as .ch-plink) */
.ch-mention {
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 4px; padding: 0 4px; font-weight: 600; white-space: nowrap;
}

/* @mention autocomplete dropdown (appended to <body>, placed at the caret) */
.ch-mention-menu {
  position: fixed; z-index: 12000; min-width: 200px; max-width: 240px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35); padding: 4px; display: flex; flex-direction: column;
}
.ch-mention-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px;
  color: var(--text); text-align: left; font-size: 13.5px; width: 100%;
}
.ch-mention-item:hover, .ch-mention-item.sel { background: var(--hover); }
.ch-mention-av {
  width: 20px; height: 20px; border-radius: 50%; overflow: hidden; flex: 0 0 20px;
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
}
.ch-mention-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-mention-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-mention-empty { padding: 8px 10px; font-size: 12.5px; opacity: .6; }

/* "/" command menu (same family as the mention dropdown, with hint text) */
.ch-slash-menu {
  position: fixed; z-index: 12000; width: 280px; max-height: 340px; overflow-y: auto;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35); padding: 4px; display: flex; flex-direction: column;
}
.ch-slash-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px;
  color: var(--text); text-align: left; width: 100%;
}
.ch-slash-item:hover, .ch-slash-item.sel { background: var(--hover); }
.ch-slash-ic {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 7px; display: grid; place-items: center;
  background: var(--bg-1); border: 1px solid var(--line); color: var(--dim); font-size: 12px;
}
.ch-slash-tx { display: flex; flex-direction: column; min-width: 0; }
.ch-slash-tx b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-slash-tx span { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Structured blocks ---- */
/* Callouts */
.ch-callout { position: relative; border-radius: 10px; border: 1px solid; padding: 12px 14px 12px 44px; margin: 0.6em 0; }
.ch-callout::before { font-family: 'Font Awesome 7 Free', 'Font Awesome 6 Free', 'Font Awesome 5 Free'; font-weight: 900; position: absolute; left: 15px; top: 13px; font-size: 15px; }
.ch-callout > p:last-child { margin-bottom: 0; }
.ch-callout-info { background: color-mix(in srgb, #3b82f6 9%, transparent); border-color: color-mix(in srgb, #3b82f6 35%, transparent); }
.ch-callout-info::before { content: '\f05a'; color: #3b82f6; }
.ch-callout-warning { background: color-mix(in srgb, #f59e0b 9%, transparent); border-color: color-mix(in srgb, #f59e0b 38%, transparent); }
.ch-callout-warning::before { content: '\f071'; color: #f59e0b; }
.ch-callout-success { background: color-mix(in srgb, #3ba55d 9%, transparent); border-color: color-mix(in srgb, #3ba55d 38%, transparent); }
.ch-callout-success::before { content: '\f058'; color: #3ba55d; }
.ch-callout-error { background: color-mix(in srgb, #ed4245 9%, transparent); border-color: color-mix(in srgb, #ed4245 38%, transparent); }
.ch-callout-error::before { content: '\f057'; color: #ed4245; }
.ch-callout-decision { background: color-mix(in srgb, #8b5cf6 9%, transparent); border-color: color-mix(in srgb, #8b5cf6 38%, transparent); }
.ch-callout-decision::before { content: '\f0e3'; color: #8b5cf6; }

/* Expand (collapsible section) */
.ch-expand { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 8px 34px; margin: 0.6em 0; }
.ch-expand-caret {
  position: absolute; left: 6px; top: 9px; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; background: none; border: none; color: var(--dim); cursor: pointer;
}
.ch-expand-caret:hover { background: var(--hover); color: var(--text); }
.ch-expand-caret i { transition: transform .15s; }
.ch-expand[data-open='true'] .ch-expand-caret i { transform: rotate(90deg); }
.ch-expand-title { font-weight: 700; min-height: 22px; padding: 1px 0; }
.ch-expand-body { margin-top: 6px; }
.ch-expand-body > p:last-child { margin-bottom: 0; }
.ch-expand[data-open='false'] .ch-expand-body { display: none; }

/* Live-tool embed card (/currents, /whiteboard) */
.ch-embed {
  display: flex; align-items: center; gap: 12px; margin: 0.6em 0;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--bg-2); user-select: none;
}
.ch-embed.ProseMirror-selectednode { outline: 2px solid var(--accent); }
.ch-embed.gone { opacity: .6; }
.ch-embed-cover {
  width: 56px; height: 40px; flex: 0 0 56px; border-radius: 7px;
  background: var(--bg-1) center/cover no-repeat; border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--dim); font-size: 16px;
}
.ch-embed-main { flex: 1; min-width: 0; }
.ch-embed-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-embed-sub { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-embed-open {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg-1);
  color: var(--text); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.ch-embed-open:hover { border-color: var(--accent); color: var(--accent); }

/* Status lozenge */
.ch-status-badge {
  display: inline-block; padding: 1px 8px 2px; border-radius: 4px; font-size: 11.5px; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase; cursor: pointer; line-height: 1.5; vertical-align: baseline;
  border: 1px solid transparent; user-select: none;
}
.ch-status-badge.ProseMirror-selectednode { outline: 2px solid var(--accent); }
.sb-grey { background: color-mix(in srgb, #6b7280 22%, transparent); color: #9aa4b2; border-color: color-mix(in srgb, #6b7280 40%, transparent); }
.sb-blue { background: color-mix(in srgb, #3b82f6 18%, transparent); color: #3b82f6; border-color: color-mix(in srgb, #3b82f6 40%, transparent); }
.sb-green { background: color-mix(in srgb, #3ba55d 18%, transparent); color: #3ba55d; border-color: color-mix(in srgb, #3ba55d 40%, transparent); }
.sb-orange { background: color-mix(in srgb, #e8842b 18%, transparent); color: #e8842b; border-color: color-mix(in srgb, #e8842b 40%, transparent); }
.sb-red { background: color-mix(in srgb, #ed4245 18%, transparent); color: #ed4245; border-color: color-mix(in srgb, #ed4245 40%, transparent); }
.sb-purple { background: color-mix(in srgb, #8b5cf6 18%, transparent); color: #8b5cf6; border-color: color-mix(in srgb, #8b5cf6 40%, transparent); }

/* "Linked from" backlinks below the page body. */
.ch-backlinks { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); }
.ch-backlinks-head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin-bottom: 8px; }
.ch-backlinks-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-backlink { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1); color: var(--text); font-size: 13px; cursor: pointer; }
.ch-backlink span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-backlink:hover { border-color: var(--accent); }

.ch-sr-create .ch-sr-title, .ch-sr-create .ch-sr-icon { color: var(--accent); }

/* Page-link picker (reuses the search modal styling). */
.ch-linkpick { width: min(520px, 92vw); padding: 0; overflow: hidden; }
.ch-linkpick .ch-search-bar { border-bottom: 1px solid var(--line); }

/* ---- Margin comments (Google-Docs style) ---- */
.ch-comments-btn .ch-cm-count { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 5px; font-size: 11px; margin-left: 3px; }
/* The sheet + its comment gutter share a positioned wrapper; when comments
   exist the wrapper widens and the sheet stays left so cards get the margin. */
/* width:100% matters: as a flex child (TOC open) the wrap otherwise shrinks
   to its content (the 840px sheet), the gutter at left:856 falls outside it,
   and comment cards collapse to zero width. */
.ch-sheetwrap { position: relative; width: 100%; max-width: 840px; margin: 0 auto; min-width: 0; }
.ch-sheetwrap.has-cm { max-width: 1132px; }
.ch-sheetwrap.has-cm .ch-sheet { margin: 0; }
.ch-margin { position: absolute; left: 856px; right: 4px; top: 0; bottom: 0; pointer-events: none; }
.ch-margin > * { pointer-events: auto; }
.ch-margin-pill {
  position: absolute; top: 0; left: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-1);
  color: var(--dim); font-size: 12px; cursor: pointer;
}
.ch-margin-pill:hover { color: var(--text); border-color: var(--accent); }
.ch-cmm {
  position: absolute; left: 0; right: 4px; min-width: 200px; background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; transition: top .15s ease, box-shadow .15s;
}
.ch-cmm:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .22); }
.ch-cmm.active { border-color: #e8c34a; box-shadow: 0 6px 18px rgba(0, 0, 0, .28); }
.ch-cmm.resolved { opacity: .62; }
.ch-cmm-top { display: flex; align-items: center; gap: 8px; }
.ch-cmm-who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 7px; overflow: hidden; }
.ch-cmm-who b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-cmm-act { background: none; border: none; color: var(--faint); cursor: pointer; padding: 2px 3px; font-size: 12px; flex: none; }
.ch-cmm-act:hover { color: var(--text); }
.ch-cmm-act.del:hover { color: var(--danger, #ed4245); }
.ch-cmm-reply { display: flex; gap: 7px; margin: 7px 0 0 6px; padding-left: 8px; border-left: 2px solid var(--line); }
.ch-cmm-reply-main { min-width: 0; flex: 1; }
.ch-cm-anchor { font-size: 12px; color: var(--dim); font-style: italic; border-left: 2px solid color-mix(in srgb, #e8c34a 70%, transparent); padding: 0 8px; margin: 0 0 6px 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ch-cm-anchor > i { font-size: 9px; margin-right: 4px; opacity: .6; }
.ch-cm-when { font-size: 11px; color: var(--faint); }
.ch-cm-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; }
.ch-cm-replybox { display: flex; gap: 6px; margin-top: 8px; }
.ch-cm-replybox input { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--text); font-size: 13px; }
/* Narrow viewports: the gutter collapses; the focused thread floats instead. */
.ch-margin-solo { position: fixed; right: 12px; bottom: 16px; width: min(340px, 92vw); z-index: 60; }
.ch-cmm.solo { position: static; box-shadow: 0 12px 34px rgba(0, 0, 0, .4); cursor: default; }

/* Floating "comment on selection" button + inline composer in the gutter. */
.ch-addcm-btn {
  position: absolute; left: calc(min(100%, 840px) - 16px); width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-1); border: 1px solid var(--line);
  color: var(--dim); cursor: pointer; z-index: 5; box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
}
.ch-addcm-btn:hover { color: var(--accent); border-color: var(--accent); }
.ch-composer {
  position: absolute; left: 856px; right: 4px; min-width: 200px; z-index: 6;
  background: var(--bg-1); border: 1px solid #e8c34a; border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 8px;
}
.ch-composer textarea { resize: none; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); font-size: 13px; }
.ch-composer-acts { display: flex; justify-content: flex-end; gap: 6px; }
/* No room for the gutter (ChartsPage measures the canvas) → composer floats. */
.ch-composer.solo { position: fixed; right: 12px; bottom: 16px; left: auto; width: min(340px, 92vw); top: auto !important; }

/* Inline-comment highlight inside the document. */
.ch-comment-mark { background: color-mix(in srgb, #e8c34a 26%, transparent); border-bottom: 2px solid #e8c34a; cursor: pointer; border-radius: 2px; }
.ch-comment-mark:hover, .ch-comment-mark.cm-active { background: color-mix(in srgb, #e8c34a 42%, transparent); }
.ch-comment-mark.cm-resolved { background: none; border-bottom: 1px dotted color-mix(in srgb, #e8c34a 50%, transparent); }

/* ---- Create-page modal (Blank / from template) ---- */
.ch-create { width: min(460px, 94vw); }
.ch-create-title {
  width: 100%; background: var(--bg-1); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; color: var(--text); font-size: 15px; font-weight: 600;
}
.ch-create-title:focus { outline: none; border-color: var(--accent); }
.ch-tpl-list { display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; }
.ch-tpl-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-1); color: var(--text); text-align: left; cursor: pointer;
}
.ch-tpl-row.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ch-tpl-ic {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--dim); font-size: 13px;
}
.ch-tpl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-tpl-main b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-tpl-main span { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-tpl-rm { flex: none; color: var(--faint); padding: 3px 5px; border-radius: 6px; cursor: pointer; }
.ch-tpl-rm:hover { color: var(--danger, #ed4245); background: var(--hover); }
.ch-tpl-hint { font-size: 12px; color: var(--faint); padding: 8px 2px; }

/* Restricted/private page indicator in the tree. */
.ch-restricted-icon { flex: none; font-size: 10px; color: var(--faint); }

/* ---- Permissions modal ---- */
.ch-perms { width: min(500px, 94vw); }
.ch-perms-body { max-height: min(66vh, 560px); overflow-y: auto; overflow-x: hidden; }
.ch-perms-title { font-weight: 600; margin-bottom: 12px; color: var(--dim); }
.ch-perms-scope { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; margin-left: 4px; }
.ch-perms-hint { font-size: 12px; color: var(--faint); margin: -6px 0 4px; }
/* ---- Department permissions picker ---- */
.ch-deptperms { width: min(440px, 94vw); }
.ch-deptperms-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.ch-deptperms-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1); color: var(--text); cursor: pointer; text-align: left; }
.ch-deptperms-row:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ch-deptperms-row .n { flex: 1; font-weight: 500; }
.ch-perms-lbl { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin: 12px 0 6px; }
.ch-perms-defaults { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ch-perms-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1); color: var(--text); cursor: pointer; }
.ch-perms-opt span { font-size: 11px; color: var(--faint); }
.ch-perms-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ch-perms-grants { display: flex; flex-direction: column; gap: 4px; }
.ch-perms-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.ch-perms-row:hover { background: var(--hover); }
.ch-perms-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-perms-level {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-1);
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ch-perms-level:hover { border-color: var(--accent); }
.ch-perms-level i { font-size: 10px; opacity: .6; }
.ch-perms-roleic { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--bg-1); color: var(--dim); flex: none; }
.ch-perms-rm { background: none; border: none; color: var(--faint); cursor: pointer; padding: 2px 5px; flex: none; }
.ch-perms-rm:hover { color: var(--danger, #ed4245); }
/* Add-people search + results */
.ch-perms-search { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1); }
.ch-perms-search i { color: var(--faint); font-size: 12px; }
.ch-perms-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 13px; }
.ch-perms-results { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.ch-perms-hit { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; background: none; border: none; color: var(--text); cursor: pointer; text-align: left; }
.ch-perms-hit:hover { background: var(--hover); }
.ch-perms-addlbl { flex: none; font-size: 12px; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }

/* ---- Trash modal ---- */
.ch-trash { width: min(560px, 94vw); }
.ch-trash-body { max-height: min(60vh, 480px); overflow-y: auto; }
.ch-trash-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.ch-trash-meta { flex: 1; min-width: 0; }
.ch-trash-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-trash-sub { font-size: 11px; color: var(--faint); }
.ch-trash-purge { color: var(--danger, #ed4245); }

/* ---- Sidebar: Favorites + Recently viewed sections ---- */
.ch-quick { padding: 4px 0 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ch-quick-sec { margin-bottom: 4px; }
.ch-quick-head { display: flex; align-items: center; gap: 6px; padding: 4px 12px 2px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.ch-quick-head > i { font-size: 10px; }
.ch-fav-star { margin-left: auto; font-size: 10px; color: #f5b301; }
/* Page status: a small colored dot in the tree; dim archived/deprecated pages. */
.ch-status-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.ch-node.ch-dim { opacity: .55; }
.ch-node.ch-dim:hover { opacity: 1; }
/* Header status select (colored pill) + owner chip. */
.ch-status-select {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--st, var(--accent)) 16%, transparent);
  color: var(--st, var(--text)); border: 1px solid color-mix(in srgb, var(--st, var(--accent)) 45%, transparent);
  border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 600; cursor: pointer; outline: none;
}
.ch-status-select:hover { background: color-mix(in srgb, var(--st, var(--accent)) 26%, transparent); }
.ch-status-select:disabled { opacity: .55; cursor: default; }
.ch-status-select .fa-caret-down { font-size: 9px; opacity: .8; }
.ch-owner { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--dim); white-space: nowrap; }
.ch-owner > i { font-size: 10px; }
/* Page locking. */
.ch-lock-icon { flex: none; font-size: 10px; color: var(--faint); }
.ch-locked-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #e8842b; white-space: nowrap; }
.ch-lock-banner {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 12px; border-radius: 8px; font-size: 13px;
  color: #e8842b; background: color-mix(in srgb, #e8842b 12%, transparent); border: 1px solid color-mix(in srgb, #e8842b 30%, transparent);
}
.ch-fav-btn.on { color: #f5b301; }

/* ---- Full-text search modal ---- */
.ch-search-modal { width: min(680px, 94vw); max-width: 680px; padding: 0; overflow: hidden; }
.ch-search-bar { display: flex; align-items: center; gap: 10px; padding: 13px 14px; }
.ch-search-bar > .fa-magnifying-glass { color: var(--faint); flex: none; }
.ch-search-input { flex: 1 1 auto; min-width: 0; background: transparent; border: none; outline: none; color: var(--text); font-size: 16px; }
/* Filters live on their own row so the search field always gets the full width. */
.ch-search-filter { display: flex; align-items: center; gap: 10px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.ch-search-filter-label { flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.ch-search-filter .df-wrap { flex: 1 1 auto; min-width: 0; }
.ch-search-results { max-height: min(60vh, 520px); overflow-y: auto; padding: 6px; }
.ch-sr { display: flex; gap: 10px; width: 100%; text-align: left; background: transparent; border: none; cursor: pointer; padding: 9px 10px; border-radius: 8px; }
.ch-sr:hover { background: var(--hover); }
.ch-sr-icon { margin-top: 2px; }
.ch-sr-body { min-width: 0; flex: 1; }
.ch-sr-title { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sr-sub { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sr-status { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; margin-left: 8px; }

/* Status filter chips in the search modal */
.ch-search-status { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.ch-status-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-1); color: var(--dim); font-size: 12px; cursor: pointer;
}
.ch-status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st, var(--dim)); }
.ch-status-chip:hover { color: var(--text); }
.ch-status-chip.on { border-color: var(--st, var(--accent)); color: var(--text); background: color-mix(in srgb, var(--st, var(--accent)) 12%, transparent); }

/* "Show archived" toggle under the tree filter */
.ch-arch-toggle {
  display: flex; align-items: center; gap: 7px; margin: 0 10px 4px; padding: 4px 8px;
  border: none; background: none; border-radius: 7px; color: var(--faint); font-size: 11.5px; cursor: pointer; text-align: left;
}
.ch-arch-toggle:hover { color: var(--text); background: var(--hover); }
.ch-sr-excerpt { font-size: 12.5px; color: var(--dim); margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ch-sr-excerpt mark { background: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--text); border-radius: 2px; padding: 0 1px; }
.ch-sr-meta { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Confluence-style shell: persistent page tree + document area */
.ch-shell { flex: 1; display: grid; grid-template-columns: 264px 1fr; min-height: 0; min-width: 0; }
.ch-side { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.ch-side-head { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ch-side-btn { position: relative; width: 28px; height: 28px; border-radius: 6px; color: var(--dim); } /* relative: hosts .tut-dot */
.ch-side-btn:hover { background: var(--hover); color: var(--text); }
.ch-side-btn.on { background: var(--hover); color: var(--accent); }

/* Built-in "Charts guide" page (ChartsHelp.tsx) */
.ch-kbd {
  display: inline-block; padding: 0 7px; border-radius: 5px; border: 1px solid var(--line);
  border-bottom-width: 2px; background: var(--bg-2); font-family: inherit;
  font-size: 12.5px; font-weight: 700; line-height: 1.6; color: var(--text);
}
.ch-help h2 { margin-top: 1.1em; }
.ch-help .ch-status-badge { cursor: default; margin: 0 2px; }
.ch-help li { margin: 0.25em 0; }
.ch-help i.fa-solid, .ch-help i.fa-regular { font-size: 0.85em; opacity: 0.85; margin: 0 1px; }
.ch-search-wrap { position: relative; padding: 8px 10px; }
.ch-search-wrap > i { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--faint); }
.ch-search { width: 100%; background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 6px 10px 6px 28px; font-size: 13px; }
.ch-side-filter { padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.ch-side-filter .df-chip { padding: 2px 9px; font-size: 11.5px; }
.ch-tree { flex: 1; overflow-y: auto; padding: 4px 6px 20px; }
.ch-node { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--dim); white-space: nowrap; }
.ch-node:hover { background: var(--hover); color: var(--text); }
.ch-node .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ch-node.ch-pnode.sel { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
/* Drag-to-reorder drop indicator (line above a page, ring around a folder). */
.ch-node.ch-pnode.drop-target { box-shadow: inset 0 2px 0 var(--accent); }
.ch-node.ch-fnode.drop-target { box-shadow: inset 0 0 0 1.5px var(--accent); border-radius: 6px; }
.ch-caret { width: 12px; text-align: center; font-size: 10px; color: var(--faint); transition: transform 0.12s; }
.ch-caret.open { transform: rotate(90deg); }
.ch-caret.none { visibility: hidden; }
.ch-tree-empty { padding: 18px 12px; color: var(--faint); font-size: 13px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.ch-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* Home (nothing selected): recent pages */
.ch-home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; }
.ch-home img { width: 64px; height: 64px; opacity: 0.85; }
.ch-recent { margin-top: 18px; width: min(460px, 90%); display: flex; flex-direction: column; gap: 2px; }
.ch-recent-head { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.ch-recent-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); text-align: left; }
.ch-recent-row:hover { background: var(--hover); }
.ch-recent-row .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-recent-row .when { color: var(--faint); font-size: 12px; }

/* "Needs review" queue: approve / request-changes inline actions */
.ch-nr-row { cursor: pointer; }
.ch-nr-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .12s; }
.ch-nr-row:hover .ch-nr-actions, .ch-nr-row:focus-within .ch-nr-actions { opacity: 1; }
.ch-nr-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: var(--text);
  background: var(--hover); border: 1px solid var(--line); white-space: nowrap;
}
.ch-nr-btn:hover { border-color: var(--accent); }
.ch-nr-btn.ok { color: #3ba55d; }

/* Document header (inside the sheet) */
.ch-bar-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.ch-doc-title {
  width: 100%; background: transparent; border: none; outline: none; color: var(--text);
  font-size: 30px; font-weight: 800; line-height: 1.25; padding: 0; margin: 0 0 2px;
}
.ch-doc-title::placeholder { color: var(--faint); }
.ch-byline { color: var(--faint); font-size: 12.5px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }

.ch-page { display: flex; flex-direction: column; height: 100%; min-width: 0; }

.ch-live { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 9px; }
.ch-live.connected { color: #3ba55d; background: color-mix(in srgb, #3ba55d 14%, transparent); }
.ch-live.connecting, .ch-live.offline { color: #f0b232; background: color-mix(in srgb, #f0b232 14%, transparent); }

.ch-peer { border-radius: 50%; box-shadow: 0 0 0 2px var(--peer, var(--accent)); display: inline-flex; }

/* Launcher page tiles */
.ch-thumb { display: flex; align-items: center; justify-content: center; position: relative; background: color-mix(in srgb, var(--cat, #64748b) 26%, var(--bg-1)); color: var(--cat, #64748b); font-size: 26px; }
.ch-thumb-when { position: absolute; right: 8px; bottom: 6px; font-size: 10px; color: var(--dim); }

/* Toolbar */
.ch-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.ch-tool { width: 30px; height: 30px; border-radius: 6px; color: var(--dim); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.ch-tool:hover { background: var(--hover); color: var(--text); }
.ch-tool.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.ch-tool:disabled { opacity: 0.4; }

/* Page canvas. overflow-x hidden: oversized content (tables resized wider
   than the screen, huge images, long unbroken strings) must scroll INSIDE
   the sheet, never stretch the app layout. */
.ch-canvas { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px 16px 80px; scroll-padding-bottom: 140px; scroll-padding-top: 60px; }
.ch-sheet { max-width: 840px; margin: 0 auto; background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 36px 44px; min-height: 70vh; min-width: 0; }
.ch-sheet .tiptap { overflow-wrap: anywhere; }

/* Editor content */
.ch-sheet .tiptap { outline: none; color: var(--text); font-size: 15px; line-height: 1.65; }
.ch-sheet .tiptap p { margin: 0 0 0.6em; }
.ch-sheet .tiptap h1 { font-size: 26px; margin: 0.8em 0 0.4em; }
.ch-sheet .tiptap h2 { font-size: 21px; margin: 0.8em 0 0.4em; }
.ch-sheet .tiptap h3 { font-size: 17px; margin: 0.8em 0 0.4em; }
.ch-sheet .tiptap ul, .ch-sheet .tiptap ol { padding-left: 1.4em; margin: 0 0 0.6em; }
.ch-sheet .tiptap blockquote { border-left: 3px solid var(--accent); margin: 0.6em 0; padding: 2px 14px; color: var(--dim); }
.ch-sheet .tiptap code { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.ch-sheet .tiptap pre { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0.6em 0; }
.ch-sheet .tiptap pre code { background: none; border: none; padding: 0; }
.ch-sheet .tiptap hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.ch-sheet .tiptap img { max-width: 100%; border-radius: 8px; display: block; margin: 0.6em 0; }
.ch-sheet .tiptap img.ProseMirror-selectednode { outline: 2px solid var(--accent); }
.ch-sheet .tiptap a { color: var(--accent); }

/* Tables. TipTap wraps each table in .tableWrapper — that wrapper scrolls
   horizontally when columns are resized wider than the page, so a huge table
   pans inside the document instead of breaking the layout. */
.ch-sheet .tiptap .tableWrapper { max-width: 100%; overflow-x: auto; margin: 0.8em 0; }
.ch-sheet .tiptap table { border-collapse: collapse; min-width: 100%; width: auto; margin: 0; table-layout: fixed; }
.ch-sheet .tiptap th, .ch-sheet .tiptap td { border: 1px solid var(--line); padding: 6px 10px; vertical-align: top; position: relative; }
.ch-sheet .tiptap th { background: var(--bg-2); font-weight: 700; text-align: left; }
.ch-sheet .tiptap .selectedCell::after { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 16%, transparent); pointer-events: none; }
.ch-sheet .tiptap .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; background: var(--accent); cursor: col-resize; }

/* Checklists */
.ch-sheet .tiptap ul[data-type='taskList'] { list-style: none; padding-left: 0.2em; }
.ch-sheet .tiptap ul[data-type='taskList'] li { display: flex; gap: 8px; align-items: flex-start; }
.ch-sheet .tiptap ul[data-type='taskList'] li > label { margin-top: 3px; }
.ch-sheet .tiptap ul[data-type='taskList'] li[data-checked='true'] > div { text-decoration: line-through; color: var(--dim); }

/* Page break: labeled dashed divider on screen, real break in print/PDF */
.ch-pagebreak {
  position: relative; margin: 1.6em -44px; border-top: 2px dashed var(--line); height: 0;
}
.ch-pagebreak::after {
  content: 'PAGE BREAK'; position: absolute; top: -0.7em; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 800; letter-spacing: 0.12em; color: var(--faint);
  background: var(--bg-1); padding: 0 10px;
}
.ch-pagebreak.ProseMirror-selectednode { border-top-color: var(--accent); }
@media print {
  .ch-pagebreak { break-after: page; page-break-after: always; border: none; }
  .ch-pagebreak::after { content: none; }
  .ch-toolbar, .wb-bar { display: none !important; }
  .ch-margin, .ch-margin-solo, .ch-addcm-btn, .ch-composer { display: none !important; }
  .ch-canvas { overflow: visible; padding: 0; }
  .ch-sheetwrap { max-width: none; }
  .ch-sheet { border: none; max-width: none; padding: 0; }
}

/* Placeholder */
.ch-sheet .tiptap p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--faint); float: left; height: 0; pointer-events: none; }

/* Collaboration cursors (y-prosemirror renders these) */
.ch-sheet .tiptap .collaboration-cursor__caret {
  border-left: 1px solid; border-right: 1px solid; margin-left: -1px; margin-right: -1px;
  position: relative; word-break: normal; pointer-events: none;
}
.ch-sheet .tiptap .collaboration-cursor__label {
  position: absolute; top: -1.35em; left: -1px; font-size: 10px; font-weight: 700; color: #fff;
  padding: 1px 6px; border-radius: 4px 4px 4px 0; white-space: nowrap; user-select: none; pointer-events: none;
}

/* History modal */
.ch-history { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.ch-rev { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.ch-rev-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ch-rev-meta .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Page activity (audit trail) — admin-only section under the version list */
.ch-audit-head {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 6px; opacity: .75;
}
.ch-audit-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 3px 2px; font-size: 13px; }
.ch-audit-what { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ch-audit-when { font-size: 12px; white-space: nowrap; opacity: .65; }

/* ---- Auto table of contents (Confluence-style, built from headings) ---- */
.ch-canvas.has-toc { display: flex; align-items: flex-start; justify-content: center; gap: 30px; }
.ch-canvas.has-toc .ch-sheetwrap { margin: 0; }
.ch-toc {
  position: sticky; top: 0; flex: 0 0 220px; align-self: flex-start;
  max-height: calc(100vh - 180px); overflow-y: auto;
  padding: 2px 2px 8px; font-size: 13px;
}
.ch-toc-head { text-transform: uppercase; font-size: 11px; letter-spacing: .05em; color: var(--faint); font-weight: 700; padding: 6px 8px; }
.ch-toc-item {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--dim); padding: 4px 8px; border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4;
}
.ch-toc-item:hover { color: var(--text); background: var(--hover); }
.ch-toc-item.active { color: var(--text); border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ch-toc-item.lvl2 { padding-left: 20px; }
.ch-toc-item.lvl3 { padding-left: 32px; font-size: 12px; }
/* Narrow screens: keep the sheet full and hide the rail. */
@media (max-width: 980px) {
  .ch-toc { display: none; }
  .ch-canvas.has-toc { display: block; }
  .ch-canvas.has-toc .ch-sheetwrap { margin: 0 auto; }
}
/* When there's no room for the comment gutter, ChartsPage measures the canvas
   (accounting for the TOC rail) and switches to the floating solo view — no
   viewport media query, so collapsed/open side panels are handled correctly. */
/* Drydock — built-in version control. All colors from theme vars. */

.dd-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--main-bg, var(--bg-1)); position: relative; }
.dd-head { height: 52px; flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
.dd-head h1 { font-size: 16px; margin: 0 10px 0 4px; }
.dd-head .hamburger { background: transparent; border: none; color: var(--dim); cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.dd-head .hamburger:hover { color: var(--text); background: var(--hover); }
.dd-depot-sel { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 13px; max-width: 220px; }
.dd-head-meta { font-size: 12px; color: var(--dim); margin-left: 10px; white-space: nowrap; }

.dd-tabs { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.dd-tabs > button { background: transparent; border: none; color: var(--dim); font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.dd-tabs > button.on { color: var(--text); background: var(--hover); }
.dd-filter { flex: 1; max-width: 340px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 6px 10px; font-size: 13px; }
.dd-add-btn { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; margin-left: auto; }

.dd-files { flex: 1; overflow-y: auto; padding: 6px 8px 20px; }
/* The name column can NEVER collapse: minmax floor keeps names readable at any
   window size (the pane scrolls horizontally instead of hiding the name). */
.dd-row { display: grid; grid-template-columns: minmax(170px, 1fr) 56px 84px 140px 132px; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.dd-files { overflow-x: auto; }
.dd-row:hover { background: color-mix(in srgb, var(--hover) 65%, transparent); }
.dd-row.head { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; position: sticky; top: 0; background: var(--main-bg, var(--bg-1)); z-index: 1; }
.dd-row .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; font-size: 12.5px; }
.dd-row .r, .dd-row .s { color: var(--dim); font-variant-numeric: tabular-nums; }
.dd-row .a { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; }
.dd-row:hover .a { opacity: 1; }
.dd-row .a button, .dd-row .a a { background: transparent; border: none; color: var(--dim); cursor: pointer; padding: 4px 7px; border-radius: 6px; font-size: 12px; }
.dd-row .a button:hover, .dd-row .a a:hover { color: var(--text); background: var(--hover); }
.dd-lock { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--accent); font-weight: 600; }
.dd-lock.mine { opacity: 0.85; }

.dd-changes { flex: 1; overflow-y: auto; padding: 10px 14px 20px; display: flex; flex-direction: column; gap: 6px; }
.dd-cl { display: grid; grid-template-columns: 84px 1fr auto; gap: 12px; align-items: center; text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--text); cursor: pointer; }
.dd-cl:hover { border-color: var(--accent); }
.dd-cl .num { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.dd-cl .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.dd-cl .meta { color: var(--dim); font-size: 12px; white-space: nowrap; }

.dd-empty, .dd-off { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--dim); text-align: center; padding: 24px; }
.dd-empty i, .dd-off i { font-size: 42px; opacity: 0.5; }
.dd-off h2 { color: var(--text); margin: 0; }
.dd-off p { max-width: 420px; line-height: 1.5; margin: 0; }

.dd-drop-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg-1) 72%, transparent); border: 2px dashed var(--accent); border-radius: 8px; font-weight: 800; font-size: 16px; color: var(--text); z-index: 30; pointer-events: none; }
.dd-toast { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 8px 18px; font-size: 13px; box-shadow: 0 8px 26px rgba(0,0,0,0.4); z-index: 40; }

.dd-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 900; }
.dd-modal { width: min(640px, 94vw); max-height: 84vh; display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 24px 70px rgba(0,0,0,0.5); }
.dd-modal h2 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.dd-modal h2 .muted { font-weight: 400; font-size: 12.5px; color: var(--dim); }
.dd-modal textarea { background: var(--bg-1); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; resize: vertical; margin-bottom: 10px; }
.dd-cl-desc { white-space: pre-wrap; color: var(--text); background: var(--bg-1); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; margin: 0 0 10px; }
.dd-pend-list { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.dd-pend { display: grid; grid-template-columns: 72px 1fr auto auto; gap: 10px; align-items: center; padding: 5px 8px; border-radius: 7px; font-size: 12.5px; }
.dd-pend:nth-child(odd) { background: color-mix(in srgb, var(--hover) 40%, transparent); }
.dd-pend .act { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.dd-pend .act.add { color: var(--green, #4caf6e); }
.dd-pend .act.edit { color: var(--accent); }
.dd-pend .act.delete { color: #e5534b; }
.dd-pend .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; }
.dd-pend .p .muted { color: var(--dim); }
.dd-pend .s { color: var(--dim); font-variant-numeric: tabular-nums; }
.dd-pend .dl { color: var(--dim); padding: 3px 6px; border-radius: 6px; }
.dd-pend .dl:hover { color: var(--text); background: var(--hover); }
.dd-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Tools menu off-chip (owner sees Drydock even when the master switch is off) */
.dd-off-chip { margin-left: auto; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }

/* Compact rows well before true mobile: the fixed columns total ~450px, so on
   any window under ~1100px the 1fr name column collapsed to nothing and rows
   showed only sizes ("nameless rows" bug). */
@media (max-width: 1100px) {
  .dd-row { grid-template-columns: minmax(170px, 1fr) 64px 110px; }
  .dd-row .l, .dd-row.head span:nth-child(4), .dd-row.head span:nth-child(5) { display: none; }
  .dd-row .s { grid-column: 2 / -1; }
  .dd-row .a { grid-column: 2 / -1; grid-row: 1; justify-content: flex-end; }
  .dd-row:hover .s { visibility: hidden; } /* on hover, the actions take the size's spot */
}

/* Workspace chip on pending changelist headers */
.dd-cl-ws {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Files inside the depot tree (P4V-style) */
.dd-tnode.dd-tfile .dd-fic { color: var(--dim); }
.dd-tnode.dd-tfile .n { color: var(--dim); }
.dd-tnode.dd-tfile:hover .n { color: var(--text); }
.dd-tlock { margin-left: 6px; font-size: 10px; color: var(--accent); }

/* File viewer modal */
.dd-viewer { width: min(880px, 94vw); }
.dd-viewer h2 .muted { font-size: 12px; font-weight: 400; color: var(--dim); }
.dd-viewer-body {
  max-height: 62vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0 0;
  font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.55; white-space: pre; color: var(--text);
}
.dd-viewer-img { display: flex; justify-content: center; padding: 14px; }
.dd-viewer-img img { max-width: 100%; max-height: 58vh; border-radius: 6px; }
.dd-viewer-load { display: flex; align-items: center; gap: 8px; color: var(--dim); font-family: inherit; }

/* Bulk folder import */
.dd-import { width: min(560px, 94vw); }
.dd-import-sum { margin: 4px 0 8px; font-size: 14px; font-weight: 600; }
.dd-import-note { margin: 0 0 10px; font-size: 12.5px; color: var(--dim); line-height: 1.5; }
.dd-import-err { margin: 0 0 10px; font-size: 12.5px; color: #e5534b; }
.dd-import-bar { height: 10px; border-radius: 999px; background: var(--bg-1); border: 1px solid var(--line); overflow: hidden; margin: 8px 0 4px; }
.dd-import-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

/* ---- P4V-style layout ---- */
.dd-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.dd-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; background: transparent; border: none; color: var(--dim); cursor: pointer; font-size: 10.5px; padding: 5px 10px; border-radius: 8px; min-width: 54px; }
.dd-tool i { font-size: 15px; }
.dd-tool:hover { background: var(--hover); color: var(--text); }
.dd-tool:disabled { opacity: 0.35; cursor: default; }
.dd-tool:disabled:hover { background: transparent; color: var(--dim); }
.dd-row.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.dd-tsep { width: 1px; height: 28px; background: var(--line); margin: 0 6px; }
.dd-toolbar .dd-filter { margin-left: auto; max-width: 260px; }

.dd-addr { display: flex; align-items: center; padding: 5px 12px; border-bottom: 1px solid var(--line); font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--dim); background: var(--bg-1); white-space: nowrap; overflow-x: auto; }
.dd-addr button { background: transparent; border: none; color: var(--accent); cursor: pointer; padding: 1px 2px; font: inherit; }
.dd-addr button:hover { text-decoration: underline; }
.dd-addr-tail { opacity: 0.6; }

.dd-body { flex: 1; display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.dd-tree { border-right: 1px solid var(--line); overflow-y: auto; padding: 6px 4px 20px; background: var(--bg-2); }
.dd-tnode { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.dd-tnode:hover { background: var(--hover); }
.dd-tnode.sel { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.dd-tnode .n { overflow: hidden; text-overflow: ellipsis; }
.dd-tnode .c { margin-left: auto; font-size: 10.5px; color: var(--faint); }
.dd-caret { width: 12px; text-align: center; color: var(--dim); transition: transform 0.12s; font-size: 11px; }
.dd-caret.open { transform: rotate(90deg); }
.dd-caret.none { visibility: hidden; }
.dd-tnode .dd-fic { color: var(--accent); }
.dd-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dd-main .dd-files, .dd-main .dd-changes { flex: 1; overflow-y: auto; }

.dd-fic { margin-right: 8px; opacity: 0.85; }
.dd-row .dd-fic { color: var(--dim); }
.dd-dir { cursor: pointer; }
.dd-dir .p { font-weight: 600; font-family: inherit; }
.dd-dir .dd-fic { color: var(--accent); }
.dd-ftype { margin-left: 8px; color: var(--faint); font-size: 11px; }
.dd-badge { margin-left: 6px; background: var(--accent); color: var(--bg-1); border-radius: 999px; font-size: 10px; font-weight: 800; padding: 1px 6px; }

/* Pending file rows (P4V-style: badged icon + depot path + #base/head).
   Same minmax floor as .dd-row so paths never collapse to nothing. */
.dd-row.phead, .dd-row.prow { grid-template-columns: minmax(170px, 1fr) 70px; }
.dd-pact.add { color: var(--green, #4caf6e); }
.dd-pact.edit { color: var(--accent); }
.dd-pact.delete { color: #e5534b; }
.dd-pdepot { color: var(--faint); }

/* Inline changelist-description editing */
.dd-clhead .desc.editable { cursor: text; border-radius: 6px; padding: 1px 6px; margin: -1px -6px; }
.dd-clhead .desc.editable:hover { background: var(--hover); }
.dd-desc-edit {
  flex: 1; min-width: 160px; background: var(--bg-1); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--text); font-size: 12.5px; padding: 2px 8px; outline: none;
}
.dd-row.phead { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; position: sticky; top: 0; background: var(--main-bg, var(--bg-1)); z-index: 1; }
.dd-row.prow { cursor: pointer; }
.dd-row .act { font-weight: 700; font-size: 11px; text-transform: uppercase; }
.dd-row .act.add { color: var(--green, #4caf6e); }
.dd-row .act.edit { color: var(--accent); }
.dd-row .act.delete { color: #e5534b; }
.dd-row .dim { color: var(--dim); font-size: 12px; }

@media (max-width: 760px) {
  .dd-body { grid-template-columns: 1fr; }
  .dd-tree { display: none; }
  .dd-tool span { display: none; }
}

/* ---- Pending tab: grouped changelists (P4V style) ---- */
.dd-pending { flex: 1; overflow-y: auto; padding: 4px 0 20px; }
.dd-ptoolbar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.dd-phint { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.dd-clgroup { border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.dd-clgroup.sel .dd-clhead { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.dd-clhead { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; user-select: none; }
.dd-clhead:hover { background: var(--hover); }
.dd-clhead .dd-cico { color: #e0a53b; font-size: 12px; }
.dd-clhead .num { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.dd-clhead .who { color: var(--dim); }
.dd-clhead .desc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-clhead .cnt { color: var(--faint); font-size: 11.5px; white-space: nowrap; }

/* ---- Right-click context menu ---- */
.dd-menu-scrim { position: fixed; inset: 0; z-index: 999; }
.dd-menu { position: fixed; z-index: 1000; min-width: 240px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 12px 34px rgba(0,0,0,0.5); }
.dd-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); font-size: 13px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.dd-menu-item:hover:not(.disabled) { background: var(--accent); color: #fff; }
.dd-menu-item.disabled { color: var(--faint); cursor: default; }
.dd-menu-item.danger:hover:not(.disabled) { background: #e5534b; }
.dd-menu-item .sc { font-size: 11px; opacity: 0.7; }
:root {
  --teal: #159a8a;
  --green: #5bc88a;
  --blue: #2f80ed;
  /* Primary-action / selected-highlight color. Change THIS ONE value to
     restyle every primary button (Join voice, Create channel, Save, etc.) and
     every blue "selected/active" highlight app-wide. */
  --accent: #5db23b;
  --orange: #f2683c;
  --purple: #9b6dff;
  --yellow: #f0b232;

  --bg-0: #0f1216;
  --bg-1: #161a20;
  --bg-2: #1c2128;
  --bg-3: #232a33;
  --hover: #272e38;
  --active: #2e3742;
  --line: #2a313b;
  --text: #e7ebf0;
  --dim: #98a2b0;
  --faint: #6b7480;

  /* Surface gradients (one set per theme; see themes.css for the variants).
     --sidebar-bg: side columns, dark at top → lighter blue at the bottom.
     --panel-bg:   the bottom-left "me" panel, a subtle golden circular glow.
     --main-bg:    the central chat column, a flat darker surface (no gradient). */
  --sidebar-bg: linear-gradient(180deg, #0f131b 0%, #16203a 60%, #1d2c4e 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(241,185,67,0.17), rgba(241,185,67,0.05) 44%, rgba(0,0,0,0) 72%), #0d1117;
  --main-bg: #0e1116;
  /* Full-screen image viewer backdrop — dark by default; each theme tints it
     to match (medium gray on the light theme; see themes.css). */
  --lb-backdrop: rgba(8, 10, 14, 0.95);

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; }
body { font-family: var(--sans); background: var(--bg-0); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
a { color: var(--blue); cursor: pointer; }
/* Scrollbars follow the theme: thumb derived from the theme's text/background
   mix so it adapts to every preset AND custom themes. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text) 20%, var(--bg-0)); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text) 32%, var(--bg-0)); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

.splash { display: grid; place-items: center; height: 100%; color: var(--dim); }

/* ---------------- auth + setup ---------------- */
.auth-wrap { display: grid; place-items: center; height: 100%; background: radial-gradient(circle at 50% 0%, #16242a, var(--bg-0) 60%); padding: 20px; }
.auth-card { width: 360px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; }
.auth-card.wide { width: 440px; }
.auth-logo { width: 64px; height: 64px; align-self: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 24px; letter-spacing: -0.02em; }
.auth-sub { text-align: center; color: var(--dim); margin-bottom: 20px; }
.auth-card label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin: 12px 0 6px; }
.auth-card input, .settings-form input, .settings-form select {
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; color: var(--text); font-size: 14px; outline: none;
}
.auth-card input:focus { border-color: var(--accent); }
.auth-error { margin-top: 12px; color: #ff8a8a; font-size: 13px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 8px; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; border-radius: 8px; padding: 10px 16px; font-size: 14px; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-ghost { background: var(--bg-3); color: var(--dim); border-radius: 8px; padding: 10px 16px; font-weight: 600; }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.auth-toggle { text-align: center; margin-top: 16px; color: var(--dim); font-size: 13px; }

.wiz-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.wiz-dot { width: 28px; height: 4px; border-radius: 3px; background: var(--hover); }
.wiz-dot.on { background: var(--accent); }
.wiz-h { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.wiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }
.radio-row { display: flex; gap: 10px; }
.radio-card { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 12px; cursor: pointer; }
.radio-card.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.radio-card .rc-t { font-weight: 700; font-size: 13px; }
.radio-card .rc-d { font-size: 12px; color: var(--dim); margin-top: 3px; }

/* ---------------- bubbles (top tab bar) + app shell ---------------- */
.app-shell { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.app-shell > .app { flex: 1; min-height: 0; height: auto; }

.bubble-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--sidebar-bg); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  user-select: none; -webkit-user-select: none;
}
.bubble-bar::-webkit-scrollbar { display: none; }
.bubble {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 6px 14px; border-radius: 999px; border: 1px solid transparent;
  background: var(--bg-3); color: var(--dim); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.bubble:hover { color: var(--text); background: var(--hover); }
.bubble.active { background: var(--accent); color: #fff; border-color: transparent; }
.bubble .dd-off-chip { margin-left: 2px; }

/* On a tool bubble the tool fills the width. Use FLEX (not the grid with
   0-width side columns): display:none-ing grid items makes .main reflow into
   the first 0-width column and collapse — flex just drops the hidden panels. */
.app.on-tool { display: flex !important; }
.app.on-tool .sidebar, .app.on-tool .right { display: none; }
.app.on-tool .main { flex: 1 1 auto; min-width: 0; }

/* Keep-alive tool/chat panes: only the active one shows; the rest stay mounted.
   `display:contents` makes the visible wrapper layout-transparent, so each tool
   lays out exactly as if it were a direct child of .main (its original context);
   hidden panes are pulled out of layout entirely but stay mounted. */
.tab-pane { display: contents; }
.tab-pane.tab-hidden { display: none; }

/* ---------------- app shell (three panes) ---------------- */
.app { display: grid; grid-template-columns: 240px 1fr 220px; height: 100%; }

.sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ws-head { height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; }
.ws-head img { width: 26px; height: 26px; }
.ws-head span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-gear { color: var(--dim); font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.ws-gear:hover { background: var(--hover); color: var(--text); }

.chan-section { flex: 1; overflow-y: auto; padding: 10px 8px; min-height: 0; }
.chan-group { margin-bottom: 8px; }
.chan-label { display: flex; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); padding: 6px 8px 3px; }
.chan-label .add { margin-left: auto; font-size: 16px; line-height: 1; color: var(--faint); padding: 0 4px; }
.chan-label .add:hover { color: var(--text); }
.add-cat { width: 100%; text-align: left; font-size: 12px; color: var(--faint); padding: 6px 8px; border-radius: 6px; }
.add-cat:hover { background: var(--hover); color: var(--text); }
.chan { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 1px 0; border-radius: 6px; color: var(--dim); cursor: pointer; }
.chan:hover { background: var(--hover); color: var(--text); }
.chan.active { background: var(--active); color: #fff; }
.chan .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hash { color: var(--faint); font-weight: 600; }

.user-panel { border-top: 1px solid var(--line); background: var(--panel-bg); display: flex; align-items: center; gap: 9px; padding: 8px 10px; }
.user-panel .meta { flex: 1; min-width: 0; }
.user-panel .name { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.user-panel .status { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: var(--green); } .dot.off { background: var(--orange); }
.dot.dnd { background: #ed4245; } .dot.invis { background: #80848e; }
.logout { color: var(--dim); font-size: 17px; padding: 6px; border-radius: 6px; }
.logout:hover { background: var(--hover); color: var(--text); }

.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; }
.pdot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg-1); }
.pdot.on { background: var(--green); } .pdot.off { background: #5a6270; }

/* ---------------- main ---------------- */
.main { background: var(--main-bg); display: flex; flex-direction: column; min-width: 0; }
.main-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
.main-head .topic { color: var(--dim); font-size: 13px; border-left: 1px solid var(--line); padding-left: 12px; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.head-actions { margin-left: auto; display: flex; gap: 2px; }
.head-actions button { color: var(--dim); padding: 6px 8px; border-radius: 6px; }
.head-actions button:hover { background: var(--hover); color: var(--text); }

.messages { flex: 1; overflow-y: auto; padding: 16px 0; min-height: 0; }
.load-older { display: block; margin: 0 auto 10px; font-size: 12px; color: var(--accent); padding: 6px 12px; border-radius: 6px; }
.load-older:hover { background: var(--hover); }
.welcome { padding: 12px 18px 18px; }
.welcome img { width: 52px; height: 52px; margin-bottom: 8px; }
.welcome h2 { font-size: 22px; }
.welcome p { color: var(--dim); }

.msg { display: flex; gap: 18px; padding: 3px 22px; position: relative; }
/* Softened via color-mix so the row tint stays subtler than button hovers,
   while still coming from each theme's own --hover color. */
.msg:hover { background: color-mix(in srgb, var(--hover) 65%, transparent); }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
/* Extra breathing room before a new author's block; consecutive messages from
   the same person (grouped) stay tight. */
.msg:not(.grouped) { margin-top: 18px; }
.msg .gutter { width: 41px; flex-shrink: 0; }
.msg .avatar.sm { width: 41px; height: 41px; font-size: 14px; }
.msg .body { min-width: 0; flex: 1; }
.msg .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg .author { font-weight: 600; color: #fff; font-size: 16px; }
.msg .time { font-size: 13px; color: var(--faint); }
.msg .time em { font-style: normal; }
.msg .text { color: #dce0e6; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 1.45; }
.edit-input { width: 100%; background: var(--bg-0); border: 1px solid var(--accent); border-radius: 6px; padding: 7px 10px; color: var(--text); font-size: 15px; outline: none; }
.msg-actions { position: absolute; top: -10px; right: 14px; display: none; background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { padding: 6px 9px; color: var(--dim); font-size: 13px; }
.msg-actions button:hover { color: var(--text); }

.composer { padding: 0 16px 18px; display: flex; gap: 8px; }
.composer input { flex: 1; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 13px 20px; color: var(--text); font-size: 15px; outline: none; }
.composer input:focus { border-color: var(--accent); }
.composer .send { background: var(--blue); color: #fff; font-weight: 600; border-radius: 999px; padding: 0 22px; }
.composer .send:disabled { opacity: 0.5; cursor: default; }

.voice-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--dim); }
.voice-placeholder img { width: 56px; height: 56px; opacity: 0.8; }
.voice-placeholder h3 { color: var(--text); }

/* ---------------- right: members ---------------- */
.right { background: var(--sidebar-bg); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.right-head { height: 52px; display: flex; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--dim); letter-spacing: 0.02em; }
.right-scroll { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.mgroup { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); padding: 10px 8px 4px; }
.member { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 6px; }
.member:hover { background: var(--hover); }
.member.off { opacity: 0.5; }
.member .mn { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.role-tag { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; padding: 1px 5px; border-radius: 4px; }
.t-owner { background: rgba(240, 178, 50, 0.18); color: var(--yellow); }
.t-admin { background: rgba(155, 109, 255, 0.18); color: var(--purple); }
.t-member { background: rgba(47, 128, 237, 0.16); color: #8fb4ff; }
.t-guest { background: rgba(120, 130, 145, 0.18); color: #9aa3af; }

/* ---------------- settings modal ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 9, 11, 0.72); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 640px; max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-close { margin-left: auto; width: 30px; height: 30px; border-radius: 7px; color: var(--dim); font-size: 16px; }
.modal-close:hover { background: var(--hover); color: var(--text); }
.tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.tab { padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: #fff; border-color: var(--accent); }
.tab:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.settings-form { display: flex; flex-direction: column; max-width: 320px; }
.settings-form label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin: 14px 0 6px; }
.settings-form .btn-primary { margin-top: 20px; align-self: flex-start; }
/* Space between the last field (or error) and the Log in / Create account
   button — the glass glow otherwise touches the password input. */
.auth-card .btn-primary { margin-top: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td select { background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--text); }
.muted { color: var(--faint); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.pill.on { background: rgba(91, 200, 138, 0.16); color: var(--green); }
.pill.off { background: rgba(120, 130, 145, 0.16); color: var(--dim); }
.mini { font-size: 12px; color: var(--dim); padding: 4px 9px; border-radius: 6px; border: 1px solid var(--line); }
.mini:hover { background: var(--hover); color: var(--text); }
.invite-create { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.invite-create select, .invite-create input { background: var(--bg-0); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--text); outline: none; }
.code { font-family: var(--mono); background: var(--bg-0); padding: 2px 7px; border-radius: 5px; cursor: pointer; color: #cdd9ff; }

@media (max-width: 1100px) { .app { grid-template-columns: 220px 1fr; } .right { display: none; } }
@media (max-width: 640px) { .app { grid-template-columns: 1fr; } .sidebar { display: none; }  }
/* Attachments + upload UI (M2) */

/* Image/media attachments line up with the message text column — i.e. the
   image's left edge starts exactly where text begins (under the username), with
   no extra indent. align-items: flex-start so the wrappers (and the image
   inside) shrink-wrap to the photo's real width instead of stretching to the
   full message width — otherwise a portrait photo gets letterboxed/centered
   (object-fit: contain) inside an over-wide element and looks indented. */
.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; }

/* No frame — the photo sits in the message at its true aspect ratio, with just
   softly rounded corners (no border, no background fill). */
.att-image {
  max-width: 420px; max-height: 320px; width: auto; height: auto; border-radius: 8px;
  cursor: pointer; display: block; object-fit: contain; background: transparent;
}
.att-video { max-width: 480px; max-height: 340px; border-radius: 8px; border: 1px solid var(--line); background: #000; }
.att-audio { width: 360px; max-width: 100%; }

.att-file {
  display: flex; align-items: center; gap: 12px; max-width: 360px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 13px; text-decoration: none; color: var(--text);
}
.att-file:hover { border-color: var(--accent); }
.att-file .fi { width: 36px; height: 36px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 18%, transparent); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.att-file .fn { font-weight: 600; font-size: 13px; color: #cdd9ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .fs { font-size: 11px; color: var(--faint); }

.att-processing {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim);
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.att-processing .spin { width: 12px; height: 12px; border: 2px solid var(--faint); border-top-color: var(--accent); border-radius: 50%; animation: kp-spin 0.8s linear infinite; }
@keyframes kp-spin { to { transform: rotate(360deg); } }

/* composer upload chips */
.upload-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
.chip {
  display: flex; align-items: center; gap: 8px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; max-width: 240px; font-size: 12px;
}
.chip .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.chip .bar { width: 60px; height: 4px; background: #3a4049; border-radius: 3px; overflow: hidden; }
.chip .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.15s; }
.chip .x { color: var(--faint); cursor: pointer; font-size: 14px; }
.chip .x:hover { color: var(--text); }
.chip.err { border-color: var(--orange); color: #ffb39a; }
.chip .ok { color: var(--green); }

.composer .attach-btn {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--dim);
  border-radius: 10px; padding: 0 14px; font-size: 18px;
}
.composer .attach-btn:hover { color: var(--text); border-color: var(--accent); }
.messages.drag { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* Inline links + Discord-style unfurl preview cards. */
.msg-link { color: var(--accent); text-decoration: none; word-break: break-word; }
.msg-link:hover { text-decoration: underline; }

.link-card {
  display: block; max-width: 440px; margin-top: 6px; padding: 10px 12px;
  border-left: 4px solid var(--accent); background: var(--bg-2);
  border-radius: 4px 8px 8px 4px; text-decoration: none; overflow: hidden;
}
.link-card:hover { background: var(--bg-3); }
.lc-body { min-width: 0; }
.lc-site { color: var(--dim); font-size: 12px; margin-bottom: 3px; }
.lc-title { color: var(--accent); font-weight: 700; font-size: 15px; line-height: 1.3; word-break: break-word; }
.lc-desc {
  color: var(--dim); font-size: 13px; margin-top: 4px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.lc-thumb {
  position: relative; margin-top: 10px; border-radius: 8px;
  width: 100%; aspect-ratio: 16 / 9; max-height: 300px;
  background-size: cover; background-position: center; background-color: var(--bg-0);
}
/* Portrait thumbnails (e.g. TikTok 9:16) are letterboxed, not cropped, and kept
   to a sensible height so the card doesn't dominate the message list. */
.lc-thumb.portrait {
  aspect-ratio: auto; height: 320px; max-width: 240px;
  background-size: contain; background-repeat: no-repeat;
}
.lc-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.lc-play i {
  width: 56px; height: 56px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; padding-left: 3px;
}
.link-card:hover .lc-play i { background: rgba(0, 0, 0, 0.72); }

/* ---- Inline 3D model viewer ---- */
.mv-wrap {
  position: relative; width: min(520px, 100%); border-radius: 12px; overflow: hidden;
  background: radial-gradient(120% 130% at 50% 20%, #1c2230, #0b0e14 75%);
  border: 1px solid var(--line);
}
/* Works for both native fullscreen and the iOS CSS fallback: fixed+inset
   pins the viewer over the app; dvh tracks the collapsing browser chrome. */
.mv-wrap.fs { position: fixed; inset: 0; width: 100vw; height: 100dvh; z-index: 2000; border-radius: 0; background: var(--bg-2); }
.mv-canvas { width: 100%; height: 300px; cursor: grab; }
.mv-wrap.fs .mv-canvas { height: calc(100% - 40px); }
.mv-canvas:active { cursor: grabbing; }
.mv-canvas canvas { display: block; }
.mv-status {
  position: absolute; inset: 0 0 40px; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: #8fa0b5; font-size: 13px; pointer-events: none;
}
.mv-status.err { color: #e8a0a2; }
.mv-bar {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px;
  background: rgba(8, 10, 14, 0.75); border-top: 1px solid var(--line);
}
.mv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: #c8d2de; display: flex; gap: 8px; align-items: center; }
.mv-actions { display: flex; gap: 4px; }
.mv-actions button, .mv-actions a {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; color: #9fb0c3; font-size: 12.5px; cursor: pointer; background: transparent;
}
.mv-actions button:hover, .mv-actions a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.mv-actions button.on { background: var(--accent); color: #fff; }
.mv-mats {
  position: absolute; right: 10px; bottom: 48px; width: 290px; z-index: 5;
  max-width: calc(100% - 20px);
  /* Never taller than the viewer: cap to the wrap and scroll the slot list
     inside — otherwise long slot lists clip against the viewer's edges. */
  max-height: calc(100% - 58px);
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); padding: 12px;
}
.mv-mats-head, .mv-mats-foot, .mv-mats-empty { flex: 0 0 auto; }
.mv-mats-head { font-size: 12.5px; font-weight: 700; margin-bottom: 10px; }
.mv-mats-head .muted { display: block; font-weight: 400; font-size: 11px; margin-top: 2px; }
.mv-mat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mv-mat-label { width: 92px; flex: none; font-size: 12px; color: var(--dim); }
.mv-mat-row select {
  flex: 1; min-width: 0; background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 8px; font-size: 12px; outline: none;
}
.mv-mats-foot { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.mv-mats-foot button { white-space: nowrap; }
@media (max-width: 760px) { .mv-canvas { height: 240px; } }
.mv-mats-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.mv-slot { padding: 6px 0; }
.mv-slot + .mv-slot { border-top: 1px solid var(--line); }
.mv-slot-name { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.mv-slot-name i { color: var(--accent); font-size: 11px; }
.mv-mats-empty { font-size: 12px; color: var(--text-dim); line-height: 1.5; padding: 8px 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px dashed var(--line); border-radius: 8px; margin: 6px 0; }
.mv-mats-empty b { color: var(--text); font-weight: 600; }
.mv-wrap.droptex { outline: 2px dashed var(--accent); outline-offset: -2px; }
.mv-wrap.droptex::after { content: 'Drop textures to add them to this model'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg-2) 72%, transparent); color: var(--text); font-weight: 700; font-size: 14px; z-index: 6; pointer-events: none; border-radius: inherit; }

/* Inline YouTube player (click-to-load facade → iframe). */
.link-card.yt-card { max-width: 480px; padding: 10px 12px 12px; }
.yt-embed, .yt-facade {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
  margin-top: 8px; padding: 0; border: none; border-radius: 10px; overflow: hidden;
  background-color: #000; background-position: center; background-size: cover; background-repeat: no-repeat;
  cursor: pointer;
}
.yt-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.yt-play i { font-size: 52px; color: #ff0000; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5)); transition: transform .12s ease; }
.yt-facade:hover .yt-play i { transform: scale(1.08); }
/* Voice room (M3) */
.voice-join {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--dim);
}
.voice-join img { width: 56px; height: 56px; }
.voice-join h3 { color: var(--text); }
.voice-join .btn-primary { margin-top: 8px; }

.voice-room { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #14161b; }
.voice-stage {
  flex: 1; overflow: auto; padding: 16px;
  display: grid; gap: 12px; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  /* Size container so tiles can bound themselves to the stage height. */
  container-type: size;
}
.tile {
  position: relative; background: #0e1013; border: 1px solid #2a2f37; border-radius: 12px;
  aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; overflow: hidden;
  /* Never taller than the stage: with 1-2 people on camera a tile used to
     take the full grid column width, and 16/10 of a full-width column is far
     taller than the stage (giant video + scrolling). Bounding by container
     height keeps the whole tile in frame, centered. */
  width: 100%; max-width: calc(96cqh * 1.6); max-height: 96cqh; margin: 0 auto;
}
.tile.speaking { box-shadow: 0 0 0 2px var(--green); border-color: var(--green); }
.tile.screen { grid-column: 1 / -1; aspect-ratio: 16 / 9; background: #000; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile-avatar {
  width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.tile-label {
  position: absolute; bottom: 8px; left: 10px; background: rgba(0, 0, 0, 0.6); color: #eaeef3;
  padding: 2px 9px; border-radius: 6px; font-size: 12px; display: flex; align-items: center; gap: 6px;
}

.voice-bar {
  height: 72px; flex-shrink: 0; background: #1b1e24; border-top: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.vb-info { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 8px; flex: 1; }
.vb-controls { display: flex; gap: 10px; }
.vb-spacer { flex: 1; }
.q { width: 9px; height: 9px; border-radius: 50%; background: #5a6270; display: inline-block; }
.q-excellent { background: var(--green); } .q-good { background: var(--green); }
.q-poor { background: var(--yellow); } .q-lost { background: var(--orange); }
.vctrl {
  width: 46px; height: 46px; border-radius: 50%; background: var(--bg-3); color: var(--text);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.vctrl:hover { background: var(--hover); }
.vctrl.on { background: #fff; color: #15171b; }
.vctrl.off { background: var(--bg-3); color: var(--orange); }
.vctrl.leave { background: var(--orange); color: #fff; }
.vctrl.leave:hover { background: #d9542c; }

/* sidebar voice participants */
.vc-members { padding: 1px 0 4px 22px; }
.vc-member { display: flex; align-items: center; gap: 7px; padding: 3px 8px; font-size: 13px; color: var(--dim); }
.vc-member .va {
  width: 18px; height: 18px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
/* Real-time speaking highlight in the sidebar call list — green ring on the
   avatar + brighter name, matching the call tiles/pucks. */
.vc-member .avatar { box-shadow: 0 0 0 0 rgba(59, 165, 93, 0); transition: box-shadow 0.12s ease; }
.vc-member.speaking .avatar { box-shadow: 0 0 0 2px #3ba55d; }
.vc-member.speaking { color: var(--text); }

/* Raise-hand badge on a puck/tile; the hand waves briefly every few seconds. */
.kp-hand {
  position: absolute; top: 6px; left: 6px; z-index: 4;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(240, 192, 64, 0.96); color: #3b2a00;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.kp-hand i { transform-origin: 65% 80%; animation: kp-wave 3.2s ease-in-out infinite; }
@keyframes kp-wave {
  0%, 68%, 100% { transform: rotate(0deg); }
  72% { transform: rotate(-16deg); }
  77% { transform: rotate(13deg); }
  82% { transform: rotate(-11deg); }
  87% { transform: rotate(9deg); }
  92% { transform: rotate(0deg); }
}

/* ---- Region screen share selector ---- */
.region-modal { max-width: 720px !important; width: 100%; }
.region-stage { position: relative; width: 100%; border-radius: 12px; overflow: hidden; background: #000; cursor: crosshair; touch-action: none; }
.region-stage video { display: block; width: 100%; pointer-events: none; }
.region-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); pointer-events: none; }
.region-rect {
  position: absolute; pointer-events: none; box-sizing: border-box;
  border: 2px dashed #fff; border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}
.region-foot-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.region-screen-pick { max-width: 220px; appearance: auto; }
/* M4 collaboration polish: reactions, replies, mentions, pins, typing, search, DMs */

.mention { background: rgba(47, 128, 237, 0.22); color: #cdd9ff; border-radius: 4px; padding: 0 3px; font-weight: 600; }
.ch-link { color: #8fb4ff; }

.reply-context {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim);
  margin-bottom: 2px; opacity: 0.9;
}
.reply-context .ra { font-weight: 600; color: #bcc4d0; }
.reply-context .rs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }

/* Settings → Emojis tab */
.emj-tab { display: flex; flex-direction: column; gap: 12px; }
.emj-add { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.emj-naming { display: flex; align-items: center; gap: 6px; }
.emj-naming input { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 6px 10px; font-family: ui-monospace, monospace; font-size: 13px; width: 220px; }
.emj-preview { width: 32px; height: 32px; object-fit: contain; }
.emj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; }
.emj-cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 10px; }
.emj-cell:hover { background: var(--hover); }
.emj-img { width: 32px; height: 32px; object-fit: contain; }
.emj-name { font-size: 11px; color: var(--dim); font-family: ui-monospace, monospace; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emj-del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 6px; color: var(--dim); opacity: 0; }
.emj-cell:hover .emj-del { opacity: 1; }
.emj-del:hover { color: #ed4245; background: var(--hover); }

/* Custom emojis: inline in message text, reaction pills, autocomplete rows */
.cemoji { height: 1.4em; width: auto; max-width: 3em; vertical-align: -0.3em; object-fit: contain; }

/* Jumbo: emoji-only messages render big, Discord-style */
.msg .text.jumbo { font-size: 42px; line-height: 1.25; }
.msg .text.jumbo .cemoji { height: 48px; max-width: 5em; vertical-align: middle; }
.rx .cemoji { height: 20px; vertical-align: middle; }
.rx-tip-emoji .cemoji { height: 28px; }

/* Notification-click landing: briefly highlight the message that pinged you */
.msg.msg-flash { animation: kp-msg-flash 2.4s ease-out; border-radius: 8px; }
@keyframes kp-msg-flash {
  0%, 40% { background: color-mix(in srgb, var(--accent) 22%, transparent); }
  100% { background: transparent; }
}

.reactions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.rx {
  display: flex; align-items: center; gap: 5px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 12px; padding: 3px 10px; font-size: 20px; cursor: pointer;
}
.rx:hover { border-color: var(--accent-dim, #33508c); }
.rx.mine { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.rx .cnt { color: var(--dim); font-weight: 600; font-size: 13px; }
.rx-add { background: var(--bg-3); border: 1px solid var(--line); border-radius: 11px; padding: 2px 8px; font-size: 15px; color: var(--faint); cursor: pointer; }
.rx-add:hover { color: var(--text); }

/* Discord-style "who reacted" tooltip on hover */
.rx { position: relative; }
.rx .rx-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(2px);
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px;
  background: var(--bg-3, #1a1d22); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  white-space: normal; width: max-content; max-width: 240px; text-align: left; z-index: 30;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease; transition-delay: 0s;
}
.rx:hover .rx-tip { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); transition-delay: 0.25s; }
.rx .rx-tip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--bg-3, #1a1d22);
}
.rx-tip-emoji { font-size: 26px; line-height: 1; }
.rx-tip-text { font-size: 12.5px; color: var(--dim); line-height: 1.4; }
.rx-tip-text b { color: var(--text); font-weight: 600; }

.emoji-pop {
  position: absolute; z-index: 30; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px; display: flex; gap: 4px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.emoji-pop button { font-size: 18px; padding: 3px 5px; border-radius: 6px; }
.emoji-pop button:hover { background: var(--hover); }

.pin-flag { font-size: 11px; color: var(--yellow); margin-top: 3px; display: inline-flex; gap: 4px; align-items: center; }

.reply-bar, .typing-line {
  padding: 6px 18px; font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 8px;
}
.reply-bar { background: var(--bg-3); border-top: 1px solid var(--line); }
.reply-bar .x { margin-left: auto; cursor: pointer; color: var(--faint); }
.reply-bar .x:hover { color: var(--text); }
.typing-line { height: 20px; }
.typing-line .dots span { animation: kpblink 1.2s infinite; }
.typing-line .dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-line .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes kpblink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* unread badges */
.chan .badge, .dm-row .badge {
  margin-left: auto; background: var(--bg-hover, #2c313a); color: var(--text); font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 0 6px; min-width: 18px; text-align: center;
}
.chan .badge.mention, .dm-row .badge.mention { background: var(--red, #ed4245); color: #fff; }
.chan.unread .cn, .dm-row.unread .nm { color: #fff; font-weight: 600; }

/* DM section */
.dm-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 1px 0; border-radius: 6px; color: var(--dim); cursor: pointer; }
.dm-row:hover { background: var(--hover); color: var(--text); }
.dm-row.active { background: var(--active); color: #fff; }
.dm-row .da { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dm-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* search + pins panels (reuse .overlay/.modal from styles.css) */
.search-box { display: flex; gap: 8px; margin-bottom: 14px; }
.search-box input { flex: 1; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; color: var(--text); outline: none; }
.search-box input:focus { border-color: var(--accent); }
.result { padding: 10px 8px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.result:hover { background: #1e242c; }
.result .rh { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.result .rh b { color: #fff; }
.result .rh .where { color: var(--faint); }
.result .rc { color: #dce0e6; margin-top: 2px; }

.icon-btn { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--dim); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.pins-list .msg { padding: 8px 4px; border-bottom: 1px solid var(--line); }
/* M4b: read-only composer + notification menu */
.composer-readonly {
  margin: 0 16px 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--faint); font-size: 13px; text-align: center; background: var(--bg-3);
}

.notif-wrap { position: relative; }
.notif-menu {
  position: absolute; right: 0; top: 38px; z-index: 30; width: 200px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.notif-menu .item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; width: 100%; text-align: left; }
.notif-menu .item:hover { background: var(--hover); }
.notif-menu .item.sel { color: #fff; }
.notif-menu .item.sel::after { content: '✓'; margin-left: auto; color: var(--accent); }
.notif-menu .sep { height: 1px; background: var(--line); margin: 5px 2px; }
.icon-btn.has-menu.on { color: #fff; }
/* Layout robustness: the "chrome" (headers, composer, user panel) must always
   stay visible; only the scroll regions flex. Fixes elements getting clipped
   when the window is resized. The crucial bit is min-height:0 on the flex
   columns so a tall message list scrolls instead of pushing the composer off. */

.app { min-height: 0; }
.sidebar, .main, .right { min-height: 0; min-width: 0; }

.ws-head,
.user-panel,
.main-head,
.composer,
.composer-readonly,
.reply-bar,
.typing-line,
.upload-chips,
.voice-bar {
  flex-shrink: 0;
}

.chan-section,
.messages,
.right-scroll,
.voice-stage {
  min-height: 0;
}

.user-panel .meta { min-width: 0; }
.user-panel .name { text-overflow: ellipsis; }
.composer input { min-width: 0; }

/* Brand: bigger Dogfish Games badge on the login screen. */
.auth-logo { width: 96px; height: 96px; }
/* Avatars as images */
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar { overflow: hidden; }
.avatar.xl { width: 96px; height: 96px; font-size: 30px; }

/* Context menu (right-click) */
.ctx-menu {
  position: fixed; z-index: 200; min-width: 210px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.ctx-item {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text); cursor: pointer; user-select: none;
}
.ctx-item:hover { background: var(--accent); color: #fff; }
.ctx-item.danger { color: #ff8a8a; }
.ctx-item.danger:hover { background: var(--red, #ed4245); color: #fff; }
.ctx-item.disabled { opacity: 0.4; cursor: default; }
.ctx-item.disabled:hover { background: transparent; color: var(--text); }
.ctx-item .ci { width: 18px; text-align: center; }
.ctx-item .cl { flex: 1; }
.ctx-item .ca { color: var(--dim); }

/* Voice user menu (right-click a person in a call) */
.vum-head {
  display: flex; align-items: center; gap: 9px; padding: 8px 9px 9px; margin-bottom: 3px;
  border-bottom: 1px solid var(--line);
}
.vum-name { font-weight: 700; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vum-vol { padding: 8px 10px 10px; }
.vum-vol-top { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--dim); margin-bottom: 7px; }
.vum-vol-top .fa-solid { margin-right: 6px; }
.vum-pct { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.vum-vol input[type="range"] { display: block; }
.vum-sub { padding-left: 24px; }
.vum-sub .ci { color: var(--dim); }
.ctx-item:hover .ca { color: #fff; }
.ctx-item .ck { color: var(--accent); }
.ctx-item:hover .ck { color: #fff; }
.ctx-item.on { color: #fff; }
.ctx-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.ctx-submenu {
  position: absolute; left: 100%; top: -6px; min-width: 190px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
/* Flip the submenu when it would run off the viewport edge. */
.ctx-submenu.up { top: auto; bottom: -6px; }
.ctx-submenu.left { left: auto; right: 100%; }

/* Create-channel modal */
.create-modal { max-width: 480px; }
.ctype { display: flex; gap: 10px; margin-bottom: 16px; }
.ctype-opt { flex: 1; display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--text); }
.ctype-opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.ctype-opt .ct-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-0); display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--dim); }
.create-modal label, .profile-modal label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin: 12px 0 6px; }
.create-modal input, .create-modal select, .profile-modal input, .profile-modal textarea {
  width: 100%; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; font-family: inherit;
}
.create-modal input:focus, .profile-modal input:focus, .profile-modal textarea:focus { border-color: var(--accent); }
.name-row { display: flex; gap: 8px; }
.emoji-btn { width: 44px; flex-shrink: 0; background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; font-size: 18px; }
.emoji-btn:hover { border-color: var(--accent); }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.emoji-grid .eg { width: 32px; height: 32px; border-radius: 7px; font-size: 17px; }
.emoji-grid .eg:hover { background: var(--hover); }
.emoji-grid .eg.sel { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* Profile modal */
.profile-modal { max-width: 460px; }
.profile-view { text-align: center; }
.profile-view .avatar.xl { margin: 0 auto 12px; }
.profile-view h2 { font-size: 22px; }
.pf-status { margin-top: 8px; font-size: 14px; }
.pf-bio { margin-top: 12px; color: var(--dim); white-space: pre-wrap; }
.pf-row { margin-top: 10px; font-size: 13px; }
.pf-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }

/* drag-reorder */
.chan.drag-over { box-shadow: inset 0 2px 0 var(--accent); }
.chan[draggable='true'] { cursor: grab; }
.user-panel .name { cursor: pointer; }
.user-panel .name:hover { text-decoration: underline; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 250;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
/* Keep logos at their natural aspect ratio inside fixed boxes. */
.ws-head img, .welcome img, .voice-join img, .voice-room img { object-fit: contain; }

/* Unread divider */
.unread-divider {
  display: flex; align-items: center; gap: 10px; margin: 8px 16px;
  color: var(--red, #ed4245); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.unread-divider::before, .unread-divider::after { content: ''; flex: 1; height: 1px; background: var(--red, #ed4245); opacity: 0.45; }

/* Date divider between messages from different days (Discord-style) */
.date-divider {
  display: flex; align-items: center; gap: 10px; margin: 16px 16px 4px;
  color: var(--faint); font-size: 11.5px; font-weight: 700;
}
.date-divider::before, .date-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* @mention autocomplete */
.mention-pop {
  position: absolute; bottom: 100%; left: 16px; margin-bottom: 6px; width: 250px; max-height: 230px; overflow: auto;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45); z-index: 40; padding: 5px;
}
.mention-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.mention-row.sel, .mention-row:hover { background: var(--accent); color: #fff; }
.mention-row .mu { color: var(--dim); font-size: 12px; }
.mention-row.sel .mu, .mention-row:hover .mu { color: #dbe7ff; }

/* Discord-style profile card */
.profile-card { position: fixed; z-index: 240; width: 280px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); overflow: hidden; }
.pc-banner { height: 56px; background: linear-gradient(135deg, var(--teal), var(--blue)); }
.pc-body { padding: 0 16px 16px; margin-top: -30px; }
.pc-body .avatar { width: 68px; height: 68px; font-size: 24px; border: 4px solid var(--bg-2); }
.pc-name { font-size: 19px; font-weight: 700; margin-top: 8px; }
.pc-sub { color: var(--dim); font-size: 13px; text-transform: capitalize; }
.pc-status { margin-top: 8px; font-size: 13px; }
.pc-bio { margin-top: 10px; font-size: 13px; color: var(--dim); white-space: pre-wrap; }
.pc-row { margin-top: 8px; font-size: 12px; color: var(--dim); }
.pc-actions { margin-top: 14px; display: flex; gap: 8px; }
.pc-actions button { flex: 1; }

/* Notepad button */
.notepad-btn { display: flex; align-items: center; gap: 8px; padding: 7px 8px; margin: 4px 0 2px; border-radius: 6px; color: var(--dim); cursor: pointer; width: 100%; text-align: left; font-size: 14px; }
.notepad-btn:hover { background: var(--hover); color: var(--text); }
.notepad-btn.active { background: var(--active); color: #fff; }
.notepad-btn .npi { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #5bc88a, #159a8a); display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }

/* ---- Themed confirm dialog (replaces window.confirm) ---- */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(6, 8, 11, 0.6);
}
.confirm-box {
  width: 100%; max-width: 380px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { font-size: 14px; line-height: 1.5; color: var(--dim); white-space: pre-wrap; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.confirm-actions button { padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.btn-danger { background: #dc3c3e; color: #fff; border-radius: 8px; }
.btn-danger:hover { background: #e4494b; }

/* ---- "View as" preview (owner only) ---- */
.preview-wrap { position: relative; margin-left: auto; }
.preview-eye { padding: 0 12px; }
.preview-eye.on { background: var(--yellow); color: #1a1200; border-color: var(--yellow); }
.preview-scrim { position: fixed; inset: 0; z-index: 3000; }
.preview-menu {
  /* Fixed + portalled to <body>: the bubble bar's overflow-x would otherwise
     clip it, and no z-index can escape an ancestor that clips. */
  position: fixed; z-index: 3001; transform: translateX(-100%);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; min-width: 170px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 2px;
}
.preview-menu p { margin: 2px 6px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.preview-menu button {
  text-align: left; padding: 7px 10px; border-radius: 7px;
  background: transparent; color: var(--text); font-size: 13px; cursor: pointer;
}
.preview-menu button:hover { background: var(--hover); }

.preview-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 16px; font-size: 13px;
  background: var(--yellow); color: #1a1200; font-weight: 600;
}
.preview-bar i { opacity: .8; }
.preview-bar .mini {
  margin-left: auto; background: rgba(0,0,0,.22); color: #1a1200;
  border: none; font-weight: 700;
}
.preview-bar .mini:hover { background: rgba(0,0,0,.34); }
/* Color schemes. Dark is the default (defined in styles.css :root). Each theme
   also defines its own surface gradients: --sidebar-bg (side columns, dark top →
   lighter/bluer bottom), --panel-bg (bottom-left "me" panel, a subtle golden
   circular glow) and --main-bg (flat central chat surface). */

[data-theme='light'] {
  --bg-0: #ffffff; --bg-1: #f3f5f8; --bg-2: #ffffff; --bg-3: #eef1f5;
  --hover: #e7edf3; --active: #dbe4ee; --line: #e1e6ec;
  --text: #1b2330; --dim: #5c6573; --faint: #8b94a1;
  --sidebar-bg: linear-gradient(180deg, #eef1f6 0%, #e6edf8 58%, #d9e7fc 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(240,184,64,0.22), rgba(240,184,64,0.06) 45%, rgba(255,255,255,0) 72%), #eef1f5;
  --main-bg: #ffffff;
  /* Light theme keeps the viewer readable with a medium gray (not near-black). */
  --lb-backdrop: rgba(82, 88, 97, 0.96);
}
[data-theme='light'] .messages, [data-theme='sakura'] .messages { background: #fff; }

[data-theme='gray'] {
  --bg-0: #1f2123; --bg-1: #292c2f; --bg-2: #303336; --bg-3: #393d41;
  --hover: #41464c; --active: #4b5158; --line: #3c4147;
  --text: #e6e8ea; --dim: #a3a8af; --faint: #777d85;
  --sidebar-bg: linear-gradient(180deg, #232527 0%, #29313f 58%, #2e3a52 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(240,184,64,0.16), rgba(240,184,64,0.045) 44%, rgba(0,0,0,0) 72%), #202224;
  --main-bg: #1a1c1e;
}

[data-theme='retro'] {
  --bg-0: #1a1410; --bg-1: #221a13; --bg-2: #2a2017; --bg-3: #34281d;
  --hover: #3d3022; --active: #4a3a28; --line: #3a2d1f;
  --text: #f0d9b5; --dim: #c2a47c; --faint: #8a7050;
  --blue: #e0a13e; --green: #a7c957; --teal: #c98b2e;
  /* Warm variant: top dark amber → lighter toasted amber at the bottom. */
  --sidebar-bg: linear-gradient(180deg, #1c150e 0%, #2a1f14 55%, #3a2c1a 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(224,161,62,0.24), rgba(224,161,62,0.07) 46%, rgba(0,0,0,0) 72%), #1a130c;
  --main-bg: #17110b;
}

[data-theme='sea'] {
  --bg-0: #061a2b; --bg-1: #0b2436; --bg-2: #0e2c42; --bg-3: #123851;
  --hover: #164460; --active: #1c5272; --line: #15415d;
  --text: #e0f3fb; --dim: #8fc1da; --faint: #5e93ad;
  --blue: #22b8c4; --teal: #1fb6a8; --green: #4fd1a6;
  /* Deep navy → brighter teal at the bottom. */
  --sidebar-bg: linear-gradient(180deg, #061a2b 0%, #0b2f48 55%, #114f60 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(240,184,64,0.18), rgba(240,184,64,0.05) 45%, rgba(0,0,0,0) 72%), #07202f;
  --main-bg: #051420;
}

/* Light theme readability: several elements hardcode white text that assumed a
   dark background. On the light theme those backgrounds are pale, so switch the
   text to the theme's dark --text (or accent) to keep them readable. */
[data-theme='light'] .msg .author, [data-theme='sakura'] .msg .author { color: var(--text); }
[data-theme='light'] .chan.active,
[data-theme='sakura'] .chan.active,
[data-theme='light'] .dm-row.active,
[data-theme='sakura'] .dm-row.active,
[data-theme='light'] .notepad-btn.active, [data-theme='sakura'] .notepad-btn.active { color: var(--text); }
[data-theme='light'] .chan.unread .cn,
[data-theme='sakura'] .chan.unread .cn,
[data-theme='light'] .dm-row.unread .nm, [data-theme='sakura'] .dm-row.unread .nm { color: var(--text); }
[data-theme='light'] .tab.active,
[data-theme='sakura'] .tab.active,
[data-theme='light'] .icon-btn.has-menu.on,
[data-theme='sakura'] .icon-btn.has-menu.on,
[data-theme='light'] .ctx-item.on,
[data-theme='sakura'] .ctx-item.on,
[data-theme='light'] .notif-menu .item.sel, [data-theme='sakura'] .notif-menu .item.sel { color: var(--accent); }
[data-theme='light'] .result .rh b, [data-theme='sakura'] .result .rh b { color: var(--text); }
[data-theme='light'] .welcome p,
[data-theme='sakura'] .welcome p,
[data-theme='light'] .typing-line, [data-theme='sakura'] .typing-line { color: var(--dim); }

/* The category "+" (create-channel) button sits on a dark-glass chip. On the
   light theme its faint grey "+" disappears against that chip, so force the
   glyph white here only — other themes keep their existing colour. */
[data-theme='light'] .chan-label .add,
[data-theme='sakura'] .chan-label .add,
[data-theme='light'] .chan-label .add:hover, [data-theme='sakura'] .chan-label .add:hover { color: #fff; }

/* =====================================================================
   Desktop (Electron) custom title bar. Each theme sets --titlebar to the
   same color as the TOP of its --sidebar-bg gradient, so the window chrome
   reads as one continuous surface (like Discord). --titlebar-text drives
   both our label and the native min/max/close symbols (via IPC). */
:root { --titlebar: #0f131b; --titlebar-text: #e7ebf0; }
[data-theme='light'] { --titlebar: #eef1f6; --titlebar-text: #1b2330; }
[data-theme='gray'] { --titlebar: #232527; --titlebar-text: #e6e8ea; }
[data-theme='retro'] { --titlebar: #1c150e; --titlebar-text: #f0d9b5; }
[data-theme='sea'] { --titlebar: #061a2b; --titlebar-text: #e0f3fb; }
[data-theme='midnight'] { --titlebar: #0a0a14; --titlebar-text: #e6e4f5; }
[data-theme='forest'] { --titlebar: #0d1710; --titlebar-text: #e3f0e6; }
[data-theme='sakura'] { --titlebar: #fdeef3; --titlebar-text: #3a2a33; }
[data-theme='sunset'] { --titlebar: #1a0f18; --titlebar-text: #f5e3dc; }
[data-theme='nord'] { --titlebar: #2b303b; --titlebar-text: #eceff4; }
[data-theme='terminal'] { --titlebar: #030503; --titlebar-text: #c8facc; }



/* ---- Six additional themes ---- */

[data-theme='midnight'] {
  --bg-0: #0a0a12; --bg-1: #10101c; --bg-2: #151525; --bg-3: #1c1c30;
  --hover: #24243c; --active: #2d2d4a; --line: #202036;
  --text: #e6e4f5; --dim: #a29ec4; --faint: #6d6a92;
  --accent: #7c5cff; --blue: #7c5cff; --teal: #5cb3ff;
  --sidebar-bg: linear-gradient(180deg, #0a0a14 0%, #131332 58%, #1b1b48 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(124,92,255,0.20), rgba(124,92,255,0.06) 45%, rgba(0,0,0,0) 72%), #0a0a12;
  --main-bg: #07070d;
}

[data-theme='forest'] {
  --bg-0: #0f1a12; --bg-1: #14211a; --bg-2: #182920; --bg-3: #1f3428;
  --hover: #274031; --active: #2f4d3b; --line: #23392c;
  --text: #e3f0e6; --dim: #9fc0a9; --faint: #6b8f77;
  --accent: #4caf6e; --green: #4caf6e; --teal: #3d9c82;
  --sidebar-bg: linear-gradient(180deg, #0d1710 0%, #14291c 55%, #1b3a26 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(76,175,110,0.18), rgba(76,175,110,0.05) 45%, rgba(0,0,0,0) 72%), #0e1811;
  --main-bg: #0b140d;
}

[data-theme='sakura'] {
  --bg-0: #fff7f9; --bg-1: #fbeef2; --bg-2: #ffffff; --bg-3: #f7e4ea;
  --hover: #f3d9e2; --active: #eccbd8; --line: #eed7de;
  --text: #3a2a33; --dim: #8a6a78; --faint: #b394a2;
  --accent: #e0559a;
  --sidebar-bg: linear-gradient(180deg, #fdeef3 0%, #fbdce8 58%, #f7cbdd 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(224,85,154,0.16), rgba(224,85,154,0.05) 45%, rgba(255,255,255,0) 72%), #fbeef2;
  --main-bg: #ffffff;
  --lb-backdrop: rgba(97, 78, 88, 0.96);
}
[data-theme='sakura'] .messages { background: #fff; }

[data-theme='sunset'] {
  --bg-0: #1a1016; --bg-1: #221520; --bg-2: #2a1a26; --bg-3: #35202e;
  --hover: #422939; --active: #4f3143; --line: #3a2433;
  --text: #f5e3dc; --dim: #c9a49c; --faint: #90716c;
  --accent: #ff7849; --blue: #ff9f68; --teal: #ff6d8a;
  --sidebar-bg: linear-gradient(180deg, #1a0f18 0%, #3a1b33 55%, #5a2440 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(255,120,73,0.20), rgba(255,120,73,0.06) 45%, rgba(0,0,0,0) 72%), #190f15;
  --main-bg: #150c12;
}

[data-theme='nord'] {
  --bg-0: #2e3440; --bg-1: #333a48; --bg-2: #3b4252; --bg-3: #434c5e;
  --hover: #4c566a; --active: #566078; --line: #454e60;
  --text: #eceff4; --dim: #aeb6c5; --faint: #7d8697;
  --accent: #88c0d0; --blue: #81a1c1; --green: #a3be8c; --teal: #8fbcbb;
  --sidebar-bg: linear-gradient(180deg, #2b303b 0%, #333a48 58%, #3b4557 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(136,192,208,0.16), rgba(136,192,208,0.05) 45%, rgba(0,0,0,0) 72%), #2c313d;
  --main-bg: #292e39;
}

[data-theme='terminal'] {
  --bg-0: #050805; --bg-1: #081008; --bg-2: #0a150c; --bg-3: #0e1e10;
  --hover: #132916; --active: #18341c; --line: #122815;
  --text: #c8facc; --dim: #7fbf88; --faint: #4d7d55;
  --accent: #33ff66; --green: #33ff66; --blue: #37d9a0; --teal: #2bd482;
  --sidebar-bg: linear-gradient(180deg, #030503 0%, #07140a 55%, #0a1f0e 100%);
  --panel-bg: radial-gradient(130% 150% at 26% 50%, rgba(51,255,102,0.14), rgba(51,255,102,0.04) 45%, rgba(0,0,0,0) 72%), #040704;
  --main-bg: #030503;
}
[data-theme='terminal'] .btn-primary { color: #04140a; }

/* ---- Under the Sea: ambient effects (bubbles + drifting fish) ----
   Rendered by SeaEffects.tsx inside both side columns; invisible on every
   other theme, and fully disabled for reduced-motion users. */
.sea-fx { display: none; }
/* overflow keeps fish/bubbles clipped inside the bars. position: relative is
   desktop-only: on mobile the bars are position:fixed drawers, and this
   higher-specificity rule must NOT override that (it collapsed the whole
   phone layout when it did — the drawers fell back into the grid flow). */
[data-theme='sea'] .sidebar, [data-theme='sea'] .right { overflow: hidden; }
@media (min-width: 761px) {
  [data-theme='sea'] .sidebar, [data-theme='sea'] .right { position: relative; }
}
[data-theme='sea'] .sea-fx { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 0; }

.sea-bubble {
  position: absolute; bottom: -14px; border-radius: 50%;
  background: rgba(180, 230, 255, 0.14);
  box-shadow: inset 0 0 4px rgba(220, 245, 255, 0.4);
  animation: sea-rise linear infinite;
}
@keyframes sea-rise {
  0%   { transform: translate(0, 0); opacity: 0; }
  8%   { opacity: 0.75; }
  30%  { transform: translate(6px, -30vh); }
  55%  { transform: translate(-5px, -55vh); }
  80%  { transform: translate(7px, -80vh); opacity: 0.45; }
  100% { transform: translate(0, -104vh); opacity: 0; }
}

.sea-fish { position: absolute; left: 0; animation: sea-swim linear infinite; opacity: 0.55; }
.sea-fish img { display: block; animation: sea-bob 5.5s ease-in-out infinite alternate; }
.sea-fish.rev { animation-name: sea-swim-rev; }
.sea-fish.rev img { transform: scaleX(-1); }
@keyframes sea-swim { from { translate: -70px 0; } to { translate: 380px 0; } }
@keyframes sea-swim-rev { from { translate: 380px 0; } to { translate: -70px 0; } }
@keyframes sea-bob { from { margin-top: -5px; rotate: -2deg; } to { margin-top: 6px; rotate: 2.5deg; } }

@media (prefers-reduced-motion: reduce) { .sea-fx { display: none !important; } }

/* ---- Custom theme editor ---- */
.th-fields { display: flex; flex-direction: column; gap: 8px; }
.th-field {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.th-field input[type='color'] {
  width: 40px; height: 30px; border: none; background: none; padding: 0; cursor: pointer;
}
.th-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.th-label { font-size: 14px; font-weight: 600; }
.th-hint { font-size: 11px; color: var(--faint); }
.th-hex { font-family: var(--mono); font-size: 12px; color: var(--dim); }


/* ---- Theme-change transition: bouncy circle reveal ----
   The new theme's snapshot pops out of the last click point (--vt-x/--vt-y,
   set by theme.ts), overshoots with a springy scale wobble, and settles.
   Only runs when theme.ts calls document.startViewTransition. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) {
  z-index: 2;
  animation: kp-theme-pop 640ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
  transform-origin: var(--vt-x, 50%) var(--vt-y, 50%);
}
@keyframes kp-theme-pop {
  0%   { clip-path: circle(0px at var(--vt-x, 50%) var(--vt-y, 50%)); transform: scale(0.96); }
  55%  { clip-path: circle(145% at var(--vt-x, 50%) var(--vt-y, 50%)); transform: scale(1.014); }
  74%  { transform: scale(0.995); }
  88%  { transform: scale(1.004); }
  100% { clip-path: circle(150% at var(--vt-x, 50%) var(--vt-y, 50%)); transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}
/* Custom tags */
.utag { display: inline-flex; align-items: center; height: 16px; padding: 0 6px; border-radius: 8px; font-size: 10px; font-weight: 700; color: #fff; letter-spacing: .2px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.mtags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-left: auto; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ---- Theme-aware text colors (audit). ---- */
.msg .text { color: var(--text); }
.msg .author { color: var(--text); }
.reply-context .ra { color: var(--dim); }
.result .rh b { color: var(--text); }
.result .rc { color: var(--dim); }
.att-file .fn { color: var(--text); }
[data-theme='light'] .mention,
[data-theme='sakura'] .mention,
[data-theme='light'] .ch-link,
[data-theme='sakura'] .ch-link,
[data-theme='light'] .code, [data-theme='sakura'] .code { color: #1d4ed8; }
[data-theme='light'] .chan.active,
[data-theme='sakura'] .chan.active,
[data-theme='light'] .dm-row.active,
[data-theme='sakura'] .dm-row.active,
[data-theme='light'] .notepad-btn.active,
[data-theme='sakura'] .notepad-btn.active,
[data-theme='light'] .chan.unread .cn,
[data-theme='sakura'] .chan.unread .cn,
[data-theme='light'] .dm-row.unread .nm, [data-theme='sakura'] .dm-row.unread .nm { color: var(--text); }
[data-theme='light'] .tab.active,
[data-theme='sakura'] .tab.active,
[data-theme='light'] .ctx-item.on,
[data-theme='sakura'] .ctx-item.on,
[data-theme='light'] .notif-menu .item.sel,
[data-theme='sakura'] .notif-menu .item.sel,
[data-theme='light'] .icon-btn.has-menu.on, [data-theme='sakura'] .icon-btn.has-menu.on { color: var(--accent); }

/* Avatar presence dot must not be clipped by the avatar circle. */
.avatar { overflow: visible; }
.pdot.idle, .dot.idle { background: #f0b232 !important; }
.pdot.dnd { background: #ed4245; }

/* Suspended members */
.member.suspended .mn { text-decoration: line-through; opacity: .6; }
tr.row-suspended td { opacity: .6; }

/* Attachment expiry note */
.att-wrap { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: 100%; }
.att-expiry { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 4px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8px; }

/* ---- Resizable, wider sidebar (drag the right edge: -10% to +20%). ---- */
.app { grid-template-columns: var(--col-l, var(--sidebar-w, 280px)) 1fr var(--col-r, 220px); }
.sidebar { position: relative; }
.sidebar-grip { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 40; }
.sidebar-grip:hover { background: linear-gradient(90deg, transparent, rgba(59,130,246,.6)); }
@media (max-width: 1100px) { .app { grid-template-columns: var(--col-l, var(--sidebar-w, 280px)) 1fr; } .app .right { display: none; } }
@media (max-width: 760px) { .sidebar-grip { display: none; } }

/* ---- Sidebar "On Voice" panel (Discord-style); only while in a voice channel. ---- */
.voice-status { margin: 6px 8px 0; padding: 8px 9px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.vs-top { display: flex; align-items: center; gap: 8px; }
.vs-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: transparent; border: none; cursor: pointer; padding: 2px 3px; border-radius: 6px; text-align: left; }
.vs-info:hover { background: var(--hover); }
.vs-on { display: flex; align-items: center; gap: 6px; color: #3ba55d; font-weight: 800; font-size: 13px; line-height: 1.2; }
.vs-wave { width: 9px; height: 9px; border-radius: 50%; background: #3ba55d; }
.vs-wave.live { animation: vs-pulse 1.7s ease-out infinite; }
@keyframes vs-pulse { 0% { box-shadow: 0 0 0 0 rgba(59,165,93,.5); } 70% { box-shadow: 0 0 0 6px rgba(59,165,93,0); } 100% { box-shadow: 0 0 0 0 rgba(59,165,93,0); } }
.vs-chan { color: var(--dim); font-size: 12px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-info:hover .vs-chan { color: var(--text); }
.vs-hang { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-3); color: #ed4245; border: none; cursor: pointer; font-size: 15px; flex-shrink: 0; }
.vs-hang:hover { background: #ed4245; color: #fff; }
.vs-ctrls { display: flex; gap: 6px; }
.vs-btn { flex: 1; height: 32px; border-radius: 8px; background: var(--bg-3); color: var(--text); border: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.vs-btn:hover { background: var(--hover); }
.vs-btn.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.vs-btn.off { background: rgba(237,66,69,.18); color: #ed4245; }
.vs-btn:disabled { opacity: .5; cursor: default; }

/* ---- Discord-style video grid ---- */
/* Tiles fill the available stage: rows stretch to share the height (min 150px),
   so a single participant fills the whole frame and the avatar stays centered,
   instead of a fixed aspect-ratio tile overflowing and pushing it to the bottom. */
.voice-stage { display: grid; gap: 10px; padding: 14px; align-content: stretch; justify-content: stretch; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); grid-auto-rows: minmax(150px, 1fr); overflow: auto; }
.tile { position: relative; background: #0b0d10; border-radius: 12px; overflow: hidden; min-height: 0; display: flex; align-items: center; justify-content: center; border: 2px solid transparent; }
.tile.speaking { border-color: #3ba55d; box-shadow: 0 0 0 2px rgba(59,165,93,.35); }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile-avatar { width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tile-label { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-kick { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.5); color: #fff; border: none; border-radius: 6px; width: 24px; height: 24px; cursor: pointer; font-size: 12px; }
.tile-kick:hover { background: var(--red, #ed4245); }

/* Voice-only call (no cameras): centered circular avatars that scale with the
   frame, with a green speaking ring — Discord's voice-call look. Uses container
   query units so avatars grow/shrink as the panel is resized, staying centered. */
.voice-stage.audio-only { display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 30px; padding: 24px; container-type: size; overflow: auto; }
.voice-puck { display: flex; flex-direction: column; align-items: center; gap: 12px; }
/* No overflow:hidden here, so overlay badges (raised hand, kick) sit OVER the
   circle's edge instead of being clipped inside it. The image rounds itself. */
.puck-av { position: relative; width: clamp(48px, 22cqmin, 168px); height: clamp(48px, 22cqmin, 168px); border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; font-weight: 700; font-size: clamp(18px, 8cqmin, 60px); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px transparent; transition: box-shadow .12s ease; }
.puck-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.voice-puck.speaking .puck-av { box-shadow: 0 0 0 3px #3ba55d, 0 0 0 7px rgba(59,165,93,.28); }
.puck-name { color: var(--dim); font-size: 13px; font-weight: 600; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.puck-kick { position: absolute; top: 6%; right: 6%; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px; line-height: 1; }
.puck-kick:hover { background: var(--red, #ed4245); }
.voice-stage.audio-only .screen-card { width: clamp(200px, 46cqmin, 380px); aspect-ratio: 16 / 10; }

/* Screen-share "Watch Stream" card */
.tile.screen-card { flex-direction: column; gap: 8px; cursor: pointer; background: linear-gradient(160deg, #1b1e24, #0b0d10); border: 2px dashed rgba(255,255,255,.14); }
.tile.screen-card:hover { border-color: var(--accent); }
.screen-card .sc-icon { font-size: 30px; }
.screen-card .sc-name { color: #cdd3dc; font-size: 13px; }
.screen-card .sc-watch { background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; padding: 7px 16px; border-radius: 999px; }

/* Theater (maximized stream) */
.voice-theater { display: flex; flex-direction: column; height: 100%; background: #000; }
.theater-stage { position: relative; flex: 1; min-height: 0; background: #000; }
.theater-video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.theater-fs { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.55); color: #fff; border: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; pointer-events: auto; }
.theater-fs:hover { background: rgba(0,0,0,.8); }
.theater-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--bg-1); border-top: 1px solid var(--line); }
.theater-bar .tb-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theater-bar .tb-controls { margin-left: auto; display: flex; gap: 8px; }

/* Popped-out screen share: floating draggable mini-player over the whole app. */
.kp-floater {
  position: fixed; z-index: 2147483000; background: #000;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.6); user-select: none;
}
.kpf-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; cursor: move;
  background: var(--bg-1); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text-1);
}
.kpf-head > .fa-display { opacity: .7; }
.kpf-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.kpf-btn {
  background: transparent; border: none; color: var(--text-2); cursor: pointer;
  width: 24px; height: 24px; border-radius: 6px; font-size: 13px; display: grid; place-items: center;
}
.kpf-btn:hover { background: rgba(255,255,255,.08); color: var(--text-1); }
.kpf-video { width: 100%; background: #000; }
.kpf-video .theater-video { width: 100%; height: 100%; }
.kpf-resize {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--text-2) 50%, var(--text-2) 60%, transparent 60%, transparent 72%, var(--text-2) 72%, var(--text-2) 82%, transparent 82%);
  opacity: .5;
}
.kpf-resize:hover { opacity: .9; }

/* Theater layout: grow the voice panel (resizable), dock the chat. */
body.kp-theater .voice-dock.expanded { max-height: none; height: 60vh; }
body.kp-theater .main-head { display: none; }
body.kp-theater .messages { flex: 1 1 auto; min-height: 60px; transition: height .25s ease; }
body.kp-theater.kp-chat-min .messages { flex: 0 0 0; height: 0; min-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }

/* Drag-to-resize grip at the bottom of the voice dock. */
/* Drag-to-resize grip at the bottom of the voice dock. It sits above the
   floating composer (.composer-dock, z-index 6), which docks to the bottom of
   <main> and would otherwise sit on top of an 8px transparent strip and eat
   every pointer event aimed at it. The pill is always faintly visible so the
   handle is findable without hunting for a dead zone. */
.voice-resize {
  height: 11px; flex: 0 0 11px; cursor: ns-resize; background: transparent; touch-action: none;
  position: relative; z-index: 7;
  display: flex; align-items: center; justify-content: center;
}
.voice-resize::before {
  content: ''; width: 46px; height: 3px; border-radius: 999px;
  background: var(--line); opacity: .8; transition: background .12s ease, width .12s ease, opacity .12s ease;
}
.voice-resize:hover::before { background: var(--blue); width: 78px; opacity: 1; }

/* Minimized voice room: keep the audio alive but render nothing here — the
   sidebar "On Voice" panel is the control surface. */
.voice-dock.mini { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.voice-bg { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Shared drawing overlay + tools + cursors */
.draw-wrap { position: absolute; inset: 0; pointer-events: none; }
.draw-canvas { position: absolute; inset: 0; pointer-events: none; }
.draw-canvas.active { pointer-events: auto; cursor: crosshair; touch-action: none; }
.draw-canvas.erasing { cursor: cell; }
.draw-cursors { position: absolute; inset: 0; pointer-events: none; }
.draw-cursor { position: absolute; transform: translate(-3px, -3px); display: flex; align-items: center; gap: 4px; }
.dc-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.5); flex-shrink: 0; }
.dc-name { color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.45); }
.draw-tools { position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 5px 8px; pointer-events: auto; }
.draw-tools .dt { background: transparent; color: #fff; font-size: 15px; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.draw-tools .dt.on { background: var(--accent); }
.draw-tools .dt-color { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); cursor: pointer; }
.draw-tools .dt-color.sel { border-color: #fff; transform: scale(1.12); }
.draw-tools .dt-size { width: 84px; accent-color: var(--accent); cursor: pointer; }

/* Voice channel you're connected to */
.chan.in-voice .cn { color: var(--green, #3ba55d); font-weight: 600; }
.in-voice-dot { color: var(--green, #3ba55d); font-size: 9px; margin-left: auto; }

/* Persistent voice dock */
.voice-dock.expanded { display: flex; flex-direction: column; max-height: 46vh; min-height: 200px; overflow: hidden; border-bottom: 1px solid var(--line); }
.voice-dock.expanded .voice-room { flex: 1; min-height: 0; }
.voice-cta { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.voice-cta img { width: 40px; height: 40px; opacity: .9; }
.voice-cta .vcta-text { display: flex; flex-direction: column; min-width: 0; }
.voice-cta .vcta-text b { font-size: 15px; }
.voice-cta .vcta-text span { color: var(--dim); font-size: 13px; }
.voice-cta .btn-primary { margin-left: auto; flex-shrink: 0; }

/* New-DM member picker */
.dm-empty { width: 100%; text-align: left; color: var(--dim); font-size: 13px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.dm-empty:hover { background: var(--hover); color: var(--text); }
.dm-search { width: 100%; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); outline: none; font-size: 14px; }
.dm-search:focus { border-color: var(--accent); }
.dm-pick-list { margin-top: 12px; max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.dm-pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.dm-pick-row:hover { background: var(--hover); }
.dpr-meta { min-width: 0; }
.dpr-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dpr-user { font-size: 12px; color: var(--dim); }
.dm-pick-row.picked { background: var(--active); }
.dm-pick-row.picked .dpr-user { color: inherit; opacity: 0.75; }
.dpr-check { margin-left: auto; color: var(--accent); }
.dm-pick-row.picked .dpr-check { color: inherit; }

/* Multi-select "To:" chips (group DMs) */
.dm-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.dm-chips-to { color: var(--dim); font-size: 13px; margin-right: 2px; }
.dm-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.dm-chip .x { cursor: pointer; color: var(--dim); display: inline-flex; }
.dm-chip .x:hover { color: var(--text); }

/* Group-DM sidebar avatar: member-count square, Slack-style */
.gdm-ava { width: 22px; height: 22px; border-radius: 6px; background: var(--bg-3); border: 1px solid var(--line); color: var(--dim); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dm-row.active .gdm-ava { color: inherit; }

/* GIF (Giphy) picker + emoji board */
.gif-btn { background: var(--bg-3); color: var(--dim); border-radius: 999px; padding: 0 12px; font-weight: 800; font-size: 11px; letter-spacing: .6px; }
.gif-btn:hover { color: var(--text); }
.emoji-btn { background: transparent; font-size: 18px; padding: 0 6px; line-height: 1; }
.emoji-backdrop { position: fixed; inset: 0; z-index: 200; }
.emoji-popover { position: absolute; bottom: calc(100% + 10px); right: 8px; z-index: 201; box-shadow: 0 16px 44px rgba(0,0,0,.5); border-radius: 10px; }
.giphy-modal { max-width: 560px; }
.giphy-attr { margin-left: 10px; font-size: 10px; color: var(--faint); letter-spacing: 1.5px; align-self: center; }
.giphy-grid { columns: 3; column-gap: 8px; margin-top: 12px; max-height: 52vh; overflow-y: auto; }
.giphy-cell { display: block; width: 100%; margin: 0 0 8px; padding: 0; border: none; background: var(--bg-1); border-radius: 8px; overflow: hidden; cursor: pointer; break-inside: avoid; }
.giphy-cell img { width: 100%; display: block; }
.giphy-cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.gif-embed { cursor: pointer; max-width: 320px; border-radius: 8px; }

/* Discord-style profile card */
.profile-card.themed { width: 320px; background: linear-gradient(165deg, var(--c1, #14b8a6), var(--c2, #3b82f6)); border: 1px solid rgba(0,0,0,.4); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 55px rgba(0,0,0,.6); }
.profile-card .pc-banner { height: 120px; background-size: cover; background-position: center; }
.profile-card .pc-inner { position: relative; margin: 12px; padding: 66px 16px 16px; background: rgba(14,15,19,.68); border: 1px solid rgba(0,0,0,.45); border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); text-align: center; }
/* Avatar: 25% larger (84 -> 105) and centered to the frame. */
.pc-av { position: absolute; top: -52px; left: 50%; transform: translateX(-50%); width: 105px; height: 105px; }
.pc-av .avatar.xl { width: 105px; height: 105px; font-size: 37px; border: 3px solid var(--c2, #3b82f6); border-radius: 50%; box-sizing: border-box; }
.pc-dot { position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--c2, #3b82f6); box-sizing: border-box; }
.pc-dot.online { background: #3ba55d; }
.pc-dot.idle { background: #f0b232; }
.pc-dot.dnd { background: #ed4245; }
.pc-dot.offline { background: #80848e; }
.profile-card .pc-name { color: #fff; font-size: 20px; font-weight: 800; line-height: 1.2; }
.profile-card .pc-sub { color: rgba(255,255,255,.66); font-size: 13px; margin-top: 1px; }
.pc-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 8px 0 2px; }
.profile-card .pc-status { color: rgba(255,255,255,.92); font-size: 13px; margin-top: 10px; }
.profile-card .pc-bio { color: rgba(255,255,255,.82); font-size: 13px; margin-top: 8px; white-space: pre-wrap; }
.profile-card .pc-row { color: rgba(255,255,255,.7); font-size: 12px; margin-top: 8px; }
.pc-edit { width: 100%; margin-top: 14px; }
.pc-localtime { color: #fff; font-weight: 600; }
/* DM box: a fully-rounded pill with a leading paper-plane icon that hides once
   you start typing. The input keeps a constant left pad so text doesn't jump. */
.pc-dm { position: relative; margin-top: 14px; text-align: left; }
.pc-dm-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.5); font-size: 13px; pointer-events: none; }
.pc-dm-input { width: 100%; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 11px 18px 11px 40px; color: #fff; outline: none; font-size: 13px; box-sizing: border-box; }
.pc-dm-input::placeholder { color: rgba(255,255,255,.45); }
.pc-dm-input:focus { border-color: rgba(255,255,255,.32); }

/* Profile banner editor */
.pf-banner-preview { height: 100px; border-radius: 10px; background-size: cover; background-position: center; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 32px; }
.pf-banner-preview .avatar.xl { width: 72px; height: 72px; font-size: 24px; border: 4px solid var(--bg-2); margin-bottom: -28px; }
.banner-tabs { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; flex-wrap: wrap; }
.seg { border: 1px solid var(--line); background: transparent; color: var(--text); padding: 5px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.seg.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.banner-colors { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.bc-row { display: flex; align-items: center; gap: 10px; }
.bc-label { width: 60px; font-size: 12px; color: var(--dim); }
.crop-stage.banner { width: 320px; height: 120px; border-radius: 10px; }

/* Settings */
.row-actions { white-space: nowrap; }
.row-actions .mini { margin-left: 4px; }
.mini.danger { color: var(--red, #ed4245); border-color: var(--red, #ed4245); }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; }
.tag-toggle { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 12px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.tag-toggle.on { color: #fff; }
.tag-create { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--text); }
.tag-list { display: flex; flex-direction: column; gap: 8px; }
.tag-row { display: flex; align-items: center; gap: 10px; }
.audit-list { display: flex; flex-direction: column; gap: 6px; }
.audit-row { display: flex; gap: 10px; align-items: baseline; padding: 6px 8px; border-radius: 6px; background: var(--bg-1); font-size: 13px; }
.audit-when { color: var(--faint); font-size: 11px; white-space: nowrap; min-width: 130px; }
.audit-text { color: var(--dim); }
.audit-text b { color: var(--text); }

/* ---- Profile card v2: single surface, banner fades into body ---- */
.profile-card.v2 { width: 328px; border-radius: 16px; overflow: hidden; position: fixed; z-index: 240;
  animation: pc2-pop 0.34s cubic-bezier(0.34, 1.5, 0.64, 1) both; transform-origin: 50% 85%; }
@keyframes pc2-pop { from { opacity: 0; transform: scale(0.93) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (prefers-reduced-motion: reduce) { .profile-card.v2 { animation: none; } }

.pc2-banner { position: absolute; inset: 0 0 auto 0; height: 132px; }
.pc2-fade { position: absolute; inset: 0 0 auto 0; height: 132px; pointer-events: none;
  background: linear-gradient(180deg, rgba(10,12,16,0) 34%, rgba(10,12,16,0.55) 66%, rgba(10,12,16,0.92) 100%); }
.pc2-body { position: relative; padding: 64px 18px 16px; }

.pc2-head { display: flex; align-items: flex-end; justify-content: space-between; }
.pc2-av { position: relative; width: 86px; height: 86px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 5px rgba(10, 12, 16, 0.9), 0 6px 22px rgba(0, 0, 0, 0.45); }
.pc2-av .avatar, .pc2-av .av { width: 86px !important; height: 86px !important; font-size: 30px; }
.pc2-av img { width: 86px; height: 86px; border-radius: 50%; object-fit: cover; display: block; }
.pc2-dot { position: absolute; right: 1px; bottom: 1px; width: 18px; height: 18px; border-radius: 50%;
  border: 4px solid rgba(10, 12, 16, 0.95); }
.pc2-dot.online { background: var(--green, #3ba55d); }
.pc2-dot.idle { background: #f0b232; }
.pc2-dot.dnd { background: #ed4245; }
.pc2-dot.offline { background: #80848e; }

.pc2-actions { display: flex; gap: 6px; margin-bottom: 4px; }
.pc2-actions button { width: 32px; height: 32px; border-radius: 9px; color: #d6dbe2; font-size: 13px; cursor: pointer;
  background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.12); }
.pc2-actions button:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.pc2-name { color: #fff; font-size: 21px; font-weight: 800; line-height: 1.15; margin-top: 12px; }
.pc2-user { color: rgba(255, 255, 255, 0.62); font-size: 13px; margin-top: 2px; }
.pc2-pronouns { color: rgba(255, 255, 255, 0.45); }
.pc2-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.pc2-context { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px;
  color: #b8e6c6; background: rgba(59, 165, 93, 0.14); border: 1px solid rgba(59, 165, 93, 0.35);
  padding: 7px 11px; border-radius: 9px; }
.pc2-context b { color: #dff5e6; }
.pc2-context-wave { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.pc2-context-wave i { width: 3px; background: #3ba55d; border-radius: 2px; animation: pc2-wave 1s ease-in-out infinite; }
.pc2-context-wave i:nth-child(1) { height: 6px; }
.pc2-context-wave i:nth-child(2) { height: 11px; animation-delay: 0.18s; }
.pc2-context-wave i:nth-child(3) { height: 8px; animation-delay: 0.34s; }
@keyframes pc2-wave { 0%, 100% { transform: scaleY(0.55); } 50% { transform: scaleY(1); } }

.pc2-status { color: rgba(255, 255, 255, 0.9); font-size: 13.5px; margin-top: 12px; font-style: italic; }
.pc2-bio { color: rgba(255, 255, 255, 0.78); font-size: 13px; margin-top: 10px; line-height: 1.5; white-space: pre-wrap; }
.pc2-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.pc2-row { color: rgba(255, 255, 255, 0.66); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.pc2-row i { width: 14px; text-align: center; color: rgba(255, 255, 255, 0.45); }
.pc2-row-dim { color: rgba(255, 255, 255, 0.4); }

.pc2-edit { width: 100%; margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.pc2-dm { position: relative; margin-top: 16px; }
.pc2-dm-input { width: 100%; box-sizing: border-box; background: rgba(0, 0, 0, 0.35); color: #eef2f6;
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 10px 44px 10px 15px;
  font-size: 13.5px; outline: none; }
.pc2-dm-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.pc2-dm-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.pc2-send { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px;
  border-radius: 50%; color: rgba(255, 255, 255, 0.45); font-size: 12px; cursor: pointer; background: transparent; }
.pc2-send.ready { background: var(--accent); color: #fff; }

/* v2 glass tint, darkened for guaranteed text contrast even with bright
   user banner colors (overrides glass.css's lighter mix via specificity). */
.profile-card.themed.v2 {
  background: linear-gradient(170deg,
    color-mix(in srgb, var(--c1, #14b8a6) 30%, rgba(9, 11, 15, 0.94)),
    color-mix(in srgb, var(--c2, #3b82f6) 22%, rgba(9, 11, 15, 0.96)) 60%,
    rgba(9, 11, 15, 0.97));
}

/* ---- Profile card v3: wavy banner, horizontal identity, docked actions ---- */
.profile-card.v3 .pc2-banner { height: 112px; }
.pc3-wave {
  /* Wavy bottom edge — the Dogfish signature, instead of Discord's straight cut. */
  clip-path: path('M0 0 H328 V90 C300 106 268 84 236 94 C204 104 176 80 144 92 C112 104 80 86 48 96 C28 102 12 98 0 90 Z');
}
.profile-card.v3 .pc2-fade { display: none; }
.profile-card.v3 .pc2-body { padding-top: 56px; }
.pc3-head { display: flex; align-items: flex-end; gap: 14px; }
.pc3-id { min-width: 0; padding-bottom: 7px; }
.profile-card.v3 .pc2-name { margin-top: 0; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card.v3 .pc2-user { margin-top: 1px; }

.pc3-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 2; }
.pc3-actions button {
  width: 30px; height: 30px; border-radius: 9px; color: #fff; font-size: 12.5px; cursor: pointer;
  background: rgba(8, 10, 14, 0.45); border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.pc3-actions button:hover { background: rgba(8, 10, 14, 0.7); }

/* Avatar halo fix: the initials-gradient background peeked out ~1px around
   photo avatars. Pin the image over the whole circle and overscale a hair. */
.pc2-av .avatar { background-clip: padding-box; }
.pc2-av .av-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; transform: scale(1.02); }

/* GIF framing stage (banner-ratio window, drag/zoom the animated GIF). */
.crop-stage.gif-stage { width: 320px; height: 110px; border-radius: 12px; background-color: #000; }

/* ---- Two-factor section (Edit Profile) ---- */
.tfa { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tfa-row { display: flex; align-items: center; gap: 10px; }
.tfa-row .muted { flex: 1; font-size: 13px; }
.tfa-on { flex: 1; color: var(--green, #3ba55d); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.tfa-setup { display: flex; gap: 14px; align-items: flex-start; }
.tfa-qr { width: 132px; height: 132px; border-radius: 10px; background: #fff; padding: 6px; flex: none; }
.tfa-steps { display: flex; flex-direction: column; gap: 8px; font-size: 13px; min-width: 0; }
.tfa-steps code { font-family: var(--mono); font-size: 11px; word-break: break-all; background: var(--bg-0); padding: 2px 6px; border-radius: 5px; }
.tfa-confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tfa-confirm input { width: 110px; font-family: var(--mono); letter-spacing: 3px; }

/* ---- "New version available" banner (versionCheck.ts). Theme-driven. ---- */
.kp-upd {
  position: fixed;
  /* Clear the mobile status bar / notch — it also swallowed taps before. */
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%; transform: translateX(-50%);
  z-index: 2147483646;
  display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: min(94vw, 480px);
  padding: 8px 10px 8px 16px; border-radius: 16px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 13.5px; font-weight: 500;
  -webkit-app-region: no-drag;
}
/* Electron: the 40px custom titlebar is above everything and draggable —
   sit below it or the banner is clipped and unclickable. */
.kp-upd.desktop { top: 52px; }
.kp-upd-msg { flex: 1 1 auto; min-width: 0; }
.kp-upd .btn-primary { white-space: nowrap; flex: 0 0 auto; }
.kp-upd-x {
  background: transparent; border: none; color: var(--text-dim, var(--text));
  cursor: pointer; font-size: 15px; line-height: 1; padding: 6px 8px; flex: 0 0 auto;
}
.kp-upd-x:hover { color: var(--text); }

/* Voice state badges in the DM list (streaming / muted / deafened). */
.dm-row .dm-voice { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; padding-left: 6px; font-size: 12px; flex-shrink: 0; }
.dm-row .dm-voice .dv-stream { color: var(--text); opacity: 0.85; }
.dm-row .dm-voice .dv-alert { color: #ff6b6b; animation: dv-blink 1.6s ease-in-out infinite; }
@keyframes dv-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
/* When a DM row has both an unread badge and voice icons, keep them apart. */
.dm-row .dm-voice + .badge { margin-left: 6px; }

/* ---- Focused-workspace layout (big tools auto-collapse the side panels) ---- */
@media (min-width: 761px) {
  .app.tool-focus { transition: grid-template-columns .18s ease; }
  .app.tool-focus .sidebar, .app.tool-focus .right { overflow: hidden; }
  .app.tool-left-collapsed { --col-l: 0px; }
  .app.tool-right-collapsed { --col-r: 0px; }
}
/* Small edge tabs to collapse/expand each panel while in a tool. */
.tool-edge {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 30;
  width: 20px; height: 48px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); color: var(--dim);
  border: 1px solid var(--line); cursor: pointer;
  opacity: 0.65; transition: opacity .12s ease, background .12s ease, color .12s ease;
  font-size: 12px;
}
.tool-edge:hover { opacity: 1; color: var(--text); background: var(--bg-3); }
.tool-edge.left { left: 0; border-left: none; border-radius: 0 8px 8px 0; }
.tool-edge.right { right: 0; border-right: none; border-radius: 8px 0 0 8px; }
/* Right panel is hidden below 1100px anyway; drop its tab there. Both tabs go
   on phones, where tools already use the full width. */
@media (max-width: 1100px) { .tool-edge.right { display: none; } }
@media (max-width: 760px) { .tool-edge { display: none; } }

/* Favourite star on pinned DM/group rows. */
.dm-row .dm-fav-star { color: var(--yellow, #f0b232); font-size: 11px; margin-left: 6px; flex-shrink: 0; }
/* ---- Whiteboards ---- */

/* Sidebar entry (pinned above the channel list). */
.wb-nav-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; color: var(--text); border: none; cursor: pointer;
  padding: 7px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; margin-bottom: 4px;
}
.wb-nav-btn:hover { background: var(--hover); }
.wb-nav-btn.active { background: var(--active, var(--hover)); color: var(--accent); }
.wb-nav-btn .npi { font-size: 15px; }

/* Sidebar: collapsible live list of boards under the Whiteboards entry. */
.wb-nav { margin-bottom: 4px; }
.wb-nav .wb-nav-btn { margin-bottom: 2px; }
.wb-nav-toggle { margin-left: auto; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; opacity: .55; font-size: 11px; }
.wb-nav-toggle:hover { opacity: 1; background: rgba(255,255,255,.1); }
.wb-nav-list { display: flex; flex-direction: column; margin: 0 0 4px 12px; padding-left: 8px; border-left: 1px solid var(--line); }
.wb-nav-note { font-size: 12px; color: var(--text-2); padding: 4px 8px; }
.wb-nav-sub { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); padding: 6px 8px 2px; }
.wb-nav-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); cursor: pointer; padding: 4px 8px; border-radius: 6px; font-size: 13px; min-width: 0; }
.wb-nav-item:hover { background: var(--hover); }
.wb-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-nav-item.is-active .wb-item-name { font-weight: 600; }
.wb-item-count { flex: none; font-size: 11px; color: var(--text-2); background: rgba(255,255,255,.09); border-radius: 9px; padding: 0 6px; line-height: 16px; }
.wb-live { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #10b981; animation: wb-live-pulse 2s infinite; }
@keyframes wb-live-pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); } 70% { box-shadow: 0 0 0 5px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }
.wb-item-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); opacity: .35; }
/* Tiny board cover in the sidebar list; a green ring marks an active board. */
.wb-item-cover { flex: none; width: 18px; height: 18px; border-radius: 4px; background-size: cover; background-position: center; background-color: var(--bg-2); }
.wb-item-cover.live { box-shadow: 0 0 0 1px var(--bg-1), 0 0 0 2px #10b981; }

/* Launcher */
.wb-launcher { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.wb-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.wb-crumbs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; flex-wrap: wrap; }
.wb-crumb-wrap { display: inline-flex; align-items: center; gap: 4px; }
.wb-crumb { background: transparent; border: none; color: var(--text); font-size: 15px; font-weight: 700; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.wb-crumb:hover { background: var(--hover); }
.wb-sep { color: var(--faint); }
.wb-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-ghost.sm, .btn-primary.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.wb-grid { flex: 1; overflow: auto; padding: 16px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-content: start; }
.wb-card {
  display: flex; flex-direction: column; padding: 0; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; background: var(--bg-1); cursor: pointer; text-align: left; transition: border-color .12s, transform .08s;
}
.wb-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.wb-thumb { height: 110px; display: flex; align-items: center; justify-content: center; font-size: 34px; color: rgba(255,255,255,.55); }
/* Board cover image: cropped to fill the tile, consistent across all boards. */
.wb-cover { background-size: cover; background-position: center; background-repeat: no-repeat; }
.wb-folder-thumb { background: linear-gradient(160deg, #2a2f37, #1b1e24); color: #cdd3dc; }
/* Department-colored folder cards (color set inline via --dept). */
.wb-folder { border-color: color-mix(in srgb, var(--dept, var(--line)) 40%, var(--line)); }
.wb-card-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.wb-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-dots { color: var(--dim); padding: 0 4px; border-radius: 6px; font-weight: 700; }
.wb-dots:hover { background: var(--hover); color: var(--text); }

.wb-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--dim); }

/* Board view */
.wb-board { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.wb-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.wb-back { background: var(--bg-3); border: none; color: var(--text); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.wb-back:hover { background: var(--hover); }
.wb-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.wb-title { display: inline-flex; align-items: center; gap: 8px; cursor: text; }
.wb-title-edit-btn { opacity: 0; background: none; border: none; color: var(--dim); cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 5px; flex-shrink: 0; }
.wb-title:hover .wb-title-edit-btn { opacity: 0.75; }
.wb-title-edit-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.wb-title-edit { flex: 1; min-width: 0; max-width: 340px; font-weight: 700; font-size: 15px; color: var(--text); background: var(--bg-0); border: 1px solid var(--accent); border-radius: 7px; padding: 5px 9px; outline: none; }
.wb-peers { display: flex; gap: -6px; align-items: center; }
.wb-peer { display: inline-flex; margin-left: -6px; border-radius: 50%; outline: 2px solid var(--accent); outline-offset: 0; background: var(--bg-2); }
.wb-peer:first-child { margin-left: 0; }

.wb-canvas { position: relative; flex: 1; min-height: 0; }
.wb-canvas .excalidraw { height: 100%; }
.wb-canvas > div { height: 100%; }
.wb-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--dim); font-size: 14px; }
.wb-overlay { position: absolute; inset: 0; background: var(--bg-2); }

/* Keep the Excalidraw editor below our app modals/menus. */
.excalidraw { --zIndex-layerUI: 4; }

@media (max-width: 760px) {
  .wb-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 12px; }
}
/* "Liquid glass" treatments — frosted blur + a bright top rim + soft shadow,
   PLUS true refraction via the #kp-glass SVG displacement filter (defined in
   index.html), the same technique BYD uses. The plain blur is the fallback;
   the url() line adds the warp on browsers that support SVG filters in
   backdrop-filter (Chromium: Chrome/Edge). Firefox/Safari keep just the blur. */

/* =====================================================================
   Global glass buttons — every chrome button across the app is round and
   glassy. Neutral controls get a dark tint; primary actions get the accent
   color; leave/danger get red; the composer Send stays gold (below). Tiny
   inline controls (reactions, message-hover icons, color swatches, context-menu
   rows, the emoji picker) keep their own styles so menus and pickers stay usable. */
.icon-btn, .members-btn, .hamburger, .ws-gear, .add, .add-cat, .notepad-btn,
.wb-nav-btn, .wb-back, .vctrl, .vs-btn, .modal-close, .seg, .tab, .mini,
.theater-fs, .load-older, .dm-empty, .pc-edit, .sc-watch, .vbtn, .tag-toggle,
.btn-ghost, .btn-primary {
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Neutral dark-tinted glass. */
.icon-btn, .members-btn, .hamburger, .ws-gear, .add, .add-cat, .notepad-btn,
.wb-nav-btn, .wb-back, .vctrl, .vs-btn, .modal-close, .seg, .tab, .mini,
.theater-fs, .load-older, .dm-empty, .pc-edit, .vbtn, .tag-toggle, .btn-ghost {
  background: rgba(14, 18, 24, 0.42);
  color: #e8ebf1;
}
.icon-btn:hover, .members-btn:hover, .hamburger:hover, .ws-gear:hover, .add:hover,
.add-cat:hover, .notepad-btn:hover, .wb-nav-btn:hover, .wb-back:hover, .vctrl:hover,
.vs-btn:hover, .modal-close:hover, .seg:hover, .tab:hover, .mini:hover, .theater-fs:hover,
.load-older:hover, .dm-empty:hover, .pc-edit:hover, .vbtn:hover, .tag-toggle:hover, .btn-ghost:hover {
  background: rgba(30, 36, 46, 0.52);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

/* Primary / selected = accent glass (driven by --accent). */
.btn-primary, .seg.on, .tab.active, .tag-toggle.on, .vctrl.on, .vs-btn.on {
  background: color-mix(in srgb, var(--accent) 74%, transparent);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, #ffffff);
  border-top-color: color-mix(in srgb, var(--accent) 25%, #ffffff);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 34%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, transparent); color: #fff; }

/* Leave / danger = red glass. */
.vctrl.leave, .vs-hang, .mini.danger, .tile-kick {
  border-radius: 999px;
  background: rgba(220, 60, 62, 0.72);
  color: #fff;
  border: 1px solid rgba(255, 175, 175, 0.5);
  border-top-color: rgba(255, 222, 222, 0.85);
  box-shadow: 0 5px 16px rgba(120, 20, 20, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
}
.vctrl.leave:hover, .vs-hang:hover, .mini.danger:hover { background: rgba(237, 76, 78, 0.9); }

.btn-primary:disabled, .btn-ghost:disabled { opacity: 0.55; }

/* =====================================================================
   Floating top info bar that OVERLAYS the message list, so the chat frosts
   and refracts through it as it scrolls behind. Fully pill-shaped, like the
   message bar. Absolutely positioned inside .chat-pane (which sits BELOW the
   voice panel in flow, so they never collide). */
.chat-pane { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main-head {
  position: absolute; top: 10px; left: 14px; right: 14px; z-index: 7;
  height: 52px; padding: 0 22px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.34);
  background: rgba(14, 18, 24, 0.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(10px) saturate(1.5);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
/* Reserve space so content begins below the floating bar. */
.chat-pane .messages { padding-top: 76px; }
.chat-pane .voice-cta { margin-top: 76px; }
.chat-pane .voice-cta + .messages { padding-top: 14px; }
/* Header buttons stay subtle (no nested glass). */
.main-head .icon-btn,
.main-head .members-btn,
.main-head .hamburger {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.main-head .icon-btn:hover,
.main-head .members-btn:hover,
.main-head .hamburger:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
[data-theme='light'] .main-head, [data-theme='sakura'] .main-head { background: rgba(255, 255, 255, 0.5); }
[data-theme='light'] .main-head .icon-btn,
[data-theme='sakura'] .main-head .icon-btn,
[data-theme='light'] .main-head .members-btn,
[data-theme='sakura'] .main-head .members-btn,
[data-theme='light'] .main-head .hamburger, [data-theme='sakura'] .main-head .hamburger { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.1); }
@media (max-width: 760px) {
  .main-head { top: 8px; left: 8px; right: 8px; }
  .chat-pane .messages { padding-top: 72px; }
  .chat-pane .voice-cta { margin-top: 72px; }
}

/* Emoji picker opened from a modal (channel-name editor): centered, so it
   escapes the modal's clipped overflow. */
.emoji-popover.center {
  position: fixed; top: 50%; left: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%);
}

/* ---- Message field: a rounded, multi-line box that grows with content
   (auto-sized in JS, capped at 200px). ---- */
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 56px;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 22px;
  padding: 15px 22px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  box-sizing: border-box;
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(10px) saturate(1.5);
  backdrop-filter: blur(10px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(7px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.composer textarea::placeholder { color: rgba(255, 255, 255, 0.55); }
.composer textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  border-top-color: rgba(255, 255, 255, 0.5);
}

[data-theme='light'] .composer textarea, [data-theme='sakura'] .composer textarea {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-top-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
[data-theme='light'] .composer textarea::placeholder, [data-theme='sakura'] .composer textarea::placeholder { color: rgba(20, 22, 27, 0.5); }

/* ---- Round, glassy controls around the field; buttons sit at the bottom so
   they stay aligned with the last line as the box grows. ---- */
.composer { align-items: flex-end; }
.composer .send { border-radius: 999px; height: 56px; padding: 0 26px; }
.composer .gif-btn { border-radius: 999px; height: 56px; padding: 0 20px; }
.composer .attach-btn,
.composer .emoji-btn {
  width: 56px; min-width: 56px; height: 56px; flex: 0 0 56px; padding: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.composer .attach-btn,
.composer .emoji-btn,
.composer .gif-btn,
.composer .send {
  -webkit-backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: blur(8px) saturate(1.4);
  backdrop-filter: url(#kp-glass) blur(7px) saturate(1.4);
}
.composer .attach-btn,
.composer .emoji-btn,
.composer .gif-btn {
  background: rgba(14, 18, 24, 0.42);
  color: #e8ebf1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.34);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.composer .attach-btn:hover,
.composer .emoji-btn:hover,
.composer .gif-btn:hover {
  background: rgba(30, 36, 46, 0.5);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}
/* Golden glass Send with dark text — no outer glow. */
.composer .send {
  background: rgba(240, 192, 64, 0.74);
  color: #241b00;
  font-weight: 700;
  border: 1px solid rgba(255, 226, 140, 0.6);
  border-top-color: rgba(255, 248, 214, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.composer .send:hover { background: rgba(248, 206, 88, 0.86); color: #241b00; }
.composer .send:disabled { opacity: 0.55; }

@media (max-width: 760px) {
  .composer .send, .composer .gif-btn { height: 48px; }
  .composer textarea { min-height: 48px; padding: 12px 18px; }
  .composer .attach-btn, .composer .emoji-btn { width: 48px; min-width: 48px; height: 48px; flex-basis: 48px; }
}

/* ---- Float the composer over the message list so chat content frosts AND
   refracts through the glass input as it scrolls behind it. ---- */
.main .messages { padding-bottom: 94px; }
.composer-dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; pointer-events: none; }
.composer-dock > * { pointer-events: auto; }
@media (max-width: 760px) { .main .messages { padding-bottom: 80px; } }

/* ---- Profile card: frosted glass tinted by the user's own gradient colors
   (--c1/--c2), with the same refraction warping the chat behind it. ---- */
.profile-card.themed {
  background: linear-gradient(165deg,
    color-mix(in srgb, var(--c1, #14b8a6) 58%, transparent),
    color-mix(in srgb, var(--c2, #3b82f6) 58%, transparent));
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(18px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* =====================================================================
   Modal / dialog windows (Create channel, New message, Workspace settings,
   etc.) — dark-tinted liquid glass that frosts and refracts the app behind.
   The scrim is softened so the refraction stays visible. */
.overlay {
  background: rgba(8, 9, 11, 0.5);
}
.modal {
  background: rgba(16, 20, 27, 0.62);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(16px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(255, 255, 255, 0.26);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
/* The wiz footer sits OUTSIDE the padded .modal-body, so its buttons were
   flush against the modal edges. Inset them to match the body's padding. */
.modal .wiz-foot { padding: 0 22px 22px; }

/* Light theme: a bright frosted panel instead of the dark tint. */
[data-theme='light'] .overlay, [data-theme='sakura'] .overlay { background: rgba(18, 22, 30, 0.34); }
[data-theme='light'] .modal, [data-theme='sakura'] .modal {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-top-color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
/* Loaded LAST so these rules win over styles.css and features.css. */

/* Right-aligned modal footer (fixes the odd Cancel/Save spacing). */
.wiz-foot.end { justify-content: flex-end; gap: 10px; }

/* Mobile nav toggles — hidden on desktop. */
.hamburger { display: none; width: 32px; height: 32px; border-radius: 6px; align-items: center; justify-content: center; font-size: 18px; color: var(--dim); margin-right: 4px; flex-shrink: 0; }
.hamburger:hover { background: var(--hover); color: var(--text); }
.members-btn { display: none; width: 32px; height: 32px; border-radius: 6px; align-items: center; justify-content: center; font-size: 15px; color: var(--dim); flex-shrink: 0; }
.members-btn:hover { background: var(--hover); color: var(--text); }
.nav-backdrop, .right-backdrop { display: none; }

/* Emoji board container hugs the picker (emoji-mart renders a fixed width), and
   never overflows a narrow viewport. */
.emoji-popover { width: max-content; max-width: min(360px, calc(100vw - 16px)); }

/* Floating "jump to newest" button (Slack/Discord style). */
.main { position: relative; }
.jump-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 80px; z-index: 50; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.4); cursor: pointer; }
.jump-bottom:hover { filter: brightness(1.08); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr !important; }

  /* Left channel sidebar slides in. The `display:flex !important` overrides the
     old `.sidebar { display:none }` mobile rule in styles.css that was hiding it. */
  .sidebar {
    display: flex !important;
    position: fixed; left: 0; top: 0; bottom: 0; width: 84vw; max-width: 300px; z-index: 120;
    transform: translateX(-102%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,.6); }

  /* Right members panel slides in from the right (toggled by the 👥 button).
     Kept narrower than the nav drawer so a decent slice of the chat stays
     visible — that's the tap-away area that closes the panel. */
  .right {
    display: flex !important;
    position: fixed; right: 0; top: 0; bottom: 0; width: 70vw; max-width: 240px; z-index: 120;
    transform: translateX(102%); transition: transform .2s ease;
  }
  .right.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,.6); }

  .hamburger, .members-btn { display: flex; }

  /* Tools (Whiteboards / Currents) are desktop experiences — hide the section
     on phones. `.chan-section > .chan-label` is the "Tools" heading (category
     and DM headings live inside .chan-group, so they're unaffected). */
  .wb-nav, .wb-nav-btn, .chan-section > .chan-label { display: none; }
  .nav-backdrop, .right-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 110; }

  .modal { max-width: 100% !important; max-height: 92vh; }
  .att-image, .att-video, .gif-embed { max-width: 100%; }
  .messages { padding: 12px 0; }
  .composer, .composer-readonly { margin: 0; }
  .composer { padding: 0 10px 12px; gap: 6px; }
  .composer .send { padding: 0 14px; }
  .gif-btn { padding: 0 9px; }

  .main-head { padding: 0 10px; }
  .main-head .topic { display: none; }
  .main-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .head-actions { gap: 0; }

  .giphy-grid { columns: 2; }
  .emoji-popover { left: 8px; right: auto; }

  .voice-cta { flex-wrap: wrap; }
  .voice-cta .btn-primary { margin-left: 0; }
  .voice-dock.expanded { max-height: 52vh; }

  /* Profile card on phones: centered, opaque sheet. The desktop position is
     anchored to the tap point and the glass look needs backdrop blur (disabled
     on mobile) — anchored + translucent reads as a broken overlap over chat. */
  .profile-card, .profile-card.themed {
    left: 50% !important; top: 50% !important; right: auto !important;
    transform: translate(-50%, -50%);
    width: min(340px, calc(100vw - 24px)) !important;
    max-height: 86vh; overflow-y: auto;
  }
  /* v2 card on phones: opaque body (glass blur is disabled on mobile) and no
     pop animation — its transform would fight the translate(-50%,-50%) centering. */
  .profile-card.themed { background: rgba(10, 12, 16, 0.96) !important; }
  .profile-card.v2 { animation: none; }

  /* Modals share the glass translucency problem on phones — go opaque. */
  .modal { background: var(--bg-2) !important; }
}

/* Avatar crop */
.crop-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.crop-stage { width: 280px; height: 280px; border-radius: 50%; overflow: hidden; background: #000; cursor: grab; touch-action: none; box-shadow: 0 0 0 4px var(--bg-3); }
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas { display: block; }
.crop-controls { width: 280px; max-width: 100%; }

.theme-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* =====================================================================
   Mobile overhaul (phones / installed PWA).
   - No pinch zoom, no whole-page scrolling: only the message list, channel
     list, and member list scroll.
   - The liquid-glass blur doesn't render well on mobile — everything goes
     flat, using the theme's own surface colors.
   - Simpler composer: just [+] [message] [Send]; GIF + attachments live in
     the + menu, and the phone's keyboard provides emoji. */
@media (max-width: 760px) {
  /* --- lock the frame; scroll only inside designated panes --- */
  html, body, #root { height: 100dvh; }
  body { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; }
  .app { height: 100dvh; max-width: 100vw; overflow: hidden; }
  .main { max-width: 100vw; overflow-x: hidden; }
  .messages, .chan-section, .right-scroll { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

  /* --- flat surfaces: kill every blur/glass effect --- */
  * { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }

  /* Top bar: full-width flat bar under the status bar (safe-area aware). */
  .main-head {
    top: 0 !important; left: 0 !important; right: 0 !important;
    border-radius: 0 !important;
    background: var(--bg-1) !important;
    border: none !important; border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
    height: calc(52px + env(safe-area-inset-top)) !important;
    padding: env(safe-area-inset-top) 10px 0 10px !important;
  }
  .chat-pane .messages { padding-top: calc(60px + env(safe-area-inset-top)); }
  .chat-pane .voice-cta { margin-top: calc(60px + env(safe-area-inset-top)); }
  .main-head .icon-btn, .main-head .members-btn, .main-head .hamburger {
    background: transparent !important; border: none !important; box-shadow: none !important;
  }

  /* Admin-only header actions hide on phones (still available via menus). */
  .head-actions .adm { display: none !important; }

  /* Drawers respect the notch and go flat. */
  .sidebar, .right { padding-top: env(safe-area-inset-top); }

  /* --- composer: [+] [field] [Send], flat, roomy, no iOS focus-zoom --- */
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  /* Solid, themed bar behind the composer so messages don't show through it. */
  .composer-dock { background: var(--bg-1); border-top: 1px solid var(--line); pointer-events: auto !important; }
  /* Clear the whole composer height (field + padding + notch) so the last
     message is never clipped behind it. */
  .main .messages { padding-bottom: calc(74px + env(safe-area-inset-bottom)) !important; }
  .composer .gif-btn, .composer .emoji-btn { display: none !important; }
  .composer textarea {
    min-height: 44px !important; max-height: 120px;
    padding: 11px 16px !important; border-radius: 22px !important;
    font-size: 16px !important; /* <16px makes iOS zoom into the field */
    background: var(--bg-3) !important;
    border: 1px solid var(--line) !important; box-shadow: none !important;
  }
  .composer .send {
    height: 44px !important; padding: 0 18px !important;
    background: var(--accent) !important; color: #fff !important;
    border: none !important; box-shadow: none !important;
  }
  .composer .attach-btn {
    width: 44px !important; min-width: 44px !important; height: 44px !important; flex-basis: 44px !important;
    background: var(--bg-3) !important; border: 1px solid var(--line) !important; box-shadow: none !important;
  }

  /* Buttons/pills elsewhere: flat theme surfaces instead of glass. */
  .icon-btn, .members-btn, .hamburger, .ws-gear, .add, .add-cat, .notepad-btn,
  .vctrl, .vs-btn, .modal-close, .seg, .tab, .mini, .load-older, .btn-ghost {
    background: var(--bg-3); border-color: var(--line); box-shadow: none;
  }
  .btn-primary { background: var(--accent); border-color: var(--accent); box-shadow: none; }
}

/* The "+" menu above the composer (mobile). */
.plus-pop {
  position: absolute; bottom: 64px; left: 10px; z-index: 60;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); overflow: hidden; min-width: 180px;
}
.plus-row { display: flex; align-items: center; gap: 10px; padding: 13px 16px; font-size: 14px; cursor: pointer; }
.plus-row:hover { background: var(--hover); }
.plus-row i { color: var(--dim); width: 16px; text-align: center; }
/* Font Awesome icon alignment. Icons are rendered as <i class="fa-solid fa-…">
   inside buttons and inline labels that previously held emoji. These rules keep
   them centered, inheriting the button's color, and sized consistently. */
.fa-solid, .fa-regular, .fa-brands, i.fa, i[class*="fa-"] {
  line-height: 1;
  vertical-align: -0.05em;
}

/* Inline icons that sit before a text label (sidebar buttons, menu rows, voice
   strip, chips) get a touch of trailing space. */
.npi.fa-solid, .vs-chan .fa-solid, .ctx-ic { margin-right: 2px; }

/* Context-menu leading icon: fixed-width so labels line up. */
.ctx-ic { display: inline-block; width: 18px; text-align: center; font-size: 13px; opacity: 0.92; }

/* Channel-list and header type glyphs render at a comfortable size. */
.hash .fa-solid { font-size: 0.82em; }
/* Full-screen image viewer (Discord-style). The photo is centered and scaled to
   fit the window with ~130px of breathing room on every side; the glass control
   pill floats 50px below the picture. The backdrop tints to the active theme
   (--lb-backdrop): dark on dark themes, medium gray on the light theme. */
.lb-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--lb-backdrop, rgba(8, 10, 14, 0.95));
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* Shrink-wraps the image so the toolbar can anchor to the picture's edges. */
.lb-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}

/* Scaled to fit inside the viewport minus 130px on each side, aspect preserved
   (never upscaled past natural size). */
.lb-img {
  display: block;
  max-width: calc(100vw - 260px);
  max-height: calc(100vh - 260px);
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55);
  transform-origin: center center;
  transition: transform 0.18s ease;
  user-select: none;
}

/* Toolbar — a big pill of liquid glass, centered 50px under the photo. */
.lb-bar {
  position: absolute; z-index: 2;
  top: calc(100% + 50px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(14, 18, 24, 0.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: url(#kp-glass) blur(14px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.36);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.lb-btn {
  width: 50px; height: 50px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #e8ebf1; font-size: 20px; background: transparent; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.lb-more-wrap { position: relative; display: inline-flex; }

/* "More" menu pops up above the ⋯ button. */
.lb-menu {
  position: absolute; bottom: calc(100% + 14px); right: 0; min-width: 196px;
  background: #1c2027; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px;
  padding: 6px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); z-index: 3;
}
.lb-mi {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 11px; border-radius: 8px; color: #e8ebf1; font-size: 13.5px; cursor: pointer;
}
.lb-mi:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.lb-mi i { width: 16px; text-align: center; opacity: 0.9; }
.lb-sep { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 5px 4px; }

/* Details card floats above the toolbar. */
.lb-details {
  position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translateX(-50%);
  width: 290px; max-width: 86vw;
  background: #1c2027; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px;
  padding: 11px 13px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); z-index: 3;
}
.lb-d-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: #fff; font-size: 13px; }
.lb-d-head button { color: var(--faint, #9aa3af); width: 22px; height: 22px; border-radius: 6px; }
.lb-d-head button:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.lb-d-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 12px; color: #9aa3af; }
.lb-d-row b { color: #e8ebf1; font-weight: 600; max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tiny confirmation toast (e.g. "Image copied"). */
.lb-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 310;
  background: #1c2027; border: 1px solid rgba(255, 255, 255, 0.14); color: #fff;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Tighter on small screens — 130px padding would leave no photo. */
@media (max-width: 760px) {
  .lb-img { max-width: calc(100vw - 32px); max-height: calc(100vh - 180px); }
  .lb-bar { top: calc(100% + 28px); gap: 4px; padding: 7px 9px; }
  .lb-btn { width: 44px; height: 44px; font-size: 18px; }
}
/* "Currents" — kanban boards. The launcher reuses the whiteboard launcher
   classes (.wb-launcher / .wb-grid / .wb-card / .wb-bar). These rules cover the
   board itself: a horizontally scrolling row of columns full of cards. */

.kb-board { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--main-bg); }
.kb-board-title { flex: 1; min-width: 0; background: transparent; border: none; color: var(--text); font-size: 16px; font-weight: 700; outline: none; padding: 5px 8px; border-radius: 7px; }
.kb-board-title:focus { background: var(--bg-2); }

/* Thumbnail tint on the launcher cards. */
.wb-thumb.kb-thumb { background: linear-gradient(135deg, #2f80ed, #14b8a6); color: #fff; }

.kb-canvas { flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; padding: 14px; }
.kb-cols { display: flex; gap: 12px; align-items: flex-start; height: 100%; }

.kb-col {
  width: 286px; flex: 0 0 286px; max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
}
.kb-col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }

.kb-col-head { display: flex; align-items: center; gap: 4px; padding: 2px 2px 8px; cursor: grab; }
.kb-list-title { flex: 1; min-width: 0; background: transparent; border: none; color: var(--text); font-weight: 700; font-size: 14px; outline: none; padding: 4px 6px; border-radius: 6px; }
.kb-list-title:focus { background: var(--bg-0); }
.kb-count { color: var(--faint); font-size: 12px; min-width: 20px; text-align: center; }
.kb-col-del { color: var(--faint); padding: 4px 7px; border-radius: 6px; font-size: 12px; }
.kb-col-del:hover { color: var(--red, #ed4245); background: var(--hover); }

.kb-cards { flex: 1; min-height: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }

.kb-card {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.kb-card:hover { border-color: var(--accent); }

/* Live drag: someone else is holding this card right now. Tinted dashed
   outline in their presence color + a name chip, pulsing until they drop. */
.kb-card { position: relative; }
.kb-card.kb-held { outline: 2px dashed var(--held, var(--accent)); outline-offset: 2px; opacity: 0.8; animation: kb-held-pulse 1.1s ease-in-out infinite; }
@keyframes kb-held-pulse { 50% { opacity: 0.55; } }
.kb-held-chip {
  position: absolute; top: -9px; right: 8px; z-index: 2;
  font-size: 10px; font-weight: 700; color: #fff; border-radius: 999px; padding: 2px 8px;
  display: inline-flex; gap: 4px; align-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.kb-card-title { color: var(--text); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.kb-card-desc-flag { display: inline-block; margin-top: 5px; color: var(--faint); font-size: 11px; }

.kb-add-btn { margin-top: 6px; width: 100%; text-align: left; color: var(--dim); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.kb-add-btn:hover { background: var(--hover); color: var(--text); }

.kb-add-card { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.kb-add-card textarea {
  width: 100%; resize: none; box-sizing: border-box; font-family: inherit; font-size: 14px;
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); outline: none;
}
.kb-add-card textarea:focus { border-color: var(--accent); }
.kb-add-row { display: flex; gap: 6px; }

.kb-col-new { background: transparent; border: 1px dashed var(--line); gap: 8px; }
.kb-newlist { background: transparent; border: none; color: var(--text); font-size: 14px; outline: none; padding: 6px; width: 100%; }
.kb-newlist::placeholder { color: var(--faint); }

@media (max-width: 760px) {
  .kb-col { width: 84vw; flex-basis: 84vw; }
}

/* ---- Card metadata (labels / due / assignees) ---- */
.kb-labels { display: flex; gap: 4px; margin-bottom: 6px; }
.kb-label { width: 32px; height: 6px; border-radius: 3px; display: inline-block; }
.kb-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.kb-due { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--dim); background: var(--bg-0); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; }
.kb-due.overdue { color: #fff; background: var(--red, #ed4245); border-color: transparent; }
.kb-avatars { margin-left: auto; display: inline-flex; align-items: center; }
.kb-avatars > * { margin-left: -5px; }
.kb-avatars > *:first-child { margin-left: 0; }
.kb-ava-more { font-size: 10px; color: var(--dim); background: var(--bg-3); border: 1px solid var(--line); border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }

/* ---- Card modal ---- */
.kb-modal label { display: block; font-size: 12px; font-weight: 700; color: var(--dim); margin: 12px 2px 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.kb-modal label:first-child { margin-top: 0; }
.kb-desc { width: 100%; resize: vertical; box-sizing: border-box; font-family: inherit; font-size: 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); outline: none; }
.kb-desc:focus { border-color: var(--accent); }
.kb-label-row { display: flex; gap: 8px; }
.kb-label-pill { width: 44px; height: 26px; border-radius: 7px; cursor: pointer; color: #fff; font-size: 12px; opacity: 0.55; border: 2px solid transparent; }
.kb-label-pill.on { opacity: 1; border-color: #fff3; }
.kb-label-pill:hover { opacity: 0.85; }
.kb-field-row { display: flex; gap: 12px; }
.kb-field { flex: 1; min-width: 0; }
.kb-due-row { display: flex; gap: 6px; align-items: center; }
/* Themed "List" dropdown pill (replaces the native select, which can't be styled). */
.kbm-select {
  display: inline-flex; align-items: center; gap: 8px; width: 100%; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
}
.kbm-select .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbm-select i { font-size: 10px; opacity: .6; }
.kbm-select:hover { border-color: var(--accent); }
.kb-assignees { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.kb-assignee { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.kb-assignee:hover { background: var(--hover); }
.kb-assignee.on { background: var(--active); }
.kb-assignee .ka-name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-assignee i { color: var(--accent); }
.kb-assignee.on i { color: inherit; }

/* ---- Board categories (launcher sections + create modal) ---- */
.kb-cats-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 16px; }
.kb-cat-head {
  display: flex; align-items: center; gap: 9px; padding: 18px 18px 0;
  font-size: 12px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim);
}
.kb-cat-head i { color: var(--cat); font-size: 14px; }
.kb-cat-count { color: var(--faint); font-weight: 600; }
.wb-grid.kb-sec { flex: none; overflow: visible; padding-top: 10px; }
.kb-cat-options { display: flex; flex-wrap: wrap; gap: 8px; }
.kb-cat-opt {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--bg-3); border: 2px solid var(--line); color: var(--text);
}
.kb-cat-opt i { color: var(--cat); }
.kb-cat-opt:hover { border-color: var(--cat); }
.kb-cat-opt.on { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 18%, transparent); }
.kb-cat-chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  color: #fff; font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px;
}

/* ---- Media: card covers, board bg, Trello-style card modal ---- */
.kb-card-cover { width: calc(100% + 22px); margin: -9px -11px 8px; max-height: 140px; object-fit: cover; display: block; border-radius: 8px 8px 0 0; background: #000; }
.kb-viewers { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; }
.kb-viewers > * { margin-left: -5px; }
.kb-viewers > *:first-child { margin-left: 0; }
.kb-viewers-label { color: var(--faint); font-size: 11px; margin-left: 7px; }
.kb-dim-pop {
  position: absolute; top: 52px; right: 16px; z-index: 80;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.kb-dim-label { color: var(--dim); font-size: 12px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.kb-board { position: relative; }

.kb-card-modal { max-width: 860px !important; width: 100%; padding: 0; overflow: hidden; }
.kbm-cover { height: 170px; background-size: cover; background-position: center; background-color: #000; position: relative; }
.kbm-cover-btn {
  position: absolute; right: 10px; bottom: 10px; font-size: 12px;
  background: rgba(0,0,0,.65); color: #fff; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.kbm-cover-btn:hover { background: rgba(0,0,0,.85); }
.kbm-cover-actions { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; }
.kbm-cover-actions .kbm-cover-btn { position: static; }

/* Department filter chips (shared by Currents / Whiteboards / Charts) */
.dept-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Auto-collapsing filter: the strip never wraps and never scrolls — when the
   chips can't fit the available width, the component swaps itself for a
   single dropdown button (the invisible strip stays mounted for measuring). */
.df-wrap { flex: 1 1 auto; min-width: 0; position: relative; display: flex; align-items: center; }
.df-strip { flex: 1; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
.df-strip .df-chip { flex: none; white-space: nowrap; }
.df-strip.ghost { visibility: hidden; position: absolute; inset: 0; pointer-events: none; }
.df-compact { display: inline-flex; flex: none; }
.df-caret { font-size: 10px; margin-left: 2px; color: var(--faint); }
/* The title/crumbs yield leftover header space to the filter. */
.wb-head:has(.df-wrap) .wb-crumbs { flex: 0 0 auto; }
.ch-side-filter .df-wrap { width: 100%; }
.df-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--dim); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.df-chip:hover { color: var(--text); border-color: var(--cat, var(--accent)); }
.df-chip.on { color: var(--text); border-color: var(--cat, var(--accent)); background: color-mix(in srgb, var(--cat, var(--accent)) 18%, transparent); }
.df-chip i { color: var(--cat, var(--dim)); font-size: 11px; }

/* Manage-departments modal (shared by Currents / Whiteboards / Charts) */
.dept-list { display: flex; flex-direction: column; gap: 2px; max-height: 56vh; overflow-y: auto; }
.dept-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.dept-row:hover { background: var(--hover); }
.dept-dot { width: 28px; height: 28px; border-radius: 8px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.dept-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 14px; }
.dept-acts { display: flex; gap: 2px; opacity: 0; }
.dept-row:hover .dept-acts { opacity: 1; }
.dept-acts button { width: 26px; height: 26px; border-radius: 6px; color: var(--dim); }
.dept-acts button:hover { background: var(--hover); color: var(--text); }
.dept-acts button.danger:hover { color: #ed4245; }
.dept-style { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 12px; }
.dept-icons { display: flex; gap: 4px; flex-wrap: wrap; }
.dept-ic { width: 26px; height: 26px; border-radius: 6px; color: var(--dim); }
.dept-ic:hover { background: var(--hover); color: var(--text); }
.dept-ic.sel { outline: 2px solid var(--accent); color: var(--text); }
.kbm-body { display: grid; grid-template-columns: 1fr 300px; gap: 20px; max-height: 62vh; overflow-y: auto; }
.kbm-main { min-width: 0; }
.kbm-title { width: 100%; box-sizing: border-box; background: transparent; border: none; outline: none; color: var(--text); font-size: 19px; font-weight: 800; padding: 4px 2px 10px; }
.kbm-side { min-width: 0; border-left: 1px solid var(--line); padding-left: 18px; }
.kbm-side-head { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kbm-att-head { display: flex; align-items: center; gap: 10px; }
.kbm-att-head label { flex: 1; }
.kbm-atts { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.kbm-empty { color: var(--faint); font-size: 13px; padding: 4px 2px; }
.kbm-att { display: flex; gap: 10px; align-items: center; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.kbm-att-thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.kbm-att-file { width: 64px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--bg-0); border-radius: 6px; color: var(--dim); font-size: 20px; flex: none; }
.kbm-att-meta { min-width: 0; flex: 1; }
.kbm-att-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbm-att-actions { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; }
.kbm-att-actions a, .kbm-att-actions button { color: var(--dim); text-decoration: underline; cursor: pointer; background: none; border: none; padding: 0; font-size: 12px; }
.kbm-att-actions a:hover, .kbm-att-actions button:hover { color: var(--text); }
.kbm-att-actions .danger:hover { color: var(--red, #ed4245); }
.kbm-comments { display: flex; flex-direction: column; gap: 10px; }
.kbm-comment-list { display: flex; flex-direction: column; gap: 12px; }
.kbm-comment { display: flex; gap: 9px; }
.kbm-comment-body { min-width: 0; flex: 1; }
.kbm-comment-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.kbm-comment-head b { color: var(--text); font-size: 13px; }
.kbm-comment-del { color: var(--faint); cursor: pointer; margin-left: auto; }
.kbm-comment-del:hover { color: var(--red, #ed4245); }
.kbm-comment-text { font-size: 13px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.kbm-activity { color: var(--faint); font-size: 12px; padding-top: 6px; border-top: 1px solid var(--line); }
.kbm-activity b { color: var(--dim); }

@media (max-width: 760px) {
  .kbm-body { grid-template-columns: 1fr; }
  .kbm-side { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; }
}
