/* ==============================================================================
   Global Scrollbar — thin, semi-transparent, consistent everywhere
   ============================================================================== */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

/* ==============================================================================
   Typography Overrides
   ============================================================================== */

/* Reduce heading sizes (Tailwind defaults are too large) */
.text-5xl, .lg\:text-5xl {
  font-size: 2.2rem !important;
  line-height: 1.2 !important;
}
.text-4xl, .lg\:text-4xl {
  font-size: 2rem !important;
  line-height: 1.2 !important;
}
.text-3xl, .lg\:text-3xl {
  font-size: 1.8rem !important;
  line-height: 1.2 !important;
}

blockquote {
  font-style: italic;
  margin: 3px;
  padding: 5px 10px;
  border-left: 5px solid #ccc;
  font-size: 0.8rem;
}

h3 {
  margin: 0;
}

blockquote {
  font-style: normal;
  line-height: 1rem;
}

.MuiAlert-message .MuiBox-root .markdown-body p:last-child {
  margin-bottom: 0;
}

/* Slightly right-shift first level <ul> because they're too close to the left end of message area*/
ul.pl-2:not(ul ul) {
  padding-left: 2rem;
}

/* Watermark: Hide Chainlit's default elements (JS handles custom text replacement) */
.watermark svg {
  display: none;
}

/* Document link styling */
.doc-link {
  color: #29d8ff;
  text-decoration: underline;
}

.doc-link:hover {
  color: #78e6ff;
}

/* Hide message composer until loading completes */
#message-composer {
  opacity: 0;
  pointer-events: none;
  /* No transition - instant hide when chat-ready removed */
}

body.chat-ready #message-composer {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease-in;  /* Smooth fade-in only */
}

/* Composer toolbar status pills — read-only data/Web Search indicators.
   Right-pinned cluster, visually distinct from clickable tool buttons:
   pill shape + subtle filled bg, no button-like hover elevation. */
.ao-composer-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;     /* pin cluster to the right of the row */
  margin-right: 0.625rem; /* breathing room from the send button */
}

/* Assistive, not a primary control: smaller, lighter, and quieter than the
   send button (the king of this row). Recessive muted fill at reduced opacity,
   normal weight, compact height — the eye lands on Send first. */
.ao-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 1.5rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: none;
  background: hsl(var(--muted) / 0.55);
  color: hsl(var(--muted-foreground));
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  /* color/bg only — no transform/shadow, so it reads as status, not a button */
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.ao-status-pill:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  opacity: 1;
}

.ao-status-pill svg {
  width: 0.8rem;
  height: 0.8rem;
  flex-shrink: 0;
}

/* Web Search pill — icon-only, square-ish */
.ao-status-pill--web {
  padding: 0 0.5rem;
}

/* Zero-sources warning — solid bright warning fill, static (no animation).
   Uses the --destructive token (with fallback, mirroring .ao-fav usage) and a
   forced white foreground so it stays legible in both .dark and light. */
/* The warning is the one pill allowed to assert itself — full opacity + solid
   fill so it stays unmistakeable. It's still smaller than the send button, so
   Send remains the dominant control by size while the warning reads by colour. */
.ao-status-pill--zero {
  background: hsl(var(--destructive, 0 84% 60%));
  color: #fff;
  font-weight: 600;
  opacity: 1;
}

.ao-status-pill--zero:hover {
  background: hsl(var(--destructive, 0 84% 60%));
  color: #fff;
  filter: brightness(1.08);
}

/* Hide custom header buttons until loading completes */
#custom-help-button,
#custom-settings-button,
#notif-bell-button,
#active-users-count {
  opacity: 0;
  pointer-events: none;
}

body.chat-ready #custom-help-button,
body.chat-ready #custom-settings-button,
body.chat-ready #notif-bell-button,
body.chat-ready #active-users-count {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease-in;
}

/* Active users counter in header */
#active-users-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.7);
  padding: 4px 8px;
  border-radius: 6px;
  user-select: none;
  cursor: default;
}
.dark #active-users-count {
  color: rgba(255, 255, 255, 0.7);
}

/* Logo fade transition (animated GIF -> static on chat-ready) */
.logo-fade-wrapper {
  position: relative;
  display: inline-block;
}

.logo-fade-wrapper .logo-animated {
  transition: opacity 0.5s ease-out;
}

.logo-fade-wrapper .logo-static {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease-in;
}

body.chat-ready .logo-fade-wrapper .logo-animated {
  opacity: 0;
}

body.chat-ready .logo-fade-wrapper .logo-static {
  opacity: 1;
}

:root {
  --modal-bg: hsl(var(--card));
  --modal-border: hsl(var(--border));
  --modal-fg: hsl(var(--foreground));
  --modal-muted-fg: hsl(var(--muted-foreground));
  --modal-accent: hsl(var(--primary));
  --modal-accent-fg: hsl(var(--primary-foreground));
  --modal-input-bg: hsl(var(--secondary));
  --modal-input-fg: hsl(var(--secondary-foreground));
  --modal-ring: hsl(var(--ring));
  /* Card-edge border for inner subsection cards (e.g. Persona/Flow inside the
   * Coordinator tab). Brighter than --modal-border so the card outline is
   * visible against --modal-input-bg fills. */
  --card-border: rgba(255, 255, 255, 0.18);
}

/* Hide Tools button while keeping slash "/" autocomplete menu */
div.command-popover-wrapper {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}


/* ============================================================================
   MOTD Modal - Minimal 2030 Design
   ============================================================================ */

/* Full-screen overlay */
.motd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Fade-in state */
.motd-overlay.visible {
  opacity: 1;
}

/* Modal card - clean and minimal */
.motd-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  max-width: 1000px;
  width: 80vh;
  height: 85vh;
  max-height: 85vh;
  overflow: hidden;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: column;
}

/* Header section */
.motd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--modal-border);
}

.motd-header h2 {
  margin: 0;
  color: var(--modal-accent);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Close button (X) */
.motd-close {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: color 0.2s ease;
  border-radius: 0.25rem;
}

.motd-close:hover {
  color: #fff;
}

.motd-close:active {
  opacity: 0.7;
}

/* Content section */
.motd-content {
  padding: 1.5rem;
  color: var(--modal-fg);
  overflow-y: auto;
  flex: 1;
  line-height: 1.6;
}

/* Styling for content elements */
.motd-content h2 {
  color: var(--modal-accent);
  margin-top: 0;
  font-size: 1.3rem;
}

.motd-content h3 {
  color: var(--modal-accent);
  font-size: 1.1rem;
  margin-top: 1.5rem;
}

.motd-content p {
  margin: 0.75rem 0;
  color: var(--modal-fg);
}

.motd-content ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.motd-content li {
  margin: 0.5rem 0;
  color: var(--modal-fg);
}

.motd-content strong {
  color: var(--modal-accent);
  font-weight: 600;
}

.motd-content a {
  color: var(--modal-accent);
  text-decoration: underline;
  transition: color 0.2s;
}

.motd-content a:hover {
  color: var(--modal-ring);
}

/* Timestamp footer inside content */
.motd-timestamp {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--modal-border);
  font-size: 0.85rem;
  color: var(--modal-muted-fg);
  font-style: italic;
}

/* Static message section (usage guide) */
.motd-static {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--modal-border);
}

.motd-static h3 {
  margin-top: 0;
  color: var(--modal-accent);
}

.motd-status {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--modal-border);
  margin-bottom: 1.5rem;
  background: var(--modal-input-bg);
  color: var(--modal-fg);
}

.motd-status--nominal {
  border-color: #3fb950;
  background: rgba(63, 185, 80, 0.12);
}

.motd-status--degraded {
  border-color: #f85149;
  background: rgba(248, 81, 73, 0.15);
}

.motd-status--pending {
  border-color: var(--modal-border);
  background: rgba(125, 125, 125, 0.1);
}

.motd-status-list {
  margin: 1rem 0 0;
  padding-left: 1.5rem;
  list-style: disc;
}

.motd-status-list li {
  margin-bottom: 0.5rem;
  color: var(--modal-fg);
  display: list-item;
}

/* Usage Boundaries collapsible section */
.motd-limits {
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  background: var(--modal-input-bg);
}

.motd-limits summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--modal-muted-fg);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0.5rem 0.5rem 0 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.motd-limits:not([open]) summary {
  border-radius: 0.5rem;
}

.motd-limits summary::-webkit-details-marker {
  display: none;
}

.motd-limits summary::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  margin-right: 0.25rem;
}

.motd-limits[open] summary::before {
  transform: rotate(45deg);
}

.motd-limits summary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--modal-fg);
}

.motd-limits-content {
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid var(--modal-border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Individual limit row */
.limit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
}

.limit-label {
  flex: 1;
  color: var(--modal-fg);
  font-size: 0.9rem;
}

.limit-value {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  color: var(--modal-accent);
  background: rgba(41, 216, 255, 0.1);
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
}

/* Info icon with hover tooltip */
.limit-info {
  color: var(--modal-muted-fg);
  font-size: 0.85rem;
  cursor: help;
  position: relative;
  transition: color 0.15s ease;
}

.limit-info:hover {
  color: var(--modal-accent);
}

.limit-info:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: 1.5rem;
  width: 280px;
  padding: 0.75rem;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--modal-fg);
  white-space: pre-wrap;
  z-index: 100;
}

/* Announcements section */
.motd-announcements {
  margin-top: 1rem;
}

.motd-announcements h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--modal-accent);
}

.motd-announcements ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.motd-announcements li {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--modal-input-bg);
  border-radius: 0.375rem;
  border-left: 3px solid var(--modal-ring);
  color: var(--modal-fg);
}

.motd-announcements li:last-child {
  margin-bottom: 0;
}

.motd-announcements li code {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--modal-muted-fg);
  font-family: "Inter", monospace;
  margin-bottom: 0.35rem;
}


/* Footer section */
/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  .motd-modal {
    width: 95%;
    max-height: 80vh;
  }

  .motd-header {
    padding: 1rem;
  }

  .motd-header h2 {
    font-size: 1.25rem;
  }

  .motd-content {
    padding: 1rem;
    max-height: 60vh;
  }

}

/* Accessibility: Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .motd-overlay,
  .motd-modal,
  .motd-close {
    transition: none;
  }
}


/* ============================================================================
   Access Denied Modal — Unremovable (same theme as MOTD)
   ============================================================================ */

