/* ==========================================================================
   HunterViz app styles: the base, the component kit and the app shell.

   Every color, size, radius and shadow comes from tokens.css, which loads
   first; nothing here names a raw color but white on the sidebar and the
   blue fills. The kit's markup lives in app/core/templates/_kit.html (Jinja
   macros) and its behavior in static/assets/hv-ui.js; the dev-only style
   guide (/app/style-guide) shows every piece. See docs/STYLE_GUIDE.md.

   The look is the hub's original one, restored on 2026-10-22: white and
   light blue, bright blue primary buttons, the dark slate sidebar with the
   current page in blue, DM Sans with tight bold titles. Labels are upright
   and in sentence case (the kit's, plan 4.2).
   ========================================================================== */

/* --- Reset and base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { margin: 0 0 0.5em; font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: var(--lh-tight); color: var(--text); }
h1 { font-size: var(--fs-display); letter-spacing: -0.035em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -0.03em; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
a { color: var(--link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img, svg { vertical-align: middle; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }
code, kbd { font-family: var(--font-mono); font-size: 0.85em; }
::selection { background: var(--accent-tint); }

/* --- Layout helpers ------------------------------------------------------ */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.5rem; }
.container-narrow { max-width: 760px; }
.stack > * + * { margin-top: var(--stack-gap, 1rem); }
.row { display: flex; align-items: center; gap: var(--row-gap, 0.75rem); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.eyebrow { font-size: var(--fs-sm); font-weight: var(--fw-semibold); letter-spacing: 0.01em; color: var(--accent); }
.lead { font-size: 1.15rem; color: var(--text-muted); line-height: 1.6; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   The component kit
   ========================================================================== */

/* --- Buttons --------------------------------------------------------------
   .btn + one look: -primary (the action, the blue gradient), -secondary,
   -ghost, -danger and -danger-ghost (red: destructive actions only), -white
   (on a blue or dark band). Sizes: -sm, -lg; -block fills the row; -icon is
   a square icon button, -round a round one. */
/* The hidden attribute hides a button too: .btn's display would otherwise win over the browser's own rule. */
.btn[hidden] { display: none !important; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: inherit; font-size: 0.9375rem; font-weight: var(--fw-semibold); line-height: 1;
  text-transform: none;
  padding: 0.7rem 1.15rem; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition), filter var(--transition);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 1.05em; height: 1.05em; }
.btn-primary { background: var(--action); background: var(--action-grad); color: var(--action-ink); box-shadow: var(--action-shadow); }
.btn-primary:hover { color: var(--action-ink); filter: brightness(0.94) saturate(1.05); }
.btn-primary:active { filter: brightness(0.88); }
.btn-primary:disabled:hover { filter: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--icon-faint); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--accent-tint); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-ink); color: #fff; }
:root[data-theme="dark"] .btn-danger:hover { background: #b0213a; }
/* The ink, not --danger: #dc2626 is 3.9:1 on the hover tint. */
.btn-danger-ghost { background: transparent; color: var(--danger-ink); border-color: var(--danger-soft); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger-ink); }
.btn-lg { padding: 0.95rem 1.6rem; font-size: 1.0625rem; border-radius: var(--r-lg); }
.btn-sm { padding: 0.45rem 0.8rem; font-size: var(--fs-sm); }
.btn-icon { padding: 0.55rem; width: 2.3rem; height: 2.3rem; border-radius: var(--r-sm); }
.btn-round { padding: 0; width: 2.4rem; height: 2.4rem; border-radius: 50%; flex-shrink: 0; }
.btn-round svg { width: 1.1rem; height: 1.1rem; }
.btn-round.btn-sm { width: 2rem; height: 2rem; }
.btn-block { width: 100%; }
.btn-white { background: #fff; color: var(--action); box-shadow: var(--shadow-md); }
.btn-white:hover { background: #fff; color: var(--action-deep); }

/* --- Chips: small pill toggles and filters ------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.75rem; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: 1.2;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .chip.active, :root[data-theme="dark"] .chip[aria-pressed="true"] { color: var(--ink); }
.chip svg { width: 0.95em; height: 0.95em; }

/* --- Forms --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.field label, .label { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); }
.field .hint, .hint { font-size: var(--fs-sm); color: var(--text-faint); }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: 0.95rem; color: var(--text);
  background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 0.7rem 0.85rem; transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); opacity: 1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-ring); }
.input[readonly], .textarea[readonly] { background: var(--surface-2); }
.textarea { min-height: 110px; resize: vertical; }
/* Inline field errors: HV.fieldError(input, message) sets aria-invalid and fills .field-error. */
.input-error, .input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger) !important; }
.input[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 30%, transparent); }
.field-error { display: flex; align-items: flex-start; gap: 0.35rem; color: var(--danger-ink); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.field-error:empty { display: none; }
.field-error svg { width: 1em; height: 1em; margin-top: 0.15em; flex-shrink: 0; }
.checkbox-row { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; cursor: pointer; }
.checkbox-row input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

/* --- Cards --------------------------------------------------------------- */
/* Things to copy in an agent's answer (markdown.js): a "copy" block's text with its Copy button, and the button
   on a code block. Used by the Chat and by a Task's agent comments. */
.md-copy { position: relative; margin: 0.5rem 0 0.9rem; }
.md-copy > pre.md-copy-body { margin: 0; padding-right: 4.75rem; }
.md-copy-words { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.6rem 0.6rem 0.6rem 0.85rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.md-copy-words .md-copy-body { flex: 1; min-width: 0; align-self: center; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.md-copy-btn { flex-shrink: 0; font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.2; padding: 0.35rem 0.7rem; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.md-copy-btn:hover { border-color: var(--action); color: var(--action); }
.md-copy-btn:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.md-copy-btn.is-done { border-color: var(--success); color: var(--success); }
.md-copy:not(.md-copy-words) .md-copy-btn { position: absolute; top: 0.45rem; right: 0.45rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.5rem; border-bottom: 1px solid var(--border); }
/* A phone: what's on a card head's right (a count, a button) goes under its title rather than squeezing it into a
   column a word wide. */
@media (max-width: 560px) { .card-head { flex-wrap: wrap; padding: 1rem; } .card-head > :first-child { flex: 1 1 14rem; min-width: 0; } }
.card-title { font-size: 1.05rem; font-weight: var(--fw-bold); margin: 0; }

/* --- Badges: tones neutral, accent, success, warning, danger, info --------- */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.35; padding: 0.15rem 0.6rem; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap; }
.badge svg { width: 0.95em; height: 0.95em; }
.badge[hidden] { display: none !important; }  /* a .badge is flex: hidden means hidden (the bell's count at none) */
.badge-accent { background: var(--accent-soft); color: var(--accent-active); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success-ink); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info-ink); border-color: transparent; }
.badge-dot::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.provider-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--fs-xs); font-weight: var(--fw-bold); padding: 0.25rem 0.6rem; border-radius: var(--r-pill); color: #fff; }
.cap-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; font-weight: var(--fw-semibold); padding: 0.2rem 0.55rem; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-muted); }
.cap-chip.on { background: var(--accent-soft); color: var(--accent-active); }

