/* ============================================================================
   STUDIO — RESET + BASE + COMPONENTS + LAYOUT + RESPONSIVE
   Depth = tone + hairline. One accent. Motion = transform/opacity only.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body {
  height: 100%;
  overflow-x: clip;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  letter-spacing: -0.006em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
:where(h1, h2, h3, h4) { font-weight: 600; text-wrap: balance; }
p { text-wrap: pretty; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Theme-swap guard: JS toggles this for one frame so hover transitions don't animate the swap. */
:root.theme-switching *, :root.theme-switching *::before, :root.theme-switching *::after {
  transition: none !important;
}

/* ---- Focus ring (WCAG 2.4.13) ---- */
:where(a, button, input, select, textarea, [tabindex], [role="tab"], [role="option"], [role="menuitem"]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: var(--z-tooltip);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: var(--fs-label); font-weight: 500;
  box-shadow: var(--shadow-overlay);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

::selection { background: var(--accent-tint); }

/* Scrollbars — quiet */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: color-mix(in oklab, var(--border-strong) 60%, transparent); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }

/* ============================================================================
   TYPE HELPERS
   ========================================================================== */
.t-display { font-size: var(--fs-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; }
.t-title   { font-size: var(--fs-title); font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
.t-heading { font-size: var(--fs-heading); font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; }
.t-subhead { font-size: var(--fs-subhead); font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.t-body-lg { font-size: var(--fs-body-lg); font-weight: 400; line-height: 1.55; }
.t-label   { font-size: var(--fs-label); font-weight: 500; line-height: 1.3; }
.t-caption { font-size: var(--fs-caption); font-weight: 400; line-height: 1.4; color: var(--text-muted); }
.t-eyebrow { font-size: var(--fs-eyebrow); font-weight: 600; line-height: 1.3; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.measure { max-width: 65ch; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { flex: none; }

/* ============================================================================
   APP SHELL LAYOUT
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
}

.sidebar {
  grid-column: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--chrome);
  border-right: 1px solid var(--chrome-border);
  overflow: hidden;
  min-width: 0;
}
.sidebar__scroll { overflow-y: auto; padding: var(--space-3) var(--space-3) var(--space-4); }

.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--chrome-border);
}
.brand__mark { width: 22px; height: 22px; flex: none; color: var(--accent-text); }
.brand__name {
  font-family: var(--font-brand); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: 0.04em; color: var(--chrome-text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__section { margin-top: var(--space-5); padding: 0 var(--space-2) var(--space-1); }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-label); font-weight: 500;
  white-space: nowrap; min-width: 0;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.nav__item .icon { color: currentColor; opacity: .92; }
.nav__item .nav__label { overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) and (pointer: fine) {
  .nav__item:hover { background: var(--surface-2); color: var(--text); }
}
.nav__item.is-active { background: var(--accent-tint); color: var(--accent-text); }
.nav__item.is-active .icon { opacity: 1; }
.nav__item[hidden] { display: none; } /* role-gated nav items collapse cleanly (beats .nav__item's display:flex) */

/* bottom-pinned job spine */
.spine {
  border-top: 1px solid var(--chrome-border);
  padding: var(--space-3);
}
.spine__row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 40px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--fs-label); font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .spine__row:hover { background: var(--surface-2); color: var(--text); } }
.spine__row .spine__label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.spine__count {
  font-family: var(--font-mono); font-size: var(--fs-caption); font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--text-secondary);
  border-radius: var(--radius-xs); padding: 1px 7px; min-width: 22px; text-align: center;
}
.spine__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.spine.is-live .spine__dot { background: var(--accent); animation: pulse 1.8s var(--ease-in-out) infinite; }
.spine.is-live .spine__count { background: var(--accent-tint); color: var(--accent-text); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* content region */
.content {
  grid-column: 2;
  min-width: 0;
  height: 100dvh;
  display: grid;
  /* Constrain the single content column (minmax 0-basis) so wide-min-content surfaces
     like Asset detail and Create shrink to fit instead of overflowing + clipping the
     rail at narrow widths. Matches the .app / .asset base-rule idiom. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
}

.topbar {
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--chrome-border);
  background: var(--chrome);
}
.topbar__lead { display: flex; align-items: center; gap: var(--space-3); min-width: 0; flex: 1 1 auto; }
.topbar__title { font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.02em; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.crumb { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.crumb__sep { color: var(--text-muted); }
.crumb__root { color: var(--text-muted); font-size: var(--fs-body); font-weight: 400; }
@media (hover: hover) { .crumb__root:hover { color: var(--text-secondary); } }

.topbar .menu-btn { display: none; }

/* Top-right cluster: per-route actions + wallet pill + account button */
.topbar__right { display: flex; align-items: center; gap: var(--space-2); flex: none; }

/* Wallet pill — glanceable balance; low/empty states shift tone, never shout */
.wallet-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px 0 10px;
  border: 1px solid var(--border-input); border-radius: var(--radius-pill);
  background: var(--surface-1); cursor: pointer;
  transition: background var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.wallet-pill .icon { color: var(--text-muted); }
.wallet-pill__num { font-size: var(--fs-label); font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
@media (hover: hover) { .wallet-pill:hover { background: var(--surface-2); border-color: var(--border-strong); } }
.wallet-pill:active { transform: scale(0.97); }
.wallet-pill.is-low { border-color: color-mix(in oklab, var(--warning-text) 40%, var(--border-input)); }
.wallet-pill.is-low .icon, .wallet-pill.is-low .wallet-pill__num { color: var(--warning-text); }
.wallet-pill.is-empty { border-color: color-mix(in oklab, var(--danger-text) 45%, var(--border-input)); }
.wallet-pill.is-empty .icon, .wallet-pill.is-empty .wallet-pill__num { color: var(--danger-text); }

/* Account button — round avatar + chevron */
.acct-btn {
  display: inline-flex; align-items: center; gap: 3px; height: 32px; padding: 2px 5px 2px 2px;
  border: 1px solid transparent; border-radius: var(--radius-pill); background: none; cursor: pointer;
  color: var(--text-muted); transition: background var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
@media (hover: hover) { .acct-btn:hover { background: var(--surface-2); } }
.acct-btn[aria-expanded="true"] { background: var(--surface-2); }
.acct-btn:active { transform: scale(0.97); }

/* Wallet popover (inside .menu--panel): balance header + spend deltas */
.menu--wallet { min-width: 264px; }
.wallet-pop { padding: 6px 10px 8px; }
.wallet-pop__bal { font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; color: var(--text); }
.wallet-pop__unit { display: flex; align-items: center; gap: 8px; font-size: var(--fs-caption); color: var(--text-muted); margin-top: 3px; }
.wallet-pop__flag { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: var(--radius-pill); font-size: var(--fs-eyebrow); font-weight: 600; }
.wallet-pop__flag.is-low { color: var(--warning-text); background: color-mix(in oklab, var(--warning-fill) 20%, transparent); }
.wallet-pop__flag.is-empty { color: var(--danger-text); background: color-mix(in oklab, var(--danger-fill) 16%, transparent); }
.wallet-pop__delta { margin-left: auto; font-size: var(--fs-label); font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Buy-credits packs (modal) */
.modal--packs { max-width: 560px; }
.packs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-5); }
.pack {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--space-5) var(--space-3) var(--space-4); text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); cursor: not-allowed;
}
.pack.is-popular { border-color: var(--accent); }
.pack__tag {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 2px 8px; border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-eyebrow); font-weight: 600;
}
.pack__credits { font-size: var(--fs-heading); font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.pack__unit { font-size: var(--fs-caption); color: var(--text-muted); }
.pack__price { margin-top: 6px; font-size: var(--fs-body-lg); font-weight: 600; color: var(--text); }
.pack__cta { display: inline-flex; align-items: center; gap: 5px; margin-top: var(--space-3); font-size: var(--fs-label); font-weight: 500; color: var(--text-muted); }
.pack__cta .icon { color: var(--text-muted); }
.buy-note { display: flex; align-items: center; gap: 8px; margin-top: var(--space-4); font-size: var(--fs-caption); color: var(--text-muted); }
.buy-note .icon { flex: none; }
@media (max-width: 560px) { .packs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.view { grid-row: 2; overflow-y: auto; overflow-x: clip; }
.page { max-width: var(--content-max); margin-inline: auto; padding: var(--space-8) var(--space-6) var(--space-16); }
.page--narrow { max-width: 720px; }

/* ============================================================================
   BUTTONS
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body); font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out), opacity var(--dur-micro) var(--ease-out);
  user-select: none;
}
.btn .icon { opacity: .95; }
.btn:active { transform: scale(0.97); }

.btn--primary { background: var(--accent); color: var(--on-accent); }
@media (hover: hover) { .btn--primary:hover { background: var(--accent-hover); } }

.btn--secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
@media (hover: hover) { .btn--secondary:hover { border-color: var(--border-strong); background: color-mix(in oklab, var(--surface-2) 60%, var(--surface-1)); } }

.btn--ghost { background: transparent; color: var(--text-secondary); }
@media (hover: hover) { .btn--ghost:hover { background: var(--surface-2); color: var(--text); } }

.btn--danger { background: transparent; color: var(--danger-text); }
@media (hover: hover) { .btn--danger:hover { background: color-mix(in oklab, var(--danger-fill) 12%, transparent); } }
.btn--danger-solid { background: var(--danger-fill); color: var(--danger-on); }

.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn:disabled:active, .btn[aria-disabled="true"]:active { transform: none; }
.btn--block { width: 100%; }
.btn--sm { height: 30px; padding: 0 10px; font-size: var(--fs-label); }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--on-accent); opacity: .9;
  animation: spin .7s linear infinite;
}
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after { color: var(--text-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* icon button — 32 visual, 44 hit */
.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  color: var(--text-secondary); background: transparent;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.icon-btn::after { content: ""; position: absolute; inset: -6px; }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); color: var(--text); } }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-on { color: var(--accent-text); background: var(--accent-tint); }

/* ============================================================================
   SEGMENTED CONTROL
   ========================================================================== */
.segmented {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface-2); border-radius: var(--radius-pill);
  padding: 2px;
}
.segmented__item {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 12px; border-radius: var(--radius-pill);
  color: var(--text-secondary); font-size: var(--fs-label); font-weight: 500; white-space: nowrap;
  transition: color var(--dur-micro) var(--ease-out);
}
.segmented__item.is-active { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-lift); }
@media (hover: hover) { .segmented__item:not(.is-active):hover { color: var(--text); } }
.segmented--icons .segmented__item { width: 30px; padding: 0; }

