/* ============================================================
   SCOPELINE APP — page compositions on top of the design system
   (tokens.css + components.css). Consolidated from the design's
   example pages so PHP views share one stylesheet.
   ============================================================ */

/* ---- Dashboard ---- */
.dash-row { display: grid; grid-template-columns: 1.55fr 1fr; gap: var(--sp-5); align-items: start; }
/* Even split for the Portfolio row: its two halves (Recent activity / Needs
   attention) carry comparable content, unlike the Action Queue / EOD row the
   default ratio is tuned for. */
.dash-row--even { grid-template-columns: 1fr 1fr; }
/* Portfolio "Needs attention": project cards flow to fill the width instead of
   stacking into a tall single column. ~2 across inside a half-width column,
   3–4 across when the row spans full width (e.g. Recent activity is empty). */
.pf-attn { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); align-items: start; }
.attn-card { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); background: var(--bg-inset); border: 1px solid var(--stroke); border-radius: var(--r-md); }
.attn-card .attn-head { display: flex; align-items: center; gap: var(--sp-2); }
.attn-card .attn-name { font-weight: 600; flex: 1; min-width: 0; }
.attn-card .attn-reasons { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
/* Action Queue / EOD row: the two cards share height so a sparse Action Queue
   ("All clear") doesn't leave a void — its content centers in the shared
   height instead of clinging to the top. */
.dash-row--eod { align-items: stretch; }
.aq-card { display: flex; flex-direction: column; }
.aq-card .qstack { flex: 1; justify-content: center; }
.int-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); align-items: start; }
@media (max-width: 1280px) { .dash-row, .int-grid { grid-template-columns: 1fr; } }
.eod-grid { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-6); align-items: center; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table td { padding: var(--sp-2) 0; border-bottom: 1px solid var(--stroke); font-size: var(--fs-sm); vertical-align: middle; }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table .mt-main { font-weight: 600; color: var(--text-1); font-size: var(--fs-body); }
.mini-table .mt-sub { color: var(--text-3); font-size: 12.5px; }
.mini-table .num { text-align: right; font-family: var(--font-mono); color: var(--text-2); white-space: nowrap; }
.mini-table .act { width: 32px; text-align: right; }
.env-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; }
.env-row + .env-row { border-top: 1px solid var(--stroke); }
.snap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.snap { background: var(--bg-inset); border: 1px solid var(--stroke); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); }
.snap .sn-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.snap .sn-label { font-size: var(--fs-sm); color: var(--text-3); }
.site-browser { margin-top: var(--sp-3); }
.site-browser summary { cursor: pointer; color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; }
.site-browser[open] summary { margin-bottom: var(--sp-2); }
.site-browser .env-row { padding: var(--sp-2) 0; }

/* ---- Projects ---- */
.match-row { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.match-row .arrow { color: var(--text-3); }

/* ---- Project detail ---- */
.sys-panels { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); align-items: start; }
@media (max-width: 1200px) { .sys-panels { grid-template-columns: 1fr; } }
.rec-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; }
.rec-row + .rec-row { border-top: 1px solid var(--stroke); }
.rec-row .rr-body { flex: 1; min-width: 0; }
.rec-row .rr-title { font-weight: 600; display: block; }
.rec-row .rr-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 1px; display: block; }
.id-chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }

/* ---- Connections (unified per-project linking) ---- */
.conn-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; }
.conn-row + .conn-row { border-top: 1px solid var(--stroke); }
.conn-body { flex: 1; min-width: 0; }
.conn-name { font-weight: 600; display: block; }
.conn-role { font-weight: 400; color: var(--text-3); font-size: var(--fs-sm); }
.conn-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 1px; display: block; }
.conn-status { flex: none; }
.conn-actions { flex: none; display: flex; align-items: center; gap: var(--sp-2); }
.conn-pick { position: relative; }
.conn-pick > summary { list-style: none; cursor: pointer; }
.conn-pick > summary::-webkit-details-marker { display: none; }
.conn-pick-panel { position: absolute; right: 0; top: calc(100% + var(--sp-1)); z-index: 30; width: max(320px, 100%); max-width: 420px; max-height: 360px; overflow-y: auto; padding: var(--sp-3); background: var(--bg-base); border: 1px solid var(--stroke); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.conn-cand { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2); border-radius: var(--r-sm); text-decoration: none; color: inherit; }
.conn-cand:hover { background: var(--bg-hover); }
.conn-cand-title { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-cand-id { color: var(--text-3); font-size: 12px; flex: none; }
@media (max-width: 640px) {
  .conn-row { flex-wrap: wrap; }
  .conn-pick-panel { position: static; width: 100%; max-width: none; }
}

/* ---- AI prose (rendered Markdown from the answer engine) ---- */
.ai-prose { line-height: 1.6; }
.ai-prose > :first-child { margin-top: 0; }
.ai-prose > :last-child { margin-bottom: 0; }
.ai-prose p { margin: 0 0 var(--sp-2); }
.ai-prose .ai-h { color: var(--text-1); font-weight: 700; line-height: 1.3; margin: var(--sp-4) 0 var(--sp-2); }
.ai-prose .ai-h:first-child { margin-top: 0; }
.ai-prose h4.ai-h { font-size: var(--fs-base); }
.ai-prose h5.ai-h { font-size: var(--fs-sm); }
.ai-prose h6.ai-h { font-size: var(--fs-sm); color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.ai-prose strong { font-weight: 700; color: var(--text-1); }
.ai-prose em { font-style: italic; }
.ai-prose code { font-family: ui-monospace, "IBM Plex Mono", monospace; font-size: 0.9em; background: var(--bg-inset); padding: 1px 5px; border-radius: var(--r-xs); }
.ai-prose a:not(.cite-chip) { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ai-prose a:not(.cite-chip):hover { text-decoration-thickness: 2px; }
.ai-prose .ai-hr { border: 0; border-top: 1px solid var(--stroke); margin: var(--sp-4) 0; }
.ai-prose .ai-quote { margin: var(--sp-3) 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--stroke-strong); background: color-mix(in oklab, var(--bg-inset) 60%, transparent); color: var(--text-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
/* Markdown tables. Horizontal scroll on narrow widths via the wrapper so a wide
   table never blows out the card. */
.ai-table-wrap { overflow-x: auto; margin: var(--sp-3) 0; }
.ai-prose .ai-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: 1.45; }
.ai-prose .ai-table th, .ai-prose .ai-table td { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--stroke); text-align: left; vertical-align: top; }
.ai-prose .ai-table thead th { background: var(--bg-inset); color: var(--text-1); font-weight: 600; white-space: nowrap; }
.ai-prose .ai-table tbody tr:nth-child(even) td { background: color-mix(in oklab, var(--bg-inset) 45%, transparent); }
.ai-prose ul.ai-list { margin: 0 0 var(--sp-2); padding-left: 1.5em; list-style: disc; }
.ai-prose ol.ai-list { margin: 0 0 var(--sp-2); padding-left: 1.7em; list-style: decimal; }
.ai-prose ol.ai-list > li, .ai-prose ul.ai-list > li { margin: 4px 0; }
.ai-prose li > ul.ai-list, .ai-prose li > ol.ai-list { margin: 5px 0 2px; }
.ai-prose li { line-height: 1.55; }
.ai-prose li::marker { color: var(--text-3); }
/* Citations are reference, not action — quiet neutral chip (orange is reserved
   for nav-active + primary actions, so inline refs don't speckle the prose). */
.cite-chip { display: inline-block; font-family: ui-monospace, "IBM Plex Mono", monospace; font-size: 0.8em; font-weight: 600; line-height: 1.4; padding: 0 6px; border-radius: var(--r-pill); text-decoration: none; color: var(--text-2); background: color-mix(in oklab, var(--text-1) 8%, transparent); vertical-align: baseline; white-space: nowrap; }
.cite-chip:hover { color: var(--text-1); background: color-mix(in oklab, var(--text-1) 16%, transparent); }
.ai-lens-stale { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); background: color-mix(in oklab, var(--warning) 12%, transparent); border: 1px solid color-mix(in oklab, var(--warning) 32%, transparent); }
.ai-lens-stale .icon { flex: none; color: var(--warning); }
.ai-lens-fresh { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); background: color-mix(in oklab, var(--success) 10%, transparent); border: 1px solid color-mix(in oklab, var(--success) 28%, transparent); }
.ai-lens-fresh .icon { flex: none; color: var(--success); }

