/* ══════════════════════════════════════════════════════════════════════
   titi-ui-ext.css — TiTi UI Extension (stable name, replaces R8/R9/R10/R11)
   ══════════════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ───────────────────────────────────────────────────── */
:root {
  --titi-icon-normal:   #8fa1b5;
  --titi-icon-hover:    #c7d2e1;
  --titi-icon-active:   #49d3c6;
  --titi-icon-disabled: rgba(143, 161, 181, 0.38);
  --titi-chip-bg:       rgba(20, 31, 42, 0.86);
  --titi-chip-border:   rgba(255,255,255,0.08);
  --titi-chip-hover-bg: rgba(31, 45, 60, 0.92);
}

/* ── 0. SUPPRESS OLD ACTION BARS (R10) ───────────────────────────────── */
.msg-action-bar       { display: none !important; }
.r9-action-bar        { display: none !important; }
.msg-action-row       { display: none !important; }
.msg-answer-actions   { display: none !important; }
.msg-activity-section { display: none !important; }
.msg-activity-toggle  { display: none !important; }

/* ── 1. MODE SELECTOR (R8) ───────────────────────────────────────────── */
.ai-mode-btn {
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 5px 11px !important;
  border-radius: 20px !important;
  border: 1px solid var(--border-soft, rgba(255,255,255,.14)) !important;
  background: none !important;
  color: var(--text-main, #f3f4f6) !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-width: 0;
  max-width: 130px;
  overflow: hidden;
}
.ai-mode-btn:hover { background: var(--bg-surface-hover, rgba(255,255,255,.07)) !important; }

#aiModeMenu {
  min-width: 180px !important;
  max-width: 220px !important;
  border-radius: 12px !important;
  padding: 6px 4px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,.45) !important;
  border: 1px solid var(--border-soft, rgba(255,255,255,.1)) !important;
  background: var(--bg-surface, #151c24) !important;
}
#aiModeMenu .composer-menu-desc,
#aiModeMenu .titi-expert-note,
#aiModeMenu .composer-menu-section-title { display: none !important; }
#aiModeMenu .composer-menu-item {
  padding: 8px 12px !important;
  border-radius: 8px !important;
  margin: 1px 2px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}
#aiModeMenu .composer-menu-name { font-size: 13.5px !important; font-weight: 500 !important; }
#aiModeMenu .titi-core-item.is-active { background: var(--accent-soft, rgba(79,156,255,.14)) !important; }
#aiModeMenu .titi-core-item.is-active .composer-menu-name { color: var(--accent, #4f9cff) !important; }
.titi-advanced-btn { justify-content: space-between !important; }
.titi-advanced-btn .composer-menu-caret { opacity: .5; font-size: 12px; }

/* Hide Auto section from mode menu (R11) */
.titi-menu-auto { display: none !important; }
.titi-menu-expert .composer-menu-item.titi-advanced-btn { opacity: .7; font-size: 12px; }

#aiModeBtnLabel { font-weight: 500; }

