:root {
  color-scheme: dark;
  --bg: #0b0b0f;
  --panel: #141420;
  --panel-border: #232334;
  --accent: #7c9bff;
  --text: #f1f1f6;
  --muted: #a5a5b5;
  --success: #3ddc97;
  --error: #ff6b6b;
}

* {
  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;
}

.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;
}

.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: #12121c;
  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: #12121c;
  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);
}

.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: #1a1a28;
  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: #1f2233;
}

/* 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: rgba(255, 255, 255, 0.6);
  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: #111;
  color: white;
}

.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: white;
}

.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: #1a1a28;
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
}

.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: #0f0f18;
  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: 16px 24px;
  background: #11111a;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

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

#top-bar .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#status-label {
  display: none;
}

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

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

.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: #10101a;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

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

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

.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: #0f0f1a;
  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;
}

.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: #ffffff;
}

.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: #11111c;
  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;
  height: calc(100vh - 64px);
}

#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: #fff;
}

.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: rgba(255, 255, 255, 0.85);
  padding: 6px 10px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

#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: #111;
  border: 1px solid #333;
  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;
}

#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;
}

.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: #f8fafc;
}

.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;
}

/* 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: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
}

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

.icon-button:hover {
  color: rgba(255, 255, 255, 0.9);
}

.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;
}

.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: #11111b;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

/* ─── HLSF-RAG: Discipline Pills & 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: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  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: rgba(255,255,255,0.6);
}
.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;
}

.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: #111118;
  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: #e2e8f0;
}

.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: #0f172a;
  border: 1px solid #334155;
  border-radius: 14px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.45);
  color: #e2e8f0;
  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: #f8fafc;
}

.ape-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.ape-close-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.ape-close-btn:hover {
  color: #e2e8f0;
}

.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: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ape-hint {
  font-weight: 400;
  text-transform: none;
  color: #64748b;
  letter-spacing: 0;
}

.ape-input,
.ape-select,
.ape-textarea {
  background: #091222;
  border: 1px solid #28425f;
  color: #e2e8f0;
  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: #64748b;
}

.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 #334155;
  background: #111827;
  color: #cbd5e1;
}

.ape-btn-cancel:hover {
  background: #1e293b;
  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: #e2e8f0;
  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 #334155;
  color: #94a3b8;
  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: #64748b;
  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: #94a3b8;
  line-height: 1.6;
}

.pipeline-cost-label {
  color: #64748b;
}

.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: baseline;
  justify-content: space-between;
  gap: 10px;
}

.recommended-prompt-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #e2e8f0;
  text-transform: uppercase;
}

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

.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: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.8rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}
.controls-row-toggle:hover {
  color: rgba(255,255,255,0.85);
}
.controls-row-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.9rem;
}
.chat-controls-row.collapsed .controls-row-chevron {
  transform: rotate(-90deg);
}
.controls-row-summary {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  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;
}

.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: #10101a;
  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: #e2e8f0;
  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: #11111c;
  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;
}

.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: #ffffff;
}

.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: #0c0c15;
  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);
  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;
}

#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: #0c0c15;
  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;
  padding: 4px 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.2);
}
.chat-input-left-actions {
  display: flex;
  gap: 4px;
}
.chat-tool-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.chat-tool-btn:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.08);
}
.chat-send-btn {
  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; }

/* ── 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;
}

#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(11, 11, 15, 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: #e2e8f0;
}

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

.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;
  max-width: 260px;
  line-height: 1.3;
}

.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: rgba(255,255,255,0.35);
  font-family: monospace;
  margin-right: 4px;
}
.code-toolbar-spacer { flex: 1; }
.code-toolbar-btn {
  background: none;
  border: 1px solid transparent;
  color: rgba(255,255,255,0.45);
  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: #e2e8f0;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
.code-toolbar-btn:disabled {
  opacity: 0.25;
  cursor: default;
}
.code-toolbar-btn:disabled:hover {
  background: none;
  border-color: transparent;
  color: rgba(255,255,255,0.45);
}
.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);
}
/* 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: #1a1a2e;
  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: rgba(255,255,255,0.4);
  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: rgba(255,255,255,0.65);
}

.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;
}
.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: #64748b; }
.console-status-chip.running { color: #34d399; }
.console-status-chip.error { color: #f87171; }
.console-status-label {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

#code-footer {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  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: #10101a;
  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;
  position: relative;
}

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

.msg-sender-attribution {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #7c9bff;
  margin-bottom: 3px;
  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;
}

.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: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  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: rgba(255, 255, 255, 0.95);
}

.message.assistant h2 {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.88);
}

.message.assistant h3 {
  font-size: 0.97rem;
  color: rgba(255, 255, 255, 0.78);
}

.message.assistant h4,
.message.assistant h5,
.message.assistant h6 {
  font-size: 0.93rem;
  color: rgba(255, 255, 255, 0.65);
  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 SKG contribution badge — appears ~2.5s 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,
#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,
#conversation-overlay-role .skg-triple-badge {
  margin-top: 0;
  margin-left: auto;
}

.mosaic-tile-header .skg-triple-tooltip,
.agent-panel-header .skg-triple-tooltip,
#conversation-overlay-role .skg-triple-tooltip {
  top: calc(100% + 6px);
  bottom: auto;
}

/* Badges on right-side modules flow left so tooltips don't clip the viewport */
[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="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;
  max-width: 380px;
  z-index: 200;
  white-space: nowrap;
  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;
}