/* Citations under an AI answer: a disclosure collapsed by default so the
   answer reads clean; click "Cited · N" to reveal the record chips. */
.cite-disc { margin-top: var(--sp-2); }
.cite-disc > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; font-size: 12px; font-weight: 600; color: var(--text-3); user-select: none; }
.cite-disc > summary::-webkit-details-marker { display: none; }
.cite-disc > summary::before { content: '▸'; font-size: 9px; line-height: 1; transition: transform 0.12s ease; }
.cite-disc[open] > summary::before { transform: rotate(90deg); }
.cite-disc > summary:hover { color: var(--text-2); }
.cite-list { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-1); }

/* ---- Required-permissions disclosure (Admin → Credentials / AI) ---- */
.perm-disc { margin: calc(var(--sp-2) * -1) 0 var(--sp-2); border-top: 1px solid var(--stroke); }
/* Standalone context (no .sync-row above, a .sync-footer below): drop the
   negative pull and its own hairline so it neither crowds the text above nor
   double-rules against the footer's border. */
.perm-disc--bare { margin: var(--sp-3) 0 0; border-top: 0; }
.perm-disc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; color: var(--text-2); font-size: var(--fs-sm); }
.perm-disc > summary::-webkit-details-marker { display: none; }
.perm-disc > summary:hover { color: var(--text-1); }
.perm-sum-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.perm-disc[open] > summary { color: var(--text-1); }
.perm-list { padding: 0 0 var(--sp-2); display: flex; flex-direction: column; }
.perm-row { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-2) 0; }
.perm-row + .perm-row { border-top: 1px solid color-mix(in oklab, var(--stroke) 60%, transparent); }
.perm-body { flex: 1; min-width: 0; }
.perm-name { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.perm-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); border: 1px solid var(--stroke); border-radius: var(--r-pill); padding: 1px 7px; }
.perm-why { display: block; font-size: var(--fs-sm); color: var(--text-3); margin-top: 2px; }
.perm-foot { font-size: 12px; color: var(--text-3); margin: var(--sp-2) 0 0; }