.access-denied-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000; /* Above MOTD (9999) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.access-denied-overlay.visible {
  opacity: 1;
}

.access-denied-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  max-width: 500px;
  width: 90%;
  padding: 2rem;
  text-align: center;
}

.access-denied-modal h2 {
  margin: 0 0 1rem 0;
  color: var(--modal-accent);
  font-size: 1.25rem;
}

.access-denied-modal p {
  color: var(--modal-fg);
  line-height: 1.6;
  margin: 0;
}

.access-denied-modal a {
  color: var(--modal-accent);
  text-decoration: underline;
}

.access-denied-modal a:hover {
  color: var(--modal-ring);
}

/* Dev-debug detail line at the bottom of the backend-unavailable modal.
   Intentionally small + dim + monospace so non-technical users don't
   focus on it but a dev looking over their shoulder can read the error. */
.access-denied-modal-detail {
  display: block;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  word-break: break-all;
  text-align: left;
}


/* ============================================================================
   Hide Stock ChatSettings Cog Wheel
   ============================================================================ */

/* Hide the stock Chainlit ChatSettings cog wheel button (but NOT our custom settings button) */
button[aria-label*="settings" i]:not(#custom-settings-button),
button[aria-label*="chat settings" i]:not(#custom-settings-button),
.chainlit-chat-settings,
#chat-settings-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}


/* ============================================================================
   User Settings Modal - Minimal 2030 Design (Same theme as MOTD)
   ============================================================================ */

/* Full-screen overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Fade-in state */
.settings-overlay.visible {
  opacity: 1;
}

/* Modal card - clean and minimal */
.settings-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  max-width: 1200px;
  width: 85vw;
  height: 80vh;
  max-height: 80vh;
  overflow: auto;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: column;
}

/* Settings body wrapper (tabs + content) — fill remaining space after header */
.settings-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Detail view layout: flex chain from modal → body → content → tab panel → capabilities → form
   so the scrollable form fills exactly the remaining space (no hardcoded max-height). */
.settings-modal.detail-view-active {
  overflow: hidden;
}
.settings-modal.detail-view-active .settings-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-modal.detail-view-active .settings-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-modal.detail-view-active .settings-tab-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.settings-modal.detail-view-active .capabilities-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Header section */
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--modal-border);
  flex-shrink: 0;
  gap: 1rem;
}

.settings-header h2 {
  margin: 0;
  color: var(--modal-accent);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Close button (X) */
.settings-close {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: color 0.2s ease;
  border-radius: 0.25rem;
}

.settings-close:hover {
  color: #fff;
}

.settings-close:active {
  opacity: 0.7;
}

/* Tab navigation — lives inside .settings-header for compact layout */
.settings-tabs {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.settings-tab {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  padding: 0.5rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.settings-tab:hover {
  color: var(--modal-fg);
}

.settings-tab.active {
  color: var(--modal-accent);
  border-bottom-color: var(--modal-ring);
}

/* Content section */
.settings-content {
  padding: 1.5rem;
  color: var(--modal-fg);
  flex: 1;
  min-height: 0;
}

/* Tab panel */
.settings-tab-panel {
  display: none;
}

.settings-tab-panel.active {
  display: block;
}

/* Form elements */
.settings-form-group {
  margin-bottom: 1.5rem;
}

.settings-form-label {
  display: block;
  color: var(--modal-accent);
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.settings-form-label-hint {
  display: block;
  color: var(--modal-muted-fg);
  font-weight: 400;
  font-size: 0.85rem;
  margin-top: 0.25rem;
  font-style: italic;
}

/* Horizontal pill group for agent mode selection */
.settings-mode-pills {
  display: flex;
  gap: 0;
  margin-top: 0.5rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--modal-input-bg);
}

.settings-mode-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 0.5rem;
  background: transparent;
  border: none;
  border-right: 1px solid var(--modal-border);
  color: var(--modal-muted-fg);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-mode-pill:last-child {
  border-right: none;
}

.settings-mode-pill:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--modal-fg);
}

.settings-mode-pill.active {
  background: var(--modal-ring);
  color: var(--modal-accent-fg);
}

.settings-mode-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-mode-desc {
  margin-top: 0.5rem;
  color: var(--modal-muted-fg);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  min-height: 1.25rem;
}

.settings-textarea {
  width: 100%;
  min-height: 20rem;
  padding: 0.75rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  color: var(--modal-input-fg);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.settings-textarea:focus {
  outline: none;
  border-color: var(--modal-ring);
  background: hsl(var(--card));
}

.settings-textarea::placeholder {
  color: var(--modal-muted-fg);
}

.settings-multiselect {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-multiselect-search {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-multiselect-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 38px;
  max-height: 150px;
  overflow-y: auto;
  overflow-x: hidden;
}

.settings-multiselect-empty {
  color: var(--modal-muted-fg);
  font-size: 0.9rem;
}

.settings-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  background: var(--modal-input-bg);
  color: var(--modal-accent);
  border: 1px solid var(--modal-border);
  border-radius: 0.3rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.settings-chip-remove {
  border: none;
  background: transparent;
  color: var(--modal-accent);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 0.1rem;
}

.settings-multiselect-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  color: var(--modal-input-fg);
  font-size: 0.95rem;
}

.settings-multiselect-input:focus {
  outline: none;
  border-color: var(--modal-ring);
  background: hsl(var(--card));
}

.settings-multiselect-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
  padding-top: 0.5rem;
}

.settings-option {
  text-align: left;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  padding: 0.65rem 0.75rem;
  color: var(--modal-fg);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
  max-height: 120px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.settings-option:hover {
  border-color: var(--modal-ring);
  transform: translateY(-1px);
}

.settings-option.empty {
  cursor: default;
  text-align: center;
  color: var(--modal-muted-fg);
  border-style: dashed;
}

.settings-option-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.settings-option-desc {
  font-size: 0.85rem;
  color: var(--modal-muted-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

/* Character counter */
.settings-char-counter {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.settings-char-count {
  color: var(--modal-muted-fg);
}

.settings-char-count.warning {
  color: #fdbb5a;
}

.settings-char-count.error {
  color: #f37272;
}

.settings-char-warning {
  color: #fdbb5a;
  font-style: italic;
  max-width: 60%;
  text-align: right;
}


/* Footer section */
/* Toast notifications */
.ao-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #fff;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
  cursor: default;
  user-select: text;
}
.ao-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.ao-toast-error {
  background: #c62828;
}
.ao-toast-warning {
  background: #e65100;
}
.ao-toast-info {
  background: var(--teal, #26a69a);
}

/* Sources header: label+hint on left, button on right */
.obeya-sources-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.obeya-select-sources-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  color: var(--modal-fg);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.obeya-select-sources-btn:hover {
  border-color: var(--modal-ring);
}
.obeya-select-sources-count {
  font-size: 0.7rem;
  color: var(--modal-accent);
  background: rgba(41, 216, 255, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  min-width: 1rem;
  text-align: center;
}

/* SRA form: expand modal height for vertical space */
.settings-modal.obeya-form-active {
  height: 90vh;
  max-height: 90vh;
}

/* Selected sources — grid: capa label column (auto-sized) | flowing team pills */
.obeya-source-pills {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0;
  margin-top: 0.4rem;
}
/* Left column: colored border + capa name + count badge */
.obeya-source-cap-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem 0.2rem 0.5rem;
  border-left: 2.5px solid hsl(var(--foreground) / 0.15);
}
.obeya-source-cap-label[data-cap="enlight"] { border-left-color: #5ba0d0; }
.obeya-source-cap-label[data-cap="cnx"] { border-left-color: #8bc34a; }
.obeya-source-cap-label[data-cap="web"] { border-left-color: #f0ad4e; }
.obeya-source-cap-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--modal-fg);
  white-space: nowrap;
}
.obeya-source-cap-count {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--modal-accent);
  background: rgba(41, 216, 255, 0.12);
  padding: 0.05rem 0.3rem;
  border-radius: 0.2rem;
  min-width: 1rem;
  text-align: center;
}
/* Right column: flowing team pills */
.obeya-source-cap-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0 0.15rem 0.6rem;
  min-width: 0;
}
/* Team pill: subtle container with team prefix + source names */
.obeya-source-team-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: hsl(var(--foreground) / 0.04);
  border: 1px solid hsl(var(--foreground) / 0.08);
  border-radius: 0.3rem;
  line-height: 1.4;
}
.obeya-source-team-name {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--modal-muted-fg);
  white-space: nowrap;
}
.obeya-source-item-name {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--modal-muted-fg);
  white-space: nowrap;
}

/* Orphaned source styling */
.obeya-source-cap-label--orphaned { border-left-color: #d9534f; }
.obeya-source-cap-count--orphaned { background: #d9534f; }
.obeya-source-team-pill--orphaned {
  border-color: rgba(217, 83, 79, 0.4);
  background: rgba(217, 83, 79, 0.1);
}
.obeya-source-team-pill--orphaned .obeya-source-item-name {
  color: var(--modal-muted-fg);
  text-decoration: line-through;
}
.obeya-source-orphan-delete {
  cursor: pointer;
  color: var(--modal-muted-fg);
  font-size: 1rem;
  line-height: 1;
  margin-left: 0.2rem;
  padding: 0 0.15rem;
}
.obeya-source-orphan-delete:hover { color: #d9534f; }

/* Warning tint on source count badge */
.obeya-select-sources-count.warn {
  background: #f0ad4e;
  color: #1a1a1a;
}
.obeya-select-sources-count.error {
  background: #ef5350;
  color: #fff;
}
/* Source count warning inside modal — left of Done btn */
.obeya-sources-modal-warning {
  font-size: 0.78rem;
  white-space: nowrap;
}
.obeya-sources-modal-warning--warn {
  color: #f0ad4e;
}
.obeya-sources-modal-warning--error {
  color: #ef5350;
}

/* Sources modal overlay */
.obeya-sources-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.obeya-sources-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}
.obeya-sources-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--modal-border);
}
.obeya-sources-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--modal-accent);
}
.obeya-sources-modal-close {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.obeya-sources-modal-close:hover {
  color: var(--modal-fg);
}
.obeya-sources-modal .obeya-source-tabs-container {
  flex: 1;
  overflow-y: auto;
  border: none;
  border-radius: 0;
}

/* Share To section */
.obeya-share-note {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--modal-muted-fg);
  font-style: italic;
}
.obeya-share-chip-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  min-height: 2rem;
  cursor: text;
}
.obeya-share-chip-area--readonly {
  pointer-events: none;
  opacity: 0.6;
}
.obeya-share-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.obeya-share-chip--team {
  background: rgba(255, 255, 255, 0.1);
  color: var(--modal-fg);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.obeya-share-chip-remove {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.1rem;
  margin-left: 0.1rem;
}
.obeya-share-chip-remove:hover {
  opacity: 1;
}
.obeya-share-input {
  flex: 1;
  min-width: 6rem;
  background: none;
  border: none;
  outline: none;
  color: var(--modal-fg);
  font-size: 0.8rem;
  padding: 0.15rem 0;
}
.obeya-share-input::placeholder {
  color: var(--modal-muted-fg);
  opacity: 0.6;
}
.obeya-share-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  margin-bottom: 0.2rem;
  max-height: 10rem;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}
