:root {
  color-scheme: dark;
  --bg: #0b0b0f;
  --bg-color: var(--bg);
  --bg-2: #111118;
  --bg-3: #1a1a2e;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --panel: #141420;
  --panel-bg: #17171d;
  --input-bg: #101015;
  --panel-border: #232334;
  --border-color: #2e3a50;
  --border: #333333;
  --accent: #7c9bff;
  --accent-color: var(--accent);
  --text: #f1f1f6;
  --text-primary: #e2e8f0;
  --text-secondary: #b0b8d0;
  --text-tertiary: #64748b;
  --text-color: var(--text-primary);
  --muted: #a5a5b5;
  --text-muted: var(--muted);
  --success: #3ddc97;
  --error: #ff6b6b;
  --bg-secondary: var(--bg-3);
  --surface-1: var(--panel);
  --surface-2: var(--bg-2);
  --surface-3: #222222;
  --surface-4: #2a2a2a;
  /* RGB triple (no alpha) so translucent surfaces like .conversation-overlay
     can flip tint via rgba(var(--overlay-tint), X) while keeping their own
     per-element opacity. Root-caused 2026-08-28: these surfaces were still
     hardcoded rgba(11,11,15,X) after the first light-theme pass because the
     hex-based color audit that drove that pass doesn't see rgba() literals —
     meanwhile several *text* colors inside the same components (e.g.
     .conv-overlay-title) had already been converted to --text-primary, so in
     light mode that produced near-black text on a near-black surface. */
  --overlay-tint: 11, 11, 15;
}

/* Light theme — opt-in via [data-theme="light"] on <html>; dark (above) stays the
   default so unauthenticated/no-preference sessions render exactly as before. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f9;
  --bg-2: #eceef4;
  --bg-3: #ffffff;
  --bg-hover: rgba(15, 23, 42, 0.05);
  --panel: #ffffff;
  --panel-bg: #ffffff;
  --input-bg: #eef0f6;
  --panel-border: #e2e8f0;
  --border-color: #dbe2ee;
  --border: #dbe2ee;
  --accent: #4f63d2;
  --text: #14161f;
  --text-primary: #1f2430;
  --text-secondary: #4b5468;
  --text-tertiary: #6b7488;
  --muted: #5a687d;
  --success: #128a5e;
  --error: #d64545;
  --surface-3: #eef0f6;
  --surface-4: #e4e7f0;
  --overlay-tint: 255, 255, 255;
}

/* One-off light-theme text-color overrides for classes that hardcode a hex
   accent tuned for the dark background above. #a78bfa (light violet) reads
   fine on dark surfaces but drops well below WCAG AA contrast on light
   ones -- darkened here to the same hue family instead of the CSS-variable
   flip the rest of the theme uses, since these are one-off accent colors
   rather than the shared text/surface palette. */
:root[data-theme="light"] .pipeline-status,
:root[data-theme="light"] .pipeline-summary-toggle,
:root[data-theme="light"] .pipeline-steps,
:root[data-theme="light"] .preview-execution-status.completed,
:root[data-theme="light"] .assistant-meta-routing,
:root[data-theme="light"] .conversation-overlay-text.is-user {
  color: #6d28d9;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
}

#root {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 14, 0.78);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  pointer-events: auto;
}

.modal-root.hidden {
  display: none !important;
}

.account-page {
  flex: 1;
  padding: 0 48px 60px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
  /* body.mosaic-enabled collapses #root (this element's parent) to its
     topbar's natural height and hides overflow at the body level (see the
     comment at the body.mosaic-enabled rule) — that's correct for the
     mosaic workspace, but #account-page is also a child of #root and gets
     caught in the same collapse with no scroll fallback anywhere in the
     chain, silently clipping account content below the fold instead of
     scrolling to it. Bounding this element to the viewport and giving it
     its own scroll fixes that regardless of mosaic state. */
  min-height: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.account-header h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.account-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.account-section {
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-section-header h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.account-section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.account-card {
  background: rgba(10, 10, 16, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-preferences {
  gap: 16px;
}

.account-toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--text);
}

.account-toggle input[type="checkbox"] {
  margin-top: 4px;
  width: 16px;
  height: 16px;
}

.account-toggle strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.account-field,
.account-metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
}

.account-value {
  font-size: 15px;
  font-weight: 600;
}

.account-field.compact {
  gap: 8px;
}

.account-select {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 10, 16, 0.6);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

.account-details {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 16px;
  background: rgba(10, 10, 16, 0.3);
}

.account-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

.account-user-id {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.account-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.account-action-row.align-between {
  justify-content: space-between;
}

.overage-return {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(108, 240, 213, 0.28);
  border-radius: 14px;
  background: rgba(108, 240, 213, 0.07);
}

.overage-return.hidden {
  display: none;
}

.overage-return strong,
.overage-return span {
  display: block;
}

.overage-return strong {
  color: var(--text);
  font-size: 13px;
}

.overage-return span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.ghost-button.small {
  padding: 6px 10px;
  font-size: 12px;
}

.ghost-button.subtle {
  opacity: 0.8;
}

.account-session-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.account-table-wrapper {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.account-table th,
.account-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.account-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(10, 10, 16, 0.6);
}

.account-table tr:last-child td {
  border-bottom: none;
}

.account-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.account-muted {
  color: var(--muted);
  font-size: 12px;
}

.account-footer {
  margin-bottom: 20px;
}

.billing-dashboard-grid {
  align-items: stretch;
}

.billing-summary-card,
.billing-usage-card {
  min-height: 100%;
}

.billing-usage-meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.billing-usage-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #5eead4, #818cf8);
  transition: width 180ms ease;
}

/* Overage card */
.overage-card {
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.overage-header-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.overage-description {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  margin: 4px 0 8px;
  line-height: 1.4;
}

.overage-value {
  color: #fbbf24;
}

.overage-toggle-label {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.overage-toggle-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.overage-toggle-switch {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  transition: background 150ms ease;
}

.overage-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}

.overage-toggle-checkbox:checked + .overage-toggle-switch {
  background: #818cf8;
}

.overage-toggle-checkbox:checked + .overage-toggle-switch::after {
  transform: translateX(16px);
}

.billing-upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.billing-plan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.billing-plan-option {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 10, 16, 0.55);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}

.billing-plan-option:hover {
  border-color: rgba(129, 140, 248, 0.65);
}

.billing-plan-option.is-current-plan {
  border-color: rgba(94, 234, 212, 0.8);
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.4);
}

.billing-plan-name {
  font-size: 14px;
  font-weight: 700;
}

.billing-plan-copy {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.ghost-button.danger {
  border-color: rgba(255, 107, 107, 0.5);
  color: var(--error);
}

@media (max-width: 720px) {
  .account-page {
    padding: 24px;
  }

  .account-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.modal-panel,
.auth-card {
  width: min(420px, 100%);
  background: var(--bg-3);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
  position: relative;
  z-index: 1;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--bg-3);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  max-width: 320px;
  font-size: 13px;
  z-index: 120;
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.4);
  color: var(--error);
}

@media (max-width: 640px) {
  /* right: 24px + max-width: 320px needs 344px of viewport — narrower
     phones (~320-360px wide) would clip the toast's left edge off-screen.
     Span with symmetric margins instead of a fixed max-width so it always
     fits. */
  .toast {
    left: 16px;
    right: 16px;
    max-width: none;
  }
}

.auth-card h2,
.modal-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.auth-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 24px 0;
}

/* Every provider gets the same slot */
.auth-slot {
  width: 100%;
  display: flex;
  justify-content: center;
}

.auth-btn {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--bg-3);
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.auth-btn:hover {
  border-color: rgba(124, 155, 255, 0.6);
  background: var(--bg-3);
}

/* Unified button geometry */
.auth-btn,
.auth-slot iframe {
  width: 100%;
  max-width: 360px;
  height: 48px;
  border-radius: 12px;
  font-size: 15px;
}

/* Google container rules */
.auth-slot[data-provider="google"] {
  position: relative;
  min-height: 48px;
}

#google-signin {
  width: 100%;
  display: flex;
  justify-content: center;
}

.auth-slot[data-provider="google"] button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-helper {
  margin: 8px auto 0;
  width: 100%;
  max-width: 360px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}

.auth-helper[data-active='false'] {
  display: none;
}

/* --- Google auth skeleton --- */
.auth-slot[data-provider="google"]:has(#google-signin:empty)::before {
  content: "";
  display: block;
  width: 100%;
  max-width: 360px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.12) 37%,
    rgba(255, 255, 255, 0.06) 63%
  );
  background-size: 400% 100%;
  animation: auth-skeleton 1.2s ease-in-out infinite;
  margin: 0 auto;
}

@keyframes auth-skeleton {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* Ensure iframe never collapses */
#google-signin iframe {
  width: 100%;
  height: 48px;
  border-radius: 12px;
}

/* Optional provider styling */
.auth-slot[data-provider="apple"] .auth-btn {
  background: var(--bg-2);
  color: var(--text);
}

.auth-slot[data-provider="email"] .auth-btn {
  background: rgba(255, 255, 255, 0.06);
}

.auth-slot[data-provider="guest"] .auth-btn {
  background: rgba(95, 160, 255, 0.14);
  border-color: rgba(95, 160, 255, 0.35);
}

.email-auth {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}

.email-input {
  flex: 1;
  height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.email-sent {
  width: 100%;
  max-width: 360px;
  text-align: center;
  font-size: 14px;
  opacity: 0.9;
}

.newsletter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}

.auth-legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 11px;
  color: var(--muted);
}
.auth-legal-links a {
  color: #60a5fa;
  text-decoration: none;
}
.auth-legal-links a:hover {
  text-decoration: underline;
}

.modal-panel h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-panel p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.modal-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.modal-input input {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.modal-input textarea {
  min-height: 120px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  resize: vertical;
  font: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions button {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.modal-actions .secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--panel-border);
}

.modal-actions .secondary:hover {
  border-color: rgba(124, 155, 255, 0.6);
}

.modal-actions .danger {
  background: #2a1416;
  color: #ffb5b5;
  border-color: rgba(255, 107, 107, 0.6);
}

.modal-actions .danger:hover {
  background: #351719;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
}

.auth-form button {
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #0b0b0f;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.auth-form button:hover {
  filter: brightness(1.1);
}

.auth-form button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.auth-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-notice {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  background: rgba(61, 220, 151, 0.14);
  color: var(--success);
}

.auth-notice.error {
  background: rgba(255, 107, 107, 0.14);
  color: var(--error);
}

#top-bar {
  padding: 10px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* pdco-logo.svg is baked with a fixed light fill (#e2e8f0) for the dark
   #top-bar background -- it isn't currentColor-driven, so it can't adapt to
   [data-theme="light"] the way CSS-variable text can. Rather than maintain a
   second light-mode logo asset, pin a small dark backdrop behind it so the
   mark always renders exactly as it does in dark mode, regardless of theme. */
.logo-mark {
  background: #111118;
  border-radius: 8px;
  padding: 3px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#top-bar h1 {
  margin: 0;
  font-size: 18px;
}

#status-label {
  display: none;
}

/* ── Chrome density ─────────────────────────────────────────────────────────
   Normal density spends 171px before any module renders (top bar 61 + thread
   dock 36 + mosaic toolbar 47 + gaps) - 19% of a 900px viewport, 22% of a
   768px laptop. Focused density collapses the two toolbars and compacts the
   header to ~32px, handing that space back to the modules.

   What focused density must NEVER do is strand anyone: PR #715 shipped a
   collapsed state that hid the thread list AND the only "new thread" button,
   and had to be deleted in #717. So #chrome-focused-nav re-exposes both the
   module toggles and + new thread inside the compact bar, and the density
   control itself stays visible in both states. */

.chrome-focused-nav {
  display: none;
  align-items: center;
  gap: 6px;
}

body.chrome-focused .chrome-focused-nav {
  display: flex;
}

.chrome-focused-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  background: var(--bg-3);
  color: var(--text);
  font: 600 12px/1 'IBM Plex Sans', 'Segoe UI', sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chrome-focused-btn:hover {
  border-color: var(--accent, #6ea8fe);
}

.chrome-focused-plus {
  padding: 0 6px;
}

/* Mirrors .mosaic-chip.is-attention/.has-console-update: in focused/collapsed
   chrome density the module toolbar (and its Console chip) is display:none
   until this button's dropdown is expanded, so a new-console-output pulse
   needs a visible target that survives collapse — this button is it. */
#chromeModulesBtn.is-attention,
#chromeModulesBtn.has-console-update {
  border-color: rgba(34, 211, 238, 0.72);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.08));
  color: #f8feff;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.16), 0 0 18px rgba(34, 211, 238, 0.18);
}

#chromeModulesBtn.is-attention {
  animation: mosaic-chip-attention 1.4s ease-in-out infinite;
}

.chrome-focused-count {
  min-width: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--panel-border);
  font-size: 11px;
  text-align: center;
}

.chrome-focused-caret {
  font-size: 9px;
  opacity: 0.7;
}

/* The density control is the escape hatch, so it is present at both densities
   and only rotates to show which way it will move. */
.chrome-density-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, transform 0.18s;
}

.chrome-density-toggle:hover {
  color: var(--text);
  border-color: var(--panel-border);
}

body.chrome-focused .chrome-density-toggle {
  transform: rotate(180deg);
}

/* ── Focused density: collapse ─────────────────────────────────────────── */

body.chrome-focused #top-bar {
  padding: 4px 24px;
}

body.chrome-focused #top-bar h1,
body.chrome-focused #top-bar .brand-divider,
body.chrome-focused #voice-mode-toggle,
body.chrome-focused #conversation-mode-toggle,
body.chrome-focused #topBarPublicResearchButton,
body.chrome-focused #topBarColonyButton,
body.chrome-focused .logo-mark {
  display: none;
}

body.chrome-focused .user-trigger {
  padding-top: 0;
  padding-bottom: 0;
}

body.chrome-focused .user-avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

body.chrome-focused .user-meta {
  line-height: 1.05;
}

body.chrome-focused #creditBadge {
  padding-top: 2px;
  padding-bottom: 2px;
}

body.chrome-focused #thread-dock {
  display: none !important;
}

body.chrome-focused #mosaic-toolbar {
  display: none;
}

/* Peeking re-shows the REAL toolbar rather than a duplicate set of chips, so
   toggling a module from focused density runs exactly the same handlers. */
body.chrome-focused.chrome-modules-peek #mosaic-toolbar {
  display: flex;
}

/* Studio Shell (non-mosaic) sizes #workspace off a hardcoded 100px of chrome;
   with both toolbars gone only the compact header remains. */
body.chrome-focused #workspace {
  height: calc(100vh - 32px);
}


/* ── Voice & Conversation Mode Buttons (desktop) ────────────────────────── */

.mobile-voice-toggle {
  display: inline-flex;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--bg-3);
  font-size: 15px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-voice-toggle svg {
  width: 28px;
  height: 28px;
  display: block;
  pointer-events: none;
}

.mobile-voice-toggle:hover {
  background: #28283a;
  border-color: rgba(168, 85, 247, 0.4);
}

.mobile-voice-toggle[aria-pressed="true"] {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.5);
}

/* Companion has a new thought — pulses amber until user opens Converse */
.mobile-voice-toggle.has-companion-thought {
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5);
  animation: companion-thought-pulse 2s ease-in-out infinite;
}
@keyframes companion-thought-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(251, 191, 36, 0.5); }
  50%  { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(251, 191, 36, 0.5); }
}

.credit-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.credit-badge .icon {
  font-size: 12px;
}

.credit-badge .count {
  color: var(--text);
}

/* Fuel-gauge dial for the top-bar credit badge (simple + advanced mode share
   this one header, so this one rule covers both). Green fill = remaining,
   red fill grows clockwise as credits are used -- fixed semantic colors,
   independent of the badge-soft/firm/hard tone classes (those still drive
   the pill border, unrelated). Exact remaining/total numbers live in
   #credit-panel, revealed on click. Scoped to the #creditBadge instance
   only -- the generic .credit-badge .icon rule above still serves the
   overage/earn badges' text-glyph icons. */
#creditBadge .icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  font-size: 0;
  border-radius: 50%;
  background: conic-gradient(var(--error) calc(var(--credit-used-pct, 0) * 360deg), var(--success) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  flex: none;
}

#creditBadge .count {
  color: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* F (full, 0% used) and E (<=5% remaining) get their own fixed color,
   independent of tone -- the letter itself already carries the state. */
#creditBadge.credit-full .count {
  color: var(--success);
}

#creditBadge.credit-empty .count {
  color: var(--error);
}

.credit-badge:hover .credit-badge-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.credit-badge-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  z-index: 10;
}

.credit-badge.badge-soft {
  border-color: rgba(250, 204, 21, 0.6);
  color: #fde047;
}

.credit-badge.badge-firm {
  border-color: rgba(251, 146, 60, 0.7);
  color: #fdba74;
}

.credit-badge.badge-hard {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fca5a5;
}

.credit-badge.overage-badge {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(20, 184, 166, 0.08);
  color: #99f6e4;
}

.credit-badge.overage-badge .count {
  color: inherit;
}

/* Inside #credit-panel (see index.html) rather than a second permanent
   top-bar pill — the badge keeps its pill styling but sits in-flow as a
   popover row instead of floating in the header. */
.credit-panel-overage {
  margin-top: 10px;
  cursor: default;
}

.user-menu {
  position: relative;
  display: inline-block;
}

.user-trigger {
  background: none;
  border: none;
  color: #cfd6ff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-trigger:hover {
  color: var(--text);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #e6e8ff;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.1;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
}

.user-plan {
  font-size: 11px;
  color: rgba(214, 219, 255, 0.8);
}

.chevron {
  margin-left: 4px;
  font-size: 12px;
  opacity: 0.7;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 28px;
  min-width: 220px;
  background: #0f1117;
  border: 1px solid #1f2330;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 1000;
}

.user-menu:hover .user-dropdown {
  display: block;
}

.menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #d6dbff;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(79, 140, 255, 0.12);
}

.menu-divider {
  height: 1px;
  margin: 6px 0;
  background: #1f2330;
}

.menu-item.danger {
  color: #ff9a9a;
}

.menu-item.danger:hover {
  background: rgba(255, 90, 90, 0.12);
}

.credit-panel {
  position: absolute;
  right: 24px;
  top: 70px;
  width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.credit-panel.hidden {
  display: none;
}

.credit-panel-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
}

.credit-meter {
  position: relative;
  display: grid;
  gap: 6px;
}

.credit-meter .bar {
  background: #0b0b14;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  height: 22px;
  overflow: hidden;
}

.credit-meter .fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(124, 155, 255, 0.4), rgba(124, 155, 255, 0.9));
  width: 0%;
  transition: width 0.3s ease;
}

.credit-meter .label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--text);
  letter-spacing: 0.02em;
}

.credit-panel-meta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.credit-session {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.credit-session-title {
  font-weight: 600;
  color: var(--text);
}

.credit-session-metrics {
  display: grid;
  gap: 6px;
}

.credit-session-metrics div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.credit-session-previous {
  font-size: 11px;
  color: #d7defb;
}

.credit-session-previous.hidden {
  display: none;
}

.credit-panel-callout {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(124, 155, 255, 0.1);
  border: 1px solid rgba(124, 155, 255, 0.3);
  font-size: 12px;
  color: #d7defb;
}

.credit-panel-nudge {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.credit-panel-nudge.hidden,
.credit-panel-callout.hidden,
.usage-nudge.hidden {
  display: none;
}

#workspace {
  flex: 1;
  display: grid;
  /*  chat | split1 | companion | split2 | secondary  */
  grid-template-columns: minmax(0, 1.3fr) 6px 320px 6px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "tabbar tabbar tabbar tabbar tabbar"
    "chat   split1 companion split2 secondary";
  gap: 16px 0;
  padding: 16px;
  /* 64px top bar + 36px persistent thread dock (moved out of #chat-panel). */
  height: calc(100vh - 100px);
}

#workspace-tab-bar { grid-area: tabbar; }
#left-pane         { grid-area: chat; }       /* now holds chat only - see Task 5 */
#agent-panel       { grid-area: companion; }
#col-splitter      { grid-area: split1; }
#col-splitter-2    { grid-area: split2; }
#secondary-column  { grid-area: secondary; display: flex; flex-direction: column; min-height: 0; }

@media (min-width: 1366px) {
  #workspace-tab-bar { display: none; }
}

#secondary-tab-bar { display: flex; }
.secondary-tab-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  margin-right: 4px;
}
.secondary-tab-button.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.secondary-drawer-toggle { display: none; }   /* tablet-landscape only - Task 5 */

/* Column splitter between left and right panes */
.col-splitter {
  grid-row: 2;
  grid-column: 2;
  width: 6px;
  cursor: col-resize;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  margin: 0 5px;
  transition: background 0.15s;
  z-index: 10;
}

.col-splitter:hover,
.col-splitter.dragging {
  background: rgba(96, 165, 250, 0.4);
}

.workspace-tab-bar {
  grid-column: 1 / -1; /* span all columns including splitter */
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
}

.workspace-tab-button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 6px 10px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.workspace-tab-button.is-active {
  border-color: var(--panel-border);
  background: rgba(255, 255, 255, 0.09);
}

.workspace-tab-button.has-console-update {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(14, 165, 233, 0.16);
  color: #e0f7ff;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), 0 0 18px rgba(56, 189, 248, 0.16);
}

.workspace-tab-button.has-console-update::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #67e8f9;
  box-shadow: 0 0 10px rgba(103, 232, 249, 0.9);
}

#left-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#workspace[data-workspace-panel="agent"] {
  grid-template-columns: minmax(0, 1fr) 6px minmax(260px, 0.72fr);
  grid-template-areas:
    "tabbar tabbar tabbar"
    "chat   split2 secondary";
}

#workspace[data-workspace-panel="agent"] #chat-panel,
#workspace[data-workspace-panel="agent"] #left-pane-splitter,
#workspace[data-workspace-panel="agent"] #col-splitter {
  display: none !important;
}

#workspace[data-workspace-panel="agent"] #left-pane,
#workspace[data-workspace-panel="agent"] #agent-panel,
#workspace[data-workspace-panel="agent"] #agent-personality-section,
#workspace[data-workspace-panel="agent"] #agent-active-display {
  min-height: 0;
}

#workspace[data-workspace-panel="agent"] #agent-panel {
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
}

#workspace[data-workspace-panel="agent"] #agent-console-render {
  min-height: 0;
}

#workspace[data-workspace-panel="agent"][data-secondary-tab="companion"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "tabbar"
    "chat";
}

#workspace[data-workspace-panel="agent"][data-secondary-tab="companion"] #secondary-column,
#workspace[data-workspace-panel="agent"][data-secondary-tab="companion"] #col-splitter-2 {
  display: none !important;
}

#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "tabbar"
    "chat";
}

#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #chat-panel,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #left-pane-splitter,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #col-splitter,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #secondary-column,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #col-splitter-2 {
  display: none !important;
}

#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #agent-panel,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #agent-personality-section,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #agent-active-display,
#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #agent-console-render {
  min-height: 0;
}

#workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) #agent-panel {
  flex: 1 1 auto;
  height: 100%;
  overflow: hidden;
}

.agents-panel {
  flex: 1;
}

.agents-panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agents-layout {
  display: flex;
  gap: 20px;
  min-height: 0;
}

.agents-graph-column {
  flex: 1;
}

.agents-side-column {
  width: 300px;
  min-width: 0;
  transition: width 200ms ease, opacity 200ms ease;
  overflow: hidden;
}

.agents-side-column.is-collapsed {
  width: 0;
  opacity: 0;
}

.agents-side-toggle {
  align-self: flex-start;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.agents-box {
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  min-height: 90px;
  max-height: 360px;
  resize: vertical;
  overflow: auto;
  margin-bottom: 12px;
}

.agents-autogen-button {
  align-self: flex-start;
  padding: 8px 12px;
  border: 1px solid rgba(251, 146, 60, 0.5);
  background: rgba(251, 146, 60, 0.1);
  color: #fb923c;
  font-weight: 600;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.agents-autogen-button:hover {
  background: rgba(251, 146, 60, 0.2);
  border-color: rgba(251, 146, 60, 0.8);
}
.agents-run-button {
  align-self: flex-start;
  padding: 8px 12px;
  border: none;
  background: #00afff;
  color: #000;
  font-weight: 700;
  border-radius: 6px;
}

#chat-panel {
  flex: 1 1 0;
  min-height: 160px;
  position: relative;
  /* Lets the send button react to the panel's own rendered width (a resized
     mosaic tile, a popped-out module window) instead of only the viewport —
     see the @container rule near .chat-send-btn. */
  container-type: inline-size;
  container-name: chat-panel;
}

#agent-panel {
  flex: 1 1 0;
  min-height: 0;
  overflow: visible;
}

#secondary-column {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 8px;
  min-height: 0;
  min-width: 0;
}

/* Emphasis: the focused panel grows, others shrink */
#left-pane .panel,
#secondary-column .panel {
  flex: 1 1 0;
  transition: flex 0.2s ease;
  overflow: hidden;
}

#secondary-column .panel.is-emphasized {
  flex: 4 1 0;
}

/* Left pane: ~60/40 split — both panels stay usable regardless of active tab */
#left-pane .panel.is-emphasized {
  flex: 3 1 0;
}
#left-pane .panel:not(.is-emphasized):not(.hidden) {
  flex: 2 1 0;
  min-height: 120px;
}

/* Splitter drag state */
#left-pane .splitter.dragging,
#secondary-column .splitter.dragging {
  background: rgba(96, 165, 250, 0.4);
}

#left-pane .panel:not(.is-emphasized):not(.hidden),
#secondary-column .panel:not(.is-emphasized):not(.hidden) {
  flex: 1 1 0;
  min-height: 120px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Individuated Studio Shell */
#workspace.studio-shell {
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: 1fr;
  grid-template-areas: "studio-sidebar studio-stage";
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.studio-sidebar {
  grid-area: studio-sidebar;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(10, 13, 22, 0.92);
}

.studio-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(241, 245, 249, 0.92);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.studio-sidebar-icon,
.studio-sidebar-open {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
}

.studio-sidebar-icon {
  width: 28px;
  height: 28px;
}

.studio-sidebar-open {
  position: fixed;
  left: 12px;
  top: 76px;
  z-index: 220;
  padding: 8px 10px;
  font-size: 12px;
}

.studio-module-nav,
.studio-layout-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.studio-layout-controls {
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.studio-module-button,
.studio-layout-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(226, 232, 240, 0.84);
  text-align: left;
  cursor: pointer;
  position: relative;
}

.studio-layout-button {
  justify-content: center;
  min-height: 32px;
  font-size: 12px;
}

.studio-module-button:hover,
.studio-layout-button:hover,
.studio-module-button.is-active,
.studio-layout-button.is-active {
  border-color: rgba(125, 211, 252, 0.46);
  background: rgba(14, 165, 233, 0.13);
  color: var(--text);
}

.studio-module-button.has-console-update {
  border-color: rgba(56, 189, 248, 0.62);
  background: rgba(14, 165, 233, 0.14);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.1);
}

.studio-module-button.has-console-update::after {
  content: "";
  position: absolute;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #67e8f9;
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.82);
}

.studio-module-stage {
  grid-area: studio-stage;
  display: grid;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

#workspace[data-studio-layout="focus"] .studio-module-stage {
  grid-template-columns: minmax(0, 1fr);
}

#workspace[data-studio-layout="split"] .studio-module-stage {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#workspace[data-studio-layout="grid"] .studio-module-stage {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.studio-module-panel {
  grid-area: auto !important;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.studio-module-panel.hidden,
.studio-legacy-hidden,
#workspace.studio-shell #workspace-tab-bar,
#workspace.studio-shell #secondary-tab-bar,
#workspace.studio-shell #left-pane,
#workspace.studio-shell #secondary-column,
#workspace.studio-shell #left-pane-splitter,
#workspace.studio-shell #splitter,
#workspace.studio-shell #col-splitter,
#workspace.studio-shell #col-splitter-2 {
  display: none !important;
}

.studio-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.studio-panel-switcher {
  max-width: 132px;
  min-height: 28px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.86);
  color: var(--text);
  font-size: 12px;
}

.voice-panel {
  position: relative;
}

.voice-panel-body,
.voice-panel-overlay-anchor {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Without display:flex the empty placeholder (height:100%) consumed every
   pixel of voice-panel-body and the anchor below it collapsed to 0×0 —
   leaving the docked overlay (position:absolute; inset:0 inside the
   anchor) with no visible area. Pop-out worked because .is-popped uses
   width/height:100% inside a fresh window body. */
.voice-panel-body {
  display: flex;
  flex-direction: column;
}

/* Show the placeholder OR the overlay, never both. The anchor still hosts
   the overlay; hiding it when the overlay is .hidden keeps the empty state
   click-targets reachable. */
#voice-panel .voice-panel-body:has(.conversation-overlay.hidden) .voice-panel-overlay-anchor {
  display: none;
}
#voice-panel .voice-panel-body:has(.conversation-overlay:not(.hidden)) .voice-panel-empty {
  display: none;
}

.voice-panel-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: rgba(226, 232, 240, 0.86);
  text-align: center;
}

.voice-panel-empty h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.voice-panel-empty p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.voice-panel-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 50%;
  background: rgba(14, 165, 233, 0.12);
  color: #bae6fd;
  font-weight: 700;
}

#voice-panel .conversation-overlay:not(.is-floating):not(.is-popped) {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

.studio-sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas: "studio-stage" !important;
}

.studio-sidebar-collapsed .studio-sidebar {
  display: none;
}

.studio-popout-body {
  margin: 0;
  height: 100vh;
  background: #070a12;
  color: var(--text);
  overflow: hidden;
}

.studio-popout-body .is-popped-module {
  width: 100vw;
  height: 100vh;
  border: none;
  border-radius: 0;
}

/* Defense in depth: app.js strips `.is-floating` before adopting a panel into
   a pop-out window, but if a stray in-page "float" state (mosaicBoot.js's
   Create-tile float, `position:fixed; width:480px; height:560px; bottom/right:
   24px`) ever survives the adopt, force the pop-out window to still win —
   same-specificity rules would otherwise fall back to source order and pin the
   panel to a small corner card instead of filling the window. */
.studio-popout-body .is-popped-module.is-floating {
  position: static !important;
  inset: auto !important;
  width: 100vw !important;
  height: 100vh !important;
  bottom: auto !important;
  right: auto !important;
}

/* render() in initStudioModuleShell adds `hidden` to popped panels after
   popOutModule moves them to the new window. Inside mosaic, the panel was
   kept visible by `#mosaic-host [data-panel-host] > .panel`, but that
   ancestor selector no longer matches after adoptNode strips the panel
   from the mosaic tree. Force the popped panel to render. */
.studio-popout-body .studio-module-panel,
.studio-popout-body .is-popped-module {
  display: flex !important;
}

@media (max-width: 1099px) {
  #workspace.studio-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "studio-stage";
    padding-top: 52px;
  }

  .studio-sidebar {
    position: fixed;
    top: 64px;
    left: 12px;
    bottom: 12px;
    width: min(280px, calc(100vw - 24px));
    z-index: 230;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  }

  #workspace[data-studio-layout="split"] .studio-module-stage,
  #workspace[data-studio-layout="grid"] .studio-module-stage {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
}

.ui-icon {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: middle;
}

.icon-button:hover {
  color: var(--text);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.icon-button.copied {
  color: #4ade80;
}

.panel-header-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Thread-switch loading bar -- app.js toggles .hidden on _switchToThread.
   Classic top-loading-bar pattern: a 2px strip with a sliding gradient,
   overlaid rather than pushing layout so it never shifts the messages
   underneath. */
.thread-switch-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
  z-index: 5;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.thread-switch-indicator::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: var(--accent);
  animation: thread-switch-sweep 1.1s ease-in-out infinite;
}

.thread-switch-indicator.hidden { display: none; }

@keyframes thread-switch-sweep {
  0% { left: -40%; }
  100% { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .thread-switch-indicator::after { animation: none; left: 0; width: 100%; }
}

.panel-footer {
  padding: 0;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  flex: 0 0 auto;
}

.context-mode-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.context-mode-control select {
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

/* Discipline pills and source chips */
.library-disciplines-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.library-disciplines {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.discipline-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--panel-border);
  transition: opacity 0.3s;
}
.discipline-pill.dimmed { opacity: 0.4; }
.attachment-pill.library-source .pill-remove { display: none; }
.attachment-pill.library-source {
  border-left: 3px solid var(--genre-color, rgba(255,255,255,0.3));
}
.attachment-pill.library-source.dimmed { opacity: 0.4; }
.attachment-pill.user-attachment .pill-icon { margin-right: 4px; }
.source-manifest {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.source-manifest summary {
  cursor: pointer;
  font-weight: 500;
}
.source-manifest ul {
  list-style: none;
  padding-left: 0;
  margin-top: 4px;
}
.source-manifest li {
  padding: 2px 0;
}
.source-manifest a {
  color: #9fd3ff;
  text-decoration: none;
}
.source-manifest a:hover {
  text-decoration: underline;
}
.source-manifest-author {
  color: var(--muted);
}
.source-manifest-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(159,211,255,0.24);
  color: #9fd3ff;
  font-size: 0.72rem;
  line-height: 1.4;
}

.library-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f1118;
  border: 1px solid rgba(127, 174, 212, 0.22);
  color: #a9c7e3;
  border-radius: 8px;
  width: 38px;
  height: 34px;
  padding: 0;
  font: 600 11px/1 'IBM Plex Sans', 'Segoe UI', sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.library-mode-btn:hover:not(:disabled) {
  border-color: rgba(169, 199, 227, 0.5);
  color: #e6edf5;
}

.library-mode-btn.is-active {
  color: #e6edf5;
  border-color: rgba(127, 174, 212, 0.55);
  background:
    radial-gradient(circle at top left, rgba(127, 174, 212, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(15, 22, 33, 0.98), rgba(10, 14, 20, 0.98));
  box-shadow: 0 0 0 1px rgba(127, 174, 212, 0.14), 0 8px 18px rgba(3, 7, 12, 0.28);
}

.library-mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.library-mode-icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.creativity-mode-pill-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(11, 14, 22, 0.88);
  border: 1px solid rgba(116, 134, 168, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.creativity-mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(110, 127, 160, 0.18);
  background: rgba(18, 22, 32, 0.96);
  color: #8ea6c7;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.creativity-mode-pill[hidden] {
  display: none;
}

.creativity-mode-pill:hover {
  border-color: rgba(164, 191, 224, 0.42);
  color: #e9f2fb;
  transform: translateY(-1px);
}

.creativity-mode-pill.is-active {
  color: #f6fbff;
  border-color: rgba(127, 174, 212, 0.55);
  background:
    radial-gradient(circle at 30% 25%, rgba(127, 174, 212, 0.22), transparent 52%),
    linear-gradient(180deg, rgba(19, 28, 40, 0.98), rgba(13, 18, 27, 0.98));
  box-shadow: 0 0 0 1px rgba(127, 174, 212, 0.12), 0 7px 18px rgba(3, 7, 12, 0.26);
}

.creativity-mode-pill:focus-visible,
.library-mode-btn:focus-visible {
  outline: 2px solid rgba(164, 191, 224, 0.55);
  outline-offset: 2px;
}

.creativity-mode-pill-icon {
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
}

.creativity-mode-pill-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
}

.creativity-mode-pill-icon-svg svg {
  display: block;
}

.library-dropdown-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.library-dropdown-caret {
  font-size: 9px;
  opacity: 0.6;
  flex-shrink: 0;
}

.library-dropdown-panel {
  position: fixed;
  min-width: 380px;
  max-width: 520px;
  max-height: min(460px, 55vh);
  background: var(--bg-2);
  border: 1px solid rgba(124, 155, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.library-dropdown-panel.hidden {
  display: none;
}

.library-dropdown-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(124, 155, 255, 0.1);
  background: rgba(17, 17, 27, 0.95);
}

.library-filter-btn {
  background: transparent;
  border: 1px solid rgba(100, 100, 140, 0.3);
  color: var(--muted);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.library-filter-btn:hover {
  background: rgba(124, 155, 255, 0.1);
  border-color: rgba(124, 155, 255, 0.3);
}

.library-filter-btn.active {
  background: rgba(124, 155, 255, 0.2);
  border-color: rgba(124, 155, 255, 0.5);
  color: var(--text-primary);
}

.library-dropdown-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px;
}

.library-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
  transition: background 0.1s;
}

.library-dropdown-item:hover {
  background: rgba(124, 155, 255, 0.1);
}

.library-genre-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.library-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.library-item-genre {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.library-item-tokens {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Agent Profile Editor Modal ───────────────────────────────────────── */
.ape-modal {
  width: min(520px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.45);
  color: var(--text-primary);
  overflow: hidden;
}

.ape-header {
  padding: 16px 20px;
  border-bottom: 1px solid #1f2a3d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ape-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.ape-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.ape-close-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.ape-close-btn:hover {
  color: var(--text-primary);
}

.ape-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.ape-row {
  display: flex;
  gap: 12px;
}

.ape-row-thirds {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.ape-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.ape-field-wide {
  flex: 1.6;
}

.ape-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ape-hint {
  font-weight: 400;
  text-transform: none;
  color: var(--text-tertiary);
  letter-spacing: 0;
}

.ape-input,
.ape-select,
.ape-textarea {
  background: #091222;
  border: 1px solid #28425f;
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.ape-textarea {
  resize: vertical;
  line-height: 1.5;
  min-height: 60px;
}

.ape-input:focus,
.ape-select:focus,
.ape-textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.ape-select {
  cursor: pointer;
  appearance: auto;
}

.ape-footer {
  padding: 12px 20px;
  border-top: 1px solid #1f2a3d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ape-footer-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

.ape-footer-actions {
  display: flex;
  gap: 8px;
}

.ape-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.ape-btn-cancel {
  border: 1px solid var(--border-color);
  background: var(--bg-2);
  color: var(--text-primary);
}

.ape-btn-cancel:hover {
  background: var(--bg-3);
  border-color: #475569;
}

.ape-btn-save {
  border: none;
  background: #4f46e5;
  color: #fff;
}

.ape-btn-save:hover {
  background: #4338ca;
}

.ape-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ape-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  min-height: 42px;
  background: #091222;
  border: 1px solid #28425f;
  border-radius: 8px;
  align-items: center;
}

.ape-chips:focus-within {
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.ape-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: rgba(79, 70, 229, 0.18);
  border: 1px solid rgba(79, 70, 229, 0.45);
  color: #c7d2fe;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  text-transform: lowercase;
  letter-spacing: 0.1px;
}

.ape-chip-x {
  border: none;
  background: transparent;
  color: #c7d2fe;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 0.7;
}

.ape-chip-x:hover {
  opacity: 1;
  color: #fff;
}

.ape-chip-input {
  flex: 1;
  min-width: 140px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 4px;
}

.ape-chip-input:focus {
  outline: none;
}

.ape-suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ape-suggest-chip {
  padding: 3px 9px;
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  text-transform: lowercase;
  transition: all 0.15s;
}

.ape-suggest-chip:hover {
  border-color: #4f46e5;
  color: #c7d2fe;
  background: rgba(79, 70, 229, 0.08);
}

.ape-helper-text {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.4;
}

.pipeline-status {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #a78bfa;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.pipeline-dropdown {
  margin-top: 8px;
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-radius: 6px;
  overflow: hidden;
}

.pipeline-summary-toggle {
  cursor: pointer;
  padding: 4px 10px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.06);
  user-select: none;
  list-style: none;
}

.pipeline-summary-toggle::-webkit-details-marker {
  display: none;
}

.pipeline-summary-toggle::before {
  content: '▸ ';
}

details[open] > .pipeline-summary-toggle::before {
  content: '▾ ';
}

.pipeline-content {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
}

.pipeline-steps {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #a78bfa;
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
}

.pipeline-step {
  display: block;
}

.pipeline-ms {
  color: rgba(167, 139, 250, 0.4);
  font-size: 10px;
}

.pipeline-cost {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(167, 139, 250, 0.1);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.pipeline-cost-label {
  color: var(--text-tertiary);
}

.pipeline-savings {
  color: #34d399;
  font-weight: 600;
}

.pipeline-hlsf {
  margin-top: 6px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #f0abfc;
}

.quick-reply-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.quick-reply-btn {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.quick-reply-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: #6366f1;
}

.recommended-prompt-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 10px 12px 12px;
  border: 1px solid rgba(124, 155, 255, 0.18);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(17, 20, 36, 0.96), rgba(13, 16, 28, 0.96));
}

.recommended-prompt-strip.hidden {
  display: none;
}

.recommended-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.recommended-prompt-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.recommended-prompt-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.recommended-prompt-subtitle {
  font-size: 11px;
  color: var(--muted);
}

/* Collapse chevron for this strip alone — deliberately NOT shared with
   #chatControlsRow's own toggle (see the doc comment on
   _buildRecommendedPromptHeader, app.js) so it still works when that row is
   hidden in Simple Mode. */
.recommended-prompt-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
}
.recommended-prompt-collapse:hover {
  color: var(--text);
}
.recommended-prompt-collapse svg {
  width: 12px;
  height: 12px;
  display: block;
  pointer-events: none;
  transition: transform 0.2s ease;
}
.recommended-prompt-strip.is-collapsed .recommended-prompt-collapse svg {
  transform: rotate(-90deg);
}
.recommended-prompt-strip.is-collapsed .recommended-prompt-bar {
  display: none;
}

.recommended-prompt-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recommended-prompt-btn {
  appearance: none;
  border: 1px solid rgba(124, 155, 255, 0.24);
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
  white-space: nowrap;
}

.recommended-prompt-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 155, 255, 0.55);
  background: rgba(99, 102, 241, 0.22);
}