/* ============================================================================
   TABS
   ========================================================================== */
.tabs { display: flex; align-items: center; gap: var(--space-5); border-bottom: 1px solid var(--border); }
.tab {
  position: relative; height: 40px; display: inline-flex; align-items: center;
  color: var(--text-secondary); font-size: var(--fs-body); font-weight: 500; white-space: nowrap;
}
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.tab.is-active { color: var(--text); }
.tab.is-active::after { background: var(--accent); }
@media (hover: hover) { .tab:not(.is-active):hover { color: var(--text); } }

/* ============================================================================
   FORM CONTROLS
   ========================================================================== */
.field { display: grid; gap: 6px; }
.field__label { font-size: var(--fs-label); font-weight: 500; color: var(--text-secondary); }
.field__help { font-size: var(--fs-caption); color: var(--text-muted); min-height: 1lh; }
.field.is-error .field__help { color: var(--danger-text); }

.input, .textarea, .select {
  width: 100%; min-height: 36px;
  background: var(--surface-1); color: var(--text);
  border: 1px solid var(--border-input); border-radius: var(--radius-md);
  padding: 0 12px; font-size: var(--fs-body);
  transition: border-color var(--dur-micro) var(--ease-out);
}
.textarea { padding: 9px 12px; resize: vertical; line-height: 1.5; min-height: 84px; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.field.is-error .input, .field.is-error .textarea { border-color: var(--danger-fill); }

.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888e98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  cursor: pointer;
}

.search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: var(--surface-1); border: 1px solid var(--border-input); border-radius: var(--radius-md);
  color: var(--text-muted); min-width: 0;
  transition: border-color var(--dur-micro) var(--ease-out);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); color: var(--text-secondary); }
.search input { width: 100%; border: none; background: none; outline: none; color: var(--text); }
.search input::placeholder { color: var(--text-muted); }

/* choice chips (aspect, count, style) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--surface-1); border: 1px solid var(--border-input);
  color: var(--text-secondary); font-size: var(--fs-label); font-weight: 500; white-space: nowrap;
  transition: border-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
@media (hover: hover) { .chip:hover { border-color: var(--border-strong); color: var(--text); } }
.chip.is-active { background: var(--accent-tint); border-color: transparent; color: var(--accent-text); }
.chip .mono { font-size: 12px; }

/* toggle switch */
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch__track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-strong); transition: background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out); }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-secondary); transition: transform var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out); }
.switch input:checked ~ .switch__track { background: var(--accent); border-color: transparent; }
.switch input:checked ~ .switch__thumb { transform: translateX(16px); background: var(--on-accent); }
.switch input:focus-visible ~ .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ============================================================================
   CARDS
   ========================================================================== */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card--pad-lg { padding: var(--space-6); }
a.card, button.card { display: block; text-align: left; width: 100%; transition: border-color var(--dur-micro) var(--ease-out); }
@media (hover: hover) { a.card:hover, button.card:hover { border-color: var(--border-strong); } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.section-head__title { font-size: var(--fs-heading); font-weight: 600; letter-spacing: -0.015em; }
.link { color: var(--accent-text); font-size: var(--fs-label); font-weight: 500; }
@media (hover: hover) { .link:hover { text-decoration: underline; text-underline-offset: 2px; } }

/* ============================================================================
   STATUS PILL
   ========================================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: var(--radius-sm);
  font-size: var(--fs-caption); font-weight: 500; white-space: nowrap;
}
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill--running   { color: var(--accent-text); background: var(--accent-tint); }
.pill--running .pill__dot { background: var(--accent); animation: pulse 1.8s var(--ease-in-out) infinite; }
.pill--queued    { color: var(--text-secondary); background: var(--surface-2); }
.pill--completed { color: var(--success-text); background: color-mix(in oklab, var(--success-fill) 13%, transparent); }
.pill--failed    { color: var(--danger-text); background: color-mix(in oklab, var(--danger-fill) 13%, transparent); }
.pill--qa        { color: var(--warning-text); background: color-mix(in oklab, var(--warning-fill) 16%, transparent); }
/* Membership lifecycle (Feature 4) + approval workflow (grammar for Feature 5) */
.pill--active    { color: var(--success-text); background: color-mix(in oklab, var(--success-fill) 13%, transparent); }
.pill--active .pill__dot { animation: none; }
.pill--invited   { color: var(--text-secondary); background: var(--surface-2); }
.pill--expired   { color: var(--warning-text); background: color-mix(in oklab, var(--warning-fill) 16%, transparent); }
.pill--suspended { color: var(--text-muted); background: var(--surface-2); }
.pill--draft     { color: var(--text-secondary); background: var(--surface-2); }
.pill--in-review { color: var(--warning-text); background: color-mix(in oklab, var(--warning-fill) 16%, transparent); }
.pill--approved  { color: var(--success-text); background: color-mix(in oklab, var(--success-fill) 13%, transparent); }
.pill--changes   { color: var(--danger-text); background: color-mix(in oklab, var(--danger-fill) 13%, transparent); }

/* ============================================================================
   MEDIA TILE (placeholder motifs — flat, monochrome, honest)
   ========================================================================== */
.tile {
  position: relative; display: block; width: 100%;
  border-radius: var(--radius-md); overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: var(--ar, 1);
  transition: transform var(--dur-short) var(--ease-out);
}
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--tile-inset); pointer-events: none; }
.tile__ph { position: absolute; inset: 0; color: var(--text-muted); opacity: .55; }
.tile__ph svg { width: 100%; height: 100%; }
.tile__type { position: absolute; top: 8px; left: 8px; color: var(--text-secondary); opacity: .8; }
.tile__dur {
  position: absolute; bottom: 8px; right: 8px;
  font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums;
  background: rgb(0 0 0 / .55); color: #fff; padding: 1px 6px; border-radius: var(--radius-xs);
}
.tile__play { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgb(0 0 0 / .40); color: #fff; }

.tile__meta {
  position: absolute; inset: auto 0 0 0; padding: 22px 10px 9px;
  background: linear-gradient(to top, rgb(0 0 0 / .58), transparent);
  color: #fff; opacity: 0; transform: translateY(4px);
  transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
}
.tile__meta-title { font-size: var(--fs-label); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__meta-sub { font-family: var(--font-mono); font-size: 11px; opacity: .85; }
.tile__check {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: var(--radius-xs);
  background: rgb(0 0 0 / .35); border: 1.5px solid rgb(255 255 255 / .8);
  display: grid; place-items: center; color: #fff;
  opacity: 0; transition: opacity var(--dur-short) var(--ease-out); cursor: pointer;
}
.tile__check .icon { opacity: 0; }

.tile-card { display: grid; gap: 8px; }
.tile-wrap { position: relative; }
@media (hover: hover) and (pointer: fine) {
  .tile-wrap:hover .tile__meta { opacity: 1; transform: none; }
  .tile-wrap:hover .tile__check { opacity: 1; }
}
.tile-wrap.is-selected .tile__check { opacity: 1; background: var(--accent); border-color: var(--accent); }
.tile-wrap.is-selected .tile__check .icon { opacity: 1; }
.tile-wrap.is-selected .tile::after { box-shadow: inset 0 0 0 2px var(--accent); }
.tile-card__foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 2px; }
.tile-card__name { font-size: var(--fs-label); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-card__meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); flex: none; }