/* ---- Key Vault secret-name editor (Admin) ---- */
.kv-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
.kv-row + .kv-row { border-top: 1px solid color-mix(in oklab, var(--stroke) 60%, transparent); }
.kv-body { flex: 1; min-width: 0; }
.kv-label { font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.kv-path { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.kv-status { flex: none; min-width: 78px; text-align: right; }
.kv-name { flex: none; width: 340px; max-width: 42%; font-family: ui-monospace, "IBM Plex Mono", monospace; font-size: 12px; }
@media (max-width: 640px) { .kv-row { flex-wrap: wrap; } .kv-name { width: 100%; max-width: none; } }

/* ---- Operational settings (Admin → Settings) ---- */
.set-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
.set-row + .set-row { border-top: 1px solid color-mix(in oklab, var(--stroke) 60%, transparent); }
.set-body { flex: 1; min-width: 0; }
.set-label { font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.set-path { font-size: 11px; color: var(--text-3); font-weight: 400; }
.set-help { display: block; font-size: var(--fs-sm); color: var(--text-3); margin-top: 1px; }
.set-input { flex: none; width: 340px; max-width: 46%; }
@media (max-width: 640px) { .set-row { flex-wrap: wrap; } .set-input { width: 100%; max-width: none; } }

/* ---- Admin credentials: per-integration collapsible sections ---- */
.creds-disc { border: 1px solid var(--stroke); border-radius: var(--r-md); margin-bottom: var(--sp-3); background: color-mix(in oklab, var(--bg-inset) 35%, transparent); }
.creds-disc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); user-select: none; }
.creds-disc > summary::-webkit-details-marker { display: none; }
.creds-disc > summary::after { content: '▸'; margin-left: var(--sp-2); color: var(--text-3); font-size: 11px; transition: transform 0.12s ease; }
.creds-disc[open] > summary::after { transform: rotate(90deg); }
.creds-disc > summary:hover { background: var(--bg-hover); }
.creds-disc[open] > summary { border-bottom: 1px solid var(--stroke); border-radius: var(--r-md) var(--r-md) 0 0; }
.creds-disc .creds-disc-name { font-weight: 700; flex: 1; }
.creds-disc .creds-disc-meta { font-size: var(--fs-sm); }
.creds-disc-body { padding: var(--sp-1) var(--sp-4) var(--sp-3); }

/* SharePoint full-access audit results */
.sp-audit-result { margin: var(--sp-2) 0 var(--sp-3); }
.sp-audit-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.sp-audit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--stroke); border-radius: var(--r-sm); overflow: hidden; }
.sp-audit-row { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); background: var(--bg-inset); }
.sp-audit-mark { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.sp-audit-row.sp-pass .sp-audit-mark { background: color-mix(in oklab, var(--success) 22%, transparent); color: var(--success); }
.sp-audit-row.sp-fail .sp-audit-mark { background: color-mix(in oklab, var(--danger) 22%, transparent); color: var(--danger); }
.sp-audit-row.sp-skip .sp-audit-mark { background: var(--bg-hover); color: var(--text-3); }
.sp-audit-row.sp-info .sp-audit-mark { background: color-mix(in oklab, var(--info) 22%, transparent); color: var(--info); font-style: italic; }
.sp-audit-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: var(--fs-sm); }
.sp-audit-text b { color: var(--text-1); font-weight: 600; }
.sp-audit-detail { color: var(--text-3); font-size: 12px; }

/* ---- Record ---- */
.record-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--sp-5); align-items: start; }
@media (max-width: 1200px) { .record-grid { grid-template-columns: 1fr; } }
.link-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; }
.link-row + .link-row { border-top: 1px solid var(--stroke); }
.link-row .lr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.link-row .lr-title { font-weight: 600; }
.link-row .lr-sub { font-size: var(--fs-sm); color: var(--text-3); }
.evidence {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-inset);
  border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--stroke));
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-style: italic;
}

/* ---- Admin ---- */
.admin-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--sp-8); align-items: start; max-width: 1380px; }
@media (max-width: 1000px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-nav { position: sticky; top: var(--sp-5); display: flex; flex-direction: column; gap: 2px; }
.admin-nav a { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; font-size: var(--fs-body); text-decoration: none; }
.admin-nav a:hover { background: var(--bg-hover); color: var(--text-1); }
.admin-nav a.active { background: var(--accent-softer); color: var(--accent); }
.admin-nav a .icon { width: 18px; height: 18px; }
.admin-nav .phase-tag { margin-left: auto; }
.admin-stack { display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.sync-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) 0; }
.sync-row + .sync-row { border-top: 1px solid var(--stroke); }
.sync-row .sy-body { flex: 1; min-width: 0; }
.sync-row .sy-name { font-weight: 700; display: block; }
.sync-row .sy-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 1px; display: block; }
.sync-row .sy-err { color: var(--danger); font-size: var(--fs-sm); display: block; white-space: normal; overflow-wrap: anywhere; margin-top: 2px; }
/* The hidden attribute must win over component display rules (e.g. .pill is
   display:inline-flex), otherwise a [hidden] pill still shows. */
[hidden] { display: none !important; }
/* Groups a credential row + its permission disclosure so the inline "Test"
   button can scope its pill updates. display:contents keeps the grouping in the
   DOM for JS without generating a box, so the row layout is unchanged. */
.creds-block { display: contents; }
.creds-test-result { white-space: nowrap; }
.creds-test-detail { font-size: var(--fs-sm); color: var(--text-3); margin: 2px 0 var(--sp-2); overflow-wrap: anywhere; }
.creds-test-detail.is-warn { color: var(--warning); }
.creds-test-detail.is-error { color: var(--danger); }

/* Live model response test (Admin > AI) */
.ai-live-row { padding: var(--sp-3) 0; }
.ai-live-row + .ai-live-row { border-top: 1px solid var(--stroke); }
.ai-live-head { display: flex; align-items: center; gap: var(--sp-3); }
.ai-live-head .sy-name { flex: 1; min-width: 0; }
.ai-live-out { margin: var(--sp-2) 0 0; padding: var(--sp-3); background: var(--bg-inset); border: 1px solid var(--stroke); border-radius: var(--r-md); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-1); max-height: 240px; overflow: auto; }
.ai-live-out.is-error { color: var(--danger); }

/* ---- Sign-in gate ---- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6); }
.login-card {
  width: min(430px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  padding: var(--sp-10) var(--sp-8) var(--sp-8);
}
.login-card .brand { margin: 0 0 var(--sp-2); }
.login-title { font-size: var(--fs-h1); font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.login-text { color: var(--text-2); margin: 0; line-height: 1.55; }
.login-error { width: 100%; text-align: left; }
.login-foot { color: var(--text-3); font-size: var(--fs-sm); margin: var(--sp-2) 0 0; }
.ms-logo { width: 18px; height: 18px; flex: none; }

/* ---- Consistent page rhythm ----
   Every page head occupies the same vertical slot and titles share one
   size, so the title, sub-line, and the first content block top edge sit
   at identical positions on every page. Heads with breadcrumbs fill the
   reserved space above (align-items: flex-end) instead of pushing the
   content down. */
.page-head { min-height: 104px; }
.page-title { font-size: 36px; }
/* Sub-lines always occupy pill height, whether or not they contain one
   (the dashboard status pill made its head taller than text-only ones). */