.recommended-prompt-btn.is-question {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.25);
  color: #99f6d2;
}

.recommended-prompt-btn.is-code {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.28);
  color: #fdba74;
}

.recommended-prompt-btn.is-debug {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.28);
  color: #fca5a5;
}

.recommended-prompt-btn.is-info {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.28);
  color: #7dd3fc;
}

.recommended-prompt-btn.is-creative {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.28);
  color: #d8b4fe;
}

.recommended-prompt-btn.is-library {
  background: rgba(124, 155, 255, 0.12);
  border-color: rgba(124, 155, 255, 0.30);
  color: #a5b4fc;
}

.recommended-prompt-btn.is-library:hover {
  background: rgba(124, 155, 255, 0.22);
  border-color: rgba(124, 155, 255, 0.55);
}

.contextual-action-btn {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.contextual-action-btn:hover {
  background: rgba(52, 211, 153, 0.25);
  border-color: #34d399;
}

.contextual-action-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.chat-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ─── Controls Row Collapse Toggle (desktop) ─────────────────────────── */
.controls-row-toggle {
  display: none; /* hidden by default — shown via JS when disciplines/sources exist */
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.8rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}
.controls-row-toggle:hover {
  color: var(--text);
}
.controls-row-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  font-size: 0.9rem;
}
.controls-row-chevron svg,
.chevron svg {
  width: 12px;
  height: 12px;
  display: block;
  pointer-events: none;
}
.chat-controls-row.collapsed .controls-row-chevron {
  transform: rotate(-90deg);
}
.controls-row-summary {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.controls-row-content {
  display: contents; /* flows children into parent flex — no extra wrapper when expanded */
}
.chat-controls-row.collapsed .controls-row-content {
  display: none;
}
.chat-controls-row.collapsed {
  flex-wrap: nowrap;
  gap: 6px;
}
.chat-controls-row.collapsed .controls-row-summary {
  display: inline;
}
.controls-row-collapsed-hidden {
  display: none !important;
}
/* On mobile, never show the toggle — mobile has its own layout */
@media (max-width: 768px) {
  .controls-row-toggle { display: none !important; }
  .chat-controls-row.collapsed .controls-row-content { display: contents; }
}

.plan-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.plan-approve-btn {
  background: #a78bfa;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.plan-approve-btn:hover {
  background: #8b5cf6;
}

.console-output-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.console-output-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(56, 189, 248, 0.48);
  border-radius: 7px;
  background: rgba(14, 165, 233, 0.14);
  color: #e0f7ff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.console-output-open-btn:hover,
.console-output-open-btn:focus-visible {
  border-color: rgba(103, 232, 249, 0.82);
  background: rgba(14, 165, 233, 0.22);
  outline: none;
}

/* Default Mode inline console (app.js dockConsoleOutputInline): the one real
   #output-panel re-parented into the assistant turn that produced output. A
   fixed, viewport-relative height so the sandbox iframe (flex:1 1 auto inside
   .panel-body) has real room to lay out in a normal-flow chat column; the
   panel is otherwise exactly the Console module, chrome and all. */
.default-mode-inline-console {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}
body.default-mode-enabled .default-mode-inline-console #output-panel.is-inline-in-turn {
  display: flex;
  flex-direction: column;
  height: min(62vh, 560px);
  min-height: 280px;
  flex: none;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2, #0f1526);
}
/* .hidden is `display:none !important` (top of this file); the Studio Shell
   render skips module hiding while Default Mode owns the workspace, but any
   stray .hidden / [hidden] must not be able to blank a docked console. */
body.default-mode-enabled .default-mode-inline-console #output-panel.is-inline-in-turn.hidden,
body.default-mode-enabled .default-mode-inline-console #output-panel.is-inline-in-turn[hidden] {
  display: flex !important;
}

.console-output-action-hint {
  color: rgba(186, 230, 253, 0.72);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.plan-edit-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.plan-edit-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.pricing-body {
  padding: 20px 20px 24px;
}

.pricing-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.pricing-section {
  margin-bottom: 18px;
}

.pricing-section:last-child {
  margin-bottom: 0;
}

.pricing-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.pricing-section ul {
  margin: 0;
  padding-left: 18px;
  color: #e2e2ef;
  line-height: 1.5;
  font-size: 13px;
}

.pricing-sublist {
  margin-top: 10px;
}

.pricing-card {
  border: 1px solid rgba(124, 155, 255, 0.3);
  background: rgba(124, 155, 255, 0.08);
  padding: 12px 14px;
  border-radius: 10px;
}

.pricing-card + .pricing-card {
  margin-top: 12px;
}

.pricing-card p {
  margin: 0 0 8px;
  font-size: 13px;
}

.pricing-math {
  margin: 0;
  color: #c9d4ff;
}

.pricing-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.tier-card {
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  border-radius: 10px;
  padding: 12px 12px 14px;
}

.tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 13px;
}

.tier-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a9b8ff;
  background: rgba(124, 155, 255, 0.12);
  padding: 2px 6px;
  border-radius: 999px;
}

.tier-card ul {
  padding-left: 16px;
  margin: 0 0 8px;
  font-size: 12.5px;
}

.tier-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.tier-cta {
  margin-top: 10px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(124, 155, 255, 0.4);
  background: rgba(124, 155, 255, 0.18);
  color: #d9e4ff;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}

.tier-cta:hover {
  background: rgba(124, 155, 255, 0.28);
}

.pricing-table {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
}

.pricing-table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 8px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--panel-border);
}

.pricing-table.two-col .pricing-table-row {
  grid-template-columns: 1fr 1fr;
}

.pricing-table-row:last-child {
  border-bottom: none;
}

.pricing-table-header {
  background: #1a1a27;
  font-weight: 600;
  color: var(--muted);
}

.pricing-callout {
  margin: 10px 0 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(61, 220, 151, 0.12);
  border: 1px solid rgba(61, 220, 151, 0.3);
  font-size: 12.5px;
}

.pricing-warning {
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.3);
  font-size: 12.5px;
}

.pricing-code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.pricing-muted {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pricing-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 60;
}

.pricing-modal.hidden {
  display: none;
}

.pricing-modal-panel {
  width: min(1100px, 92vw);
  max-height: 90vh;
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(4, 10, 24, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pricing-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--panel-border);
}

.pricing-modal-header h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.pricing-modal-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.pricing-modal-actions {
  display: inline-flex;
  gap: 8px;
  flex-shrink: 0;
}

.pricing-modal-body {
  overflow-y: auto;
  padding: 0 24px 24px;
}

.pricing-modal-body.collapsed {
  display: none;
}

#chat-form {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  gap: 6px;
}

/* .chat-controls-row has to fit the context select plus the response-mode
   pills on one line. Its width tracks #chat-panel at a fixed 34px offset
   (#chat-form padding), and the panel is a mosaic tile whose width the
   viewport does not predict -- hence the container query rather than a
   media query. Under ~309px of panel the row wrapped to a second line and
   cost 38px of composer height (40px -> 78px). Dropping the visible label
   first buys ~49px, holding one line down to ~287px; the select keeps
   aria-label="Context Mode" and the <label> stays clickable, so only the
   repeated word goes. Narrower still, the select and pills alone exceed the
   row and wrapping is the correct outcome.
   .library-disciplines-wrapper shares .context-mode-control, so it is
   excluded -- its "Sources" label heads the discipline pills. */
@container chat-panel (max-width: 308px) {
  .context-mode-control:not(.library-disciplines-wrapper) > span {
    display: none;
  }
}

.credit-banner,
.credit-inline-warning,
.credit-zero,
.throttle {
  width: 100%;
  font-size: 12.5px;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.credit-banner {
  background: rgba(248, 113, 113, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

.credit-inline-warning {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fde68a;
}

.throttle {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-cta {
  border: none;
  background: transparent;
  color: #bfdbfe;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.inline-cta:hover {
  color: var(--text);
}

.credit-zero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.credit-cta {
  display: flex;
  gap: 8px;
}

.credit-inline-warning.hidden,
.credit-banner.hidden,
.credit-zero.hidden,
.throttle.hidden {
  display: none;
}

.usage-nudge {
  width: 100%;
  margin-bottom: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(124, 155, 255, 0.32);
  background: rgba(124, 155, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.usage-nudge-message {
  color: var(--text);
}

.usage-nudge-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.usage-nudge-primary {
  border-color: rgba(124, 155, 255, 0.6);
  color: #dbe4ff;
}

.usage-nudge-secondary {
  color: var(--muted);
}

.credit-link {
  color: #bfdbfe;
  text-decoration: underline;
  cursor: pointer;
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chat-input {
  width: 100%;
  min-height: 100px;
  max-height: 240px;
  resize: vertical;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.credit-preview {
  display: none;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.82;
  align-self: flex-end;
  min-height: 16px;
  max-width: min(100%, 760px);
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}

.credit-preview-main {
  white-space: nowrap;
}

.credit-preview-detail,
.credit-preview-warningline {
  font-size: 11px;
  line-height: 1.35;
  opacity: 0.9;
}

.credit-preview.tol-preview .credit-preview-main {
  color: #b9f4e0;
}

.credit-preview.tol-preview .credit-preview-detail {
  color: #8fb7ff;
}

.credit-preview.warning {
  color: var(--error);
  opacity: 0.98;
}

.credit-preview.warning .credit-preview-warningline {
  color: #ffb4a7;
  opacity: 1;
}

#btn-mic {
  margin-right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1em;
  opacity: 0.7;
  padding: 0;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.playable-btn {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 120px;
  min-height: 40px;
}

.playable-btn-icon {
  font-size: 18px;
  line-height: 1;
}

.playable-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.playable-btn:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.16);
}

.playable-btn-stop {
  min-width: 92px;
}

.playable-btn-stop:hover:not(:disabled) {
  background-color: rgba(255, 102, 102, 0.22);
  border-color: rgba(255, 130, 130, 0.45);
}

.chat-controls {
  width: 100%;
  flex-shrink: 0;
}

.mobile-library-pill svg {
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
}

#playable-controller-btn {
  display: inline-flex !important;
  opacity: 1 !important;
  pointer-events: auto;
  min-height: 40px;
  margin-left: 6px;
}

.chat-input-row {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Full-width chat input redesign */
.chat-input-full {
  width: 100%;
  border: 1px solid var(--panel-border, #2e3a50);
  border-radius: 8px;
  background: var(--input-bg);
  overflow: hidden;
  flex-shrink: 0;
}
.chat-input-full #chat-input {
  width: 100%;
  border: none;
  border-radius: 0;
  min-height: 40px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  background: transparent;
  color: var(--text, #e2e8f0);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.chat-input-full #chat-input:focus {
  box-shadow: none;
}
.chat-input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.2);
  gap: 8px;
}
.restricted-data-notice {
  margin: 4px 2px 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary, #94a3b8);
  text-align: center;
}
.chat-input-left-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}
/* Structural wrapper (Task 4, Default Mode plan) around the GitHub/attach/
   mic/camera/screen buttons — same flex/gap as .chat-input-left-actions
   used to give these buttons directly, so wrapping them costs Developer
   Mode / Mosaic nothing visually. The "+" cluster look (border, background,
   tighter gap) is added only under .default-mode-enabled further below. */
.chat-input-plus-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-tool-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.chat-tool-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}
.chat-tool-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
}

/* Screen share on a device without getDisplayMedia (all mobile browsers
   today) -- reads as off/unavailable, but deliberately NOT the native
   `disabled` attribute: that would swallow the click, and the click is what
   surfaces the explanatory toast (app.js toggle() catching
   LiveMediaContext.start's SCREEN_SHARE_UNSUPPORTED error). */
.capture-unsupported {
  opacity: 0.35;
  cursor: not-allowed;
}
.capture-unsupported:hover {
  opacity: 0.5;
}
.context-crystal-picker {
  position: relative;
  display: inline-flex;
}
.github-picker {
  position: relative;
  display: inline-flex;
}
#btn-github.has-selection {
  color: #d0d7de;
}
.github-picker-menu {
  position: fixed;
  z-index: 600;
  width: min(380px, calc(100vw - 32px));
  max-height: clamp(220px, 52vh, 440px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(7, 12, 20, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}
.github-picker-menu[hidden] { display: none; }
.github-picker-title {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #e6edf3;
  font-size: 12px;
  font-weight: 700;
}
.github-picker-title button {
  padding: 2px 7px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: #d0d7de;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.github-picker-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  padding: 10px;
}
.github-picker-empty {
  color: #8b98a5;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0 0 10px;
}
.github-picker-error {
  color: #ff9b9b;
  font-size: 12px;
  margin: 8px 0 0;
}
.github-picker-connect-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  background: #d0d7de;
  color: #0b0f14;
  font-weight: 700;
  font-size: 12.5px;
  text-decoration: none;
}
.github-picker-connect-btn:hover { background: #ffffff; }
.github-picker-repo-select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  color: #e6edf3;
  font: inherit;
  font-size: 12.5px;
  margin-bottom: 8px;
}
.github-picker-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: #8b98a5;
  margin-bottom: 8px;
}
.github-picker-breadcrumb button {
  background: none;
  border: none;
  color: #8b98a5;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.github-picker-breadcrumb button:hover,
.github-picker-breadcrumb button:last-child {
  color: #e6edf3;
}
.github-picker-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 4px;
  border: none;
  background: none;
  color: #d0d7de;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}
.github-picker-entry:hover { background: rgba(255,255,255,0.06); }
.github-picker-entry-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.github-picker-imported {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.github-picker-imported-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #8b98a5;
  margin-bottom: 6px;
}
.github-picker-imported-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  color: #d0d7de;
}
.github-picker-imported-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.github-picker-imported-row button {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #8b98a5;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.github-picker-imported-row button:hover { color: #ff9b9b; }
.github-picker-imported-row-indexing { color: #8b98a5; }
.github-picker-indexing-label {
  flex: 0 0 auto;
  font-size: 11px;
  color: #d29922;
  animation: github-picker-indexing-pulse 1.4s ease-in-out infinite;
}
@keyframes github-picker-indexing-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .github-picker-indexing-label { animation: none; opacity: 1; }
}
.github-picker-footer {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.github-picker-import-btn {
  width: 100%;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #e6edf3;
  font: inherit;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}
.github-picker-import-btn:disabled { opacity: 0.42; cursor: default; }
.github-picker-import-btn:not(:disabled):hover { background: rgba(255,255,255,0.14); }
#btn-context-crystal.has-selection,
#conv-btn-crystal.has-selection {
  color: #8fffe8;
  background: rgba(125, 249, 200, 0.12);
}
/* The Converse trigger sits in the voice toolbar next to Attach and shares the
   chat picker. Border included because .conversation-media-btn is a bordered
   pill, unlike the borderless .chat-tool-btn icons. */
#conv-btn-crystal.has-selection {
  border-color: rgba(125, 249, 200, 0.45);
}
.context-crystal-menu {
  position: fixed;
  z-index: 600;
  width: min(430px, calc(100vw - 32px));
  max-height: clamp(280px, 52vh, 480px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(125, 249, 200, 0.22);
  border-radius: 8px;
  background: rgba(7, 12, 20, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}
.context-crystal-menu[hidden] {
  display: none;
}
.context-crystal-menu-title {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(7, 12, 20, 0.98);
  color: #d7fff8;
  font-size: 12px;
  font-weight: 700;
}
.context-crystal-menu-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  padding: 10px;
}
.context-crystal-menu > .context-crystal-empty {
  padding: 12px;
}
.context-crystal-menu-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.context-crystal-menu-actions button {
  padding: 2px 7px;
  border: 1px solid rgba(125, 249, 200, 0.28);
  border-radius: 999px;
  background: rgba(125, 249, 200, 0.08);
  color: #b8fff0;
  font: inherit;
  cursor: pointer;
}
.context-crystal-menu-actions button:disabled {
  opacity: 0.42;
  cursor: default;
}
.context-crystal-new {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(125, 249, 200, 0.35);
  border-radius: 999px;
  background: rgba(125, 249, 200, 0.10);
  color: #b8fff0;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.context-crystal-new:hover { background: rgba(125, 249, 200, 0.2); }
.context-crystal-menu-note,
.context-crystal-empty {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}
.context-crystal-key-group + .context-crystal-key-group {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.context-crystal-library-group {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.context-crystal-key-name {
  margin-bottom: 6px;
  color: #a5f3fc;
  font-size: 11px;
  font-weight: 800;
}
/* .context-crystal-key-name doubles as the <summary> for the collapsed
   Industry-libraries <details> — cursor + spacing only; the native
   disclosure marker stays (no custom chevron, needs no JS to keep in sync). */
summary.context-crystal-key-name {
  cursor: pointer;
  list-style-position: outside;
  user-select: none;
}
.context-crystal-library-group[open] > .context-crystal-library-grid {
  margin-top: 8px;
}
.context-crystal-library-grid {
  display: grid;
  gap: 8px;
}
.context-crystal-library-card {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--library-accent, #7df9c8) 42%, rgba(255,255,255,0.14));
  border-radius: 8px;
  background: color-mix(in srgb, var(--library-accent, #7df9c8) 10%, rgba(15, 23, 42, 0.92));
}
.context-crystal-library-head {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.context-crystal-library-head img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: cover;
}
.context-crystal-library-head strong,
.context-crystal-library-head span {
  display: block;
  overflow-wrap: anywhere;
}
.context-crystal-library-head strong {
  color: var(--text);
  font-size: 12px;
}
.context-crystal-library-head span {
  margin-top: 1px;
  color: #a6b0c3;
  font-size: 10.5px;
  line-height: 1.35;
}
.context-crystal-library-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.context-crystal-library-samples span {
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  color: var(--text-primary);
  font-size: 10.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.context-crystal-library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}
.context-crystal-library-trial,
.context-crystal-library-link,
.context-crystal-library-status {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}
.context-crystal-library-trial {
  background: var(--library-accent, #7df9c8);
  color: #071014;
}
.context-crystal-library-link {
  border: 1px solid rgba(255,255,255,0.14);
  color: #d7fff8;
}
.context-crystal-library-status {
  background: rgba(125, 249, 200, 0.12);
  color: #b8fff0;
}
.context-crystal-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 6px 4px;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}
.context-crystal-option:hover {
  background: rgba(255,255,255,0.06);
}
.context-crystal-option input {
  margin-top: 2px;
}
.context-crystal-handle {
  display: block;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.context-crystal-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11px;
}
.chat-send-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.chat-thinking-depth-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #a6b0c3;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}
.chat-thinking-depth-control select {
  height: 28px;
  min-width: 58px;
  border: 1px solid rgba(125, 157, 255, 0.35);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.82);
  color: #dbeafe;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 0 22px 0 8px;
}
.chat-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.9; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-send-btn.is-stopping { background: #dc2626; }
.chat-send-btn.is-stopping:hover { opacity: 0.85; }

/* Icon-arrow-in-a-triangle glyph for Send, swaps to a stop-square while
   generating. Persistent so JS can keep swapping just the text label
   (see updateSendButton in app.js) without wiping the icon out. */
.chat-send-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  display: none;
}
.chat-send-icon-arrow { display: block; }
.chat-send-btn.is-stopping .chat-send-icon-arrow { display: none; }
.chat-send-btn.is-stopping .chat-send-icon-stop { display: block; }

@media (max-width: 640px) {
  .chat-input-toolbar {
    flex-wrap: wrap;
  }
  .chat-send-controls {
    margin-left: auto;
  }
  .chat-thinking-depth-control span {
    display: none;
  }
}

/* Same icon-only/wrap treatment as the viewport media query above, but keyed
   to the chat panel's own width. A mosaic tile or popped-out module window
   can be narrow on a wide desktop viewport, where the media query above
   never fires — without this, the toolbar doesn't wrap and Send can get
   clipped by the tile's overflow:hidden instead of staying reachable. */
@container chat-panel (max-width: 480px) {
  .chat-input-toolbar {
    flex-wrap: wrap;
  }
  .chat-send-controls {
    margin-left: auto;
  }
  .chat-thinking-depth-control span {
    display: none;
  }
  .chat-send-label {
    display: none;
  }
  .chat-send-btn {
    padding: 6px 9px;
    min-width: 30px;
    justify-content: center;
  }
}

/* ── Attachment pills ────────────────────────── */
.attachment-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  width: 100%;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(100, 120, 255, 0.15);
  border: 1px solid rgba(100, 120, 255, 0.35);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text);
  max-width: min(100%, 500px);
}

.attachment-pill .pill-name,
.attachment-pill .attachment-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: none;
}

.attachment-pill .attachment-pill-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.attachment-pill .attachment-pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-pill .pill-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
}

.attachment-pill .pill-remove:hover {
  opacity: 1;
}

.auditory-analysis-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-width: 680px;
}

.auditory-analysis-card {
  overflow: hidden;
  border: 1px solid rgba(91, 167, 142, 0.34);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(15, 63, 52, 0.2), rgba(9, 18, 24, 0.86)),
    repeating-linear-gradient(90deg, transparent 0 13px, rgba(129, 215, 185, 0.025) 13px 14px);
  color: #d9eee7;
}

.auditory-analysis-card > summary {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.45;
  color: #bfe6d8;
}

.auditory-analysis-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.auditory-analysis-metrics,
.auditory-analysis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.auditory-analysis-metrics span {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(129, 215, 185, 0.09);
  color: #9fc8ba;
  font-size: 10px;
}

.auditory-analysis-transcript {
  max-height: 110px;
  overflow: auto;
  margin: 0;
  padding: 8px 10px;
  border-left: 2px solid rgba(129, 215, 185, 0.35);
  color: #c7d8d2;
  font-size: 11px;
  line-height: 1.55;
}

.auditory-analysis-events {
  display: grid;
  gap: 4px;
}

.auditory-analysis-event {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  font-size: 10px;
  color: #8ca99f;
}

.auditory-analysis-event strong {
  overflow: hidden;
  color: #dcece6;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auditory-analysis-actions button {
  padding: 5px 9px;
  border: 1px solid rgba(129, 215, 185, 0.3);
  border-radius: 6px;
  background: rgba(8, 28, 24, 0.7);
  color: #bfe6d8;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
}

.auditory-analysis-actions button:hover {
  background: rgba(44, 101, 83, 0.45);
}

.auditory-analysis-muted {
  margin: 0;
  color: #789087;
  font-size: 10px;
}

@media (max-width: 640px) {
  .auditory-analysis-event {
    grid-template-columns: 68px minmax(0, 1fr) 36px;
  }
}

#btn-attach {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1em;
  opacity: 0.7;
  padding: 0;
}

#btn-attach:hover {
  opacity: 1;
}


#btn-mic.listening {
  color: var(--error);
  opacity: 1;
}

#btn-camera, #btn-screen {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1em;
  opacity: 0.7;
  padding: 0;
  margin-left: 4px;
}

#btn-camera:hover, #btn-screen:hover {
  opacity: 1;
}

#btn-camera.active, #btn-screen.active {
  color: var(--error);
  opacity: 1;
}

#btn-camera.active::after, #btn-screen.active::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--error);
  margin-left: 4px;
  vertical-align: middle;
  animation: media-indicator-pulse 1.4s ease-in-out infinite;
}

@keyframes media-indicator-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.conv-media-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.conv-media-indicator[hidden] { display: none; }

.media-indicator-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(255, 80, 80, 0.45);
  color: #ffe4e4;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78em;
  line-height: 1.2;
}

.media-indicator-pill .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  animation: media-indicator-pulse 1.4s ease-in-out infinite;
}

.media-indicator-pill .pill-stop {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1em;
  opacity: 0.75;
  padding: 0 2px;
  line-height: 1;
}

.media-indicator-pill .pill-stop:hover { opacity: 1; }

/* Vision describe failure indicator on toolbar buttons */
.vision-error { position: relative; }
.vision-error::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error, #ff5050);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.conv-drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--overlay-tint), 0.78);
  backdrop-filter: blur(4px);
  z-index: 50;
  pointer-events: none;
  border: 2px dashed rgba(124, 155, 255, 0.6);
  border-radius: 12px;
  animation: conv-drop-fade-in 120ms ease-out;
}

.conv-drop-overlay[hidden] { display: none; }

.conv-drop-overlay-inner {
  text-align: center;
  color: #d8e2ff;
  pointer-events: none;
}

.conv-drop-overlay-icon {
  font-size: 2.4em;
  margin-bottom: 8px;
}

.conv-drop-overlay-text {
  font-size: 1.05em;
  font-weight: 500;
}

@keyframes conv-drop-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

#runCode {
  display: none;
}

#rollbackButton {
  display: none;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: #a1a1aa;
}

#promoteButton {
  display: none;
  background: transparent;
  border: 1px solid rgba(124, 155, 255, 0.4);
  color: #d8e2ff;
}

#rollbackButton:hover {
  border-color: rgba(124, 155, 255, 0.5);
  color: var(--text-primary);
}

#promoteButton:hover {
  border-color: rgba(124, 155, 255, 0.7);
  color: var(--text-primary);
}

.loading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  opacity: 0.7;
}

.loading-label {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.loading.hidden {
  display: none;
}

.dot {
  animation: fade 1.4s infinite both;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes fade {
  0% { opacity: 0.2; }
  20% { opacity: 1; }
  100% { opacity: 0.2; }
}

.timer {
  margin-left: 8px;
  font-size: 12px;
  opacity: 0.6;
}

button {
  background: var(--accent);
  border: none;
  color: #0b0b0f;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#revertButton.runtime-running::after,
#forwardButton.runtime-running::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #f4c24f;
  display: inline-block;
  margin-left: 6px;
  box-shadow: 0 0 0 2px rgba(244, 194, 79, 0.2);
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.ghost-button:hover {
  border-color: rgba(124, 155, 255, 0.6);
  color: var(--accent);
}

.interface-status {
  font-size: 12px;
  opacity: 0.7;
  padding: 4px 8px;
}

.preview-status {
  font-size: 12px;
  opacity: 0.7;
  padding: 4px 8px;
  color: var(--muted);
}

.preview-execution-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-execution-status.idle {
  color: var(--muted);
  border-color: rgba(165, 165, 181, 0.3);
  background: rgba(165, 165, 181, 0.1);
}

.preview-execution-status.ready {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.12);
}

.preview-execution-status.preparing {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
}

.preview-execution-status.stale {
  color: #fb7185;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

.preview-execution-status.running {
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
}

.preview-execution-status.capped {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
}

.preview-execution-status.heavy {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

.preview-execution-status.stopped {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.12);
}

.preview-execution-status.completed {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.4);
  background: rgba(167, 139, 250, 0.12);
}

.execution-warnings {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
  /* Lives inside the console toolbar's flex row: shrink instead of running
     under the reload/follow buttons, and truncate with the full text on
     title (set by setExecutionWarnings). */
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(420px, 50%);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.execution-warnings.hidden {
  display: none;
}

.preview-error-banner {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  font-size: 12px;
  font-weight: 600;
}

.preview-error-banner.hidden {
  display: none;
}

.preview-controls {
  display: flex;
  gap: 8px;
  margin: 8px 0 10px;
}

.preview-controls .ghost-button.is-active {
  border-color: rgba(74, 222, 128, 0.45);
  color: #bbf7d0;
}

.sandbox-controls {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
}

.sandbox-controls.hidden {
  display: none;
}

.sandbox-controls .ghost-button {
  padding: 4px 10px;
}

.interface-status.updated {
  color: #4ade80;
}

.interface-status.unchanged {
  color: #a1a1aa;
}

#secondary-column {
  position: relative;
}


#workspace.workspace-pipeline-mode #secondary-column {
  overflow: hidden;
  min-height: 0;
}

#workspace.workspace-pipeline-mode #code-panel,
#workspace.workspace-pipeline-mode #output-panel,
#workspace.workspace-pipeline-mode #agents-panel {
  min-height: 0;
}

#workspace.workspace-pipeline-mode #code-panel {
  flex: 2 1 0;
}

#workspace.workspace-pipeline-mode #output-panel {
  flex: 1 1 0;
}

#workspace.workspace-pipeline-mode #agents-panel {
  flex: 1 1 0;
}

#left-pane .splitter,
#secondary-column .splitter {
  height: 6px;
  cursor: row-resize;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  flex-shrink: 0;
}

#left-pane .splitter:hover,
#secondary-column .splitter:hover {
  background: rgba(255, 255, 255, 0.18);
}

#code-editor-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 100%;
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  background: #07070d;
}

#code-editor {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
}

#code-editor .monaco-editor,
#code-editor .monaco-editor .overflow-guard {
  height: 100%;
}

.panel-footer.actions {
  justify-content: flex-end;
}

/* Compact icon-based toolbars for code editor footer and console header */
.code-toolbar {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  min-height: 0;
}
.code-toolbar-meta {
  font-size: 10px;
  color: var(--muted);
  font-family: monospace;
  margin-right: 4px;
}
.code-toolbar-spacer { flex: 1; }
.code-toolbar-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
  width: 28px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
  padding: 0;
}
.code-toolbar-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  border-color: var(--panel-border);
}
.code-toolbar-btn:disabled {
  opacity: 0.25;
  cursor: default;
}
.code-toolbar-btn:disabled:hover {
  background: none;
  border-color: transparent;
  color: var(--muted);
}
.code-toolbar-btn.is-active {
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.25);
  background: rgba(94, 234, 212, 0.08);
}
.code-toolbar-btn.is-active:hover {
  color: #5eead4;
  background: rgba(94, 234, 212, 0.14);
}
/* ── Multi-file bar (Code module) — shared studioFiles manifest ─────────────── */
.code-file-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  min-height: 30px;
  flex: 0 0 auto;
}
.code-file-bar.hidden { display: none; }
.code-file-bar-toggle,
.code-file-new {
  background: none;
  border: 1px solid transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.code-file-bar-toggle:hover,
.code-file-new:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  border-color: var(--panel-border);
}
.code-file-bar-toggle { transition: transform 0.12s, color 0.1s; }
.code-file-bar.collapsed .code-file-bar-toggle { transform: rotate(-90deg); }
.code-file-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1 1 auto;
  min-width: 0;
}
.code-file-tabs::-webkit-scrollbar { height: 4px; }
.code-file-tabs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.code-file-bar.collapsed .code-file-tabs { display: none; }
.code-file-summary {
  display: none;
  font-size: 11.5px;
  color: var(--text-tertiary);
  padding: 0 6px;
  white-space: nowrap;
}
.code-file-bar.collapsed .code-file-summary { display: inline; }
.code-file-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 9px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.code-file-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.07); }
.code-file-tab.active {
  color: #5eead4;
  background: rgba(94, 234, 212, 0.09);
  border-color: rgba(94, 234, 212, 0.28);
}
.code-file-tab.is-entry .code-file-tab-name::before {
  content: '▸ ';
  color: rgba(94, 234, 212, 0.7);
}
.code-file-tab-close {
  border: none;
  background: none;
  color: inherit;
  opacity: 0.5;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0 1px;
  border-radius: 3px;
}
.code-file-tab-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }

/* Editor system message (error surface in bottom toolbar) */
.editor-system-message {
  font-size: 11px;
  color: #f87171;
  padding: 2px 8px;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
  border-radius: 4px;
  transition: background 0.15s ease;
}
.editor-system-message.has-error {
  background: rgba(248, 113, 113, 0.1);
}
.editor-system-message.expanded {
  white-space: normal;
  max-width: 80%;
  position: absolute;
  bottom: 32px;
  left: 80px;
  right: 80px;
  z-index: 10;
  background: var(--bg-3);
  border: 1px solid rgba(248, 113, 113, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
}
.auto-repair-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-left: 4px;
  flex-shrink: 0;
  user-select: none;
}
.auto-repair-toggle input[type="checkbox"] {
  width: 12px;
  height: 12px;
  accent-color: #34d399;
}
.auto-repair-toggle:hover {
  color: var(--text-secondary);
}

.code-toolbar-run {
  color: #34d399;
  font-size: 13px;
}
.code-toolbar-run:hover {
  color: #6ee7b7;
  background: rgba(52,211,153,0.1);
  border-color: rgba(52,211,153,0.3);
}

/* Console compact header */
.console-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow-x: auto;
  min-height: 32px;
  flex-shrink: 0;
}
.console-toolbar .code-toolbar-btn {
  flex-shrink: 0;
  overflow: hidden;
}
.console-toolbar .console-status-chip {
  flex-shrink: 0;
}
.console-toolbar .console-status-label {
  flex-shrink: 1;
}
/* Splits the reload/follow-editor cluster from the report-issue/fullscreen
   utility cluster — six icon buttons in a row with no grouping read as one
   undifferentiated strip. */
.console-toolbar-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--panel-border);
  flex: 0 0 auto;
  margin: 0 2px;
}
.console-status-chip {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.console-status-chip.idle { color: var(--text-tertiary); }
.console-status-chip.running { color: #34d399; }
.console-status-chip.error { color: #f87171; }
.console-status-label {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

#code-footer {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-right: auto;
}

.code-editor,
.output-panel {
  flex: 1 1 50%;
  min-height: 0;
  overflow: hidden;
}

.console-output {
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;
  cursor: zoom-in;
}

/* Native Fullscreen API styling */
.console-output:fullscreen,
.console-output:-webkit-full-screen {
  background: #000;
  display: flex;
  cursor: zoom-out;
  width: 100vw;
  height: 100vh;
}

.console-output:fullscreen .preview-frame-container,
.console-output:-webkit-full-screen .preview-frame-container {
  flex: 1;
  width: 100%;
  height: 100%;
}

.console-output:fullscreen #sandbox,
.console-output:-webkit-full-screen #sandbox {
  width: 100%;
  height: 100%;
}

.console-output:fullscreen #fullscreenToggle,
.console-output:-webkit-full-screen #fullscreenToggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000000;
}

/* CSS fallback for browsers without Fullscreen API */
.console-output.preview-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #000;
  display: flex;
  cursor: zoom-out;
}