/* ============================================================================
   LIST / TABLE (jobs, etc.)
   ========================================================================== */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: var(--space-2) var(--space-1); border-top: 1px solid var(--border); }
.row:first-child { border-top: none; }

/* ============================================================================
   JOBS
   ========================================================================== */
.jobgroup { margin-top: var(--space-6); }
.jobgroup:first-child { margin-top: 0; }
.jobgroup__head {
  position: sticky; top: 0; z-index: var(--z-raised);
  display: flex; align-items: center; gap: 8px;
  padding: var(--space-2) var(--space-1); margin-bottom: var(--space-1);
  background: var(--bg);
}
.jobgroup__head .t-eyebrow { color: var(--text-secondary); }
.jobgroup__count { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--text-muted); }

.job {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto auto;
  align-items: center; gap: var(--space-4);
  min-height: 60px; padding: var(--space-2) var(--space-2);
  border-top: 1px solid var(--border);
}
.job:first-child { border-top: none; }
.job__thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); position: relative; }
.job__thumb::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px var(--tile-inset); border-radius: inherit; }
.job__main { min-width: 0; display: grid; gap: 3px; }
.job__title { font-size: var(--fs-body); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job__sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); display: flex; gap: 10px; }
.job__dest { color: var(--text-muted); font-size: var(--fs-caption); white-space: nowrap; }
.job__actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.job__error { color: var(--danger-text); font-size: var(--fs-caption); }

.progress { width: 140px; }
.progress__bar { height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress__fill { height: 100%; width: 100%; transform-origin: left center; transform: scaleX(0); background: var(--accent); border-radius: inherit; transition: transform var(--dur-base) linear; }
.progress__fill--indet { width: 40%; transform: none; animation: indet 1.15s var(--ease-in-out) infinite; }
@keyframes indet { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
.progress__label { margin-top: 5px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }

/* ============================================================================
   HOME
   ========================================================================== */
.greeting { margin-bottom: var(--space-8); }
.greeting__hi { font-size: var(--fs-display); font-weight: 600; letter-spacing: -0.02em; }
.greeting__sub { color: var(--text-secondary); font-size: var(--fs-body-lg); margin-top: 4px; }

.start {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-1); padding: var(--space-6);
  display: grid; gap: var(--space-5); margin-bottom: var(--space-10);
}
.start__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.modes { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mode {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--surface-1); border: 1px solid var(--border-input);
  color: var(--text); font-size: var(--fs-label); font-weight: 500; white-space: nowrap;
  transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.mode .icon { color: var(--text-secondary); }
@media (hover: hover) { .mode:hover { border-color: var(--border-strong); background: var(--surface-2); } }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8); }
.resume-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 232px; gap: var(--space-3);
  overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: var(--space-2);
  margin: 0 calc(-1 * var(--space-1)); padding-inline: var(--space-1);
}
.resume-row > * { scroll-snap-align: start; }
.resume-card { display: grid; gap: 10px; }
.resume-card .tile { aspect-ratio: 16/10; }
.resume-card__title { font-size: var(--fs-label); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-card__meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.glance-list { display: flex; flex-direction: column; }
.glance {
  display: grid; grid-template-columns: 32px minmax(0,1fr) auto; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-1); border-top: 1px solid var(--border);
}
.glance:first-child { border-top: none; }
.glance__thumb { width: 32px; height: 32px; border-radius: var(--radius-xs); overflow: hidden; background: var(--surface-2); position: relative; }
.glance__thumb::after { content:""; position:absolute; inset:0; box-shadow: inset 0 0 0 1px var(--tile-inset); border-radius: inherit; }
.glance__main { min-width: 0; }
.glance__title { font-size: var(--fs-label); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.glance__sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }

/* first-run "how it works" primer (Home zero-state) — reuses .card */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.step { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); align-items: start; }
.step__icon { color: var(--accent-text); margin-top: 1px; }
@media (max-width: 768px) { .steps { grid-template-columns: 1fr; } }

/* ============================================================================
   CREATE — three-pane workspace
   ========================================================================== */
.create { display: grid; grid-template-columns: 320px minmax(0, 1fr) 280px; height: calc(100dvh - var(--topbar-h)); }
.create__rail { border-right: 1px solid var(--border); min-height: 0; min-width: 0; display: grid; grid-template-rows: 1fr auto; }
.create__rail-scroll { overflow-y: auto; overflow-x: hidden; padding: var(--space-5); display: grid; gap: var(--space-5); align-content: start; min-width: 0; }
.create__rail-scroll > * { min-width: 0; }

.segmented--fill { display: flex; width: 100%; }
.segmented--fill .segmented__item { flex: 1 1 0; min-width: 0; padding: 0; }
.mode-caption { font-size: var(--fs-caption); color: var(--text-muted); margin-top: -8px; }
.mode-caption b { color: var(--text-secondary); font-weight: 500; }
.create__generate { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); background: var(--bg); }
/* Feature 6 — per-run cost row + calm out-of-credits / daily-limit notice above Generate */
.gen-cost { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-3); font-size: var(--fs-caption); }
.gen-cost__label { color: var(--text-muted); margin-right: auto; }
.gen-cost__amt { color: var(--text-secondary); }
.gen-cost__amt .mono { color: var(--text); font-weight: 500; }
.gen-cost__bal { color: var(--warning-text); }
.gen-notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
.gen-notice__icon { flex: none; margin-top: 1px; color: var(--text-secondary); display: inline-flex; }
.gen-notice__body { display: grid; gap: 4px; min-width: 0; }
.gen-notice__reason { font-size: var(--fs-label); color: var(--text-secondary); line-height: 1.45; }
.gen-notice__action { justify-self: start; display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-label); font-weight: 500; color: var(--accent-text); }
@media (hover: hover) { .gen-notice__action:hover { text-decoration: underline; text-underline-offset: 2px; } }

.field-group { display: grid; gap: 8px; }
.disclosure > summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  font-size: var(--fs-label); font-weight: 500; color: var(--text-secondary); padding: 4px 0;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary .chev { transition: transform var(--dur-short) var(--ease-out); color: var(--text-muted); }
.disclosure[open] > summary .chev { transform: rotate(90deg); }
.disclosure__body { display: grid; gap: var(--space-4); padding-top: var(--space-3); }

.dropzone {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
  padding: var(--space-3); display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-tint); }