.obeya-share-dropdown-option {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--modal-fg);
}
.obeya-share-dropdown-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* #262: team blocked from share because it lacks RBAC access to one or more
 * sources. Non-clickable, visually distinct from selectable items. Tooltip
 * (set via .title) names the blocking source(s). */
.obeya-share-dropdown-option--blocked {
  color: var(--modal-muted-fg);
  text-decoration: line-through;
  cursor: not-allowed;
  opacity: 0.55;
}
.obeya-share-dropdown-option--blocked:hover {
  background: transparent;
}

/* Confirmation overlay */
.settings-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-confirm-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  max-width: 420px;
  width: 90%;
  color: var(--modal-fg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.settings-confirm-modal header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.settings-confirm-modal h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  color: var(--modal-accent);
}

.settings-confirm-modal p {
  margin: 0 0 1rem;
  color: var(--modal-muted-fg);
  line-height: 1.5;
}

.settings-confirm-modal .confirm-zero-source-warning {
  background: rgba(234, 179, 8, 0.15);
  border-left: 3px solid #ca8a04;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
  color: #ca8a04;
}

.settings-confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.settings-confirm-actions .confirm-save,
.settings-confirm-actions .confirm-discard {
  padding: 0.6rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.settings-confirm-actions .confirm-save {
  background: var(--modal-accent);
  border: none;
  color: var(--modal-accent-fg);
}

.settings-confirm-actions .confirm-discard {
  background: transparent;
  border: 1px solid var(--modal-border);
  color: var(--modal-fg);
}

.settings-confirm-modal .confirm-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

/* Danger variant — zero-source exit warning */
.settings-confirm-modal--danger header h3 {
  color: #dc2626;
}
.settings-confirm-modal--danger .confirm-discard {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.settings-confirm-modal--danger .confirm-discard:hover {
  background: #b91c1c;
}

/* ================================================================
   Obeya Tab
   ================================================================ */

/* Heavy load badge — only shown when enabled count > heavy_threshold */
.obeya-heavy-badge {
  display: inline-block;
  min-width: calc(5.75rem + 13px);  /* 92px base + 13px inset so left edge aligns with cog, right edge with card edge */
  text-align: center;
  padding: 0.2rem 0.4rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(217, 74, 74, 0.15);
  color: #b33;
}

/* Row 1: search input fused with "+" button.
 * No inline padding — search row and agent-list rows both sit flush to the
 * parent panel's content edge so their left/right edges line up. */
.obeya-search-row {
  display: flex;
  align-items: stretch;
  margin-bottom: 0.5rem;
}

.obeya-search-row .settings-multiselect-input {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.obeya-create-btn {
  background: var(--modal-accent);
  color: var(--modal-accent-fg);
  border: none;
  width: calc(5.75rem + 13px);  /* 92px badge + 13px inset so left edge aligns with badge/cog, right edge with card edge */
  padding: 0;
  border-radius: 0 0.375rem 0.375rem 0;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.obeya-create-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.obeya-create-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============================================================================
   Obeya capability-view subtabs (議長 | SRA | 進行 | 確認) — Epic #230 Wave 1
   ========================================================================== */

.obeya-subtabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--modal-border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.obeya-subtab {
  background: none;
  border: none;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.55));
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;  /* Sit on the parent's bottom border */
  transition: color 0.15s ease, border-color 0.15s ease;
}

.obeya-subtab:hover {
  color: var(--modal-fg, inherit);
}

.obeya-subtab.active {
  color: var(--modal-accent, #5ba0d0);
  border-bottom-color: var(--modal-accent, #5ba0d0);
}

/* Minimal red dot on the エージェント subtab when no SRAs are enabled.
 * Hidden by default; JS toggles [hidden] via cachedObeyaSras.enabled_count.
 * Sits inline with the label so users landing in 議長 tab see the signal. */
.obeya-subtab-badge {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 0.45rem;
  border-radius: 50%;
  background: #e53935;
  vertical-align: middle;
}

.obeya-subtab-badge[hidden] {
  display: none;
}

.obeya-subtab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  padding-top: 0.75rem;
  /* Right gutter so card-shaped subsections (Persona, Flow) don't touch the
   * vertical scrollbar that lives on this panel's right edge. */
  padding-right: 0.5rem;
}

.obeya-subtab-panel.active {
  display: flex;
  flex-direction: column;
  overflow-y: auto;  /* scroll fix: each panel is its own scroll container */
}

.obeya-section-desc {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.55));
  line-height: 1.4;
}

/* Chairman (議長) panel */
.obeya-chairman-textarea {
  width: 100%;
  min-height: 8rem;
  box-sizing: border-box;
  padding: 0.5rem 0.625rem;
  background: var(--modal-input-bg, rgba(0, 0, 0, 0.25));
  color: var(--modal-fg, inherit);
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.12));
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.45;
  resize: vertical;
}

.obeya-chairman-textarea:focus {
  outline: none;
  border-color: var(--modal-accent, #5ba0d0);
}

/* Persona header row: title+desc (left, flex-grow) | counter | reset btn (right).
 * Counter is right-justified next to the reset button with a sensible gap;
 * both sit in the trailing-edge cluster so the title/desc claim the full
 * left side. */
.obeya-persona-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.obeya-persona-header-text {
  flex: 1;
  min-width: 0;
}

.obeya-persona-header-text .obeya-subsection-title {
  margin: 0 0 0.25rem;
}

.obeya-persona-header-text .obeya-section-desc {
  margin: 0;
}

.obeya-chairman-counter {
  font-size: 0.75rem;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.55));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.obeya-chairman-counter--warn {
  color: #f0ad4e;
}

.obeya-chairman-reset {
  background: transparent;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.6));
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  padding: 0.3rem 0.7rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.obeya-chairman-reset:hover {
  background: var(--modal-hover-bg, rgba(255, 255, 255, 0.06));
  color: var(--modal-fg, inherit);
}

.obeya-section-coming-soon {
  margin: 0;
  font-size: 0.85rem;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.5));
  font-style: italic;
}

/* Chairman-tab sub-sections (Persona / Flow / Speaking order) */
.obeya-subsection {
  margin-bottom: 1.75rem;
}

.obeya-subsection:last-child {
  margin-bottom: 0;
}

/* Horizontal divider between non-card subsections. Card subsections
 * (--persona, --flow) have their own border via the card chrome below, so
 * they're excluded from this rule to avoid a hairline overlapping the card
 * border. */
.obeya-subsection + .obeya-subsection:not(.obeya-subsection--persona):not(.obeya-subsection--flow) {
  padding-top: 1.5rem;
  border-top: 1px solid var(--modal-border, rgba(255, 255, 255, 0.08));
}

.obeya-subsection-title {
  /* Top-level section heading inside the 議長 tab (Persona, Flow). Larger and
   * heavier than the inner control labels so the hierarchy reads:
   *   subsection title > control label (Default rounds / Summary / Speaking order). */
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--modal-accent, #5ba0d0);
}

/* Control-label heading nested inside a card (Default rounds / Summary /
 * Speaking order). One canonical style across the three. */
.obeya-subsection--flow .obeya-flow-label,
.obeya-subsection--flow .obeya-order-header-text .obeya-subsection-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--modal-fg, inherit);
  margin: 0;
}

/* Restore the icon+text flex layout for the Speaking-order title-with-icon. */
.obeya-subsection--flow .obeya-order-header-text .obeya-subsection-title--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.obeya-subsection--placeholder {
  opacity: 0.45;
}

/* 発言順序 header: title+description on the left, mode toggle right-justified.
 * Full-width to match the list and the Flow grid below. */
.obeya-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 0 0 0.6rem;
}

.obeya-order-header-text {
  /* Shrink allowed (flex: 1 1 auto) + min-width:0 so a long JA/EN
   * description wraps within the left column instead of pushing the
   * toggle off the right edge. */
  flex: 1 1 auto;
  min-width: 0;
}

.obeya-order-header-text .obeya-subsection-title {
  margin: 0 0 0.25rem;
}

.obeya-order-header-text .obeya-section-desc {
  margin: 0;
}

/* Speaking-order controls: segmented toggle (Specified | Random) + list */
.obeya-order-toggle-with-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;  /* tooltip anchor */
}

.obeya-order-toggle {
  display: inline-flex;
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  border-radius: 0.35rem;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.obeya-order-info-icon {
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.55));
  font-size: 0.95rem;
  cursor: help;
  position: relative;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.obeya-order-info-icon:hover {
  color: var(--modal-accent, #5ba0d0);
}

.obeya-order-info-icon:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  padding: 0.6rem 0.75rem;
  background: var(--modal-bg, #1e1e1e);
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--modal-fg, inherit);
  white-space: pre-line;
  z-index: 100;
  pointer-events: none;
}

/* Inside the wrapper or order header — no extra bottom margin. */
.obeya-order-toggle-with-info .obeya-order-toggle,
.obeya-order-header .obeya-order-toggle {
  margin-bottom: 0;
  align-self: center;
}

.obeya-order-toggle-btn {
  background: transparent;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.6));
  border: none;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  flex: 1;
  min-width: 5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.obeya-order-toggle-btn + .obeya-order-toggle-btn {
  border-left: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
}

.obeya-order-toggle-btn:hover:not(.active) {
  color: var(--modal-fg, inherit);
  background: var(--modal-hover-bg, rgba(255, 255, 255, 0.05));
}