.output-panel.preview-fullscreen #fullscreenToggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000000;
}

.fullscreen-exit {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #555;
}

/* Floating exit button visible only during native fullscreen */
.fullscreen-exit-float {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #555;
  color: #fff;
  font-size: 18px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
}
.fullscreen-exit-float:hover {
  background: rgba(255, 255, 255, 0.15);
}

.output-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.output-panel .panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.console-output-log {
  overflow: auto;
  max-height: 40%;
}

/* Collapsible pipeline log group */
.pipeline-log-group {
  border: 1px solid var(--panel-border, #232334);
  border-radius: 6px;
  margin: 4px 0;
  background: rgba(0,0,0,0.15);
}
.pipeline-log-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
}
.pipeline-log-toggle:hover {
  color: var(--text, #ccc);
  background: rgba(255,255,255,0.04);
}
.pipeline-log-entries {
  padding: 0 8px 4px;
}
.pipeline-log-entries.collapsed {
  display: none;
}

.console-output iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.preview-frame-container {
  width: 100%;
  height: 100%;
  display: flex;
}

.preview-frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.output-panel iframe {
  flex: 1 1 auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.output-panel.loading iframe {
  opacity: 0;
  transform: scale(0.98);
}

.generation-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--bg-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.generation-indicator.active {
  color: var(--text);
  border-color: rgba(124, 155, 255, 0.6);
  background: rgba(124, 155, 255, 0.12);
}

.message {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.message.user {
  background: rgba(124, 155, 255, 0.2);
  border: 1px solid rgba(124, 155, 255, 0.4);
}

.msg-turn-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 3px;
}

.msg-sender-attribution {
  font-size: 0.72rem;
  font-weight: 600;
  color: #7c9bff;
  cursor: pointer;
  text-decoration: underline dotted rgba(124, 155, 255, 0.4);
  text-underline-offset: 2px;
  letter-spacing: 0.02em;
}
.msg-sender-attribution:hover {
  color: #a8bfff;
  text-decoration-color: rgba(168, 191, 255, 0.6);
}
.msg-sender-attribution.msg-sender-anon {
  cursor: default;
  text-decoration: none;
  opacity: 0.7;
}

/* Prompt-origin dot: how this turn's text arrived (see _PROMPT_ORIGIN_BADGES
   in app.js for the exact tooltip strings, kept in sync with these colors). */
.turn-origin-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.turn-origin-dot.origin-suggested {
  background: #f4f6ff;
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.turn-origin-dot.origin-pasted {
  background: #f5d94e;
}
.turn-origin-dot.origin-prepared {
  background: #f5a94e;
}
.turn-origin-dot.origin-own-mind {
  background: #ff5c5c;
  box-shadow: 0 0 6px 2px rgba(255, 92, 92, 0.65);
}

/* Camera/screen session-state icons: dim + slashed when off, lit when on. */
.turn-media-icon {
  position: relative;
  display: inline-flex;
  font-size: 0.78rem;
  line-height: 1;
  opacity: 0.9;
}
.turn-media-icon.is-off {
  opacity: 0.35;
  filter: grayscale(1);
}
.turn-media-icon.is-off::after {
  content: '';
  position: absolute;
  left: -1px;
  right: -1px;
  top: 50%;
  height: 1px;
  background: currentColor;
  background: #ff5c5c;
  transform: rotate(-45deg);
}

.turn-timeago {
  font-size: 0.68rem;
  color: rgba(230, 235, 255, 0.55);
  cursor: default;
  white-space: nowrap;
}

/* Regular (non-shared-thread) Chat/Converse turns: the timestamp stays out
   of sight until the turn is hovered, so every bubble doesn't carry a
   permanent "9 minutes ago" label. Touch devices have no hover concept, so
   they keep it visible at all times instead of behind an undiscoverable
   gesture. */
.message-timeago-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
@media (hover: hover) and (pointer: fine) {
  .turn-timeago-reveal {
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  .message:hover .turn-timeago-reveal,
  .message:focus-within .turn-timeago-reveal {
    opacity: 1;
  }
}

/* JIT concept linking — a dotted underline marks a concept the reader
   attentively dwelled on that a cheap classifier judged grad/PhD-level (see
   hlsf/conceptDifficultyLinking.js). Deliberately understated: this augments
   reading, it should never look like a normal hyperlink or draw the eye away
   from the turn itself. */
.jit-concept-link {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: rgba(124, 155, 255, 0.65);
  text-underline-offset: 2px;
}
.jit-concept-link:hover,
.jit-concept-link:focus-visible {
  text-decoration-color: rgba(124, 155, 255, 0.95);
  outline: none;
}

/* Single shared floating tooltip (see _ensureJitTooltip in app.js) rather
   than one per span — fixed positioning sidesteps the overflow-clipping
   issues the per-badge .skg-triple-tooltip pattern has inside scrollable
   chat panels. */
.jit-concept-tooltip {
  position: fixed;
  z-index: 200;
  max-width: min(320px, calc(100vw - 32px));
  background: var(--bg-2, #14162a);
  border: 1px solid rgba(124, 155, 255, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text, #e8ecf8);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  /* Interactive, not just visible -- the gap between the underlined word and
     this box (positioned a few px below it) has to be crossable to reach
     the Wikipedia link, and a hide-on-mouseout with no grace period would
     close it the instant the cursor entered that gap. See the
     _scheduleJitTooltipHide pairing in app.js. */
  pointer-events: auto;
}
.jit-concept-tooltip.hidden { display: none; }
.jit-tooltip-def { margin-bottom: 6px; }
.jit-tooltip-related {
  color: var(--text-secondary, rgba(230, 235, 255, 0.7));
  font-size: 11.5px;
  margin-bottom: 6px;
}
.jit-tooltip-link {
  display: inline-block;
  color: #9db4ff;
  font-size: 11.5px;
  font-weight: 600;
}

/* Testing Environment: owner-only reading-engagement button + panel. */
.reading-engagement-btn {
  background: rgba(124, 155, 255, 0.15);
  border: 1px solid rgba(124, 155, 255, 0.4);
  color: #cdd8ff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  margin-left: 6px;
}
.reading-engagement-btn:hover {
  background: rgba(124, 155, 255, 0.25);
}

.reading-engagement-modal {
  max-width: 720px;
  max-height: 70vh;
  overflow-y: auto;
}
.reading-engagement-disclaimer {
  font-size: 0.8rem;
  color: rgba(230, 235, 255, 0.6);
  margin-bottom: 14px;
}
.reading-engagement-reader {
  margin-bottom: 20px;
}
.reading-engagement-reader h4 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.reading-engagement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.reading-engagement-table th,
.reading-engagement-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.reading-flag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  white-space: nowrap;
}
.reading-flag-skimmed {
  background: rgba(245, 217, 78, 0.18);
  color: #f5d94e;
}
.reading-flag-unattended {
  background: rgba(255, 92, 92, 0.18);
  color: #ff5c5c;
}
.reading-flag-uniform-pattern {
  background: rgba(255, 140, 66, 0.18);
  color: #ff8c42;
}
.reading-flag-none {
  color: rgba(230, 235, 255, 0.4);
  font-size: 0.78rem;
}

.sender-action-modal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
  min-width: 220px;
}
.sender-action-modal .sender-action-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sender-action-modal .sender-action-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: #e0e6f0;
}
.sender-action-modal .sender-action-handle {
  font-size: 0.78rem;
  color: rgba(124, 155, 255, 0.7);
}
.sender-action-modal .sender-action-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: rgba(124, 155, 255, 0.12);
  border: 1px solid rgba(124, 155, 255, 0.25);
  border-radius: 6px;
  color: #c0d0ff;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.sender-action-modal .sender-action-btn:hover {
  background: rgba(124, 155, 255, 0.22);
  border-color: rgba(124, 155, 255, 0.45);
}

/* ─── @mention highlighting ─────────────────────────────────────────── */
.msg-mention {
  color: #7c9bff;
  font-weight: 600;
  background: rgba(124, 155, 255, 0.12);
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
}
.msg-mention:hover {
  background: rgba(124, 155, 255, 0.25);
  text-decoration: underline;
}

/* ─── Thread-only messages (not directed at AI) ─────────────────────── */
.message.thread-only {
  border-left: 3px solid rgba(124, 155, 255, 0.45);
  background: rgba(124, 155, 255, 0.04);
  position: relative;
}
.message.thread-only::before {
  content: 'thread';
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(124, 155, 255, 0.55);
  font-weight: 600;
}

.message.assistant {
  background: var(--bg-hover);
  border: 1px solid var(--panel-border);
  white-space: normal;
  line-height: 1.55;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4,
.message.assistant h5,
.message.assistant h6 {
  margin: 1.4rem 0 0.5rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.message.assistant h1:first-child,
.message.assistant h2:first-child,
.message.assistant h3:first-child,
.message.assistant h4:first-child {
  margin-top: 0;
}

.message.assistant h1 {
  font-size: 1.15rem;
  color: var(--text);
}

.message.assistant h2 {
  font-size: 1.05rem;
  color: var(--text-primary);
}

.message.assistant h3 {
  font-size: 0.97rem;
  color: var(--text-secondary);
}

.message.assistant h4,
.message.assistant h5,
.message.assistant h6 {
  font-size: 0.93rem;
  color: var(--text-tertiary);
  font-weight: 600;
}

/* Suppress orphaned <br> elements that markdown-it emits directly after
 * list containers when breaks:true is enabled. */
.message.assistant ul + br,
.message.assistant ol + br {
  display: none;
}

/* Post-response contribution badge: appears after a text turn
 * once haiku triple extraction completes. Subtle, non-interactive. */
.skg-triple-badge {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.06);
  border: 1px solid rgba(52, 211, 153, 0.12);
  border-radius: 20px;
  padding: 2px 10px;
  pointer-events: none;
  user-select: none;
  animation: skg-badge-fade-in 0.4s ease;
}

.skg-loop-badge {
  display: inline-block;
  margin-top: 0.75rem;
  margin-left: 0.5rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: rgba(168, 85, 247, 0.65);
  background: rgba(168, 85, 247, 0.06);
  border: 1px solid rgba(168, 85, 247, 0.15);
  border-radius: 20px;
  padding: 2px 10px;
  pointer-events: none;
  user-select: none;
  animation: skg-badge-fade-in 0.4s ease;
}

.skg-loop-badge--dev {
  pointer-events: auto;
  cursor: default;
  position: relative;
}

.skg-loop-badge--dev:hover .skg-triple-tooltip {
  display: block;
}

.mosaic-tile-header .skg-loop-badge,
.agent-panel-header .skg-loop-badge,
.console-toolbar .skg-loop-badge,
#conversation-overlay-role .skg-loop-badge {
  margin-top: 0;
  margin-left: 0.5rem;
}

.skg-triple-badge--dev {
  pointer-events: auto;
  cursor: default;
  position: relative;
}

/* Badge inside a panel/tile header — sits inline in the flex row, no top margin,
   tooltip drops DOWN so it doesn't escape above the panel edge. */
.mosaic-tile-header .skg-triple-badge,
.agent-panel-header .skg-triple-badge,
.console-toolbar .skg-triple-badge,
#conversation-overlay-role .skg-triple-badge {
  margin-top: 0;
  margin-left: auto;
}

.mosaic-tile-header .skg-triple-tooltip,
.agent-panel-header .skg-triple-tooltip,
.console-toolbar .skg-triple-tooltip,
#conversation-overlay-role .skg-triple-tooltip {
  top: calc(100% + 6px);
  bottom: auto;
  max-width: min(520px, calc(100vw - 32px));
  max-height: min(58vh, 360px);
}

.console-toolbar:has(.skg-triple-badge--dev:hover),
.console-toolbar:has(.skg-loop-badge--dev:hover) {
  overflow: visible;
}

.agent-panel-header:has(.skg-triple-badge--dev:hover),
.agent-panel-header:has(.skg-loop-badge--dev:hover) {
  overflow: visible;
}

.console-toolbar .skg-triple-tooltip {
  left: auto;
  right: 0;
}

.agent-panel-header .skg-triple-tooltip,
.agent-panel-header .skg-nested-tip {
  left: auto;
  right: 0;
}

.console-toolbar .skg-nested-tip {
  left: auto;
  right: 0;
}

/* Badges on right-side modules flow left so tooltips don't clip the viewport */
[data-tile-module="converse"] .skg-triple-tooltip,
[data-tile-module="companion"] .skg-triple-tooltip,
[data-tile-module="console"] .skg-triple-tooltip,
[data-tile-module="code"] .skg-triple-tooltip {
  left: auto;
  right: 0;
}
[data-tile-module="converse"] .skg-nested-tip,
[data-tile-module="companion"] .skg-nested-tip,
[data-tile-module="console"] .skg-nested-tip,
[data-tile-module="code"] .skg-nested-tip {
  left: auto;
  right: 0;
}

.skg-triple-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #141414;
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.7rem;
  line-height: 1.7;
  min-width: 220px;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  max-height: min(64vh, 420px);
  overflow: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  z-index: 200;
  white-space: normal;
  font-family: var(--font-mono, monospace);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.skg-triple-badge--dev:hover .skg-triple-tooltip {
  display: block;
}

.skg-triple-row {
  display: block;
  padding: 1px 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.skg-triple-subject,
.skg-triple-object {
  position: relative;
  display: inline-block;
  max-width: 28ch;
  overflow-wrap: anywhere;
  vertical-align: bottom;
  color: rgba(255, 255, 255, 0.7);
  cursor: default;
}

.skg-triple-glyph {
  position: relative;
  display: inline-block;
  color: rgba(52, 211, 153, 0.9);
  font-size: 0.85rem;
  margin: 0 4px;
  cursor: default;
}

.skg-triple-conf {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.68rem;
  margin-left: 6px;
}

.skg-nested-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 3px);
  left: 0;
  background: #0d0d1a;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.65rem;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 210;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.skg-diag-divider {
  display: block;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 5px 0;
}

.skg-diag-row {
  display: block;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.02em;
}

.skg-diag-row--warn {
  color: rgba(255, 180, 50, 0.6);
}

.skg-loop-row {
  display: block;
  font-size: 0.65rem;
  color: rgba(168, 85, 247, 0.7);
  letter-spacing: 0.02em;
  line-height: 1.8;
  overflow-wrap: anywhere;
  white-space: normal;
}

.skg-triple-subject:hover .skg-nested-tip,
.skg-triple-object:hover .skg-nested-tip,
.skg-triple-glyph:hover .skg-nested-tip {
  display: block;
}

/* Score chip (header) */
.score-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  background: rgba(99, 179, 237, 0.12);
  border: 1px solid rgba(99, 179, 237, 0.25);
  color: #90cdf4;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.score-badge:hover {
  background: rgba(99, 179, 237, 0.2);
  border-color: rgba(99, 179, 237, 0.45);
}
.score-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  opacity: 0.85;
}
.score-glyph svg {
  width: 13px;
  height: 13px;
  display: block;
}

/* Leaderboard popover */
.skg-leaderboard-popover {
  display: none;
  position: absolute;
  z-index: 9999;
  min-width: 260px;
  max-width: calc(100vw - 16px);
  background: #1a2030;
  border: 1px solid rgba(99, 179, 237, 0.25);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  padding: 0;
  overflow: hidden;
  font-size: 13px;
}
.skg-leaderboard-popover--open {
  display: block;
}
.skg-lb-header {
  padding: 10px 14px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #90cdf4;
  border-bottom: 1px solid rgba(99,179,237,0.12);
  background: rgba(99,179,237,0.07);
}
.skg-lb-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #c4cde0;
}
.skg-lb-row:last-of-type { border-bottom: none; }
.skg-lb-row--self {
  background: rgba(99,179,237,0.09);
  color: #e2edf8;
  font-weight: 600;
}
.skg-lb-rank {
  width: 24px;
  text-align: right;
  flex-shrink: 0;
  opacity: 0.5;
  font-size: 11px;
  margin-right: 10px;
}
.skg-lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.skg-lb-you {
  display: inline-block;
  margin-left: 5px;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(99,179,237,0.2);
  color: #90cdf4;
  vertical-align: middle;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.skg-lb-score {
  font-family: monospace;
  font-size: 12px;
  color: #90cdf4;
  margin-left: 10px;
  flex-shrink: 0;
}
.skg-lb-gap {
  text-align: center;
  padding: 4px;
  color: rgba(255,255,255,0.2);
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.skg-lb-footer {
  padding: 7px 14px;
  font-size: 11px;
  color: rgba(144,205,244,0.55);
  background: rgba(99,179,237,0.04);
  border-top: 1px solid rgba(99,179,237,0.1);
  text-align: right;
}
.skg-lb-loading, .skg-lb-error {
  padding: 20px 14px;
  text-align: center;
  color: rgba(255,255,255,0.3);
  font-size: 12px;
}
.skg-lb-ghost-section {
  opacity: 0.45;
  border-top: 1px dashed rgba(255,255,255,0.1);
  margin-top: 2px;
}
.skg-lb-row--ghost {
  font-style: italic;
  color: rgba(180,190,210,0.7);
}

.message.assistant p {
  margin: 0 0 0.75rem;
}

.message.assistant ul,
.message.assistant ol {
  margin: 0.5rem 0 0.85rem 1.35rem;
  padding: 0;
}

.message.assistant li {
  margin: 0.3rem 0;
}

/* Plain <strong> reads as emphasis, not a headline. Semibold (600) is
 * clearly differentiated from body text without shouting. LLMs over-bold
 * frequently ("**the**", "**(sandbox, active, decisions)**") and heavy
 * weights amplify that noise. */
.message.assistant strong {
  font-weight: 600;
}

/* ── Markdown tables ── */
.message.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}

.message.assistant th,
.message.assistant td {
  padding: 6px 10px;
  border: 1px solid var(--panel-border, #232334);
  text-align: left;
}

.message.assistant th {
  background: rgba(255,255,255,0.04);
  font-weight: 600;
  color: var(--text, #e8eaf0);
}

.message.assistant td {
  color: var(--text-secondary, #b0b8d0);
}

.message.assistant code {
  background: rgba(148, 163, 184, 0.14);
  border-radius: 6px;
  padding: 0.08rem 0.35rem;
  font-size: 0.95em;
}

.message.assistant pre {
  margin: 0.85rem 0;
  white-space: pre-wrap;
  overflow-x: auto;
}

.message.assistant pre code {
  display: block;
  /* Deliberately dark in both themes, like any code viewer -- so the text
     color must stay pinned light too. Without this, light theme's dark
     --text inherits here against this same dark background: dark-on-dark. */
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.message.assistant.thinking {
  opacity: 0.45;
  font-style: italic;
  transition: opacity 0.2s ease;
}

/* Spoken turns in the chat thread. Collapsed by default and grouped per run so
   a voice exchange reads as one entry instead of burying the typed thread under
   a column of eight-word utterances. Tinted away from .chat-thinking-stack's
   blue so "was this said aloud or typed" is answerable at a glance. */
.converse-group {
  margin: 0 0 12px;
  border: 1px solid rgba(125, 249, 200, 0.24);
  border-radius: 8px;
  background: rgba(8, 26, 24, 0.55);
  overflow: hidden;
}

.converse-group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
  color: #8fffe8;
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
}

.converse-group summary::-webkit-details-marker {
  display: none;
}

.converse-group summary::before {
  content: ">";
  color: #8fffe8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: transform 0.15s ease;
}

.converse-group[open] summary::before {
  transform: rotate(90deg);
}

.converse-turn {
  padding: 5px 12px 5px 22px;
  font-size: 13px;
  line-height: 1.45;
  color: #cfeee6;
  overflow-wrap: anywhere;
}

.converse-turn-user {
  color: #eaf6f3;
}

.converse-turn-user::before {
  content: "you ";
  color: #6fb9a6;
  font-size: 11px;
}

.converse-turn-assistant::before {
  content: "said ";
  color: #6fb9a6;
  font-size: 11px;
}

.chat-thinking-stack {
  margin: 0 0 12px;
  border: 1px solid rgba(124, 155, 255, 0.26);
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.62);
  color: #dbeafe;
  overflow: hidden;
}

.chat-thinking-stack summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
  color: #a7f3d0;
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
}

.chat-thinking-stack summary::-webkit-details-marker {
  display: none;
}

.chat-thinking-stack summary::before {
  content: ">";
  color: #7dd3fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

.chat-thinking-stack[open] summary::before {
  transform: rotate(90deg);
}

.chat-thinking-stack-scale {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.chat-thinking-stack-count {
  margin-left: auto;
  color: var(--text-secondary);
  font-weight: 600;
}

.chat-thinking-loop-list {
  max-height: 260px;
  margin: 0;
  padding: 0 10px 10px;
  overflow-y: auto;
  list-style: none;
}

.chat-thinking-loop {
  padding: 9px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.chat-thinking-loop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.chat-thinking-loop-index {
  color: #93c5fd;
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: lowercase;
}

.chat-thinking-loop-text {
  margin: 0;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .chat-thinking-stack-count {
    margin-left: 0;
  }
}

.message .assistant-meta {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Scroll chevrons for long assistant messages ────────────────── */
.msg-scroll-chevron {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(124, 155, 255, 0.15);
  border: 1px solid rgba(124, 155, 255, 0.3);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.msg-scroll-chevron:hover {
  opacity: 1;
  background: rgba(124, 155, 255, 0.3);
  color: var(--text-primary);
}
.msg-scroll-down { top: 8px; right: 72px; }  /* offset left to avoid message action buttons */
.msg-scroll-up { bottom: 8px; }

.assistant-meta-usage {
  color: #d8e2ff;
}

.assistant-meta-warning {
  color: #fbbf24;
}

.assistant-meta-routing {
  color: #a78bfa;
  font-style: italic;
  background: rgba(167, 139, 250, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* Companion/PDCo attribution — dotted underline + cursor:help signal that
   hovering reveals more (the disclaimer lives in the native `title`
   tooltip, set by renderAssistantMeta from part.tooltip). */
.assistant-meta-companion {
  color: #a5c4ff;
  cursor: help;
  border-bottom: 1px dotted rgba(165, 196, 255, 0.5);
  padding-bottom: 1px;
}
.assistant-meta-companion:hover {
  color: #c7d9ff;
  border-bottom-color: rgba(199, 217, 255, 0.8);
}

.assistant-meta-compression {
  color: #34d399;
  font-style: italic;
  background: rgba(52, 211, 153, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.assistant-meta-glyph {
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  opacity: 0.65;
  cursor: default;
  user-select: none;
  color: #6b7fc4;
}
.assistant-meta-glyph:hover { opacity: 0.9; }

/* Color cipher palette — semantic-free class names, one-to-many mapping */
.assistant-meta-glyph.mgx-a, #conversation-overlay-role.mgx-a { color: #7c8fcb; }
.assistant-meta-glyph.mgx-b, #conversation-overlay-role.mgx-b { color: #8eab8e; }
.assistant-meta-glyph.mgx-c, #conversation-overlay-role.mgx-c { color: #c49a72; }
.assistant-meta-glyph.mgx-d, #conversation-overlay-role.mgx-d { color: #9b7ec0; }
.assistant-meta-glyph.mgx-e, #conversation-overlay-role.mgx-e { color: #7ab5c2; }
.assistant-meta-glyph.mgx-f, #conversation-overlay-role.mgx-f { color: #c47a8a; }
.assistant-meta-glyph.mgx-g, #conversation-overlay-role.mgx-g { color: #8a9ab0; }

.message .assistant-aside {
  font-style: italic;
  opacity: 0.7;
}

/* Genuine markdown emphasis (*text*) is not the same thing as
   .assistant-aside's deliberate de-emphasis (a quiet side-note) — this used
   to share the same dimmed-opacity treatment, which made a model's actual
   *emphasis* read as muted instead of emphasized. */
.message em {
  font-style: italic;
  color: inherit;
}

.message strong {
  font-weight: 700;
  color: var(--text, #e8ecf8);
}

.message s,
.message del {
  opacity: 0.65;
  text-decoration-thickness: 1.5px;
}

/* Headings: browser UA defaults (a raw h1 at ~2em) read as oversized and
   inconsistent inside an already-bounded chat bubble. Scaled down to a
   compact, clearly-tiered hierarchy instead. */
.message h1, .message h2, .message h3,
.message h4, .message h5, .message h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text, #e8ecf8);
  margin: 0.9em 0 0.4em;
}
.message h1:first-child, .message h2:first-child, .message h3:first-child,
.message h4:first-child, .message h5:first-child, .message h6:first-child {
  margin-top: 0;
}
.message h1 { font-size: 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, 0.12); padding-bottom: 0.3em; }
.message h2 { font-size: 1.12rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); padding-bottom: 0.25em; }
.message h3 { font-size: 1.03rem; }
.message h4, .message h5, .message h6 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary, rgba(230, 235, 255, 0.75));
}

/* Lists: give nested levels their own marker style so a sub-list reads as
   "inside" its parent item at a glance, not just as extra indent. */
.message ul, .message ol {
  margin: 0.35em 0;
  padding-left: 1.4em;
}
.message li {
  margin: 0.2em 0;
}
.message li > ul, .message li > ol {
  margin: 0.25em 0 0.35em;
}
.message ul { list-style-type: disc; }
.message ul ul { list-style-type: circle; }
.message ul ul ul { list-style-type: square; }
.message ol ol { list-style-type: lower-alpha; }
.message ol ol ol { list-style-type: lower-roman; }

.message blockquote {
  margin: 0.5em 0;
  padding: 0.2em 0.9em;
  border-left: 3px solid rgba(124, 155, 255, 0.5);
  color: var(--text-secondary, rgba(230, 235, 255, 0.8));
}

.tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(124, 155, 255, 0.12);
  border: 1px solid rgba(124, 155, 255, 0.28);
  border-radius: 999px;
  color: #b9c8ff;
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1;
  padding: 0.25rem 0.55rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.tts-btn:hover {
  background: rgba(124, 155, 255, 0.2);
  border-color: rgba(124, 155, 255, 0.48);
  transform: translateY(-1px);
}

.tts-btn[aria-pressed="true"] {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.42);
  color: #d9fff1;
}

.tts-btn-icon {
  font-size: 0.95em;
}

.tts-btn-label {
  letter-spacing: 0.02em;
}


/* ── Conversation Mode Overlay ── */
.conversation-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--overlay-tint), 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.6s ease-out;
  touch-action: pan-y;
}

.conversation-overlay.hidden {
  display: none;
}

/* Floating compact mode — overlay becomes a draggable, resizable panel that
   does not block the rest of the UI. Position/size are controlled via inline
   style by the layout module so localStorage can persist them. */
.conversation-overlay.is-floating {
  position: fixed;
  inset: auto;
  width: 460px;
  height: 640px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  min-width: 360px;
  min-height: 560px;
  bottom: 24px;
  right: 24px;
  container-type: inline-size;
  container-name: conv-overlay;
  background: rgba(var(--overlay-tint), 0.94);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  resize: none;
  overflow: hidden;
  z-index: 13000;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.conversation-overlay.is-floating .conversation-overlay-inner {
  max-width: 100%;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 10px 14px 12px;
  overflow: hidden;
  align-items: stretch;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-overlay.is-floating .conv-3d-scene,
.conversation-overlay.is-floating .conversation-spectrum,
.conversation-overlay.is-floating .conv-media-previews,
.conversation-overlay.is-floating .conversation-overlay-text,
.conversation-overlay.is-floating .conversation-overlay-role {
  flex: 0 0 auto;
}

.conversation-overlay.is-floating .conv-3d-scene {
  width: clamp(150px, 46cqw, 220px);
  margin: 0 auto 4px;
  /* Match cube-half to the floating scene width so faces don't extrude
     beyond the panel. Fullscreen mode keeps the default 200px (matching
     its 400px scene). */
  --cube-half: clamp(75px, 23cqw, 110px);
}

.conversation-overlay.is-floating .conversation-spectrum {
  height: 44px;
  margin-bottom: 0;
}

.conversation-overlay.is-floating .conversation-overlay-text {
  font-size: clamp(14px, 4cqw, 18px);
  line-height: 1.28;
  max-height: 5.2em;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Live preview strip: small thumbnails of the camera/screen streams so the
   user can see what's being shared. Hidden when no media is active. */
.conv-media-previews {
  display: flex;
  gap: 6px;
  margin: 6px 0;
  justify-content: center;
  align-items: center;
}

.conv-media-previews[hidden] { display: none; }

.conv-media-preview {
  position: relative;
  width: 140px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(148, 163, 184, 0.28);
  flex: 0 0 auto;
}

.conv-media-preview[hidden] { display: none; }

.conv-media-preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.conv-media-preview-label {
  position: absolute;
  left: 6px;
  bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #f1f5f9;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
}

/* Front camera preview is mirrored like a native selfie view. Rear lens and the
   screen share are never mirrored. */
.conv-media-preview-video.mirrored { transform: scaleX(-1); }

/* Front/rear switch overlaid on the camera thumbnail. Hidden unless the device
   has multiple cameras and the camera is active (toggled from app.js). */
.conv-camera-flip {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  color: #f1f5f9;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s ease, transform 0.15s ease;
}

.conv-camera-flip:hover { background: rgba(0, 0, 0, 0.78); }
.conv-camera-flip:active { transform: scale(0.92); }
.conv-camera-flip:disabled { opacity: 0.5; cursor: default; }
.conv-camera-flip[hidden] { display: none; }

/* In floating mode, thumbnails are tighter and stack side by side if both are
   active. They sit between the spectrum and text region. */
.conversation-overlay.is-floating .conv-media-previews {
  margin: 4px 0;
  gap: 4px;
}

.conversation-overlay.is-floating .conv-media-preview {
  width: 110px;
  height: 64px;
  border-radius: 6px;
}

/* When toolbar is in icon-only mode (narrow widths), shrink previews too. */
@container conv-overlay (max-width: 360px) {
  .conversation-overlay.is-floating .conv-media-preview {
    width: 90px;
    height: 54px;
  }
}

/* Pin the media toolbar to the bottom of the floating panel so Mic / Attach /
   Camera / Screen are always reachable even when text or cube push above. */
.conversation-overlay.is-floating .conversation-media-toolbar {
  margin-top: auto;
  flex: 0 0 auto;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  gap: 6px;
}

.conv-resize-handle {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 24px;
  height: 24px;
  z-index: 4;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, transparent 0 45%, rgba(148, 163, 184, 0.32) 46% 54%, transparent 55%),
    linear-gradient(135deg, transparent 0 62%, rgba(148, 163, 184, 0.5) 63% 71%, transparent 72%);
  cursor: nwse-resize;
  opacity: 0.78;
  padding: 0;
  touch-action: none;
}

.conversation-overlay:not(.is-floating) .conv-resize-handle,
.conversation-overlay.is-popped .conv-resize-handle {
  display: none;
}

.conversation-overlay.is-resizing,
.conversation-overlay.is-resizing * {
  user-select: none;
}

.conversation-overlay.is-floating .conversation-media-btn {
  padding: 6px 9px;
  font-size: 12px;
  min-height: 32px;
}

/* At narrow floating widths, collapse the toolbar buttons to icon-only so all
   four (Mic / Attach / Camera / Screen) fit on a single row instead of
   wrapping below the panel. Labels remain in title/aria-label for a11y. */
@container conv-overlay (max-width: 360px) {
  .conversation-overlay.is-floating .conversation-media-btn > span:not([aria-hidden="true"]),
  .conversation-overlay.is-floating .conv-mic-label {
    display: none;
  }
  .conversation-overlay.is-floating .conversation-media-btn {
    padding: 6px 10px;
    min-width: 38px;
    justify-content: center;
  }
  .conversation-overlay.is-floating .conversation-media-toolbar {
    flex-wrap: nowrap;
    justify-content: space-around;
  }
}

/* Picture-in-Picture: when overlay is moved into a real OS-level PiP window,
   it should fill that window, not float inside it. */
.conversation-overlay.is-popped {
  position: relative;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  resize: none;
  background: rgba(var(--overlay-tint), 0.96);
  /* Base .conversation-overlay is a row flex; without this the header ends
     up beside the inner content instead of above it. */
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

/* Header bar (drag + window controls) — visible in all modes so users can
   switch into floating/PiP from the default full-screen view */
.conversation-overlay-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  user-select: none;
  flex: 0 0 auto;
}

/* In full-screen mode the header floats at the top of the modal */
.conversation-overlay:not(.is-floating):not(.is-popped) .conversation-overlay-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(var(--overlay-tint), 0.55);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  z-index: 1;
}

.conversation-overlay-header[data-drag-handle="true"] {
  cursor: move;
}

/* In floating mode use grab/grabbing for clearer drag affordance. Buttons
   inside the header keep pointer cursor via their own rules. */
.conversation-overlay.is-floating .conversation-overlay-header[data-drag-handle="true"] {
  cursor: grab;
}

.conversation-overlay.is-floating .conversation-overlay-header[data-drag-handle="true"]:active {
  cursor: grabbing;
}

.conversation-overlay.is-floating .conv-overlay-iconbtn {
  cursor: pointer;
}

.conv-overlay-handle {
  color: rgba(148, 163, 184, 0.55);
  font-size: 14px;
  letter-spacing: 0.05em;
}

.conv-overlay-title {
  flex: 1 1 auto;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Wake-lock status badge. Only phones can actually lose a voice session to
   the display locking, so the badge is a mobile affordance -- mobile.css owns
   the pill styling and reveals it there. Without this base rule it fell back
   to an unstyled 16px inline <span> in the voice-chat header on desktop,
   wedged between the title and the window controls in the floating and
   popped-out panel, and it never went away when the conversation ended. */
.conv-wake-lock-badge {
  display: none;
}

.conv-overlay-controls {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.conv-overlay-iconbtn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  transition: background 140ms ease, color 140ms ease;
}

.conv-overlay-iconbtn:hover {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text);
}

.conv-overlay-iconbtn[hidden] { display: none; }

/* Minimized widget — persistent control to restore the overlay */
.conv-minimized-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(15, 23, 42, 0.94);
  color: #f1f5f9;
  font-size: 22px;
  cursor: pointer;
  z-index: 13010;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  transition: transform 140ms ease, background 140ms ease;
  padding: 0;
}

.conv-minimized-widget:hover { transform: translateY(-2px); }
.conv-minimized-widget[hidden] { display: none; }

.conv-widget-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(168, 85, 247, 0);
  pointer-events: none;
  transition: border-color 200ms ease;
}

.conv-minimized-widget.is-speaking .conv-widget-pulse {
  border-color: rgba(168, 85, 247, 0.6);
  animation: conversation-listen-pulse 1.6s ease-in-out infinite;
}

.conversation-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.conversation-overlay-inner {
  max-width: 88%;
  width: 100%;
  max-height: calc(100% - 16px);
  text-align: center;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile: prevent the cube + spectrum from pushing the media toolbar
   off-screen by capping their heights and giving the toolbar room. */
@media (max-width: 720px) {
  .conversation-overlay {
    align-items: stretch;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  .conversation-overlay-inner {
    max-width: 100%;
    max-height: 100%;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    justify-content: flex-start;
  }
  .conv-3d-scene {
    width: min(220px, 60vw) !important;
    margin: 4px auto 8px !important;
  }
  .conversation-spectrum {
    height: clamp(60px, 14vw, 100px) !important;
    margin-bottom: 8px !important;
  }
  .conversation-overlay-text {
    font-size: clamp(15px, 4vw, 20px) !important;
    margin-bottom: 8px;
  }
  .conversation-media-toolbar {
    margin-top: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 6px;
  }
  .conversation-media-btn {
    padding: 8px 10px;
    font-size: 12px;
  }
  .conversation-overlay.is-floating .conv-3d-scene {
    width: clamp(140px, 44cqw, 200px) !important;
    margin: 0 auto 4px !important;
  }
  .conversation-overlay.is-floating .conversation-spectrum {
    height: 40px !important;
    margin-bottom: 0 !important;
  }
  .conversation-overlay.is-floating .conversation-overlay-text {
    font-size: clamp(14px, 4cqw, 18px) !important;
    margin-bottom: 0;
  }
  .conversation-overlay.is-floating .conversation-media-toolbar {
    margin-top: auto;
  }
}

.conversation-overlay-text {
  font-family: 'Inter', 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.conversation-overlay-text.is-user {
  color: #a78bfa;
  font-weight: 400;
  font-size: clamp(18px, 4.5vw, 28px);
}

.conversation-overlay-text.is-thinking {
  color: var(--text-tertiary);
  font-style: italic;
}

.conversation-overlay-role {
  margin-top: 12px;
  font-size: 12px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.conversation-media-toolbar {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.conversation-media-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #dbeafe;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.conversation-media-btn:hover {
  transform: translateY(-1px);
  background: rgba(30, 41, 59, 0.92);
  border-color: rgba(96, 165, 250, 0.42);
  color: var(--text);
}

.conversation-media-btn.active {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.34);
  border-color: rgba(248, 113, 113, 0.55);
}

.conv-btn-mic.is-listening {
  color: #bbf7d0;
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(74, 222, 128, 0.55);
}
.conv-btn-mic.is-listening::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.85);
  animation: media-indicator-pulse 1.4s ease-in-out infinite;
}
.conv-btn-mic.is-paused {
  color: #fde68a;
  background: rgba(120, 53, 15, 0.3);
  border-color: rgba(251, 191, 36, 0.55);
}
.conv-btn-mic.is-paused::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.68);
}
.conv-btn-mic.is-error {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.34);
  border-color: rgba(248, 113, 113, 0.55);
}
.conv-btn-mic.is-error::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--error, #ef4444);
}