/* ── 2. CHAT LAYOUT (R9 — better than R8) ────────────────────────────── */
#chat {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px 120px;
  width: 100%;
  box-sizing: border-box;
}
.msg { max-width: 100%; }
.msg-bubble-assistant {
  max-width: 100%;
  padding: 14px 16px 8px;
  border-radius: 12px;
  background: var(--bg-surface, #151c24);
  border: 1px solid var(--border-soft, rgba(255,255,255,.06));
  margin-bottom: 4px;
  overflow: visible !important;
}
.msg { overflow: visible !important; }
.msg-bubble-user {
  max-width: 75%;
  margin-left: auto;
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  background: var(--accent-soft, rgba(79,156,255,.12));
  border: 1px solid var(--accent, rgba(79,156,255,.25));
}
.msg-answer { word-break: break-word; overflow-wrap: anywhere; line-height: 1.65; }

/* User bubble TiTi color (R11) */
.msg.user .msg-bubble-user,
.msg-bubble-user {
  background: rgba(20, 44, 58, 0.72) !important;
  border: 1px solid rgba(59, 213, 191, 0.28) !important;
  color: #f3f7fb !important;
}

/* Section headers in answers */
.md-body h2, .md-body h3, .md-body h4, .md-body h5 {
  margin: 14px 0 6px;
  font-weight: 600;
  line-height: 1.3;
}
.md-body h2 { font-size: 16px; }
.md-body h3 { font-size: 14.5px; }
.md-body h4, .md-body h5 { font-size: 13.5px; }

/* ── 3. TABLES (R9 — better than R8) ────────────────────────────────── */
.md-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
  border: 1px solid var(--border-soft, rgba(255,255,255,.08));
  border-radius: 8px;
}
.md-table { border-collapse: collapse; width: 100%; min-width: max-content; font-size: 13px; }
.md-table th, .md-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-soft, rgba(255,255,255,.06));
  text-align: left;
  white-space: nowrap;
}
.md-table thead th {
  background: var(--bg-active, rgba(255,255,255,.05));
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted, #9ca3af);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.md-table tbody tr:last-child td { border-bottom: none; }
.md-table tbody tr:hover { background: var(--bg-surface-hover, rgba(255,255,255,.03)); }

/* ── 4. NUMBERED LISTS ───────────────────────────────────────────────── */
.md-body ol.md-ol { list-style-type: decimal !important; padding-left: 1.6em; }
.md-body ol.md-ol li { margin: 2px 0; }

/* ── 5. SOURCE WARNING ───────────────────────────────────────────────── */
.r8-source-warning {
  font-size: 12px;
  padding: 5px 10px;
  border-left: 3px solid #f59e0b;
  background: rgba(245,158,11,.08);
  border-radius: 0 6px 6px 0;
  color: #f59e0b;
  margin-bottom: 4px;
}

/* ── 6. TiTi BADGE (R9 — better than R8) ────────────────────────────── */
.msg-titi-badge {
  float: right;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft, rgba(79,156,255,.1));
  color: var(--accent, #4f9cff);
  font-weight: 500;
  margin: 0 0 6px 8px;
  max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── 7. + MENU BASE (R8) ─────────────────────────────────────────────── */
#composerPlusMenu {
  min-width: 300px !important;
  max-width: 340px !important;
  border-radius: 14px !important;
  padding: 0 !important;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.5) !important;
  border: 1px solid var(--border-soft, rgba(255,255,255,.1)) !important;
  background: var(--bg-surface, #151c24) !important;
}
#composerPlusMenu .composer-menu-desc,
#composerPlusMenu .composer-plus-sheet-header,
#composerPlusMenu .composer-plus-sheet-title { display: none !important; }

.r8-plus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-soft, rgba(255,255,255,.07));
}
.r8-plus-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted, #9ca3af);
}
.r8-plus-close {
  width: 22px; height: 22px;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted, #9ca3af);
  font-size: 18px; line-height: 1;
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
}
.r8-plus-close:hover { color: var(--text-main, #f3f4f6); background: var(--bg-surface-hover, rgba(255,255,255,.07)); }

.r8-plus-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 8px;
  border: none; background: none; cursor: pointer;
  border-radius: 10px;
  color: var(--text-main, #f3f4f6);
  transition: background .13s;
  text-align: center;
}
.r8-plus-item:hover { background: var(--bg-surface-hover, rgba(255,255,255,.07)); }
.r8-plus-item:focus-visible { outline: 2px solid var(--accent, #4f9cff); outline-offset: -2px; }
.r8-plus-icon {
  color: var(--text-muted, #9ca3af);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--bg-active, rgba(255,255,255,.05));
  transition: color .13s, background .13s;
  font-size: 17px; line-height: 1;
}
.r8-plus-item:hover .r8-plus-icon { color: var(--accent, #4f9cff); background: var(--accent-soft, rgba(79,156,255,.14)); }
.r8-plus-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted, #9ca3af);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 80px;
}

/* ── 8. + MENU 5-GROUP LAYOUT (R11) ─────────────────────────────────── */
.r11-plus-menu .r8-plus-header { padding: 10px 14px 8px; font-size: 13px; font-weight: 600; }
.r11-plus-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim, #6b7280);
  padding: 6px 14px 2px;
  user-select: none;
}
.r11-plus-group-items { padding: 2px 6px; }
.r11-plus-group-items .r8-plus-item {
  width: 100%;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  text-align: left;
}
.r11-plus-group-items .r8-plus-label { max-width: none; }
.r11-plus-divider {
  height: 1px;
  background: var(--border-soft, rgba(255,255,255,.07));
  margin: 4px 6px;
}

/* ── 9. ACTION BAR WRAPPER (R10) ─────────────────────────────────────── */
.r10-bar-wrap { position: relative; display: block; }

.r10-action-bar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px 0 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity .15s;
  flex-wrap: nowrap;
}
.msg:hover .r10-action-bar,
.msg.assistant:focus-within .r10-action-bar { opacity: 1; }
.msg.assistant:last-child .r10-action-bar { opacity: 1; }
.r10-bar-wrap.r10-is-open .r10-action-bar { opacity: 1 !important; }

.r10-sources-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 999px;
  background: none;
  color: var(--text-muted, #9ca3af);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
  margin-right: 4px;
}
.r10-sources-chip:hover { background: var(--accent-soft, rgba(79,156,255,.1)); color: var(--accent, #4f9cff); border-color: var(--accent, rgba(79,156,255,.3)); }
.r10-src-label { font-size: 12px; }

.r10-act-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px;
  border: none; background: none;
  border-radius: 6px; cursor: pointer;
  color: var(--titi-icon-normal, #8fa1b5);
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.r10-act-btn:hover { background: var(--titi-chip-hover-bg, rgba(31,45,60,.92)); color: var(--titi-icon-hover, #c7d2e1); }
.r10-act-btn.r10-act-ok  { color: var(--titi-icon-active, #49d3c6) !important; }
.r10-act-btn.r10-act-err { color: #f87171 !important; }
.r10-act-btn svg { display: block; }
.r10-more-btn { width: 32px; }

/* Teal hover */
.r10-act-btn:hover,
.r10-sources-chip:hover { color: var(--titi-icon-active, #49d3c6) !important; }

/* ── 10. DROPDOWN MENU (R10) ─────────────────────────────────────────── */
.r10-more-menu {
  position: absolute;
  bottom: calc(100% + 6px); right: 0;
  z-index: 620;
  min-width: 220px; max-width: 280px;
  background: var(--bg-surface, #151c24);
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  padding: 4px 0;
  overflow: hidden;
  animation: uiext-fade-in .1s ease;
}
.r10-more-menu.r10-menu-up { bottom: auto; top: calc(100% + 6px); }
@keyframes uiext-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.r10-menu-group-lbl {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim, #6b7280);
  padding: 6px 12px 2px;
  user-select: none;
}
.r10-menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 12px;
  border: none; background: none;
  color: var(--text-main, #f3f4f6);
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background .1s;
}
.r10-menu-item:hover { background: var(--bg-active, rgba(255,255,255,.06)); }
.r10-menu-icon { flex-shrink: 0; display: flex; align-items: center; color: var(--text-muted, #9ca3af); }
.r10-menu-lbl { flex: 1; }
.r10-menu-disabled { opacity: .45; cursor: default; pointer-events: none; }
.r10-menu-div { height: 1px; background: var(--border-soft, rgba(255,255,255,.07)); margin: 3px 0; }

/* ── 11. TASK TYPE CHIP (R11) ────────────────────────────────────────── */
#uiExtTaskChipWrap {
  display: inline-flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}
.r11-task-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 6px;
  background: none;
  color: var(--text-muted, #9ca3af);
  font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
  line-height: 1;
}
.r11-task-chip:hover { background: var(--bg-surface-hover, rgba(255,255,255,.07)); color: var(--text-main, #f3f4f6); border-color: rgba(59,213,191,.3); }
.r11-task-chip-caret { font-size: 9px; opacity: .6; }
.r11-task-prefix { opacity: .5; font-size: 11px; }

.r11-task-menu {
  position: absolute;
  bottom: calc(100% + 6px); left: 0;
  z-index: 630;
  min-width: 210px;
  background: var(--bg-surface, #151c24);
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  padding: 4px 0;
  animation: uiext-fade-in .1s ease;
}
.r11-task-menu.hidden { display: none; }
.r11-task-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 8px 14px;
  border: none; background: none;
  color: var(--text-main, #f3f4f6);
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background .1s;
}
.r11-task-menu-item:hover { background: var(--bg-active, rgba(255,255,255,.06)); }
.r11-task-menu-item.is-active { color: #3bd5bf; font-weight: 600; }
.r11-task-check { font-size: 11px; opacity: .8; }
.r11-task-divider { height: 1px; background: var(--border-soft, rgba(255,255,255,.07)); margin: 3px 0; }

/* ── 12. ACTIVITY PANEL (R8) ─────────────────────────────────────────── */
#projectActivityPanelRight { padding: 4px 0 8px; min-height: 60px; }
.r8-activity-wrap { display: flex; flex-direction: column; gap: 1px; }
.r8-act-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 10px 6px;
  border-radius: 8px; transition: background .12s;
}
.r8-act-item:hover { background: var(--bg-surface-hover, rgba(255,255,255,.04)); }
.r8-act-icon { flex-shrink: 0; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.r8-act-icon svg { width: 14px; height: 14px; }
.r8-act-done  { color: #22c55e; }
.r8-act-running { color: #f59e0b; animation: uiext-spin 1.2s linear infinite; }
.r8-act-error { color: #ef4444; }
.r8-act-neutral { color: var(--text-muted, #9ca3af); }
@keyframes uiext-spin { to { transform: rotate(360deg); } }
.r8-act-body { flex: 1; min-width: 0; }
.r8-act-title { font-size: 12px; font-weight: 600; color: var(--text-main, #f3f4f6); line-height: 1.3; }
.r8-act-summary { font-size: 11.5px; color: var(--text-muted, #9ca3af); margin-top: 2px; line-height: 1.4; }
.r8-act-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.r8-act-domain { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--bg-active, rgba(255,255,255,.07)); color: var(--text-muted, #9ca3af); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r8-act-count, .r8-act-time { font-size: 10.5px; color: var(--text-muted, #9ca3af); opacity: .75; }
.r8-act-empty { font-size: 12px; color: var(--text-muted, #9ca3af); opacity: .6; padding: 12px 10px; font-style: italic; }
.r8-act-thinking .r8-act-title { opacity: .7; }

/* ── 13. ACTIVITY TIMELINE (R11) ─────────────────────────────────────── */
#uiExtActivityBox { padding: 8px 0; }
.r11-activity-empty { color: var(--text-muted, #9ca3af); font-size: 13px; padding: 16px 12px; text-align: center; }
.r11-activity-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim, #6b7280);
  padding: 4px 12px 8px;
}
.r11-timeline { list-style: none; margin: 0; padding: 0 12px; position: relative; }
.r11-timeline::before {
  content: ''; position: absolute; left: 22px; top: 8px; bottom: 8px;
  width: 1px; background: var(--border-soft, rgba(255,255,255,.08));
}
.r11-tl-item { display: flex; gap: 10px; padding: 6px 0; position: relative; }
.r11-tl-dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  margin-top: 5px; background: var(--text-dim, #6b7280);
  border: 1.5px solid var(--bg-base, #0b0f14);
  position: relative; z-index: 1;
}
.r11-tl-item.is-success .r11-tl-dot { background: #3bd5bf; }
.r11-tl-item.is-error   .r11-tl-dot { background: #f87171; }
.r11-tl-item.is-running .r11-tl-dot { background: #facc15; animation: uiext-pulse 1.2s ease-in-out infinite; }
@keyframes uiext-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.r11-tl-body { flex: 1; min-width: 0; }
.r11-tl-title { font-size: 13px; font-weight: 500; color: var(--text-main, #f3f4f6); line-height: 1.4; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r11-tl-detail { font-size: 11.5px; color: var(--text-muted, #9ca3af); margin: 2px 0 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.r11-tl-meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.r11-tl-chip { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,.06); color: var(--text-dim, #6b7280); border: 1px solid rgba(255,255,255,.07); }

/* ── 14. ADVANCED PANEL (R8) ─────────────────────────────────────────── */
.r8-advanced-panel {
  position: fixed; bottom: 80px; left: 20px;
  width: 260px; border-radius: 14px;
  background: var(--bg-surface, #151c24);
  border: 1px solid var(--border-soft, rgba(255,255,255,.12));
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 1300; overflow: hidden;
  animation: uiext-fade-in .15s ease;
}
.r8-advanced-panel.hidden { display: none; }
.r8-adv-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; border-bottom: 1px solid var(--border-soft, rgba(255,255,255,.07)); }
.r8-adv-title { font-size: 12px; font-weight: 600; color: var(--text-main, #f3f4f6); }
.r8-adv-close { width: 22px; height: 22px; border: none; background: none; cursor: pointer; color: var(--text-muted, #9ca3af); font-size: 18px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.r8-adv-close:hover { background: var(--bg-surface-hover, rgba(255,255,255,.07)); }
.r8-adv-note { font-size: 11.5px; color: var(--text-muted, #9ca3af); padding: 8px 14px 4px; line-height: 1.5; }
.r8-provider-list { list-style: none; margin: 0; padding: 4px 0 8px; }
.r8-provider-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 14px; font-size: 12.5px; color: var(--text-main, #f3f4f6); }
.r8-prov-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted, #9ca3af); }
.r8-prov-active { background: #22c55e; }
.r8-prov-error  { background: #ef4444; }
.r8-prov-warn   { background: #f59e0b; }
.r8-prov-unknown { background: #6b7280; animation: uiext-pulse 1.5s ease-in-out infinite; }
.r8-prov-body { flex: 1; min-width: 0; }
.r8-prov-name { flex: 1; }
.r8-prov-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.r8-prov-status { font-size: 11px; color: var(--text-muted, #9ca3af); }
.r8-prov-meta { font-size: 10px; line-height: 1.3; margin-top: 2px; }
.r8-prov-err { font-size: 10px; margin-top: 2px; color: #f87171; }
.r8-prov-group { margin-bottom: 10px; }
.r8-prov-group-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted, #9ca3af); margin: 6px 0 4px; }
.r8-provider-body { max-height: 360px; overflow-y: auto; padding-right: 4px; }
.r8-adv-actions { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.r8-prov-verify { flex-shrink: 0; align-self: flex-start; margin-left: 4px; }
.r8-adv-footer { font-size: 11px; padding: 4px 14px 10px; }

/* ── 15. PROVIDER TIMEOUT BUTTON (R11) ───────────────────────────────── */
.r11-verify-btn {
  font-size: 11px; padding: 2px 8px;
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 5px; background: none;
  color: var(--text-muted, #9ca3af); cursor: pointer;
  transition: background .1s, color .1s;
}
.r11-verify-btn:hover { background: rgba(59,213,191,.1); color: #3bd5bf; border-color: rgba(59,213,191,.3); }

/* ── 16. INSPECTOR TABS (R9 — better than R8) ────────────────────────── */
.inspector-tabs {
  display: flex !important; flex-direction: row !important;
  flex-wrap: nowrap !important; overflow-x: auto !important;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border-bottom: 1px solid var(--border-soft, rgba(255,255,255,.07));
  gap: 0; padding: 2px 2px 0;
}
.inspector-tabs::-webkit-scrollbar { display: none; }
.inspector-tab {
  display: inline-flex !important; flex-direction: row !important;
  align-items: center !important; gap: 4px !important;
  flex-shrink: 0 !important; white-space: nowrap !important;
  padding: 6px 9px !important; font-size: 11.5px !important;
  border-radius: 6px 6px 0 0 !important;
  border-bottom: 2px solid transparent;
  cursor: pointer; color: var(--text-muted, #9ca3af);
  background: none; border-top: none; border-left: none; border-right: none;
  transition: color .12s;
}
.inspector-tab.active { color: var(--text-main, #f3f4f6) !important; border-bottom-color: var(--accent, #4f9cff) !important; }
.inspector-tab:hover { color: var(--text-main, #f3f4f6); }
.inspector-tab-icon { display: flex; align-items: center; }
.inspector-tab-label { font-size: 11.5px; white-space: nowrap !important; }

/* ── 17. RIGHT PANEL (R9) ────────────────────────────────────────────── */
.reviewer-panel, #researchInspector {
  min-width: 320px !important; max-width: 420px;
  overflow-x: hidden !important;
  flex-shrink: 0; display: flex; flex-direction: column;
}
#inspectorPanelContext { overflow-y: auto; flex: 1; padding: 0 !important; }
#inspectorContextPanel { padding: 0 6px; }
#projectActivityPanelRight {
  border-top: 1px solid var(--border-soft, rgba(255,255,255,.06));
  margin-top: 4px; min-height: 40px;
}
.source-card-title { font-size: 13px; font-weight: 600; }
.source-card-meta { font-size: 11.5px; color: var(--text-muted, #9ca3af); }

/* ── 18. COMPOSER ────────────────────────────────────────────────────── */
.composer-wrap, #composerWrap {
  flex-shrink: 0;
  background: var(--bg-main, #0b0f14);
  border-top: 1px solid var(--border-soft, rgba(255,255,255,.07));
  padding: 8px 16px 12px;
}

/* ── 19. RESPONSIVE DRAWER/SHEET (R11) ───────────────────────────────── */
@media (max-width: 1099px) and (min-width: 700px) {
  #researchInspector.r11-activity-open {
    position: fixed !important; right: 0 !important; top: 0 !important; bottom: 0 !important;
    width: 360px !important; z-index: 800 !important;
    box-shadow: -4px 0 32px rgba(0,0,0,.5) !important;
    border-radius: 0 !important;
    animation: uiext-slide-right .2s ease;
  }
  @keyframes uiext-slide-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
  .r11-inspector-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 799;
    animation: uiext-fade-in .15s ease;
  }
}

@media (max-width: 699px) {
  #researchInspector.r11-activity-open {
    position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important;
    height: 65dvh !important; border-radius: 20px 20px 0 0 !important;
    z-index: 800 !important; box-shadow: 0 -4px 32px rgba(0,0,0,.5) !important;
    animation: uiext-slide-up .2s ease;
  }
  @keyframes uiext-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .r11-inspector-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 799; }
  #chat { max-width: 100%; padding: 0 10px 100px; }
  .msg-bubble-user { max-width: 88%; }
  .reviewer-panel, #researchInspector {
    position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100% !important; min-width: unset !important;
    max-height: 75dvh; border-radius: 20px 20px 0 0;
    transform: translateY(100%); transition: transform .25s ease;
    z-index: 1100; box-shadow: 0 -4px 32px rgba(0,0,0,.5);
  }
  .reviewer-panel.mobile-open, #researchInspector.mobile-open { transform: translateY(0); }
  .r10-action-bar { opacity: 1; }
  .r10-more-menu:not(.hidden) {
    position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important; max-height: 70dvh; overflow-y: auto;
    box-shadow: 0 -4px 32px rgba(0,0,0,.5); animation: uiext-slide-up .2s ease;
    z-index: 1200 !important;
  }
  .r10-menu-item { padding: 11px 16px; font-size: 14px; }
  .r10-menu-group-lbl { padding: 10px 16px 3px; }
  .msg-bubble-assistant { padding: 10px 12px 6px; }
  .r8-advanced-panel { left: 8px; right: 8px; width: auto; bottom: 70px; }
  #composerPlusMenu {
    position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important; top: auto !important;
    min-width: unset !important; max-width: unset !important; width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
  }
}

/* ── PORTAL MENU (... rendered into body) ────────────────────────────── */
#uiExtMorePortal {
  position: fixed;
  z-index: 9800;
  min-width: 230px; max-width: 280px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  background: var(--bg-surface, #151c24);
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
  padding: 4px 0;
  animation: uiext-fade-in .1s ease;
}
#uiExtMorePortal.hidden { display: none; }

/* ── PLUS MENU CATEGORY ROWS (8-item design) ─────────────────────────── */
.uiext-plus-cat-icon {
  display: flex; align-items: center; justify-content: center;
  width: 22px; flex-shrink: 0;
  color: var(--titi-icon-normal, #8fa1b5);
}
.uiext-plus-cat-btn:hover .uiext-plus-cat-icon { color: var(--titi-icon-active, #49d3c6); }

/* ── PLUS MENU SUB-ITEM ───────────────────────────────────────────────── */
.uiext-plus-sub-item {
  display: flex; flex-direction: column;
  width: 100%; padding: 8px 14px 7px;
  background: transparent; border: 0; border-radius: 7px;
  color: var(--text-main, #f3f4f6); cursor: pointer;
  font-size: 13px; text-align: left;
  transition: background .1s;
}
.uiext-plus-sub-item:hover { background: rgba(255,255,255,.06); }
.uiext-plus-sub-item.uiext-disabled { opacity: .4; cursor: default; pointer-events: none; }
.uiext-plus-sub-label { font-size: 13px; font-weight: 500; }
.uiext-plus-item-hint {
  font-size: 10.5px; color: var(--text-dim, #6b7280);
  margin-top: 1px; line-height: 1.3;
}
.uiext-plus-sub-note {
  font-size: 11px; color: var(--titi-icon-active, #49d3c6);
  padding: 4px 14px 8px; opacity: .8;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 2px;
}

/* ── MIC BUTTON ───────────────────────────────────────────────────────── */
.uiext-mic-btn {
  color: var(--titi-icon-normal, #8fa1b5);
  width: 32px; height: 32px;
  border-radius: 50% !important;
  border: 1px solid var(--titi-chip-border, rgba(255,255,255,.08)) !important;
  background: transparent !important;
  margin-right: 4px;
  transition: color .12s, border-color .12s, background .12s;
}
.uiext-mic-btn:hover { color: var(--titi-icon-hover, #c7d2e1); border-color: rgba(255,255,255,.18) !important; }
.uiext-mic-btn.r10-act-ok { color: #f87171 !important; border-color: rgba(248,113,113,.4) !important; animation: uiext-pulse 1.2s infinite; }

@media (max-width: 900px) {
  .reviewer-panel, #researchInspector { min-width: 280px !important; max-width: 300px; }
}

/* ── THUMB / RETRY ACTION BUTTONS ────────────────────────────────────── */
.r10-thumb-btn { font-size: 13px !important; line-height: 1 !important; }
.r10-thumb-btn.r10-act-ok  { opacity: 1 !important; filter: none; }
.r10-thumb-btn.r10-act-err { opacity: 1 !important; filter: none; }
.r10-act-btn.r10-act-err { color: #f87171 !important; }

/* ── SIDEBAR ACCOUNT CARD ─────────────────────────────────────────────── */
.sidebar-account-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.sidebar-account-name {
  font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-main, #f3f4f6);
}
.sidebar-account-plan {
  font-size: 11px; opacity: .65;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-muted, #9ca3af);
}
.sidebar-acc-settings {
  opacity: .55; font-size: 14px; text-decoration: none;
  padding: 2px 3px; border-radius: 4px;
  color: var(--text-muted, #9ca3af);
  transition: opacity .12s;
  flex-shrink: 0;
}
.sidebar-acc-settings:hover { opacity: 1; }

/* ── PLUS MENU POSITIONING ────────────────────────────────────────────── */
#composerPlusMenu {
  position: absolute !important;
  bottom: calc(100% + 6px) !important;
  left: 0 !important;
  top: auto !important;
  min-width: 280px !important;
  max-width: 320px !important;
}

/* ── PLUS MENU 2-PANEL ────────────────────────────────────────────────── */
.uiext-plus-categories {
  display: flex; flex-direction: column;
  gap: 1px; padding: 4px 6px 6px;
}
.uiext-plus-cat-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 10px;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--text-main, #f3f4f6);
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background .1s;
}
.uiext-plus-cat-btn:hover { background: rgba(255,255,255,.07); }
.uiext-plus-cat-label { flex: 1; }
.uiext-plus-cat-arrow { opacity: .45; font-size: 18px; line-height: 1; }
.uiext-plus-subpanel { display: flex; flex-direction: column; }
.uiext-plus-back-btn {
  display: block; width: 100%; padding: 9px 14px;
  background: transparent; border: 0;
  border-bottom: 1px solid var(--border-soft, rgba(255,255,255,.06));
  color: var(--accent, #4f9cff); cursor: pointer;
  font-size: 13px; text-align: left;
  transition: background .1s;
}
.uiext-plus-back-btn:hover { background: rgba(255,255,255,.05); }
.uiext-plus-sub-title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; opacity: .45;
  padding: 8px 14px 3px;
  color: var(--text-muted, #9ca3af);
}
.uiext-plus-sub-items {
  display: flex; flex-direction: column;
  gap: 1px; padding: 4px 6px 8px;
}

/* ── HOTFIX: ACCOUNT SIDEBAR — hide text, avatar-only button ──────────── */
.sidebar-account-name,
.sidebar-account-plan,
.sidebar-account-info,
.sidebar-acc-settings,
.sidebar-footer-note,
.sidebar-account-label,
.sidebar-user-label,
.sidebar-account-heading,
.sidebar-account-old,
.sidebar-profile-old { display: none !important; }

.page-workspace .sidebar-account-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 7px 12px !important;
  height: 44px !important;
  gap: 0 !important;
}
.page-workspace .sidebar-account-avatar {
  width: 32px !important;
  height: 32px !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(79,156,255,.18) !important;
  color: var(--text-main, #f3f4f6) !important;
  font-weight: 700 !important;
  font-size: 14px !important;
}
.sidebar-acc-gear {
  color: var(--titi-icon-normal, #8fa1b5);
  opacity: .55;
  flex-shrink: 0;
  transition: opacity .15s;
}
.sidebar-account-btn:hover .sidebar-acc-gear { opacity: .9; }
.sidebar-collapsed .sidebar-acc-gear { display: none; }

/* Account popover portal */
#titiAccPopover {
  position: fixed;
  z-index: 9900;
  min-width: 230px;
  max-width: 280px;
  background: var(--bg-surface, #151c24);
  border: 1px solid var(--border-soft, rgba(255,255,255,.1));
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.3);
  padding: 4px 0;
  animation: uiext-fade-in .12s ease;
}
#titiAccPopover.hidden { display: none; }
.titi-acc-pop-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
}
.titi-acc-pop-avatar {
  width: 36px; height: 36px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(79,156,255,.22);
  color: var(--text-main, #f3f4f6);
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.titi-acc-pop-name {
  display: block;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-main, #f3f4f6);
}
.titi-acc-pop-plan {
  display: block;
  font-size: 11.5px;
  color: var(--titi-icon-active, #49d3c6);
  margin-top: 1px;
}
.titi-acc-pop-sep {
  border: 0;
  border-top: 1px solid var(--line, rgba(255,255,255,.08));
  margin: 4px 0;
}
.titi-acc-pop-item {
  display: block;
  width: 100%;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-main, #e4e7ec);
  text-decoration: none;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: background .1s;
  box-sizing: border-box;
}
.titi-acc-pop-item:hover { background: rgba(255,255,255,.06); }
.titi-acc-pop-logout { color: #f87171 !important; }

/* ── HOTFIX: plus button always visible (was opacity:0 until hover).
   send is intentionally NOT included here — titi-ux-flow.css owns its
   visibility (hidden until #prompt has text, via chat-input-guard.js's
   is-disabled toggle). Including .send in this !important rule defeated
   that logic entirely, which is why send never auto-hid. */
.page-workspace .composer-v42 .composer-plus-btn {
  opacity: 1 !important;
  pointer-events: auto !important;
}