.ref-thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); background: var(--surface-2); position: relative; overflow: hidden; }
.ref-thumb::after { content:""; position:absolute; inset:0; box-shadow: inset 0 0 0 1px var(--tile-inset); border-radius: inherit; }
.ref-thumb__x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-secondary); display: grid; place-items: center; box-shadow: var(--shadow-lift); }
.ref-add {
  width: 56px; height: 56px; border-radius: var(--radius-sm); border: 1px dashed var(--border-strong);
  display: grid; place-items: center; color: var(--text-muted);
  transition: border-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
@media (hover: hover) { .ref-add:hover { border-color: var(--accent); color: var(--accent-text); } }
.dropzone__hint { font-size: var(--fs-caption); color: var(--text-muted); flex: 1 1 120px; }

.modelpick { display: grid; gap: 6px; }
.model-opt {
  display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-input);
  background: var(--surface-1); text-align: left; width: 100%;
  transition: border-color var(--dur-micro) var(--ease-out);
}
@media (hover: hover) { .model-opt:hover { border-color: var(--border-strong); } }
.model-opt.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.model-opt__radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); position: relative; }
.model-opt.is-active .model-opt__radio { border-color: var(--accent); }
.model-opt.is-active .model-opt__radio::after { content:""; position:absolute; inset:3px; border-radius:50%; background: var(--accent); }
.model-opt__name { font-size: var(--fs-label); font-weight: 500; }
.model-opt__specs { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.model-opt__cost { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }

.create__stage { min-width: 0; overflow-y: auto; display: grid; place-items: center; padding: var(--space-6); background:
  radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 22px 22px; background-attachment: local; }
.stage-frame {
  position: relative; max-width: min(100%, 640px); width: 100%;
  aspect-ratio: var(--ar, 1); border-radius: var(--radius-md);
  background: var(--surface-1); border: 1px solid var(--border);
  display: grid; place-items: center; overflow: hidden;
}
.stage-frame::after { content:""; position:absolute; inset:0; box-shadow: inset 0 0 0 1px var(--tile-inset); border-radius: inherit; pointer-events: none; }
.stage-empty { text-align: center; padding: var(--space-8); display: grid; gap: var(--space-5); place-items: center; max-width: 420px; }
.stage-empty__icon { width: 44px; height: 44px; color: var(--text-muted); }
.prompt-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.create__variations { border-left: 1px solid var(--border); overflow-y: auto; padding: var(--space-4); display: grid; gap: var(--space-3); align-content: start; }
.var-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 2px; }
.var-card { position: relative; border-radius: var(--radius-md); overflow: hidden; border: 1px solid transparent; cursor: pointer; }
.var-card .tile { border-radius: 0; }
.var-card.is-active { box-shadow: 0 0 0 2px var(--accent); }
.var-card__bar { position: absolute; inset: auto 0 0 0; display: flex; gap: 2px; padding: 6px; background: linear-gradient(to top, rgb(0 0 0 /.55), transparent); opacity: 0; transition: opacity var(--dur-short) var(--ease-out); }
@media (hover: hover) { .var-card:hover .var-card__bar { opacity: 1; } }
.var-card__btn { flex: 1; height: 26px; border-radius: var(--radius-xs); background: rgb(255 255 255 / .16); color: #fff; font-size: 11px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
@media (hover: hover) { .var-card__btn:hover { background: rgb(255 255 255 / .28); } }
.var-fail { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); display: grid; gap: 10px; text-align: center; place-items: center; }

/* ============================================================================
   LIBRARY
   ========================================================================== */
.library { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.facets { display: grid; gap: var(--space-5); position: sticky; top: var(--space-4); }
.facet-group { display: grid; gap: 2px; }
.facet {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--fs-label); width: 100%; text-align: left;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.facet .facet__label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet .facet__count { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .facet:hover { background: var(--surface-2); color: var(--text); } }
.facet.is-active { background: var(--accent-tint); color: var(--accent-text); }
.facet.is-active .facet__count { color: var(--accent-text); }

.lib-toolbar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.lib-toolbar .search { flex: 1 1 auto; max-width: 360px; }
.lib-toolbar__spacer { flex: 1 1 auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4); }
.grid.is-compact { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--space-3); }

.batchbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}
.batchbar__count { font-size: var(--fs-label); font-weight: 500; }
.batchbar__spacer { flex: 1 1 auto; }

/* ============================================================================
   ASSET DETAIL
   ========================================================================== */
.asset { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; height: calc(100dvh - var(--topbar-h)); }
.asset__stage {
  min-width: 0; display: grid; place-items: center; padding: var(--space-8); overflow: auto;
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface-1) 0% 50%) 0 0 / 24px 24px;
}
.asset__frame { position: relative; max-width: min(100%, 720px); width: 100%; aspect-ratio: var(--ar, 1); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-overlay); }
.asset__frame .tile { border-radius: var(--radius-md); }
.asset__rail { border-left: 1px solid var(--border); overflow-y: auto; padding: var(--space-6); display: grid; gap: var(--space-6); align-content: start; }


.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-4); font-size: var(--fs-label); }
.kv dt { color: var(--text-muted); }
.kv dd { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }

.prompt-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--fs-body); line-height: 1.5; color: var(--text-secondary); position: relative; }
.prompt-box__copy { position: absolute; top: 8px; right: 8px; }

.versions { display: grid; gap: 2px; }
.version {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm); text-align: left; width: 100%;
  transition: background-color var(--dur-micro) var(--ease-out);
}
@media (hover: hover) { .version:hover { background: var(--surface-2); } }
.version.is-active { background: var(--accent-tint); }
.version__thumb { width: 36px; height: 36px; border-radius: var(--radius-xs); overflow: hidden; background: var(--surface-2); position: relative; }
.version__thumb::after { content:""; position:absolute; inset:0; box-shadow: inset 0 0 0 1px var(--tile-inset); border-radius: inherit; }
.version__name { font-size: var(--fs-label); font-weight: 500; }
.version.is-active .version__name { color: var(--accent-text); }
.version__meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.version__tag { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.action-list { display: grid; gap: 2px; }
.action-row {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--fs-label); font-weight: 500; width: 100%; text-align: left;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.action-row .icon { color: var(--text-secondary); }
@media (hover: hover) { .action-row:hover { background: var(--surface-2); } }
.action-row--primary { background: var(--accent); color: var(--on-accent); }
.action-row--primary .icon { color: var(--on-accent); }
@media (hover: hover) { .action-row--primary:hover { background: var(--accent-hover); } }
.action-row--danger { color: var(--danger-text); }
.action-row--danger .icon { color: var(--danger-text); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); width: 100%; max-width: 980px; }
.compare figure { display: grid; gap: 8px; }
.compare figcaption { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); text-align: center; }

/* ============================================================================
   SETTINGS
   ========================================================================== */
.settings { display: grid; gap: var(--space-5); }
.set-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.set-card__head { padding: var(--space-5) var(--space-6) 0; }
.set-card__title { font-size: var(--fs-subhead); font-weight: 600; }
.set-card__desc { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 3px; }
.set-card__body { padding: var(--space-5) var(--space-6); display: grid; gap: var(--space-5); }
.set-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-4); }
.set-row__label { font-size: var(--fs-label); font-weight: 500; }
.set-row__desc { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 2px; max-width: 42ch; }
.set-row__control { justify-self: end; }
.set-divide { height: 1px; background: var(--border); margin: 0 calc(-1 * var(--space-6)); }

.accent-swatches { display: flex; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; position: relative; border: 1px solid var(--border); display: grid; place-items: center; }
.swatch__dot { width: 20px; height: 20px; border-radius: 50%; }
.swatch.is-active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.swatch .icon { position: absolute; color: #fff; opacity: 0; }
.swatch.is-active .icon { opacity: 1; }

.mark-upload { display: flex; align-items: center; gap: var(--space-3); }
.brand-mood { display: flex; align-items: center; gap: var(--space-2); }
.mark-preview { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--accent-text); overflow: hidden; }
.mark-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================================
   ADMIN — billing & credits (balance metric, usage ledger, spend caps, invoices)
   ========================================================================== */