.conversation-media-btn.active::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--error);
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.75);
  animation: media-indicator-pulse 1.4s ease-in-out infinite;
}

/* Coaching Thread: pulses the camera/screen buttons (Studio Chat's
   .chat-tool-btn and Converse's .conversation-media-btn) until the student
   turns one on. Set/cleared by _syncCoachingDeviceAttentionMarkers() in
   app.js — never both this and .active at once, since it only applies while
   neither stream is live. */
.chat-tool-btn.needs-coaching-attention,
.conversation-media-btn.needs-coaching-attention {
  position: relative;
  color: var(--accent);
}
.chat-tool-btn.needs-coaching-attention {
  box-shadow: 0 0 0 2px var(--accent);
}
.conversation-media-btn.needs-coaching-attention {
  border-color: var(--accent);
}
.chat-tool-btn.needs-coaching-attention::after,
.conversation-media-btn.needs-coaching-attention::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: media-indicator-pulse 1.4s ease-in-out infinite;
}

/* Testing Environment: the send button is visually blocked (not just
   disabled — chatForm's submit handler is the actual gate, this is the
   affordance) until screen share is live. Set/cleared by
   _syncTestingEnvironmentEnforcement() in app.js. */
.chat-send-btn.testing-env-blocked {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 0 0 2px var(--error);
}

.conversation-overlay-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.conversation-overlay-actions.hidden {
  display: none;
}

.conversation-overlay-action {
  padding: 10px 16px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.25);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.conversation-overlay-action-secondary {
  background: rgba(15, 23, 42, 0.55);
  color: var(--text-primary);
}

.conversation-overlay-action:hover {
  transform: translateY(-1px);
  background: rgba(30, 41, 59, 0.96);
  border-color: rgba(96, 165, 250, 0.36);
}

.conversation-overlay-action.hidden {
  display: none;
}

.conversation-spectrum {
  width: 100%;
  height: clamp(120px, 25vw, 200px);
  border-radius: 12px;
  margin-bottom: 20px;
  background: transparent;
}

.conversation-input-form {
  margin-top: 16px;
  width: 100%;
}

.conversation-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 10px;
  /* Mid-gray tint (not white) so this reads correctly whether the parent
     .conversation-overlay is dark or light-themed -- a white-alpha tint
     the way this used to be written would wash out to invisible once the
     parent itself turned light. */
  background: rgba(127, 127, 127, 0.12);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.conversation-input:focus {
  border-color: rgba(168, 85, 247, 0.5);
}

.conversation-input::placeholder {
  color: var(--text-tertiary);
}

/* Listening pulse ring around overlay when STT is active */
.conversation-overlay.is-listening {
  box-shadow: inset 0 0 0 3px rgba(168, 85, 247, 0.3);
  animation: conversation-listen-pulse 2s ease-in-out infinite;
}

@keyframes conversation-listen-pulse {
  0%   { box-shadow: inset 0 0 0 3px rgba(168, 85, 247, 0.15); }
  50%  { box-shadow: inset 0 0 0 3px rgba(168, 85, 247, 0.4); }
  100% { box-shadow: inset 0 0 0 3px rgba(168, 85, 247, 0.15); }
}

/* PDCo 3D conversational cube */
.conv-3d-scene {
  position: relative;
  width: min(400px, 88%);
  aspect-ratio: 1 / 1;
  margin: 0 auto 24px;
  perspective: 700px;
  pointer-events: none;
  transition: transform 0.1s ease-out;
}

/* When the WebGL sphere avatar has mounted (convBubble.initConvCube adds this
   class), flatten the container's 3D-transform context. The `perspective` above
   is only needed by the legacy CSS-3D `.conv-cube` fallback; a WebGL <canvas>
   nested in a 3D rendering context renders solid black on iOS WebKit (mobile
   Chrome/Safari) because the promoted compositing layer never receives its GL
   contents. Removing the perspective lets iOS paint the canvas. No visual effect
   on the sphere elsewhere — it is not a 3D-transformed element. */
.conv-3d-scene.bubble-active {
  perspective: none;
  transform-style: flat;
  -webkit-transform-style: flat;
}

.conv-cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.conv-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.65);
  backface-visibility: hidden;
  overflow: hidden;
}

.conv-face--front { transform: rotateY(0deg)   translateZ(var(--cube-half, 200px)); }
.conv-face--right { transform: rotateY(90deg)  translateZ(var(--cube-half, 200px)); }
.conv-face--back  { transform: rotateY(180deg) translateZ(var(--cube-half, 200px)); }
.conv-face--left  { transform: rotateY(-90deg) translateZ(var(--cube-half, 200px)); }

.conv-face-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.conv-persona-label {
  text-align: center;
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: 0.25em;
  font-family: monospace;
  color: var(--text-tertiary);
  transition: color 0.4s ease;
}

#retry-btn {
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

#retry-btn:hover {
  background: rgba(124, 155, 255, 0.2);
  border-color: rgba(124, 155, 255, 0.5);
}
.chat-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
  cursor: pointer;
  color: white;
}

.chat-delete-btn {
  position: absolute;
  top: 6px;
  right: 38px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 999px;
  background: rgba(127, 29, 29, 0.75);
  color: #fecaca;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.chat-delete-btn:hover {
  background: rgba(153, 27, 27, 0.92);
  color: #fff;
}

/* Sits in the same slot as .chat-delete-btn -- the two are mutually exclusive
   per message (user turns get Edit, assistant turns keep plain Delete). */
.chat-edit-btn {
  position: absolute;
  top: 6px;
  right: 38px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(124, 155, 255, 0.45);
  border-radius: 999px;
  background: rgba(30, 41, 82, 0.75);
  color: #c7d2fe;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.chat-edit-btn:hover {
  background: rgba(67, 90, 189, 0.92);
  color: #fff;
}

.chat-copy-btn .ui-icon {
  width: 14px;
  height: 14px;
}

.chat-copy-btn.copied {
  background: rgba(34, 197, 94, 0.9);
}

@media (hover: hover) {
  .chat-copy-btn,
  .chat-delete-btn {
    opacity: 0;
  }

  .message:hover .chat-copy-btn,
  .message:hover .chat-delete-btn {
    opacity: 1;
  }

  .chat-edit-btn {
    opacity: 0;
  }

  .message:hover .chat-edit-btn {
    opacity: 1;
  }
}

@media (hover: none) {
  /* Touch devices have no hover to reveal these on demand, so they used to sit
     at 0.9 opacity permanently -- a solid red circle and copy icon overlaid on
     every message, distracting from the text underneath. Dim them at rest;
     a finger actually on the message or button still gets full opacity, so
     the affordance survives without the constant visual noise. */
  .chat-copy-btn,
  .chat-delete-btn {
    opacity: 0.35;
  }

  .message:active .chat-copy-btn,
  .message:active .chat-delete-btn,
  .chat-copy-btn:active,
  .chat-delete-btn:active {
    opacity: 1;
  }

  .chat-edit-btn {
    opacity: 0.35;
  }

  .message:active .chat-edit-btn,
  .chat-edit-btn:active {
    opacity: 1;
  }
}

.message.system {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--error);
}

/* Muted, centered inline "system event" message (slash-command echoes, etc.).
   NOT a reply target — see docs/plans/2026-04-14-slash-commands-design.md §3. */
.message.system_event {
  background: transparent;
  border: none;
  color: var(--text-secondary, #b0b8d0);
  text-align: center;
  font-size: 0.85em;
  font-style: italic;
  padding: 4px 8px;
  opacity: 0.85;
  user-select: none;
}
.message.system_event .system-event-icon { margin-right: 4px; }
.message.system_event .system-event-actor { font-weight: 600; margin-right: 6px; }
.message.system_event .system-event-time { margin-left: 6px; opacity: 0.7; }

.output-line {
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
}

.output-line.error {
  color: var(--error);
  border-color: rgba(255, 107, 107, 0.3);
}

.output-line.success {
  color: var(--success);
  border-color: rgba(61, 220, 151, 0.3);
}

.credit-panel-cta {
  width: 100%;
  margin-bottom: 12px;
}

.paywall-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 50;
}

.paywall-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.72);
}

.paywall-sheet {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  background: rgba(17, 19, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(4, 10, 24, 0.45);
  display: grid;
  gap: 20px;
}

.paywall-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.paywall-header-copy {
  display: grid;
  gap: 6px;
}

.paywall-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.paywall-subtext {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.92rem;
}

.paywall-body {
  display: grid;
  gap: 20px;
}

.paywall-status-card {
  border-radius: 14px;
  background: rgba(12, 14, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.paywall-status-card .status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
}

.paywall-status-card .status-row strong {
  color: #fff;
  font-weight: 600;
}

.paywall-plans {
  display: grid;
  gap: 10px;
}

.paywall-plan-compact {
  display: grid;
  gap: 12px;
}

.paywall-plan-cards {
  display: grid;
  gap: 12px;
}

.paywall-plan-card {
  border-radius: 16px;
  padding: 16px;
  background: rgba(14, 16, 24, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 12px;
  box-shadow: 0 12px 30px rgba(8, 12, 24, 0.35);
}

.paywall-plan-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.paywall-plan-card .plan-label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
}

.paywall-plan-card .plan-price {
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.78);
}

.paywall-plan-card ul {
  margin: 0;
  padding-left: 16px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.88rem;
  display: grid;
  gap: 6px;
}

.paywall-plan-card.is-recommended,
.paywall-plan-card.is-selected {
  border-color: rgba(124, 155, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(124, 155, 255, 0.4),
    0 18px 35px rgba(90, 120, 255, 0.25);
}

.paywall-plan-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.plan-chip {
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  cursor: pointer;
}

.plan-chip.is-selected {
  background: rgba(124, 155, 255, 0.2);
  border-color: rgba(124, 155, 255, 0.6);
  color: #e3e9ff;
}

.paywall-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: rgba(12, 14, 20, 0.6);
  border-radius: 12px;
  overflow: hidden;
}

.paywall-table th,
.paywall-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.paywall-table thead th {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.paywall-compare-table th[scope="row"] {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  font-weight: 500;
}

.paywall-compare-table [data-paywall-plan-cell].is-selected {
  background: rgba(124, 155, 255, 0.12);
  color: #f2f4ff;
}

.paywall-compare-table .is-recommended {
  position: relative;
}

.paywall-compare-table .is-recommended::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 10px;
  border: 1px solid rgba(124, 155, 255, 0.3);
  pointer-events: none;
}

.paywall-table tbody tr:last-child td {
  border-bottom: none;
}

.paywall-note {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.paywall-cost-line {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.62);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.paywall-inline-link {
  font-size: 0.82rem;
}

.paywall-inline-link[data-tooltip] {
  position: relative;
}

.paywall-inline-link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  width: max-content;
  max-width: 220px;
  z-index: 10;
}

.paywall-inline-link[data-tooltip]:hover::after,
.paywall-inline-link[data-tooltip]:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.paywall-actions {
  display: grid;
  gap: 10px;
}

.primary-button {
  width: 100%;
  background: linear-gradient(135deg, #8b9bff, #6f7cff);
  color: #0b0b10;
  font-size: 0.95rem;
  border-radius: 12px;
  padding: 12px 16px;
}

.link-button {
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  border: none;
  padding: 4px 0;
  font-size: 0.9rem;
  text-decoration: none;
}

.link-button:hover {
  color: #fff;
}

.paywall-modal.dismissable .paywall-backdrop {
  cursor: pointer;
}

.paywall-modal.hidden {
  display: none;
}

.paywall-footer {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
}

.usage-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 40;
}

.usage-panel {
  background: rgba(17, 19, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  width: min(1100px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(4, 10, 24, 0.45);
}

.usage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.usage-header h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.usage-scope {
  margin: 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
}

/* Upgrade modal */
.upgrade-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.upgrade-overlay.hidden {
  display: none;
}

.upgrade-modal {
  position: relative;
  width: min(900px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: #12141b;
  border-radius: 14px;
  padding: 24px 28px 28px;
  color: #e6e8ee;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.upgrade-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: #9aa0b4;
  font-size: 22px;
  cursor: pointer;
}

.upgrade-close:hover {
  color: #fff;
}

.upgrade-header h2 {
  margin: 0;
  font-size: 22px;
}

.upgrade-subtitle {
  margin-top: 6px;
  color: #b6bbd3;
  font-size: 14px;
}

.upgrade-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: #0e1017;
  padding: 12px;
  border-radius: 10px;
  margin: 20px 0;
  font-size: 13px;
}

.upgrade-status div {
  display: flex;
  justify-content: space-between;
  color: #aab0c5;
}

.upgrade-status strong {
  color: #fff;
}

.upgrade-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.plan {
  background: #0e1017;
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  border: 1px solid #1c2030;
}

.plan h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.plan-price {
  font-size: 18px;
  margin-bottom: 10px;
}

.plan ul {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  font-size: 13px;
  color: #b6bbd3;
}

.plan ul li {
  margin-bottom: 6px;
}

.plan-featured {
  border-color: #4f7cff;
  background: linear-gradient(180deg, #121c3a, #0e1017);
}

.plan-cta {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #2a2f44;
  background: transparent;
  color: #e6e8ee;
  cursor: pointer;
}

.plan-cta:hover {
  background: #1a1f33;
}

.plan-cta.primary {
  background: #4f7cff;
  border: none;
  color: #fff;
}

.plan-cta.primary:hover {
  background: #6a8dff;
}

.upgrade-footer {
  margin-top: 18px;
  font-size: 13px;
  color: #9aa0b4;
}

.upgrade-note {
  margin-top: 6px;
  font-size: 12px;
  color: #7e849b;
}

.usage-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.usage-filter {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.usage-filter select,
.usage-filter input[type="date"] {
  background: rgba(12, 14, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
  color: inherit;
  font-size: 0.85rem;
}

.usage-filter-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.usage-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.usage-tab {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.9rem;
  cursor: pointer;
}

.usage-tab.active {
  background: rgba(82, 120, 255, 0.2);
  border-color: rgba(82, 120, 255, 0.6);
  color: #fff;
}

.usage-tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.usage-tab-panel.active {
  display: flex;
}

.usage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.usage-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.usage-card strong {
  font-size: 1.3rem;
}

.usage-chart-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.usage-chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.usage-chart-header h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.usage-chart-header p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
}

.usage-range-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.usage-table th,
.usage-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.usage-table details {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.75);
}

.usage-table summary {
  cursor: pointer;
  color: rgba(122, 162, 247, 0.9);
}

.usage-request-list {
  margin: 8px 0 0;
  padding-left: 16px;
  display: grid;
  gap: 6px;
}

.usage-request-item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
}

.usage-pill {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.usage-empty {
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  padding: 20px 0;
}

.gallery-page {
  padding: 32px;
}

.gallery-page--scrollable {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.gallery-subtitle {
  color: var(--muted);
}

.gallery-actions {
  display: flex;
  gap: 12px;
}

.gallery-filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.gallery-college-filter {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(151, 115, 255, 0.52);
  border-radius: 16px;
  background:
    radial-gradient(circle at 8% 20%, rgba(126, 87, 255, 0.2), transparent 42%),
    rgba(126, 87, 255, 0.08);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
}

.gallery-college-filter__copy {
  display: grid;
  gap: 3px;
}

.gallery-college-filter__eyebrow {
  color: #bda9ff;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.gallery-college-filter__copy label {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
}

.gallery-college-filter__copy > span:last-child,
.gallery-college-filter__control > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.gallery-college-filter__control {
  display: grid;
  gap: 6px;
  min-width: min(360px, 100%);
}

.gallery-college-filter__control select {
  width: 100%;
  min-height: 46px;
  padding: 9px 40px 9px 13px;
  border: 1px solid rgba(189, 169, 255, 0.72);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.gallery-college-filter__control select:focus-visible {
  outline: 3px solid rgba(189, 169, 255, 0.3);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .gallery-college-filter {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
  }

  .gallery-college-filter__control {
    min-width: 0;
  }
}

.gallery-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.gallery-search {
  flex: 1;
  min-width: 220px;
}

.gallery-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
}

.gallery-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-sort {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.gallery-sort select {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
}

.gallery-tags-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.gallery-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.tag-chip.is-active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.gallery-grid--public {
  align-content: start;
  padding-bottom: 12px;
}

.gallery-results-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  overscroll-behavior: contain;
}

.gallery-results-scroll--public {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 18px;
}

.gallery-results-scroll::-webkit-scrollbar {
  width: 10px;
}

.gallery-results-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.gallery-results-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.gallery-results-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.gallery-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
}

/* Grading console — shown on /threads/shared once the owner has enabled
   grading and the share has expired (see app.js _renderGradingConsole). */
.grading-console {
  margin-top: 24px;
}

.grading-console-card {
  display: flex;
  gap: 20px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
}

.grading-console-asset {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  object-fit: cover;
  flex: none;
}

.grading-console-body {
  flex: 1;
  min-width: 0;
}

.grading-console-tier {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.grading-console-explanation {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  animation: skg-badge-fade-in 0.5s ease 0.15s both;
}

.grading-console-enable-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 20px;
}

.grading-console-enable-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.artifact-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: border-color 0.4s, box-shadow 0.4s;
}

.artifact-card--just-shared {
  border-color: rgba(124, 155, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(124, 155, 255, 0.35);
  animation: artifact-card-just-shared-pulse 1.8s ease-out 2;
}

@keyframes artifact-card-just-shared-pulse {
  0% { box-shadow: 0 0 0 2px rgba(124, 155, 255, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(124, 155, 255, 0.12); }
  100% { box-shadow: 0 0 0 2px rgba(124, 155, 255, 0.35); }
}

.artifact-thumb {
  position: relative;
  background: #0f1115;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.artifact-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.artifact-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

.artifact-thumb--thread {
  background:
    radial-gradient(circle at top left, rgba(255, 96, 146, 0.22), transparent 48%),
    linear-gradient(135deg, #121729 0%, #1b2438 100%);
}

.thread-workspace-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 2rem;
}

.artifact-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.artifact-tag {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.artifact-visibility {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 17, 21, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
}

.artifact-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.artifact-body h3 {
  margin: 0;
  font-size: 1rem;
}

.artifact-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.artifact-fork-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.artifact-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
}

.artifact-engagement {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.artifact-engagement button {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.artifact-engagement button.is-liked {
  color: #ff6b8a;
}

.artifact-author {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.artifact-author a {
  color: inherit;
  text-decoration: none;
}

.artifact-author a:hover {
  text-decoration: underline;
}

.artifact-fork-label a {
  color: inherit;
  text-decoration: none;
}

.artifact-fork-label a:hover {
  text-decoration: underline;
}

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-page {
  padding: 0 32px 32px;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.profile-header-actions,
.account-header-actions {
  display: flex;
  gap: 10px;
}

.profile-identity {
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar.large {
  width: 120px;
  height: 120px;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account-profile-summary {
  margin-top: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.account-profile-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.account-profile-copy strong {
  color: var(--text);
}

.account-profile-copy .account-muted,
.account-profile-copy .profile-location {
  margin: 0;
}

.profile-meta h2 {
  margin: 0 0 4px;
}

.profile-handle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.profile-bio {
  margin: 8px 0 0;
  color: var(--muted);
}

.profile-location {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
}

.profile-stat-value {
  font-size: 1.3rem;
  font-weight: 600;
}

.profile-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.profile-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.profile-tabs .ghost-button.is-active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.profile-tab-panel {
  margin-bottom: 24px;
}

.profile-about {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
}

.profile-about-label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.profile-about-value {
  margin: 6px 0 0;
  color: var(--muted);
}

.profile-edit-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.profile-edit-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.profile-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-demographics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.profile-edit-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-helper {
  font-size: 0.75rem;
  color: var(--muted);
}

.profile-helper.is-error {
  color: #ff8b8b;
}

.profile-subtitle {
  color: var(--muted);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0;
}

.comment-thread {
  padding: 12px;
  background: rgba(15, 17, 21, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.comment-replies {
  margin-top: 12px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-item.is-reply {
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  padding-left: 12px;
}

.comment-meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 6px;
}

.comment-author {
  color: #fff;
}

.comment-content {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.comment-actions {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.6);
}

.comment-actions button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.comment-empty {
  color: var(--muted);
}

@media (max-width: 900px) {
  .profile-edit-grid {
    grid-template-columns: 1fr;
  }
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.modal-field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.modal-field.checkbox input {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 4px;
  background: transparent;
}

.modal-helper {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-field input,
.modal-field textarea,
.modal-field select {
  background: #10131a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.thread-workspace-summary-input {
  min-height: 140px;
  max-height: 280px;
  line-height: 1.45;
  resize: vertical;
  overflow-y: auto;
}

.thread-workspace-icon-input {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Segoe UI Symbol', 'Inter', system-ui, sans-serif;
  font-size: 1.05rem;
}

.artifact-modal-preview {
  width: 100%;
  border-radius: 12px;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.artifact-modal-code-preview {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 18, 24, 0.8);
  color: #d7deea;
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
}

.artifact-version-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.artifact-version-row {
  cursor: pointer;
  text-align: left;
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 18, 24, 0.8);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.artifact-version-row:hover,
.artifact-version-row.is-active {
  border-color: rgba(124, 155, 255, 0.5);
}

.artifact-version-row.is-current .artifact-version-title {
  color: #b6c8ff;
}

.artifact-version-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.artifact-version-title {
  font-weight: 600;
}

.artifact-version-date {
  font-size: 0.85rem;
  color: var(--muted);
}

.artifact-version-actions {
  display: flex;
  gap: 8px;
}

.artifact-version-current {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.artifact-version-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.artifact-version-loading {
  color: var(--muted);
  font-size: 0.9rem;
}

.artifact-detail-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  margin-top: 12px;
}

.artifact-version-column h3 {
  margin: 0;
}

.artifact-version-view {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 15, 20, 0.7);
  padding: 16px;
}

.artifact-version-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.artifact-version-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.artifact-version-header h3 {
  margin: 0 0 4px;
}

.artifact-version-section h4 {
  margin: 0 0 8px;
}

.artifact-diff {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 13, 18, 0.9);
  padding: 12px;
}

.artifact-diff-summary {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.artifact-diff-body {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow: auto;
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.artifact-diff-line {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  white-space: pre;
  padding: 2px 4px;
  border-radius: 6px;
}

.artifact-diff-line.add {
  background: rgba(94, 209, 143, 0.12);
  color: #b8f2d1;
}

.artifact-diff-line.remove {
  background: rgba(242, 124, 124, 0.12);
  color: #f6b4b4;
}

.artifact-diff-marker {
  color: var(--muted);
}

.artifact-diff-text {
  overflow-wrap: anywhere;
}

/* Auto-surfaced diff shown inline after an AI edit lands in the editor —
   see applyLLMEdit(). Reuses .artifact-diff-* for the body content. */
.code-edit-diff-panel {
  border-top: 1px solid var(--panel-border);
  background: rgba(10, 13, 18, 0.9);
  padding: 8px 12px 12px;
}

.code-edit-diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.code-edit-diff-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.code-edit-diff-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
  line-height: 1;
}

.code-edit-diff-close:hover {
  color: var(--text-secondary);
}

.code-edit-diff-body .artifact-diff-body {
  max-height: 180px;
}

.artifact-chat-history summary {
  cursor: pointer;
  font-weight: 600;
}

.comment-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.artifact-chat-body {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.artifact-chat-message {
  border-radius: 10px;
  padding: 10px;
  background: rgba(17, 20, 27, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.artifact-chat-message.user {
  border-color: rgba(124, 155, 255, 0.3);
}

.artifact-chat-message.assistant {
  border-color: rgba(138, 255, 196, 0.3);
}

.artifact-chat-role {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.artifact-chat-content {
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.artifact-chat-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .artifact-detail-layout {
    grid-template-columns: 1fr;
  }
}

.code-editor.is-locked #code-editor {
  opacity: 0.75;
  cursor: not-allowed;
}

/* TODO(ui-refactor): verify against new 768/1100/1366 system; mobile.css and tablet.css should already cover this case. */
@media (max-width: 1280px) {
  #workspace {
    grid-template-columns: minmax(300px, 1.3fr) 6px minmax(260px, 1fr);
    gap: 12px 0;
    padding: 12px;
  }
}

/* TODO(ui-refactor): verify against new 768/1100/1366 system; mobile.css and tablet.css should already cover this case. */
@media (max-width: 1000px) {
  #workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 10px;
    padding: 10px;
  }

  .col-splitter {
    display: none;
  }

  #chat-panel {
    grid-row: auto;
  }

  #secondary-column {
    max-height: 50vh;
  }

  #workspace[data-workspace-panel="agent"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "tabbar"
      "chat";
  }

  #workspace[data-workspace-panel="agent"] #secondary-column {
    max-height: none;
  }

  #workspace[data-workspace-panel="agent"]:not([data-secondary-tab="companion"]) {
    grid-template-rows: auto minmax(0, 1fr) minmax(220px, 42vh);
    grid-template-areas:
      "tabbar"
      "chat"
      "secondary";
  }

  #workspace[data-workspace-panel="agent"]:not([data-secondary-tab="companion"]) #col-splitter-2 {
    display: none !important;
  }

  #workspace:has(#workspace-tab-bar [data-workspace-panel="agent"].is-active):has(#secondary-tab-bar [data-secondary-tab="companion"].is-active) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "tabbar"
      "chat";
  }
}

@media (max-width: 640px) {
  .credit-badge {
    padding: 6px 8px;
  }

  .credit-panel {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    top: auto;
    width: auto;
    border-radius: 16px;
  }

  .usage-modal {
    padding: 12px;
  }

  .usage-panel {
    padding: 16px;
  }

  .paywall-modal {
    align-items: flex-end;
    padding: 0;
  }

  .paywall-sheet {
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    max-height: 92vh;
    overflow-y: auto;
  }

  .paywall-table {
    font-size: 0.82rem;
  }
}

.plans-page {
  --plans-bg: #0a0e18;
  --plans-panel: rgba(15, 23, 42, 0.72);
  --plans-border: rgba(148, 163, 184, 0.16);
  --plans-text: #e5eefb;
  --plans-muted: #94a3b8;
  --plans-primary: #60a5fa;
  --plans-primary-strong: #2563eb;
  --plans-accent: #34d399;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.18), transparent 34%),
    linear-gradient(180deg, #08111e 0%, var(--plans-bg) 48%, #070a12 100%);
  color: var(--plans-text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.plans-page::before,
.plans-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.plans-page::before {
  background:
    radial-gradient(circle at 18% 14%, rgba(96, 165, 250, 0.12), transparent 22%),
    radial-gradient(circle at 82% 22%, rgba(52, 211, 153, 0.08), transparent 24%),
    radial-gradient(circle at 50% 72%, rgba(96, 165, 250, 0.06), transparent 28%);
}

.plans-page::after {
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.85), rgba(0,0,0,0.2) 55%, transparent 100%);
  opacity: 0.25;
}

.plans-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.7) 55%, rgba(0,0,0,0.35) 78%, transparent 100%);
}

.plans-matrix {
  position: absolute;
  inset: 0;
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.18em;
  white-space: pre;
  user-select: none;
  text-transform: uppercase;
  color: rgba(96, 165, 250, 0.1);
}

.plans-matrix pre {
  margin: 0;
  position: absolute;
}

.plans-matrix-a {
  transform: rotate(-5deg) scale(1.02);
  opacity: 0.78;
}

.plans-matrix-a pre:first-child {
  top: 2%;
  left: -2%;
}

.plans-matrix-a pre:last-child {
  top: 34%;
  right: -3%;
}

.plans-matrix-b {
  transform: rotate(7deg) scale(0.92);
  color: rgba(52, 211, 153, 0.08);
  opacity: 0.66;
}

.plans-matrix-b pre {
  top: 10%;
  left: 20%;
}

.plans-link-field {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 24%, rgba(96, 165, 250, 0.16) 0 2px, transparent 3px),
    radial-gradient(circle at 76% 20%, rgba(52, 211, 153, 0.14) 0 2px, transparent 3px),
    radial-gradient(circle at 38% 58%, rgba(229, 238, 251, 0.12) 0 2px, transparent 3px),
    radial-gradient(circle at 68% 66%, rgba(96, 165, 250, 0.12) 0 2px, transparent 3px),
    linear-gradient(120deg, transparent 19%, rgba(96, 165, 250, 0.08) 20%, transparent 21%),
    linear-gradient(62deg, transparent 33%, rgba(52, 211, 153, 0.06) 34%, transparent 35%),
    linear-gradient(152deg, transparent 47%, rgba(229, 238, 251, 0.05) 48%, transparent 49%);
  opacity: 0.38;
  filter: drop-shadow(0 0 22px rgba(96, 165, 250, 0.05));
}

.plans-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  position: relative;
  z-index: 1;
}

.plans-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 44px;
}

.plans-signin {
  color: var(--plans-muted);
  text-decoration: none;
  font-size: 13px;
}

.plans-header {
  padding: 22px 0 16px;
  text-align: center;
}

.plans-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--plans-primary);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.plans-header h1 {
  margin: 18px auto 14px;
  max-width: 780px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.plans-header p {
  margin: 0 auto;
  max-width: 680px;
  color: var(--plans-muted);
  font-size: 17px;
  line-height: 1.6;
}

.plans-hero-graphic {
  display: flex;
  justify-content: center;
  margin: 24px 0 12px;
}

.plans-orbit-card {
  width: min(100%, 760px);
  min-height: 160px;
  border: 1px solid var(--plans-border);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 42%, rgba(96, 165, 250, 0.18), transparent 32%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.45));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 24px 80px rgba(0,0,0,0.24);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
}

.plans-orbit-card::before,
.plans-orbit-card::after {
  content: "";
  position: absolute;
  inset: 24px 12%;
  border: 1px dashed rgba(96, 165, 250, 0.22);
  border-radius: 999px;
  transform: rotate(-8deg);
}

.plans-orbit-card::after {
  inset: 44px 20%;
  border-color: rgba(52, 211, 153, 0.18);
  transform: rotate(10deg);
}

.orbit-core {
  width: 86px;
  height: 86px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--plans-primary-strong), var(--plans-accent));
  box-shadow: 0 0 42px rgba(96, 165, 250, 0.28);
  position: relative;
  z-index: 1;
}

.plans-orbit-card p {
  margin: 12px 0 0;
  color: var(--plans-muted);
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.orbit-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--plans-primary);
  box-shadow: 0 0 24px rgba(96, 165, 250, 0.55);
}

.orbit-dot-a { top: 36px; left: 18%; }
.orbit-dot-b { right: 22%; top: 54px; background: var(--plans-accent); }
.orbit-dot-c { bottom: 38px; right: 34%; background: rgba(229, 238, 251, 0.78); }

.link-button {
  color: var(--plans-muted);
  text-decoration: none;
  font-size: 13px;
}

.plans-grid {
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.plan-card {
  position: relative;
  border: 1px solid var(--plans-border);
  border-radius: 20px;
  background: var(--plans-panel);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  backdrop-filter: blur(12px);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.plan-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(96, 165, 250, 0.08), transparent 42%),
    linear-gradient(180deg, transparent, rgba(52, 211, 153, 0.04));
  pointer-events: none;
}

.plan-card > * {
  position: relative;
  z-index: 1;
}

.plan-card-orbit {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 1px solid rgba(96, 165, 250, 0.12);
  background:
    radial-gradient(circle at 50% 50%, rgba(96, 165, 250, 0.28) 0 3px, transparent 4px),
    linear-gradient(90deg, transparent 47%, rgba(96, 165, 250, 0.08) 48%, rgba(96, 165, 250, 0.08) 52%, transparent 53%),
    linear-gradient(transparent 47%, rgba(52, 211, 153, 0.08) 48%, rgba(52, 211, 153, 0.08) 52%, transparent 53%);
  opacity: 0.62;
  pointer-events: none;
}

.plan-card--featured {
  border-color: rgba(96, 165, 250, 0.42);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.18), 0 24px 60px rgba(37, 99, 235, 0.18);
}

.plan-card[data-tier="power"] {
  border-color: rgba(52, 211, 153, 0.34);
  background:
    radial-gradient(circle at 84% 12%, rgba(52, 211, 153, 0.12), transparent 26%),
    var(--plans-panel);
}

.plan-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.14);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #bfdbfe;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.plan-card h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.plan-card-tagline {
  min-height: 38px;
  color: var(--plans-muted);
  font-size: 13px;
  margin: 0 72px 0 0;
  line-height: 1.45;
}

.plan-card-price {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.05em;
  margin: 0.4rem 0 0;
}

.plan-card-compare {
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.86);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.plan-card ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.1rem;
  color: var(--plans-muted);
  font-size: 0.875rem;
  flex: 1;
  display: grid;
  gap: 0.3rem;
}

.plan-card li::marker {
  color: var(--plans-accent);
}

.plan-card .primary-button {
  min-height: 46px;
  border-radius: 12px;
  background: var(--plans-primary-strong);
  color: white;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22);
}