/* --- Avatars ------------------------------------------------------------- */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--brand-blue); background: var(--accent-grad); color: #fff; font-weight: var(--fw-bold); font-size: 0.85rem; flex-shrink: 0; }
.avatar-sm { width: 1.7rem; height: 1.7rem; font-size: 0.72rem; }
.avatar-lg { width: 3rem; height: 3rem; font-size: 1.1rem; }
.avatar-quiet { background: var(--surface-3); color: var(--text-muted); }

/* --- Tables: always in a .table-wrap, which scrolls sideways when narrow --- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.boxed { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-weight: var(--fw-semibold); color: var(--text-faint); font-size: var(--fs-sm); padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Stats: a label, a number, a line under it ----------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1.25rem 1.35rem; box-shadow: var(--shadow-xs); }
.stat.is-accent { border-color: var(--accent); }
.stat.is-alert { border-color: var(--danger); }
.stat-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-faint); display: flex; align-items: center; gap: 0.4rem; }
.stat-value { font-size: 2rem; font-weight: var(--fw-bold); letter-spacing: -0.03em; margin-top: 0.35rem; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }

/* --- Empty states -------------------------------------------------------- */
.empty { text-align: center; padding: 3.5rem 1.5rem; }
.empty-icon { width: 3.5rem; height: 3.5rem; border-radius: var(--r-lg); display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 1rem; }
.empty h3 { margin-bottom: 0.35rem; }
.empty p { color: var(--text-muted); max-width: 420px; margin: 0 auto 1.25rem; }

/* --- Icons (macro default size; specific contexts size up/down) ---------- */
.hv-icon { width: 18px; height: 18px; flex-shrink: 0; }
.empty-icon .hv-icon { width: 1.85rem; height: 1.85rem; }
.avatar .hv-icon, .avatar-sm .hv-icon { width: 1.05em; height: 1.05em; }
.stat-label .hv-icon { width: 1rem; height: 1rem; }

/* --- Dialogs: .modal-overlay > .modal[role=dialog] -------------------------
   hv-ui.js gives every one dialog semantics: it moves focus in and keeps it
   there, closes on Esc (the top one only) and gives focus back on close. */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: var(--z-modal); opacity: 0; visibility: hidden; transition: opacity var(--transition), visibility 0s linear 0.18s; }