.admin { display: grid; gap: var(--space-5); max-width: 1040px; margin-inline: auto; }

/* Balance hero */
.balance-card { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.balance { display: grid; gap: 8px; min-width: 0; }
.balance__value { font-size: var(--fs-display); font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.balance__unit { font-family: var(--font-sans); font-size: var(--fs-body); font-weight: 500; color: var(--text-muted); letter-spacing: normal; }
.balance__flag { display: flex; align-items: center; gap: 10px; font-size: var(--fs-label); flex-wrap: wrap; }
.balance__side { display: grid; gap: 8px; justify-items: end; align-content: end; }
.balance__note { font-size: var(--fs-caption); }

/* Usage ledger — grid table, tabular-nums, no zebra (matches the shell's table grammar) */
.ledger { min-width: 0; }
.ledger__head, .ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px 100px 104px 116px;
  align-items: center;
  gap: var(--space-4);
}
.ledger__head {
  padding-bottom: var(--space-2); border-bottom: 1px solid var(--border);
  font-size: var(--fs-eyebrow); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted);
}
.ledger__head span:nth-child(4), .ledger__head span:nth-child(5) { text-align: right; }
.ledger-row { min-height: 48px; padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.ledger-row:first-of-type { border-top: none; }
.ledger__activity { min-width: 0; }
.ledger__reason { font-size: var(--fs-body); font-weight: 500; }
.ledger__submeta { display: none; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ledger__model { font-size: var(--fs-label); color: var(--text-secondary); min-width: 0; }
.ledger__when { font-size: 12px; color: var(--text-muted); }
.ledger__amt { font-size: 13px; text-align: right; justify-self: end; color: var(--text); }
.ledger__amt.is-credit { color: var(--success-text); }
.ledger__bal { font-size: 12px; color: var(--text-muted); text-align: right; justify-self: end; }

/* Spend caps control */
.cap-control { display: flex; align-items: center; gap: var(--space-3); }
.cap-value { font-size: 13px; color: var(--text-secondary); }

/* Invoices */
.invoices { min-width: 0; }
.invoice { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3) var(--space-4); min-height: 56px; padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.invoice:first-of-type { border-top: none; }
.invoice__icon { color: var(--text-secondary); display: flex; }
.invoice__main { min-width: 0; }
.invoice__title { font-size: var(--fs-body); font-weight: 500; }
.invoice__meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Top-up modal summary */
.tu-summary { margin-top: var(--space-4); font-size: var(--fs-label); color: var(--text-secondary); }

@media (max-width: 560px) {
  .ledger__head { display: none; }
  .ledger-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--space-3); }
  .ledger__model, .ledger__when, .ledger__bal { display: none; }
  .ledger__submeta { display: block; }
  .ledger__amt { align-self: center; }
  .balance-card { align-items: flex-start; }
  .balance__side { justify-items: start; }
}

/* ============================================================================
   MEMBERS & SEATS (Feature 4) — seat meter, roster table, invite modal
   Reuses card / progress / pill / menu / modal / chip / select grammar. Both themes.
   ========================================================================== */
.members { display: grid; gap: var(--space-5); max-width: 1040px; margin-inline: auto; }

/* Seat-usage header: determinate meter + Invite */
.seat-card { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.seat { display: grid; gap: 8px; min-width: 0; }
.seat__count { font-size: var(--fs-heading); font-weight: 600; letter-spacing: -0.01em; }
.seat__meter { width: min(280px, 60vw); }
.seat__note { font-size: var(--fs-caption); max-width: 46ch; }
.seat-card__side { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* Roster table — grid rows, hairline separators, no zebra (the shell table grammar) */
.mtable { min-width: 0; }
.mtable__head, .mrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px 108px 116px 132px 36px;
  align-items: center; gap: var(--space-4);
}
.mtable__head {
  padding-bottom: var(--space-2); border-bottom: 1px solid var(--border);
  font-size: var(--fs-eyebrow); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted);
}
.mrow { min-height: 60px; padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.mrow:first-of-type { border-top: none; }
.mcell { min-width: 0; }
.mcell--who { display: flex; align-items: center; gap: var(--space-3); }
.who { min-width: 0; display: grid; gap: 1px; }
.who__name { font-size: var(--fs-body); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.who__you {
  font-size: var(--fs-eyebrow); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 0 5px; height: 16px; display: inline-flex; align-items: center; flex: none;
}
.who__email { font-size: var(--fs-caption); color: var(--text-muted); }
.mrow__submeta { display: none; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.mcell--menu { justify-self: end; }
.seat-tag { font-size: var(--fs-caption); color: var(--text-secondary); white-space: nowrap; }
.seat-tag--free { color: var(--text-muted); }

/* Compact select for inline role change */
.select--sm { height: 30px; min-height: 30px; padding: 0 30px 0 10px; font-size: var(--fs-label); border-radius: var(--radius-sm); background-position: right 9px center; max-width: 100%; }

/* Static (non-interactive) capability chip */
.chip--static { cursor: default; background: var(--surface-2); border-color: transparent; color: var(--text-secondary); }
@media (hover: hover) { .chip--static:hover { border-color: transparent; color: var(--text-secondary); } }

/* Invite modal — email token input, permission preview, seat-impact + upsell */
.token-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 5px 8px;
  background: var(--surface-1); border: 1px solid var(--border-input); border-radius: var(--radius-md);
  transition: border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out);
}
.token-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.token-input.is-error { border-color: var(--danger-fill); }
.token-input.is-error ~ .field__help { color: var(--danger-text); }
.token-input__field { flex: 1 1 140px; min-width: 140px; border: none; background: none; outline: none; color: var(--text); font-size: var(--fs-body); height: 26px; }
.token-input__field::placeholder { color: var(--text-muted); }
.token { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: var(--radius-sm); background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-label); font-weight: 500; max-width: 100%; }
.token__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token__x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: var(--radius-xs); color: currentColor; opacity: .7; flex: none; }
@media (hover: hover) { .token__x:hover { opacity: 1; background: color-mix(in oklab, var(--accent) 18%, transparent); } }

.invite-perms { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
.invite-impact { margin-top: var(--space-4); display: grid; gap: var(--space-3); }
.invite-impact__line { display: flex; align-items: center; gap: 8px; font-size: var(--fs-label); color: var(--text-secondary); }
.invite-impact__line.is-over { color: var(--danger-text); }
.invite-impact__line .icon { flex: none; color: currentColor; }
.invite-impact__free { display: inline-flex; align-items: center; gap: 4px; color: var(--success-text); font-weight: 500; }
.invite-impact__free .icon { color: currentColor; }
.invite-upsell { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-3) var(--space-4); background: var(--surface-2); border-radius: var(--radius-md); font-size: var(--fs-label); }
.invite-upsell .muted { flex: 1 1 200px; min-width: 0; }
.invite-upsell__actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }

@media (max-width: 620px) {
  .mtable__head { display: none; }
  .mrow { grid-template-columns: minmax(0, 1fr) 36px; gap: var(--space-3); align-items: start; }
  .mcell--role, .mcell--status, .mcell--when, .mcell--seat { display: none; }
  .mrow__submeta { display: flex; }
  .mcell--who { align-items: flex-start; }
  .mcell--menu { align-self: center; }
}

/* ============================================================================
   STATES: empty, error, loading skeleton
   ========================================================================== */
.state { display: grid; place-items: center; gap: var(--space-4); text-align: center; padding: var(--space-16) var(--space-6); }
.state__icon { width: 40px; height: 40px; color: var(--text-muted); }
.state__title { font-size: var(--fs-subhead); font-weight: 600; }
.state__msg { font-size: var(--fs-body); color: var(--text-secondary); max-width: 40ch; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-xs); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--surface-3) 70%, transparent), transparent);
  transform: translateX(-100%); animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; border-radius: 999px; }
.sk-tile { aspect-ratio: 1; border-radius: var(--radius-md); }

/* ============================================================================
   TOASTS
   ========================================================================== */