.plan-card[data-tier="power"] .primary-button {
  background: linear-gradient(135deg, var(--plans-primary-strong), #059669);
}

.plans-comparison-section {
  margin-top: 42px;
}

.plans-comparison-section h2 {
  margin: 0 0 14px;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.plans-comparison {
  overflow-x: auto;
  border: 1px solid var(--plans-border);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(12px);
}

.plans-comparison .col-ours {
  background: rgba(96, 165, 250, 0.06);
  color: var(--plans-text);
  font-weight: 500;
}

.plans-comparison .col-competitor {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

.plans-comparison .col-competitor.dim {
  color: rgba(255, 255, 255, 0.3);
}

.plans-footnote {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.72);
}

.plans-error {
  margin-top: 1rem;
  color: #ffb5b5;
}

@media (max-width: 720px) {
  .plans-shell {
    padding: 22px 18px 48px;
  }

  .plans-topbar {
    margin-bottom: 28px;
  }

  .plans-matrix-b {
    display: none;
  }

  .plans-orbit-card::before,
  .plans-orbit-card::after {
    left: 6%;
    right: 6%;
  }

  .plan-card-tagline {
    margin-right: 58px;
  }
}

.artifact-category {
  display: inline-flex;
  margin-bottom: 0.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(138, 180, 248, 0.35);
  color: #8ab4f8;
  font-size: 0.72rem;
  text-transform: capitalize;
}

.gallery-pagination {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.gallery-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Wide enough for a four-digit page number: the unfiltered gallery runs to ~2,000 pages. */
.gallery-page-input {
  width: 5.5ch;
  padding: 0.2rem 0.35rem;
  text-align: center;
  font: inherit;
  color: inherit;
  background: var(--input-bg, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border, rgba(148, 163, 184, 0.25));
  border-radius: 6px;
  -moz-appearance: textfield;
  appearance: textfield;
}

.gallery-page-input::-webkit-outer-spin-button,
.gallery-page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.agent-workspace {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px;
  margin-top: 8px;
}

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 160px;
  overflow: auto;
}

.agent-item {
  height: 34px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  text-align: left;
  font-size: 12px;
  padding: 6px;
  border: 1px solid #444;
  background: var(--bg-2);
  color: #eee;
  border-radius: 6px;
  cursor: pointer;
}

.agent-item.active {
  border-color: #66a3ff;
}

.agent-item.focused {
  outline: 1px solid #8ab4f8;
  outline-offset: -1px;
}

.agent-list-spacer {
  flex: 0 0 auto;
}

.agent-focus {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  min-height: 120px;
  background: #0b0b0b;
}

.agent-active-label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 6px;
}

.agent-active-output {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
}


.agent-sim {
  margin-top: 10px;
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  padding: 8px;
  background: #0d0d0d;
}

.agent-sim-controls,
.agent-sim-compare {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.agent-sim-controls input,
.agent-sim-controls select,
.agent-sim-compare select {
  background: #151515;
  color: #f5f5f5;
  border: 1px solid #343434;
  border-radius: 6px;
  padding: 6px;
  font-size: 12px;
}

.agent-sim-option {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.agent-sim-result {
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 180px;
  overflow: auto;
  border: 1px solid #2d2d2d;
  border-radius: 6px;
  padding: 8px;
  background: #090909;
}
.agent-empty {
  font-size: 12px;
  opacity: 0.7;
}

.perf-hud {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 12000;
  width: min(340px, calc(100vw - 24px));
  max-height: 60vh;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(132, 153, 255, 0.35);
  border-radius: 10px;
  background: rgba(15, 18, 32, 0.95);
  color: #dce8ff;
  font-size: 12px;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.perf-hud__header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 700;
}

.perf-hud__header span {
  color: #8ea5ff;
  font-weight: 500;
}

.perf-hud__section + .perf-hud__section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(142, 165, 255, 0.25);
}

.perf-hud__label {
  margin-bottom: 4px;
  color: #9cb1ff;
  font-weight: 600;
}

.perf-hud__meta {
  margin-top: 6px;
  color: #9aa9cf;
  font-size: 11px;
}

/* ─── Agent Pipeline ─────────────────────────────────────────────────────── */

.agent-pipeline-section {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-pipeline-input-area h3,
.agent-pipeline-milestones h3,
.agent-pipeline-rating h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #b0b8d0);
}

.agent-pipeline-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--panel, #141420);
  border: 1px solid var(--panel-border, #232334);
  border-radius: 6px;
  color: var(--text, #e8eaf0);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
}

.agent-pipeline-textarea:focus {
  outline: none;
  border-color: var(--accent, #6c8cff);
}

.agent-pipeline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.agent-icon-button {
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-size: 18px;
  line-height: 1;
}

.agent-icon-button.is-loading {
  opacity: 0.88;
  cursor: progress;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), 0 0 12px rgba(59, 130, 246, 0.18);
  animation: pipelineDownloadPulse 1.1s ease-in-out infinite;
}

@keyframes pipelineDownloadPulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}

.agent-pipeline-status {
  font-size: 12px;
  color: var(--text-tertiary, #8090b0);
  transition: opacity 0.3s ease;
}

.agent-pipeline-status.working {
  color: #60a5fa;
}

.agent-pipeline-status.working .status-text {
  display: inline;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes statusDots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

.agent-pipeline-status.working .status-dots::after {
  content: '';
  animation: statusDots 1.5s steps(1) infinite;
}

.agent-create-trace-slot {
  margin-top: 10px;
}

.agent-create-trace-chip {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(88px, 1.4fr) repeat(4, minmax(54px, auto));
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(96, 165, 250, 0.32);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(10, 16, 30, 0.96));
  color: #c7d2fe;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.agent-create-trace-chip.hidden {
  display: none;
}

.agent-create-trace-chip:hover {
  border-color: rgba(125, 211, 252, 0.6);
  background: linear-gradient(180deg, rgba(17, 31, 56, 0.98), rgba(11, 20, 38, 0.98));
}

.agent-create-trace-chip.is-complete {
  border-color: rgba(52, 211, 153, 0.5);
}

.agent-create-trace-chip.is-failed {
  border-color: rgba(248, 113, 113, 0.58);
}

.agent-create-trace-chip__label {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.agent-create-trace-chip__metric {
  color: #93c5fd;
  font-size: 11px;
  white-space: nowrap;
}

.create-build-trace-signals {
  grid-column: 1 / -1;
  font-size: 11px;
  color: rgba(52, 211, 153, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 2px;
}

.pipeline-signal-triple-row {
  font-size: 11px;
  color: rgba(167, 139, 250, 0.72);
  padding-left: 8px;
}

.agent-create-trace-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.agent-create-trace-panel {
  width: min(860px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: #0b1020;
  color: #dbeafe;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.agent-create-trace-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.agent-create-trace-panel__eyebrow {
  margin-bottom: 4px;
  color: #38bdf8;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.agent-create-trace-panel h3,
.agent-create-trace-panel h4 {
  margin: 0;
}

.agent-create-trace-panel h3 {
  color: var(--text);
  font-size: 18px;
}

.agent-create-trace-panel h4 {
  margin-bottom: 10px;
  color: #bfdbfe;
  font-size: 12px;
  text-transform: uppercase;
}

.agent-create-trace-panel__close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  cursor: pointer;
}

.agent-create-trace-panel__summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 20px;
}

.agent-create-trace-panel__summary div,
.agent-create-trace-panel__phase,
.agent-create-trace-panel__grid section,
.agent-create-trace-panel__events {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
}

.agent-create-trace-panel__summary div {
  padding: 12px;
}

.agent-create-trace-panel__summary strong {
  display: block;
  color: var(--text);
  font-size: 20px;
}

.agent-create-trace-panel__summary span,
.agent-create-trace-panel__phase span {
  color: var(--text-secondary);
  font-size: 11px;
}

.agent-create-trace-panel__phase {
  margin: 0 20px 16px;
  padding: 12px;
}

.agent-create-trace-panel__phase strong {
  display: block;
  margin-top: 3px;
  color: #e0f2fe;
  font-size: 13px;
}

.agent-create-trace-panel__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 20px 16px;
}

.agent-create-trace-panel__grid section,
.agent-create-trace-panel__events {
  padding: 14px;
}

.agent-create-trace-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.agent-create-trace-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 9px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.72);
}

.agent-create-trace-row span,
.agent-create-trace-node span {
  color: var(--text-primary);
  font-size: 12px;
}

.agent-create-trace-row em {
  color: #93c5fd;
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.agent-create-trace-row[data-status="gap"] em {
  color: #fbbf24;
}

.agent-create-trace-row[data-status="known"] em {
  color: #34d399;
}

.agent-create-trace-node-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.agent-create-trace-node {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
}

.agent-create-trace-node[data-kind="gap"] {
  border-color: rgba(251, 191, 36, 0.42);
}

.agent-create-trace-node[data-status="completed"],
.agent-create-trace-node[data-status="known"] {
  border-color: rgba(52, 211, 153, 0.38);
}

.agent-create-trace-panel__events {
  margin: 0 20px 20px;
}

.agent-create-trace-event {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.agent-create-trace-event:first-of-type {
  border-top: 0;
}

.agent-create-trace-event span {
  color: #38bdf8;
  font-size: 11px;
}

.agent-create-trace-event strong {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

.agent-create-trace-empty {
  color: var(--text-tertiary);
  font-size: 12px;
}

@media (max-width: 760px) {
  .agent-create-trace-chip {
    grid-template-columns: 1fr 1fr;
  }

  .agent-create-trace-overlay {
    padding: 12px;
  }

  .agent-create-trace-panel__summary,
  .agent-create-trace-panel__grid {
    grid-template-columns: 1fr;
  }

  .agent-create-trace-event {
    grid-template-columns: 1fr;
  }
}

/* Pipeline progress tracker */
.pipeline-progress-bar {
  margin-top: 8px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.pipeline-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 2px;
  transition: width 0.6s ease;
  position: relative;
}

.pipeline-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
  animation: progressShimmer 1.5s ease-in-out infinite;
}

@keyframes progressShimmer {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.pipeline-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
  gap: 8px;
}

.pipeline-elapsed {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.pipeline-eta {
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.pipeline-step-count {
  color: var(--text-secondary);
}

/* Pipeline cancel button with warning */
.pipeline-cancel-btn {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pipeline-cancel-btn:hover {
  background: #b91c1c;
  transform: scale(1.02);
}

.pipeline-cancel-warning {
  margin-top: 6px;
  font-size: 11px;
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s, max-height 0.3s;
}

.pipeline-cancel-warning.visible {
  opacity: 1;
  max-height: 40px;
}

/* Signal badge styles for live triple accumulation */
.create-build-trace-signals {
  grid-column: 1 / -1;
  font-size: 11px;
  color: rgba(52, 211, 153, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 2px;
}

.pipeline-signal-triple-row {
  font-size: 11px;
  color: rgba(167, 139, 250, 0.72);
  padding-left: 8px;
}

/* HITL decision modal */
.pipeline-hitl-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.pipeline-hitl-modal__card {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.pipeline-hitl-modal__heading {
  font-size: 16px;
  font-weight: 700;
  color: #f0ad4e;
  margin-bottom: 10px;
}

.pipeline-hitl-modal__detail {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.5;
}

.pipeline-hitl-modal__actions {
  display: flex;
  gap: 8px;
}

.pipeline-hitl-modal__btn {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  color: #000;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.pipeline-hitl-modal__btn:hover {
  transform: scale(1.03);
  opacity: 0.9;
}

/* Pipeline build settings */
.pipeline-build-settings {
  margin: 8px 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.5);
}

.pipeline-build-settings__toggle {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  user-select: none;
}

.pipeline-build-settings__body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-build-settings__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.pipeline-build-settings__input {
  width: 72px;
  padding: 3px 6px;
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  text-align: right;
}

.agent-pipeline-milestone-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-pipeline-milestone-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel, #141420);
  border: 1px solid var(--panel-border, #232334);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text, #e8eaf0);
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.agent-pipeline-milestone-item[data-status="completed"] {
  border-color: #2ea04388;
  background:
    linear-gradient(90deg, rgba(46, 160, 67, 0.1), rgba(20, 26, 40, 0.92)),
    var(--panel, #141420);
}

.agent-pipeline-milestone-item[data-status="in_progress"] {
  border-color: #6c8cff88;
  background:
    linear-gradient(90deg, rgba(108, 140, 255, 0.1), rgba(20, 26, 40, 0.92)),
    var(--panel, #141420);
}

.agent-pipeline-milestone-item[data-status="failed"] {
  border-color: #e5534b88;
  background:
    linear-gradient(90deg, rgba(229, 83, 75, 0.1), rgba(20, 26, 40, 0.92)),
    var(--panel, #141420);
}

.agent-pipeline-phase-index {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  color: #7aa2ff;
  font-weight: 700;
}

.agent-pipeline-phase-node {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(122, 162, 255, 0.28);
  background: rgba(18, 24, 38, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

.agent-pipeline-phase-glyph {
  color: #93c5fd;
  font-size: 17px;
  line-height: 1;
}

.agent-pipeline-phase-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.agent-pipeline-phase-label {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.agent-pipeline-phase-meta {
  font-size: 11px;
  color: var(--text-tertiary, #8090b0);
  white-space: nowrap;
}

.agent-pipeline-phase-link {
  width: 44px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(74, 90, 122, 0.3), rgba(74, 90, 122, 0.9), rgba(74, 90, 122, 0.3));
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.agent-pipeline-phase-link::after {
  content: '';
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(147, 197, 253, 0.85), transparent);
}

.agent-pipeline-milestone-item[data-status="in_progress"] .agent-pipeline-phase-link::after {
  animation: pipeline-phase-travel 1.3s linear infinite;
}

.agent-pipeline-milestone-item[data-status="completed"] .agent-pipeline-phase-link {
  background: linear-gradient(90deg, rgba(46, 160, 67, 0.45), rgba(74, 222, 128, 0.95), rgba(46, 160, 67, 0.45));
}

.agent-pipeline-milestone-item[data-status="completed"] .agent-pipeline-phase-node {
  border-color: rgba(74, 222, 128, 0.45);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.25);
}

.agent-pipeline-milestone-item[data-status="completed"] .agent-pipeline-phase-glyph {
  color: #86efac;
}

.agent-pipeline-milestone-item[data-status="in_progress"] .agent-pipeline-phase-node {
  border-color: rgba(96, 165, 250, 0.52);
  box-shadow: 0 0 14px rgba(96, 165, 250, 0.24);
}

.agent-pipeline-milestone-item[data-status="in_progress"] .agent-pipeline-phase-glyph {
  color: #bfdbfe;
}

.agent-pipeline-milestone-item[data-status="failed"] .agent-pipeline-phase-node {
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.18);
}

.agent-pipeline-milestone-item[data-status="failed"] .agent-pipeline-phase-glyph {
  color: #fca5a5;
}

.agent-pipeline-milestone-item.is-terminal .agent-pipeline-phase-link {
  opacity: 0;
}

@keyframes pipeline-phase-travel {
  0% { left: -40%; }
  100% { left: 100%; }
}

.agent-pipeline-quorum {
  font-size: 14px;
  color: var(--text, #e8eaf0);
  padding: 8px 10px;
  background: var(--panel, #141420);
  border: 1px solid var(--panel-border, #232334);
  border-radius: 6px;
}

.agent-pipeline-quorum-score {
  font-size: 22px;
  font-weight: 700;
}

.agent-pipeline-quorum-passed {
  color: #2ea043;
}

.agent-pipeline-quorum-failed {
  color: #e5534b;
}

.agent-pipeline-rating-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin-top: 8px;
  font-size: 12px;
}

.agent-pipeline-rating-dim {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  color: var(--text-secondary, #b0b8d0);
}

.agent-pipeline-rating-dim span:last-child {
  font-weight: 600;
  color: var(--text, #e8eaf0);
}

/* ── Quality proxy bars ── */
.pipeline-quality-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

.pipeline-quality-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pipeline-quality-bar-label {
  width: 64px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-secondary, #8090b0);
  text-align: right;
}

.pipeline-quality-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 5px;
  overflow: hidden;
}

.pipeline-quality-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.pipeline-orbit-shell {
  display: grid;
  place-items: center;
  padding: 12px 0 6px;
}

.pipeline-orbit-stage {
  position: relative;
  max-width: 100%;
}

.pipeline-orbit-svg,
.pipeline-spiral-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pipeline-orbit-core-ring {
  fill: rgba(30, 41, 59, 0.18);
  stroke: rgba(100, 116, 139, 0.35);
  stroke-width: 1;
}

.pipeline-orbit-core-dot {
  fill: rgba(96, 165, 250, 0.65);
  filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.35));
}

.pipeline-orbit-core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(96, 165, 250, 0.28);
  color: #bfdbfe;
  box-shadow: 0 0 18px rgba(96, 165, 250, 0.2);
  font-size: 18px;
  line-height: 1;
}

.pipeline-orbit-node,
.pipeline-spiral-node {
  position: absolute;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(100, 116, 139, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
}

.pipeline-orbit-node-glyph,
.pipeline-spiral-node-glyph {
  font-size: 13px;
  line-height: 1;
  color: #93c5fd;
  letter-spacing: 0;
  font-variant-ligatures: none;
}

.pipeline-orbit-node.is-completed,
.pipeline-spiral-node.is-completed {
  border-color: rgba(74, 222, 128, 0.5);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.24);
}

.pipeline-orbit-node.is-completed .pipeline-orbit-node-glyph,
.pipeline-spiral-node.is-completed .pipeline-spiral-node-glyph {
  color: #86efac;
}

.pipeline-orbit-node.is-active,
.pipeline-spiral-node.is-active {
  border-color: rgba(96, 165, 250, 0.56);
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.28);
  animation: pipeline-node-pulse 1.6s ease-in-out infinite;
}

.pipeline-orbit-node.is-active .pipeline-orbit-node-glyph,
.pipeline-spiral-node.is-active .pipeline-spiral-node-glyph {
  color: #dbeafe;
}

.pipeline-orbit-node.is-failed,
.pipeline-spiral-node.is-failed {
  border-color: rgba(248, 113, 113, 0.56);
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.2);
}

.pipeline-orbit-node.is-failed .pipeline-orbit-node-glyph,
.pipeline-spiral-node.is-failed .pipeline-spiral-node-glyph {
  color: #fca5a5;
}

.pipeline-spiral-trail {
  fill: none;
  stroke: rgba(71, 85, 105, 0.18);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.pipeline-spiral-path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke: rgba(96, 165, 250, 0.7);
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - (var(--spiral-progress, 0) * 100));
  transition: stroke-dashoffset 0.55s ease, stroke 0.35s ease;
  filter: drop-shadow(0 0 4px rgba(96, 165, 250, 0.2));
}

.pipeline-spiral-path[style*="--spiral-progress:0"] {
  stroke: rgba(71, 85, 105, 0.34);
  filter: none;
}

.pipeline-spiral-path:not([style*="--spiral-progress:0"]):not(.is-failed) {
  stroke: rgba(74, 222, 128, 0.86);
  filter: drop-shadow(0 0 6px rgba(74, 222, 128, 0.25));
}

.pipeline-spiral-path.is-failed {
  stroke: rgba(248, 113, 113, 0.8);
}

.pipeline-spiral-substep {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  line-height: 1;
  color: var(--text-tertiary);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(100, 116, 139, 0.25);
  transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
  z-index: 1;
}

.pipeline-spiral-substep.is-completed {
  border-color: rgba(74, 222, 128, 0.5);
  color: #86efac;
  background: rgba(74, 222, 128, 0.08);
}

.pipeline-spiral-substep.is-active {
  border-color: rgba(96, 165, 250, 0.6);
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.1);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.3);
  animation: pipeline-node-pulse 1.6s ease-in-out infinite;
}

@keyframes pipeline-node-pulse {
  0%, 100% { transform: translateZ(0) scale(1); }
  50% { transform: translateZ(0) scale(1.05); }
}

/* ─── Dev Tab Pulse Animation ─────────────────────────────────────────────── */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 4px #22c55e44; }
  50% { box-shadow: 0 0 12px #22c55e88; }
}

/* ─── Auto Dev Plan Styles ────────────────────────────────────────────────── */
.auto-dev-plan {
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid #2ecc7144;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text, #e8eaf0);
  line-height: 1.5;
}
.auto-dev-plan-header {
  font-size: 16px;
  font-weight: 700;
  color: #2ecc71;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}
.auto-dev-plan-section {
  margin-bottom: 14px;
}
.auto-dev-plan-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.auto-dev-plan-section p {
  margin: 0;
  color: var(--text-secondary, #b0b8d0);
}
.auto-dev-plan-milestones {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}
.auto-dev-plan-milestones li {
  padding: 4px 0;
  color: var(--text-secondary, #b0b8d0);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.auto-dev-plan-milestones li:last-child {
  border-bottom: none;
}
.auto-dev-plan-deliverables {
  list-style: disc;
  padding-left: 18px;
  margin: 4px 0 0;
  color: var(--text-secondary, #b0b8d0);
}
.auto-dev-plan-deliverables li {
  padding: 2px 0;
}
.auto-dev-plan-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 14px 0;
}
.auto-dev-plan-costs {
  font-size: 12px;
  color: var(--text-secondary, #b0b8d0);
}
.auto-dev-plan-costs div {
  padding: 2px 0;
}
.auto-dev-plan-costs strong {
  color: var(--text, #e8eaf0);
}
.auto-dev-plan-costs .savings {
  color: #2ecc71;
  font-weight: 600;
}

/* Quality Target Selector */
.quality-target-selector {
  margin-top: 14px;
}
.quality-target-selector-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.quality-target-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 10px;
}
.quality-target-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary, #b0b8d0);
  transition: background 0.15s;
}
.quality-target-option:hover {
  background: rgba(255,255,255,0.05);
}
.quality-target-option input[type="radio"] {
  accent-color: #2ecc71;
  margin: 0;
}
.quality-target-option .qt-label {
  flex: 1;
  font-weight: 500;
}
.quality-target-option .qt-score {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 60px;
}
.quality-target-option .qt-time {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 50px;
  text-align: right;
}
.quality-target-option .qt-note {
  font-size: 10px;
  color: #f39c12;
  min-width: 70px;
  text-align: right;
}

/* Development-depth slider (replaces the quality radios as the primary control) */
.depth-slider-control {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
}

/* Per-step plan editor — lets a user correct a step's title/description before
   Approve, instead of the old all-or-nothing Approve/Redo choice. Only shown
   on the pre-build "Ready to start" screen (see renderPipelineFlowchart). */
.agent-pipeline-steps-list {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
}
.agent-pipeline-steps-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.agent-pipeline-steps-hint {
  font-size: 10.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-tertiary);
}
.agent-pipeline-step-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.agent-pipeline-step-row:first-of-type {
  border-top: none;
}
.agent-pipeline-step-index {
  flex: 0 0 auto;
  width: 18px;
  padding-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: right;
}
.agent-pipeline-step-fields {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-pipeline-step-title,
.agent-pipeline-step-desc {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: inherit;
  padding: 5px 7px;
  box-sizing: border-box;
}
.agent-pipeline-step-title {
  font-size: 12.5px;
  font-weight: 600;
}
.agent-pipeline-step-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  resize: vertical;
  min-height: 32px;
}
.agent-pipeline-step-title:focus,
.agent-pipeline-step-desc:focus {
  outline: none;
  border-color: #2ecc71;
}
.agent-pipeline-step-save-status {
  font-size: 10px;
  color: var(--text-tertiary);
  min-height: 12px;
  display: block;
}
.agent-pipeline-step-save-status.is-saved {
  color: #2ecc71;
}
.agent-pipeline-step-save-status.is-error {
  color: #f87171;
}

/* Repeat-request check-in — offered before a Create build starts when the new
   request looks like the one just submitted in this thread. Non-blocking:
   either button dismisses it immediately. See startAgentPipelineWithQuality(). */
.agent-pipeline-repeat-checkin {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.agent-pipeline-repeat-checkin-text {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.agent-pipeline-repeat-checkin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.agent-pipeline-repeat-try-btn,
.agent-pipeline-repeat-build-btn {
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
}
.agent-pipeline-repeat-try-btn {
  background: #334155;
  color: #cbd5e1;
}
.agent-pipeline-repeat-build-btn {
  background: #22c55e;
  color: #fff;
  font-weight: 600;
}
/* Persistent depth slider mounted under the Create textarea (always visible). */
.agent-pipeline-depth {
  margin: 8px 0;
}
.depth-slider-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.depth-slider-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.depth-slider-value {
  font-size: 13px;
  font-weight: 700;
  color: #2ecc71;
}
.depth-slider-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(90deg, #1e3a5f, #2ecc71);
  outline: none;
  margin: 4px 0 6px;
  cursor: pointer;
}
.depth-slider-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2ecc71;
  border: 2px solid #0f172a;
  box-shadow: 0 0 0 1px rgba(46,204,113,0.5);
  cursor: pointer;
}
.depth-slider-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2ecc71;
  border: 2px solid #0f172a;
  cursor: pointer;
}
.depth-slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-tertiary);
  letter-spacing: 0;
}
.depth-slider-tick {
  flex: 1;
  text-align: center;
  /* Rendered as a <button> so it's natively clickable/keyboard-selectable —
     strip the native chrome so it still reads as a tick label. */
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 3px 0 0;
  font: inherit;
  font-size: 9px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.12s ease;
}
.depth-slider-tick:hover { color: var(--text-secondary); }
.depth-slider-tick.is-active { color: #2ecc71; font-weight: 700; }
.depth-slider-tick:focus-visible {
  outline: 1px solid rgba(46, 204, 113, 0.6);
  outline-offset: 1px;
  border-radius: 3px;
}
.depth-slider-tick:first-child { text-align: left; }
.depth-slider-tick:last-child { text-align: right; }
.depth-slider-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.depth-slider-blurb {
  font-size: 11px;
  color: var(--text-secondary, #b0b8d0);
  line-height: 1.4;
}
.depth-slider-cost {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Plan-only deliverable (Outline / Spec) */
.plan-doc {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 8px;
}
.plan-doc__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.plan-doc__badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #2ecc71;
  border: 1px solid rgba(46,204,113,0.4);
  border-radius: 4px;
  padding: 2px 8px;
}
.plan-doc__actions { display: flex; gap: 6px; }
.plan-doc__btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--border-color);
  border: none;
  border-radius: 5px;
  padding: 5px 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.plan-doc__btn:hover { opacity: 0.85; }
.plan-doc__btn--accent { background: #2ecc71; color: #04210f; }
.plan-doc__body { font-size: 12px; color: var(--text-secondary, #b0b8d0); line-height: 1.5; }
.plan-doc__body h3 { font-size: 14px; color: var(--text-primary); margin: 10px 0 6px; }
.plan-doc__body h4 { font-size: 12.5px; color: var(--text-primary); margin: 10px 0 4px; }
.plan-doc__body h5 { font-size: 11.5px; color: var(--text-secondary); margin: 8px 0 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.plan-doc__body ul { margin: 4px 0 8px; padding-left: 18px; }
.plan-doc__body li { margin: 2px 0; }
.plan-doc__body p { margin: 4px 0; }

/* Auto Dev Plan Action Buttons */
.auto-dev-plan-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.auto-dev-plan-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.auto-dev-plan-actions button:hover {
  opacity: 0.85;
}
.auto-dev-start-btn {
  flex: 1;
  background: #2ecc71;
  color: #000;
}
.auto-dev-edit-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text, #e8eaf0);
}
.auto-dev-cancel-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid #333 !important;
}

/* ─── Agent Personality Section ─────────────────────────────────────────────── */
/* Resize bar between Chat and Agent */
.chat-agent-resize-bar {
  height: 12px;
  cursor: ns-resize;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  margin: 4px 0;
  z-index: 10;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-agent-resize-bar::after {
  content: '';
  position: absolute;
  left: 20%;
  right: 20%;
  top: 50%;
  transform: translateY(-50%);
  height: 3px;
  border-radius: 2px;
  background: var(--border-color, #2e3a50);
  transition: background 0.15s, height 0.15s;
}
.chat-agent-resize-bar:hover::after {
  background: #646cff;
  height: 4px;
}
.chat-agent-resize-bar.dragging::after {
  background: #646cff;
  height: 4px;
}

.agent-personality-section {
  border-top: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel, #1a1a2e);
}

.agent-console-render {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  margin-top: 6px;
}

.agent-console-frame-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-2);
}

.agent-console-iframe {
  position: absolute;
  left: 50%;
  top: 50%;
  flex: none;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-2);
  display: block;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  transition: transform 0.16s ease;
}

.agent-console-frame-stage[hidden],
.agent-console-iframe[hidden],
.agent-render-submosaic-grid[hidden] {
  display: none;
}

.agent-console-render.is-submosaic {
  overflow: hidden;
}

.agent-render-submosaic-grid {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--companion-submosaic-columns, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--companion-submosaic-rows, 2), minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  overflow: hidden;
  background: #070b12;
}

.agent-render-submosaic-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  background: var(--bg-2);
  cursor: pointer;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.agent-render-submosaic-tile:hover,
.agent-render-submosaic-tile:focus-visible {
  border-color: rgba(94, 234, 212, 0.58);
}

.agent-render-submosaic-tile:focus-visible {
  box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.25);
}

.agent-render-submosaic-tile.is-active {
  border-color: #5eead4;
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.3), 0 0 12px rgba(45, 212, 191, 0.13);
}

.agent-render-submosaic-label {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  max-width: calc(100% - 10px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 4px;
  background: rgba(5, 8, 22, 0.84);
  color: var(--text-primary);
  font: 10px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.agent-render-submosaic-label > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-render-submosaic-favorite {
  flex: 0 0 auto;
  color: #facc15;
  font-weight: 800;
}

.agent-render-submosaic-iframe {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg-2);
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  transition: transform 0.16s ease;
  pointer-events: none;
}

/* ─── Companion Console State Animations ──────────────────────────────────── */

/* Processing: spinning gear overlay */
.console-processing::after {
  content: '\2699';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 18px;
  animation: consoleSpinGear 1.5s linear infinite;
  opacity: 0.6;
  pointer-events: none;
  z-index: 10;
}

@keyframes consoleSpinGear {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Reading: flash indicator */
.console-reading::after {
  content: '!';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 16px;
  font-weight: bold;
  font-family: monospace;
  animation: consoleFlashNotice 2s ease-in-out infinite;
  pointer-events: none;
  z-index: 10;
}

@keyframes consoleFlashNotice {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.9; color: #4ef2bf; }
}

/* Budget pause: dim the console */
.console-budget-paused {
  opacity: 0.4;
  filter: grayscale(0.5);
  transition: opacity 0.5s, filter 0.5s;
}

.agent-builder-header {
  margin-bottom: 6px;
}

.workspace-glyph-heading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.08em;
}

.agent-personality-input {
  width: 100%;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  color: var(--text-primary, #e2e8f0);
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 40px;
}

.agent-builder-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* ── Companion voice & style sliders ───────────────────────────────────────
   Six axes the user sets by hand. Collapsed by default so the builder stays a
   one-line "describe it and go" flow; opening it is the deliberate act of
   taking control of how the companion sounds. */
.companion-style-panel {
  margin-top: 8px;
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  background: var(--bg-secondary, #1a1a2e);
}

.companion-style-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.companion-style-summary::-webkit-details-marker { display: none; }
.companion-style-summary:hover { color: #f97316; }
.companion-style-panel[open] .companion-style-summary {
  border-bottom: 1px solid var(--border-color, #2e3a50);
}

.companion-style-hint {
  margin: 8px 10px 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary, #94a3b8);
}

.companion-style-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
}

.companion-style-row {
  display: grid;
  grid-template-columns: 66px 1fr;
  grid-template-areas: "label slider" "label ends";
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
}

.companion-style-label {
  grid-area: label;
  font-size: 11px;
  color: var(--text-primary, #e2e8f0);
}

.companion-style-slider {
  grid-area: slider;
  width: 100%;
  min-width: 0;
  /* Range inputs carry a 2px UA margin, which pushed the track past its grid
     column and left it misaligned with the end labels underneath. */
  margin: 0;
  accent-color: #f97316;
  cursor: pointer;
}

.companion-style-ends {
  grid-area: ends;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 9px;
  color: var(--text-secondary, #94a3b8);
}

/* The number reads as the live value, so it stays brighter than the end labels
   and is tabular so it does not jitter the row while dragging. */
.companion-style-value {
  color: var(--text-primary, #e2e8f0);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

/* A centered axis is "no opinion" and emits no instruction, so it is dimmed to
   distinguish it at a glance from one the user deliberately moved. */
.companion-style-row.is-neutral .companion-style-value { opacity: 0.45; }

.companion-style-reset {
  margin: 0 10px 10px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  color: var(--text-secondary, #94a3b8);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.companion-style-reset:hover {
  color: var(--text-primary, #e2e8f0);
  border-color: #f97316;
}

@media (prefers-reduced-motion: reduce) {
  .companion-style-slider { transition: none; }
}

.create-agent-btn {
  flex: 1;
  padding: 7px 12px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.create-agent-btn:hover { opacity: 0.9; }
.create-agent-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.create-agent-btn.is-loading {
  position: relative;
  padding-left: 34px;
}
.create-agent-btn.is-loading::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  animation: agentBuilderSpinner 0.85s linear infinite;
}

.agent-builder-status {
  min-height: 30px;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.55);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.agent-builder-status.is-visible {
  opacity: 1;
  transform: translateY(0);
  border-color: rgba(148, 163, 184, 0.25);
}

.agent-builder-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  opacity: 0.9;
}

.agent-builder-status.is-loading {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(30, 64, 175, 0.12);
}

.agent-builder-status.is-loading::before {
  animation: agentBuilderStatusPulse 1.2s ease-in-out infinite;
}

.agent-builder-status.is-success {
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.32);
  background: rgba(20, 83, 45, 0.16);
}

.agent-builder-status.is-warning {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.32);
  background: rgba(146, 64, 14, 0.14);
}

.agent-builder-status.is-error {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.34);
  background: rgba(127, 29, 29, 0.16);
}

.agent-library-panel {
  margin-top: 12px;
  border: 1px solid rgba(71, 85, 105, 0.5);
  border-radius: 10px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  gap: 8px;
}

.agent-library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-primary);
}

.agent-library-refresh-btn,
.agent-library-mini-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-2);
  color: #dbeafe;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
}

.agent-library-refresh-btn {
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}

.agent-library-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.agent-library-item {
  border: 1px solid #23324d;
  border-radius: 8px;
  background: rgba(9, 18, 34, 0.92);
  padding: 8px 10px;
  display: grid;
  gap: 5px;
}

.agent-library-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agent-library-item-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.agent-library-item-role {
  color: var(--text-secondary);
  font-size: 11px;
}

.agent-library-item-meta {
  color: #7dd3fc;
  font-size: 11px;
}

.agent-library-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.agent-library-item-actions button {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  cursor: pointer;
}

.agent-library-item-actions .agent-library-delete-btn {
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.agent-library-item-actions .agent-library-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fff1f2;
}

@keyframes agentBuilderStatusPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.45); }
  50% { transform: scale(1.2); box-shadow: 0 0 0 6px rgba(96, 165, 250, 0); }
}

@keyframes agentBuilderSpinner {
  to { transform: rotate(360deg); }
}

.agent-active-display {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Compact agent toolbar */
.agent-compact-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.agent-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
}
.agent-avatar-sm img { width: 100%; height: 100%; border-radius: 6px; object-fit: cover; }
.agent-compact-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.agent-compact-info .agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.agent-role-inline {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-status-inline {
  font-size: 10px;
  color: #34d399;
}
.agent-compact-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.companion-start-conversation-btn {
  border: 1px solid rgba(94, 234, 212, 0.45);
  background: rgba(45, 212, 191, 0.10);
  color: #99f6e4;
  border-radius: 5px;
  padding: 3px 8px;
  font: 600 10px/1.2 ui-monospace, Consolas, monospace;
  cursor: pointer;
  white-space: nowrap;
}
.companion-start-conversation-btn:hover,
.companion-start-conversation-btn:focus-visible {
  background: rgba(45, 212, 191, 0.22);
  border-color: rgba(94, 234, 212, 0.8);
  outline: none;
}
.companion-idle-sphere {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(22, 78, 99, 0.18), transparent 62%), #050816;
}
.companion-idle-sphere.hidden { display: none; }
.companion-idle-sphere::after {
  content: 'LIVE COMPANION FIELD';
  position: absolute;
  left: 14px;
  bottom: 10px;
  color: rgba(153, 246, 228, 0.42);
  font: 9px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.16em;
  pointer-events: none;
}
#agent-console-render.companion-idle-mode > .agent-console-frame-stage { display: none; }
#agent-console-render:not(.companion-idle-mode) > .companion-idle-sphere { display: none; }

/* A render module popped out to its own window (modules/mosaicBoot.js
   _openRenderPopout). The pop-up mirrors the surface, so the whole live surface
   stands down inside the tile and the "…in pop-up window" placeholder is the
   only thing left. Scoped to the CONTAINER because app.js replaces the frames
   themselves — an inline display:none dies with the frame it was set on, which
   is how the render used to pop back into the module. !important because the
   idle-sphere rules above are id-scoped and would otherwise win. */
.mosaic-render-popped-out > .agent-console-frame-stage,
.mosaic-render-popped-out > .agent-render-submosaic-grid,
.mosaic-render-popped-out > .companion-idle-sphere,
.mosaic-render-popped-out > iframe {
  display: none !important;
}
.agent-library-select-sm {
  font-size: 11px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 2px 4px;
  max-width: 120px;
}
.agent-compact-prompt {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  flex-shrink: 0;
}
.agent-direct-input-sm {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}
.agent-direct-input-sm::placeholder { color: #475569; }
.agent-prompt-btn-sm {
  background: #6366f1;
  border: none;
  color: #fff;
  width: 28px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.agent-prompt-btn-sm:hover { background: #818cf8; }

.delete-agent-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s, background 0.15s;
  z-index: 10;
}
.delete-agent-btn:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.15);
}

.agent-profile-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
}

.agent-top-actions {
  display: grid;
  gap: 8px;
  flex: 1 1 520px;
  min-width: 0;
  margin-left: auto;
  padding-right: 32px;
}

.agent-library-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.agent-save-btn {
  min-width: 64px;
}

.agent-autosave-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}

.agent-autosave-toggle input {
  margin: 0;
  accent-color: #6366f1;
}

.agent-save-status {
  min-height: 20px;
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.agent-save-status.is-saving {
  color: #7dd3fc;
}

.agent-save-status.is-saved {
  color: #86efac;
}

.agent-save-status.is-error {
  color: #fca5a5;
}

.agent-library-select {
  min-width: 220px;
  max-width: 280px;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  color: var(--text-primary, #e2e8f0);
  padding: 7px 10px;
  font-size: 12px;
}

.agent-direct-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.agent-direct-message-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  color: var(--text-primary, #e2e8f0);
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
}

/* agent-direct-message-send uses .agent-prompt-btn-sm sizing (28x24px icon button) */
.agent-direct-message-send {
  border: none;
  background: #6366f1;
  color: #fff;
  width: 28px;
  height: 24px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.agent-direct-message-send:hover {
  background: #818cf8;
}

.agent-direct-message-input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.16);
}

@media (max-width: 900px) {
  .agent-profile-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .agent-info {
    min-width: 180px;
  }

  .agent-top-actions {
    width: 100%;
    padding-right: 0;
    margin-left: 58px;
  }

  .agent-library-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .agent-save-status {
    width: 100%;
  }

  .agent-library-select {
    flex: 1 1 180px;
    max-width: none;
  }
}

.agent-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #374151, #1f2937);
  border: 2px solid #4a5568;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.agent-avatar:hover,
.agent-avatar:focus-visible {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.16);
  transform: translateY(-1px);
  outline: none;
}

.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.agent-avatar-placeholder {
  font-size: 20px;
  color: #6b7280;
}

.agent-compact-bar .agent-avatar-sm {
  width: 28px;
  height: 28px;
  border-width: 1px;
  border-radius: 7px;
}

.agent-compact-bar .agent-avatar-sm img {
  border-radius: 6px;
}

.agent-compact-bar .agent-avatar-sm .agent-avatar-placeholder {
  font-size: 13px;
}

.generate-avatar-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: none;
  background: #4a5568;
  color: #9ca3af;
  font-size: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0.6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.generate-avatar-btn:hover {
  opacity: 1;
  background: #f97316;
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.generate-avatar-btn::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #1f2937;
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  border: 1px solid #4a5568;
}

.generate-avatar-btn:hover::before {
  opacity: 1;
}

.agent-info {
  flex: 0 0 210px;
  min-width: 180px;
  padding-top: 2px;
}

.agent-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-role {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-status {
  font-size: 10px;
  color: #22c55e;
  margin-top: 2px;
}

.agent-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  min-height: 16px;
}

.agent-archetype-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  background: rgba(14, 116, 144, 0.18);
  color: #7dd3fc;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.agent-archetype-chip.hidden {
  display: none;
}

.agent-mini-console {
  margin-top: 8px;
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  overflow: hidden;
}

.agent-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(0,0,0,0.3);
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color, #2e3a50);
}

.agent-console-count {
  background: #374151;
  color: #9ca3af;
  border-radius: 8px;
  padding: 0 6px;
  font-size: 10px;
  min-width: 16px;
  text-align: center;
}

/* Agent Action Log — timestamped text entries */
.agent-action-log {
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 6px;
  margin-top: 8px;
  overflow: hidden;
}
.agent-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.3);
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color, #2e3a50);
  position: relative;
  z-index: 30;
  overflow: visible;
}
.agent-panel-header > :first-child {
  margin-right: auto;
}
.agent-panel-header .agent-console-clear-btn {
  flex-shrink: 0;
}
.agent-log-toggle {
  cursor: pointer;
  user-select: none;
}
.agent-log-toggle:hover {
  background: rgba(255,255,255,0.04);
}
.agent-log-entries {
  max-height: 100px;
  overflow-y: auto;
  padding: 4px 8px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 10px;
  line-height: 1.5;
  background: var(--bg-secondary, #0d1117);
  transition: max-height 0.2s ease, padding 0.2s ease;
}
.agent-log-entries.collapsed {
  max-height: 0;
  padding: 0 8px;
  overflow: hidden;
}
.agent-log-entry {
  padding: 1px 0;
  border-bottom: 1px solid rgba(255,255,255,0.02);
}
.agent-log-entry .timestamp {
  color: #4a5568;
  margin-right: 6px;
}
.agent-log-entry.observation { color: var(--text-secondary); }
.agent-log-entry.action { color: #60a5fa; }
.agent-log-entry.warning { color: #f59e0b; }
.agent-log-entry.positive { color: #22c55e; }
.agent-log-entry.critical { color: #ef4444; }
.agent-log-entry.cost { color: #5eead4; opacity: 0.8; }
.agent-cost-tally {
  font-size: 10px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: #5eead4;
  padding: 3px 8px;
  border-bottom: 1px solid rgba(94, 234, 212, 0.15);
  background: rgba(5, 8, 22, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Thread Dock ───────────────────────────────────────────────────────────── */
.thread-dock {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(5, 8, 22, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 36px;
  flex-shrink: 0;
}

/* Only the thread row scrolls — the action buttons after it (public / share /
   export / new) stay pinned on the right no matter how many threads exist. */
.thread-dock-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.thread-dock-inner::-webkit-scrollbar { display: none; }

/* Edge fades signal hidden threads past the row's edge — the scrollbar is
   hidden, so this is the only overflow cue. Classes come from
   _syncThreadDockOverflowAffordance() in app.js. */
.thread-dock-inner.can-scroll-left {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px);
  mask-image: linear-gradient(to right, transparent 0, #000 28px);
}
.thread-dock-inner.can-scroll-right {
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 28px);
  mask-image: linear-gradient(to left, transparent 0, #000 28px);
}
.thread-dock-inner.can-scroll-left.can-scroll-right {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
}

.thread-dock > .thread-new-btn {
  flex-shrink: 0;
}

/* Dock filter — toggled by the 🔎 action button, filters icons by title. */
.thread-filter-input {
  flex-shrink: 0;
  width: 140px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text, #e8ecf8);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  outline: none;
}
.thread-filter-input:focus { border-color: rgba(124, 155, 255, 0.55); }
.thread-filter-input.hidden { display: none; }
#thread-filter-btn.is-active {
  background: rgba(124, 155, 255, 0.18);
  color: #dfe6ff;
}

/* Undo toast shown after confirming a thread deletion. */
.thread-undo-toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  z-index: 9300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12px;
  color: #e8ecf8;
  background: var(--bg-2);
  border: 1px solid rgba(124, 155, 255, 0.25);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
}
.thread-undo-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #dfe6ff;
  background: rgba(124, 155, 255, 0.18);
  border: 1px solid rgba(124, 155, 255, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.thread-undo-btn:hover { background: rgba(124, 155, 255, 0.3); }

/* Drop indicator while dragging a thread over another to reorder. */
.thread-icon-btn.drop-before {
  box-shadow: -3px 0 0 0 rgba(124, 155, 255, 0.85);
}

/* Inline rename popover — opened by double-clicking a thread icon. */
.thread-rename-popover {
  position: fixed;
  z-index: 9200;
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid rgba(124, 155, 255, 0.25);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
}
.thread-icon-input {
  width: 40px;
  padding: 6px 4px;
  font-size: 14px;
  text-align: center;
  color: var(--text, #e8ecf8);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  outline: none;
}
.thread-icon-input:focus { border-color: rgba(124, 155, 255, 0.55); }

.thread-rename-input {
  width: 200px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text, #e8ecf8);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  outline: none;
}
.thread-rename-input:focus { border-color: rgba(124, 155, 255, 0.55); }
.thread-rename-save {
  padding: 6px 10px;
  font-size: 12px;
  color: #dfe6ff;
  background: rgba(124, 155, 255, 0.18);
  border: 1px solid rgba(124, 155, 255, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.thread-rename-save:hover { background: rgba(124, 155, 255, 0.3); }

.thread-icon-btn {
  position: relative;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s, box-shadow 0.15s;
  filter: grayscale(0.8) opacity(0.65);
  padding: 0;
}
.thread-icon-btn:not(.active):hover {
  filter: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 0 10px 2px rgba(255, 255, 255, 0.12);
}
.thread-icon-btn.active {
  filter: none;
  box-shadow: 0 0 0 1.5px rgba(251, 146, 60, 0.7), 0 0 4px 1px rgba(251, 146, 60, 0.2);
  background: rgba(251, 146, 60, 0.08);
}

/* Per-kind highlight, distinguishing a Coaching Thread / Local Daemon
   thread-row entry from a regular thread (orange, above) and from the
   pinned-shared-workspace chip (teal, .thread-icon-btn.workspace-context-chip
   further down) — three unrelated colors already in use nearby that these
   must not collide with. */
.thread-icon-btn--coaching {
  border: 1px solid rgba(167, 139, 250, 0.35);
}
.thread-icon-btn--coaching.active {
  box-shadow: 0 0 0 1.5px rgba(167, 139, 250, 0.7), 0 0 4px 1px rgba(167, 139, 250, 0.2);
  background: rgba(167, 139, 250, 0.08);
}
.thread-icon-btn--daemon {
  border: 1px solid rgba(250, 204, 21, 0.3);
}
.thread-icon-btn--daemon.active {
  box-shadow: 0 0 0 1.5px rgba(250, 204, 21, 0.7), 0 0 4px 1px rgba(250, 204, 21, 0.2);
  background: rgba(250, 204, 21, 0.08);
}

/* Inline title on the ACTIVE thread only — the icon row is otherwise
   anonymous emojis with hover-only titles. */
.thread-icon-btn.active {
  width: auto;
  padding: 0 8px 0 4px;
  gap: 5px;
  flex-shrink: 0;
}
.thread-icon-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text, #e8ecf8);
  opacity: 0.85;
}

.thread-icon-glyph {
  pointer-events: none;
  line-height: 1;
}

.thread-sweep-btn {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
  border: none;
  background: #1e2030;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  z-index: 5;
}
.thread-icon-btn:hover .thread-sweep-btn,
.thread-icon-btn:focus-within .thread-sweep-btn {
  display: block;
}

/* Touch devices have no hover — keep the delete control visible (slightly
   larger tap target; deletion is still guarded by the confirm dialog). */
@media (hover: none) {
  .thread-sweep-btn {
    display: block;
    width: 16px;
    height: 16px;
    line-height: 16px;
  }
}
.thread-sweep-btn:hover {
  background: #ef4444;
  color: #fff;
}

/* Pin a thread into the Create module's cross-thread build context — a second,
   independent selection from the shift-click grouping selection above. Shown
   on hover, or persistently once pinned. The active thread has no pin (it's
   always included implicitly), so this only appears on other threads. */
.thread-pin-btn {
  display: none;
  position: absolute;
  bottom: -6px;
  left: -6px;
  width: 14px;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
  border: none;
  background: #1e2030;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  z-index: 5;
}
.thread-icon-btn:hover .thread-pin-btn,
.thread-icon-btn:focus-within .thread-pin-btn,
.thread-icon-btn.build-pinned .thread-pin-btn {
  display: block;
}
@media (hover: none) {
  .thread-pin-btn {
    display: block;
    width: 16px;
    height: 16px;
    line-height: 16px;
  }
}
.thread-pin-btn:hover {
  background: rgba(45, 212, 191, 0.85);
  color: #06281f;
}
.thread-icon-btn.build-pinned {
  box-shadow: 0 0 0 1.5px rgba(45, 212, 191, 0.85), 0 0 8px 1px rgba(45, 212, 191, 0.3);
}
.thread-icon-btn.build-pinned .thread-pin-btn {
  background: rgba(45, 212, 191, 0.9);
  color: #06281f;
}

/* Brief confirm state right after pinning -- distinct brighter green from the
   steady teal above, so "just added" reads differently from "already in
   context". Cleared after PIN_CONFIRM_MS (app.js _toggleBuildContextThread). */
.thread-pin-btn.just-pinned {
  display: block;
  background: var(--success);
  color: #06281f;
  animation: thread-pin-confirm-pulse 0.5s ease-out;
}

@keyframes thread-pin-confirm-pulse {
  0% { transform: scale(1.6); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .thread-pin-btn.just-pinned { animation: none; }
}

/* A public thread, or one shared with you, pinned into the active thread's
   context. It sits in the dock row but is NOT a local thread — no rename, no
   sweep, and a dashed edge so it never reads as "one of my threads". */
.thread-icon-btn.workspace-context-chip {
  border: 1px dashed rgba(45, 212, 191, 0.55);
  opacity: 0.92;
}
.thread-icon-btn.workspace-context-chip:hover {
  opacity: 1;
}

/* Gallery-card control that puts a shared thread into thread context. Teal
   once pinned, matching the dock's pinned-thread ring. */
.ghost-button.workspace-context-pin.is-pinned {
  border-color: rgba(45, 212, 191, 0.75);
  color: #2dd4bf;
}

.thread-new-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  padding: 0;
}
.thread-new-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-color);
}
.thread-new-btn svg {
  width: 15px;
  height: 15px;
  display: block;
  pointer-events: none;
}

/* ─── Share icon: reflects whether the active thread is currently shared ──── */
#thread-share-btn.is-shared {
  border-style: solid;
  border-color: rgba(124, 155, 255, 0.55);
  color: #9db4ff;
  background: rgba(124, 155, 255, 0.12);
}
#thread-share-btn.is-shared:hover {
  border-color: rgba(124, 155, 255, 0.8);
  color: #c2d0ff;
}
#thread-share-btn.is-shared.is-shared-public {
  border-color: rgba(139, 213, 202, 0.6);
  color: #8bd5ca;
  background: rgba(139, 213, 202, 0.12);
}
#thread-share-btn.is-shared.is-shared-public:hover {
  border-color: rgba(139, 213, 202, 0.85);
  color: #b3e6dc;
}

/* ─── Public threads dock icon (glows until first viewed) ───────────────────── */
.thread-public-btn {
  border-style: solid;
  border-color: rgba(124, 155, 255, 0.35);
  color: #9db4ff;
}
.thread-public-btn:hover {
  color: #c7d4ff;
  border-color: rgba(124, 155, 255, 0.7);
}
.thread-public-btn.glow {
  color: #cdd9ff;
  border-color: rgba(124, 155, 255, 0.85);
  animation: thread-public-glow 1.8s ease-in-out infinite;
}
@keyframes thread-public-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 155, 255, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(124, 155, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .thread-public-btn.glow { animation: none; box-shadow: 0 0 0 1.5px rgba(124, 155, 255, 0.7); }
}

/* ─── Multi-select + thread grouping ───────────────────────────────────────── */
.thread-icon-btn.selected {
  filter: none;
  box-shadow: 0 0 0 1.5px rgba(124, 155, 255, 0.85), 0 0 8px 1px rgba(124, 155, 255, 0.3);
  background: rgba(124, 155, 255, 0.12);
}
.thread-icon-btn.drop-target,
.thread-group-btn.drop-target {
  box-shadow: 0 0 0 2px rgba(61, 220, 151, 0.85), 0 0 10px 2px rgba(61, 220, 151, 0.3);
}

.thread-group-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.thread-group-btn {
  position: relative;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(124, 155, 255, 0.1);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 1px rgba(124, 155, 255, 0.3);
  padding: 0;
}
.thread-group-btn:hover {
  box-shadow: 0 0 0 1px rgba(124, 155, 255, 0.55), 0 0 10px 2px rgba(124, 155, 255, 0.18);
}
.thread-group-btn.active {
  box-shadow: 0 0 0 1.5px rgba(251, 146, 60, 0.7), 0 0 4px 1px rgba(251, 146, 60, 0.2);
  background: rgba(251, 146, 60, 0.1);
}
.thread-group-btn .thread-group-glyph { pointer-events: none; line-height: 1; }
.thread-group-count {
  position: absolute;
  bottom: -5px;
  right: -5px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 600;
  line-height: 14px;
  text-align: center;
  border-radius: 7px;
  background: #7c9bff;
  color: #0b0b0f;
  pointer-events: none;
}

/* Auto-managed "Public development" folder — derived from publish status, tinted
   green (vs. the blue manual bands) so published threads are distinguishable. */
.thread-group-btn--public {
  background: rgba(61, 220, 151, 0.12);
  box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.4);
}
.thread-group-btn--public:hover {
  box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.65), 0 0 10px 2px rgba(61, 220, 151, 0.2);
}
.thread-group-btn--public .thread-group-count { background: #3ddc97; }

/* Custom tooltip (not the native title attribute) so we control which way it
   opens. The dock sits near the top of the viewport, so a tooltip opening
   upward (the browser's native default here) clips into whatever sits above
   it -- open downward instead, same fix shape as the contributors panel and
   share-icon corner cases. */
.thread-group-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #1f2937;
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 70;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: opacity 0.15s;
}
.thread-group-btn[data-tooltip]:hover::after,
.thread-group-btn[data-tooltip]:focus-visible::after {
  opacity: 1;
}

/* Vertical member list that opens above or below the group icon, whichever
   side has room (decided in JS by _positionGroupList). Rendered fixed and
   body-anchored so it escapes the dock's overflow clipping and can be
   clamped to the viewport edges. */
.thread-group-list {
  position: fixed;
  z-index: 95;
  min-width: 200px;
  max-width: 280px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-3);
  border: 1px solid var(--panel-border, #232334);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.thread-group-list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 4px;
}
.thread-group-list-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #a5a5b5);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-group-disband-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #a5a5b5;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.thread-group-disband-btn:hover { background: #ef4444; color: #fff; }
.thread-group-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text, #f1f1f6);
  font-size: 12px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}
.thread-group-row:hover { background: rgba(255, 255, 255, 0.05); }
.thread-group-row.active {
  background: rgba(251, 146, 60, 0.1);
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.45);
}
.thread-group-row-glyph { flex-shrink: 0; font-size: 14px; line-height: 1; }
.thread-group-row-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-group-row-remove {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #6b7280;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  padding: 0;
}
.thread-group-row:hover .thread-group-row-remove { opacity: 1; }
.thread-group-row-remove:hover { background: #ef4444; color: #fff; }

/* "Group threads?" floating prompt */
.thread-group-prompt {
  position: fixed;
  z-index: 95;
  background: var(--bg-3);
  border: 1px solid rgba(124, 155, 255, 0.4);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 260px;
}
.thread-group-prompt-text {
  font-size: 12px;
  color: var(--text, #f1f1f6);
  font-weight: 600;
}
.thread-group-prompt-sub {
  font-size: 11px;
  color: var(--muted, #a5a5b5);
  margin-top: -4px;
}
.thread-group-prompt-actions { display: flex; gap: 8px; }
.thread-group-prompt-actions button {
  flex: 1;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.thread-group-prompt-yes {
  background: #7c9bff;
  color: #0b0b0f;
  border-color: #7c9bff;
}
.thread-group-prompt-yes:disabled { opacity: 0.4; cursor: not-allowed; }
.thread-group-prompt-no {
  background: var(--bg-3);
  color: var(--text, #f1f1f6);
  border-color: var(--panel-border);
}
.thread-group-prompt-mosaic {
  background: rgba(45, 212, 191, 0.16);
  color: #5eead4;
  border-color: rgba(45, 212, 191, 0.5);
}
.thread-group-prompt-mosaic:hover { background: rgba(45, 212, 191, 0.28); }
.thread-group-prompt-mosaic:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Mosaic thread-view pane ─────────────────────────────────────────────── */
/* A lightweight, read-focused view of one thread's history inside a mosaic
   tile — distinct from the live "chat" module panel. See _renderThreadPaneBody
   in app.js and modules/mosaicPanels.js's decoupled renderer hook. */
.mosaic-thread-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 8px;
  padding: 10px;
}
.mosaic-thread-pane-promote {
  align-self: flex-start;
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #5eead4;
  background: rgba(45, 212, 191, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.45);
  border-radius: 7px;
  cursor: pointer;
}
.mosaic-thread-pane-promote:hover { background: rgba(45, 212, 191, 0.26); }
.mosaic-thread-pane-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mosaic-thread-pane-msg {
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}
.mosaic-thread-pane-msg.role-user {
  background: rgba(124, 155, 255, 0.1);
}
.mosaic-thread-pane-msg-role {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted, #a5a5b5);
  margin-bottom: 2px;
}
.mosaic-thread-pane-msg-text {
  color: var(--text, #e8ecf8);
  white-space: pre-wrap;
  word-break: break-word;
}
.mosaic-thread-pane-empty {
  color: var(--muted, #a5a5b5);
  font-size: 12px;
  padding: 8px 0;
}
.mosaic-thread-pane-compose {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.mosaic-thread-pane-input {
  flex: 1;
  min-width: 0;
  resize: none;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text, #e8ecf8);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  outline: none;
}
.mosaic-thread-pane-input:focus { border-color: rgba(124, 155, 255, 0.55); }
.mosaic-thread-pane-input:disabled { opacity: 0.6; }
.mosaic-thread-pane-send {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #0b0b0f;
  background: #7c9bff;
  border: 1px solid #7c9bff;
  border-radius: 6px;
  cursor: pointer;
}
.mosaic-thread-pane-send:hover:not(:disabled) { background: #93aeff; }
.mosaic-thread-pane-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Onboarding tutorial ─────────────────────────────────────────────────── */
.modal-panel.tutorial-shell {
  width: min(680px, 100%);
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.tutorial-modal { position: relative; width: 100%; }

.tutorial-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted, #a5a5b5);
  font-size: 22px;
  line-height: 1;
}

.tutorial-close:hover,
.tutorial-close:focus-visible {
  border-color: rgba(124, 155, 255, 0.6);
  color: var(--text, #f1f1f6);
}

.tutorial-card {
  min-height: 350px;
  padding: 42px 42px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tutorial-eyebrow {
  margin: 0 0 8px;
  color: var(--accent, #7c9bff) !important;
  font-size: 11px !important;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tutorial-card h2 {
  max-width: 560px;
  margin: 0 0 12px;
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.tutorial-card > p:not(.tutorial-eyebrow) {
  max-width: 580px;
  margin: 0 0 22px;
  color: var(--muted, #a5a5b5);
  font-size: 0.96rem;
  line-height: 1.6;
}

.tutorial-start-list,
.tutorial-module-grid,
.tutorial-share-split { display: grid; gap: 10px; }

.tutorial-start-list,
.tutorial-share-split { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tutorial-start-list > div,
.tutorial-module,
.tutorial-share-col {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.tutorial-start-list > div { padding: 14px; }

.tutorial-start-list > div > span {
  display: block;
  margin-bottom: 12px;
  color: var(--accent, #7c9bff);
  font: 700 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.tutorial-start-list p,
.tutorial-share-col p {
  margin: 0;
  color: var(--muted, #a5a5b5);
  font-size: 12px;
  line-height: 1.45;
}

.tutorial-start-list strong,
.tutorial-share-label {
  display: block;
  margin-bottom: 4px;
  color: var(--text, #f1f1f6);
  font-size: 13px;
}

.tutorial-module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tutorial-module {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.tutorial-module-glyph {
  width: 40px;
  flex: 0 0 40px;
  color: var(--accent, #7c9bff);
  font: 650 12px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: center;
}

.tutorial-module-name,
.tutorial-module-desc { display: block; }

.tutorial-module-name {
  margin-bottom: 2px;
  color: var(--text, #f1f1f6);
  font-size: 13px;
  font-weight: 650;
}

.tutorial-module-desc {
  color: var(--muted, #a5a5b5);
  font-size: 11px;
  line-height: 1.4;
}

.tutorial-share-col { padding: 16px; }

.tutorial-share-col.private {
  border-color: rgba(124, 155, 255, 0.4);
  background: rgba(124, 155, 255, 0.07);
}

.tutorial-footer {
  min-height: 78px;
  padding: 16px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 7, 14, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.tutorial-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted, #a5a5b5);
  font-size: 11px;
  white-space: nowrap;
}

.tutorial-dots { display: flex; gap: 6px; }

.tutorial-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.2s, width 0.2s;
}

.tutorial-dot.active {
  width: 20px;
  border-radius: 4px;
  background: var(--accent, #7c9bff);
}

.tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.tutorial-nav button {
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 12px;
}

.tutorial-nav .tutorial-dismiss {
  padding-inline: 8px;
  background: transparent;
  color: var(--muted, #a5a5b5);
}

.tutorial-nav .tutorial-dismiss:hover,
.tutorial-nav .tutorial-dismiss:focus-visible { color: var(--text, #f1f1f6); }

.tutorial-nav .tutorial-secondary {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #f1f1f6);
}

.tutorial-nav .tutorial-primary { min-width: 92px; }

@media (max-width: 640px) {
  .modal-root { padding: 12px; }

  /* .modal-panel had no max-height/overflow at all -- only .tutorial-shell
     below got this fix. Every other modal (share thread, invite people, any
     modal with enough fields to exceed viewport height) silently overflowed
     .modal-root with no way to scroll to its own Cancel/Save buttons.
     Reported directly from a mobile screenshot of the share-thread modal. */
  .modal-panel {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .modal-panel.tutorial-shell {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .tutorial-card {
    min-height: 0;
    padding: 54px 20px 24px;
  }

  .tutorial-card > p:not(.tutorial-eyebrow) {
    margin-bottom: 18px;
    font-size: 0.9rem;
  }

  .tutorial-start-list,
  .tutorial-module-grid,
  .tutorial-share-split { grid-template-columns: 1fr; }

  .tutorial-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .tutorial-progress { justify-content: space-between; }
  .tutorial-nav { flex-wrap: wrap; }
  .tutorial-nav .tutorial-dismiss { margin-right: auto; }
}

.thread-summary-banner {
  margin: 8px 12px;
  padding: 8px 12px;
  background: rgba(251, 146, 60, 0.06);
  border: 1px solid rgba(251, 146, 60, 0.2);
  border-radius: 6px;
  font-size: 11px;
  color: #a0aec0;
  line-height: 1.5;
}
.thread-summary-banner strong {
  color: #fb923c;
}
.thread-summary-meta {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: #4a5568;
}

/* Thread delete confirmation dialog */
.thread-delete-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.thread-delete-dialog {
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px 24px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.thread-delete-header {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 8px;
}
.thread-delete-body {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 14px;
  line-height: 1.5;
}
.thread-delete-code-options {
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.thread-delete-code-notice {
  font-size: 11px;
  color: #fb923c;
  margin: 0 0 8px;
  font-weight: 500;
}
.thread-delete-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 3px 0;
}
.thread-delete-option input[type="checkbox"] {
  accent-color: #fb923c;
  width: 14px;
  height: 14px;
}
.thread-delete-crystal-options {
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.thread-delete-crystal-notice {
  font-size: 11px;
  color: #7c9bff;
  margin: 0 0 8px;
  font-weight: 500;
}
.thread-delete-crystal-options .thread-delete-option input[type="checkbox"] {
  accent-color: #7c9bff;
}
/* Free-tier gate: an actual clickable CTA (opens the paywall), not a
   dead-end text notice -- matches the click-informs-then-upgrades pattern
   already used for camera/screen share. */
.thread-delete-option-locked {
  width: 100%;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 6px;
  color: #fbbf24;
  font-weight: 600;
  justify-content: center;
}
.thread-delete-option-locked:hover {
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(251, 191, 36, 0.55);
}

/* Voice picker (Converse mode) — pick from the device's other available
   speechSynthesis voices instead of the browser's auto-picked default. */
.voice-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 14px 0;
  max-height: 320px;
  overflow-y: auto;
}
.voice-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: #10131a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 9px 12px;
  color: #d6dbff;
  font-size: 13px;
  cursor: pointer;
}
.voice-picker-row:hover {
  border-color: rgba(124, 155, 255, 0.5);
}
.voice-picker-row.active {
  border-color: #7c9bff;
  background: rgba(124, 155, 255, 0.12);
}
.voice-picker-row-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-picker-row-lang {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-secondary);
}
.voice-picker-row-check {
  flex: 0 0 auto;
  color: #7c9bff;
  font-weight: 700;
}
.voice-picker-row-auto {
  font-weight: 600;
}
.thread-delete-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.thread-delete-cancel-btn {
  background: var(--border-color);
  color: var(--text-primary);
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.thread-delete-cancel-btn:hover { background: #475569; }
.thread-delete-confirm-btn {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.thread-delete-confirm-btn:hover { background: #ef4444; }

/* Agent Console — live HTML/CSS/JS render surface */
/* (layout rules in .agent-console-render and .agent-console-iframe above) */
.agent-console-clear-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
}
.agent-console-clear-btn:hover {
  color: var(--text-primary);
}
.agent-credit-tally {
  display: none;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
  font-family: monospace;
}
.agent-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(5, 8, 22, 0.95);
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 0 0 6px 6px;
  font-size: 11px;
  color: var(--text-secondary);
}
.agent-settings-panel.hidden {
  display: none;
}
.agent-settings-panel label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.agent-settings-panel select {
  background: var(--bg-3);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
}
.agent-console-clear-btn:hover { color: var(--text-primary); }

.agent-settings-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}
.agent-settings-save-btn,
.agent-settings-cancel-btn {
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-family: inherit;
}
.agent-settings-save-btn {
  background: #0f766e;
  color: var(--text-primary);
}
.agent-settings-save-btn:hover {
  background: #14b8a6;
}
.agent-settings-cancel-btn {
  background: transparent;
  color: var(--text-secondary);
}
.agent-settings-cancel-btn:hover {
  background: var(--bg-3);
  color: var(--text-primary);
}

/* Speech bubble CSS removed — companion output simplified to console renders + log only */

/* ── Companion Time-Series Navigation ── */
.agent-timeseries-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 8px;
  min-width: 0;
}

.agent-nav-btn {
  width: 28px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

#agent-render-first {
  width: 42px;
  min-width: 42px;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1;
}

.agent-nav-btn:hover:not(.is-disabled) {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
}

.agent-nav-btn.is-disabled {
  color: var(--text-tertiary);
  border-color: rgba(255, 255, 255, 0.06);
  cursor: default;
  pointer-events: none;
}

.agent-nav-btn.is-glowing {
  /* .agent-panel-header's background is only a 30% black overlay, not a
     solid dark surface -- on light theme's white panel that composites to a
     mid-gray, not dark enough to host a hardcoded near-white text color. */
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.12);
}

.agent-render-delete-btn:not(.is-disabled) {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

.agent-render-delete-btn:hover:not(.is-disabled) {
  border-color: rgba(248, 113, 113, 0.65);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.18);
}

.agent-render-favorite-btn.is-active:not(.is-disabled) {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.08);
}

.agent-render-submosaic-btn.is-active:not(.is-disabled) {
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.62);
  background: rgba(45, 212, 191, 0.1);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.16);
}

.agent-render-zoom-select {
  width: 62px;
  min-width: 62px;
  height: 24px;
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.82);
  color: #99f6e4;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0 4px;
  cursor: pointer;
}

.agent-render-zoom-select:hover,
.agent-render-zoom-select:focus-visible {
  border-color: rgba(94, 234, 212, 0.62);
  outline: none;
}

.agent-render-zoom-select:disabled {
  color: #475569;
  border-color: rgba(255, 255, 255, 0.06);
  cursor: default;
}

.agent-render-favorite-btn:hover:not(.is-disabled) {
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.16);
}

.agent-render-ai-btn:not(.is-disabled) {
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.35);
}

.agent-render-ai-btn.is-busy {
  color: #0f172a;
  background: #5eead4;
  border-color: #5eead4;
  pointer-events: none;
}

.agent-render-scrub-btn:not(.is-disabled) {
  color: #bfdbfe;
  border-color: rgba(147, 197, 253, 0.35);
}

.agent-render-select {
  height: 24px;
  max-width: 112px;
  min-width: 82px;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.76);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 0 20px 0 7px;
  outline: none;
}

.agent-render-select:hover:not(:disabled),
.agent-render-select:focus:not(:disabled) {
  border-color: rgba(94, 234, 212, 0.46);
  color: var(--text-primary);
}

.agent-render-select:disabled {
  color: var(--text-tertiary);
  border-color: rgba(255, 255, 255, 0.06);
  cursor: default;
}

.agent-render-issue-select {
  min-width: 74px;
  max-width: 90px;
}

.agent-render-counter {
  font-size: 11px;
  color: var(--text-tertiary);
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Companion console header: two tiers ──────────────────────────────────
   Tier 1 (always visible, never shrinks): render nav + delete + the "more"
   trigger. Tier 2 (everything else) lives in the overflow popover below.
   The nav used to hold 15 controls in one non-wrapping row, so the delete
   button — last in source order — was the first thing squeezed off-screen
   in a narrow tile. Nothing here may shrink. */
.agent-timeseries-nav,
.agent-console-more {
  flex: 0 0 auto;
}

.agent-panel-header .agent-render-delete-btn {
  flex: 0 0 auto;
  width: 34px;
  margin-left: 2px;
}

/* Primary destructive action — deliberately loud, never ambiguous. */
.agent-panel-header .agent-render-delete-btn:not(.is-disabled) {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.55);
}

.agent-panel-header .agent-render-delete-btn:hover:not(.is-disabled) {
  color: #fff1f2;
  background: rgba(248, 113, 113, 0.24);
  border-color: rgba(248, 113, 113, 0.85);
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.28);
}

.agent-console-more {
  position: relative;
  display: inline-flex;
}

.agent-console-more-btn {
  width: 30px;
  letter-spacing: 1px;
}

.agent-console-more-btn[aria-expanded="true"] {
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.6);
  background: rgba(45, 212, 191, 0.1);
}

/* Fixed, not absolute: the console body sets overflow-y:auto, which would
   clip an absolutely-positioned popover. JS places it under the trigger. */
.agent-console-more-menu {
  position: fixed;
  z-index: 1200;
  width: 244px;
  max-height: min(70vh, 480px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: rgba(5, 8, 22, 0.98);
  border: 1px solid var(--border-color, #2e3a50);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  font-size: 11px;
  color: var(--text-secondary);
}

.agent-console-more-menu[hidden] {
  display: none;
}

.agent-console-more-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-console-more-group + .agent-console-more-group {
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.agent-console-more-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #475569;
}

.agent-console-more-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.agent-console-more-label {
  color: var(--text-primary);
  line-height: 1.3;
}

.agent-console-more-row:has(.is-disabled) .agent-console-more-label,
.agent-console-more-row:has(:disabled) .agent-console-more-label {
  color: #475569;
}

.agent-console-more-row > .agent-nav-btn,
.agent-console-more-row > .agent-render-select,
.agent-console-more-row > .agent-render-zoom-select,
.agent-console-more-row > .agent-console-clear-btn,
.agent-console-more-row > .companion-auto-layout-pill {
  flex: 0 0 auto;
}

.agent-console-more-foot {
  display: flex;
  justify-content: flex-end;
  min-height: 0;
}

.agent-console-more-foot:empty,
.agent-console-more-foot .agent-credit-tally:empty {
  display: none;
}

/* Agent approval popup */
.agent-approval-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 14, 0.78);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.agent-approval-card {
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  color: var(--text-primary);
}
.agent-approval-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
  color: #f97316;
}
.agent-approval-field {
  margin-bottom: 10px;
}
.agent-approval-field label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.agent-approval-field .value {
  font-size: 13px;
  color: var(--text-primary);
}
.agent-expertise-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.agent-expertise-pill {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.agent-approval-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.agent-approval-actions button {
  flex: 1;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.agent-approve-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}
.agent-edit-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}
.agent-cancel-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid #333 !important;
}

/* Companion carousel strip */
.companion-carousel {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2, #1a1a1a);
  border-top: 1px solid var(--border, #333);
  min-height: 96px;
  max-height: 96px;
  scrollbar-width: none;
}
.companion-carousel::-webkit-scrollbar { display: none; }

.companion-card {
  flex: 0 0 80px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--surface-3, #222);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.companion-card.active { border-color: var(--accent, #7c6fff); }
.companion-card__thumb {
  width: 56px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-4, #2a2a2a);
}
.companion-card__name {
  font-size: 9px;
  color: var(--text-muted, #888);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 72px;
}
.companion-card__pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #7c6fff);
  animation: pulse 1.2s infinite;
}
@keyframes skg-badge-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.companion-carousel--empty {
  display: none;
}

.agent-thread-attachment-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 999px;
  color: #7dd3fc;
  background: rgba(14, 116, 144, 0.16);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.agent-thread-attachment-badge.hidden {
  display: none;
}

.agent-active-display.is-thread-attached .agent-compact-actions {
  display: none;
}

.agent-active-display.is-thread-attached #agent-avatar,
.agent-active-display.is-thread-attached #agent-name {
  cursor: default !important;
}

/* Companion detail panel — docked */
.companion-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60vh;
  background: var(--surface-1, #111);
  border-top: 1px solid var(--border, #333);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.companion-panel.open { transform: translateY(0); }

.companion-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #333);
  flex-shrink: 0;
}
.companion-panel__header h3 { margin: 0; font-size: 14px; }
.companion-panel__actions { display: flex; gap: 8px; }
.companion-panel__body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.companion-panel-frame {
  width: 100%;
  min-height: 320px;
  flex: 1;
  border: 0;
  background: transparent;
  display: block;
}

/* History scrubber */
.render-history-scrubber {
  display: flex;
  flex-direction: row;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, #333);
  scrollbar-width: none;
}
.render-history-scrubber::-webkit-scrollbar { display: none; }
.render-history-thumb {
  flex: 0 0 48px;
  height: 40px;
  border-radius: 4px;
  background: var(--surface-3, #222);
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  object-fit: cover;
}
.render-history-thumb.current { border-color: var(--accent, #7c6fff); }

/* Pop-out window */
.companion-popout {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 480px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 80px);
  background: var(--surface-1, #111);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  resize: both;
  overflow: hidden;
  z-index: 300;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.companion-popout-drag-handle {
  cursor: grab;
  padding: 10px 14px;
  background: var(--surface-2, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, #333);
}
.companion-popout-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }

/* Secondary column tab visibility - only the active panel renders */
#secondary-column #code-panel,
#secondary-column #output-panel,
#secondary-column #agents-panel {
  display: none;
}
#secondary-column #code-panel.is-secondary-active,
#secondary-column #output-panel.is-secondary-active,
#secondary-column #agents-panel.is-secondary-active {
  display: flex !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mosaic workspace  (feature-flagged; replaces #workspace on wide viewports)
   ═══════════════════════════════════════════════════════════════════════════ */

.mosaic-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  /* 64px top bar + 36px persistent thread dock (moved out of #chat-panel). */
  height: calc(100vh - 100px);
  min-height: 0;
}
/* Respect [hidden] regardless of mosaic state — the base class sets
   display:flex which wins over the UA stylesheet's [hidden] rule. */
#mosaic-workspace[hidden] { display: none !important; }

/* Panels docked inside mosaic tile bodies must always be visible.
   mobile.css and tablet.css hide ".panel:not(.is-mobile-primary)" with
   !important at specificity 0,3,0. Using the ID #mosaic-host gives us
   specificity 1,2,0 which beats any class-only rule even with !important. */
#mosaic-host [data-panel-host] > .panel {
  display: flex !important;
  min-height: 0 !important;
}

.mosaic-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.mosaic-host {
  flex: 1;
  display: flex;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.mosaic-host:empty::before {
  content: 'Pick a module to start';
  margin: auto;
  color: var(--muted);
  font-size: 14px;
}

.mosaic-graveyard { display: none !important; }

/* ── Mosaic flex split containers ────────────────────────────────────────── */

.mosaic-split {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.mosaic-split.row { flex-direction: row; }
.mosaic-split.col { flex-direction: column; }

.mosaic-tile {
  flex: 1 1 0;
  min-width: 120px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

/* ── Tile header ─────────────────────────────────────────────────────────── */

.mosaic-tile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  flex-shrink: 0;
}

.mosaic-drag-handle {
  cursor: grab;
  color: var(--muted);
  padding: 2px 4px;
  font-family: ui-monospace, monospace;
  letter-spacing: 1px;
  touch-action: none;
}

.mosaic-drag-handle:active { cursor: grabbing; }

.mosaic-tile-title {
  flex: 1;
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  font-family: ui-monospace, monospace;
}

.mosaic-tile-actions {
  display: inline-flex;
  gap: 4px;
}

.mosaic-tile-collapse,
.mosaic-tile-popout,
.mosaic-tile-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.mosaic-tile-collapse:hover,
.mosaic-tile-popout:hover,
.mosaic-tile-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* ── Collapsed tile ──────────────────────────────────────────────────────────
   Folded down to its header bar; the sibling pane takes the freed space. The
   flex value has to beat the inline `flex: <ratio> 1 0` that _buildSplit writes
   for the split ratio, hence !important. */
.mosaic-split > .mosaic-tile.is-collapsed,
#mosaic-host > .mosaic-tile.is-collapsed {
  flex: 0 0 auto !important;
  min-width: 0;
  min-height: 0;
}

.mosaic-tile.is-collapsed > .mosaic-tile-body { display: none; }

/* Split ratios are grow factors that sum to 1, so the surviving sibling would
   otherwise claim only its share (0.27, 0.5 …) of the freed space and leave the
   rest blank. Next to a collapsed pane it takes all of it. */
.mosaic-split:has(> .mosaic-tile.is-collapsed) > *:not(.mosaic-splitter):not(.is-collapsed) {
  flex-grow: 1 !important;
}

/* Side-by-side splits collapse to a narrow gutter — the title text would set a
   wide floor, so only the controls remain. Stacked splits keep the full header. */
.mosaic-split.row > .mosaic-tile.is-collapsed .mosaic-tile-title,
.mosaic-split.row > .mosaic-tile.is-collapsed .mosaic-drag-handle {
  display: none;
}

/* Nothing to resize against a collapsed pane (the drag is disabled in JS). */
.mosaic-split:has(> .mosaic-tile.is-collapsed) > .mosaic-splitter {
  cursor: default;
  pointer-events: none;
  opacity: 0.4;
}

.mosaic-tile-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mosaic-tile-body > * { flex: 1; min-height: 0; }

/* Converse tile idle placeholder (see mosaicView.js _buildTile): shown by
   default via .voice-panel-empty's own display:flex. #conversation-overlay
   itself cycles hidden/visible for transient companion-speech toasts even
   while idle, so hiding on body.conversation-mode-active — toggled only by
   the actual Start/End Converse action (app.js) — is the reliable signal
   that a session is live, not just that a toast is mid-fade. */
body.conversation-mode-active .mosaic-tile[data-tile-module="converse"] .mosaic-converse-empty {
  display: none;
}

.agents-panel.is-floating {
  position: fixed;
  inset: auto;
  width: 480px;
  height: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  bottom: 24px;
  right: 24px;
  background: rgba(var(--overlay-tint), 0.94);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  z-index: 13000;
  display: flex;
  flex-direction: column;
  flex: unset;
}

.agents-panel.is-floating .agents-panel-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  cursor: move;
  user-select: none;
}

.agents-panel.is-floating .agents-panel-float-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}

.agents-panel.is-floating .agents-panel-float-close:hover {
  color: var(--text);
}

.mosaic-popout-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
  user-select: none;
}

/* ── Splitters ───────────────────────────────────────────────────────────── */

.mosaic-splitter {
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.15s;
  z-index: 5;
  flex-shrink: 0;
  /* Pointer-driven drag (mosaicBoot.js) preventDefaults on pointerdown, but
     iOS Safari can still start its own pan/scroll gesture from a touch on a
     6px target before that runs. touch-action: none stops the browser from
     ever claiming the gesture. */
  touch-action: none;
}

.mosaic-splitter.row {
  width: 6px;
  cursor: col-resize;
}

.mosaic-splitter.col {
  height: 6px;
  cursor: row-resize;
}

.mosaic-splitter:hover,
.mosaic-splitter.dragging {
  background: rgba(96, 165, 250, 0.4);
}

/* ── Toolbar chips ───────────────────────────────────────────────────────── */

.mosaic-chip {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.mosaic-chip:hover { background: rgba(255, 255, 255, 0.04); }

.mosaic-chip.is-active {
  background: rgba(96, 165, 250, 0.15);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.4);
}

.mosaic-chip.is-attention,
.mosaic-chip.has-console-update {
  border-color: rgba(34, 211, 238, 0.72);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.08));
  color: #f8feff;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.16), 0 0 18px rgba(34, 211, 238, 0.18);
}

.mosaic-chip.is-attention {
  animation: mosaic-chip-attention 1.4s ease-in-out infinite;
}

.mosaic-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mosaic-chip-reset {
  font-size: 11px;
  color: var(--muted);
  font-family: inherit;
}

/* ── Layouts preset switcher ─────────────────────────────────────────────── */
.mosaic-layouts { display: inline-flex; }
.mosaic-layouts-caret { font-size: 9px; opacity: 0.7; margin-left: 2px; }
/* Positioned against .mosaic-toolbar (position:relative, above), not this
   button: on tablet the toolbar wraps and the button itself can land on a
   left-starting second row, which made `right: 0` measure off that near-left
   position and push the menu off-screen. Anchoring to the full-width toolbar
   keeps `right: 0` meaning "flush with the toolbar's right edge" regardless
   of which row the button wraps to. */
.mosaic-layouts-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10000;
  min-width: 230px;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mosaic-layouts-menu[hidden] { display: none; }
.mosaic-layouts-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.mosaic-layouts-item:hover { background: rgba(255, 255, 255, 0.06); }
.mosaic-layouts-item.is-active { background: rgba(96, 165, 250, 0.15); color: #fff; }
.mosaic-layouts-item-label { flex: 1 1 auto; font-weight: 600; }
.mosaic-layouts-item-hint { flex-basis: 100%; font-size: 11px; color: var(--muted); font-weight: 400; }
.mosaic-layouts-sep { height: 1px; background: var(--panel-border); margin: 5px 2px; }
.mosaic-layouts-save { color: rgba(96, 165, 250, 0.95); font-weight: 600; }
.mosaic-layouts-del {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
  cursor: pointer;
}
.mosaic-layouts-del:hover { color: #f87171; background: rgba(248, 113, 113, 0.12); }

@keyframes mosaic-chip-attention {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

/* ── Drag-to-split ghost + drop overlays ─────────────────────────────────── */

.mosaic-ghost {
  position: fixed;
  z-index: 9999;
  background: rgba(96, 165, 250, 0.85);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  font-family: ui-monospace, monospace;
}

.mosaic-drop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(96, 165, 250, 0.18);
  border: 2px dashed rgba(96, 165, 250, 0.7);
  border-radius: 8px;
  z-index: 1000;
}

.mosaic-drop-overlay[data-side="left"]   { right: 50%; }
.mosaic-drop-overlay[data-side="right"]  { left: 50%;  }
.mosaic-drop-overlay[data-side="top"]    { bottom: 50%; }
.mosaic-drop-overlay[data-side="bottom"] { top: 50%; }

/* ─── Converse docked mode ──────────────────────────────────────────────── */
/* Use !important on geometry properties so inline styles set by the
   floating-mode JS (width/height/inset) cannot win, regardless of timing. */
#conversation-overlay.is-docked {
  /* relative (not static) so the compact docked-mode controls strip can
     position itself absolutely inside the overlay rather than escaping to
     an outer positioned ancestor. */
  position: relative !important;
  inset: unset !important;
  flex: 1 1 0;
  min-width: 0 !important;
  /* Enable cqw queries so the cube/spectrum/text can scale with the tile width,
     mirroring the floating-mode approach (which already uses container-type). */
  container-type: inline-size;
  min-height: 0 !important;
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  transform: none !important;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  resize: none !important;
  overflow: hidden;
  z-index: auto !important;
  opacity: 1 !important;
  padding: 0 !important;
}
/* Docked mode keeps a compact controls strip in the corner so the user can
   pop to Picture-in-Picture or end the conversation without leaving the
   mosaic tile. The drag handle and title belong to the mosaic tile chrome,
   not here — hide them. The compact-mode toggle and minimize buttons don't
   apply when docked. */
#conversation-overlay.is-docked .conversation-overlay-header {
  display: flex;
  position: absolute;
  top: 4px;
  right: 4px;
  left: auto;
  width: auto;
  padding: 2px 4px;
  background: rgba(var(--overlay-tint), 0.55);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  z-index: 2;
  gap: 2px;
  pointer-events: auto;
  cursor: default;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#conversation-overlay.is-docked .conv-overlay-handle,
#conversation-overlay.is-docked .conv-overlay-title,
#conversation-overlay.is-docked #conv-mode-toggle,
#conversation-overlay.is-docked #conv-minimize-btn {
  display: none;
}
/* Previously hidden outside docked mode on the theory that the top-bar 🎧
   toggle was always reachable instead — false in the overlay's own default
   (non-docked) state: that overlay covers the FULL viewport (mobile always,
   desktop whenever not floating/popped), so the top bar sits behind it,
   unreachable, for the entire conversation. Reported live: no way to end a
   call from Converse itself outside the top menu bar. Always show it; a
   redundant end button next to the top-bar toggle on desktop floating mode
   (where the top bar IS visible) costs far less than an unreachable one. */
/* Inner container: fill the tile body completely. */
#conversation-overlay.is-docked .conversation-overlay-inner {
  flex: 1 1 0;
  min-height: 0;
  max-width: 100%;
  max-height: none !important;
  width: 100%;
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow-y: auto;
  text-align: center;
}

/* Docked tiles can be short, so compact the conversational cube + spectrum
   (mirroring the floating-mode caps) and let the live caption + media toolbar
   (attach / camera / screen) stay in view instead of being pushed off. Docked
   tiles have no container-type, so use fixed px instead of cqw — and keep
   --cube-half at exactly half the scene width so the 3D faces don't extrude
   past the shrunken cube (the var defaults to 200px, sized for the 400px
   fullscreen scene). */
/* Avatar + spectrum + role are fixed-size; the caption flexes (see below). */
#conversation-overlay.is-docked .conv-3d-scene,
#conversation-overlay.is-docked .conversation-spectrum,
#conversation-overlay.is-docked .conv-media-previews,
#conversation-overlay.is-docked .conversation-overlay-role {
  flex: 0 0 auto;
}
#conversation-overlay.is-docked .conv-3d-scene {
  /* Scale with the tile width (cqw resolves against the is-docked container).
      --cube-half is exactly half the scene width so 3D faces stay flush.
      Clamp keeps it readable on both narrow sidebar tiles and wide full tiles. */
  --conv-scene-size: min(100%, clamp(180px, 82cqw, 420px));
  width: var(--conv-scene-size) !important;
  margin: 0 auto 4px !important;
  --cube-half: calc(var(--conv-scene-size) / 2);
}
#conversation-overlay.is-docked .conv-persona-label {
  margin-top: 4px;
}
#conversation-overlay.is-docked .conversation-spectrum {
  height: clamp(40px, 8cqw, 120px) !important;
  margin-bottom: 6px !important;
}
/* Caption is the only flexible region: it absorbs leftover height and scrolls
   internally, so the avatar above and the toolbar below always stay in view —
   in tall tiles and short ones alike. */
#conversation-overlay.is-docked .conversation-overlay-text {
  font-size: clamp(14px, 1.9cqw, 21px) !important;
  line-height: 1.35;
  flex: 1 1 auto;
  min-height: 0;
  max-width: min(72ch, 92%);
  padding: 0 8px;
  margin: 0 auto;
  overflow-y: auto;
  align-self: stretch;
}
/* The inner column centers its children, which would shrink the toolbar to its
   content width and let flex-wrap stack the buttons into a tall, clipped
   column. Stretch it to full width so the controls sit in a single row. */
#conversation-overlay.is-docked .conversation-media-toolbar {
  flex: 0 0 auto;
  align-self: stretch;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
#conversation-overlay.is-docked .conversation-media-btn {
  padding: clamp(6px, 1cqw, 12px) clamp(10px, 2cqw, 22px);
  font-size: clamp(12px, 1.6cqw, 18px);
}

/* ─── Converse docked mode: Default Mode variant ─────────────────────────
   Originally appended straight into #chat-panel (a shared flex column also
   holding the header, thread, composer, and "next prompts" chips) -- NOT an
   exclusive mosaic tile the way .is-docked's own flex:1 1 0 /
   width:100%!important / height:auto!important sizing assumes. That sizing
   made the overlay grow to absorb ALL remaining flex space as one more
   sibling in that shared column, instead of coexisting with them at a fixed
   size -- rendering as an oversized, blank region below the composer,
   reported live as a "black box" (it isn't painted black; it's an empty
   region -- .is-docked's own background:transparent!important above -- over
   the app's own near-black page background showing through).

   Fixing the black box this way (a fixed-height, non-growing sibling) traded
   it for the SAME bug the Companion dock and thread-access row had: a
   flex:0 0 auto sibling still eats its height straight out of #chat-messages'
   flex:1 share, shrinking the actual chat thread every time Converse was
   docked. restoreToInitialParent() (app.js) now appends this overlay into
   #default-mode-floating-modules instead of #chat-panel -- the same
   position:absolute floating wrapper the Companion dock and thread-access
   row float in (see that wrapper's own doc comment above) -- so docking
   Converse no longer touches the thread's height either. `!important` stays
   on flex/width/height below because `.is-docked` above declares the
   properties this overrides with `!important` too; without matching it here
   the cascade falls back to `.is-docked`'s own values at equal specificity
   order. Applied alongside (not instead of) .is-docked, so every .is-docked
   descendant rule above (header, inner, 3d-scene, spectrum, caption, media
   toolbar) still applies unchanged -- only the OUTER container's own sizing
   differs here. */
#conversation-overlay.is-docked.is-docked-default-mode {
  flex: 0 0 auto !important;
  width: 100% !important;
  height: 360px !important;
}

/* ─── Mosaic: tablet + desktop visibility (≥768 px) ────────────────────── */
@media (min-width: 768px) {
  body.mosaic-enabled #workspace { display: none !important; }
  body.mosaic-enabled #mosaic-workspace { display: flex !important; }
  /* #mosaic-workspace is a sibling of #root in the DOM. Without this, #root
     keeps height:100% and pushes the mosaic below the fold. Make body a flex
     column so #root collapses to its topbar and mosaic fills the rest. Other
     body-level siblings (modals, side panel, perf HUD) are position:fixed so
     they don't enter the flex layout. */
  body.mosaic-enabled { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
  body.mosaic-enabled > #root { flex: 0 0 auto; height: auto; }
  body.mosaic-enabled > #mosaic-workspace { flex: 1 1 0; height: auto; min-height: 0; }

  /* Keep [hidden] respected even when mosaic is active.
     The .studio-shell variant is required because tablet.css / mobile.css set
     `#workspace.studio-shell { display: grid !important }` at the same
     specificity (1,2,1) and — being loaded later — win the cascade. Adding
     `.studio-shell[hidden]` bumps us to 1,3,1, beating the studio-shell rule. */
  body.mosaic-enabled #workspace[hidden],
  body.mosaic-enabled #workspace.studio-shell[hidden] {
    display: none !important;
  }

  /* Belt-and-suspenders: even if some other rule manages to keep #workspace
     in the layout, the leftover legacy nav bars (and the studio-sidebar)
     inside it must never appear next to the mosaic toolbar. Targeting the
     IDs with mosaic-enabled gives 1,1,1 + !important, beating every
     mobile.css / tablet.css positioning rule. */
  body.mosaic-enabled #workspace-tab-bar,
  body.mosaic-enabled #secondary-tab-bar,
  body.mosaic-enabled #studio-sidebar,
  body.mosaic-enabled #studio-sidebar-open,
  body.mosaic-enabled #studio-support-dock {
    display: none !important;
  }

  /* Companion console fills its full tile in mosaic mode.
     The compact-bar and note prompt are redundant because the companion
     renders its full interface (avatar, controls, IDLE bar) inside the
     iframe. Without this, adding a second tile to the same column (e.g.
     Converse) halves the tile height while the compact-bar + prompt still
     consume ~75 px of fixed vertical space, visibly shrinking the console. */
  body.mosaic-enabled .agent-compact-prompt {
    display: none !important;
  }

  /* Clip overflow so flex-height constraints propagate correctly through
     the #agent-panel → .agent-personality-section → .agent-console-render
     chain. The tile body already clips visually (overflow:hidden); this
     ensures layout calculations agree with the visual boundary. */
  body.mosaic-enabled #agent-panel {
    overflow: hidden;
  }
}
/* Below 768 px: phones always get the legacy workspace layout. If mosaic was
   activated on a wider viewport earlier (leaving body.mosaic-enabled and
   #workspace[hidden] behind), force the workspace visible here so the user
   doesn't end up with both #workspace and #mosaic-workspace hidden (the
   "phone blank screen" failure mode). */
@media (max-width: 767px) {
  body.mosaic-enabled #mosaic-workspace { display: none !important; }
  body.mosaic-enabled #workspace,
  body.mosaic-enabled #workspace[hidden],
  body.mosaic-enabled #workspace.studio-shell,
  body.mosaic-enabled #workspace.studio-shell[hidden] {
    display: flex !important;
    flex-direction: column !important;
  }
}

/* ─── Mosaic: compact styles for tablet widths (768 – 1023 px) ──────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  .mosaic-workspace { gap: 8px; padding: 8px; }
  .mosaic-toolbar   { flex-wrap: wrap; gap: 4px; padding: 6px 8px; }
  /* Was font-size:0.75rem/padding:3px 8px — shrank chips to ~22px tall,
     tuned for saving space, not for the touch input tablets actually use.
     See the touch-target block below for the fix (measured live at 820px). */
  .mosaic-chip      { font-size: 0.78rem; padding: 8px 10px; }
  .mosaic-tile-header { padding: 4px 8px; }

  /* On tablet/mobile #top-bar is position:fixed (set by mobile.css/tablet.css)
     which removes it from flow, collapsing #root to 0 height and letting
     mosaic-workspace start behind the topbar.
     Restore it to in-flow when mosaic is active so #root regains its natural
     height and the body flex layout pushes mosaic-workspace below the bar.
     Specificity must exceed mobile.css "body[data-mobile] #top-bar" (0,2,0),
     so we include both the class and the data attribute. */
  body.mosaic-enabled[data-mobile="true"] #top-bar,
  body.mosaic-enabled[data-device="tablet"] #top-bar {
    position: relative !important;
    width: 100%;
    box-sizing: border-box;
  }
}

/* ─── Mosaic: touch targets across both tablet orientations (768 – 1365.98px,
   matches utils/mobileDetect.js's tablet range) ──────────────────────────
   Mosaic is the default workspace for tablet+ width (mosaicBoot.js
   _isMosaicOn), but its tile chrome — close/pop-out/drag-handle buttons and
   the resize splitters — had no touch-specific sizing anywhere: measured
   live at 820px, tile buttons rendered at 17-19px and splitters at 6px. */
@media (min-width: 768px) and (max-width: 1365.98px) {
  .mosaic-tile-popout,
  .mosaic-tile-close {
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
  }

  .mosaic-drag-handle {
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mosaic-layouts-btn {
    padding: 8px 10px;
  }

  /* Delete-custom-layout (×) — measured live at 17x15px inside a 31px-tall
     row after saving a custom layout (built-in layouts are taller because
     their hint text wraps to a second line, which masked this). */
  .mosaic-layouts-item {
    min-height: 44px;
  }

  .mosaic-layouts-del {
    min-width: 32px;
    min-height: 32px;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Splitters stay visually thin (6px, unchanged) but gain an invisible hit
     area via ::before — a finger doesn't need pixel precision to grab a
     resize handle. The pseudo-element is part of the splitter's own hit
     testing (pointerdown still targets .mosaic-splitter, see mosaicBoot.js),
     so the existing drag handler needs no changes. */
  .mosaic-splitter {
    position: relative;
  }

  .mosaic-splitter.row::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -8px;
    right: -8px;
  }

  .mosaic-splitter.col::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -8px;
    bottom: -8px;
  }
}

/* ─── Default Mode: single-column chat-first shell ──────────────────────
   Scaffold (Task 3 of the 2026-09-05 Default Mode plan) — mirrors the
   body.mosaic-enabled visibility block above. modules/defaultModeShell.js
   re-parents #chat-panel into #default-mode-chat-host and toggles this class;
   never active at the same time as body.mosaic-enabled (the module refuses
   to mount while that class is present). */
body.default-mode-enabled #workspace { display: none !important; }
body.default-mode-enabled #mosaic-workspace { display: none !important; }
body.default-mode-enabled #default-mode-shell { display: flex !important; }

body.default-mode-enabled { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
body.default-mode-enabled > #root { flex: 0 0 auto; height: auto; }
body.default-mode-enabled > #default-mode-shell { flex: 1 1 0; height: auto; min-height: 0; }

/* Keep [hidden] respected even when Default Mode is active — same
   .studio-shell specificity note as the mosaic block above applies here. */
body.default-mode-enabled #workspace[hidden],
body.default-mode-enabled #workspace.studio-shell[hidden] {
  display: none !important;
}

/* #default-mode-shell is a persistent sibling of #root (see the flex rules
   above), so a route change that swaps #root's own children -- Shared
   Threads, Public Research, Account -- does nothing to it on its own: the
   whole Default Mode shell, companion dock included, kept rendering full-
   height on top of those pages (reported live, 2026-09-06). updateRouteView()
   (app.js) now toggles .hidden on it the same way it already does for
   #workspace/#thread-dock; this is the matching override so that class wins
   over the unconditional `display: flex !important` two rules up. */
body.default-mode-enabled #default-mode-shell.hidden {
  display: none !important;
}

.default-mode-shell {
  display: none;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  position: relative; /* anchors .default-mode-floating-modules below */
}

.default-mode-chat-host {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(72ch, 92%);
  margin: 0 auto;
}

/* #chat-panel keeps its own .panel styling; only stretch it to fill the new
   single-column host instead of the two-pane legacy #workspace grid.
   position:relative anchors .default-mode-talk-btn.is-collapsed-pill below. */
.default-mode-chat-host #chat-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
}

/* ─── Default Mode: empty-state Talk button + "+" toolbar cluster (Task 4) ──
   index.html's #default-mode-talk-btn and .chat-input-plus-cluster wrapper
   exist in the static markup for every shell, but are only ever visible/
   styled here under body.default-mode-enabled — Developer Mode and Mosaic
   see a display:none button and a plain unstyled wrapper div, i.e. the exact
   same toolbar they render today. */
.default-mode-talk-btn {
  display: none;
}
body.default-mode-enabled .default-mode-talk-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0 0 8px;
  padding: 12px 16px;
  border: 1px solid rgba(124, 155, 255, 0.35);
  border-radius: 10px;
  background: rgba(124, 155, 255, 0.14);
  color: var(--text-primary, #e2e8f0);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  /* Only properties that actually change value somewhere in this component's
     lifecycle are listed: `background` for the :hover rule just below, and
     `padding`/`font-size`/`border-radius`/`box-shadow` for the expanded <->
     .is-collapsed-pill transition handled below. `opacity` and `transform`
     were dead weight — neither ever changes for this button — so they're
     dropped rather than carried forward as no-op transition entries.
     `position` (relative -> absolute) and `width` (100% -> auto) also flip
     between the two states but aren't (and can't usefully be) transitioned:
     `position` isn't an animatable property at all, and animating to `auto`
     isn't interpolable without hardcoding a pixel width the pill doesn't
     otherwise need — both are accepted as an intentional snap rather than
     chasing a full animation for a minor visual-polish fix. */
  transition: background 0.15s, padding 0.2s ease, font-size 0.2s ease,
    border-radius 0.2s ease, box-shadow 0.2s ease;
}
body.default-mode-enabled .default-mode-talk-btn:hover {
  background: rgba(124, 155, 255, 0.22);
}

/* Collapsed state: shrinks to a small floating pill at the top of the thread
   once the first turn has been sent. modules/defaultModeShell.js
   (syncDefaultModeTalkButtonState) toggles this class from the existing
   #chat-messages .message.user DOM signal already used elsewhere in app.js —
   no new sent-turn counter, and the button is never relocated in the DOM.
   `top: 64px` clears #chat-panel's own .panel-header, which renders at 56px
   tall here (12px top padding + 12px bottom padding + ~31px content row +
   1px bottom border — confirmed via getBoundingClientRect in a live browser,
   not just the CSS arithmetic) plus an 8px gap, so the pill sits below the
   header's clearChatButton/threadCrystalIndicator (and, when Mosaic's own
   per-panel controls are present, its Thread-switcher/focus/popout row too)
   instead of on top of them. */
body.default-mode-enabled .default-mode-talk-btn.is-collapsed-pill {
  position: absolute;
  top: 64px;
  right: 8px;
  z-index: 5;
  width: auto;
  margin: 0;
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* "+" cluster: GitHub / attach / mic / camera / screen read as one grouped
   control in Default Mode's slimmer composer instead of five loose icons.
   Purely visual grouping (border + tinted background around the existing
   .chat-tool-btn icons) — no interaction change, no new expand/collapse
   behavior. */
.default-mode-enabled .chat-input-plus-cluster {
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

/* ─── Default Mode: floating modules wrapper ──────────────────────────────
   Common parent for .default-mode-companion-dock and
   .default-mode-thread-access-row below (index.html
   #default-mode-floating-modules). Both used to be flex:0 0 auto siblings of
   #default-mode-chat-host inside .default-mode-shell's fixed-height flex
   column -- the moment either appeared it ate its height straight out of
   #default-mode-chat-host's flex:1 1 0 share, visibly shrinking the chat
   thread every time a companion was adopted or a code/Create affordance
   became available. Taking this wrapper out of the flex column entirely
   (position:absolute, anchored to the shell's own position:relative above)
   and floating it just above the composer means #default-mode-chat-host's
   flex-basis is never affected by whether a module is open -- the thread
   always gets the shell's full height. The tradeoff is the open module now
   overlaps the tail of the scrollable message list instead of shrinking it,
   which is the whole point (see the AskUserQuestion choice this was built
   for: "float as an overlay"). `bottom` tracks the composer's real height
   via --dm-composer-h, a CSS var kept in sync by a ResizeObserver in
   modules/defaultModeShell.js (mountDefaultMode) -- the composer's own
   height isn't fixed (Simple Mode's collapsible controls row, a growing
   textarea), so a hardcoded pixel offset would drift out of sync with it. */
/* row + wrap (not column): the collapsed companion dock and the thread-
   access row both shrink to content width now (see .is-collapsed and
   .default-mode-thread-access-row below), so they share one line by
   default -- a collapsed Talk pill next to a Code/Create pill reads as one
   compact strip instead of two stacked full-width bars. The EXPANDED dock
   still declares width:100%, which alone forces it (and anything after it)
   onto its own line via the wrap, so this doesn't change that layout. */
.default-mode-floating-modules {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--dm-composer-h, 64px);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  /* center, not flex-start: the collapsed companion dock has a fixed 34px
     height (see .is-collapsed below) while the thread-access row's Code/
     Create pills size to their own content (~25-29px) -- top-aligning the
     two left their bottoms visibly out of step on the shared line. */
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: min(72ch, 92%);
  margin: 0 auto;
  padding-bottom: 8px;
  pointer-events: none;
  z-index: 4;
}
.default-mode-floating-modules > * {
  pointer-events: auto;
}

/* ─── Default Mode: inline companion dock (Task 5) ───────────────────────
   #default-mode-companion-dock hosts #agent-personality-section (re-parented
   there by modules/defaultModeShell.js's dockCompanionRenderInline()) — the
   builder form before a companion exists, the compact bar + render after.
   #agent-personality-section's own class already carries `flex:1;
   min-height:0; display:flex; flex-direction:column` (styles.css ~line
   11258) expecting a flex ancestor with a REAL (not just max-) height to
   resolve against — in its original #workspace home that came from
   `#workspace[data-workspace-panel="agent"] #agent-panel { height:100% }`,
   a rule scoped to #workspace and therefore dead here. This block gives the
   dock its own explicit height instead so that existing flex chain
   (.agent-personality-section -> .agent-active-display -> .agent-console-
   render -> .agent-console-frame-stage, all already `flex:1`) resolves the
   same way it does inside the legacy secondary panel. */
.default-mode-companion-dock {
  display: none;
}
body.default-mode-enabled .default-mode-companion-dock:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  height: 360px;
  width: 100%;
  border: 1px solid rgba(124, 155, 255, 0.28);
  border-radius: 10px;
  /* Solid, not the translucent rgba() this had as a flex sibling — floating
     over the message list now, so it needs to actually occlude the text
     scrolled underneath it instead of letting it show through. */
  background: #14192b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: height 0.15s ease;
}
body.default-mode-enabled .default-mode-companion-dock.is-collapsed {
  height: 34px;
}
/* Collapsed: shrink to content width (just the Talk pill + toggle) instead
   of the base rule's width:100%, so .default-mode-floating-modules' row-wrap
   layout can put the thread-access row's Code/Create pills on the same line
   instead of forcing them onto their own row below. Selector matches the
   base rule's specificity plus .is-collapsed so it reliably wins regardless
   of source order. Expanded dock is untouched -- still width:100%, still
   pushes everything after it onto the next line. */
body.default-mode-enabled .default-mode-companion-dock.is-collapsed:not([hidden]) {
  width: auto;
}
/* Header row: the dock's own integrated Talk button on the left, collapse
   toggle on the right. Always present regardless of whether this thread has
   an adopted companion yet (see _syncDefaultModeCompanionDockForThread's
   2026-09-07 correction) -- Simple Mode's ONLY persistent access to voice,
   now that the old always-visible empty-state Talk button was removed
   (#2645) and this dock used to hide outright with no companion adopted. */
.default-mode-companion-dock-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 0;
}
.default-mode-companion-talk-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
  padding: 3px 10px 3px 8px;
  border: 1px solid rgba(124, 155, 255, 0.4);
  border-radius: 999px;
  background: rgba(124, 155, 255, 0.16);
  color: var(--text-primary, #e2e8f0);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s;
}
.default-mode-companion-talk-btn:hover {
  background: rgba(124, 155, 255, 0.28);
}
.default-mode-companion-talk-btn svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}
.default-mode-companion-dock-toggle {
  flex: 0 0 auto;
  /* Circle, not the old 5px-radius near-square: it sits directly beside the
     pill-shaped Talk button (.default-mode-companion-talk-btn, 999px radius)
     in the same compact header, and the shape clash read as visual noise. */
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #e2e8f0);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.default-mode-companion-dock-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}
.default-mode-companion-dock-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 8px 8px;
}
.default-mode-companion-dock.is-collapsed .default-mode-companion-dock-body {
  display: none;
}