.page-head .meta-strip { min-height: 28px; }

/* ---- Layout stability + fluid navigation ----
   scrollbar-gutter keeps the page width identical whether or not the page
   scrolls (the dashboard looked narrower only because it scrolled);
   cross-document view transitions replace the instant pop between pages
   with a soft cross-fade. */
html { scrollbar-gutter: stable; }

@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  /* The old page holds still while the new one fades in over it: fading
     both at once dipped to the dark root background (the "flash from
     black"), and the slide-up compounded it on quick navigation. */
  ::view-transition-old(root) { animation: none; }
  ::view-transition-new(root) { animation: vt-in 0.14s ease both; }
}

@keyframes vt-in {
  from { opacity: 0; }
}

/* ---- Site footer: bottom of content, or bottom of the viewport when the
   page is short (the .app shell is a flex column) ---- */
.app { min-height: 100vh; box-sizing: border-box; }
.site-footer {
  margin-top: auto;
  padding-top: var(--sp-6);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.login-footer { position: fixed; left: 0; right: 0; bottom: var(--sp-5); margin: 0; padding: 0; }

/* ---- Folder picker (source folder browse on the Documents page) ---- */
/* Floating dropdown anchored under its field - it must not push the
   panel taller while browsing. */
.field:has(.folder-pick) { position: relative; }
.folder-pick {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  background: var(--solid-raised);
  box-shadow: var(--shadow-pop);
  max-height: 260px;
  overflow-y: auto;
}
.folder-pick .fp-row { display: flex; align-items: center; border-bottom: 1px solid var(--stroke); }
.folder-pick .fp-row:last-child { border-bottom: none; }
.folder-pick .fp-head { padding: var(--sp-2) var(--sp-3); font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.folder-pick .fp-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: none;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-pick .fp-name:hover { background: var(--bg-hover); }
.folder-pick .fp-choose {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  flex: none;
}
.folder-pick .fp-choose:hover { text-decoration: underline; }
.folder-pick .fp-note { padding: var(--sp-2) var(--sp-3); color: var(--text-3); font-size: var(--fs-sm); }

/* ---- Table row title links (same destination as the row's Open) ---- */
a.row-link { display: inline-block; color: inherit; text-decoration: none; }
a.row-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Environment pills: Dev = hazard stripes, Live = glowing ---- */
.env-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  flex: none;
  border: 1px solid var(--stroke-strong);
  color: var(--text-2);
}
.env-pill.env-dev {
  color: var(--text-1);
  /* Soft hazard stripes: low-contrast dark bands on the raised surface
     keep the pattern recognizable without fighting the label. */
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(2, 5, 9, 0.22) 6px 12px),
    var(--bg-raised);
}
.env-pill.env-live {
  color: #fff;
  background: linear-gradient(180deg in oklab, color-mix(in oklab, var(--success) 82%, white), var(--success));
  border-color: color-mix(in oklab, var(--success) 65%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 7px rgba(255, 255, 255, 0.3), 0 0 16px -2px color-mix(in oklab, var(--success) 75%, transparent);
  animation: live-glow 4.4s ease-in-out infinite;
}

@keyframes live-glow {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 7px rgba(255, 255, 255, 0.32), 0 0 18px -2px color-mix(in oklab, var(--success) 80%, transparent); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 7px rgba(255, 255, 255, 0.18), 0 0 9px -2px color-mix(in oklab, var(--success) 45%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .env-pill.env-live { animation: none; }
}

/* ---- Project context: header chip + hero depth ---- */
.header-project {
  gap: var(--sp-3);
  padding: var(--sp-1) var(--sp-4);
  max-width: 320px;
  border-color: color-mix(in oklab, var(--accent) 45%, transparent);
  background: var(--accent-softer);
  box-shadow: inset 0 1px 0 var(--edge-hl), 0 6px 22px -12px color-mix(in oklab, var(--accent) 65%, transparent);
  transition: box-shadow 0.6s ease;
}
.header-project:hover {
  transition-duration: 0.45s;
  box-shadow: inset 0 1px 0 var(--edge-hl), inset 0 0 16px -6px color-mix(in oklab, var(--accent) 45%, transparent), 0 6px 26px -10px color-mix(in oklab, var(--accent) 75%, transparent), 0 10px 64px -14px color-mix(in oklab, var(--accent) 32%, transparent);
}
.header-project .ps-name { font-size: var(--fs-sm); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-project .ps-id { font-size: 11px; display: block; }
.header-project .hp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px 1px color-mix(in oklab, var(--accent) 60%, transparent), inset 0 0 3px rgba(255, 255, 255, 0.6);
  flex: none;
  animation: glow-breathe 4.4s ease-in-out infinite;
}

.project-hero {
  position: relative;
  padding: var(--sp-5) var(--sp-6);
  background:
    var(--grain) repeat,
    linear-gradient(135deg in oklab, var(--accent-softer), var(--bg-raised) 65%);
  border: 1px solid color-mix(in oklab, var(--accent) 26%, var(--stroke));
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card), 0 0 70px -32px color-mix(in oklab, var(--accent) 50%, transparent), inset 0 0 56px -36px color-mix(in oklab, var(--accent) 30%, transparent);
  overflow: hidden;
}
.project-hero::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg in oklab, var(--accent), color-mix(in oklab, var(--accent) 35%, transparent));
}