.toasts { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: var(--z-toast); display: grid; gap: var(--space-2); width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay); padding: 12px 12px 12px 14px; font-size: var(--fs-body);
  animation: toast-in var(--dur-short) var(--ease-out);
}
.toast.is-out { animation: toast-out var(--dur-short) var(--ease-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.toast__icon { margin-top: 1px; color: var(--text-secondary); }
.toast__icon.is-success { color: var(--success-text); }
.toast__icon.is-error { color: var(--danger-text); }
.toast__body { flex: 1 1 auto; min-width: 0; }
.toast__msg { color: var(--text); }
.toast__sub { color: var(--text-muted); font-size: var(--fs-caption); margin-top: 1px; }
.toast__undo { flex: none; color: var(--accent-text); font-weight: 500; font-size: var(--fs-label); padding: 2px 6px; border-radius: var(--radius-xs); }
@media (hover: hover) { .toast__undo:hover { background: var(--accent-tint); } }

/* ============================================================================
   OVERLAYS: scrim / menu / dialog / cmdk
   ========================================================================== */
.scrim { position: fixed; inset: 0; z-index: calc(var(--z-modal) - 1); background: var(--scrim); }

.menu {
  position: fixed; z-index: var(--z-dropdown); min-width: 180px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay); padding: 5px;
  animation: menu-in var(--dur-micro) var(--ease-out); transform-origin: var(--origin, top right);
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.96); } }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm); color: var(--text); font-size: var(--fs-label); font-weight: 500; text-align: left;
}
.menu__item .icon { color: var(--text-secondary); }
@media (hover: hover) { .menu__item:hover { background: var(--surface-2); } }
.menu__item.is-danger { color: var(--danger-text); }
.menu__item.is-danger .icon { color: var(--danger-text); }
.menu__sep { height: 1px; background: var(--border); margin: 5px -5px; }

dialog {
  border: none; padding: 0; background: transparent; color: inherit;
  max-height: 100dvh;
}
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.modal {
  width: min(520px, calc(100vw - 32px));
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-overlay); padding: var(--space-6);
  margin: auto;
}
dialog[open].modal, dialog[open].cmdk { animation: modal-in var(--dur-base) var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: scale(0.96); } }
.modal__title { font-size: var(--fs-heading); font-weight: 600; }
.modal__desc { color: var(--text-secondary); margin-top: 6px; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6); }

.cmdk {
  width: min(560px, calc(100vw - 32px));
  margin: 12vh auto auto;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay); overflow: hidden;
}
.cmdk__search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.cmdk__search input { flex: 1; border: none; background: none; outline: none; font-size: var(--fs-body-lg); color: var(--text); }
.cmdk__list { max-height: 340px; overflow-y: auto; padding: 6px; }
.cmdk__empty { padding: 28px; text-align: center; color: var(--text-muted); font-size: var(--fs-body); }
.cmdk__group-label { padding: 10px 10px 4px; }
.cmdk__item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--text); font-size: var(--fs-body); width: 100%; text-align: left; }
.cmdk__item .icon { color: var(--text-secondary); }
.cmdk__item.is-active { background: var(--surface-2); }
.cmdk__item kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 1px 6px;
}

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1120px) {
  .create { grid-template-columns: 300px minmax(0,1fr); }
  .create__variations { display: none; }
  .home-grid { grid-template-columns: 1fr; }
  .asset { grid-template-columns: minmax(0,1fr) 320px; }
}

/* Tablet — icon rail */
@media (max-width: 768px) {
  .app { grid-template-columns: var(--rail-w) 1fr; }
  .brand { justify-content: center; padding: 0; }
  .brand__name { display: none; }
  .nav__item { justify-content: center; padding: 0; gap: 0; position: relative; }
  .nav__item .nav__label { display: none; }
  .nav__section { height: 1px; margin: 8px 14px; padding: 0; background: var(--chrome-border); overflow: hidden; text-indent: -9999px; }
  .nav__badge { position: absolute; top: 4px; right: 10px; min-width: 8px; height: 8px; padding: 0; font-size: 0; border-radius: 50%; }
  .spine { padding: var(--space-2); }
  .spine__row { justify-content: center; padding: 0; }
  .spine__label, .spine__count { display: none; }
  .topbar { padding: 0 var(--space-5); }
  .page { padding: var(--space-6) var(--space-5) var(--space-16); }

  .library { grid-template-columns: 1fr; }
  .facets { display: none; }
  .asset { grid-template-columns: 1fr; height: auto; }
  .asset__stage { min-height: 44dvh; }
  .asset__rail { border-left: none; border-top: 1px solid var(--border); }
  .create { grid-template-columns: 260px minmax(0,1fr); }
  .mini-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Phone — drawer */
@media (max-width: 560px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: var(--z-modal); left: 0; top: 0; width: 264px; max-width: 84vw;
    transform: translateX(-100%); transition: transform var(--dur-base) var(--ease-out);
    box-shadow: var(--shadow-overlay);
  }
  body.drawer-open .sidebar { transform: none; }
  .brand { justify-content: flex-start; padding: 0 var(--space-3); }
  .brand__name { display: block; }
  .nav__item { justify-content: flex-start; padding: 0 10px; gap: 10px; }
  .nav__item .nav__label { display: block; }
  .nav__section { text-align: left; }
  .nav__section .t-eyebrow { font-size: var(--fs-eyebrow); }
  .nav__section .t-eyebrow::after { content: ""; }
  .spine { padding: var(--space-3); }
  .spine__row { justify-content: flex-start; padding: 0 10px; }
  .spine__label, .spine__count { display: inline; }

  .content { grid-column: 1; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
  .topbar__title { font-size: var(--fs-heading); }
  .page { padding: var(--space-5) var(--space-4) var(--space-16); }

  .home-grid { grid-template-columns: 1fr; }
  .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .grid.is-compact { grid-template-columns: repeat(2, 1fr); }
  .lib-toolbar { flex-wrap: wrap; }
  .lib-toolbar .search { max-width: none; order: -1; flex-basis: 100%; }

  .create { display: block; height: auto; }
  .create__rail { border-right: none; display: block; }
  .create__rail-scroll { padding: var(--space-4); }
  .create__stage { min-height: 52dvh; padding: var(--space-4); }
  .create__generate { position: sticky; bottom: 0; }

  .compare { grid-template-columns: 1fr; }
  .toasts { right: var(--space-4); left: var(--space-4); bottom: var(--space-4); width: auto; }
  .set-row { grid-template-columns: 1fr; }
  .set-row__control { justify-self: start; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .spine.is-live .spine__dot, .pill--running .pill__dot { animation: none; }
  .toast { animation: none; }
}
/* ── critique fixes (2026-07-15) · confirmed-safe from hallmark/pro-max/apple-lens ── */
.spine__row.is-active { background: var(--accent-tint); color: var(--accent-text); }
@media (max-width: 560px) {
  .hide-phone { display: none; }
  /* Jobs row reflows to a stacked card instead of crushing the title to 0px + clipping actions */
  .job { grid-template-columns: 40px minmax(0, 1fr); grid-auto-rows: auto; row-gap: var(--space-2); column-gap: var(--space-3); align-items: start; }
  .job > :nth-child(n+3) { grid-column: 2; }
  .job__actions { justify-content: flex-start; flex-wrap: wrap; }
  .progress { width: 100%; }
  /* keep the theme switcher reachable: title truncates before actions clip */
  .topbar { gap: var(--space-2); }
  .topbar__lead { min-width: 0; }
  .topbar__actions { flex: 0 0 auto; }
}

/* ============================================================================
   FEATURE 3 — WORKSPACE SWITCHER + USER CHIP (mock tenancy identity)
   Reuses the .menu overlay grammar, one accent, hairline borders. Both themes.
   ========================================================================== */

/* Workspace monogram (mark) + round initials avatar (user) — both flex-none */
.ws-mark {
  width: 22px; height: 22px; flex: none; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-secondary);
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 600; line-height: 1;
}
.ws-mark--brand { width: 100%; height: 100%; background: var(--accent-tint); color: var(--accent-text); }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent-text);
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 600; line-height: 1;
}

/* Role badge — a hairline chip so it reads on any row/surface tone, both themes */
.role-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  font-size: var(--fs-eyebrow); font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; letter-spacing: normal; text-transform: none;
}

