/* shell.css — foundation-ui structural app-shell styles.
 *
 * Loaded AFTER tokens.css + themes.css (reads only var() tokens). Owns the shell
 * chrome: resets/typography, the header/sidebar/main/footer layout, the generic
 * .btn/.btn-icon controls, the whitebell vendor credit, and the AI chat panel
 * interior. App-specific rules (data tables, filters, page bodies) stay in the
 * consumer's own CSS. Re-skin by overriding token VALUES, never these selectors.
 */

/* ─────────────────────────  Resets & typography  ───────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%; /* viewport-locked shell (ree-x contract): the window never scrolls */
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Hover contract (owner ruling 2026-07-31): never underline — hover feedback comes
   from border/frame or surface color changes on the containing control, plus a
   slight brightness lift on bare text links. */
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast), filter var(--t-fast); }
a:hover { text-decoration: none; filter: brightness(1.15); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

h1, h2, h3, h4, h5, h6 { margin: 0 0 0.5em; font-weight: 600; line-height: 1.25; color: var(--fg); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5, h6 { font-size: var(--fs-md); }
p { margin: 0 0 1em; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid transparent; background: transparent; }
input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  color: var(--fg);
  transition: border-color var(--t-fast);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
::selection { background: var(--accent); color: var(--accent-fg); }

.ph, [class*=" ph-"], [class^="ph-"] { font-size: 1.05em; vertical-align: -0.15em; }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Accessibility: skip-to-content + visually-hidden (WCAG 2.4.1) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.sr-only-focusable:focus-visible {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto;
  padding: 6px 14px; margin: 0; overflow: visible; clip: auto; white-space: normal;
  background: var(--accent); color: var(--accent-fg); border-radius: var(--r-sm);
  font-weight: 600; z-index: 200; text-decoration: none;
}

/* ─────────────────────────  Page layout  ───────────────────────── */

/* Fixed-chrome contract (ree-x, platform foundation rule): header and footer are
   viewport-locked flex rows, .app-layout takes the exact remaining height, and each
   column (sidebar / main / chat) scrolls INTERNALLY. Pages never move the chrome and
   the AI panel is layout-independent from page content. */
body { display: flex; flex-direction: column; height: 100vh; min-height: 100vh; overflow: hidden; }

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 0.16s ease;
}
body.nav-resizing .app-layout { transition: none; } /* live drag: no easing lag */
body[data-sidebar="collapsed"] .app-layout { grid-template-columns: var(--sidebar-w-mini) 1fr; }
body[data-chat="open"] .app-layout { grid-template-columns: var(--sidebar-w) 1fr var(--chat-panel-w); }
body[data-chat="open"][data-sidebar="collapsed"] .app-layout {
  grid-template-columns: var(--sidebar-w-mini) 1fr var(--chat-panel-w);
}
/* results/context pane — sits BETWEEN main and the chat column (owner ruling
   2026-07-31: RAG hits get their own pane; the chat keeps the answer) */
body[data-ctx="open"] .app-layout { grid-template-columns: var(--sidebar-w) 1fr var(--ctx-panel-w); }
body[data-ctx="open"][data-sidebar="collapsed"] .app-layout {
  grid-template-columns: var(--sidebar-w-mini) 1fr var(--ctx-panel-w);
}
body[data-ctx="open"][data-chat="open"] .app-layout {
  grid-template-columns: var(--sidebar-w) 1fr var(--ctx-panel-w) var(--chat-panel-w);
}
body[data-ctx="open"][data-chat="open"][data-sidebar="collapsed"] .app-layout {
  grid-template-columns: var(--sidebar-w-mini) 1fr var(--ctx-panel-w) var(--chat-panel-w);
}

/* ── Header ── */
.top-header {
  flex: none; z-index: 30;
  height: var(--header-h);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 var(--content-pad); gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--fs-lg); color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand .ph { font-size: 1.4em; color: var(--accent); }
.header-sep { width: 1px; height: 20px; background: var(--border); }
.header-title { color: var(--fg-subtle); font-size: var(--fs-md); }
.header-spacer { flex: 1; }
.sidebar-toggle-btn {
  background: none; border: none; padding: 4px 6px; cursor: pointer;
  color: var(--fg-muted); font-size: 1.1em; line-height: 1;
  transition: color var(--t-fast); flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--fg); }