/* Visible at once when it opens (so focus can move in), hidden only once faded out. */
.modal-overlay.active { opacity: 1; visibility: visible; transition: opacity var(--transition), visibility 0s; }
.modal { position: relative; background: var(--surface); color: var(--text); width: 100%; max-width: 460px; border-radius: var(--r-xl); border: 1px solid var(--border-soft); box-shadow: var(--shadow-xl); padding: 1.75rem; transform: translateY(14px) scale(0.98); transition: transform var(--transition); max-height: 90vh; overflow-y: auto; }
.modal:focus { outline: none; }
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal h3 { font-size: 1.2rem; margin-bottom: 0.35rem; }
.modal-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.modal-close { position: absolute; top: 0.85rem; right: 0.85rem; }
.modal-wide { max-width: 680px; }
.modal-dialog-input { margin-top: 0.25rem; }
@media (max-width: 560px) {
  .modal-overlay { padding: 0.75rem; align-items: flex-end; }
  .modal { padding: 1.35rem; border-radius: var(--r-lg); }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* --- Picking from the Vault (vault-picker.js; the standard, docs/STYLE_GUIDE.md) ---
   .vp-bar: a search bar (or a list of folders) with Browse beside it; .vp-results:
   what typing in the bar finds; .vp: the dialog Browse opens. */
.vp-bar { display: flex; gap: 0.5rem; align-items: stretch; }
.vp [hidden], .vp-bar [hidden], .vp-browse[hidden], .vp-results[hidden] { display: none !important; }  /* a .btn is flex: hidden means hidden */
.vp-bar > .input, .vp-bar > .select { flex: 1 1 8rem; min-width: 0; width: auto; }
.vp-bar > .btn { flex: 0 0 auto; }
.vp-browse svg { width: 1em; height: 1em; }
.vp-results { list-style: none; margin: 0.35rem 0 0; padding: 0.25rem; max-height: 14rem; overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--surface); }
.vp-result { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0.4rem 0.6rem; border-radius: var(--r-sm); font: inherit; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.vp-result:hover, .vp-result:focus-visible { background: var(--surface-3); }
.vp-where { display: block; color: var(--text-faint); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-empty { padding: 0.6rem; color: var(--text-muted); font-size: var(--fs-sm); }
.vp .vp-search { margin: 0.6rem 0 0.5rem; }
.vp-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem; min-height: 1.9rem; margin-bottom: 0.35rem; font-size: var(--fs-sm); }
.vp-crumb { background: none; border: 0; padding: 0.2rem 0.35rem; border-radius: var(--r-sm); font: inherit; color: var(--accent); cursor: pointer; }
.vp-crumb:hover { background: var(--surface-3); }
.vp-crumb[aria-current] { color: var(--text); font-weight: var(--fw-semibold); cursor: default; background: none; }
.vp-sep { color: var(--text-faint); }
.vp-found { color: var(--text-muted); margin-right: 0.35rem; }
.vp-list { list-style: none; margin: 0; padding: 0.25rem; height: min(21rem, 44vh); overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--r-md); }
.vp-list:focus { outline: none; }
.vp-row { display: flex; align-items: center; gap: 0.4rem; border-radius: var(--r-sm); padding-right: 0.4rem; }
.vp-row:hover { background: var(--surface-3); }
.vp-row.is-off:hover { background: none; }
.vp-item { display: flex; align-items: center; gap: 0.6rem; flex: 1 1 auto; min-width: 0; padding: 0.5rem 0.6rem; background: none; border: 0; border-radius: var(--r-sm); font: inherit; font-size: 0.9rem; color: var(--text); text-align: left; cursor: pointer; }
.vp-item svg { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; color: var(--text-faint); }
.vp-folder .vp-item svg:first-child { color: var(--accent); }
.vp-row.is-off .vp-item { color: var(--text-faint); cursor: default; }
.vp-text { flex: 1 1 auto; min-width: 0; }
.vp-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-check { flex: 0 0 auto; width: 1rem; height: 1rem; }
.vp-row > .vp-check { margin-left: 0.6rem; }
.vp-row > .vp-check + .vp-item { padding-left: 0.2rem; }
.vp-choose, .vp-had { flex: 0 0 auto; }
.vp-under { display: flex; align-items: center; gap: 0.5rem; min-height: 2.1rem; margin-top: 0.35rem; }
.vp-note { flex: 1 1 auto; margin: 0; }
.vp .modal-actions { margin-top: 0.5rem; }

/* --- Alerts and callouts --------------------------------------------------
   An alert is a status line (role=status or alert); a callout is a note
   that stays, with a blue mark on its left edge. */
.alert { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.8rem 1rem; border-radius: var(--r-md); font-size: var(--fs-md); border: 1px solid transparent; }
.alert > svg, .alert > .hv-icon { margin-top: 0.1rem; }
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.alert-success { background: var(--success-soft); color: var(--success-ink); border-color: var(--success-border); }
.alert-danger { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-soft); color: var(--warning-ink); border-color: var(--warning-border); }
.alert-info { background: var(--info-soft); color: var(--info-ink); border-color: var(--info-border); }
.callout { position: relative; padding: 0.9rem 1.1rem 0.9rem 1.35rem; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-md); color: var(--text-muted); }
.callout::before { content: ""; position: absolute; left: 0.55rem; top: 0.85rem; bottom: 0.85rem; width: 3px; border-radius: 2px; background: var(--brand-blue-light); }
.callout-title { display: block; color: var(--text); font-weight: var(--fw-semibold); margin-bottom: 0.2rem; }
.callout p:last-child { margin-bottom: 0; }
.status-msg { display: none; margin-top: 0.85rem; padding: 0.7rem 0.9rem; border-radius: var(--r-md); font-size: var(--fs-md); }
.status-msg.show { display: block; }
.status-msg.error { background: var(--danger-soft); color: var(--danger-ink); }
.status-msg.success { background: var(--success-soft); color: var(--success-ink); }