/* Brand block as a switcher trigger (keeps the .brand lockup; adds hover + chevron) */
.brand--switch { width: 100%; text-align: left; }
@media (hover: hover) { .brand--switch:hover { background: var(--surface-2); } }
.brand__chev { margin-left: auto; color: var(--text-muted); display: inline-flex; flex: none; }
.brand--switch[aria-expanded="true"] { background: var(--surface-2); }
.brand--switch[aria-expanded="true"] .brand__chev { color: var(--text-secondary); }

/* User chip — bottom of the sidebar */
.usermenu { border-top: 1px solid var(--border); padding: var(--space-2) var(--space-3); }
.userchip {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; padding: 6px 8px; border-radius: var(--radius-sm); text-align: left;
  transition: background-color var(--dur-micro) var(--ease-out);
}
@media (hover: hover) { .userchip:hover { background: var(--surface-2); } }
.userchip[aria-expanded="true"] { background: var(--surface-2); }
.userchip__main { min-width: 0; display: grid; gap: 4px; justify-items: start; }
.userchip__name { font-size: var(--fs-label); font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip__chev { color: var(--text-muted); display: inline-flex; flex: none; }

/* Popover panel variant (switcher + account menu): wider, taller rows, scrolls if tall */
.menu { max-height: min(72vh, 460px); overflow-y: auto; }
.menu--panel { min-width: 236px; max-width: 288px; }
.menu--panel .menu__item { height: 40px; }
.menu__head {
  padding: 8px 10px 4px; font-size: var(--fs-eyebrow); font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted);
}
.menu__head:first-child { padding-top: 4px; }
.menu__display { display: flex; align-items: center; gap: 10px; padding: 4px 10px 8px; }
.switch-row__main { flex: 1 1 auto; min-width: 0; display: grid; }
.switch-row__name { font-size: var(--fs-label); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu__sub { font-size: var(--fs-caption); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-row__check { flex: none; width: 15px; display: inline-flex; color: var(--accent-text); }
.menu__item.is-active .switch-row__name { color: var(--accent-text); font-weight: 600; }

/* Rail (tablet): collapse the chip + brand chevron to icon-only, centered */
@media (max-width: 768px) {
  .brand__chev { display: none; }
  .usermenu { padding: var(--space-2); }
  .userchip { grid-template-columns: 1fr; justify-items: center; padding: 6px; gap: 0; }
  .userchip__main, .userchip__chev { display: none; }
}

/* Drawer (phone): sidebar is full width again — restore the full chip + chevron */
@media (max-width: 560px) {
  .brand__chev { display: inline-flex; }
  .usermenu { padding: var(--space-2) var(--space-3); }
  .userchip { grid-template-columns: 28px minmax(0, 1fr) auto; justify-items: stretch; padding: 6px 8px; gap: 10px; }
  .userchip__main { display: grid; }
  .userchip__chev { display: inline-flex; }
}

/* ============================================================================
   FEATURE 5 — SURFACE COMPLIANCE (verdict block, approval strip, tile pill)
   Reuses the status color roles (no new colors) + pill / prompt-box / textarea
   grammar. Both themes. Verdict pills carry a leading icon, never color alone.
   ========================================================================== */

/* Compliance verdict pills — mapped to the existing status color roles */
.pill--passed  { color: var(--success-text); background: color-mix(in oklab, var(--success-fill) 13%, transparent); }
.pill--flagged { color: var(--warning-text); background: color-mix(in oklab, var(--warning-fill) 16%, transparent); }
.pill--blocked { color: var(--danger-text);  background: color-mix(in oklab, var(--danger-fill) 13%, transparent); }
.pill--passed .icon, .pill--flagged .icon, .pill--blocked .icon { color: currentColor; }

/* Asset-detail compliance block — an inset well in the rail (matches .prompt-box) */
.compliance {
  display: grid; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.compliance__reason { font-size: var(--fs-label); color: var(--text-secondary); line-height: 1.45; }
.compliance__ruleset { display: flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-muted); }
.compliance__ruleset .icon { color: var(--text-muted); flex: none; }

/* Approve / request-changes strip */
.review-strip { display: grid; gap: var(--space-3); }
.review-strip__note { min-height: 62px; }
.review-strip__actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.review-readonly { font-size: var(--fs-label); color: var(--text-secondary); }

/* Library tile approval pill — top-right by default; yields the corner to the
   multiselect check on hover/selection so the two never overlap */
.tile__approval { position: absolute; top: 8px; right: 8px; transition: opacity var(--dur-short) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .tile-wrap:hover .tile__approval { opacity: 0; } }
.tile-wrap.is-selected .tile__approval { opacity: 0; }

/* Compliance-blocked job reason — lock glyph + danger reason on one line */
.job__error--compliance { display: flex; align-items: center; gap: 6px; }
.job__error--compliance .icon { color: var(--danger-text); flex: none; }

/* Auth gate — mirrors supermaxx.ai's phosphor-terminal skin (dark, IBM Plex Mono, green glow) */
body.is-auth { background: #060806; overflow-x: hidden; }
body.is-auth #app { display: block; }  /* override the shell's sidebar+content grid so the gate fills the screen */
.auth-gate { position: relative; min-height: 100vh; min-height: 100dvh; width: 100%; display: grid; place-items: center; padding: var(--space-10) var(--space-6); background: radial-gradient(130% 90% at 50% -10%, #0c140d 0%, #060806 58%); overflow: hidden; }
.auth-gate__scan { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: repeating-linear-gradient(to bottom, rgba(126,232,150,0.028) 0, rgba(126,232,150,0.028) 1px, transparent 1px, transparent 3px); opacity: 0.6; }
.auth-gate__inner { position: relative; z-index: 2; width: min(92vw, 480px); display: flex; flex-direction: column; align-items: center; text-align: center; }
.auth-gate__eyebrow { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: clamp(9px, 2.4vw, 12px); font-weight: 500; letter-spacing: 0.28em; color: #57a06c; text-transform: uppercase; white-space: nowrap; }
.auth-gate__word { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 400; font-size: clamp(38px, 6vw, 62px); line-height: 1.0; letter-spacing: -0.01em; color: #b9e8c6; margin-top: var(--space-3); white-space: nowrap; text-shadow: 0 0 44px rgba(126,232,150,.5), 0 0 15px rgba(126,232,150,.5), 0 0 3px rgba(185,232,198,.6); }
.auth-gate__box { width: 100%; max-width: 400px; margin: var(--space-9) auto 0; display: flex; justify-content: center; }
/* Belt-and-suspenders: force the Clerk card to center on the same axis as the wordmark. */
.auth-gate__box .cl-rootBox { width: 100% !important; align-items: center !important; }
.auth-gate__box .cl-card, .auth-gate__box .cl-cardBox { margin-left: auto !important; margin-right: auto !important; }

/* ============================================================================
   CREATIVE-ENGINE SURFACES — nav sections, tool locks, pricing chart,
   coming-soon pages, Brand Brain ingestion.
   ========================================================================== */

/* Nav section eyebrows + locked tools */
.nav__section {
  margin-top: var(--space-4); padding: var(--space-3) var(--space-2) var(--space-1);
  font-size: var(--fs-eyebrow); font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
}
.nav__lock { margin-left: auto; display: inline-flex; color: var(--text-muted); }
.nav__item--locked { color: var(--text-muted); }
@media (hover: hover) and (pointer: fine) { .nav__item--locked:hover .nav__lock { color: var(--text-secondary); } }
.nav__item--brand .icon { color: var(--accent-text); }

/* Pricing chart (Add-funds modal, wallet, Admin) */
.pricing { margin-top: var(--space-5); }
.pricing__head { margin-bottom: var(--space-3); }
.pricing__title { font-size: var(--fs-label); font-weight: 600; color: var(--text); }
.pricing__rows { display: flex; flex-direction: column; gap: var(--space-2); }
.price-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); }
.price-row__type { font-size: var(--fs-label); color: var(--text-secondary); }
.price-row__track { position: relative; height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); }
.price-row__bar { position: absolute; top: 0; bottom: 0; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--accent), var(--accent-text)); }
.price-row__amt { font-size: var(--fs-caption); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pricing__note { display: flex; gap: 8px; align-items: flex-start; margin-top: var(--space-4); font-size: var(--fs-caption); color: var(--text-muted); line-height: 1.5; }
.pricing__note .icon { flex: none; margin-top: 1px; color: var(--accent-text); }
.pricing--compact .price-row { grid-template-columns: 68px minmax(0, 1fr) auto; }

/* Coming-soon (locked tools) */
.soon { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-4); padding: var(--space-16) var(--space-4); }
.soon__badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-eyebrow); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.soon__icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: var(--radius-lg); background: var(--surface-1); border: 1px solid var(--border); color: var(--accent-text); }
.soon__title { font-size: var(--fs-title); }
.soon__blurb { max-width: 46ch; color: var(--text-secondary); line-height: 1.6; }
.soon__note { display: flex; gap: 8px; align-items: flex-start; max-width: 48ch; text-align: left; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-1); border: 1px solid var(--border); font-size: var(--fs-caption); color: var(--text-muted); line-height: 1.55; }
.soon__note .icon { flex: none; margin-top: 1px; color: var(--accent-text); }
.soon__note a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.soon .btn { margin-top: var(--space-2); }