.obeya-order-toggle-btn.active {
  background: var(--modal-accent, #5ba0d0);
  color: var(--modal-accent-fg, #0b1220);
}

.obeya-order-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Hidden via [hidden] attribute when Random is selected */
.obeya-order-list[hidden] {
  display: none;
}

.obeya-order-serial-warning {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.65));
  background: rgba(240, 173, 78, 0.08);
  border-left: 3px solid rgba(240, 173, 78, 0.5);
  border-radius: 0 0.25rem 0.25rem 0;
  line-height: 1.4;
}

.obeya-order-serial-warning[hidden] {
  display: none;
}

/* Styled to match .obeya-agent-row — same padding, border radius, hover feel.
 * Grid: numbered-badge | name | author | reorder-btns. */
.obeya-order-item {
  display: grid;
  grid-template-columns: auto 1fr 12rem auto;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding: 0.75rem;
  background: var(--modal-input-bg, rgba(0, 0, 0, 0.18));
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.08));
  border-radius: 0.375rem;
  font-size: 0.85rem;
  transition: border-color 0.2s ease;
}

.obeya-order-item:hover {
  border-color: var(--modal-ring, rgba(255, 255, 255, 0.3));
}

.obeya-order-item > * {
  min-width: 0;
  overflow: hidden;
}

/* Swap flash — 5s fade-out. Triggered after optimistic reorder. */
@keyframes obeya-order-flash-moved {
  0%   { background: rgba(76, 175, 120, 0.32); }
  100% { background: var(--modal-input-bg, rgba(0, 0, 0, 0.18)); }
}

@keyframes obeya-order-flash-swapped {
  0%   { border-color: rgba(91, 160, 208, 0.9); box-shadow: 0 0 0 1px rgba(91, 160, 208, 0.6) inset; }
  100% { border-color: var(--modal-border, rgba(255, 255, 255, 0.08)); box-shadow: none; }
}

.obeya-order-item--moved {
  animation: obeya-order-flash-moved 5s ease-out;
}

.obeya-order-item--swapped {
  animation: obeya-order-flash-swapped 5s ease-out;
}

.obeya-order-item-info {
  min-width: 0;
  overflow: hidden;
}

.obeya-order-item-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--modal-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.obeya-order-item-author {
  font-size: 0.75rem;
  color: var(--modal-muted-fg);
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}

.obeya-order-item-btns {
  display: inline-flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.obeya-order-btn {
  background: transparent;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.65));
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  border-radius: 0.25rem;
  width: 1.6rem;
  height: 1.4rem;
  padding: 0;
  line-height: 1;
  font-size: 0.65rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.obeya-order-btn:hover:not(:disabled) {
  background: var(--modal-hover-bg, rgba(255, 255, 255, 0.07));
  color: var(--modal-fg, inherit);
}

.obeya-order-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.obeya-order-empty {
  padding: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.5));
  font-style: italic;
}

/* Card chrome for top-level 議長 subsections (Persona, Flow). Uses
 * --card-border so the edge is visible against --modal-input-bg fills. The
 * generic subsection-divider rule above excludes card subsections, so no
 * border restate is needed even when this card follows another subsection. */
.obeya-subsection--persona,
.obeya-subsection--flow {
  background: var(--modal-input-bg, rgba(0, 0, 0, 0.18));
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  padding: 1.1rem 1.25rem;
}

/* Speaking-order block nested inside the Flow card:
 *   - drop the standalone card chrome it'd get as a top-level subsection
 *   - add an inner divider above to separate it from rounds/summary */
.obeya-subsection--flow .obeya-subsection--order {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--modal-border, rgba(255, 255, 255, 0.08));
  margin-bottom: 0;
}

.obeya-flow-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.obeya-flow-header > .obeya-subsection-title {
  margin: 0;
  flex-shrink: 0;
}

.obeya-flow-header-desc {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.obeya-flow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Vertical divider between 既定のラウンド数 and 総括タイミング.
 * Applied as padding-left + border-left on the 2nd cell so the rule
 * lives inside the right cell's left edge, centered in the grid gap. */
.obeya-flow-grid > .obeya-flow-row + .obeya-flow-row {
  padding-left: 1.5rem;
  border-left: 1px solid var(--modal-border, rgba(255, 255, 255, 0.08));
}

/* Single-column fallback for very narrow modal widths — drop the rule,
 * revert to horizontal stacking. */
@media (max-width: 480px) {
  .obeya-flow-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .obeya-flow-grid > .obeya-flow-row + .obeya-flow-row {
    padding-left: 0;
    border-left: none;
  }
}

.obeya-flow-row {
  min-width: 0;
}

.obeya-flow-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--modal-fg, inherit);
}

.obeya-flow-rounds {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  border-radius: 0.35rem;
  overflow: hidden;
  margin-top: 0.3rem;
}

.obeya-flow-rounds-btn {
  background: transparent;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.7));
  border: none;
  padding: 0.25rem 0.7rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.obeya-flow-rounds-btn:hover:not(:disabled) {
  color: var(--modal-fg, inherit);
  background: var(--modal-hover-bg, rgba(255, 255, 255, 0.07));
}

.obeya-flow-rounds-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.obeya-flow-rounds-input {
  width: 3rem;
  text-align: center;
  background: var(--modal-input-bg, rgba(0, 0, 0, 0.2));
  color: var(--modal-fg, inherit);
  border: none;
  border-left: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  border-right: 1px solid var(--modal-border, rgba(255, 255, 255, 0.15));
  font-size: 0.9rem;
  padding: 0.25rem 0.25rem;
  -moz-appearance: textfield;
}

/* Hide spinner arrows — we have explicit ±  buttons */
.obeya-flow-rounds-input::-webkit-outer-spin-button,
.obeya-flow-rounds-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.obeya-flow-summary-toggle {
  margin-top: 0.3rem;
  margin-bottom: 0;  /* override .obeya-order-toggle's bottom margin */
}

/* --- Lucide icon ornaments (Flow / Speaking-order) ---------------------- */

/* Small accent-tinted glyph next to a control label or section heading. */
.obeya-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--modal-accent, #5ba0d0);
  flex-shrink: 0;
}
.obeya-section-icon > svg {
  width: 1rem;
  height: 1rem;
}

/* Speaking-order heading with leading icon */
.obeya-subsection-title--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* ⓘ-prefixed muted hint under a Flow control */
.obeya-flow-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.55));
}
.obeya-flow-hint-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--modal-muted-fg, rgba(255, 255, 255, 0.55));
  margin-top: 0.05rem;
}
.obeya-flow-hint-icon > svg {
  width: 0.85rem;
  height: 0.85rem;
}

/* ✓ glyph on the active Summary-toggle button only */
.obeya-summary-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.obeya-summary-check {
  display: none;
  align-items: center;
  flex-shrink: 0;
}
.obeya-summary-check > svg {
  width: 0.85rem;
  height: 0.85rem;
}
.obeya-summary-toggle-btn.active .obeya-summary-check {
  display: inline-flex;
}

/* Numbered position badge on speaking-order rows */
.obeya-order-item-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--modal-accent, #5ba0d0);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--modal-accent, #5ba0d0);
  background: transparent;
  flex-shrink: 0;
}

/* Row 2: active-only filter (left) + heavy badge (right) */
.obeya-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 4px;  /* match agent-list padding so row width = agent card width */
}

/* Segmented "All | Active" filter toggle */
.obeya-filter-chips {
  display: inline-flex;
  gap: 0.35rem;
}

.obeya-filter-chip {
  background: transparent;
  color: var(--modal-muted-fg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.obeya-filter-chip.active {
  background: var(--modal-accent);
  color: var(--modal-accent-fg);
  border-color: var(--modal-accent);
}

.obeya-filter-chip:not(.active):hover {
  background: rgba(255, 255, 255, 0.06);
}

.obeya-refresh-btn {
  background: transparent;
  color: var(--modal-muted-fg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.obeya-refresh-btn:hover {
  color: var(--modal-accent);
  background: rgba(255, 255, 255, 0.06);
}

/* Agent list */
.obeya-agent-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  max-height: calc(80vh - 240px);
}

.obeya-agent-row {
  display: grid;
  /* avatar | info (name + status pill) | author | controls */
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  background: var(--modal-input-bg);
  transition: border-color 0.2s ease;
}

/* Avatar and controls have intrinsic size — only info + author should clip */
.obeya-agent-row > .obeya-agent-info,
.obeya-agent-row > .obeya-agent-author {
  min-width: 0;
  overflow: hidden;
}

.obeya-agent-row:hover {
  border-color: var(--modal-ring);
}

/* Identicon avatar host — renderIdenticon() injects an inline SVG sized to
 * fill this circle. The SVG itself is the circle; we just constrain the box. */
.obeya-agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
  border-radius: 50%;
}
.obeya-agent-avatar > svg {
  width: 100%;
  height: 100%;
  display: block;
}

.obeya-agent-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--modal-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.obeya-agent-author {
  font-size: 0.75rem;
  color: var(--modal-muted-fg);
  white-space: nowrap;
  text-align: right;
}

/* Agent info (name column — grid cell 1) */
.obeya-agent-info {
  min-width: 0;
  overflow: hidden;
}

/* Briefing status badges (list view) */
.obeya-briefing-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  text-align: right;
  white-space: nowrap;
}

.obeya-briefing-badge--done {
  background: rgba(41, 216, 255, 0.15);
  color: var(--modal-accent);
}

.obeya-briefing-badge--prepping {
  background: rgba(255, 180, 41, 0.18);
  color: #ffb429;
  animation: obeya-badge-pulse 1.8s ease-in-out infinite;
}

.obeya-briefing-badge--queued {
  background: rgba(255, 180, 41, 0.10);
  color: #c89a2e;
}

@keyframes obeya-badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.obeya-briefing-badge--failed {
  background: rgba(255, 80, 80, 0.18);
  color: #ff6b6b;
}

.obeya-briefing-badge--failed-noprep {
  background: rgba(255, 80, 80, 0.25);
  color: #ff5555;
}

.obeya-briefing-badge--none {
  background: rgba(128, 128, 128, 0.2);
  color: var(--modal-muted-fg);
}

/* Badge container for stacked badges (list view grid column 2 + edit form) */
/* Badge container for stacked badges (edit form: compact) */
.obeya-agent-badges {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
}

/* In list view: badges now live inside .obeya-agent-info, BELOW the name.
 * Render as an inline row of small pills, left-aligned, with a small gap
 * between the name above and the pill(s). */
.obeya-agent-row .obeya-agent-info > .obeya-agent-badges {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

/* Pills under the name use a smaller, lower-emphasis treatment so the name
 * remains the primary signal. */
.obeya-agent-row .obeya-agent-info .obeya-briefing-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
}

/* Badge as hyperlink — underline always for discoverability */
a.obeya-briefing-badge {
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
a.obeya-briefing-badge:hover {
  opacity: 0.85;
}

.obeya-empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--modal-muted-fg);
  font-style: italic;
}
.obeya-loading-icon {
  display: flex;
  justify-content: center;
  align-items: center;
}
.obeya-loading-icon svg {
  width: 32px;
  height: 32px;
  opacity: 0.3;
  animation: obeya-pulse 1.5s ease-in-out infinite;
}
@keyframes obeya-pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.5; }
}

