*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #222;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
header h1 { font-size: 1.1rem; font-weight: 700; }
header span { color: #8888aa; font-size: 0.8rem; }

#hamburger {
  display: none;
  background: none; border: none;
  color: #fff; font-size: 1.4rem;
  cursor: pointer; padding: 2px 6px; line-height: 1;
}

#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
}

@media (max-width: 640px) {
  #hamburger { display: block; }
  .sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  #sidebar-overlay.open { display: block; }
}

.layout { display: flex; flex: 1; overflow: hidden; }

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow: hidden;
  position: relative;
}

/* ── Jump buttons ── */
#jump-btns {
  position: absolute;
  bottom: 24px; right: 16px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 10; pointer-events: none;
}
.jump-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #dde1e9;
  color: #888; font-size: 14px; line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
  display: none; align-items: center; justify-content: center;
  pointer-events: auto;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.jump-btn:hover { background: #f0f4ff; border-color: #4a6cf7; color: #4a6cf7; }

.question-box {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
textarea#question {
  width: 100%;
  height: 72px;
  border: 1px solid #dde1e9;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
}
textarea#question:focus { outline: none; border-color: #4a6cf7; }

.question-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
#cost-estimate { flex: 1; }
.question-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.question-controls label { font-size: 12px; color: #777; display: flex; align-items: center; gap: 6px; }
.question-controls input[type=number] { width: 52px; padding: 4px 8px; border: 1px solid #dde1e9; border-radius: 4px; font-size: 13px; }
.hint { font-size: 11px; color: #bbb; }
.hint a { color: #4a6cf7; text-decoration: none; cursor: pointer; }
.hint a:hover { text-decoration: underline; }
@media (max-width: 640px) { .hint { display: none; } }

/* File attachment area */
#attachment-area { margin-top: 8px; display: none; flex-wrap: wrap; gap: 8px; align-items: center; }
.attach-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 10px; border: 1px solid #dde1e9; border-radius: 6px;
  font-size: 16px; color: #666; background: #fff; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.attach-btn:hover { border-color: #4a6cf7; color: #4a6cf7; }
.attach-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 6px; border: 1px solid #dde1e9; border-radius: 20px;
  font-size: 12px; color: #444; background: #f6f7fb; max-width: 200px;
}
.attach-chip img { width: 20px; height: 20px; object-fit: cover; border-radius: 3px; }
.attach-chip .chip-icon { font-size: 16px; line-height: 1; }
.attach-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.attach-chip .chip-remove { cursor: pointer; color: #aaa; font-size: 14px; line-height: 1; }
.attach-chip .chip-remove:hover { color: #e53; }
.attach-chip.uploading { opacity: .6; }
.attach-chip.submitted { opacity: .55; cursor: default; }
.followup-header-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Read-only question display (shown after Ask) */
/* New Chat button in sidebar */
.btn-new-chat {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 8px 10px;
  background: #4a6cf7; border: none;
  border-radius: 7px; font-size: 13px; color: #fff;
  cursor: pointer; font-weight: 600;
}
.btn-new-chat:hover { background: #3558e0; }

.btn-primary {
  background: #4a6cf7; color: #fff; border: none;
  padding: 8px 22px; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover:not(:disabled) { background: #3558e0; }
.btn-primary:disabled { background: #b0b8d0; cursor: not-allowed; }

.btn-cancel {
  background: #e05252; color: #fff; border: none;
  padding: 8px 22px; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: none;
}
.btn-cancel:hover { background: #c03030; }

.btn-save {
  background: #4a6cf7; color: #fff; border: none;
  padding: 7px 0; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn-save:hover:not(:disabled) { background: #3558e0; }
.btn-save:disabled { background: #b0b8d0; cursor: not-allowed; }

.btn-icon {
  background: none; border: 1px solid #dde1e9;
  border-radius: 4px; padding: 3px 6px;
  font-size: 12px; cursor: pointer; color: #666; line-height: 1;
  flex-shrink: 0;
}
.btn-icon:hover:not(:disabled) { background: #f0f4ff; border-color: #4a6cf7; color: #4a6cf7; }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-icon.spinning { animation: spin 0.7s linear infinite; }

.btn-remove {
  background: none; border: none;
  color: #cc4444; font-size: 11px; cursor: pointer; padding: 2px;
}
.btn-remove:hover:not(:disabled) { text-decoration: underline; }
.btn-remove:disabled { opacity: 0.4; cursor: not-allowed; }

.copy-btns-row { display: flex; gap: 2px; margin-top: 6px; }
.btn-copy {
  background: none; border: none; border-radius: 4px;
  padding: 4px; cursor: pointer; color: #ccc;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.btn-copy:hover { color: #4a6cf7; background: #f0f4ff; }
.btn-copy.copied { color: #22a862; }
@media (pointer: coarse) {
  .btn-copy { flex-direction: column; gap: 2px; padding: 4px 5px; }
  .btn-copy::after { content: attr(data-label); font-size: 9px; color: #bbb; line-height: 1; }
  .btn-copy.copied::after { color: #22a862; }
}

.byok-row { margin-bottom: 10px; }
.byok-label { font-size: 12px; font-weight: 600; color: #333; display: inline-block; width: 70px; }
.byok-status { font-size: 11px; color: #22a06b; margin-left: 4px; }
.byok-input-row { display: flex; gap: 6px; margin-top: 5px; }
.byok-input { flex: 1; font-size: 11px; padding: 4px 6px; border: 1px solid #ddd; border-radius: 4px; font-family: monospace; }
.byok-actions { display: inline-flex; gap: 8px; margin-left: 6px; }
.byok-btn-edit { background: none; border: none; font-size: 11px; color: #4a6cf7; cursor: pointer; padding: 2px; }
.byok-btn-edit:hover { text-decoration: underline; }
.byok-btn-save { background: #4a6cf7; color: #fff; border: none; border-radius: 4px; font-size: 11px; padding: 4px 10px; cursor: pointer; }
.byok-btn-save:hover { background: #3a5ce0; }
.byok-btn-remove { background: none; border: none; font-size: 11px; color: #cc4444; cursor: pointer; padding: 2px; }
.byok-btn-remove:hover { text-decoration: underline; }

/* API Tokens (PAT) section */
.pat-row { display:flex; align-items:center; justify-content:space-between; padding:4px 0; border-bottom:1px solid #f0f0f0; gap:6px; }
.pat-label { font-size:11px; color:#333; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pat-meta { font-size:10px; color:#aaa; white-space:nowrap; }
.pat-btn-revoke { background:none; border:none; font-size:11px; color:#cc4444; cursor:pointer; padding:2px 4px; flex-shrink:0; }
.pat-btn-revoke:hover { text-decoration:underline; }
.pat-new-row { display:flex; gap:6px; margin-top:8px; }
.pat-new-input { flex:1; font-size:11px; padding:4px 6px; border:1px solid #ddd; border-radius:4px; }
.pat-new-btn { background:#4a6cf7; color:#fff; border:none; border-radius:4px; font-size:11px; padding:4px 10px; cursor:pointer; white-space:nowrap; }
.pat-new-btn:hover { background:#3a5ce0; }
.pat-reveal-box { background:#f6f8fa; border:1px solid #e0e4ea; border-radius:4px; padding:6px; margin-top:8px; }
.pat-reveal-header { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:5px; }
.pat-reveal-warning { font-size:10px; font-family:sans-serif; color:#333; font-weight:600; }
.pat-reveal-copy { background:#4a6cf7; color:#fff; border:none; border-radius:3px; font-size:10px; padding:2px 8px; cursor:pointer; flex-shrink:0; }
.pat-reveal-token { font-family:monospace; font-size:10px; word-break:break-all; }

.btn-add {
  background: none; border: 1px dashed #c0c8d8;
  border-radius: 6px; padding: 7px; width: 100%;
  font-size: 12px; color: #888; cursor: pointer; margin-top: 4px;
}
.btn-add:hover:not(:disabled) { border-color: #4a6cf7; color: #4a6cf7; background: #f5f8ff; }
.btn-add:disabled { opacity: 0.4; cursor: not-allowed; }

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

/* ── Results ── */
#results {
  flex: 1; overflow-y: auto;
  background: #fff; border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  line-height: 1.7;
  -webkit-user-select: text; user-select: text;
}
#pull-refresh-indicator {
  --pull-offset: 0px;
  position: absolute; top: 8px; left: 50%; z-index: 5;
  transform: translate(-50%, calc(-12px + var(--pull-offset))); opacity: 0;
  padding: 4px 9px; border-radius: 999px;
  background: #eef1ff; color: #405cc9; font-size: 12px; font-weight: 600;
  pointer-events: none; transition: opacity 0.15s ease, transform 0.15s ease;
}
#pull-refresh-indicator.visible { opacity: 1; }
#pull-refresh-indicator.refreshing {
  width: 28px; height: 28px; padding: 0; background: transparent; font-size: 0;
}
#pull-refresh-indicator.refreshing::before {
  content: ''; display: block; width: 20px; height: 20px; margin: 2px;
  border: 3px solid rgba(64, 92, 201, 0.22); border-top-color: #405cc9;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.placeholder { color: #bbb; font-size: 14px; text-align: center; margin-top: 40px; }

/* ── Round 1 card (initial question as scrollable card) ── */
#round-1-card {
  display: none;
  background: #fff;
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  padding: 16px 20px 14px;
  overflow: hidden;
  margin-bottom: 0;
}
#round-1-header {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
#round-1-attachments {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
#round-1-question-text {
  max-height: 4.5em;
  overflow: hidden;
}
#round-1-question-text.expanded { max-height: none; }
#round-1-question-toggle-row {
  display: none;
  justify-content: flex-start;
  margin-top: 4px;
}
#round-1-question-toggle {
  background: none; border: none; padding: 0;
  font-size: 12px; color: #4a6cf7; cursor: pointer;
  text-decoration: underline;
}
/* ── Share button in main header ── */
#header-share-btn {
  display: none;
  background: #4a6cf7;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  cursor: pointer;
  white-space: nowrap;
}
#header-share-btn:hover { background: #6b87f8; }

.spinner-row { display: flex; align-items: center; gap: 8px; color: #888; font-size: 13px; font-style: italic; margin: 8px 0; }
.spinner { width: 14px; height: 14px; border: 2px solid #ddd; border-top-color: #4a6cf7; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; flex-shrink: 0; }

/* Markdown */
#results h1 { font-size: 1.4rem; color: #1a1a2e; margin: 0 0 16px; }
#results h2 { font-size: 1.1rem; color: #1a1a2e; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 2px solid #eef0f5; }
#results h3 { font-size: 1rem; color: #333; margin: 20px 0 8px; }
#results h4 { font-size: 0.85rem; color: #666; text-transform: uppercase; letter-spacing: 0.6px; margin: 16px 0 6px; }
#results p { margin: 6px 0; }
#results ul, #results ol { margin: 6px 0 6px 22px; }
#results li { margin: 3px 0; }
#results hr { border: none; border-top: 1px solid #eef0f5; margin: 20px 0; }
#results strong { font-weight: 600; }
#results em { color: #888; }
#results blockquote { border-left: 3px solid #4a6cf7; background: #f5f7ff; margin: 10px 0; padding: 10px 16px; border-radius: 0 6px 6px 0; color: #444; }
#results blockquote p { margin: 3px 0; }
#results code { background: #f0f2f5; padding: 1px 5px; border-radius: 3px; font-size: 0.88em; }
#results pre { background: #f0f2f5; padding: 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
#results pre code { background: none; padding: 0; }

/* ── Sidebar ── */
.sidebar {
  width: 250px;
  background: #fff;
  border-left: 1px solid #eaecf0;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.sb-section h2 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #aaa;
  font-weight: 700;
  margin-bottom: 8px;
}

/* Info icon + tooltip */
.info-icon {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid #bbb;
  background: transparent; padding: 0; font: inherit; text-align: center;
  font-size: 10px; font-style: italic; color: #888; cursor: pointer;
  margin-left: 4px; vertical-align: middle;
  user-select: none; line-height: 1;
}
.info-icon:hover, .info-icon:focus { border-color: #666; color: #555; }
.info-icon:focus-visible { outline: 2px solid #4a6cf7; outline-offset: 2px; }
.sb-section-grounded { position: relative; }
#verification-section { position: relative; }
.verification-toggle {
  display: flex; align-items: center; gap: 4px;
  min-width: 0; white-space: nowrap;
}
.verification-toggle label { cursor: pointer; white-space: nowrap; font-size: 13px; }
#verification-models {
  display: flex; flex-direction: column; gap: 4px;
  margin: 6px 0 0 20px;
}
.verifier-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 132px);
  align-items: center; gap: 6px; min-width: 0;
}
.verifier-select-row label {
  min-width: 0; font-size: 12px; color: #555;
}
.verifier-select-row select {
  width: 132px; max-width: 100%; min-width: 0;
  padding: 4px 6px; border: 1px solid #dde1e9; border-radius: 4px;
  font-size: 12px; background: #fff;
}
.verifier-select-row select:disabled { background: #f4f4f4; color: #aaa; cursor: not-allowed; }
.info-tooltip {
  display: none; position: absolute; left: 0; right: 0; top: 100%;
  margin-top: 4px; padding: 8px 10px; background: #333; color: #fff;
  font-size: 11px; font-style: normal; line-height: 1.4;
  border-radius: 6px; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  white-space: normal;
  max-width: min(240px, calc(100vw - 16px)); overflow-wrap: anywhere;
}
.info-tooltip-cost { left: 0; right: auto; top: 22px; }
.info-icon.open + .info-tooltip,
.info-icon:hover + .info-tooltip { display: block; }

/* Provider card */
.pcard {
  background: #f8f9fb;
  border-radius: 7px;
  padding: 9px 10px;
  margin-bottom: 6px;
  border-left: 3px solid #4a6cf7;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pcard.is-analyzer { border-left-color: #f0a500; }

.pcard-row { display: flex; gap: 5px; align-items: center; }

.pcard select {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid #dde1e9;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  min-width: 0;
}
.pcard select:disabled { background: #f4f4f4; color: #aaa; cursor: not-allowed; }

.pcard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1px;
}
.pcard-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
}
.label-debater { background: #dce8ff; color: #2255bb; }
.label-analyzer { background: #fff0cc; color: #8a6000; }

/* Analyzer select */
#analyzer-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #dde1e9;
  border-radius: 5px;
  font-size: 12px;
  background: #fff;
}
#analyzer-select:disabled { background: #f4f4f4; color: #aaa; }

#mock-banner {
  display: none;
  background: #e07b00;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  padding: 5px 16px;
  flex-shrink: 0;
}

/* ── Auth area ── */
#auth-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
#auth-area img {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
}
#auth-area span { color: #ccd; }
.btn-signin {
  background: #fff; color: #1a1a2e;
  border: none; border-radius: 5px;
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn-signin:hover { background: #e8ecff; }
.btn-signout {
  background: none; border: 1px solid #555;
  color: #ccd; border-radius: 4px;
  padding: 3px 9px; font-size: 11px; cursor: pointer;
}
.btn-signout:hover { background: rgba(255,255,255,0.1); }

/* ── Settings toggle header in sidebar ── */
#settings-toggle-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 2px 0 8px;
}
#settings-toggle-header:hover h2 { color: #4a6cf7; }
#settings-chevron { font-size: 10px; color: #aaa; }

/* ── Generic collapsible sub-section headers ── */
.sb-collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 2px 0 6px;
}
.sb-collapsible-header:hover h2 { color: #4a6cf7; }
.sb-collapsible-chevron { font-size: 10px; color: #aaa; }

/* ── History in sidebar ── */
#sidebar-history-section { border-top: 1px solid #eaecf0; padding-top: 8px; margin-top: 4px; }
#history-list { padding: 4px 0; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.history-filter { display: flex; gap: 2px; }
.history-filter-btn {
  border: 0; background: transparent; color: #7a8290; font-size: 11px;
  padding: 3px 5px; border-radius: 4px; cursor: pointer;
}
.history-filter-btn.active, .history-filter-btn:hover { background: #eef1ff; color: #405cc9; }

.history-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  display: flex; align-items: center; gap: 4px; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.history-item:hover { background: linear-gradient(to right, transparent 8px, #f5f8ff 8px); }
.history-item.active { background: linear-gradient(to right, transparent 8px, #eef1ff 8px); }
.history-item.loading { opacity: 0.55; pointer-events: none; }
.history-item.loading .history-title::after { content: ' …'; color: #aaa; }
.history-item-main {
  flex: 1; min-width: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.history-title-row { display: flex; align-items: center; min-width: 0; }
.history-bookmark-indicator {
  position: absolute; left: -4px; top: 10px;
  color: #d49300; font-size: 13px; line-height: 1;
}
.history-title { font-size: 13px; color: #222; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date { font-size: 11px; color: #aaa; margin-top: 2px; }
.history-empty { padding: 24px 16px; color: #bbb; font-size: 13px; text-align: center; }
.history-menu-btn {
  display: none; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: #ccc; padding: 0 4px; border-radius: 4px; line-height: 1;
}
.history-item:hover .history-menu-btn { display: block; }
.history-menu-btn:hover { background: #e8eeff; color: #4a6cf7; }

#conv-menu {
  display: none;
  position: fixed;
  background: #fff;
  border: 1px solid #e0e4ec;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 300;
  min-width: 160px;
  padding: 4px 0;
}
.conv-menu-item {
  display: block; width: 100%; border: 0; background: transparent; text-align: left;
  padding: 9px 16px; font-size: 13px; color: #333; cursor: pointer;
}
.conv-menu-item:hover { background: #f5f8ff; }
.conv-menu-item-danger { color: #c03030; }
.conv-menu-item-danger:hover { background: #fff0f0; }

@media (max-width: 640px) {
  .history-menu-btn { display: block; }
}

/* ── Save indicator ── */
#save-indicator {
  font-size: 12px;
  color: #4a6cf7;
  font-weight: 600;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: opacity 0.4s ease, max-width 0.4s ease;
  pointer-events: none;
}
#save-indicator.visible { opacity: 1; max-width: 80px; }

/* ── Status line (compact view during streaming) ── */
#status-section {
  display: none;
  align-items: center;
  gap: 8px;
  color: #888;
  font-size: 13px;
  font-style: italic;
  padding: 4px 0 12px;
}
#status-section.visible { display: flex; }

/* ── Debate details collapsible ── */
#details-section {
  display: none;
  margin-bottom: 20px;
  border: 1px solid #eef0f5;
  border-radius: 8px;
  overflow: hidden;
}
#details-header {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  background: #f8f9fb;
  cursor: pointer;
}
#details-header:hover { background: #f0f4ff; }
#details-toggle {
  background: none; border: none;
  color: #4a6cf7; font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 0;
}
#details-body {
  display: none;
  padding: 16px 14px 4px;
  border-top: 1px solid #eef0f5;
}

/* ── Summary / final answer ── */
#summary-section { }

/* ── Follow-up area ── */
#followup-area {
  display: none;
  margin-top: 24px;
  border-top: 2px solid #eef0f5;
  padding-top: 16px;
}
#followup-area textarea {
  width: 100%;
  height: 60px;
  border: 1px solid #dde1e9;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
}
#followup-area textarea:focus { outline: none; border-color: #4a6cf7; }
#followup-area textarea:disabled { background: #f5f5f5; color: #aaa; cursor: not-allowed; resize: none; }
#followup-controls {
  display: flex;
  align-items: center;
  margin-top: 8px;
  gap: 8px;
}
#followup-cost-estimate { flex: 1; }

/* ── Per-follow-up blocks ── */
.followup-block {
  margin-top: 16px;
  padding: 14px 16px 8px;
  background: #f0f7ff;
  border: 1px solid #d4e6ff;
  border-radius: 8px;
}
.followup-block.followup-alt {
  background: #fff;
  border-color: #e8eaf0;
}
.followup-header { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid rgba(0,0,0,.06); }
.followup-label { font-size: 11px; font-weight: 600; color: #4a6cf7; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.followup-question { font-size: 15px; font-weight: 700; color: #1a1a2e; line-height: 1.4; }
/* ── Collapsible Disagreement Resolution ── */
.disag-section { margin-top: 16px; }
.disag-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; color: #4a6cf7; font-size: 12px; font-weight: 600; font-family: inherit;
  padding: 4px 0; user-select: none; border: none; background: none;
}
.disag-toggle:hover { text-decoration: underline; }
.followup-status-section {
  display: none;
  align-items: flex-start;
  gap: 8px;
  color: #888;
  font-size: 13px;
  font-style: italic;
  padding: 4px 0 12px;
}
.followup-status-section.visible { display: flex; }
.followup-details-section {
  display: none;
  margin-bottom: 20px;
  border: 1px solid #eef0f5;
  border-radius: 8px;
  overflow: hidden;
}
.followup-details-header {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  background: #f8f9fb;
  cursor: pointer;
}
.followup-details-header:hover { background: #f0f4ff; }
.followup-details-toggle {
  background: none; border: none;
  color: #4a6cf7; font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 0;
}
.followup-details-body {
  display: none;
  padding: 16px 14px 4px;
  border-top: 1px solid #eef0f5;
}

/* ── Conversation TOC ── */
#conv-toc {
  background: #f8f9fb;
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
}
.conv-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.conv-toc-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.conv-toc-num {
  font-weight: 700;
  color: #4a6cf7;
  flex-shrink: 0;
  font-size: 11px;
  min-width: 24px;
}
.conv-toc-link {
  color: #444;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.conv-toc-link:hover { color: #4a6cf7; text-decoration: underline; }