.sidebar-toggle-btn .ph { display: inline-block; transition: transform var(--t-fast); }
body[data-sidebar="collapsed"] .sidebar-toggle-btn .ph { transform: rotate(180deg); }
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ── User menu ── */
.user-menu-wrap { position: relative; }
.user-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 6px; border: none; background: none;
  color: var(--fg); font-size: var(--fs-sm); cursor: pointer; transition: background 0.15s;
}
.user-badge:hover { background: var(--bg-hover); }
.user-menu-caret { font-size: 0.75em; opacity: 0.6; transition: transform 0.15s; }
.user-menu-wrap[data-open] .user-menu-caret { transform: rotate(180deg); }
.user-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; min-width: 160px;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: var(--shadow-md); z-index: 100; overflow: hidden;
}
.user-menu-wrap[data-open] .user-menu { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  color: var(--fg); font-size: var(--fs-sm); white-space: nowrap; text-decoration: none;
}
.user-menu-item:hover { background: var(--bg-hover); text-decoration: none; }
.user-menu-item .ph { opacity: 0.7; }

/* ── Sidebar ── */
.sidebar {
  min-height: 0; /* grid child: allow internal scroll instead of growing the track */
  overflow-y: auto; background: var(--bg-alt); border-right: 1px solid var(--border);
  padding: 12px 0;
  scrollbar-width: none; -ms-overflow-style: none; /* hidden scrollbar (functional) */
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-section { margin-bottom: 16px; }
.sidebar-section-title {
  display: block; padding: 8px 16px 4px; font-size: var(--fs-xs);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted); font-weight: 600;
}
a.sidebar-section-link { text-decoration: none; cursor: pointer; transition: color var(--t-fast); }
a.sidebar-section-link:hover { color: var(--fg); }
a.sidebar-section-link.is-active { color: var(--accent); }
.sidebar-section-head { display: flex; align-items: center; cursor: pointer; user-select: none; }
.sidebar-section-head .sidebar-section-title { flex: 1; }
.sidebar-section-caret {
  font-size: 11px; color: var(--fg-muted); margin: 4px 14px 0 0;
  transition: transform var(--t-fast), color var(--t-fast);
}
.sidebar-section-head:hover .sidebar-section-title,
.sidebar-section-head:hover .sidebar-section-caret { color: var(--fg); }
.sidebar-section.collapsed .sidebar-section-caret { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-section-items { display: none; }
body[data-sidebar="collapsed"] .sidebar-section-caret { display: none; }
body[data-sidebar="collapsed"] .sidebar-section.collapsed .sidebar-section-items { display: block; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 16px;
  color: var(--fg-subtle); font-size: var(--fs-md);
  border-left: 3px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.sidebar-link:hover { background: var(--bg-card); color: var(--fg); text-decoration: none; }
.sidebar-link.is-active { background: var(--bg-card); color: var(--fg); border-left-color: var(--accent); }
.sidebar-link.is-disabled { color: var(--fg-muted); cursor: default; opacity: 0.7; }
.sidebar-link .ph { font-size: 1.1em; flex-shrink: 0; }
.sidebar-link .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-link .count {
  font-size: var(--fs-xs); color: var(--fg-muted); font-variant-numeric: tabular-nums;
  margin-left: 8px; flex-shrink: 0;
}
body[data-sidebar="collapsed"] .sidebar-section-title,
body[data-sidebar="collapsed"] .sidebar-link .label,
body[data-sidebar="collapsed"] .sidebar-link .count { display: none; }
.sidebar-children {
  display: flex; flex-direction: column; padding-left: 18px;
  border-left: 1px solid var(--border); margin-left: 26px;
}
.sidebar-children .sidebar-link { padding-left: 12px; }

/* A nav item that owns children folds too — the section caret only reaches the
   top tier, so a deep branch (a wiki category's articles) had no way to close.
   The row is a flex pair: the link keeps navigating, the caret only folds. */
.sidebar-item-row { display: flex; align-items: center; }
.sidebar-item-row > .sidebar-link { flex: 1; min-width: 0; }
.sidebar-item-caret {
  font-size: 11px; color: var(--fg-muted); padding: 6px 14px 6px 4px; cursor: pointer;
  transition: transform var(--t-fast), color var(--t-fast);
}
.sidebar-item-caret:hover { color: var(--fg); }
.sidebar-item-caret:focus-visible { color: var(--accent); outline: none; }
.sidebar-item.collapsed > .sidebar-item-row .sidebar-item-caret { transform: rotate(-90deg); }
.sidebar-item.collapsed > .sidebar-children { display: none; }
body[data-sidebar="collapsed"] .sidebar-item-caret { display: none; }

/* ── Main — the ONLY page-content scroll surface (hidden bar, ree-x idiom) ── */
.main-content {
  padding: var(--content-pad) calc(var(--content-pad) * 1.5); width: 100%;
  min-height: 0; overflow-y: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.main-content::-webkit-scrollbar { display: none; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-header h1 { margin: 0; font-size: var(--fs-xl); }

/* ── Footer + whitebell vendor credit ── */
.bottom-footer {
  flex: none; z-index: 30; height: var(--footer-h);
  background: var(--bg-alt); border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 var(--content-pad);
  font-size: var(--fs-xs); color: var(--fg-muted); gap: 12px;
}
.bottom-footer .wb-brand { display: inline-flex; align-items: center; gap: 4px; color: var(--fg); font-weight: 600; }
.bottom-footer .wb-brand svg { height: 14px; width: auto; flex: none; }
/* accent dot keeps the consumer's assigned accent (brand doc §5) via --wb-accent */
.bottom-footer .wb-brand .wb-dot { fill: var(--wb-accent, var(--accent)); }

/* ── Loading / htmx affordances ── */
#loading-bar {
  position: fixed; top: 0; left: 0; height: 3px; background: var(--accent);
  z-index: 10000; width: 0; opacity: 0;
  transition: opacity 0.1s ease, width 0.1s ease; pointer-events: none;
}
#loading-bar.lb-active { opacity: 1; animation: lb-fill 8s ease-out forwards; }
#loading-bar.lb-done { width: 100%; opacity: 0; transition: opacity 0.3s ease 0.1s, width 0.1s; }
@keyframes lb-fill { 0% { width: 0; } 30% { width: 50%; } 70% { width: 75%; } 100% { width: 90%; } }
.htmx-indicator { opacity: 0; transition: opacity var(--t-fast); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }
.minimal-version { text-align: center; font-size: 0.72rem; margin-top: 12px; opacity: 0.5; }

/* ─────────────────────────  Generic controls  ───────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--fg); font-size: var(--fs-md); font-weight: 500;
  cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.1); }
.btn-xs { padding: 2px 8px; font-size: var(--fs-sm); }
.btn-icon { padding: 0; width: 36px; height: 36px; justify-content: center; align-items: center; flex-shrink: 0; }
.btn-icon .ph { font-size: 1.15em; }
.btn-icon.btn-xs { width: 28px; height: 28px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }
.btn-icon.btn-icon-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-icon.btn-icon-primary:hover { filter: brightness(1.08); }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--fg-muted); }
.status-auth { background: var(--success); }
.status-guest { background: var(--fg-muted); }

/* ─────────────  Popup context menu (mechanism: ctx-menu.js)  ───────────── */

.ui-ctxmenu {
  display: none; position: fixed; z-index: 1000; min-width: 180px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 4px; font-size: var(--fs-sm);
}
.ui-ctxmenu-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: var(--r-sm); color: var(--fg); cursor: pointer; white-space: nowrap;
}
.ui-ctxmenu-item:hover { background: var(--bg-card-hover); }
.ui-ctxmenu-item .ph { color: var(--fg-subtle); font-size: 1.05em; }
.ui-ctxmenu-divider { height: 1px; background: var(--border); margin: 4px 6px; }
.ui-ctxmenu-header {
  padding: 6px 10px 2px; font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted);
}

/* ─────────────  Modal frame (openModalFrom/closeModal, app-shell.js)  ───────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 900; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(var(--crust-rgb, 0, 0, 0), 0.55);
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  min-width: 320px; max-width: min(480px, 92vw); padding: 18px 20px;
}
.modal h3 { margin: 0 0 12px; font-size: var(--fs-lg); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
/* uiConfirm (app-shell.js) — the shell's answer to window.confirm. Only the message
   block is new; the frame, the button row and the buttons are the modal's own. */
.modal-confirm .modal-message { margin: 0; color: var(--fg-muted); line-height: 1.5; }

/* ─────────────  Context/results pane (between main and chat)  ───────────── */

.ctx-panel {
  position: relative; min-height: 0; display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--bg-alt);
}
.ctx-resize { position: absolute; left: -3px; top: 0; width: 6px; height: 100%; cursor: col-resize; z-index: 3; }
.ctx-resize:hover, body.ctx-resizing .ctx-resize { background: rgba(var(--accent-rgb), 0.25); }
body.ctx-resizing { user-select: none; cursor: col-resize; }
body:not([data-ctx="open"]) .ctx-panel { display: none; }
.ctx-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); font-size: .82rem; font-weight: 600;
  color: var(--fg-muted); flex-shrink: 0;
}
.ctx-head .ctx-spacer { flex: 1; }
.ctx-body {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.ctx-body::-webkit-scrollbar { display: none; }

/* ─────────────────────────  AI chat panel  ───────────────────────── */

.chat-panel {
  position: relative; /* ANCHOR for .cp-resize-handle — lost when sticky was removed
                         in the fixed-chrome rework (live bug: handle unreachable) */
  min-height: 0; /* grid child: own internal scroll (cp-log), independent of pages */
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--bg-alt); overflow: hidden;
}
body:not([data-chat="open"]) .chat-panel { display: none; }
.cp-resize-handle {
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px; cursor: ew-resize;
  z-index: 20; transition: background var(--t-fast);
}
.cp-resize-handle:hover, .cp-resize-handle.is-resizing { background: var(--accent); opacity: 0.4; }
.cp-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); font-size: .82rem; font-weight: 600;
  color: var(--fg-muted); flex-shrink: 0;
}
.cp-header .cp-title { flex: 1; }
.cp-loop-selector {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg-subtle); font-size: var(--fs-sm); cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
  white-space: nowrap; max-width: 180px; overflow: hidden;
}
.cp-loop-selector .ph { font-size: 0.9em; flex-shrink: 0; }
.cp-loop-selector span { overflow: hidden; text-overflow: ellipsis; }
.cp-loop-selector:hover { border-color: var(--accent); color: var(--fg); background: var(--bg-hover); }
.cp-log {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; font-size: .84rem;
}
.cp-log::-webkit-scrollbar { width: 4px; }
.cp-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.cp-msg { padding: 6px 10px; border-radius: 8px; line-height: 1.45; word-break: break-word; max-width: 100%; }
.cp-msg.cp-user { background: rgba(var(--accent-rgb), .12); color: var(--fg); align-self: flex-end; border-bottom-right-radius: 2px; }
.cp-msg.cp-assistant { background: var(--bg-card); border: 1px solid var(--border); color: var(--fg); align-self: flex-start; border-bottom-left-radius: 2px; }
.cp-msg.cp-thinking { opacity: .55; font-style: italic; }
.cp-menu-link {
  color: var(--accent); text-decoration: none; cursor: pointer; font-size: inherit;
  border-bottom: 1px dotted var(--accent);
}
.cp-menu-link:hover { border-bottom-style: solid; filter: brightness(1.15); }

