/* U9 -- shared component primitives.
 *
 * Every page consumes these via class names + the design tokens
 * defined in /static/shell/shell.css. Adding a new primitive here +
 * documenting it in the table below is preferred over hand-rolling
 * per-page styles.
 *
 *   .btn .btn-primary .btn-ghost .btn-danger .btn-icon
 *   .card .card-header .card-body .card-footer
 *   .tabs .tab .tab.is-active
 *   .data-table
 *   .badge .badge-info .badge-success .badge-warning .badge-danger .badge-neutral
 *   .kpi-grid .kpi
 *   .skeleton
 *   .empty-state
 *   .pill .pill-mono
 *   .form-field
 */

/* ---------------------------------------------------------------- */
/* Buttons                                                           */
/* ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-13);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--motion-fast) var(--motion-ease-out),
    border-color var(--motion-fast) var(--motion-ease-out),
    color var(--motion-fast) var(--motion-ease-out),
    box-shadow var(--motion-fast) var(--motion-ease-out),
    transform var(--motion-fast) var(--motion-ease-out);
  position: relative;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-lg { height: 44px; padding: 0 var(--sp-5); font-size: var(--fs-md); }

.btn-primary {
  background: var(--brand);
  color: var(--brand-fg);
  border-color: var(--brand);
  box-shadow: var(--elev-1);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-fg); }

.btn-ghost {
  background: transparent;
  color: var(--fg-default);
  border-color: var(--border-medium);
}
.btn-ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-soft {
  background: var(--bg-sunken);
  color: var(--fg-default);
  border-color: var(--border-light);
}
.btn-soft:hover { background: var(--bg-hover); border-color: var(--border-medium); }

.btn-danger {
  background: var(--danger);
  color: var(--fg-inverse);
  border-color: var(--danger);
}
.btn-danger:hover {
  filter: brightness(0.92);
  color: var(--fg-inverse);
}

.btn-icon {
  width: 36px;
  padding: 0;
  background: transparent;
  color: var(--fg-muted);
  border-color: transparent;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--fg-default); }
.btn-icon.btn-sm { width: 28px; }

/* ---------------------------------------------------------------- */
/* Cards                                                             */
/* ---------------------------------------------------------------- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-1);
  overflow: hidden;
  transition: box-shadow var(--motion-fast) var(--motion-ease-out);
}
.card:hover { box-shadow: var(--elev-2); }
.card-flat:hover { box-shadow: var(--elev-1); }

.card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
}
.card-header h2,
.card-header h3 { margin: 0; flex: 1; }
.card-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.card-body {
  padding: var(--sp-4);
}
.card-body-flush { padding: 0; }
.card-body-tight { padding: var(--sp-3); }

.card-footer {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-sunken);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------- */
/* Tabs                                                              */
/* ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border-light);
  padding: 0 var(--sp-1);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-size: var(--fs-13);
  font-weight: 500;
  cursor: pointer;
  transition:
    color var(--motion-fast) var(--motion-ease-out),
    border-color var(--motion-fast) var(--motion-ease-out);
  margin-bottom: -1px;
}
.tab:hover { color: var(--fg-default); }
.tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--sp-2);
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-muted);
}

/* ---------------------------------------------------------------- */
/* Data table                                                        */
/* ---------------------------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: separate;   /* separate + spacing 0 keeps the collapsed look but allows rounded corners */
  border-spacing: 0;
  font-size: var(--fs-13);
}
/* Rounded outer corners so every table matches the rounded panes it sits in. */
.data-table thead th:first-child { border-top-left-radius: var(--r-md); }
.data-table thead th:last-child  { border-top-right-radius: var(--r-md); }
.data-table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-md); }
.data-table tbody tr:last-child td:last-child  { border-bottom-right-radius: var(--r-md); }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-sunken);
  color: var(--fg-muted);
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-light);
}
.data-table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background var(--motion-fast) var(--motion-ease-out);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.is-selected { background: var(--brand-soft); }
.data-table td.numeric,
.data-table th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.actions,
.data-table th.actions { text-align: right; width: 1%; white-space: nowrap; }

.data-table.is-dense thead th { padding: var(--sp-2) var(--sp-3); }
.data-table.is-dense tbody td { padding: var(--sp-2) var(--sp-3); }