/* ---- Toast lifecycle: close button, timer progress, fade/blur out ---- */
.toast { position: relative; overflow: hidden; padding-right: var(--sp-3); transition: opacity 0.4s ease, filter 0.4s ease, transform 0.4s ease, height 0.45s ease 0.1s, padding 0.45s ease 0.1s, margin 0.45s ease 0.1s, border-color 0.45s ease 0.1s; }
.toast.toast-out { padding-top: 0; padding-bottom: 0; border-color: transparent; }
.toast .toast-text { min-width: 0; }
.toast .toast-close {
  margin-left: var(--sp-2);
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1);
  border-radius: var(--r-xs);
  flex: none;
}
.toast .toast-close:hover { color: var(--text-1); background: var(--bg-hover); }
.toast .toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg in oklab, var(--accent), var(--accent-hover));
  transform-origin: left;
  animation: toast-countdown linear forwards;
}
.toast.t-danger .toast-progress { background: linear-gradient(90deg in oklab, var(--danger), color-mix(in oklab, var(--danger) 70%, white)); }
.toast:hover .toast-progress { animation-play-state: paused; }
.toast.toast-out { opacity: 0; filter: blur(6px); transform: translateY(-6px); pointer-events: none; }

@keyframes toast-countdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.45s ease; }
  .toast.toast-out { filter: none; transform: none; }
}

/* ---- Global alerts strip ---- */
.alert-strip {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3) var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid color-mix(in oklab, var(--danger) 35%, transparent);
  border-radius: var(--r-md);
  background: var(--danger-soft);
  font-size: var(--fs-sm);
}
.alert-strip > .icon { color: var(--danger); flex: none; margin-top: 1px; }
/* Each alert claims its own line and wraps fully — error text (often a long
   URL/endpoint) must stay readable, never clamp. */
.alert-strip .al-item {
  flex: 1 1 100%;
  min-width: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.alert-strip .al-item b { font-weight: 700; }
.alert-strip .spacer { flex: 1; }
.alert-strip .btn { flex: none; }

/* ---- Email overlay ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background: rgba(2, 5, 9, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: overlay-in 0.18s ease;
}
.overlay[hidden] { display: none; }

@keyframes overlay-in {
  from { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .overlay { animation: none; }
}
.overlay-panel {
  width: min(1180px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
}
.overlay-panel .record-grid { gap: var(--sp-5); }
@media (max-width: 900px) { .overlay { padding: var(--sp-2); } }

/* Recipient suggestions inside the compose overlay */
.suggest-wrap { position: relative; display: block; }
.suggest-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--solid-raised);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.suggest-hit {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: none;
  background: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.suggest-hit:hover { background: var(--bg-hover); }
.suggest-hit .sg-name { font-weight: 600; }
.suggest-hit .sg-mail { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }

/* ---- Global header search ---- */
.global-search { position: relative; width: min(320px, 30vw); flex: none; }
.global-search .input { height: var(--control-h); }
.search-drop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  background: var(--solid-raised);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
.search-hit {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  text-decoration: none;
  color: var(--text-1);
}
.search-hit:hover { background: var(--bg-hover); }
.search-hit + .search-hit { border-top: 1px solid var(--stroke); }
.search-hit .sh-body { display: flex; flex-direction: column; min-width: 0; }
.search-hit .sh-title { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hit .sh-sub { font-size: 12px; color: var(--text-3); }
.search-hit.sh-all { justify-content: center; color: var(--accent); font-weight: 600; font-size: var(--fs-sm); }

/* ---- Brand glyphs inside system marks ---- */
.sm-logo { width: 13px; height: 13px; display: block; color: #fff; flex: none; }
.sys-mark.off .sm-logo { color: var(--text-3); }
.tr-node .sm-logo { width: 19px; height: 19px; }

/* Trace grouped by record type: a quiet sticky sub-header + count per group,
   so the related-records feed reads as typed sections, not one flat wall. */
.trace-group { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-4) 0 var(--sp-2); position: sticky; top: 0; background: var(--bg-base); padding: 4px 0; z-index: 1; }
.trace-group:first-of-type { margin-top: 0; }
.trace-group-label { font-size: var(--fs-sm); font-weight: 600; letter-spacing: var(--track-micro); text-transform: uppercase; color: var(--text-2); }

/* Linked-account marks rendered as anchors are unlink controls */
a.sys-mark { cursor: pointer; transition: box-shadow 0.12s ease, transform 0.12s ease; }
a.sys-mark:hover { transform: scale(1.1); box-shadow: 0 0 0 2px var(--danger-soft), 0 0 0 1px var(--danger); }

/* ---- Shared bits the PHP views need ---- */
.topbar .spacer { flex: 1; }
.user-group { display: flex; align-items: center; gap: var(--sp-2); }
.avatar-img { object-fit: cover; padding: 0; }
.notice-card { color: var(--text-2); }
.notice-card a { color: var(--accent); }
.hero-actions { display: flex; gap: var(--sp-3); flex: none; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.muted { color: var(--text-3); }
.row-note { margin: var(--sp-3) 0 0; font-size: var(--fs-sm); color: var(--text-3); }

/* AI usage chart hover tooltip — absolutely positioned over the SVG host. */
.usage-tip {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    min-width: 140px;
    padding: var(--sp-2) var(--sp-3);
    background: color-mix(in oklab, var(--bg-raised, #11151c) 80%, transparent);
    backdrop-filter: blur(10px) saturate(1.2);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    border: 1px solid var(--stroke-strong, rgba(255,255,255,0.16));
    border-radius: var(--r-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    font-size: var(--fs-sm);
    color: var(--text-1);
    line-height: 1.5;
}
#usage-chart svg { touch-action: none; cursor: crosshair; }

/* ---- Risk / unforeseen-condition ledger ---------------------------------- */
.risk-stats { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: var(--fs-sm); color: var(--text-3); margin-bottom: var(--sp-3); }
.risk-stats b { color: var(--text-1); }
.risk-stats-flag { color: var(--warning); }
.risk-proposed { border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--stroke)); background: color-mix(in oklab, var(--accent) 6%, transparent); border-radius: var(--r-md); padding: var(--sp-3); margin-bottom: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.risk-proposed-head { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.risk-list { display: flex; flex-direction: column; }
.risk-entry { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--stroke); }
.risk-list .risk-entry:first-child { border-top: none; }
.risk-entry--proposed { border: none; padding: var(--sp-2) 0; }
.risk-entry--proposed + .risk-entry--proposed { border-top: 1px solid color-mix(in oklab, var(--accent) 18%, var(--stroke)); }
.risk-entry-main { flex: 1; min-width: 0; }
.risk-entry-top { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.risk-title { font-weight: 600; color: var(--text-1); }
.risk-kind { font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-3); }
.risk-kind--risk { color: var(--warning); }
.risk-kind--opportunity { color: var(--success); }
.risk-kind--unforeseen { color: var(--accent); }
.risk-sev { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--stroke-strong); color: var(--text-2); }
.risk-sev--high { color: var(--warning); border-color: color-mix(in oklab, var(--warning) 45%, var(--stroke)); }
.risk-sev--critical { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 45%, var(--stroke)); }
.risk-impact { font-size: 11.5px; font-family: var(--font-mono); color: var(--text-2); }
.risk-entry-sub { margin-top: 3px; font-size: var(--fs-sm); color: var(--text-3); display: flex; flex-direction: column; gap: 2px; }
.risk-entry-sub b { color: var(--text-2); font-weight: 600; }
.risk-entry-actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.risk-status-form .select { height: 30px; font-size: 12px; padding: 0 26px 0 10px; }
.risk-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--stroke); border-radius: var(--r-md); background: var(--bg-inset); }
.risk-form-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; font-weight: 700; color: var(--text-1); }
.risk-field { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-2); min-width: 0; }
.risk-field--wide { grid-column: 1 / -1; }
.risk-field > span { font-size: 12px; color: var(--text-3); }
.risk-form-actions { grid-column: 1 / -1; }
@media (max-width: 640px) { .risk-form { grid-template-columns: 1fr; } .risk-entry { flex-direction: column; } .risk-entry-actions { flex-wrap: wrap; } }