/* Brand Brain */
.brand-brain { display: flex; flex-direction: column; gap: var(--space-8); }
.bb-hero { max-width: 720px; }
.bb-hero__badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-eyebrow); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.bb-hero__title { font-size: var(--fs-display); margin-top: var(--space-3); letter-spacing: -0.02em; }
.bb-hero__sub { margin-top: var(--space-3); color: var(--text-secondary); line-height: 1.6; font-size: var(--fs-body-lg); }
.bb-meter { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-5); max-width: 420px; }
.bb-meter__track { flex: 1; height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.bb-meter__fill { display: block; height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--accent), var(--accent-text)); transition: width var(--dur-base) var(--ease-out); }
.bb-meter__label { font-size: var(--fs-caption); color: var(--text-muted); white-space: nowrap; }
.bb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.bb-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); }
.bb-card.is-filled { border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
.bb-card__head { display: flex; align-items: flex-start; gap: var(--space-3); }
.bb-card__icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none; border-radius: var(--radius-md); background: var(--surface-2); color: var(--accent-text); }
.bb-card__meta { min-width: 0; flex: 1; }
.bb-card__title { font-size: var(--fs-subhead); font-weight: 600; }
.bb-card__hint { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 2px; line-height: 1.45; }
.bb-card__count { flex: none; min-width: 22px; height: 20px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-caption); font-weight: 600; }
.bb-drop { display: flex; align-items: center; justify-content: center; padding: var(--space-4); border: 1px dashed var(--border-input); border-radius: var(--radius-md); cursor: pointer; transition: border-color var(--dur-micro) var(--ease-out), background var(--dur-micro) var(--ease-out); }
@media (hover: hover) { .bb-drop:hover { border-color: var(--border-strong); background: var(--surface-2); } }
.bb-drop__cta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-label); font-weight: 500; color: var(--text-secondary); }
.bb-items { display: flex; flex-direction: column; gap: 4px; }
.bb-item { display: flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-secondary); }
.bb-item .icon { flex: none; color: var(--success-text); }

/* ============================================================================
   IA REDESIGN — sidebar groups, Create emphasis, active indicator, Jobs badge,
   collapsed mode, workspace overviews (Studio) + explained overviews (Space).
   ========================================================================== */
.nav__item { position: relative; }
.nav__item--primary { background: var(--accent-tint); color: var(--accent-text); }
.nav__item--primary .icon { color: var(--accent-text); opacity: 1; }
@media (hover: hover) and (pointer: fine) { .nav__item--primary:hover { background: color-mix(in oklab, var(--accent) 22%, transparent); color: var(--accent-text); } }
.nav__item.is-active::before { content: ""; position: absolute; left: 2px; top: 7px; bottom: 7px; width: 2.5px; border-radius: 2px; background: var(--accent-text); }

.nav__badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--accent-tint); color: var(--accent-text); font-family: var(--font-mono); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.nav__badge.is-zero { display: none; }

.spine__collapse { width: 100%; background: none; border: none; color: var(--text-secondary); }
@media (hover: hover) and (pointer: fine) { .spine__collapse:hover { background: var(--surface-2); color: var(--text); } }

@media (min-width: 769px) {
  body.nav-collapsed .app { grid-template-columns: var(--rail-w) 1fr; }
  body.nav-collapsed .nav__label, body.nav-collapsed .brand__name, body.nav-collapsed .brand__chev, body.nav-collapsed .spine__label { display: none; }
  body.nav-collapsed .nav__item, body.nav-collapsed .brand, body.nav-collapsed .spine__collapse { justify-content: center; padding: 0; gap: 0; }
  body.nav-collapsed .nav__section { height: 1px; margin: 8px 14px; padding: 0; background: var(--chrome-border); overflow: hidden; text-indent: -9999px; }
  body.nav-collapsed .nav__badge { position: absolute; top: 4px; right: 10px; min-width: 8px; height: 8px; padding: 0; font-size: 0; border-radius: 50%; }
  body.nav-collapsed .spine__collapse .icon { transform: rotate(180deg); }
}

/* Studio workspace overview */
.studio { display: flex; flex-direction: column; gap: var(--space-6); }
.studio__hero { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.studio__lead { max-width: 640px; }
.studio__title { font-size: var(--fs-title); letter-spacing: -0.02em; }
.studio__sub { margin-top: 6px; color: var(--text-secondary); line-height: 1.55; }
.studio__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); }
.studio-card { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); transition: border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
@media (hover: hover) { .studio-card:hover { border-color: var(--border-strong); } .studio-card:active { transform: scale(0.995); } }
.studio-card__icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border-radius: var(--radius-md); background: var(--surface-2); color: var(--accent-text); }
.studio-card.is-live .studio-card__icon { background: var(--accent-tint); }
.studio-card__meta { flex: 1; min-width: 0; }
.studio-card__title { font-size: var(--fs-subhead); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.studio-card__soon { font-size: var(--fs-eyebrow); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 1px 7px; }
.studio-card__desc { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 2px; }
.studio-card__go { color: var(--text-muted); flex: none; }
.studio-recent { display: flex; flex-direction: column; gap: var(--space-3); }
.studio-recent__list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.recent-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface-1); border-bottom: 1px solid var(--border); }
.recent-row:last-child { border-bottom: none; }
@media (hover: hover) { .recent-row:hover { background: var(--surface-2); } }
.recent-row__icon { color: var(--text-muted); flex: none; }
.recent-row__title { flex: 1; min-width: 0; font-size: var(--fs-label); }
.recent-row__meta { font-size: var(--fs-caption); color: var(--text-muted); }

/* Explained overview (Space) */
.space { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-2); }
.space__head { display: flex; align-items: center; gap: var(--space-4); }
.space__icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; flex: none; border-radius: var(--radius-lg); background: var(--surface-1); border: 1px solid var(--border); color: var(--accent-text); }
.space__headmeta { display: flex; flex-direction: column; gap: 6px; }
.space__badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-eyebrow); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.space__title { font-size: var(--fs-title); letter-spacing: -0.02em; }
.space__blurb { color: var(--text-secondary); line-height: 1.6; font-size: var(--fs-body-lg); max-width: 60ch; }
.space__card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); padding: var(--space-4) var(--space-5); }
.space__cardhead { font-size: var(--fs-eyebrow); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: var(--space-3); }
.space__list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-2) var(--space-5); }
.space__list li { display: flex; align-items: center; gap: 8px; font-size: var(--fs-label); color: var(--text-secondary); }
.space__list .icon { flex: none; color: var(--accent-text); }
.space__foot { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.space__note { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-caption); color: var(--text-muted); line-height: 1.5; }
.space__note .icon { flex: none; margin-top: 1px; color: var(--accent-text); }
.space__note a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 560px) { .space__list { grid-template-columns: 1fr; } .studio__hero { flex-direction: column; } }