/* Thread-access row (see app.js _syncDefaultModeThreadAccessRowForThread):
   same conditional-visibility pattern as .default-mode-companion-dock above,
   just a plain row of pill buttons instead of a docked panel — there is no
   inline content to host, only a jump to the panel that already has it. */
.default-mode-thread-access-row {
  display: none;
}
body.default-mode-enabled .default-mode-thread-access-row:not([hidden]) {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  /* Shrink to the buttons' own content width (was 100%, forcing this row
     onto its own full-width line even for a single Code/Create pill) so it
     can share a line with the collapsed companion dock in the parent's
     row-wrap layout instead of always stacking below it. */
  width: auto;
}
.default-mode-access-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(124, 155, 255, 0.28);
  border-radius: 999px;
  background: rgba(124, 155, 255, 0.05);
  color: var(--text-primary, #e2e8f0);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.default-mode-access-btn:hover {
  background: rgba(124, 155, 255, 0.14);
}
.default-mode-access-btn[hidden] {
  display: none;
}

/* The builder form (textarea + style sliders + actions) can run taller than
   the 360px dock — let it scroll instead of clipping under the base class's
   `overflow: hidden`. Higher specificity (two ids/classes) wins over the
   bare `.agent-personality-section` rule. */
.default-mode-companion-dock-body .agent-personality-section {
  overflow-y: auto;
}
/* The render surface doesn't need the base rule's `margin-top: 6px` (the
   dock body's own padding already separates it from the toggle row). */