/* ---------------------------------------------------------------- */
/* Badges                                                            */
/* ---------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--bg-sunken);
  color: var(--fg-muted);
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-neutral { background: var(--bg-sunken);    color: var(--fg-muted); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand); }

.badge-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: var(--sp-1);
}

/* ---------------------------------------------------------------- */
/* KPI                                                               */
/* ---------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
}
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--elev-1);
  transition: box-shadow var(--motion-fast) var(--motion-ease-out);
}
.kpi:hover { box-shadow: var(--elev-2); }
.kpi-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kpi-value {
  margin-top: var(--sp-2);
  font-size: var(--fs-3xl);
  font-weight: 600;
  color: var(--fg-strong);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-delta {
  margin-top: var(--sp-2);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-muted);
}
.kpi-delta.is-up    { color: var(--success); }
.kpi-delta.is-down  { color: var(--danger); }
.kpi-spark {
  margin-top: var(--sp-2);
  height: 28px;
}

/* ---------------------------------------------------------------- */
/* Skeleton (loading shimmer)                                        */
/* ---------------------------------------------------------------- */

/* U40: the shimmer animation is gone. Skeletons now render as
 * a static muted block so the page lays out without a yellow box
 * hopping in place. Prefer `<div class="bf-loading">Loading...</div>`
 * (bf.loading.mount) over `<div class="skeleton-block">` for new
 * markup; the .skeleton class shape is preserved here so existing
 * markup still reserves space. */
.skeleton {
  display: inline-block;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  vertical-align: middle;
  color: transparent;
  pointer-events: none;
}
.skeleton-line { width: 100%; height: 14px; margin-bottom: var(--sp-2); }
.skeleton-line:last-child { margin-bottom: 0; width: 70%; }
.skeleton-block { width: 100%; height: 120px; border-radius: var(--r-md); }

/* ---------------------------------------------------------------- */
/* Empty + error states                                              */
/* ---------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: var(--sp-7) var(--sp-5);
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--r-lg);
  color: var(--fg-muted);
}
.empty-state-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--sp-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
  color: var(--fg-faint);
}
.empty-state-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--fg-default);
  margin-bottom: var(--sp-2);
}
.empty-state-actions {
  margin-top: var(--sp-4);
  display: inline-flex;
  gap: var(--sp-2);
}

.error-banner {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--r-md);
  font-size: var(--fs-13);
}
.error-banner-title { font-weight: 600; }

/* ---------------------------------------------------------------- */
/* Form fields                                                       */
/* ---------------------------------------------------------------- */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.form-field-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-field-help {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="search"],
.form-field input[type="url"],
.form-field input[type="datetime-local"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field textarea,
.form-field select,
.text-input {
  font: inherit;
  font-size: var(--fs-13);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  color: var(--fg-default);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  min-height: 36px;
  transition: border-color var(--motion-fast) var(--motion-ease-out);
}
.form-field input:hover,
.form-field textarea:hover,
.form-field select:hover { border-color: var(--border-strong); }
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-field textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  line-height: var(--lh-snug);
}

/* Invalid + disabled states so every input reads its status without a
 * tooltip (BUG-F0-86: calm hover / focus / invalid / disabled). */
.form-field input[aria-invalid="true"],
.form-field textarea[aria-invalid="true"],
.form-field select[aria-invalid="true"],
.text-input[aria-invalid="true"] {
  border-color: var(--danger);
}
.form-field input[aria-invalid="true"]:focus,
.form-field textarea[aria-invalid="true"]:focus,
.form-field select[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.form-field input:disabled,
.form-field textarea:disabled,
.form-field select:disabled,
.text-input:disabled,
.form-field input[readonly],
.text-input[readonly] {
  background: var(--bg-sunken);
  color: var(--fg-muted);
  cursor: not-allowed;
  border-color: var(--border-light);
}
.form-field input::placeholder,
.form-field textarea::placeholder,
.text-input::placeholder {
  color: var(--fg-faint);
}

/* ---------------------------------------------------------------- */
/* Pills (small inline tag chips)                                    */
/* ---------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  background: var(--bg-sunken);
  border: 1px solid var(--border-light);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}
.pill-mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------------- */
/* Modal scaffold                                                    */
/* ---------------------------------------------------------------- */

.bf-modal-scrim {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: var(--sp-5);
  backdrop-filter: saturate(120%) blur(4px);
  -webkit-backdrop-filter: saturate(120%) blur(4px);
  animation: bf-fade-in var(--motion-fast) var(--motion-ease-out);
}
.bf-modal-scrim[hidden] { display: none; }
.bf-modal-card {
  background: var(--bg-surface);
  color: var(--fg-default);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--elev-4);
  max-width: 880px;
  width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  animation: bf-modal-in var(--motion-med) var(--motion-ease-out);
}
@keyframes bf-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes bf-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------------------------------------------------------- */
/* U18 polish primitives                                             */
/* ---------------------------------------------------------------- */