/* Form layout */
.obeya-form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 1.0rem;
}

/* Name + Avatar identity row (75/25 split, vertically centered) */
.obeya-identity-row {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.obeya-identity-name {
  flex: 3;
  min-width: 0;
}

.obeya-identity-avatar {
  flex: 0 0 auto;
}

/* Avatar preview + clear button wrapper */
.obeya-avatar-wrapper {
  position: relative;
  display: inline-block;
}

.obeya-avatar-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--modal-input-bg, #2a2a2a);
  border: 2px solid var(--modal-border, #444);
  transition: border-color 0.15s;
}

.obeya-avatar-preview:hover {
  border-color: var(--modal-ring, #6366f1);
}

.obeya-avatar-preview img,
.obeya-avatar-preview svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Persistent author name label above message content */
.step .ai-message .ao-author-label {
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted, #888);
  margin-bottom: 2px;
}

/* X button overlay to clear custom avatar */
.obeya-avatar-clear-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--modal-bg, #1a1a1a);
  border: 1px solid var(--modal-border, #444);
  color: var(--modal-muted-fg, #999);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.obeya-avatar-clear-btn svg {
  width: 10px;
  height: 10px;
}

.obeya-avatar-clear-btn:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.obeya-instruction-textarea {
  min-height: 10rem;
}

/* Header action buttons (right-aligned in capability-detail-header) */
.obeya-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.obeya-header-prep-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  color: var(--modal-muted-fg);
  cursor: pointer;
  transition: opacity 0.15s;
}
.obeya-header-prep-btn:hover:not(:disabled) {
  opacity: 0.85;
  border-color: var(--accent-color, #5fc9c1);
}
.obeya-header-prep-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.obeya-header-prep-btn--abort {
  background: rgba(220, 60, 60, 0.15);
  border-color: rgba(220, 60, 60, 0.4);
  color: #dc3c3c;
}
.obeya-header-prep-btn--abort:hover:not(:disabled) {
  opacity: 0.85;
  border-color: #dc3c3c;
}

/* Lock form inputs while prep is in progress */
.obeya-form--prepping input,
.obeya-form--prepping textarea,
.obeya-form--prepping .obeya-select-sources-btn,
.obeya-form--prepping .obeya-share-input {
  pointer-events: none;
  opacity: 0.4;
}

.obeya-prep-log-link {
  font-size: 0.8rem;
  color: var(--accent-color, #5fc9c1);
  text-decoration: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
  text-decoration: underline;
}
.obeya-prep-log-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.obeya-header-save-btn {
  padding: 0.4rem 1.2rem;
  border-radius: 0.375rem;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--modal-accent);
  border: none;
  color: var(--modal-accent-fg);
  cursor: pointer;
}
.obeya-header-save-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* .obeya-header-cancel-btn removed — back arrow + save dialog serve the same purpose */

.obeya-form-delete-btn {
  padding: 0.5rem 1.2rem;
  border-radius: 0.375rem;
  font-weight: 500;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid rgba(198, 40, 40, 0.4);
  color: #ef5350;
  cursor: pointer;
  align-self: flex-end;
}
.obeya-form-delete-btn:hover:not(:disabled) {
  background: rgba(198, 40, 40, 0.15);
}
.obeya-form-delete-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Read-only form state (non-owner, non-manager) */
.obeya-readonly-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
  border-radius: 0.375rem;
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.25);
  color: var(--modal-muted-fg);
  font-size: 0.78rem;
  line-height: 1.4;
}
.obeya-readonly-warning svg {
  flex-shrink: 0;
  color: rgba(255, 193, 7, 0.7);
}
.obeya-form--readonly input:disabled,
.obeya-form--readonly textarea:disabled,
.obeya-form--readonly button:disabled,
.obeya-form--readonly .obeya-select-sources-btn:disabled,
.obeya-form--readonly .obeya-share-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.obeya-form--readonly .obeya-header-save-btn:disabled,
.obeya-form--readonly .obeya-header-prep-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.obeya-coming-soon-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  background: rgba(128, 128, 128, 0.2);
  color: var(--modal-muted-fg);
  font-style: italic;
}

.obeya-prep-spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border: 2px solid rgba(128, 128, 128, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: obeya-spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes obeya-spin {
  to { transform: rotate(360deg); }
}

.obeya-option-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.obeya-option-label {
  font-size: 0.9rem;
  color: var(--modal-fg);
  white-space: nowrap;
}

/* Compact pill selector inside options half */
.obeya-mode-pills {
  margin-top: 0;
}

.obeya-mode-pills .settings-mode-pill {
  padding: 0.375rem 0.625rem;
  font-size: 0.85rem;
}

/* Web source tab panel content */
.obeya-web-tab-content {
  padding: 1.5rem;
}
.obeya-web-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  cursor: pointer;
  background: var(--modal-input-bg);
}
.obeya-web-toggle-row:hover {
  background: var(--modal-hover-bg, rgba(255,255,255,0.05));
}
.obeya-web-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.obeya-web-toggle-title {
  font-size: 0.9rem;
  font-weight: 500;
}
.obeya-web-toggle-desc {
  font-size: 0.8rem;
  color: var(--modal-muted-fg);
}
.obeya-toggle-switch {
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 0.75rem;
  background: var(--modal-border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.obeya-toggle-switch.active {
  background: var(--accent-color, #4ecdc4);
}
.obeya-toggle-knob {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  transition: transform 0.2s;
}
.obeya-toggle-switch.active .obeya-toggle-knob {
  transform: translateX(1.125rem);
}

/* Source tab navigation */
.obeya-source-tabs-container {
  margin-top: 0.25rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  overflow: hidden;
}

.obeya-source-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--modal-border);
  background: var(--modal-input-bg);
  overflow-x: auto;
}

.obeya-source-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--modal-muted-fg);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.obeya-source-tab:hover {
  color: var(--modal-fg);
}

.obeya-source-tab.active {
  color: var(--modal-accent);
  border-bottom-color: var(--modal-accent);
}

.obeya-source-tab .capability-icon {
  display: flex;
}

.obeya-source-tab .capability-icon svg {
  width: 1rem;
  height: 1rem;
}

.obeya-source-tab-count {
  font-size: 0.75rem;
  color: var(--modal-accent);
  background: rgba(41, 216, 255, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  min-width: 1.2rem;
  text-align: center;
}

.obeya-source-panels {
  min-height: 10rem;
}

.obeya-source-tab-panel {
  display: none;
  padding: 0.75rem;
}

.obeya-source-tab-panel.active {
  display: block;
}

/* Reuse scope-chip styles from capability detail view */
.obeya-source-tab-panel .scope-selector-search-row {
  margin-bottom: 0.5rem;
}

.obeya-source-tab-panel .scope-chip-grid {
  margin-top: 0.25rem;
}

.obeya-source-tab-panel .scope-grouped-container {
  margin-top: 0.25rem;
}

/* (Share To / Visibility CSS moved to global section above) */

/* Old prep-row / prestudy / briefing-status removed — prep now in header actions */

/* Old .obeya-form-actions removed — buttons now in .obeya-header-actions */

/* Web Search Acknowledgment Popup */
.web-search-acknowledge-modal ul {
  margin: 0.5rem 0 1rem 1.2rem;
  padding: 0;
  color: var(--modal-muted-fg);
  line-height: 1.6;
}

.web-search-acknowledge-modal li {
  margin-bottom: 0.25rem;
}

.web-search-acknowledge-modal .privacy-note {
  font-size: 0.85rem;
  color: var(--modal-muted-fg);
  font-style: italic;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--modal-border);
}

/* Settings icon button in header */
.settings-icon-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  position: relative;
}

.settings-icon-button:hover {
  opacity: 1;
}

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

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  .settings-modal {
    width: 90vw;
    max-height: 85vh;
  }

  .settings-header {
    padding: 1rem;
  }

  .settings-header h2 {
    font-size: 1.25rem;
  }

  .settings-tabs {
    padding: 0 1rem;
  }

  .settings-tab {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .settings-content {
    padding: 1rem;
  }

  .settings-char-counter {
    flex-direction: column;
    gap: 0.5rem;
  }

  .settings-char-warning {
    max-width: 100%;
    text-align: left;
  }
}

/* Accessibility: Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .settings-overlay,
  .settings-modal,
  .settings-close,
  .settings-tab,
  .settings-textarea {
    transition: none;
  }
}

/* ==============================================================================
   Settings Modal Loading/Error States (state machine for instant modal open)
   ============================================================================== */

/* Loading state - subtle shimmer effect on disabled inputs */
.settings-loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.settings-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 25%,
    rgba(128, 128, 128, 0.1) 50%,
    transparent 75%
  );
  background-size: 200% 100%;
  animation: settings-shimmer 1.5s infinite;
  border-radius: inherit;
  pointer-events: none;
}

@keyframes settings-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error banner styling */
.settings-error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-error-message {
  color: #ef4444;
  font-size: 0.9rem;
}

.settings-error-retry {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
  padding: 0.4rem 0.8rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.settings-error-retry:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* Disabled inputs overlay indication */
.settings-inputs-disabled .settings-content {
  position: relative;
}

/* Disabled textarea styling */
.settings-textarea:disabled {
  background: var(--modal-input-bg);
  cursor: not-allowed;
}

/* ==============================================================================
   Capabilities UI (Claude.ai-style connectors)
   ============================================================================== */

/* Capabilities content container */
.capabilities-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

/* Capabilities list container */
.capabilities-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Individual capability row */
.capability-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  transition: border-color 0.2s ease;
}

.capability-row:hover {
  border-color: var(--modal-ring);
}