.default-mode-companion-dock-body .agent-console-render {
  margin-top: 0;
}

/* Companion console menu-condense (index.html #default-mode-companion-menu-toggle):
   mirrors the render's own already-collapsed .agent-console-more pattern —
   name/status stay on the row, everything else (the action-button row, the
   note-input row) collapses behind one chevron so the render gets the space
   by default. Scoped to the docked context only: Studio Shell/Mosaic's
   companion panel has room to spare and keeps showing everything, unchanged. */
.default-mode-companion-menu-toggle {
  display: none;
}
.default-mode-companion-dock-body .default-mode-companion-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #e2e8f0);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.default-mode-companion-dock-body .default-mode-companion-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}
.default-mode-companion-dock-body #agent-active-display:not(.is-menu-condensed) .default-mode-companion-menu-toggle {
  transform: rotate(180deg);
}
.default-mode-companion-dock-body #agent-active-display.is-menu-condensed .agent-compact-actions,
.default-mode-companion-dock-body #agent-active-display.is-menu-condensed .agent-compact-prompt,
.default-mode-companion-dock-body #agent-active-display.is-menu-condensed .agent-avatar,
.default-mode-companion-dock-body #agent-active-display.is-menu-condensed .agent-compact-info {
  display: none;
}
/* "No information on the row but the chevron" — condensed means condensed:
   the name/avatar/status card collapses away too, not just the action
   buttons, leaving a thin single strip. Expanding restores all of it. */
.default-mode-companion-dock-body #agent-active-display.is-menu-condensed .agent-compact-bar {
  padding: 2px 6px;
  min-height: 0;
  gap: 0;
}

/* Top-bar Simple / Advanced workspace switch (index.html #layoutModeToggleBtn).
   One control (role="switch"): both glyphs stay visible (● Simple / ⊞
   Advanced — the grid glyph mirrors what Advanced/Mosaic actually looks
   like) so the OTHER state is always legible, but only the sliding thumb +
   glyph opacity change — there is nothing here a user can click that isn't
   the single switch itself. Screen-reader text ("Simple"/"Advanced") sits
   next to each glyph via .sr-only (index.html), same pattern as this
   codebase's other icon-only buttons. */
.layout-mode-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: 68px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.layout-mode-switch-option {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  text-align: center;
  font-size: 15px;
  line-height: 20px;
  color: var(--text-secondary, #9aa5b8);
  transition: color 0.15s ease;
  pointer-events: none;
}

.layout-mode-switch:not(.is-advanced) .layout-mode-switch-option[data-mode="simple"],
.layout-mode-switch.is-advanced .layout-mode-switch-option[data-mode="advanced"] {
  color: var(--text-primary, #e2e8f0);
}

.layout-mode-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  border-radius: 999px;
  background: rgba(124, 155, 255, 0.22);
  border: 1px solid rgba(124, 155, 255, 0.7);
  transition: transform 0.18s ease;
}

.layout-mode-switch.is-advanced .layout-mode-switch-thumb {
  transform: translateX(100%);
}

/* Full-viewport cover for the Simple/Advanced reload (app.js
   _reloadForLayoutModeSwitch) — the switch above only gets ~1 frame to
   animate before the tab unloads, so this fills the gap instead of a blank
   flash. Opacity-only, toggled via .is-visible so it fades in before the
   reload actually fires. Reuses the existing @keyframes pulse (companion
   carousel) for the label instead of adding a new one. */
.layout-mode-transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.layout-mode-transition-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.layout-mode-transition-overlay[hidden] {
  display: none;
}

.layout-mode-transition-label {
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--text-secondary, #9aa5b8);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ─── Simple Mode declutter (2026-09-05) ──────────────────────────────────
   Three power-user controls hidden in Simple Mode only — Developer Mode
   (Mosaic/Studio Shell) keeps all of them exactly as-is, unaffected. Plain
   CSS hides (not JS state) so nothing here touches session-persisted
   preferences shared with Developer Mode (e.g. #chatControlsRow's own
   sessionStorage collapse state). */

/* Context mode row (Balanced/Aggressive/Full) + the four creativity-mode
   pills (Auto/Strict/Grounded/Exploratory/Visionary) — a technical control
   sitting directly under Talk, in the primary compose flow. Hides the row's
   own collapse chevron along with it since there's nothing left to toggle. */
body.default-mode-enabled #chatControlsRow {
  display: none !important;
}

/* Top-bar icon buttons meaningful to power users, cryptic dead weight for
   Simple Mode: voice auto-speak toggle, the Converse activity dot, Public
   Research, and the Colony launcher. #conversation-mode-toggle itself
   (the small top-bar icon that starts Converse) is deliberately left alone
   here — it's the ONLY way to start a voice conversation in Simple Mode
   now that .default-mode-talk-btn below is hidden, and it's already
   identical between Simple and Advanced (never added, never removed —
   confirmed live 2026-09-06 after it read as mode-specific). */
body.default-mode-enabled #voice-mode-toggle,
body.default-mode-enabled #conversation-mode-dot,
body.default-mode-enabled #topBarPublicResearchButton,
body.default-mode-enabled #topBarColonyButton {
  display: none !important;
}

/* Large empty-state "Talk" CTA — removed per explicit request (2026-09-06):
   Simple Mode uses the same small top-bar #conversation-mode-toggle icon as
   Advanced Mode to start Converse, not a dedicated full-width button. Covers
   both the button's in-flow empty-state layout and its floating
   .is-collapsed-pill state (that rule sets no `display` of its own, so this
   wins regardless of which state is active). */
body.default-mode-enabled .default-mode-talk-btn {
  display: none !important;
}

/* Thinking-depth selector (x1-x21) next to Send — another power-user knob
   exposed by default. */
body.default-mode-enabled .chat-thinking-depth-control {
  display: none !important;
}

/* ─── Companion render arrival animations ──────────────────────────────── */
@keyframes companionTilePulse {
  0%   { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.55); }
  50%  { box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); }
}

.mosaic-tile.companion-render-arrive {
  animation: companionTilePulse 1.2s ease-out 2;
}

/* Console tile arrival pulse — draws the eye to a freshly-rendered app even when
   the Console tile is already open in the mosaic (see activelySurfaceConsoleTileInMosaic). */
@keyframes consoleTileArrive {
  0%   { box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6); }
  50%  { box-shadow: 0 0 0 5px rgba(96, 165, 250, 0.28); }
  100% { box-shadow: 0 0 0 0 rgba(96, 165, 250, 0); }
}

.mosaic-tile.console-render-arrive {
  animation: consoleTileArrive 1.2s ease-out 2;
}

@keyframes companionIframeFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.companion-iframe-arrive {
  animation: companionIframeFadeIn 400ms ease-out forwards;
}

/* ─── AUTO/MANUAL layout pill ──────────────────────────────────────────── */
.companion-auto-layout-pill {
  font-size: 9px;
  font-family: ui-monospace, 'Fira Code', monospace;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(94, 234, 212, 0.4);
  background: transparent;
  color: #5eead4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.4;
  user-select: none;
}