/* CSS-only error state (mirrors bf.errorState() output) so a server-
 * rendered fallback or a unit-test mount still shows the right shape
 * without booting JS. */
.bf-error-state {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--r-lg);
  color: var(--fg-default);
}
.bf-error-state[hidden] { display: none; }
.bf-error-state-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: var(--fg-inverse);
  border-radius: var(--r-pill);
  font-weight: 700;
}
.bf-error-state-main { flex: 1; min-width: 0; }
.bf-error-state-title {
  font-weight: 600;
  margin: 0;
  color: var(--danger);
}
.bf-error-state-message {
  margin: var(--sp-1) 0 0;
  color: var(--fg-default);
  font-size: var(--fs-13);
  overflow-wrap: anywhere;
}
.bf-error-state-actions {
  margin-top: var(--sp-3);
  display: flex;
  gap: var(--sp-2);
}

/* Pulse-on-update: any element that gets the class flashes the
 * --pulse-bg colour briefly. JS adds the class then removes it after
 * the animation; reduced-motion users get the underline only. */
@keyframes bf-pulse-update {
  0%   { background-color: var(--pulse-bg); box-shadow: 0 0 0 0 var(--pulse-bg); }
  60%  { background-color: var(--pulse-bg); box-shadow: 0 0 0 6px rgba(0,0,0,0); }
  100% { background-color: transparent; box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
.pulse-on-update {
  animation: bf-pulse-update 600ms var(--motion-ease-out);
  border-radius: var(--r-sm);
}
@media (prefers-reduced-motion: reduce) {
  .pulse-on-update {
    animation: none;
    text-decoration: underline 2px var(--brand);
    text-underline-offset: 4px;
  }
}

/* Count-up uses tabular numerals so the width doesn't dance as the
 * digits change. */
.count-up {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* WebSocket connection indicator. Static colors only; the
 * U40 wsStatus state machine in _widgets/ws_status.js owns the
 * 5s/30s debounce that decides when the dot flips warn / down.
 * The continuous `bf-ws-pulse` animation that previously ran on
 * data-ws="warn" was the source of the flicker on noisy networks
 * and was removed in U40. The brief `bf-ws-ping` keyframe stays
 * for the per-message ping affordance (one shot, ~400 ms). */
.bf-ws-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--fg-faint);
  box-shadow: 0 0 0 0 transparent;
  transition: background var(--motion-fast) var(--motion-ease-out);
  flex-shrink: 0;
}
.bf-ws-dot[data-ws="ok"]      { background: var(--success); }
.bf-ws-dot[data-ws="warn"]    { background: var(--warning); }
.bf-ws-dot[data-ws="down"]    { background: var(--danger); }
.bf-ws-dot.is-pinging {
  animation: bf-ws-ping 400ms var(--motion-ease-out);
}
@keyframes bf-ws-ping {
  0%   { box-shadow: 0 0 0 0 var(--success); }
  100% { box-shadow: 0 0 0 8px rgba(0,0,0,0); }
}
@media (prefers-reduced-motion: reduce) {
  .bf-ws-dot.is-pinging { animation: none; }
}

/* Relative-time pill (auto-updated by bf.live.relativeTime). The
 * data-iso attr carries the source timestamp; the text content is
 * what the operator sees ("5 s ago"). */
.bf-rel-time {
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

/* Page-header polish helpers (consumed by the swept pages). */
.page-header-search {
  flex: 0 1 320px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.page-header-status {
  color: var(--fg-muted);
  font-size: var(--fs-13);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.page-header-status .bf-rel-time { font-size: inherit; }

/* Skeleton scaffolds dedicated to table rows (drop into a tbody). */
.skeleton-row td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
}
.skeleton-row .skeleton-line { display: block; height: 12px; width: 80%; }


/* ================================================================ */
/* BSP-1000 additions — kill loud solids, semantic status dot       */
/* (appended to the lifted bs-fe primitives above)                  */
/* ================================================================ */

/* Semantic status dot — replaces ● / ✅ emoji + loud solid pills. */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-faint);
  flex-shrink: 0;
}
.status-dot.is-ok     { background: var(--success); }
.status-dot.is-warn   { background: var(--warning); }
.status-dot.is-danger { background: var(--danger); }
.status-dot.is-info   { background: var(--info); }
.status-dot.is-muted  { background: var(--fg-faint); }

/* Legacy badge classes emitted by webapp.py HTMX fragments + page
 * markup. Recolour at the source so the loud solid #22c55e / #fbbf24
 * die without editing every f-string. Soft semantic look, both themes. */
.status-badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase;
  border: 1px solid transparent; white-space: nowrap;
  line-height: 1.5;
}
.status-badge.bg-active,
.status-badge.bg-success     { background: var(--success-soft); color: var(--success); }
.status-badge.bg-stale,
.status-badge.bg-warning     { background: var(--warning-soft); color: var(--warning); }
.status-badge.bg-expired,
.status-badge.bg-danger,
.status-badge.bg-unreachable { background: var(--danger-soft);  color: var(--danger); }
.status-badge.bg-info        { background: var(--info-soft);    color: var(--info); }
.status-badge.bg-secondary,
.status-badge.bg-dark        { background: var(--bg-sunken);    color: var(--fg-muted); border-color: var(--border-light); }