/* --- Toasts: announced (role=status in a live stack) and closable --------- */
.toast-stack { position: fixed; bottom: 1.25rem; right: 1.25rem; left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; z-index: var(--z-toast); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 0.6rem; max-width: min(420px, calc(100vw - 2.5rem)); background: var(--ink); color: #fff; padding: 0.7rem 0.55rem 0.7rem 1rem; border-radius: var(--r-md); border: 1px solid var(--stage-border); box-shadow: var(--shadow-lg); font-size: 0.9rem; line-height: 1.4; animation: toast-in 0.25s ease; }
.toast::before { content: ""; align-self: stretch; width: 3px; border-radius: 2px; background: var(--brand-blue-light); flex-shrink: 0; }
.toast.success::before { background: #34c27a; }
.toast.error::before { background: #ff6b6b; }
.toast-msg { flex: 1; min-width: 0; }
.toast-open { display: block; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.toast-open:hover .toast-title, .toast-open:focus-visible .toast-title { text-decoration: underline; }
.toast-title { display: block; font-weight: 600; }
.toast-detail { display: block; font-size: 0.8rem; color: var(--stage-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-desktop { padding: 0.35rem 0.7rem 0.5rem; display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.notif-desktop[hidden] { display: none !important; }
.toast-close { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; flex-shrink: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--stage-muted); cursor: pointer; }
.toast-close:hover { background: var(--stage-elev); color: var(--stage-text); }
.toast-close svg { width: 1rem; height: 1rem; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 560px) { .toast-stack { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; align-items: stretch; } .toast { max-width: none; } }

/* --- Dropdown menu ------------------------------------------------------- */
.menu { position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 200px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 0.35rem; z-index: var(--z-dropdown); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity var(--transition), visibility var(--transition), transform var(--transition); }
.menu.active { opacity: 1; visibility: visible; transform: translateY(0); }
/* A phone: the bell's menu is wider than the space left of the bell, so it spans the screen under the top bar. */
@media (max-width: 560px) { #notif-menu { position: fixed; left: 0.75rem; right: 0.75rem; top: calc(var(--topbar-h, 64px) + 0.25rem); width: auto !important; } }
.menu-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: var(--r-sm); font-size: 0.9rem; color: var(--text); cursor: pointer; width: 100%; background: none; border: none; text-align: left; font-family: inherit; text-decoration: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); color: var(--text); }
.menu-item.danger { color: var(--danger-ink); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item[aria-current="true"] { font-weight: var(--fw-semibold); }
.menu-divider { height: 1px; background: var(--border); margin: 0.35rem 0; }
.menu-label { padding: 0.4rem 0.7rem; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-faint); }

/* --- Tabs (for the workspace tabs to come, plan 4.4) ---------------------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { padding: 0.7rem 1rem; font-size: 0.9rem; font-weight: var(--fw-semibold); color: var(--text-muted); border: 0; border-bottom: 2px solid transparent; cursor: pointer; background: none; font-family: inherit; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--text); }
.tab.active, .tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Spinner and skeleton ------------------------------------------------- */
.spinner { display: inline-block; width: 1.1rem; height: 1.1rem; border: 2px solid var(--accent-ring); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; vertical-align: middle; }
.spinner-lg { width: 1.6rem; height: 1.6rem; border-width: 3px; }
.btn .spinner { border-color: rgba(255, 255, 255, 0.45); border-top-color: #fff; }
.btn-secondary .spinner, .btn-ghost .spinner { border-color: var(--accent-tint); border-top-color: var(--accent); }
/* A busy button (HV.busy, hv-core.js): its spinner and busy label, full
   strength (it isn't refused, it's working), and no second click. */
.btn.is-busy, .btn[aria-busy="true"] { opacity: 1; cursor: progress; }
.btn.is-busy .hv-busy-spinner { width: 1em; height: 1em; }
.btn-danger-ghost .spinner, .btn-white .spinner { border-color: var(--accent-tint); border-top-color: currentColor; }
.is-busy:not(.btn) .hv-busy-spinner { width: 0.9em; height: 0.9em; margin-right: 0.35em; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { display: block; min-height: 0.9em; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
.skeleton + .skeleton { margin-top: 0.55rem; }
.skeleton-line { width: 100%; height: 0.9rem; }
.skeleton-short { width: 60%; height: 0.9rem; }
.skeleton-title { width: 40%; height: 1.4rem; }
.skeleton-block { width: 100%; height: 7rem; border-radius: var(--r-md); }
.skeleton-avatar { width: 2.1rem; height: 2.1rem; border-radius: 50%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- The logo (kit.mark, kit.wordmark): the <picture> and its <source>
   take no box (in a flex row a source would be an item, with a gap each
   side), so a page's "img" rules place and size the logo as before; the
   width follows the artwork's own ratio. ------------------------------- */
.hv-pic { display: contents; }
.hv-pic > source { display: none; }
.hv-pic > img { width: auto; }

/* --- The two-tone mark (orange then blue), for a quiet brand accent -------- */
.two-tone { display: inline-block; width: 14px; height: 6px; border-radius: 3px; background: var(--brand-two-tone); vertical-align: middle; }

/* --- The workspace switcher: one component, a real button and a menu ------- */
.ws-switch { position: relative; display: inline-flex; min-width: 0; }
.ws-switch-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; max-width: 290px;
  padding: 0.3rem 0.6rem; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; text-align: left;
  transition: background var(--transition), border-color var(--transition);
}
.ws-switch-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.ws-switch-btn[aria-expanded="true"] { border-color: var(--focus); }
.ws-switch-name { font-size: 0.9rem; font-weight: var(--fw-semibold); line-height: 1.15; min-width: 0; }
.ws-switch-btn .badge { flex: none; font-size: 0.68rem; padding: 0.05rem 0.45rem; }
.ws-switch .menu { left: 0; right: auto; min-width: 260px; max-height: min(70vh, 480px); overflow-y: auto; }
.ws-switch-end .menu { left: auto; right: 0; }
.ws-switch .menu-item .small { color: var(--text-faint); }
.ws-switch-prefix { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-muted); padding-left: 0.25rem; }

/* ==========================================================================
   App shell (sidebar and topbar): every signed-in page
   ========================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--stage); color: var(--stage-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 1.1rem 0.85rem; transition: width var(--transition); overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; gap: 0.4rem; padding: 0 0 1.2rem; }
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; flex: 1; min-width: 0; border-radius: var(--r-sm); }
.sidebar-brand img { height: 26px; width: auto; flex-shrink: 0; }
.sidebar-collapse { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border-radius: var(--r-md); border: none; background: transparent; color: var(--stage-muted); cursor: pointer; flex-shrink: 0; transition: background var(--transition), color var(--transition); }
.sidebar-collapse:hover { background: var(--stage-elev); color: var(--stage-text); }
.sidebar-collapse-icon { transition: transform var(--transition); transform: rotate(180deg); }
.sidebar.collapsed .sidebar-collapse-icon { transform: rotate(0deg); }
.sidebar :focus-visible { outline-color: var(--brand-blue-light); }

/* Icons-only rail: a wide window's only. app.js keeps "collapsed" in the browser, and a phone that has it (its
   chevron was in the phone's menu) must still get the whole screen: the 68px column, outside this, was all the
   phone's page had (the owner's Android phone, 2026-11-15), with the sidebar a drawer over it. */
@media (min-width: 901px) {
  .sidebar.collapsed { padding: 1.1rem 0.5rem; }
  .app:has(> .sidebar.collapsed) { grid-template-columns: 68px 1fr; }
  .sidebar.collapsed .sidebar-head { flex-direction: column; gap: 0.35rem; padding-bottom: 0.9rem; }
  .sidebar.collapsed .sidebar-brand { padding: 0.2rem; justify-content: center; }
  .sidebar.collapsed .nav-link { justify-content: center; padding: 0.6rem 0; }
  .sidebar.collapsed .nav-link .grow,
  .sidebar.collapsed .nav-link .nav-badge,
  .sidebar.collapsed .sidebar-section-header,
  .sidebar.collapsed .ws-nav-chevron,
  .sidebar.collapsed .ws-nav-link .grow,
  .sidebar.collapsed .ws-nav-kind,
  .sidebar.collapsed .ws-nav-add,
  .sidebar.collapsed .ws-menu-anchor,
  .sidebar.collapsed .ws-menu-btn,
  .sidebar.collapsed .ws-nav-new { display: none; }
  .sidebar.collapsed .ws-nav { margin: 0.15rem 0; padding-left: 0; border-left: none; align-items: center; }
  .sidebar.collapsed .ws-nav-item { justify-content: center; }
  .sidebar.collapsed .ws-nav-link { justify-content: center; padding: 0.4rem 0; }
}
.nav-group-label { font-size: var(--fs-xs); color: var(--stage-muted); padding: 0.9rem 0.7rem 0.4rem; font-weight: var(--fw-semibold); }
.nav-link { position: relative; display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.7rem; border-radius: var(--r-md); color: var(--stage-muted); font-size: 0.9rem; font-weight: var(--fw-medium); cursor: pointer; transition: background var(--transition), color var(--transition); }
.nav-link svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.nav-link:hover { background: var(--stage-elev); color: var(--stage-text); }
/* The current page: a bright blue row (--action, the same blue in both themes). */
.nav-link.active { background: var(--action); color: var(--action-ink); box-shadow: var(--shadow-accent); }

.app-main { display: flex; flex-direction: column; min-width: 0; }
/* A Workspace's page inside the Home's canvas (docs/CHAT_ONLY_PLAN.md 2.3): no sidebar, top bar, tabs or footer. */
.app.embedded { display: block; min-height: 0; }
.app.embedded .app-footer { display: none; }
.app.embedded .workspace-header .workspace-where { display: none; }  /* the Home around it says where this is */
.app.embedded .workspace-header:not(:has(button)) { display: none; }
/* The top of one of a Workspace's pages, opened by its own address: back to its Home, and which part this is
   (app/core/templates/_workspace_nav.html; there is no tabs bar). */
.workspace-crumbs { display: flex; gap: 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.45rem; min-height: 2.4rem; }
.workspace-back { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0; max-width: 28ch; color: var(--text-muted); font-weight: var(--fw-semibold); text-decoration: none; }
.workspace-back:hover, .workspace-back:focus-visible { color: var(--brand-blue); }
.workspace-back svg { width: 1em; height: 1em; flex-shrink: 0; }
.workspace-here { font-weight: var(--fw-semibold); white-space: nowrap; }
.workspace-here::before { content: "/"; margin-right: 0.5rem; color: var(--text-muted); font-weight: var(--fw-regular, 400); }
.app.embedded .app-content { padding: 1rem 1.1rem; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 1.75rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: var(--z-header); }
@supports (backdrop-filter: blur(8px)) and (background: color-mix(in srgb, red 50%, transparent)) {
  .topbar { background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}
.topbar > .row { min-width: 0; }
.topbar h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.02em; }
@media (max-width: 640px) { .topbar h1 { display: none; } }
.app-content { padding: 1.75rem; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; margin: 0 0 0.25rem; }
.page-head p { color: var(--text-muted); margin: 0; }

/* Mobile sidebar */
.menu-toggle { display: none; }
/* The scrim is a direct child of .app. It MUST be fixed (out of grid flow) so it
   never occupies a grid cell and pushes .app-main below the sidebar. Hidden
   until the mobile sidebar opens. */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: calc(var(--z-modal) - 1); opacity: 0; visibility: hidden; transition: opacity var(--transition), visibility var(--transition); }
.scrim.show { opacity: 1; visibility: visible; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: var(--z-modal); width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 1rem; }
  .app-content { padding: 1.25rem 1rem; }
}

/* --- Dashboard grid (app) ------------------------------------------------ */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1.5rem; }
.dash-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition); }
.dash-card:focus-within { border-color: var(--accent-ring); }
/* Only genuinely openable cards get the lift + pointer (JS adds .dash-card-clickable
   to [data-link]); locked/building/failed cards stay put so hover never implies an
   action that isn't there. */
.dash-card-clickable { cursor: pointer; }
.dash-card-clickable:hover { border-color: var(--accent-ring); box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.dash-card .dash-card-actions,
.dash-card .menu-trigger { position: relative; z-index: 3; }
/* Per-card More menu keeps base .menu's absolute positioning but opens UPWARD, so
   the card's overflow:hidden never clips it and it never reserves footer space. */
.dash-card .menu { top: auto; bottom: calc(100% + 0.4rem); z-index: 20; }
.dash-preview { position: relative; width: 100%; aspect-ratio: 16 / 10; background: var(--surface-3); overflow: hidden; border-bottom: 1px solid var(--border); }
/* Embeds render at 2x and scale down — a zoomed-out thumbnail of the real
   dashboard instead of a cramped 380px viewport. pointer-events stays off so
   clicks fall through to the whole-card open handler. */
.dash-preview iframe { width: 200%; height: 200%; border: 0; display: block; background: #fff; transform: scale(0.5); transform-origin: 0 0; pointer-events: none; }
.dash-provider-chip { position: absolute; top: 0.75rem; left: 0.75rem; z-index: 3; display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.7rem; font-size: 0.72rem; font-weight: var(--fw-bold); letter-spacing: 0.01em; color: var(--text); background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--r-pill); box-shadow: var(--shadow-xs); }
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .dash-provider-chip { background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}
.dash-provider-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex-shrink: 0; }
/* Non-embed preview states: locked / unavailable / brand fallback. */
.dash-preview .placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem; padding: 1.25rem; text-align: center; color: var(--text-faint); }
.dash-state-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); color: var(--text-muted); margin-bottom: 0.35rem; }
.dash-state-icon svg { width: 1.2rem; height: 1.2rem; }
.dash-state-icon.warn { background: var(--warning-soft); border-color: transparent; color: var(--warning-ink); }
.dash-state-title { font-size: 0.9rem; font-weight: var(--fw-semibold); color: var(--text-muted); }
.dash-state-sub { font-size: 0.78rem; line-height: 1.45; color: var(--text-muted); max-width: 32ch; }
.dash-brandmark { background: linear-gradient(160deg, var(--surface-2), var(--surface-3)); }
@supports (color: color-mix(in srgb, red 10%, transparent)) {
  .dash-brandmark { background: radial-gradient(120% 90% at 18% 0%, color-mix(in srgb, var(--brand, var(--accent)) 14%, transparent), transparent 62%), linear-gradient(160deg, var(--surface-2), var(--surface-3)); }
}
.dash-monogram { display: inline-flex; align-items: center; justify-content: center; width: 3.25rem; height: 3.25rem; border-radius: var(--r-lg); background: var(--brand, var(--accent)); color: #fff; font-size: 1.35rem; font-weight: var(--fw-bold); box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(0, 0, 0, 0.08); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.32); margin-bottom: 0.35rem; }
/* Hover affordance on clickable cards: dark veil + "Open dashboard" pill.
   pointer-events: none — purely visual, the card handles the click. */
.dash-open-veil { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; background: linear-gradient(to top, rgba(11, 18, 32, 0.42), rgba(11, 18, 32, 0.1) 55%, rgba(11, 18, 32, 0)); opacity: 0; transition: opacity var(--transition); pointer-events: none; }
.dash-open-hint { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.55rem 1.05rem; font-size: 0.85rem; font-weight: var(--fw-semibold); color: var(--text); background: var(--surface); border-radius: var(--r-pill); box-shadow: var(--shadow-lg); transform: translateY(8px); transition: transform var(--transition); }
.dash-open-hint svg { width: 1em; height: 1em; }
.dash-card-clickable:hover .dash-open-veil { opacity: 1; }
.dash-card-clickable:hover .dash-open-hint { transform: translateY(0); }
@media (hover: none) { .dash-open-veil { display: none; } }
/* A Managed Dashboard locked until billing Activation (ADR-0006). */
.dash-card-locked { border-style: dashed; border-color: var(--warning); }
.dash-card-locked:hover { border-color: var(--warning-ink); box-shadow: var(--shadow-md); }
.dash-card-locked .dash-preview { background: linear-gradient(160deg, var(--warning-soft), var(--surface-2)); }
/* Sidebar alert on a workspace pending billing Activation (ADR-0006). */
.ws-nav-alert { display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--warning-ink); background: var(--warning-soft); border-radius: 999px; padding: 0.08rem 0.28rem; }
.ws-nav-alert svg { width: 13px; height: 13px; }
/* The Kind badge on a sidebar workspace row (Company / Group / Personal). */
.ws-nav-kind { flex: none; font-size: 0.7rem; font-weight: var(--fw-semibold); letter-spacing: 0.01em; color: var(--stage-muted); }
.dash-card-foot { padding: 0.75rem 0.85rem 0.75rem 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.dash-meta { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.dash-title { font-weight: var(--fw-bold); font-size: 0.95rem; letter-spacing: -0.01em; margin: 0; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-sub { font-size: 0.78rem; line-height: 1.25; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-sub:empty { display: none; }
.dash-card-actions { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.dash-card-actions .btn-icon { width: 2rem; height: 2rem; padding: 0.4rem; border-radius: var(--r-sm); color: var(--text-muted); }
.dash-card-actions .btn-icon:hover { color: var(--accent); background: var(--accent-tint); }
@media (max-width: 560px) { .dash-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  .dash-card, .dash-open-veil, .dash-open-hint { transition: none; }
  .dash-card-clickable:hover { transform: none; }
}

/* --- Sidebar: Workspaces section (labeled section with 3-dot actions) --- */
.ws-section-wrapper { display: flex; flex-direction: column; }
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0.6rem 0.35rem;
  margin-top: 0.35rem;
}
.sidebar-section-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--stage-muted);
}
.sidebar-section-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--stage-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.sidebar-section-action:hover {
  background: var(--stage-elev);
  color: var(--stage-text);
}
.sidebar-section-action svg {
  width: 0.85rem;
  height: 0.85rem;
}

.ws-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.15rem 0;
  overflow: visible;
}
/* Each Workspace's row wears its plan's colour. The sidebar is dark slate in both themes, so one set of colours serves
   both: each is 6.4:1 or more on the sidebar in either theme, and a row's text 10:1 or more on its tint. */
.ws-nav-item {
  --plan-rgb: 148, 163, 184; /* Free, and any plan without its own colour: slate */
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  border-radius: var(--r-md);
  transition: background var(--transition), box-shadow var(--transition);
}
.ws-nav-item.plan-starter { --plan-rgb: 74, 222, 128; }
.ws-nav-item.plan-workspace_team { --plan-rgb: 167, 139, 250; }
.ws-nav-item.plan-pro { --plan-rgb: 96, 165, 250; }
.ws-nav-item.plan-enterprise { --plan-rgb: 232, 184, 74; }
.ws-nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  bottom: 0.45rem;
  width: 3px;
  border-radius: var(--r-pill);
  background: rgb(var(--plan-rgb));
  opacity: 0.7;
  transition: opacity var(--transition);
}
.ws-nav-item.plan-free::before { opacity: 0; }
.ws-nav-item.active {
  background: rgba(var(--plan-rgb), 0.16);
  box-shadow: inset 0 0 0 1px rgba(var(--plan-rgb), 0.42);
}
.ws-nav-item.active::before { opacity: 1; }
@media (min-width: 901px) {  /* the rail's (above) */
  .sidebar.collapsed .ws-nav-item::before { display: none; }
  .sidebar.collapsed .ws-nav-item.active { background: none; box-shadow: none; } /* its solid square says it */
}
.ws-nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.5rem;
  border-radius: var(--r-md);
  color: var(--stage-muted);
  font-size: 0.875rem;
  font-weight: var(--fw-medium);
}
.ws-nav-link:hover {
  color: var(--stage-text);
}
.ws-nav-item:not(.active) .ws-nav-link:hover {
  background: rgba(var(--plan-rgb), 0.1);
}
.ws-nav-item.active .ws-nav-link,
.ws-nav-item.active .ws-nav-kind {
  color: #fff;
}
.ws-nav-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: var(--r-sm);
  background: rgba(var(--plan-rgb), 0.18);
  color: rgb(var(--plan-rgb));
  font-size: 0.68rem;
  font-weight: var(--fw-bold);
}
.ws-nav-dot svg {
  width: 0.88rem;
  height: 0.88rem;
  display: block;
}
/* The current Workspace: a solid square of its colour, with a dark icon that reads at AA on every one. */
.ws-nav-item.active .ws-nav-dot {
  background: rgb(var(--plan-rgb));
  color: #0b1220;
}