/* ── Rendered markdown inside an answer (spec docs/specs/chat-markdown/) ──
   The bubble is narrow, so anything that can outgrow it (tables, code) scrolls
   inside its own container instead of stretching the chat grid column. The
   horizontal bar stays visible here — it is the only cue that a table continues. */
.cp-md-p { margin: 0 0 6px; }
.cp-msg > .cp-md-p:last-child { margin-bottom: 0; }
.cp-md-h { margin: 10px 0 4px; font-size: .88rem; font-weight: 600; color: var(--fg); line-height: 1.3; }
.cp-msg > .cp-md-h:first-child { margin-top: 0; }
h6.cp-md-h { color: var(--fg-subtle); }
.cp-md-hr { margin: 8px 0; border: 0; border-top: 1px solid var(--border); }
.cp-md-list { margin: 0 0 6px; padding-left: 18px; }
.cp-md-list li { margin: 2px 0; }
.cp-md-link { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.cp-md-link:hover { border-bottom-color: var(--accent); }
.cp-md-code {
  font-family: var(--font-mono); font-size: .92em; padding: 1px 4px; border-radius: 3px;
  background: var(--bg-input); color: var(--fg); word-break: break-all;
}
.cp-md-pre {
  margin: 0 0 6px; padding: 8px 10px; border-radius: 6px; overflow-x: auto;
  background: var(--bg-input); border: 1px solid var(--border);
}
.cp-md-pre code { font-family: var(--font-mono); font-size: .82rem; line-height: 1.4; white-space: pre; }
.cp-md-tablewrap { margin: 0 0 6px; overflow-x: auto; max-width: 100%; }
.cp-md-table { border-collapse: collapse; font-size: .78rem; }
.cp-md-table th, .cp-md-table td {
  border: 1px solid var(--border); padding: 3px 7px; text-align: left; vertical-align: top;
  white-space: normal; word-break: normal;
}
.cp-md-table th { background: var(--bg-alt); font-weight: 600; color: var(--fg); }
.cp-md-table tbody tr:nth-child(even) td { background: rgba(var(--accent-rgb), .04); }
/* Column alignment from the delimiter row — scoped to beat `.cp-md-table th/td`. */
.cp-md-table .cp-md-left { text-align: left; }
.cp-md-table .cp-md-center { text-align: center; }
.cp-md-table .cp-md-right { text-align: right; }
.cp-form { position: relative; display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.cp-input {
  flex: 1; resize: none; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font-size: .84rem; font-family: var(--font-sans); line-height: 1.4;
  min-height: 36px; max-height: 120px; overflow-y: auto;
  scrollbar-width: none; -ms-overflow-style: none; /* autosize owns the height — no arrows */
}
.cp-input::-webkit-scrollbar { display: none; }
.cp-input:focus { outline: none; border-color: var(--accent); }
.cp-send-btn { align-self: flex-end; }
#chat-panel-toggle.cp-online { color: var(--success); }
#chat-panel-toggle.cp-offline { color: var(--danger); }

/* ── Sidebar resize handle (spec docs/specs/sidebar-resize/) ── */
.sidebar { position: relative; }
.sidebar-resize {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: col-resize; z-index: 3;
}
.sidebar-resize:hover, body.sidebar-resizing .sidebar-resize {
  background: rgba(var(--accent-rgb), 0.25);
}
body.sidebar-resizing { user-select: none; cursor: col-resize; }
body[data-sidebar="collapsed"] .sidebar-resize { display: none; }

/* ── Example-question chips (empty-state suggestions) ── */
.cp-examples { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.cp-example {
  text-align: left; padding: 7px 10px; font-size: var(--fs-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--fg-subtle); cursor: pointer;
}
.cp-example:hover { border-color: var(--accent); color: var(--fg); background: var(--bg-card-hover); }

/* ── Thinking indicator (johanna robot bob + vera elapsed ticker) ── */
.cp-thinking {
  display: flex; align-items: center; gap: 8px; align-self: flex-start;
  padding: 8px 12px; margin: 4px 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--fg-muted); font-size: var(--fs-sm);
}
.cp-thinking .ph { color: var(--accent); animation: cp-bob 1s ease-in-out infinite; }
.cp-elapsed { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
@keyframes cp-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30%      { transform: translateY(-4px) rotate(-8deg); }
  60%      { transform: translateY(0) rotate(0deg); }
  80%      { transform: translateY(-2px) rotate(8deg); }
}

/* ── Per-turn usage badge + session total (vera/johanna pattern) ── */
.cp-usage {
  display: flex; gap: 10px; align-items: center; align-self: flex-start;
  font-size: var(--fs-xs); color: var(--fg-muted);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  padding: 0 2px; margin: -2px 0 4px;
}
.cp-usage .ph { font-size: 0.9em; }
.cp-usage-total {
  font-size: var(--fs-xs); color: var(--fg-muted);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}

/* ── Result-tile score pill + top-k rest counter (results pane) ── */
.cp-card { position: relative; }
.cp-card-score {
  position: absolute; top: 8px; right: 8px;
  font-size: var(--fs-xs); font-family: var(--font-mono);
  color: var(--accent); background: rgba(var(--accent-rgb), 0.12);
  padding: 0 6px; border-radius: var(--r-pill, 999px);
}
.ctx-more { text-align: center; color: var(--fg-muted); font-size: var(--fs-xs); padding: 6px 0; }

/* ── Chat cited-tile cards (spec docs/specs/chat-cards/) ── */
.cp-cards { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.cp-card {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); text-decoration: none;
}
.cp-card:hover { border-color: var(--accent); }
.cp-card-cat { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.cp-card-title { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
.cp-card-snippet {
  font-size: var(--fs-xs); color: var(--fg-muted);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* replayed history turns (B5) — present but visually receded */
.cp-msg.cp-replay { opacity: 0.62; }

/* Environment marker (footer). Production is deliberately unstyled — it reads as one
   more build fact; a non-production window is the one that must announce itself. */
.env-marker--nonprod { color: var(--warning); }
/* Progress narration beside the elapsed ticker (server-named stages). */
.cp-stage { color: var(--fg-muted); font-size: .78rem; margin-right: 6px; }
/* Source approval on the retrieved-article cards (opt-in host feature): the TILE is
   the toggle — a dropped card stays visible (provenance) but reads as excluded; the
   rerun action is the icon button in the pane header. */
.cp-card--off { opacity: .38; border-style: dashed; }
.cp-card--off:hover { opacity: .6; }
/* A low-confidence source is SHOWN, dimmed — never hidden. The cards are the answer's
   provenance, so removing one from view makes "what was this based on?" unanswerable,
   and makes source approval impossible: a card you cannot see is one you cannot untick. */
.cp-card--low { opacity: .62; }
.cp-card--low .cp-card-score { color: var(--fg-subtle, var(--fg-muted)); }

/* Page help — the [i] beside the header title. Anchored to the header so it sits in the same
   place on every page: a help affordance that moves is one people stop looking for. */
.page-help { position: relative; display: inline-flex; }
.page-help-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: 380px; max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto;
  padding: 12px 14px; font-size: .84rem; line-height: 1.5; text-align: left;
  color: var(--fg); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px); box-shadow: 0 8px 24px rgba(0,0,0,.35);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.page-help-pop[hidden] { display: none; }
.page-help-pop p { margin: 0 0 10px; }
.page-help-pop p:last-child { margin-bottom: 0; }
.page-help-pop ul { margin: 0 0 10px; padding-left: 18px; }
.page-help-pop code { background: var(--bg-input); padding: .1rem .3rem; border-radius: 3px;
  font-family: var(--font-mono); font-size: .95em; }