/* Capability icon */
.capability-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--modal-accent);
}

.capability-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Capability info section */
.capability-info {
  flex: 1;
  min-width: 0;
}

.capability-name {
  font-weight: 500;
  color: var(--modal-fg);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.capability-desc {
  color: var(--modal-muted-fg);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Capability badge system: info (gray), warning (yellow), error (red) */
.capability-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-style: italic;
}

.capability-badge--info {
  background: rgba(128, 128, 128, 0.2);
  color: var(--modal-muted-fg);
}

.capability-badge--warning {
  background: rgba(234, 179, 8, 0.2);
  color: #ca8a04;
}

.capability-badge--error {
  background: rgba(239, 68, 68, 0.2);
  color: #dc2626;
}

.capability-badge--beta {
  background: rgba(240, 197, 67, 0.2);
  color: #ca8a04;
  font-style: normal;
  font-weight: 500;
}

.capability-badge--alpha {
  background: rgba(240, 67, 87, 0.2);
  color: #dc2626;
  font-style: normal;
  font-weight: 500;
}

/* Legacy class for backward compatibility */
.capability-disabled-reason {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.125rem 0.5rem;
  background: rgba(128, 128, 128, 0.2);
  border-radius: 0.25rem;
  font-size: 0.75rem;
  color: var(--modal-muted-fg);
  font-style: italic;
}

/* Memory capability detail — feature toggle rows */
.memory-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.memory-toggle-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  transition: border-color 0.2s ease;
}

.memory-toggle-row:hover {
  border-color: var(--modal-ring);
}

.memory-toggle-info {
  flex: 1;
  min-width: 0;
}

.memory-toggle-label {
  font-weight: 500;
  color: var(--modal-fg);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.memory-toggle-desc {
  color: var(--modal-muted-fg);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Capability actions */
.capability-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Config button (cogwheel) */
.capability-config-btn {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: color 0.2s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.capability-config-btn:hover:not(:disabled) {
  color: var(--modal-accent);
  background: rgba(128, 128, 128, 0.1);
}

.capability-config-btn:disabled,
.capability-config-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.capability-config-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Toggle switch */
.capability-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.capability-toggle.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.capability-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.capability-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(128, 128, 128, 0.3);
  border-radius: 24px;
  transition: background-color 0.2s ease;
}

.capability-toggle-slider::before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.capability-toggle input:checked + .capability-toggle-slider {
  background-color: var(--modal-ring);
}

.capability-toggle input:checked + .capability-toggle-slider::before {
  transform: translateX(20px);
}

.capability-toggle input:disabled + .capability-toggle-slider {
  cursor: not-allowed;
}

/* Capability detail view */
.capability-detail-view {
  display: flex;
  flex-direction: column;
  gap: 1.0rem;
  width: 100%;
}

/* Back link */
.capability-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.2s ease;
}

.capability-back-link:hover {
  color: var(--modal-accent);
}

.capability-back-link svg {
  width: 1rem;
  height: 1rem;
}

/* Detail header */
.capability-detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--modal-border);
  flex-shrink: 0;
}

.capability-detail-title h3 {
  margin: 0;
  font-weight: 500;
  color: var(--modal-fg);
  font-size: 1.1rem;
}

.capability-detail-title p {
  margin: 0.25rem 0 0;
  color: var(--modal-muted-fg);
  font-size: 0.9rem;
}

/* Scopes section */
.capability-scopes-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.capability-scopes-label {
  font-weight: 500;
  color: var(--modal-accent);
  font-size: 0.95rem;
}

.capability-scopes-hint {
  color: var(--modal-muted-fg);
  font-size: 0.85rem;
  margin: 0;
  font-style: italic;
}

/* Scopes list */
.capability-scopes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

/* Individual scope row */
.capability-scope-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.capability-scope-row:hover {
  border-color: var(--modal-ring);
}

.capability-scope-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.125rem;
  cursor: pointer;
  accent-color: var(--modal-ring);
}

.capability-scope-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.capability-scope-label {
  font-weight: 500;
  color: var(--modal-fg);
  font-size: 0.9rem;
}

.capability-scope-desc {
  color: var(--modal-muted-fg);
  font-size: 0.8rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ==============================================================================
   System Status Warning Indicator (Info Button degraded state)
   ============================================================================== */

/* Warning state for info button - just swaps icon, no additional styling needed */
#custom-help-button.system-degraded {
  /* Icon swap handled by JS, class used for state tracking */
}

/* Hide the loading placeholder (animate-pulse div inside avatar containers) */
/* This is the gray pulsing circle that appears before avatar loads */
span.relative.flex.shrink-0 span:has(> .animate-pulse) {
  display: none !important;
}
span.relative.flex.shrink-0 .animate-pulse {
  display: none !important;
}

/* Hide pulsing progress dot during step execution (left of latest message) */
/* Target: <span class="inline-block h-3.5 w-3.5 bg-foreground rounded-full animate-pulse"> */
span.inline-block.rounded-full.animate-pulse.bg-foreground {
  display: none !important;
}

/* ==============================================================================
   Sources Checked Section (Nested inside References)
   ============================================================================== */

/* Top-level sources checked section */
.sources-checked-section {
  margin-bottom: 1rem;
  background: rgba(20, 20, 20, 0.4);
  border-radius: 0.375rem;
  overflow: hidden;
}

.sources-checked-summary {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--modal-muted-fg, #888);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sources-checked-summary::-webkit-details-marker {
  display: none;
}

.sources-checked-section .sources-checked-summary::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--modal-accent, #29d8ff);
  border-bottom: 2px solid var(--modal-accent, #29d8ff);
  transform: rotate(-45deg);
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
}

.sources-checked-section[open] .sources-checked-summary::before {
  transform: rotate(45deg);
}

.sources-checked-summary:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--modal-fg, #e0e0e0);
}

.sources-checked-content {
  padding: 0.5rem 0.875rem 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Capability level */
.sources-cap,
.sources-cap-zero {
  background: transparent;
  border-left: 2px solid rgba(41, 216, 255, 0.2);
  padding-left: 0.5rem;
}

.sources-cap-zero {
  opacity: 0.6;
}

.sources-cap .sources-cap-summary,
.sources-cap-zero .sources-cap-summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--modal-fg, #e0e0e0);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

.sources-cap .sources-cap-summary::-webkit-details-marker,
.sources-cap-zero .sources-cap-summary::-webkit-details-marker {
  display: none;
}

.sources-cap .sources-cap-summary::before,
.sources-cap-zero .sources-cap-summary::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
}

.sources-cap[open] .sources-cap-summary::before,
.sources-cap-zero[open] .sources-cap-summary::before {
  transform: rotate(45deg);
}

.sources-cap .sources-cap-summary:hover,
.sources-cap-zero .sources-cap-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.sources-cap-content {
  padding: 0.375rem 0 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Category level */
.sources-cat,
.sources-cat-zero {
  background: transparent;
}

.sources-cat-zero {
  opacity: 0.5;
}

.sources-cat .sources-cat-summary,
.sources-cat-zero .sources-cat-summary {
  padding: 0.375rem 0.625rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--modal-fg, #e0e0e0);
  font-size: 0.8125rem;
  font-weight: 400;
  transition: background-color 0.2s ease;
}

.sources-cat .sources-cat-summary::-webkit-details-marker,
.sources-cat-zero .sources-cat-summary::-webkit-details-marker {
  display: none;
}

.sources-cat .sources-cat-summary::before,
.sources-cat-zero .sources-cat-summary::before {
  content: '';
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
}

.sources-cat[open] .sources-cat-summary::before,
.sources-cat-zero[open] .sources-cat-summary::before {
  transform: rotate(45deg);
}

.sources-cat .sources-cat-summary:hover,
.sources-cat-zero .sources-cat-summary:hover {
  background: rgba(255, 255, 255, 0.02);
}

.sources-cat-content {
  padding: 0.25rem 0 0.375rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Individual source items */
.source-item {
  padding: 0.25rem 0.5rem;
  color: var(--modal-muted-fg, #aaa);
  font-size: 0.75rem;
  line-height: 1.3;
}

/* ==============================================================================
   Collapsible References Section
   ============================================================================== */

.references-collapsible {
  margin-top: 1.5rem;
  border: 1px solid var(--modal-border, rgba(255, 255, 255, 0.1));
  border-radius: 0.5rem;
  background: var(--modal-input-bg, rgba(30, 30, 30, 0.6));
  overflow: hidden;
}

.references-collapsible summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--modal-muted-fg, #888);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease;
}

.references-collapsible summary::-webkit-details-marker {
  display: none;
}

.references-collapsible > summary::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  margin-right: 0.25rem;
}

.references-collapsible[open] > summary::before {
  transform: rotate(45deg);
}

.references-collapsible summary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--modal-fg, #e0e0e0);
}