/* ---- Domain model (Phase 3): reuses .risk-* structure + these ------------- */
.dm-group-head { display: flex; align-items: center; gap: var(--sp-2); font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-3); margin: var(--sp-4) 0 var(--sp-1); }
.dm-disp { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--stroke-strong); color: var(--text-2); }
.dm-disp--included, .dm-disp--holding { color: var(--success); border-color: color-mix(in oklab, var(--success) 45%, var(--stroke)); }
.dm-disp--excluded, .dm-disp--broken { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 45%, var(--stroke)); }
.dm-disp--unclear, .dm-disp--at_risk { color: var(--warning); border-color: color-mix(in oklab, var(--warning) 45%, var(--stroke)); }

/* ---- Agent skills (Admin > AI) ------------------------------------------- */
.skill-list { display: flex; flex-direction: column; }
.skill-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--stroke); flex-wrap: wrap; }
.skill-list .skill-row:first-child { border-top: none; }
.skill-row.dragging { opacity: 0.45; }
.skill-drag { flex: none; cursor: grab; color: var(--text-3); font-size: 15px; line-height: 1; letter-spacing: -3px; padding: 2px; user-select: none; }
.skill-drag:active { cursor: grabbing; }
.skill-reorder { display: flex; flex-direction: column; gap: 2px; flex: none; }
.skill-reorder .btn { padding: 1px 8px; min-height: 0; line-height: 1.2; font-size: 12px; color: var(--text-3); }
.skill-reorder .btn:disabled { opacity: 0.3; }
/* The shared .input/.select default to width:100%, which stacked the row — pin
   them to content/flex so name + target + controls sit on a single line. */
.skill-meta { display: flex; align-items: center; gap: var(--sp-2); flex: 1; min-width: 0; margin: 0; }
.skill-meta .input, .skill-meta .select { width: auto; height: 34px; }
.skill-name { flex: 2; min-width: 240px; font-weight: 600; }
.skill-meta .select { flex: none; min-width: 150px; }
.skill-enabled { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; flex: none; }
.skill-row > form[action*="ai-skill-delete"] { flex: none; margin: 0; }
.skill-preview { flex-basis: 100%; margin: 0 0 0 36px; }
.skill-preview > summary { font-size: 12px; color: var(--text-3); cursor: pointer; padding: 2px 0; }
.skill-pre { white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; background: var(--bg-inset); border: 1px solid var(--stroke); border-radius: var(--r-sm); padding: var(--sp-3); font-size: 12px; font-family: var(--font-mono); color: var(--text-2); margin: var(--sp-2) 0 0; }
@media (max-width: 720px) { .skill-name { min-width: 100%; } }

/* ---- Imported Accubid estimates (admin management list) ---- */
.est-list { display: flex; flex-direction: column; margin-bottom: var(--sp-3); }
.est-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--stroke); flex-wrap: wrap; }
.est-list .est-row:first-child { border-top: none; }
.est-row.dragging { opacity: 0.45; }
.est-drag { flex: none; cursor: grab; color: var(--text-3); font-size: 15px; line-height: 1; letter-spacing: -3px; padding: 2px; user-select: none; }
.est-drag:active { cursor: grabbing; }
/* AI live rate-limit (capacity) strip — reused on the AI usage page, the
   project Ask card, and the admin AI panel. */
.ai-rate-strip { display: flex; flex-direction: column; gap: var(--sp-1); }
.ai-rate-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* Capacity shown as a meta footer under the AI-usage totals: a quiet top-ruled
   row with the pills laid out horizontally rather than its own card. */
.usage-capacity-meta { display: flex; align-items: center; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--stroke); }
.usage-capacity-meta .ai-rate-strip { flex-direction: row; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }

.est-dropzone { border: 1px dashed transparent; border-radius: var(--radius-2); padding: var(--sp-2); margin: 0 calc(-1 * var(--sp-2)) var(--sp-2); transition: border-color .15s, background .15s; }
.est-dropzone.is-dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.est-drop-hint { flex: none; }

/* Sticky project command bar: minified project identity + the section spine +
   a quick-ask, anchored to the viewport top once the (non-sticky) topbar
   scrolls away. The spine is the scroll-spy rail built from [data-spine]
   sections (see _layout.php). */