.skg-triple-subject,
.skg-triple-object {
  position: relative;
  display: inline-block;
  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-loop-row {
  display: block;
  font-size: 0.65rem;
  color: rgba(168, 85, 247, 0.7);
  letter-spacing: 0.02em;
  line-height: 1.8;
}

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

/* ─── SKG 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 {
  font-size: 13px;
  opacity: 0.85;
}

/* ─── SKG leaderboard popover ─────────────────────────────────────────── */
.skg-leaderboard-popover {
  display: none;
  position: absolute;
  z-index: 9999;
  min-width: 260px;
  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;
}

.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;
  background: rgba(15, 23, 42, 0.72);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

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

.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: #94a3b8;
  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: #e2e8f0;
}
.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;
}

.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;
}

.message em {
  opacity: 0.6;
  font-style: italic;
}

.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(11, 11, 15, 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(11, 11, 15, 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(11, 11, 15, 0.96);
}

/* 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(11, 11, 15, 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: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.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: #94a3b8;
  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: #f1f5f9;
}

.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: #f1f5f9;
  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: #64748b;
  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: #f8fafc;
}

.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-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;
}

.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: #e2e8f0;
  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: #cbd5e1;
}

.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(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
  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: #475569;
}

/* 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;
}

.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: rgba(255, 255, 255, 0.5);
  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;
}

.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;
  }
}

@media (hover: none) {
  .chat-copy-btn,
  .chat-delete-btn {
    opacity: 0.9;
  }
}

.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: #0c0c15;
  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: #0f0f1a;
  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-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-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-empty {
  text-align: center;
  padding: 40px 0;
  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%;
}

.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: rgba(255, 255, 255, 0.8);
  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: rgba(255, 255, 255, 0.65);
}

.artifact-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

.artifact-engagement {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.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: rgba(255, 255, 255, 0.7);
}

.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: #f8fafc;
}

.account-profile-copy .account-muted,
.account-profile-copy .profile-location {
  margin: 0;
}

.profile-meta h2 {
  margin: 0 0 4px;
}

.profile-handle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
}

.profile-bio {
  margin: 8px 0 0;
  color: var(--muted);
}

.profile-location {
  margin-top: 6px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
}

.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: rgba(255, 255, 255, 0.6);
}

.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: rgba(255, 255, 255, 0.5);
}

.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: rgba(255, 255, 255, 0.55);
}

.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;
}

.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 {
  background: #0b1020;
  color: #e9ecff;
  min-height: 100vh;
}

.plans-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.plans-header h1 {
  margin: 0.75rem 0 0.25rem;
}

.plans-grid {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.plan-card {
  position: relative;
  border: 1px solid rgba(156, 168, 255, 0.35);
  border-radius: 14px;
  background: rgba(15, 22, 42, 0.72);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.plan-card--featured {
  border-color: rgba(124, 155, 255, 0.65);
  box-shadow: 0 0 0 1px rgba(124, 155, 255, 0.3),
    0 16px 40px rgba(90, 120, 255, 0.2);
}

.plan-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(124, 155, 255, 0.2);
  border: 1px solid rgba(124, 155, 255, 0.5);
  color: #c0cfff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.plan-card-price {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.25rem 0 0;
}

.plan-card-compare {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin: 0 0 0.5rem;
}

.plan-card ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.1rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.875rem;
  flex: 1;
  display: grid;
  gap: 0.3rem;
}

.plans-comparison-section {
  margin-top: 2rem;
}

.plans-comparison {
  overflow-x: auto;
}

.plans-comparison .col-ours {
  background: rgba(124, 155, 255, 0.06);
  color: #e3e9ff;
  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(255, 255, 255, 0.35);
}

.plans-error {
  margin-top: 1rem;
  color: #ffb5b5;
}

.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;
}

.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: #111;
  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 #333;
  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;
}

/* 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: #64748b;
  gap: 8px;
}

.pipeline-elapsed {
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
}

.pipeline-eta {
  font-variant-numeric: tabular-nums;
  color: #64748b;
}

.pipeline-step-count {
  color: #94a3b8;
}

/* 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;
}

.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: #e2e8f0;
  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 {
  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 {
  position: absolute;
  width: 42px;
  height: 42px;
  margin-left: -21px;
  margin-top: -21px;
  border-radius: 12px;
  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 {
  font-size: 20px;
  line-height: 1;
  color: #93c5fd;
  letter-spacing: 0;
  font-variant-ligatures: none;
}

.pipeline-orbit-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 {
  color: #86efac;
}

.pipeline-orbit-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 {
  color: #dbeafe;
}

.pipeline-orbit-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 {
  color: #fca5a5;
}

.pipeline-orbit-edge {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.78;
  stroke: rgba(71, 85, 105, 0.34);
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - (var(--edge-progress, 0) * 100));
  transition: stroke-dashoffset 0.55s ease, stroke 0.25s ease, opacity 0.25s ease;
}

.pipeline-orbit-edge.is-pending {
  stroke: rgba(71, 85, 105, 0.34);
}

.pipeline-orbit-edge.is-completed {
  stroke: rgba(74, 222, 128, 0.86);
  filter: drop-shadow(0 0 6px rgba(74, 222, 128, 0.25));
  stroke-dashoffset: 0;
}

.pipeline-orbit-edge.is-active {
  stroke: rgba(96, 165, 250, 0.9);
  animation: pipeline-edge-pulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.28));
}

.pipeline-orbit-edge.is-failed {
  stroke: rgba(248, 113, 113, 0.8);
}

@keyframes pipeline-edge-pulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@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: #8892b0;
  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: #8892b0;
  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: #8892b0;
  font-size: 11px;
  min-width: 60px;
}
.quality-target-option .qt-time {
  color: #8892b0;
  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;
}

/* 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: #8892b0;
  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-iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  background: #0d1117;
  display: block;
  position: relative;
}

/* ─── 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: #e2e8f0;
  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;
}

.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: #94a3b8;
  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: #cbd5e1;
}

.agent-library-refresh-btn,
.agent-library-mini-btn {
  border: 1px solid #334155;
  background: #111827;
  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: #f8fafc;
  font-size: 12px;
  font-weight: 700;
}

.agent-library-item-role {
  color: #94a3b8;
  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 #334155;
  background: transparent;
  color: #cbd5e1;
  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: #e2e8f0;
}
.agent-role-inline {
  font-size: 11px;
  color: #64748b;
  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;
}
.agent-library-select-sm {
  font-size: 11px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #cbd5e1;
  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: #e2e8f0;
  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: #64748b;
  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: #cbd5e1;
  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: #94a3b8;
  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;
}

.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: #e2e8f0;
  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: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-role {
  font-size: 11px;
  color: #8892b0;
  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: #8892b0;
  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: #8892b0;
  border-bottom: 1px solid var(--border-color, #2e3a50);
}
.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: #8892b0; }
.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;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.thread-dock::-webkit-scrollbar { display: none; }

.thread-dock-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.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);
}

.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: #8892b0;
  cursor: pointer;
  padding: 0;
  z-index: 5;
}
.thread-icon-btn:hover .thread-sweep-btn {
  display: block;
}
.thread-sweep-btn:hover {
  background: #ef4444;
  color: #fff;
}

.thread-new-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #8892b0;
  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: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.45);
}

.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: #1e293b;
  border: 1px solid #334155;
  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: #94a3b8;
  margin: 0 0 14px;
  line-height: 1.5;
}
.thread-delete-code-options {
  background: #0f172a;
  border: 1px solid #334155;
  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: #cbd5e1;
  cursor: pointer;
  padding: 3px 0;
}
.thread-delete-option input[type="checkbox"] {
  accent-color: #fb923c;
  width: 14px;
  height: 14px;
}
.thread-delete-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.thread-delete-cancel-btn {
  background: #334155;
  color: #e2e8f0;
  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: #64748b;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
}
.agent-console-clear-btn:hover {
  color: #e2e8f0;
}
.agent-credit-tally {
  display: none;
  font-size: 11px;
  color: #64748b;
  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: #94a3b8;
}
.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: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
}
.agent-console-clear-btn:hover { color: #e2e8f0; }

.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 #334155;
  cursor: pointer;
  font-family: inherit;
}
.agent-settings-save-btn {
  background: #0f766e;
  color: #e2e8f0;
}
.agent-settings-save-btn:hover {
  background: #14b8a6;
}
.agent-settings-cancel-btn {
  background: transparent;
  color: #94a3b8;
}
.agent-settings-cancel-btn:hover {
  background: #1e293b;
  color: #e2e8f0;
}

/* 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;
}

.agent-nav-btn {
  width: 28px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #e2e8f0;
  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-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: #334155;
  border-color: rgba(255, 255, 255, 0.06);
  cursor: default;
  pointer-events: none;
}

.agent-nav-btn.is-glowing {
  color: #f0f0f0;
  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-counter {
  font-size: 11px;
  color: #64748b;
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 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: #1a1a2e;
  border: 1px solid #2e3a50;
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  color: #e2e8f0;
}
.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: #8892b0;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.agent-approval-field .value {
  font-size: 13px;
  color: #e2e8f0;
}
.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: #e2e8f0;
}
.agent-cancel-btn {
  background: transparent;
  color: #8892b0;
  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;
}

/* 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;
  height: 560px;
  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;
  height: calc(100vh - 64px);
  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;
}

.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;
}

.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-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-popout:hover,
.mosaic-tile-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.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; }

.mosaic-popout-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: rgba(255, 255, 255, 0.45);
  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;
}

.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: rgba(255, 255, 255, 0.78);
  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:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mosaic-chip-reset {
  font-size: 11px;
  color: var(--muted);
  font-family: inherit;
}

/* ── Layouts preset switcher ─────────────────────────────────────────────── */
.mosaic-layouts { position: relative; display: inline-flex; }
.mosaic-layouts-caret { font-size: 9px; opacity: 0.7; margin-left: 2px; }
.mosaic-layouts-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10000;
  min-width: 230px;
  padding: 6px;
  background: #11131b;
  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: rgba(255, 255, 255, 0.82);
  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); }

/* ── 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(11, 11, 15, 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;
}
/* In other modes the end button is redundant with the top-bar 🎧 toggle
   and the floating overlay's minimize/close affordances — only show it
   when docked, where the top-bar may be out of the user's eye-line. */
#conversation-overlay:not(.is-docked) #conv-end-btn {
  display: none;
}
/* 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: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  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. */
  width: clamp(120px, 36cqw, 420px) !important;
  margin: 0 auto 4px !important;
  --cube-half: clamp(60px, 18cqw, 210px);
}
#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(15px, 2.8cqw, 28px) !important;
  line-height: 1.4;
  flex: 1 1 auto;
  min-height: 0;
  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);
}

/* ─── 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; }
  .mosaic-chip      { font-size: 0.75rem; padding: 3px 8px; }
  .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;
  }
}

/* ─── 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;
}

@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: #f8fafc;
}

.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;
  }
}