/* The Personal card: apart from the shared workspaces, with its own plan.
   Plus (its agent works across all workspaces) gets a violet-to-blue edge. */
.personal-nav {
  position: relative; display: flex; align-items: center; gap: 0.2rem;
  margin: 0.55rem 0 0.15rem; border-radius: var(--r-lg);
  border: 1px solid var(--stage-border, rgba(255, 255, 255, 0.08)); background: var(--stage-elev);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.personal-nav.is-plus {
  border-color: transparent;
  background: linear-gradient(var(--stage-elev), var(--stage-elev)) padding-box,
              linear-gradient(135deg, #8b5cf6, #3b82f6 55%, #06b6d4) border-box;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.12), 0 6px 18px -10px rgba(139, 92, 246, 0.55);
}
.personal-nav.active { box-shadow: 0 0 0 2px var(--action), var(--shadow-accent); }
.personal-nav-link { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; padding: 0.55rem 0.55rem; color: var(--stage-text); }
.personal-nav-icon {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.9rem; height: 1.9rem; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, #64748b, #475569);
}
.personal-nav.is-plus .personal-nav-icon { background: linear-gradient(135deg, #8b5cf6, #3b82f6); }
.personal-nav-icon svg { width: 0.95rem; height: 0.95rem; }
.personal-nav-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.personal-nav-name { font-size: 0.875rem; font-weight: var(--fw-semibold); }
.personal-nav-sub { font-size: 0.7rem; color: var(--stage-muted); }
.personal-nav-plan {
  display: inline-flex; align-items: center; gap: 0.2rem; flex-shrink: 0;
  padding: 0.12rem 0.45rem; border-radius: var(--r-pill);
  font-size: 0.66rem; font-weight: var(--fw-bold); letter-spacing: 0.02em; text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08); color: var(--stage-muted);
}
.personal-nav.is-plus .personal-nav-plan { background: linear-gradient(135deg, #8b5cf6, #3b82f6); color: #fff; }
.personal-nav-plan svg { width: 0.7rem; height: 0.7rem; }
@media (min-width: 901px) {  /* the rail's (above) */
  .sidebar.collapsed .personal-nav-text,
  .sidebar.collapsed .personal-nav-plan,
  .sidebar.collapsed .personal-nav .ws-menu-anchor { display: none; }
  .sidebar.collapsed .personal-nav { border: none; background: none; box-shadow: none; justify-content: center; }
  .sidebar.collapsed .personal-nav-link { justify-content: center; padding: 0.35rem 0; }
}

/* 3-dot dropdown button and options menu */
.ws-menu-anchor {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 0.25rem;
  flex-shrink: 0;
}
.ws-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--stage-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.ws-menu-btn svg {
  width: 0.95rem;
  height: 0.95rem;
}
.ws-menu-btn:hover,
.ws-menu-btn:focus-visible,
.ws-menu-btn[aria-expanded="true"] {
  background: var(--stage-elev);
  color: var(--stage-text);
}
.ws-nav-item.active .ws-menu-btn {
  color: rgba(255, 255, 255, 0.85);
}
.ws-nav-item.active .ws-menu-btn:hover,
.ws-nav-item.active .ws-menu-btn:focus-visible,
.ws-nav-item.active .ws-menu-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.ws-menu-dropdown {
  width: 205px;
  max-width: calc(100vw - 2rem);
  z-index: 100;
}
.ws-menu-dropdown .menu-item svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--icon-faint);
}
.ws-menu-dropdown .menu-item:hover svg,
.ws-menu-dropdown .menu-item:focus-visible svg {
  color: var(--accent);
}

.ws-nav-new {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.5rem 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--stage-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: var(--fw-semibold);
  border-radius: var(--r-md);
}
.ws-nav-new svg {
  width: 0.95rem;
  height: 0.95rem;
}
.ws-nav-new:hover {
  background: var(--stage-elev);
  color: var(--stage-text);
}
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.3rem; height: 1.3rem; padding: 0 0.4rem; border-radius: var(--r-pill); background: var(--action); color: #fff; font-size: 0.72rem; font-weight: var(--fw-bold); }
.nav-link.active .nav-badge { background: var(--action-deep); }

/* --- Overview: per-workspace sections + carousel ------------------------- */
.ws-section { display: block; }
.ws-section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.ws-section-title { font-size: 1.3rem; margin: 0; }
.ws-section-title-link { color: inherit; text-decoration: none; }
.ws-section-title-link:hover { color: var(--link); text-decoration: underline; }
.carousel { display: flex; gap: 1.25rem; overflow-x: auto; padding: 0.25rem 0.25rem 1rem; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.carousel::-webkit-scrollbar { height: 8px; }
.carousel::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); }
.carousel .dash-card { width: 340px; flex: 0 0 340px; scroll-snap-align: start; }
.carousel .dash-preview { aspect-ratio: 16 / 9; }

/* --- Workspace page: people list + split layout -------------------------- */
.ws-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 880px) { .ws-split { grid-template-columns: 1fr; } }
.people-list { list-style: none; margin: 0; padding: 0; }
.people-list .person { display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 1.5rem; border-bottom: 1px solid var(--border); }
.people-list .person:last-child { border-bottom: none; }

/* --- Add-dashboard create flow (shared by overview + workspace pages) ----- */
.detect-panel { display: none; margin-top: 0.5rem; padding: 0.85rem 1rem; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.detect-panel.show { display: block; }
.cap-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.dash-status { display: none; padding: 0.6rem 1rem; background: var(--accent-soft); border-bottom: 1px solid var(--accent-tint); align-items: center; gap: 0.6rem; font-size: 0.83rem; font-weight: var(--fw-medium); color: var(--accent-active); }
.dash-status.show { display: flex; }
.dash-status.error { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-border); }

/* --- Footer (app) --------------------------------------------------------- */
.app-footer { padding: 1rem 1.75rem; text-align: center; color: var(--text-faint); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* --- Standalone pages (Contact sales): the brand panel ---------------------
   The bright blue gradient beside the form, white type on it. */
.brand-panel { position: relative; overflow: hidden; color: #fff; background: var(--action); background: var(--accent-grad); }
.brand-panel > * { position: relative; }
.brand-panel h2 { color: #fff; }
.brand-lockup { display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem; }
.brand-lockup img { display: block; width: auto; }

/* --- Utility spacing ----------------------------------------------------- */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; }

/* --- Accessibility & Responsive (plans 4.8, 4.9) ----------------------- */
.skip-link { position: absolute; top: -999px; left: 1rem; z-index: var(--z-modal); padding: 0.6rem 1.1rem; background: var(--action); color: #fff; border-radius: var(--r-md); font-weight: var(--fw-semibold); font-size: var(--fs-md); text-decoration: none; box-shadow: var(--shadow-lg); }
.skip-link:focus { top: 1rem; outline: 3px solid var(--focus); }
.sidebar-close { display: none; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border-radius: var(--r-md); border: none; background: transparent; color: var(--stage-muted); cursor: pointer; margin-left: auto; }
.sidebar-close:hover { background: var(--stage-elev); color: var(--stage-text); }
.chat-rail-scrim { display: none; }
@media (max-width: 900px) {
  .sidebar-close { display: inline-flex; }
  .sidebar-collapse { display: none; }  /* the rail is a wide window's: the phone's menu closes with its X */
  .chat-rail-scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 55; opacity: 0; visibility: hidden; transition: opacity var(--transition), visibility var(--transition); }
  .chat-rail-scrim.show { opacity: 1; visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast, .modal, .modal-overlay, .menu { animation: none; transition: none; }
  .spinner, .skeleton { animation-duration: 2.4s; }
}


/* Dropdowns: the option list in HunterViz's own style, not the browser's
   default (CSS customizable select). Keyboard and screen-reader behaviour stay
   the native select's; browsers without base-select keep their own list. */
@supports (appearance: base-select) {
  select:not([multiple]):not([size]), select:not([multiple]):not([size])::picker(select) { appearance: base-select; }
  select:not([multiple]):not([size]) { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
  select:not([multiple]):not([size])::picker(select) {
    margin-top: 0.35rem; padding: 0.3rem; min-width: anchor-size(width); max-height: min(22rem, 60vh);
    border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-raised, var(--surface));
    box-shadow: var(--shadow-md); color: var(--text);
  }
  select:not([multiple]):not([size])::picker-icon { color: var(--text-faint); transition: rotate var(--transition, 0.15s); }
  select:not([multiple]):not([size]):open::picker-icon { rotate: 180deg; }
  /* The composer pickers draw their own chevron. */
  .pick select:not([multiple]):not([size])::picker-icon { display: none; }
  select:not([multiple]):not([size]) option {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.7rem; border-radius: var(--r-sm);
    font-size: 0.875rem; font-weight: var(--fw-medium, 500); color: var(--text); background: transparent; cursor: pointer; white-space: nowrap;
  }
  select:not([multiple]):not([size]) option:hover, select:not([multiple]):not([size]) option:focus-visible { background: var(--surface-3); outline: none; }
  select:not([multiple]):not([size]) option:checked { background: var(--accent-soft); color: var(--accent-active); font-weight: var(--fw-semibold); }
  select:not([multiple]):not([size]) option::checkmark { display: none; }
  select:not([multiple]):not([size]) option:disabled { color: var(--text-faint); cursor: default; }
}