.proj-bar {
  position: sticky;
  top: var(--sp-2);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-2);
  padding: var(--sp-3);
  margin: 0 0 var(--sp-5);
  background:
    radial-gradient(circle at 0 0, color-mix(in oklab, var(--accent) 22%, transparent), transparent 34%),
    color-mix(in oklab, var(--solid-raised) 88%, transparent);
  border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--stroke));
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--glass-blur));
}
.pb-kicker, .pb-chips, .pb-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pb-title-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); }
.pb-title { margin: 0; font-size: var(--fs-h3); line-height: 1.25; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-meta-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); }
.pb-ask { display: grid; grid-template-columns: minmax(220px, 320px) auto; align-items: center; gap: var(--sp-2); margin: 0; }
.pb-ask .input { width: 100%; height: var(--control-h-sm); background: var(--bg-inset); }
/* Row 2: the section spine, one controlled rail instead of loose wrapping. */
.page-spine {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding: var(--sp-1);
  background: var(--bg-inset);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  scrollbar-width: thin;
}
.page-spine a {
  font-size: var(--fs-sm);
  color: var(--text-2);
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.page-spine a:hover { color: var(--text-1); background: var(--bg-hover); }
.page-spine a.active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
/* Anchor offset so a clicked/spied section isn't hidden under the sticky bar.
   --spine-offset is set to the bar's measured height by the spine script. */
[data-spine] { scroll-margin-top: var(--spine-offset, 128px); }
@media (max-width: 860px) {
  .pb-title-row,
  .pb-meta-row { grid-template-columns: 1fr; }
  .pb-title { white-space: normal; }
  .pb-ask { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (prefers-reduced-motion: reduce) { .page-spine a { transition: none; } }

/* Page hierarchy tiers (project page). The squint test should resolve a clear
   primary, a body of secondary sections, and quiet reference at the bottom —
   built from elevation, size, and weight, not decorative accents. */
.card.tier-primary { box-shadow: var(--shadow-pop); border-color: var(--stroke-strong); }
.card.tier-primary > .card-head { margin-bottom: var(--sp-4); }
/* Reference/utility sections recede: flat (no raised glass or shadow), muted
   heading, so the intelligence above them reads as primary. */
.tier-ref { background: transparent; box-shadow: none; }
.tier-ref .card-title { color: var(--text-2); font-weight: 600; }
.sys-panels.tier-ref > .card { background: transparent; box-shadow: none; }
/* Fixed width (not flex:1) so the name input is identical across rows
   regardless of each row's meta/actions length. */
.est-rename { display: flex; align-items: center; gap: var(--sp-2); flex: none; width: 440px; max-width: 100%; margin: 0; }
.est-rename .est-name { flex: 1; min-width: 0; height: 34px; font-weight: 600; }
.est-meta { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; }
.est-actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; margin-left: auto; }
.est-reimport { position: relative; }
.est-reimport > summary { list-style: none; cursor: pointer; }
.est-reimport > summary::-webkit-details-marker { display: none; }
.est-reimport-form { position: absolute; right: 0; top: calc(100% + var(--sp-1)); z-index: 30; width: max(300px, 100%); display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3); background: var(--bg-base); border: 1px solid var(--stroke); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.est-reimport-form .hint { flex-basis: 100%; margin: 0; }
@media (max-width: 720px) { .est-rename { width: 100%; } .est-actions { margin-left: 0; } .est-reimport-form { position: static; width: 100%; } }

/* ---- AI usage — Conversations (chat sessions) ---- */
.conv-list { display: flex; flex-direction: column; }
.conv-row { border-top: 1px solid var(--stroke); }
.conv-list .conv-row:first-child { border-top: none; }
.conv-row > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; }
.conv-row > summary::-webkit-details-marker { display: none; }
.conv-main { flex: 1; min-width: 0; font-weight: 600; }
.conv-who { font-weight: 400; color: var(--text-3); }
.conv-meta { font-size: var(--fs-sm); white-space: nowrap; }
.conv-turns { padding: 0 0 var(--sp-3) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.conv-turn { border-left: 2px solid var(--stroke-strong); padding-left: var(--sp-3); }
.conv-q { font-weight: 600; color: var(--text-1); text-decoration: none; }
.conv-q:hover { color: var(--accent); }
.conv-a { font-size: var(--fs-sm); margin-top: 2px; line-height: 1.5; }
/* Ledger project cell: truncate so a long (often all-caps) name can't dominate
   the row; full name stays available via the title attribute. */
.led-proj { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* ---- Admin activity log — dated timeline ---- */
.log-day td { position: sticky; top: 0; z-index: 1; background: var(--bg-base); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--stroke); }
.log-day-label { font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); margin-right: var(--sp-2); }
.log-day-err { font-size: 11.5px; color: var(--danger); margin-left: var(--sp-2); }
.log-detail details > summary { list-style: none; cursor: pointer; font-size: 11.5px; color: var(--text-3); overflow-wrap: anywhere; }
.log-detail details > summary::-webkit-details-marker { display: none; }
.log-detail details[open] > summary { color: var(--text-2); }
.log-detail pre { margin: var(--sp-1) 0 0; font-size: 11px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- Admin section headers + sub-tab jump-list ---- */
/* Group headings inside a card read as real section dividers, not like a
   setting label: a rule above, more air, and an accent tick on the title. */
.sec-head { margin: var(--sp-5) 0 var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--stroke); align-items: center; gap: var(--sp-2); }
.sec-title { display: flex; align-items: center; gap: 9px; font-size: var(--fs-h3); font-weight: 700; letter-spacing: -0.01em; color: var(--text-1); }
.sec-title::before { content: ""; flex: none; width: 4px; height: 1.05em; border-radius: 2px; background: var(--stroke-strong); }
.admin-subnav { display: flex; flex-direction: column; gap: 1px; margin: 3px 0 var(--sp-2) var(--sp-5); }
.admin-subnav a { color: var(--text-3); text-decoration: none; font-size: var(--fs-sm); padding: 3px var(--sp-2); border-left: 1.5px solid var(--stroke); border-radius: 0 var(--r-xs) var(--r-xs) 0; }
.admin-subnav a:hover { color: var(--text-1); background: var(--bg-hover); border-left-color: var(--accent); }
/* Sub-section heading (one level under a .sec-title): smaller, lighter, a
   muted tick, indented — so a group like "AI runtime" reads as nested under
   its section ("AI & voice configuration"), not as a peer. */
.subsec-head { margin: var(--sp-4) 0 var(--sp-2); padding-top: 0; border-top: 0; align-items: center; gap: var(--sp-2); }
.subsec-title { display: flex; align-items: center; gap: 8px; margin-left: var(--sp-3); font-size: var(--fs-body); font-weight: 600; letter-spacing: 0; color: var(--text-2); }
.subsec-title::before { content: ""; flex: none; width: 3px; height: 0.85em; border-radius: 2px; background: var(--stroke); }
/* Nested jump-list items sit indented under their parent section link. */
.admin-subnav a.is-sub { margin-left: var(--sp-4); font-size: var(--fs-sm); color: var(--text-3); }

/* ---- Combobox (free-text input + full-list panel) ---- */
/* Replaces the native datalist so clicking the field shows the whole list
   (the native one filters by the current value). Typing still filters; any
   typed value is accepted. */
/* The wrapper takes the field's footprint (matching .set-input); the input
   fills it, so the visible box spans the full control width and the caret sits
   at its right edge. */
.combo { position: relative; display: inline-block; flex: none; width: 340px; max-width: 46%; }
#ai .field > .combo { width: 100%; max-width: none; }
.combo .set-input { width: 100%; max-width: none; padding-right: 28px; }
@media (max-width: 640px) { .combo { width: 100%; max-width: none; } }
/* Same downward chevron as .select (identical inline SVG), not a text glyph,
   so the model comboboxes match the Reasoning effort / Lens dropdowns. */
.combo-caret { position: absolute; right: 4px; top: 0; height: 100%; width: 22px; border: 0; cursor: pointer; font-size: 0; background-color: transparent; background-repeat: no-repeat; background-position: right 8px center; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23808a96' stroke-width='2' stroke-linecap='round' d='M1.5 1.5L6 6l4.5-4.5'/></svg>"); }
.combo-panel { position: absolute; z-index: 40; left: 0; top: calc(100% + 4px); width: 100%; max-height: 260px; overflow-y: auto; padding: 4px; background: var(--bg-base); border: 1px solid var(--stroke); border-radius: var(--r-md); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 1px; }
.combo-opt { display: block; width: 100%; text-align: left; padding: 6px 10px; background: none; border: 0; border-radius: var(--r-xs); color: var(--text-1); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.combo-opt:hover { background: var(--bg-hover); }
.combo-opt.on .combo-opt-name { color: var(--accent); }
.combo-opt-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt-desc { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; white-space: normal; line-height: 1.35; }

/* Models & reasoning row: top-aligned so every dropdown sits at the same Y no
   matter the label length or what hangs below it — the model fields carry a
   live-limit pill + price caption under their input, the selects don't. Equal
   label height (≈2 lines) does the aligning; the extras flow below in-flow, so
   a wrapped row never overlaps anything. */
.ai-models-row .field > label { min-height: 2.8em; line-height: 1.35; }
.ai-models-row .ai-field-rate { font-size: var(--fs-sm); line-height: 1.3; }

/* ---- Voice + printed-deck conversation surface (voice.js) ---- */
.vx-bar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.vx-mic[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent-soft); }
.vx-meter { display: inline-flex; align-items: center; width: 90px; height: 8px; border-radius: var(--r-pill); background: var(--bg-inset); overflow: hidden; flex: none; box-shadow: inset 0 1px 0 rgba(0,0,0,0.25); }
/* scaleX (not width) so the per-audio-frame level updates don't thrash layout. */
.vx-meter > i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; border-radius: inherit; background: linear-gradient(90deg in oklab, var(--accent), color-mix(in oklab, var(--accent) 55%, white)); transition: transform 0.06s linear; }
.vx-state, .vx-transcript { font-size: var(--fs-sm); }
.vx-transcript { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vx-deck { margin-top: var(--sp-3); border: 1px solid var(--stroke); border-radius: var(--r-md); background: var(--bg-inset); padding: var(--sp-3); }
.vx-deck-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.vx-count { font-size: var(--fs-sm); white-space: nowrap; }
.vx-dots { display: inline-flex; gap: 4px; }
.vx-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--stroke-strong); cursor: pointer; }
.vx-dot.on { background: var(--accent); }
.vx-card { background: var(--bg-raised); border: 1px solid var(--stroke); border-radius: var(--r-md); padding: var(--sp-3); }
.vx-card.pinned { border-color: color-mix(in oklab, var(--accent) 50%, var(--stroke)); }
.vx-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.vx-q { font-weight: 600; }
.vx-cites { font-size: 12px; margin-top: var(--sp-2); }
.vx-card-foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap; }
.vx-cost { margin-left: auto; font-family: var(--font-mono); font-size: 12px; }
.vx-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (max-width: 720px) { .vx-compare-grid { grid-template-columns: 1fr; } }
/* File inputs styled as .input: the native button/text top-align, and flex
   doesn't reliably center a file input's internals — so drop the fixed height
   and use equal vertical padding so the content is centred by construction.
   Theme the button to match the dark UI. */
input[type="file"].input { display: flex; align-items: center; height: auto; padding: var(--sp-2) var(--sp-3); }
input[type="file"].input::file-selector-button { margin-right: var(--sp-3); border: 1px solid var(--stroke-strong); background: var(--solid-raised); color: var(--text-1); border-radius: var(--r-sm); padding: 5px 12px; cursor: pointer; font: inherit; font-size: var(--fs-sm); }
input[type="file"].input::file-selector-button:hover { border-color: var(--accent); }