.references-collapsible summary .ref-icon {
  display: flex;
  align-items: center;
  color: var(--modal-accent, #29d8ff);
}

.references-collapsible summary .ref-count {
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  background: rgba(41, 216, 255, 0.15);
  color: var(--modal-accent, #29d8ff);
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.references-content {
  padding: 0.75rem 1rem 1rem 1rem;
  border-top: 1px solid var(--modal-border, rgba(255, 255, 255, 0.1));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.references-content .ref-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  color: var(--modal-fg, #e0e0e0);
  font-size: 0.9rem;
  line-height: 1.4;
}

.references-content .ref-item .ref-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  background: rgba(41, 216, 255, 0.15);
  color: var(--modal-accent, #29d8ff);
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.references-content .ref-item a {
  color: var(--modal-accent, #29d8ff);
  text-decoration: none;
  transition: color 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 48ch;
  display: inline-block;
  vertical-align: middle;
}

.references-content .ref-item a:hover {
  color: #78e6ff;
  text-decoration: underline;
}

/* Ref section containers (Cited vs Unused partitions) */
.ref-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ref-unused-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--modal-border, rgba(255, 255, 255, 0.1));
}

.ref-unused-header {
  color: var(--modal-muted-fg, #888);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ref-item.ref-unused {
  color: var(--modal-muted-fg, #888);
}

.ref-item.ref-unused a {
  color: var(--modal-muted-fg, #888);
}

.ref-item.ref-unused a:hover {
  color: #78e6ff;
}

/* ==============================================================================
   Chip-Checkbox Grid for Source Selection (redesigned detail view)
   ============================================================================== */

/* Header row with back button and title only */
.scope-selector-header,
.capability-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.scope-selector-header .capability-back-link {
  flex-shrink: 0;
}

.scope-selector-header-info {
  flex: 1;
  min-width: 0;
}

.scope-selector-header-info h3 {
  margin: 0;
  font-weight: 500;
  color: var(--modal-fg);
  font-size: 1rem;
}

.scope-selector-header-info p {
  margin: 0.125rem 0 0;
  color: var(--modal-muted-fg);
  font-size: 0.8rem;
}

/* Action buttons in search row */
.scope-selector-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.scope-selector-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.scope-selector-btn-primary {
  background: var(--modal-ring);
  color: var(--modal-accent-fg);
  border: none;
}

.scope-selector-btn-primary:hover {
  filter: brightness(1.1);
}

.scope-selector-btn-secondary {
  background: transparent;
  color: var(--modal-muted-fg);
  border: 1px solid var(--modal-border);
}

.scope-selector-btn-secondary:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--modal-fg);
}

/* Search bar + actions + count row */
.scope-selector-search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.scope-selector-search-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  color: var(--modal-input-fg);
  font-size: 0.85rem;
}

.scope-selector-search-row input:focus {
  outline: none;
  border-color: var(--modal-ring);
}

.scope-selector-search-row input::placeholder {
  color: var(--modal-muted-fg);
}

.scope-selector-search-row .scope-selector-count {
  font-size: 0.8rem;
  color: var(--modal-muted-fg);
  white-space: nowrap;
  flex-shrink: 0;
}

.scope-selector-search-row .scope-selector-count strong {
  color: var(--modal-accent);
}

/* "All | Active" segmented toggle for source selection */
.scope-filter-toggle {
  display: inline-flex;
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  overflow: hidden;
  flex-shrink: 0;
}
.scope-filter-toggle-btn {
  background: transparent;
  color: var(--modal-muted-fg);
  border: none;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.scope-filter-toggle-btn.active {
  background: var(--modal-accent);
  color: var(--modal-accent-fg);
}
.scope-filter-toggle-btn:not(.active):hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Chip grid container - use CSS Grid for consistent column widths */
.scope-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  max-height: calc(80vh - 280px);
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* Individual scope chip - fixed size, don't stretch */
.scope-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-width: 0;
  max-width: 100%;
}

.scope-chip:hover {
  background: rgba(128, 128, 128, 0.15);
  border-color: var(--modal-muted-fg);
}

.scope-chip.selected {
  background: rgba(41, 216, 255, 0.1);
  border-color: var(--modal-accent);
}

.scope-chip.selected:hover {
  background: rgba(41, 216, 255, 0.15);
}

.scope-chip.hidden {
  display: none;
}

/* Checkbox inside chip */
.scope-chip-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--modal-muted-fg);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-top: 0.0625rem;
}

.scope-chip.selected .scope-chip-checkbox {
  background: var(--modal-accent);
  border-color: var(--modal-accent);
}

.scope-chip-checkbox svg {
  width: 0.75rem;
  height: 0.75rem;
  color: var(--modal-bg);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.scope-chip.selected .scope-chip-checkbox svg {
  opacity: 1;
}

/* Chip content (name + description) */
.scope-chip-content {
  flex: 1;
  min-width: 0;
}

.scope-chip-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--modal-fg);
  margin-bottom: 0.125rem;
  word-break: break-word;
}

.scope-chip.selected .scope-chip-name {
  color: var(--modal-accent);
}

.scope-chip-desc {
  font-size: 0.75rem;
  color: var(--modal-muted-fg);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Footer with selection count */
.scope-selector-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--modal-border);
}

.scope-selector-count {
  font-size: 0.85rem;
  color: var(--modal-muted-fg);
}

.scope-selector-count strong {
  color: var(--modal-accent);
  font-weight: 600;
}

/* No results message */
.scope-selector-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--modal-muted-fg);
  font-size: 0.9rem;
}


/* Category sections for grouped sources (CNX) */
.scope-category {
  margin-bottom: 1.25rem;
  width: 100%;
}

.scope-category:last-child {
  margin-bottom: 0;
}

.scope-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--modal-border);
}

.scope-category-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--modal-muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.scope-category-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--modal-muted-fg);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: background 0.15s ease;
  user-select: none;
}

.scope-category-toggle:hover {
  background: rgba(128, 128, 128, 0.15);
}

.scope-category-checkbox {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--modal-muted-fg);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.scope-category-toggle.all-selected .scope-category-checkbox,
.scope-category-toggle.some-selected .scope-category-checkbox {
  background: var(--modal-accent);
  border-color: var(--modal-accent);
}

.scope-category-checkbox svg {
  width: 0.625rem;
  height: 0.625rem;
  color: var(--modal-bg);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.scope-category-toggle.all-selected .scope-category-checkbox svg,
.scope-category-toggle.some-selected .scope-category-checkbox svg {
  opacity: 1;
}

/* Category chip grid (inside category section) */
.scope-category .scope-chip-grid {
  max-height: none;
  overflow: visible;
  width: 100%;
}

/* Grouped container that scrolls */
.scope-grouped-container {
  max-height: calc(80vh - 280px);
  overflow-y: auto;
  padding-right: 0.25rem;
  width: 100%;
}


/* Hide category when filtered out */
.scope-category.hidden {
  display: none;
}

/* ==============================================================================
   Collapsible Long Messages
   ============================================================================== */

/* Collapsed state - height limited with gradient fade */
.message-collapsible.collapsed {
  max-height: 25rem;
  overflow: hidden;
  position: relative;
  /* No padding - text extends to edge, gradient fades it, button sits below */
}

/* Gradient fade overlay element (created by JS with computed bg color) */
.message-collapse-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 10rem;
  pointer-events: none;
  z-index: 5;
  /* Background set dynamically by JS based on actual message bg color */
}

/* Hide gradient when expanded */
.message-collapsible:not(.collapsed) .message-collapse-gradient {
  display: none;
}

/* Toggle button container */
.message-collapse-toggle {
  display: flex !important;
  justify-content: center !important;
  z-index: 10;
  position: relative;
  /* Force block-level behavior, break out of any inline context */
  width: 100% !important;
  float: none !important;
  clear: both !important;
}

/* Top toggle - minimal margin for "Show less" */
.message-collapse-toggle.toggle-top {
  margin-top: 0.15rem;
  margin-bottom: 0.5rem;
}

/* Bottom toggle - counteract parent's gap-4 (1rem) for tighter spacing */
.message-collapse-toggle.toggle-bottom {
  margin-top: -0.5rem;
  margin-bottom: 0.25rem;
  isolation: isolate;
}

/* Button is sibling below prose - no special collapsed positioning needed */

/* The toggle button itself */
.message-collapse-toggle button {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--foreground, #e0e0e0);
  background: var(--background, #1a1a2e);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.2));
  border-radius: 1.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 0.125rem 0.75rem rgba(0, 0, 0, 0.4);
}

.message-collapse-toggle button:hover {
  background: var(--accent, #2a2a4e);
  border-color: var(--border-hover, rgba(255, 255, 255, 0.3));
}

/* Chevron icon for toggle button */
.message-collapse-toggle button svg {
  width: 1.125rem;
  height: 1.125rem;
  transition: transform 0.2s ease;
}

/* Chevron rotation controlled by .is-collapsed class on the toggle itself */
/* (Bottom toggle is outside .message-collapsible, so we can't use descendant selector) */
.message-collapse-toggle.is-collapsed button svg {
  transform: rotate(0deg); /* Points DOWN (v) for "Show more" */
}
.message-collapse-toggle:not(.is-collapsed) button svg {
  transform: rotate(180deg); /* Points UP (^) for "Show less" */
}
.message-collapse-toggle.toggle-bottom.is-collapsed {
  margin-top: -1rem !important;
}

/* ============================================================================
   Feedback — Chainlit chat feedback override
   ============================================================================ */

/* Hide thumbs-down entirely */
[class*="negative-feedback"] {
  display: none !important;
}

/* Replace thumbs-up SVG with message-square-heart icon */
[class*="positive-feedback"] > svg {
  display: none !important;
}
[class*="positive-feedback"] {
  position: relative;
}
[class*="positive-feedback"]::before {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z'/%3E%3Cpath d='M7.5 9.5c0 .687.265 1.383.697 1.844l3.009 3.264a1.14 1.14 0 0 0 .407.314 1 1 0 0 0 .783-.004 1.14 1.14 0 0 0 .398-.31l3.008-3.264A2.77 2.77 0 0 0 16.5 9.5 2.5 2.5 0 0 0 12 8a2.5 2.5 0 0 0-4.5 1.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z'/%3E%3Cpath d='M7.5 9.5c0 .687.265 1.383.697 1.844l3.009 3.264a1.14 1.14 0 0 0 .407.314 1 1 0 0 0 .783-.004 1.14 1.14 0 0 0 .398-.31l3.008-3.264A2.77 2.77 0 0 0 16.5 9.5 2.5 2.5 0 0 0 12 8a2.5 2.5 0 0 0-4.5 1.5'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
/* Off state: muted */
.positive-feedback-off {
  color: var(--muted-foreground, #888) !important;
}
/* On state: feedback was submitted via our modal */
.positive-feedback-on {
  color: var(--modal-accent, #4ecdc4) !important;
}

/* ============================================================================
   Feedback Modal (own modal, triggered from Settings + Chat)
   ============================================================================ */

/* Feedback icon button in settings header */
.feedback-trigger-icon {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
  margin-right: 0.25rem;
  line-height: 1;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}
.feedback-trigger-icon:hover {
  color: var(--modal-accent);
}

/* Overlay — same pattern as settings/motd */
.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000; /* above settings (9999) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.feedback-overlay.visible {
  opacity: 1;
}

/* Modal card — compact */
.feedback-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  width: 28rem;
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: column;
}

/* Header */
.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--modal-border);
}
.feedback-header h2 {
  margin: 0;
  color: var(--modal-accent);
  font-size: 1rem;
  font-weight: 500;
}
.feedback-close {
  background: none;
  border: none;
  color: var(--modal-muted-fg);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 0.25rem;
}
.feedback-close:hover {
  color: #fff;
}

/* Form content */
.feedback-form {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
/* Category row: label + select + thumbs-up inline */
.feedback-category-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.feedback-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--modal-muted-fg);
}
.feedback-select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  background: var(--modal-input-bg);
  color: var(--modal-fg);
  font-family: inherit;
  font-size: 0.8rem;
}
.feedback-select:focus {
  outline: none;
  border-color: var(--modal-accent);
}
.feedback-textarea {
  width: 100%;
  min-height: 5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--modal-border);
  border-radius: 0.375rem;
  background: var(--modal-input-bg);
  color: var(--modal-fg);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
  resize: vertical;
  box-sizing: border-box;
}
.feedback-textarea:focus {
  outline: none;
  border-color: var(--modal-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--modal-accent) 20%, transparent);
}
.feedback-textarea::placeholder {
  color: var(--modal-muted-fg);
}