.companion-auto-layout-pill[aria-pressed="false"] {
  border-color: rgba(107, 114, 128, 0.4);
  color: #6b7280;
}

.companion-auto-layout-pill:hover {
  background: rgba(94, 234, 212, 0.08);
}

/* ── Dev agent console actions (Diff / Push / Merge) ─────────────────────────
   Previously bare <button>s rendering as default OS controls on the dark
   panel; give them a consistent bordered style with hover/active/focus. */
.agent-console-btn {
  appearance: none;
  margin-right: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 7px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.agent-console-btn:last-of-type { margin-right: 0; }

.agent-console-btn:hover {
  background: rgba(14, 165, 233, 0.16);
  border-color: rgba(125, 211, 252, 0.5);
  color: var(--text);
}

.agent-console-btn:active { background: rgba(14, 165, 233, 0.24); }

.agent-console-btn:focus-visible {
  outline: 2px solid rgba(164, 191, 224, 0.7);
  outline-offset: 2px;
}

/* ── Keyboard focus baseline (WCAG 2.4.7) ────────────────────────────────────
   Visible focus ring for interactive elements that don't define their own.
   :where() keeps specificity at zero so component-specific :focus-visible
   rules continue to win. */
:where(a, button, input, select, textarea, summary,
  [tabindex]:not([tabindex="-1"]), [role="button"], [role="tab"],
  [role="link"], [role="menuitem"], [role="switch"], [role="checkbox"]):focus-visible {
  outline: 2px solid rgba(164, 191, 224, 0.7);
  outline-offset: 2px;
}

/* ── Reduced motion (WCAG 2.2.2 / 2.3.3) ─────────────────────────────────────
   Honor the OS "reduce motion" setting: collapse CSS animations/transitions to
   near-instant and stop infinite loops (pulses, spinners, shimmers). The canvas
   visualizers are frozen separately in JS (reducedMotion.js +
   conv-cube.js / spectrumRenderer.js). */
@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;
  }
}



/* ── Earn v1 (first-class topbar button, next to the credit balance) ──── */
.earn-anchor {
  position: relative;
  display: inline-flex;
}

.earn-launcher {
  /* Inherits .credit-badge's pill shape/colors — this block only adds what
     differs: the light-up state and a touch more emphasis since this is a
     call-to-action, not a passive readout. */
  font-weight: 600;
}
.earn-launcher .icon { font-weight: 700; }

.earn-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-color, #4f8cff);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.earn-badge.hidden { display: none; }

/* "Lit up" — a task is offered. Deliberately louder than the numeric badge
   alone: a warm glow + a slow pulse, calm enough not to be an alert, but
   unmistakable at a glance. Respects reduced-motion. */
.earn-launcher.earn-launcher-lit {
  border-color: rgba(250, 204, 21, 0.65);
  color: #fde047;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.25), 0 0 14px rgba(250, 204, 21, 0.35);
  animation: earn-launcher-pulse 2.4s ease-in-out infinite;
}
@keyframes earn-launcher-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.25), 0 0 14px rgba(250, 204, 21, 0.35); }
  50% { box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.45), 0 0 20px rgba(250, 204, 21, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .earn-launcher.earn-launcher-lit { animation: none; }
}

.earn-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 96px));
  overflow-y: auto;
  border: 1px solid var(--border-color, #3a3a44);
  border-radius: 12px;
  background: var(--panel-bg, #17171d);
  color: var(--text-color, #e8e8ee);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  padding: 12px 14px;
}
.earn-panel.hidden { display: none; }
@media (max-width: 480px) {
  .earn-panel { left: auto; right: 0; }
}
.earn-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
}
.earn-panel-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.earn-panel-intro { font-size: 12px; opacity: 0.75; margin: 6px 0 10px; }

.thread-contributors-anchor {
  position: relative;
  display: inline-flex;
}
.thread-contributors-launcher.hidden { display: none; }
.thread-contributors-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  z-index: 60;
  width: min(420px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 96px));
  overflow-y: auto;
  border: 1px solid var(--border-color, #3a3a44);
  border-radius: 12px;
  background: var(--panel-bg, #17171d);
  color: var(--text-color, #e8e8ee);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  padding: 12px 14px;
}
.thread-contributors-panel.hidden { display: none; }
.thread-contributors-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
}
.thread-contributors-panel-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.thread-contributors-table-wrap { margin-top: 10px; }
.thread-contributors-empty { font-size: 12px; opacity: 0.7; padding: 8px 2px; }
.thread-contributors-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.thread-contributors-table th {
  text-align: left;
  font-weight: 600;
  opacity: 0.7;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-color, #3a3a44);
}
.thread-contributors-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-color, #2a2a32);
}
.thread-contributors-table th.num,
.thread-contributors-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Thread presence chip ("who's here") ────────────────────────────────── */
.thread-presence-anchor {
  position: relative;
  display: inline-flex;
}
.thread-presence-launcher.hidden { display: none; }
.thread-presence-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 96px));
  overflow-y: auto;
  border: 1px solid var(--border-color, #3a3a44);
  border-radius: 12px;
  background: var(--panel-bg, #17171d);
  color: var(--text-color, #e8e8ee);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  padding: 12px 14px;
}
.thread-presence-panel.hidden { display: none; }
.thread-presence-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
}
.thread-presence-panel-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.thread-presence-empty { font-size: 12px; opacity: 0.7; padding: 8px 2px; }

.thread-presence-list-wrap { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.thread-presence-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 13px;
}
.thread-presence-row--registered {
  background: rgba(124, 155, 255, 0.1);
  color: var(--text-color, #e8e8ee);
}
.thread-presence-row--anonymous {
  opacity: 0.45;
  font-style: italic;
}
.thread-presence-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-presence-row-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(139, 213, 202, 0.18);
  color: #8bd5ca;
}

.thread-presence-requests-wrap {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.thread-presence-requests-wrap.hidden { display: none; }
.thread-presence-requests-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fbbf24;
  margin-bottom: 6px;
}
.thread-presence-request-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}
.thread-presence-request-handle {
  background: none;
  border: none;
  color: #9db4ff;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline dotted;
}
.thread-presence-request-handle:hover { color: #c2d0ff; }
.thread-presence-request-note {
  font-size: 12px;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-presence-ask-wrap { margin-top: 12px; }
.thread-presence-ask-hint { font-size: 12px; opacity: 0.75; margin: 0; }
.thread-presence-ask-input {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--border-color, #3a3a44);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font: inherit;
  padding: 6px 8px;
  box-sizing: border-box;
}
.thread-presence-ask-btn {
  margin-top: 6px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(124, 155, 255, 0.5);
  background: rgba(124, 155, 255, 0.12);
  color: #9db4ff;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
}
.thread-presence-ask-btn:hover { border-color: rgba(124, 155, 255, 0.8); color: #c2d0ff; }
.thread-presence-ask-btn:disabled { opacity: 0.6; cursor: default; }

.earn-offer-row {
  border: 1px solid var(--border-color, #3a3a44);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.earn-offer-goal { font-size: 13px; line-height: 1.4; }
.earn-offer-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  opacity: 0.85;
}
.earn-chip {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.18);
  color: var(--accent-color, #4f8cff);
  font-weight: 700;
}
.earn-offer-actions { display: flex; gap: 8px; }
.earn-offer-actions button {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #3a3a44);
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.earn-offer-actions .earn-accept {
  background: var(--accent-color, #4f8cff);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.earn-offer-actions button:disabled { opacity: 0.5; cursor: default; }
.earn-offer-active-note { font-size: 11px; opacity: 0.7; align-self: center; }
.earn-empty { font-size: 12px; opacity: 0.7; padding: 8px 2px; }

.earn-profile-form { display: flex; flex-direction: column; gap: 10px; font-size: 12px; }
.earn-profile-form p { margin: 0; }
.earn-profile-form label { display: flex; flex-direction: column; gap: 4px; }
.earn-profile-form input[type="text"],
.earn-profile-form select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #3a3a44);
  background: var(--input-bg, #101015);
  color: inherit;
  font-size: 12px;
}
.earn-consent { flex-direction: row !important; align-items: center; gap: 6px; }
.earn-cash-note { font-size: 11px; opacity: 0.65; }
.earn-save {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent-color, #4f8cff);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.earn-save:disabled { opacity: 0.5; }

.earn-task-card {
  border: 1px solid var(--accent-color, #4f8cff);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.earn-task-card.earn-task-done { opacity: 0.75; border-color: var(--border-color, #3a3a44); }
.earn-task-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.7; }
.earn-task-goal { font-size: 14px; line-height: 1.45; }
.earn-task-counter { font-size: 12px; opacity: 0.75; }
.earn-task-actions { display: flex; gap: 8px; }
.earn-task-actions button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #3a3a44);
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.earn-task-actions .earn-submit {
  background: var(--accent-color, #4f8cff);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.earn-task-actions button:disabled { opacity: 0.5; cursor: default; }

.earn-image-task-form { display: flex; flex-direction: column; gap: 8px; }
.earn-image-slot {
  border: 1px solid var(--border-color, #3a3a44);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.earn-image-slot label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
.earn-image-rationale {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color, #3a3a44);
  background: var(--input-bg, #101015);
  color: inherit;
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  resize: vertical;
  min-height: 40px;
}
.earn-capture-row { display: flex; gap: 8px; }
.earn-capture-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color, #3a3a44);
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.earn-capture-btn:disabled { opacity: 0.5; cursor: default; }
.earn-image-thumb {
  max-width: 100%;
  max-height: 120px;
  border-radius: 6px;
  object-fit: cover;
}

/* ── Per-turn notes (shared/public threads) ─────────────────────────── */
.turn-notes {
  margin-top: 6px;
  font-size: 0.78rem;
}
.turn-notes-toggle {
  background: none;
  border: 1px solid rgba(124, 155, 255, 0.25);
  border-radius: 12px;
  color: #7c9bff;
  font-size: 0.72rem;
  padding: 2px 10px;
  cursor: pointer;
}
.turn-notes-toggle:hover {
  border-color: rgba(124, 155, 255, 0.55);
  color: #a8bfff;
}
.turn-notes-panel {
  margin-top: 6px;
  border-left: 2px solid rgba(124, 155, 255, 0.3);
  padding-left: 10px;
}
.turn-note {
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.turn-note:last-child {
  border-bottom: none;
}
.turn-note-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.7rem;
  opacity: 0.85;
}
.turn-note-author {
  color: #7c9bff;
  font-weight: 600;
  text-decoration: none;
}
.turn-note-author:hover {
  text-decoration: underline;
}
.turn-note-time {
  opacity: 0.6;
}
.turn-note-quarantined {
  color: #f0b357;
  border: 1px solid rgba(240, 179, 87, 0.4);
  border-radius: 8px;
  padding: 0 6px;
  font-size: 0.64rem;
}
.turn-note-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 2px 4px;
}
.turn-note-delete:hover {
  color: #f87171;
}
.turn-note-body {
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}
.turn-note-composer {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: flex-end;
}
.turn-note-input {
  flex: 1;
  resize: vertical;
  min-height: 34px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  padding: 5px 8px;
}
.turn-note-submit {
  background: rgba(124, 155, 255, 0.15);
  border: 1px solid rgba(124, 155, 255, 0.4);
  border-radius: 6px;
  color: #a8bfff;
  font-size: 0.72rem;
  padding: 5px 10px;
  cursor: pointer;
}
.turn-note-submit:disabled {
  opacity: 0.5;
  cursor: default;
}
.turn-note-profile-hint {
  margin-top: 6px;
  font-size: 0.7rem;
  opacity: 0.7;
}

/* ── Thread Context Crystal build indicator ─────────────────────────── */
.crystal-building {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.76rem;
  opacity: 0.75;
}
.crystal-ring {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(124, 155, 255, 0.25);
  border-top-color: #7c9bff;
  border-radius: 50%;
  animation: crystal-spin 0.9s linear infinite;
}
@keyframes crystal-spin {
  to { transform: rotate(360deg); }
}
.crystal-done {
  color: #7c9bff;
}

/* Persistent per-thread indicator (panel-header-actions), toggled via
   [hidden] — only ever shown once a thread actually has a live crystal.
   Doubled-up `.icon-button.crystal-indicator` selector is deliberate: a
   later, higher-in-file `.icon-button { color: ... }` rule (same file, "lift
   the resting contrast" block) otherwise wins the cascade at equal
   specificity and silently overrides the glow color. */
.icon-button.crystal-indicator {
  color: #7c9bff;
  text-shadow: 0 0 6px rgba(124, 155, 255, 0.55);
}
.icon-button.crystal-indicator:hover {
  color: #a8bdff;
  text-shadow: 0 0 9px rgba(124, 155, 255, 0.8);
}

/* Coaching Thread indicator — same row, same [hidden]-toggle pattern as the
   Context Crystal indicator above (only shown once _updateCoachThreadIndicator
   finds thread.kind === 'coaching'). Reuses --accent, matching the existing
   coaching-attention color already used on the camera/screen buttons rather
   than inventing a new one. Doubled-up `.icon-button.coach-indicator`
   selector for the same reason as `.icon-button.crystal-indicator` above: a
   later, higher-in-file `.icon-button { color: ... }` rule at equal
   specificity would otherwise win the cascade and override this. */
.icon-button.coach-indicator {
  color: var(--accent);
}
.icon-button.coach-indicator:hover {
  filter: brightness(1.2);
}

/* Probe and Earn offer cards (Phase 4) */
.probe-card {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  background: rgba(124, 155, 255, 0.05);
}

/* ── Scene record card (live camera/screen scene-record pipeline) ──────── */
.scene-record-card {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin: 8px 0 0 22px;
  background: rgba(124, 155, 255, 0.04);
  font-size: 12px;
}

.scene-record-summary {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-secondary, #9fb3c8);
  user-select: none;
}

.scene-record-body {
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scene-record-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scene-record-text {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.scene-record-thumb {
  max-width: 160px;
  max-height: 120px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  object-fit: cover;
}

.scene-record-objects,
.scene-record-actions {
  color: var(--text-secondary, #9fb3c8);
  line-height: 1.4;
}

/* Coaching recap clip — same shell as .scene-record-card, appended alongside
   it under a voice/coaching turn when maybeGenerateCoachingRecap (server.js)
   has finished assembling one (see _renderCoachingRecapCard in app.js). */
.coaching-recap-card {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin: 8px 0 0 22px;
  background: rgba(124, 155, 255, 0.04);
  font-size: 12px;
}

.coaching-recap-summary {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-secondary, #9fb3c8);
  user-select: none;
}

.coaching-recap-body {
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coaching-recap-video {
  max-width: 320px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
}

.coaching-recap-narration {
  margin: 0;
  color: var(--text-secondary, #9fb3c8);
  line-height: 1.4;
}

/* A whole turn shown collapsed by default, e.g. the Local Daemon thread's own
   prompt turn (see _createDaemonThread in app.js) — the `<summary>` line is
   the ENTIRE visible content until expanded, so it needs its own affordance
   rather than the plain scene-record-summary treatment above. */
.thread-collapsed-turn {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(124, 155, 255, 0.04);
}

.thread-collapsed-turn > summary {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-secondary, #9fb3c8);
  font-size: 13px;
  user-select: none;
  list-style: none;
}

.thread-collapsed-turn > summary::-webkit-details-marker {
  display: none;
}

.thread-collapsed-turn > summary::before {
  content: '\25B8 ';
}

.thread-collapsed-turn[open] > summary::before {
  content: '\25BE ';
}

.thread-collapsed-turn > summary ~ * {
  padding: 0 12px 12px;
}

.probe-card.submitted {
  background: rgba(61, 220, 151, 0.1);
  border-color: #3ddc97;
}

.probe-text {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
  color: var(--text);
}

.probe-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.probe-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
}

.probe-input:disabled {
  background: rgba(0, 0, 0, 0.5);
  color: var(--muted);
  cursor: not-allowed;
}

.probe-submit {
  padding: 8px 16px;
  background: #7c9bff;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.probe-submit:hover:not(:disabled) {
  background: #6b8ae0;
}

.probe-submit:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.probe-status {
  color: #3ddc97;
  font-size: 13px;
  padding: 8px 0;
}

.earned-badge {
  display: inline-block;
  margin-left: 8px;
  background: #ffa726;
  color: #000;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.probe-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.earn-offer-card {
  border: 1px solid #ffa726;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  background: rgba(255, 167, 38, 0.05);
}

.offer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 12px;
}

.offer-goal {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.offer-value {
  font-size: 16px;
  font-weight: 600;
  color: #ffa726;
  white-space: nowrap;
}

.offer-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.offer-time,
.offer-modality {
  padding: 2px 6px;
  background: rgba(255, 167, 38, 0.1);
  border-radius: 3px;
  border: 1px solid rgba(255, 167, 38, 0.2);
}

.offer-actions {
  display: flex;
  gap: 8px;
}

.offer-accept-btn,
.offer-submit-btn {
  padding: 8px 12px;
  background: #ffa726;
  color: #000;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.offer-accept-btn:hover:not(:disabled),
.offer-submit-btn:hover:not(:disabled) {
  background: #ff9500;
}

.offer-accept-btn:disabled,
.offer-submit-btn:disabled {
  background: var(--muted);
  color: var(--muted);
  cursor: not-allowed;
}

.offer-status {
  color: #3ddc97;
  font-size: 13px;
  padding: 8px 0;
}

/* ─── Action hints ─────────────────────────────────────────────────────────
   The glyph toolbars (Code, Console, Companion, files) carried their meaning
   in a native `title` alone: ~1s hover delay, nothing at all on touch, and
   nothing on keyboard focus. `uiHints` in app.js retargets that text at one
   body-level bubble that appears instantly on hover AND focus, so a row of
   single-character buttons stops being a memory test. */
#ui-hint {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2147483000;
  max-width: 260px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #10151f;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  color: #e8eefb;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 90ms ease, transform 90ms ease;
  overflow-wrap: break-word;
}
#ui-hint[data-open="1"] {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  #ui-hint { transition: none; }
}

/* Glyph buttons were drawn at 45%/60% white — legible once you knew where to
   look, easy to miss otherwise. Lift the resting contrast and give keyboard
   users the focus ring they never had. */
.code-toolbar-btn {
  color: var(--muted);
}
.code-toolbar-btn:disabled {
  opacity: 0.35;
}
.code-toolbar-btn:disabled:hover {
  color: var(--muted);
}
.icon-button {
  color: var(--text-secondary);
  border-radius: 4px;
}
.icon-button:hover {
  background: rgba(255, 255, 255, 0.06);
}
.code-toolbar-btn:focus-visible,
.icon-button:focus-visible,
.agent-nav-btn:focus-visible,
.code-file-new:focus-visible,
.code-file-bar-toggle:focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: 1px;
  color: var(--text-primary);
}

/* The run button is the primary action in the Code panel — read it as one. */
.code-toolbar-btn.code-toolbar-run {
  color: #5eead4;
}
.code-toolbar-btn.code-toolbar-run:hover {
  background: rgba(94, 234, 212, 0.12);
  border-color: rgba(94, 234, 212, 0.3);
  color: #99f6e4;
}

/* ─── Account page: visible action hierarchy + section nav ──────────────────
   The page already sorted its 16 buttons into three tiers (`ghost-button`,
   `.subtle`, `.danger`) but expressed the difference as `opacity: .8` — a
   20% fade nobody can see. Every action read as equally important, so the
   only way to find one was to read all sixteen labels. Same tiers, now
   actually legible. */
.account-page .ghost-button {
  border-color: rgba(124, 155, 255, 0.45);
  background: rgba(124, 155, 255, 0.08);
  padding: 8px 14px;
}
.account-page .ghost-button:hover {
  border-color: rgba(124, 155, 255, 0.85);
  background: rgba(124, 155, 255, 0.16);
}
.account-page .ghost-button.subtle {
  opacity: 1;
  border-color: var(--panel-border);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
}
.account-page .ghost-button.subtle:hover {
  border-color: var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.account-page .ghost-button.danger {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
}
.account-page .ghost-button.danger:hover {
  border-color: rgba(248, 113, 113, 0.85);
  background: rgba(248, 113, 113, 0.16);
}
.account-page .ghost-button:focus-visible {
  outline: 2px solid #8b9bff;
  outline-offset: 2px;
}

/* Nine stacked sections with no map: Preferences, Downloads and the
   sign-out/delete controls were invisible until you scrolled for them. The
   nav lists every section up front — it reveals the surface rather than
   folding it away, so nothing is ever one collapsed row from unreachable. */
.account-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0;
  margin-bottom: -6px;
  background: linear-gradient(var(--bg, #06070c) 78%, transparent);
}
.account-nav-link {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.account-nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.account-nav-link[aria-current="true"] {
  color: #cfd8ff;
  border-color: rgba(124, 155, 255, 0.5);
  background: rgba(124, 155, 255, 0.14);
}
.account-nav-link:focus-visible {
  outline: 2px solid #8b9bff;
  outline-offset: 2px;
}
/* --account-nav-offset is published by the nav builder from the nav's
   measured sticky top + height, so this stays correct whether the nav is one
   row or two and whether or not a fixed mobile header sits above it. The
   literal is only the pre-script fallback. */
.account-page .account-section {
  scroll-margin-top: var(--account-nav-offset, 64px);
}
/* Mobile keeps #top-bar fixed at the viewport top (z-index 200), so a nav
   stuck at 0 would sit behind it. Drop below the header and raise the stack
   order. Nine pills also stop wrapping into three rows and scroll sideways
   instead — one gesture, nothing hidden.
   Keyed off body[data-mobile] rather than a width query, because that is what
   utils/mobileDetect.js actually sets, and its "mobile" is < 768px. Note its
   orientation is derived from width, not measured: a phone held landscape is
   812px wide and therefore classified tablet/portrait, which is why the
   header offset is keyed to the device flag and not to an orientation query. */
body[data-mobile="true"] .account-nav {
  top: var(--app-header-h, 44px);
  z-index: 201;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
body[data-mobile="true"] .account-nav::-webkit-scrollbar {
  display: none;
}
/* mobile.css gives every .ghost-button a 36px minimum; the nav pills are not
   ghost-buttons and were landing at 26px, the smallest tap target on the
   page — and they are the page's primary navigation. */
body[data-mobile="true"] .account-nav-link {
  white-space: nowrap;
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

/* ── Local Daemon: fork-request card ──────────────────────────────────
   Sits above the transcript inside #chat-panel, same slot tier as the
   shared-av panel just below. Hidden entirely unless the active thread is
   thread.kind === 'daemon' (see _renderDaemonForkRequestCard in app.js). */
.daemon-fork-request-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: color-mix(in srgb, var(--panel) 88%, black);
}

.daemon-fork-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.daemon-fork-card-icon { font-size: 14px; }

.daemon-fork-card-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.daemon-fork-card-hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.daemon-fork-card-hint code {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--panel) 70%, black);
}

.daemon-fork-card-row { display: flex; }

.daemon-fork-card-gen-input,
.daemon-fork-card-prompt-input {
  flex: 1;
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 75%, black);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 8px;
  resize: vertical;
}

.daemon-fork-card-gen-input:focus,
.daemon-fork-card-prompt-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.daemon-fork-card-actions {
  align-items: center;
  gap: 10px;
}

.daemon-fork-card-submit-btn {
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-contrast, #fff);
  background: var(--accent);
  cursor: pointer;
}

.daemon-fork-card-submit-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.daemon-fork-card-submit-btn:hover:not(:disabled) { filter: brightness(1.08); }

.daemon-fork-card-status {
  font-size: 11px;
  color: var(--muted);
}

.daemon-fork-card-status.pending { color: var(--accent); }
.daemon-fork-card-status.success { color: var(--accent); }
.daemon-fork-card-status.error { color: #e5484d; }

/* Phase B — sharing panel, nested inside the same fork card. */
.daemon-fork-card-share {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--panel-border);
}

.daemon-fork-card-share-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.daemon-fork-card-share-toggle:hover { color: var(--text); }

.daemon-fork-card-share-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.daemon-fork-card-share-email {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 75%, black);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 8px;
}

.daemon-fork-card-share-role {
  font-size: 11px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 75%, black);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 5px 6px;
}

.daemon-fork-card-share-add-btn {
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-contrast, #fff);
  background: var(--accent);
  cursor: pointer;
}

.daemon-fork-card-share-status {
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

.daemon-fork-card-share-status.pending { color: var(--accent); }
.daemon-fork-card-share-status.error { color: #e5484d; }

.daemon-fork-card-share-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daemon-fork-card-share-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.daemon-fork-card-share-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.daemon-fork-card-share-role-label { color: var(--muted); }

.daemon-fork-card-share-revoke-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.daemon-fork-card-share-revoke-btn:hover { color: #e5484d; }

.daemon-fork-card-share-empty {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.daemon-fork-card-share-link-btn {
  align-self: flex-start;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  margin-top: 2px;
}

.daemon-fork-card-share-link-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Standalone grantee viewer (Phase B, #2449's follow-up) — a full-screen
   modal reached via ?daemon_session=<id>, independent of the thread/panel
   system entirely (a non-owner never has this session as a thread). Raw
   overlay + dialog, same pattern _showTemplateSelector already uses for a
   self-contained modal not docked into any panel. */
.daemon-shared-view-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.daemon-shared-view-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.daemon-shared-view-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.daemon-shared-view-close:hover { color: var(--text); }

.daemon-shared-view-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 24px;
}

.daemon-shared-view-role-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 999px;
  padding: 3px 9px;
}

.daemon-shared-view-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.daemon-shared-view-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.daemon-shared-view-stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.daemon-shared-view-summary {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  padding: 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 75%, black);
}

.daemon-shared-view-viewer-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.daemon-shared-view-error {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.daemon-shared-view-loading {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 20px 0;
}

/* "Shared with you" list (_openSharedDaemonSessionsList) — reuses the same
   .daemon-shared-view-overlay/-dialog shell as the single-session viewer. */
.daemon-shared-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daemon-shared-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  background: color-mix(in srgb, var(--panel) 75%, black);
}

.daemon-shared-list-row:hover { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }

.daemon-shared-list-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.daemon-shared-list-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daemon-shared-list-meta {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Shared Threads: live A/V panel ───────────────────────────────────
   Sits above the transcript inside #chat-panel. Hidden entirely unless
   the token endpoint says this viewer may join, so a thread with no live
   layer looks exactly as it did before. */
.shared-av {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: color-mix(in srgb, var(--panel) 88%, black);
}

.shared-av-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Collapsed: header stays (title + Join/Leave stay reachable), everything
   below it -- the descriptive idle text, Connect account button, video grid --
   is hidden. Defaults collapsed on mobile (modules/sharedThreadAv.js) since
   that content ran the full width above the fold there, pushing the thread
   itself out of view. */
.shared-av.shared-av-collapsed .shared-av-error,
.shared-av.shared-av-collapsed .shared-av-grid,
.shared-av.shared-av-collapsed .shared-av-controls,
.shared-av.shared-av-collapsed .shared-av-level-meter,
.shared-av.shared-av-collapsed .shared-av-sfu,
.shared-av.shared-av-collapsed .shared-av-mentra {
  display: none;
}

.shared-av-collapse-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
}

.shared-av-collapse-btn:hover { color: var(--text); }

.shared-av-collapse-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.shared-av-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.shared-av-role,
.shared-av-count {
  font-size: 11px;
  color: var(--muted);
}

.shared-av-role {
  padding: 1px 7px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  text-transform: lowercase;
}

.shared-av-recording {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--error);
  animation: shared-av-pulse 1.6s ease-in-out infinite;
}

@keyframes shared-av-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .shared-av-recording { animation: none; }
}

.shared-av-spacer { flex: 1 1 auto; }

.shared-av-error {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--error);
}

.shared-av-idle {
  font-size: 12px;
  color: var(--muted);
}

.shared-av-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.shared-av-grid:empty { display: none; }

/* One feed pinned for everyone: it takes the full width and the rest
   tuck underneath at tile size. */
.shared-av-grid.has-spotlight { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.shared-av-grid.has-spotlight .shared-av-tile.is-spotlight { grid-column: 1 / -1; }

.shared-av-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #000;
}

.shared-av-tile.is-spotlight { border-color: var(--accent); }

.shared-av-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* No camera published: the tile is still the participant's presence, so
   it stays in the grid rather than disappearing mid-call. */
.shared-av-tile.is-cameraless video { visibility: hidden; }
.shared-av-tile.is-cameraless::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--panel) 70%, transparent) 0 22%, transparent 23%),
    var(--panel);
}

.shared-av-label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 1;
  max-width: calc(100% - 12px);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shared-av-tile-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.shared-av-tile:hover .shared-av-tile-actions,
.shared-av-tile:focus-within .shared-av-tile-actions { opacity: 1; }

.shared-av-tile-actions:empty { display: none; }

/* "Is my audio actually reaching this person?" — real outbound-stats
   confirmation, always visible (not hover-gated like the actions) since
   it's status, not an action. */
.shared-av-send-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  font-size: 10px;
  line-height: 1;
  padding: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
}

.shared-av-send-badge.is-checking { color: var(--text-muted, #8892a0); animation: shared-av-pulse 1.6s ease-in-out infinite; }
.shared-av-send-badge.is-sending { color: var(--success); }
.shared-av-send-badge.is-silent { color: var(--error); }

@media (prefers-reduced-motion: reduce) {
  .shared-av-send-badge.is-checking { animation: none; }
}

.shared-av-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.shared-av-level-meter {
  display: block;
  width: 96px;
  height: 22px;
  margin-top: 4px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.shared-av-level-meter.hidden { display: none; }

.shared-av-btn {
  padding: 4px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.shared-av-btn:hover { border-color: var(--accent); }

.shared-av-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.shared-av-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.shared-av-btn.is-danger:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Bring-your-own SFU: owner-only section under the A/V controls. */
.shared-av-sfu {
  border-top: 1px solid var(--panel-border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shared-av-sfu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shared-av-sfu-text {
  flex: 1 1 240px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.shared-av-sfu-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shared-av-sfu-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}

.shared-av-sfu-field input {
  padding: 5px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}

.shared-av-sfu-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.shared-av-sfu-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.shared-av-sfu-note {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.85;
}

/* Mentra glasses (device grant key) reuses the .shared-av-sfu-* structural
   classes above (row/text/form/field/actions/note) via multi-class elements
   — only the box itself and the one-time plaintext reveal need their own
   rules. */
.shared-av-mentra {
  border-top: 1px solid var(--panel-border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shared-av-mentra-reveal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shared-av-mentra-reveal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shared-av-mentra-reveal-label {
  flex: 0 0 90px;
  font-size: 11px;
  color: var(--muted);
}

.shared-av-mentra-reveal-value {
  flex: 1 1 160px;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  word-break: break-all;
}

.shared-av-mentra-done {
  align-self: flex-start;
}

/* Which transport is carrying the call — and therefore whose bill it is. */
.shared-av-transport {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--muted);
}

/* ── Public renders gallery ─────────────────────────────────────────────────
   A horizontally-scrollable strip of live render previews. Widened past the
   420px .modal-panel default via panelClass rather than by changing the base,
   so every other modal keeps its width. */
.modal-panel.public-renders-shell {
  width: min(760px, 100%);
  text-align: left;
}

.modal-panel.public-renders-shell h2,
.modal-panel.public-renders-shell .modal-helper {
  text-align: left;
}

.public-renders-strip {
  position: relative;
  margin-top: 16px;
}

.public-renders-track {
  display: flex;
  column-gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  padding: 4px 2px 10px;
  /* Firefox + WebKit thin scrollbar; the arrow buttons are the primary
     affordance, the bar is the secondary one. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.public-renders-track:focus-visible {
  outline: 2px solid var(--accent, #7c8cff);
  outline-offset: 2px;
  border-radius: 12px;
}

.public-renders-track::-webkit-scrollbar { height: 8px; }
.public-renders-track::-webkit-scrollbar-track { background: transparent; }
.public-renders-track::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 99px;
}

.public-render-card {
  flex: 0 0 auto;
  width: 208px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #0d1018;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.public-render-card.is-revoked { opacity: 0.55; }

.public-render-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 480 / 300;
  overflow: hidden;
  border-radius: 10px;
  background: #050816;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The frame is laid out at the full logical stage size and scaled down, so the
   thumbnail is a true miniature instead of a reflowed narrow-viewport render.
   Card 208 - 20 padding - 2 border = 186px of content box; 186/480 = 0.3875.
   Overshooting here silently clips the render's right edge. */
.public-render-preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  transform: scale(0.3875);
  transform-origin: top left;
  /* Previews are for looking at, not driving — clicks and scrolls belong to the
     card and the strip. */
  pointer-events: none;
}

.public-render-preview-note {
  font-size: 11px;
  color: var(--muted, #8b93a7);
  text-align: center;
  padding: 0 8px;
}

.public-render-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.public-render-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #e9ecf5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.public-render-sub {
  font-size: 11px;
  color: var(--muted, #8b93a7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.public-render-link {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 9px;
}

.public-renders-nav {
  position: absolute;
  top: calc((208px * 300 / 480) / 2 + 4px);
  transform: translateY(-50%);
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 14, 22, 0.94);
  color: var(--text, #e9ecf5);
  cursor: pointer;
}

/* Only shown once there is actually somewhere to scroll — two permanently
   disabled arrows read as broken. */
.public-renders-strip.has-overflow .public-renders-nav { display: flex; }

.public-renders-nav.is-prev { left: -10px; }
.public-renders-nav.is-next { right: -10px; }

.public-renders-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.public-renders-nav:not(:disabled):hover {
  border-color: rgba(255, 255, 255, 0.3);
}

/* ── Help & Tips panel ────────────────────────────────────────────────── */
.modal-panel.help-shell {
  width: min(620px, 100%);
  max-height: min(80vh, 720px);
  overflow-y: auto;
  text-align: left;
}

.modal-panel.help-shell h2,
.modal-panel.help-shell .modal-helper {
  text-align: left;
}

.help-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 14px;
}

.help-tab {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--bg-3);
  color: var(--muted);
  cursor: pointer;
}

.help-tab:hover {
  border-color: rgba(124, 155, 255, 0.6);
}

.help-tab.is-active {
  border-color: rgba(124, 155, 255, 0.8);
  background: rgba(124, 155, 255, 0.14);
  color: var(--text);
}

.help-tip-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.help-faq-heading {
  margin: 22px 0 4px;
  font-size: 14px;
}

.help-faq {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-faq-item {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
}

.help-faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-3);
  color: var(--text);
  border: 0;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.help-faq-caret {
  flex: 0 0 auto;
  transition: transform 0.15s ease;
  color: var(--muted);
}

.help-faq-question[aria-expanded="true"] .help-faq-caret {
  transform: rotate(180deg);
}

.help-faq-answer {
  margin: 0;
  padding: 0 12px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

@media (max-width: 640px) {
  .public-render-card { width: 168px; }
  .public-render-preview-frame { transform: scale(0.3042); } /* 168 - 20 - 2 = 146; 146/480 */
  .public-renders-nav { top: calc((168px * 300 / 480) / 2 + 4px); }
  .public-renders-nav.is-prev { left: -4px; }
  .public-renders-nav.is-next { right: -4px; }
}

@media (prefers-reduced-motion: reduce) {
  .public-renders-track { scroll-behavior: auto; }
}

/* ── Thread New Menu ────────────────────────────────────────────────────── */

.thread-new-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5000;
}

.thread-new-menu {
  position: fixed;
  background: var(--bg-3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  padding: 4px;
  min-width: 280px;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  z-index: 5001;
}

:root[data-theme="light"] .thread-new-menu {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
}

.thread-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 150ms;
  border-radius: 4px;
}

.thread-menu-item:hover {
  background: var(--bg-hover);
}

.menu-icon {
  font-size: 20px;
  display: flex;
  align-items: center;
}

.menu-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-label {
  font-weight: 500;
  color: var(--text-primary);
  display: block;
}

.menu-desc {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

/* ─── Simple Mode: "/" slash-command palette ─────────────────────────────
   #slash-command-palette is created by modules/simpleModeSlashCommands.js
   and parked on <body> (position: fixed, anchored just above the composer's
   .chat-input-full by JS) — same technique as #context-crystal-menu, so the
   composer's overflow:hidden can't clip it. Only ever shown while
   body.default-mode-enabled (the module gates on isDefaultModeOn()). */
.slash-command-palette {
  position: fixed;
  z-index: 600;
  display: flex;
  flex-direction: column;
  max-height: min(340px, 48vh);
  overflow: hidden;
  border: 1px solid rgba(124, 155, 255, 0.32);
  border-radius: 10px;
  background: rgba(7, 12, 20, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  color: var(--text, #e2e8f0);
  font-size: 13px;
}
.slash-command-palette[hidden] {
  display: none;
}
.slash-command-palette-title {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #c7d2fe;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slash-command-palette-keys {
  flex: 0 0 auto;
  color: rgba(199, 210, 254, 0.55);
  font-weight: 500;
}
.slash-command-palette-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}
.slash-command-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.slash-command-item.is-active {
  background: rgba(124, 155, 255, 0.16);
}
.slash-command-item.is-disabled {
  opacity: 0.55;
  cursor: default;
}
.slash-command-item-label {
  flex: 0 0 auto;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #dbe4ff;
}
.slash-command-item-hint {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(226, 232, 240, 0.62);
  font-size: 12px;
}
.slash-command-empty {
  padding: 10px 12px;
  color: rgba(226, 232, 240, 0.55);
}
@media (max-width: 640px) {
  .slash-command-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .slash-command-item-label {
    max-width: 100%;
  }
}