/* Bootstrap badge utilities used across pages — same soft recolour. */
.badge.bg-success   { background: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-danger    { background: var(--danger-soft)  !important; color: var(--danger)  !important; }
.badge.bg-warning   { background: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-info      { background: var(--info-soft)    !important; color: var(--info)    !important; }
.badge.bg-secondary { background: var(--bg-sunken)    !important; color: var(--fg-muted) !important; }
.badge.bg-dark      { background: var(--bg-page)      !important; color: var(--fg-muted) !important; }

/* Inline SVG icon sizing (icons.js / icon() macro output). */
.bsp-ico { display: inline-flex; vertical-align: -0.125em; flex-shrink: 0; }
.bsp-ico svg { width: 1em; height: 1em; stroke: currentColor; }

/* ---- Page header (consumed by the page_header() macro) ------------- */
.page-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.page-header .page-title {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  color: var(--fg-strong);
}
.page-header .page-subtitle { color: var(--fg-muted); font-size: var(--fs-13); }
.page-header .page-header-actions { margin-left: auto; display: inline-flex; gap: var(--sp-2); align-items: center; }

/* Generic page content padding for non-gridstack pages. */
.page-pad { padding: var(--sp-5) var(--sp-6) var(--sp-7); }

/* ---- Command palette (Cmd/Ctrl-K) --------------------------------- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 9500;
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
  background: var(--bg-overlay);
  backdrop-filter: saturate(120%) blur(4px);
  -webkit-backdrop-filter: saturate(120%) blur(4px);
  animation: bf-fade-in var(--motion-fast) var(--motion-ease-out);
}
.cmdk-overlay.open { display: flex; }
.cmdk {
  width: min(560px, calc(100vw - 32px));
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--elev-5);
  overflow: hidden;
  animation: bf-modal-in var(--motion-med) var(--motion-ease-out);
}
.cmdk-search {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  color: var(--fg-muted);
}
.cmdk-search-ico { display: inline-flex; color: var(--fg-muted); }
.cmdk-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--fg-default); font-size: var(--fs-lg); font-family: inherit;
}
.cmdk-input::placeholder { color: var(--fg-faint); }
.cmdk-list { max-height: 320px; overflow-y: auto; padding: var(--sp-2); }
.cmdk-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--fg-default); font-size: var(--fs-md); cursor: pointer;
}
.cmdk-item .cmdk-ico { color: var(--fg-muted); display: inline-flex; }
.cmdk-item.is-active { background: var(--brand-soft); color: var(--brand); }
.cmdk-item.is-active .cmdk-ico { color: var(--brand); }
.cmdk-empty { padding: var(--sp-5); text-align: center; color: var(--fg-muted); }
.cmdk-foot {
  display: flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border-light);
  color: var(--fg-faint); font-size: var(--fs-xs);
}
.cmdk-foot kbd {
  background: var(--bg-sunken); border: 1px solid var(--border-light);
  border-radius: var(--r-sm); padding: 0 5px; font-family: var(--font-mono); font-size: 10px;
}

/* Topbar search trigger that opens the palette. */
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 32px; padding: 0 var(--sp-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--fg-muted); font-size: var(--fs-13); cursor: pointer;
  transition: border-color var(--motion-fast) var(--motion-ease-out), color var(--motion-fast) var(--motion-ease-out);
}
.cmdk-trigger:hover { border-color: var(--border-strong); color: var(--fg-default); }
.cmdk-trigger kbd {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: var(--r-sm); padding: 0 5px; font-family: var(--font-mono);
  font-size: 10px; color: var(--fg-muted);
}
/* Tight "Ctrl K" pairing (the parent flex gap separates it from the label) */
.cmdk-trigger-keys { display: inline-flex; align-items: center; gap: 3px; }
@media (max-width: 860px) { .cmdk-trigger .cmdk-trigger-label, .cmdk-trigger-keys { display: none; } }
.cmdk-group {
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-faint);
}