/* Actions row (right-aligned) */
.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
.feedback-submit {
  padding: 0.375rem 0.875rem;
  border-radius: 0.375rem;
  border: none;
  background: var(--modal-accent);
  color: var(--modal-accent-fg);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.feedback-submit:hover:not(:disabled) {
  opacity: 0.9;
}
.feedback-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.feedback-delete {
  padding: 0.375rem 0.875rem;
  border-radius: 0.375rem;
  border: 1px solid #ef4444;
  background: transparent;
  color: #ef4444;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  margin-right: auto;
  transition: background 0.15s ease, color 0.15s ease;
}
.feedback-delete:hover:not(:disabled) {
  background: #ef4444;
  color: white;
}
.feedback-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.feedback-status {
  font-size: 0.75rem;
  color: var(--modal-muted-fg);
}
.feedback-status.success {
  color: #22c55e;
}
.feedback-status.error {
  color: #ef4444;
}

/* ============================================================================
   Custom Favorites Popover
   ============================================================================ */

/* Hide Chainlit's built-in favorites popover wrapper (but keep star on messages) */
div.favorite-popover-wrapper {
  display: none !important;
}

/* Star button in composer toolbar */
#ao-fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: color 0.15s ease;
  padding: 0;
}
#ao-fav-btn:hover { color: hsl(var(--foreground)); }
#ao-fav-btn svg { width: 1.25rem; height: 1.25rem; }

/* Popover — anchored above star button */
.ao-fav-pop {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: -0.25rem;
  width: 20rem;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.ao-fav-pop.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Scrollable list area — max 3 visible items (~7.5rem) */
.ao-fav-list {
  max-height: 7.75rem;
  overflow-y: auto;
  padding: 0.375rem;
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--muted-foreground) / 0.3) transparent;
}

/* Overflow fade hint at bottom of list when scrollable */
.ao-fav-list-wrap {
  position: relative;
}
.ao-fav-list-wrap.has-overflow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.5rem;
  background: linear-gradient(transparent, var(--modal-bg));
  pointer-events: none;
  border-radius: 0 0 0 0;
}

/* Individual favorite item */
.ao-fav-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.08s ease;
  min-height: 2rem;
}
.ao-fav-item:hover, .ao-fav-item.kb-active { background: hsl(var(--muted) / 0.5); }

.ao-fav-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  color: var(--modal-fg);
  text-align: left;
}

/* Trash / unfavorite button */
.ao-fav-item-del {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: 0.25rem;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s, background 0.1s;
  padding: 0;
}
.ao-fav-item:hover .ao-fav-item-del { opacity: 1; }
.ao-fav-item-del:hover {
  color: hsl(var(--destructive, 0 84% 60%));
  background: hsl(var(--destructive, 0 84% 60%) / 0.12);
}
.ao-fav-item-del svg { width: 0.875rem; height: 0.875rem; }

/* Separator line before search */
.ao-fav-sep {
  height: 1px;
  background: var(--modal-border);
  margin: 0;
}

/* Search input — at bottom */
.ao-fav-search {
  padding: 0.5rem 0.625rem;
  border: none;
  background: transparent;
  color: var(--modal-input-fg);
  font-size: 0.8125rem;
  outline: none;
  width: 100%;
}
.ao-fav-search::placeholder {
  color: var(--modal-muted-fg);
  opacity: 0.5;
}

/* Empty / no-match state */
.ao-fav-empty {
  padding: 1.25rem 0.75rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--modal-muted-fg);
}

/* ============================================================================
   Onboarding Tour — first-login spotlight (see custom.template.js initOnboardingTour)
   Sits above the settings modal (z 9999) and confirm dialogs (z 10002).
   ============================================================================ */
#onboarding-tour {
  position: fixed;
  inset: 0;
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#onboarding-tour.visible { opacity: 1; }

/* Transparent click-blocker — makes the tour strictly non-interactive. */
#onboarding-tour .ob-block {
  position: fixed;
  inset: 0;
  pointer-events: auto;
}

/* Spotlight cutout — the box-shadow dims everything outside this rect. The dim
   stays on screen the whole tour; only the hole's geometry animates, so it
   GLIDES from target to target (connected feel, no flash between steps). */
#onboarding-tour .ob-hole {
  position: fixed;
  pointer-events: none;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(10, 15, 25, 0.66);
  outline: 2px solid var(--modal-accent);
  outline-offset: 2px;
  transition: top 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    outline-color 0.2s ease;
}

/* Centered/no-spotlight steps collapse the hole to a point — hide its ring. */
#onboarding-tour .ob-hole.ob-hole--hidden {
  outline-color: transparent;
}

/* Step change: fade ONLY the card (dim + gliding hole stay continuous).
   pointer-events:none so the faded-but-present card can't catch stray clicks
   mid-transition (belt-and-suspenders with the JS nav lock). */
#onboarding-tour.ob-swapping .ob-pop {
  opacity: 0;
  pointer-events: none;
}

#onboarding-tour .ob-pop {
  position: fixed;
  pointer-events: auto;
  transition: opacity 0.14s ease, top 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.34s cubic-bezier(0.4, 0, 0.2, 1);
  width: 320px;
  max-width: calc(100vw - 28px);
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  padding: 1.1rem 1.2rem 1rem;
  color: var(--modal-fg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}
.ob-pop-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--modal-muted-fg);
  margin-bottom: 0.4rem;
}
.ob-pop-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--modal-accent);
}
.ob-pop-body {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--modal-muted-fg);
}
/* Tighten paragraph spacing inside a bodyHtml step. */
.ob-pop-body p {
  margin: 0 0 0.55rem;
}
.ob-pop-body p:last-child {
  margin-bottom: 0;
}
/* Inline faux "AO message + its action row" mockup. Lives in the always-dark
   tour popover, built from the real icon SVGs + modal CSS vars — no crops, no
   Chainlit data. Shows users exactly what sits under an AO answer. */
.ob-fb-card {
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  background: var(--modal-input-bg, rgba(255, 255, 255, 0.03));
  padding: 0.75rem 0.85rem;
  margin: 0.7rem 0;
}
.ob-fb-card-msg {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}
.ob-fb-card-avatar {
  width: 13px;
  height: 13px;
  margin-top: 2px;
  flex-shrink: 0;
  background: var(--modal-accent);
  border-radius: 2px;
  transform: rotate(45deg);
}
.ob-fb-card-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding-top: 3px;
}
.ob-fb-card-lines > span {
  height: 7px;
  border-radius: 4px;
  background: var(--modal-muted-fg);
  opacity: 0.22;
}
.ob-fb-card-lines > span:first-child { width: 88%; }
.ob-fb-card-lines > span:last-child { width: 56%; }
.ob-fb-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.ob-fb-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 0.5rem;
  color: var(--modal-muted-fg);
}
.ob-fb-card-btn--hl {
  color: var(--modal-fg);
  background: var(--modal-hover-bg);
  outline: 2px solid var(--modal-accent);
  outline-offset: 1px;
}
.ob-fb-card-cap {
  font-size: 0.82rem;
}
.ob-pop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.ob-pop-nav { display: flex; gap: 0.5rem; }
.ob-pop button {
  padding: 0.45rem 1rem;
  border-radius: 0.45rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.ob-next,
.ob-welcome-start {
  background: var(--modal-accent);
  border: none;
  color: var(--modal-accent-fg);
}
.ob-back,
.ob-welcome-skip {
  background: transparent;
  border: 1px solid var(--modal-border);
  color: var(--modal-fg);
}
.ob-skip {
  border: none;
  background: transparent;
  color: var(--modal-muted-fg);
}

/* Welcome modal (ModalUtils className="ob-welcome") */
.ob-welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ob-welcome-overlay.visible { opacity: 1; }
.ob-welcome-modal {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.5rem;
  width: 90%;
  max-width: 440px;
  color: var(--modal-fg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.ob-welcome-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.4rem 0.5rem;
}
.ob-welcome-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--modal-accent);
}
/* No ✖ — the welcome gate requires an explicit "Maybe later" / "Show me" choice. */
.ob-welcome-close {
  display: none;
}
.ob-welcome-body {
  padding: 0.25rem 1.4rem 0.5rem;
}
.ob-welcome-body p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--modal-muted-fg);
}
.ob-welcome-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.4rem 1.3rem;
}
.ob-welcome-footer button {
  padding: 0.55rem 1.2rem;
  border-radius: 0.45rem;
  font-weight: 600;
  cursor: pointer;
}

/* Replay-walkthrough button at the bottom of the Agent/General settings tab. */
.settings-replay-sep {
  border-top: 1px solid var(--modal-border);
  margin: 1.25rem 0 1rem;
}
.settings-replay-btn {
  background: transparent;
  border: 1px solid var(--modal-border);
  color: var(--modal-fg);
  padding: 0.5rem 1rem;
  border-radius: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.settings-replay-btn:hover {
  background: var(--modal-hover-bg);
}

/* Centered "you can replay from Settings" notice shown on skip — a blocking
   dark veil that fades on its own after 5s (no dismiss control). */
.ob-replay-hint-overlay {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 25, 0.66);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: auto; /* blocks interaction with everything behind it */
}
.ob-replay-hint-overlay.visible {
  opacity: 1;
}
.ob-replay-hint-card {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  color: var(--modal-fg);
  padding: 1.5rem 2rem;
  border-radius: 0.6rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  font-size: 1rem;
  line-height: 1.55;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.ob-replay-hint-count {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--modal-muted-fg);
}
.ob-replay-hint-bar {
  margin-top: 0.5rem;
  height: 3px;
  border-radius: 3px;
  background: var(--modal-border);
  overflow: hidden;
}
.ob-replay-hint-bar > i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--modal-accent);
  transition: width 0.3s linear;
}
