:root {
  --bg:        #0a0a0f;
  --surface:   #111118;
  --surface-2: #18181f;
  --surface-3: #222230;
  --border:    #2a2a3c;
  --text:      #e8e8f2;
  --text-2:    #8888aa;
  --text-3:    #4a4a6a;
  --consensus: #9333ea;
  --brand-a:   #9C6B3F;   /* polecat brown  */
  --brand-b:   #d4773b;   /* warm amber     */
  --brand-c:   #F4A6A6;   /* blush          */
  --radius:    12px;
  --radius-sm: 8px;
}
[data-theme="light"] {
  --bg:        #f4f4fb;
  --surface:   #ffffff;
  --surface-2: #ebebf5;
  --surface-3: #e0e0ee;
  --border:    #d0d0e4;
  --text:      #111120;
  --text-2:    #55556e;
  --text-3:    #9090b0;
}
[data-theme="light"] #hljs-theme { display: none; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
/* Frame layout (rail | topbar+view) comes from the shell's body.ps-shell rule;
   this app keeps only its type + theme-transition choices on top. */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  transition: background .2s, color .2s;
}

/* ── Animated background (aurora) ─────────────────────────── */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 1.4s ease; }
body.processing .aurora { opacity: 1; }
.aurora span { position: absolute; border-radius: 50%; filter: blur(75px); opacity: .42; mix-blend-mode: screen; will-change: transform; }
.aurora span:nth-child(1) { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: radial-gradient(circle, var(--brand-b), transparent 68%); animation: aur1 19s ease-in-out infinite; }
.aurora span:nth-child(2) { width: 42vmax; height: 42vmax; right: -14vmax; top: 6vmax; background: radial-gradient(circle, var(--consensus), transparent 68%); animation: aur2 24s ease-in-out infinite; }
.aurora span:nth-child(3) { width: 38vmax; height: 38vmax; left: 24vmax; bottom: -18vmax; background: radial-gradient(circle, var(--brand-c), transparent 68%); animation: aur3 28s ease-in-out infinite; }
[data-theme="light"] .aurora span { opacity: .3; mix-blend-mode: multiply; }
@keyframes aur1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(9vmax,7vmax) scale(1.16); } }
@keyframes aur2 { 0%,100% { transform: translate(0,0) scale(1.05); } 50% { transform: translate(-8vmax,9vmax) scale(.92); } }
@keyframes aur3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(6vmax,-8vmax) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } }

/* ── Topbar chrome (mounted into the shell's .ps-topbar) ─── */
.logo { display: flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 700; letter-spacing: -.4px; white-space: nowrap; }
.logo-mark { flex-shrink: 0; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.logo-grad {
  background: linear-gradient(120deg, var(--brand-a) 0%, var(--brand-b) 55%, var(--brand-c) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.logo-ver { font-size: 9px; font-weight: 400; color: var(--text-2); letter-spacing: 0; margin-left: 5px; font-variant-numeric: tabular-nums; }
.logo-ver:empty { display: none; }
.header-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  height: 32px; min-width: 32px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; transition: all .15s;
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 0 10px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { pointer-events: none; flex-shrink: 0; }
.icon-btn.icon-only { padding: 0; width: 32px; }

/* ── App layout (transcript scrolls, composer docked at bottom) ─────── */
.app { position: relative; z-index: 1; flex: 1; min-height: 0; width: 100%; max-width: 1100px; margin: 0 auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

/* Transcript area grows and scrolls above the composer */
.responses { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: background .25s, border-color .25s; }
.tab-bar { flex-shrink: 0; }
#tabPanels { flex: 1; min-height: 0; }
#tabPanels:empty { flex: 0; }

/* Greeting shown before the first message */
.chat-greeting { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 32px 24px; }
.chat-greeting.hidden { display: none; }
.cg-mark { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 2px; }
.cg-mark svg { animation: cg-float 3.8s ease-in-out infinite; }
@keyframes cg-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .cg-mark svg { animation: none; } }
.cg-brand { font-size: 30px; font-weight: 900; letter-spacing: -.5px; }
.cg-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; color: var(--text-2); }
.cg-sub { font-size: 14px; color: var(--text-2); line-height: 1.6; max-width: 420px; }
.cg-try { font-family: inherit; font-size: 14px; font-weight: 700; color: #fff; background: linear-gradient(120deg, #10b981, #0ea5e9); border: none; border-radius: 100px; padding: 11px 22px; cursor: pointer; box-shadow: 0 6px 22px color-mix(in srgb, #10b981 35%, transparent); transition: transform .12s, box-shadow .12s, opacity .12s; }
.cg-try:hover { transform: translateY(-1px); box-shadow: 0 8px 28px color-mix(in srgb, #10b981 45%, transparent); }
.cg-try[hidden] { display: none; }
.cg-suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; margin-top: 6px; transition: opacity .22s ease; }
.cg-hint { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.cg-hint[hidden] { display: none; }
.cg-chip { font-family: inherit; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; padding: 8px 14px; cursor: pointer; transition: transform .12s, border-color .12s, color .12s, background .12s; }
.cg-chip:hover { color: var(--text); border-color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 9%, var(--surface-2)); transform: translateY(-1px); }

/* ── Image lightbox ──────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 600; display: none; align-items: center; justify-content: center; padding: 32px; cursor: zoom-out; }
.lightbox::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 0; }
.lightbox.open { display: flex; animation: lb-fade .18s ease; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { position: relative; z-index: 1; max-width: 96vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.6); cursor: default; }
.lightbox-close { position: absolute; z-index: 2; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; transition: background .15s; }
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ── Composer (bottom-docked) ───────────────────────────────────────── */
.composer { position: relative; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.prompt-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.prompt-card:focus-within { border-color: var(--text-3); }
.composer.dragover .prompt-card { border-color: var(--brand-b); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-b) 22%, transparent); }
.prompt-input { width: 100%; background: none; border: none; color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.6; padding: 14px; resize: none; min-height: 56px; max-height: 200px; outline: none; }
.prompt-input::placeholder { color: var(--text-3); font-size: 13px; }
.prompt-footer { display: flex; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); gap: 8px; }

/* attach button */
.attach-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer; transition: all .15s; }
.attach-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }
.attach-btn svg { pointer-events: none; }

/* attachment thumbnails */
.attach-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 12px 0; }
.attach-strip[hidden] { display: none; }
.attach-thumb { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb .at-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: none; background: rgba(0,0,0,.62); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; }
.attach-thumb .at-x:hover { background: #f87171; }

/* file chip in the attach strip (non-image docs) */
.attach-file-chip { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 8px 0 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; color: var(--text-2); max-width: 200px; flex-shrink: 0; }
.attach-file-chip svg { flex-shrink: 0; color: var(--text-3); }
.afc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; color: var(--text); }
.afc-size { color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.attach-file-chip .at-x { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 1px; border-radius: 4px; flex-shrink: 0; }
.attach-file-chip .at-x:hover { color: #f87171; }
.attach-file-chip.pending { opacity: .7; }
.attach-file-chip.error { border-color: rgba(248,113,113,.45); background: rgba(248,113,113,.08); animation: afc-err-in .2s ease; }
@keyframes afc-err-in { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.afc-err-label { color: #f87171 !important; }
.afc-spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--text-2); animation: tab-spin .65s linear infinite; flex-shrink: 0; }

/* vision capability note under composer */
.vision-note { font-size: 11.5px; color: var(--text-2); padding: 2px 6px; line-height: 1.55; overflow-wrap: break-word; }
.vision-note b { color: var(--text); }
.vision-note .vn-warn { color: #f0a830; }
.vn-privacy { color: var(--text-3); font-size: 10.5px; }

/* drag-drop hint */
.drop-hint { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: color-mix(in srgb, var(--brand-b) 12%, var(--surface)); border: 2px dashed var(--brand-b); border-radius: var(--radius); color: var(--text); font-weight: 700; font-size: 14px; pointer-events: none; z-index: 5; }
.composer.dragover .drop-hint { display: flex; }

/* ── Model chips ─────────────────────────────────────────── */
.model-chips-wrap { position: relative; display: flex; flex: 1; min-width: 0; }
.model-chips { display: flex; gap: 5px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; align-items: center; }
.model-chips::-webkit-scrollbar { display: none; }
/* Fade hint on the right edge when the chip row has more content than fits (mobile) */
.mc-fade { position: absolute; top: 0; right: 0; bottom: 0; width: 22px; pointer-events: none; opacity: 0; transition: opacity .15s; background: linear-gradient(to right, transparent, var(--surface) 70%); border-radius: 0 8px 8px 0; }
.mc-fade.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .mc-fade { transition: none; } }
.m-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 5px 3px 8px; border-radius: 100px; border: 1px solid var(--border);
  font-size: 11px; white-space: nowrap; color: var(--text-2); flex-shrink: 0;
  transition: border-color .15s; font-family: inherit;
}
.m-chip:hover { border-color: var(--text-3); }
.m-chip-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c, #888); flex-shrink: 0; }
.m-chip-label { color: var(--text-2); }
.m-chip-x { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; border-radius: 4px; }
.m-chip-x:hover { color: #f87171; }
.m-chip-vision { display: inline-flex; align-items: center; opacity: .85; }
/* when an image is attached, dim models that can't read it + flag vision ones */
.m-chip.has-vision { border-color: color-mix(in srgb, #34d399 45%, var(--border)); }
.m-chip.no-vision { opacity: .55; }
.m-chip.no-vision .m-chip-novision { display: inline-flex; align-items: center; color: #f0a830; }
.m-chip-add { cursor: pointer; padding: 4px 10px; color: var(--text-2); border-style: dashed; background: none; font-family: inherit; }
.m-chip-add:hover { color: var(--text); }
.m-chip.disabled { opacity: .45; pointer-events: none; }
.no-config-hint { font-size: 11px; color: var(--text-2); }
.no-config-hint button { background: none; border: none; color: var(--brand-b); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline; }

.send-btn { display: flex; align-items: center; gap: 5px; background: var(--text); color: var(--bg); border: none; border-radius: var(--radius-sm); padding: 7px 10px; font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; transition: opacity .15s; white-space: nowrap; flex-shrink: 0; }
.send-btn:hover { opacity: .82; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn kbd { font-family: inherit; font-size: 10px; opacity: .55; font-weight: 400; }
/* Stop button — shown during processing, hides send button */
.stop-btn { display: none; align-items: center; gap: 5px; background: #ef4444; color: #fff; border: none; border-radius: var(--radius-sm); padding: 7px 12px; font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .15s; white-space: nowrap; flex-shrink: 0; }
.stop-btn:hover:not(:disabled) { background: #dc2626; }
.stop-btn:disabled { opacity: .6; cursor: not-allowed; }
body.processing .stop-btn { display: flex; }
body.processing .send-btn { display: none; }
/* Subtle "(stopped)" label appended to partially-streamed responses */
.msg-stopped { font-size: 11px; color: var(--text-3); margin-left: 4px; font-style: italic; }
@media (max-width: 520px) { .send-text { display: none; } }

/* ── Responses / tabs ────────────────────────────────────── */
.tab-bar-wrap { position: relative; flex-shrink: 0; }
.tab-bar { display: flex; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tab-bar:empty { display: none; }
.tab-bar::-webkit-scrollbar { display: none; }
/* Fade hint on the right edge when the tab bar has tabs scrolled off-screen —
   same affordance as .mc-fade on the composer's model-chip row. Without it a
   phone user has no visual cue that e.g. the Consensus tab is off to the side. */
.tb-fade { position: absolute; top: 0; right: 0; bottom: 1px; width: 28px; pointer-events: none; opacity: 0; transition: opacity .15s; background: linear-gradient(to right, transparent, var(--surface) 65%); }
.tb-fade.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tb-fade { transition: none; } }
.tab { display: flex; align-items: center; gap: 6px; padding: 10px 16px; font-family: inherit; font-size: 12px; font-weight: 600; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-2); white-space: nowrap; flex-shrink: 0; transition: color .15s, border-color .15s; }
.tab.active { color: var(--text); }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; position: relative; }
.tab-dot.loading::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--dot-c, #888); border-top-color: transparent; animation: tab-spin .65s linear infinite; }
@keyframes tab-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.tab-dot.done { animation: pop .35s cubic-bezier(.36,.07,.19,.97); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }
.tab-step { font-size: 9px; color: var(--text-3); display: block; line-height: 1; margin-top: 2px; }
.tab-step:empty { display: none; }
.tab-inner { display: flex; flex-direction: column; justify-content: center; }
/* Agreement-level badge in the Consensus tab — visible after synthesis, no click needed */
.tab-agree-badge { display: block; font-size: 9px; font-weight: 600; padding: 1px 6px; border-radius: 100px; margin-top: 2px; line-height: 1.5; letter-spacing: .02em; animation: tab-badge-in .25s ease both; }
@keyframes tab-badge-in { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .tab-agree-badge { animation: none; } }
.tab-agree-badge[hidden] { display: none; }
.tab-agree-high { color: #34d399; background: rgba(52,211,153,.13); }
.tab-agree-mid  { color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 14%, transparent); }
.tab-agree-low  { color: var(--text-3); background: var(--surface-3); }
[data-theme="light"] .tab-agree-high { color: #059669; background: rgba(5,150,105,.10); }
.tab-stance { display: block; font-size: 9px; font-weight: 600; padding: 1px 6px; border-radius: 100px; margin-top: 2px; line-height: 1.5; letter-spacing: .02em; animation: tab-badge-in .25s ease both; }
.tab-stance[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .tab-stance { animation: none; } }
.tab-stance-aligned { color: #34d399; background: rgba(52,211,153,.13); }
.tab-stance-partial { color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 14%, transparent); }
.tab-stance-outlier { color: #fb923c; background: rgba(251,146,60,.12); }
[data-theme="light"] .tab-stance-aligned { color: #059669; background: rgba(5,150,105,.10); }
[data-theme="light"] .tab-stance-outlier { color: #ea580c; background: rgba(234,88,12,.10); }

/* First-run Consensus tab callout — shown once, auto-dismisses */
.cons-onboard-tip {
  position: fixed; z-index: 500;
  background: var(--surface-2); border: 1px solid color-mix(in srgb, var(--consensus) 38%, var(--border));
  border-radius: 8px; padding: 10px 28px 10px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  font-size: 12.5px; color: var(--text-2); line-height: 1.5; max-width: 260px;
  animation: cons-tip-in .3s ease both;
  pointer-events: auto;
}
.cons-onboard-tip::before {
  content: ''; position: absolute; top: -5px; left: 16px;
  width: 8px; height: 8px;
  background: var(--surface-2);
  border-left: 1px solid color-mix(in srgb, var(--consensus) 38%, var(--border));
  border-top: 1px solid color-mix(in srgb, var(--consensus) 38%, var(--border));
  transform: rotate(45deg);
}
.cons-onboard-tip strong { color: var(--text); }
.cons-onboard-dismiss { position: absolute; right: 7px; top: 7px; background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 16px; line-height: 1; padding: 0 3px; transition: color .12s; }
.cons-onboard-dismiss:hover { color: var(--text-2); }
.cons-onboard-tip.tip-out { opacity: 0; transform: translateY(-5px); transition: opacity .3s, transform .3s; }
@keyframes cons-tip-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .cons-onboard-tip { animation: none; } .cons-onboard-tip.tip-out { transition: none; } }

/* Demo handoff — staggered chip entrance after "Try it free" */
@keyframes cg-chip-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.cg-suggest.demo-ready .cg-chip { animation: cg-chip-enter .35s ease both; }
.cg-suggest.demo-ready .cg-chip:nth-child(2) { animation-delay: .06s; }
.cg-suggest.demo-ready .cg-chip:nth-child(3) { animation-delay: .12s; }
.cg-suggest.demo-ready .cg-chip:nth-child(4) { animation-delay: .18s; }
@media (prefers-reduced-motion: reduce) { .cg-suggest.demo-ready .cg-chip { animation: none; } }

.tab-panel { display: none; height: 100%; flex-direction: column; }
.tab-panel.active { display: flex; }
.conversation { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 0; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.conversation::-webkit-scrollbar { width: 4px; }
.conversation::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.qa-pair { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
.qa-pair + .qa-pair { border-top: 1px solid var(--border); padding-top: 16px; }

.msg { display: flex; flex-direction: column; gap: 3px; }
.msg.user { align-items: flex-end; }
.msg-label { font-size: 10px; color: var(--text-2); font-weight: 600; padding: 0 4px; text-transform: uppercase; letter-spacing: .4px; }
.msg-bubble { max-width: 90%; padding: 10px 14px; font-size: 14px; line-height: 1.65; border-radius: var(--radius); }
.msg.user .msg-bubble { background: var(--surface-3); border-radius: var(--radius) var(--radius) 4px var(--radius); }
.msg.assistant .msg-bubble { background: var(--surface-2); border-radius: var(--radius) var(--radius) var(--radius) 4px; }
.msg.assistant .msg-bubble p { margin-bottom: .7em; }
.msg.assistant .msg-bubble p:last-child { margin-bottom: 0; }
.msg.assistant .msg-bubble pre { background: #0d1117; padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 10px 0; font-size: 13px; }
.msg.assistant .msg-bubble code:not(pre code) { background: var(--surface-3); padding: 2px 5px; border-radius: 4px; font-size: .9em; font-family: 'SF Mono', 'Fira Code', monospace; }
.msg.assistant .msg-bubble pre code { background: none; padding: 0; font-size: inherit; }
.msg.assistant .msg-bubble h1, .msg.assistant .msg-bubble h2, .msg.assistant .msg-bubble h3 { margin: .8em 0 .4em; font-size: 1em; font-weight: 700; }
.msg.assistant .msg-bubble ul, .msg.assistant .msg-bubble ol { padding-left: 1.4em; margin: .5em 0; }
.msg.assistant .msg-bubble li { margin-bottom: .3em; }
.msg.assistant .msg-bubble blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--text-2); margin: .5em 0; }
.msg.assistant .msg-bubble table { border-collapse: collapse; width: 100%; margin: .8em 0; font-size: 13px; }
.msg.assistant .msg-bubble th, .msg.assistant .msg-bubble td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; }
.msg.assistant .msg-bubble th { background: var(--surface-3); font-weight: 600; }
.msg-error { color: #f87171; font-size: 13px; }
.msg-empty { color: var(--text-3); font-size: 13px; font-style: italic; }
/* image attachments inside a message */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; max-width: 90%; }
.msg.user .msg-attachments { justify-content: flex-end; }
/* "Edit prompt" hover action on user messages */
.msg-user-actions { display: flex; justify-content: flex-end; padding: 2px 0; opacity: 0; transition: opacity .15s; }
.msg.user:hover .msg-user-actions, .msg.user:focus-within .msg-user-actions { opacity: 1; }
.user-edit-btn { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 3px 6px; border-radius: 5px; display: inline-flex; align-items: center; line-height: 0; transition: all .15s; }
.user-edit-btn:hover { color: var(--text); background: var(--surface-3); }
@media (hover: none) { .msg-user-actions { opacity: .55; } }
.msg-thumb { width: 130px; max-width: 46vw; height: auto; max-height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; cursor: zoom-in; }
.msg-file-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border); border-radius: 100px; padding: 4px 10px; }
.msg-file-chip svg { flex-shrink: 0; }
.loading-dots { display: flex; gap: 4px; padding: 6px 2px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: bounce-dot 1.2s ease-in-out infinite; }
.dot:nth-child(2) { animation-delay: .18s; } .dot:nth-child(3) { animation-delay: .36s; }
@keyframes bounce-dot { 0%,80%,100% { transform: scale(.75); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); font-size: 13px; padding: 40px 0; text-align: center; }
.empty-icon { opacity: .3; color: var(--text-2); }
.consensus-glyph { opacity: 1; color: var(--brand-b); }

/* live consensus progress */
.consensus-progress { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 26px 16px; text-align: center; }
.cp-glyph { color: var(--brand-b); animation: cp-pulse 1.4s ease-in-out infinite; }
@keyframes cp-pulse { 0%,100% { opacity: .55; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }
.cp-title { font-size: 15px; font-weight: 700; color: var(--text); }
.cp-strategy { font-size: 11.5px; color: var(--text-3); }
.cp-phase { font-size: 13px; color: var(--text-2); }
.cp-models { list-style: none; display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 320px; margin-top: 2px; padding: 0; }
.cp-model { display: flex; flex-direction: column; align-items: stretch; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; gap: 0; }
.cp-model.cp-pending { opacity: .65; }
.cp-row { display: flex; align-items: center; gap: 9px; }
.cp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #888); flex-shrink: 0; }
.cp-name { flex: 1; text-align: left; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-stat { display: flex; align-items: center; flex-shrink: 0; width: 16px; height: 16px; justify-content: center; }
.cp-preview { display: none; font-size: 11px; color: var(--text-3); padding-left: 17px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; animation: cs-fade .25s ease; }
.cp-preview.has-text { display: block; }
@media (prefers-reduced-motion: reduce) { .cp-preview { animation: none; } }
.cp-step { font-size: 12px; color: var(--text-3); font-style: italic; margin-top: 2px; }
.cp-agree-teaser { display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 5px 12px; border-radius: 100px; margin-top: 2px; animation: tab-badge-in .35s ease both; }
@media (prefers-reduced-motion: reduce) { .cp-agree-teaser { animation: none; } }
.cp-agree-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: currentColor; animation: cp-pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .cp-agree-dot { animation: none; } }
.cp-agree-high { color: #34d399; background: rgba(52,211,153,.1); }
.cp-agree-mid  { color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 10%, transparent); }
.cp-agree-low  { color: var(--text-2); background: var(--surface-3); }
[data-theme="light"] .cp-agree-high { color: #059669; background: rgba(5,150,105,.09); }
.cp-stream-ind, .cp-wait-ind { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid transparent; }
.cp-stream-ind { border-top-color: var(--brand-b); animation: cp-spin .7s linear infinite; }
.cp-wait-ind   { border-top-color: var(--text-3); animation: cp-spin 1.2s linear infinite; opacity: .55; }
@keyframes cp-spin { to { transform: rotate(360deg); } }

/* consensus source attribution — under a finished consensus answer */
.consensus-sources { margin: 11px 0 2px; padding: 11px 0 0; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; max-width: 90%; animation: cs-fade .45s ease both; }
@keyframes cs-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .consensus-sources { animation: none; } }
.cs-label { font-size: 11px; font-weight: 600; color: var(--text-3); }
.cs-timerange { font-variant-numeric: tabular-nums; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-chip { display: inline-flex; align-items: center; gap: 5px; font-family: inherit; font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; padding: 4px 11px; cursor: pointer; transition: color .12s, border-color .12s, background .12s, transform .12s; }
.cs-chip:hover { color: var(--text); border-color: var(--c, var(--text-3)); background: color-mix(in srgb, var(--c) 10%, var(--surface-2)); transform: translateY(-1px); }
.cs-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c, #888); flex-shrink: 0; }
.cs-chip.cs-arbiter { color: var(--text); font-weight: 600; border-color: color-mix(in srgb, var(--consensus) 50%, var(--border)); }
.cs-chip.cs-arbiter .cs-dot { background: var(--consensus); }
/* Screen-reader-only text: visually hidden but announced by assistive tech. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Compact race-bar: shows each model's relative response time as a colored dot
   on a horizontal track — the leftmost dot = fastest, rightmost = slowest. */
.cs-race { padding: 6px 0 2px; }
.cs-race-caption { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); margin: 0 1px 6px; }
.cs-race-axis { opacity: .75; }
.cs-race-track {
  position: relative; height: 2px; background: var(--border); border-radius: 2px;
  overflow: visible;
}
.cs-race-dot {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  top: 50%; transform: translate(-50%, -50%);
  border: 1.5px solid var(--bg); padding: 0; appearance: none; outline: none;
  cursor: pointer; transition: transform .12s;
}
.cs-race-dot:hover { transform: translate(-50%, -50%) scale(1.3); }
@media (prefers-reduced-motion: reduce) { .cs-race-dot { transition: none; } }
/* Tooltip: shown on hover (desktop) or tap-toggled .cs-tip-open class (mobile,
   since hover isn't reliable on touch). */
.cs-race-dot::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--surface-3, var(--surface-2)); color: var(--text); border: 1px solid var(--border);
  font-size: 11px; font-weight: 500; white-space: nowrap; padding: 4px 8px; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  opacity: 0; pointer-events: none; transition: opacity .12s;
  z-index: 5;
}
.cs-race-dot:hover::after, .cs-race-dot.cs-tip-open::after { opacity: 1; }

/* Consensus insight — one-liner agreement summary, shown right after the answer */
.consensus-insight {
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
  padding: 7px 12px; margin: 10px 0 0;
  background: var(--surface-2); border-radius: 7px;
  animation: cs-fade .4s ease both;
}
@media (prefers-reduced-motion: reduce) { .consensus-insight { animation: none; } }

/* Consensus "synthesizing" placeholder — subtle typing dots shown in the answer
   bubble until the arbiter's first token arrives, so it's never an empty box. */
.cons-thinking { display: flex; align-items: center; gap: 10px; padding: 3px 0; color: var(--text-3); animation: cs-fade .35s ease both; }
.cons-thinking-dots { display: inline-flex; gap: 5px; }
.cons-thinking-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: cons-dot 1.15s ease-in-out infinite; }
.cons-thinking-dots i:nth-child(2) { animation-delay: .18s; }
.cons-thinking-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes cons-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: .9; transform: translateY(-3px); } }
.cons-thinking-label { font-size: 12.5px; letter-spacing: .01em; }
/* Answer fades/rises in once the first token replaces the placeholder. */
.cons-answer-in { animation: cons-answer-fade .45s ease both; }
@keyframes cons-answer-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .cons-thinking, .cons-answer-in { animation: none; }
  .cons-thinking-dots i { animation: none; opacity: .6; }
}

/* Arbiter-failure notice — warm amber, sits above the fallback consensus answer. */
.consensus-fallback-note {
  font-size: 12.5px; line-height: 1.5;
  padding: 8px 12px; margin: 0 0 10px;
  color: #9a6a00; background: rgba(240, 168, 48, .12);
  border: 1px solid rgba(240, 168, 48, .35); border-radius: 7px;
}
[data-theme="dark"] .consensus-fallback-note { color: #f0c069; }

/* Proactive arbiter-health warning — same amber language, shown in the
   Consensus tab under "Final answer written by" when that model has no key
   or a known-bad one, instead of only explaining it after a run falls back. */
.arb-health-warn {
  font-size: 12px; line-height: 1.5;
  padding: 7px 10px; margin: 6px 0 0;
  color: #9a6a00; background: rgba(240, 168, 48, .12);
  border: 1px solid rgba(240, 168, 48, .35); border-radius: 7px;
}
[data-theme="dark"] .arb-health-warn { color: #f0c069; }

/* ── Modal ───────────────────────────────────────────────── */
/* The blur lives on a ::before layer (not the modal's ancestor) so the panel
   itself never renders blurred on open. */
.backdrop { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px; }
.backdrop::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 0; }
.backdrop.open { display: flex; }
.modal { position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 520px; min-width: 0; max-height: 90vh; overflow: hidden auto; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-title { font-size: 14px; font-weight: 700; }
/* Sizes to each tab's own content (short tabs like Support stay compact); a
   tall tab caps out and scrolls internally instead of growing the modal. */
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 22px; max-height: clamp(300px, 62vh, 470px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.cfg-tabs { display: flex; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.cfg-tabs::-webkit-scrollbar { display: none; }
.cfg-tab { flex: 1 1 auto; min-width: max-content; background: none; border: none; border-radius: var(--radius-sm); color: var(--text-2); font-family: inherit; font-size: 12px; font-weight: 700; padding: 7px 12px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.cfg-tab:hover { background: var(--surface-2); color: var(--text); }
.cfg-tab.active { background: var(--surface-3); color: var(--text); }
.cfg-section { display: none; flex-direction: column; gap: 12px; }
.cfg-section.active { display: flex; }
.cfg-h { font-size: 13px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cfg-sub { font-size: 11px; font-weight: 400; color: var(--text-2); }
.cfg-divider { border-top: 1px solid var(--border); margin: 4px 0 0; }
.cfg-subhead { font-size: 12px; font-weight: 700; margin: 0; color: var(--text); }
.field-input { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; padding: 8px 12px; width: 100%; outline: none; transition: border-color .15s; }
select.field-input { font-family: inherit; cursor: pointer; min-width: 0; max-width: 100%; }
.field-input:focus { border-color: var(--text-2); }
.field-hint { font-size: 11px; color: var(--text-2); }
.field-hint a { color: var(--text-2); }
.security-note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 12px; color: var(--text-2); line-height: 1.5; }
.muted-hint { font-size: 12px; color: var(--text-3); padding: 4px 2px; }

/* result copy button */
.msg-head { display: flex; align-items: center; gap: 8px; }
.msg-time { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 3px; opacity: .85; }
.msg-time::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .55; }
.copy-btn { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 6px; margin: -4px; border-radius: 7px; display: inline-flex; line-height: 0; opacity: .7; transition: all .15s; }
.copy-btn:hover { color: var(--text); background: var(--surface-3); opacity: 1; }
.copy-btn.copied { color: #34d399; }
.regen-btn:hover svg { animation: regen-spin .45s ease-in-out; }
@keyframes regen-spin { to { transform: rotate(-360deg); } }

/* consensus switch + arbiter */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.switch-sub { font-size: 11px; color: var(--text-3); font-weight: 400; }
.switch { width: 40px; height: 23px; border-radius: 100px; background: var(--surface-3); border: 1px solid var(--border); position: relative; cursor: pointer; flex-shrink: 0; transition: background .18s; }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-b) 35%, transparent); }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--text-2); transition: transform .18s, background .18s; }
.switch.on { background: var(--brand-b); border-color: var(--brand-b); }
.switch.on .knob { transform: translateX(17px); background: #fff; }
.arb-body { display: flex; flex-direction: column; gap: 10px; }
.arb-body[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.mini-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-3); font-weight: 700; }
.mini-note { text-transform: none; letter-spacing: 0; color: var(--text-2); font-weight: 400; }

/* model status badges */
.sel-status { font-size: 12px; width: 18px; text-align: center; cursor: pointer; flex-shrink: 0; color: var(--text-3); }
.sel-status.ok { color: #34d399; }
.sel-status.bad { color: #f87171; }
.sel-status.slow { color: #f59e0b; }
.sel-status.testing { color: var(--brand-b); }
.test-all { width: 100%; margin-top: 8px; font-size: 12px; }
.m-chip.failing { border-color: #f8717155; }
.m-chip.failing .m-chip-dot { background: #f87171 !important; }

/* live model browse/search */
.browse-bar { display: flex; }
.browse-btn { width: 100%; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.browse-btn[hidden] { display: none; }
.browse-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.browse-panel[hidden] { display: none; }
.browse-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.browse-list::-webkit-scrollbar { width: 5px; }
.browse-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.browse-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; cursor: pointer; font-family: inherit; color: var(--text); transition: border-color .12s, background .12s; }
.browse-item:hover { border-color: var(--text-3); background: var(--surface-3); }
.browse-item.added { opacity: .6; }
.bi-id { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.bi-free { font-size: 10px; font-weight: 700; color: #34d399; background: rgba(52,211,153,.12); padding: 1px 6px; border-radius: 100px; }
.bi-ctx { font-size: 10px; color: var(--text-3); }
.bi-added { color: #34d399; font-weight: 700; }

/* selections */
.sel-list { display: flex; flex-direction: column; gap: 8px; }
.sel-item { display: flex; flex-direction: column; gap: 2px; }
.sel-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sel-perf-note { font-size: 10px; padding-left: 17px; color: var(--text-3); line-height: 1.3; }
/* reorder arrows */
.sel-move { display: flex; flex-direction: column; gap: 0; flex-shrink: 0; }
.sel-mv { display: flex; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; color: var(--text-3); padding: 1px 3px; border-radius: 3px; }
.sel-mv:hover:not(:disabled) { color: var(--text-1); background: var(--surface-3); }
.sel-mv:disabled { opacity: .22; cursor: default; }
/* arbiter badge button */
.sel-arb { background: none; border: 1px solid var(--border); border-radius: 100px; font-size: 9px; font-weight: 700; letter-spacing: .3px; cursor: pointer; color: var(--text-3); padding: 1px 7px; white-space: nowrap; flex-shrink: 0; transition: background .12s, color .12s; }
.sel-arb:hover:not(.arb-on) { border-color: var(--brand-b); color: var(--brand-b); }
.sel-arb.arb-on { background: var(--brand-b); border-color: var(--brand-b); color: #fff; }
/* arbiter-only sub-row */
.sel-arb-only-row { padding-left: 20px; padding-top: 2px; }
.sel-arb-only-label { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); cursor: pointer; user-select: none; }
.sel-arb-only-cb { width: 13px; height: 13px; flex-shrink: 0; accent-color: var(--brand-b); cursor: pointer; }
.sel-perf-note.perf-good { color: #34d399; opacity: .85; }
.sel-perf-note.perf-outlier { color: #f59e0b; opacity: .85; }
.sel-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sel-name { font-size: 12px; font-weight: 700; width: 78px; flex-shrink: 0; }
.sel-model { flex: 1; min-width: 0; }
.sel-warn { font-size: 10px; color: #f0a830; background: rgba(240,168,48,.12); padding: 2px 6px; border-radius: 100px; white-space: nowrap; }
button.sel-addkey { border: 1px solid rgba(240,168,48,.4); cursor: pointer; font-family: inherit; font-weight: 600; line-height: 1.4; transition: background .12s, border-color .12s; }
button.sel-addkey:hover { background: rgba(240,168,48,.22); border-color: rgba(240,168,48,.7); }
@keyframes key-flash { 0%, 100% { box-shadow: 0 0 0 0 rgba(240,168,48,0); } 30% { box-shadow: 0 0 0 3px rgba(240,168,48,.45); } }
.key-field-flash { border-radius: 8px; animation: key-flash 1.4s ease; }
@media (prefers-reduced-motion: reduce) { .key-field-flash { animation: none; } }
.sel-vision { display: inline-flex; align-items: center; flex-shrink: 0; cursor: default; }
.cfg-legend { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
#modelsFlow:empty { display: none; }
.cs-flow { justify-content: flex-start; margin-top: 0; }
.cs-flow-text { font-size: 12px; color: var(--text-3); line-height: 1.5; margin-top: 8px; }
.sel-x { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 6px; flex-shrink: 0; }
.sel-x:hover { color: #f87171; background: rgba(248,113,113,.1); }
.add-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.add-row #addProvider { flex: 1 1 38%; min-width: 0; }
.add-row #addModel { flex: 2 1 0; min-width: 0; }
.add-row .btn { flex: 0 0 auto; }
.add-row .btn { padding: 8px 14px; flex-shrink: 0; }
.add-custom { margin-top: 6px; }

/* free-demo card (Keys tab) + free badge */
.demo-card { background: linear-gradient(135deg, color-mix(in srgb, #10b981 12%, var(--surface-2)), var(--surface-2)); border: 1px solid color-mix(in srgb, #10b981 38%, var(--border)); border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 14px; }
.demo-card-head { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.demo-spark { display: inline-flex; align-items: center; }
.demo-card-sub { font-size: 12px; color: var(--text-2); line-height: 1.5; margin: 6px 0 11px; }
.demo-go { width: 100%; background: linear-gradient(120deg, #10b981, #0ea5e9); border-color: transparent; }
.sel-free { font-size: 10px; font-weight: 700; color: #10b981; background: color-mix(in srgb, #10b981 14%, transparent); padding: 2px 7px; border-radius: 100px; white-space: nowrap; flex-shrink: 0; }

/* keys */
.key-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.key-head { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.svc-dot { width: 9px; height: 9px; border-radius: 50%; }
.key-name { font-weight: 700; }
.key-status { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; color: var(--text-2); }
.key-status svg { flex: none; }
.key-status.on { color: #34d399; }
.key-status.checking { color: #eab308; }
.key-status.bad { color: #f87171; }
.key-tier { font-size: 10px; font-weight: 700; padding: 1px 8px; border-radius: 100px; }
.key-tier.free { color: #34d399; background: rgba(52,211,153,.13); }
.key-tier.paid { color: var(--text-2); background: var(--surface-2); }
.key-help { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 13px; margin-bottom: 10px; font-size: 13px; }
.key-help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.key-help p, .key-help li { color: var(--text-2); line-height: 1.55; margin-top: 8px; }
.key-help ul { margin: 6px 0 0; padding-left: 18px; }
.key-help li { margin-top: 6px; }
.key-help code { font-family: 'SF Mono','Fira Code',monospace; font-size: .9em; background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
.key-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); }

/* consensus tab */
#arbControls { display: flex; flex-direction: column; gap: 10px; }
.arb-desc { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.arb-prompts { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--surface-2); }
.arb-prompts summary { font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.arb-plabel { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); margin: 10px 0 3px; font-weight: 700; }
.arb-ptext { font-family: inherit; font-size: 12px; line-height: 1.5; resize: vertical; }
.arb-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.arb-spacer { flex: 1; }

/* donate */
.donate-copy { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.donate-row { display: flex; gap: 8px; flex-wrap: wrap; }
.donate-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 56px; padding: 8px 16px; border-radius: 100px; font-size: 13px; font-weight: 700; text-decoration: none; cursor: pointer; color: #fff; background: linear-gradient(120deg, var(--brand-a), var(--brand-b)); border: 1px solid transparent; transition: transform .12s, opacity .12s; }
.donate-btn:hover { transform: translateY(-1px); opacity: .92; }

/* buttons */
.btn { border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; font-weight: 600; padding: 8px 16px; cursor: pointer; transition: all .15s; border: 1px solid; }
.btn-ghost { background: none; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: none; border-color: transparent; color: #f87171; }
.btn-danger:hover { background: rgba(248,113,113,.1); }
.btn-solid { background: var(--text); border-color: transparent; color: var(--bg); }
.btn-solid:hover { opacity: .85; }
.btn-sm { font-size: 12px; padding: 6px 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.foot-left { display: flex; gap: 6px; }
.foot-left .btn { font-size: 12px; padding: 6px 12px; }

/* ── Toast ───────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 100px; font-size: 13px; font-weight: 500; z-index: 400; opacity: 0; transition: all .25s; white-space: normal; text-align: center; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Welcome ─────────────────────────────────────────────── */
.welcome-overlay { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; padding: 16px; }
.welcome-overlay::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 0; }
.welcome-overlay.open { display: flex; }
.welcome-modal { position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; width: 100%; max-width: 520px; max-height: 92vh; box-shadow: 0 32px 80px rgba(0,0,0,.6); overflow: hidden auto; }
.welcome-close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 20px; line-height: 1; z-index: 1; padding: 6px; border-radius: 6px; }
.welcome-slide { display: none; flex-direction: column; align-items: center; justify-content: center; padding: 30px 32px 24px; text-align: center; gap: 15px; height: clamp(400px, 60vh, 500px); overflow-y: auto; }
.welcome-slide.active { display: flex; animation: wslide-in .3s ease; }
.welcome-slide.active.going-back { animation: wslide-back .3s ease; }
@keyframes wslide-in  { from { opacity: 0; transform: translateX(14px);  } to { opacity: 1; transform: translateX(0); } }
@keyframes wslide-back { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }
.welcome-hero-logo { font-size: 36px; font-weight: 800; letter-spacing: -1.4px; line-height: 1; }
.welcome-tagline { font-size: 22px; font-weight: 700; letter-spacing: -.3px; line-height: 1.3; color: var(--text); }
.welcome-desc { font-size: 15px; color: var(--text-2); line-height: 1.65; max-width: 400px; }
.welcome-desc b { color: var(--text); font-weight: 700; }
.welcome-desc em { color: var(--brand-b); font-style: normal; font-weight: 700; }
.welcome-flow { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.wm-pill { padding: 5px 12px; border-radius: 100px; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--c, var(--text-2)) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c, var(--text-2)) 38%, transparent); color: var(--c, var(--text)); }
.wm-consensus { --c: var(--consensus); }
.wm-arrow { color: var(--text-3); font-size: 14px; }
.wm-syn-tag { font-weight: 400; opacity: .75; }
.cs-arb-only-row { margin: -2px 0 12px; }
.wstep b { font-weight: 700; }
.welcome-slide-icon { font-size: 40px; line-height: 1; margin-bottom: 4px; color: var(--text-2); }
.welcome-slide-icon svg { display: block; }
.welcome-steps { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 390px; }
.wstep { display: flex; align-items: flex-start; gap: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; font-size: 14px; color: var(--text); text-align: left; }
.wstep em { color: var(--brand-b); font-style: normal; font-weight: 700; }
.wstep-n { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.welcome-note-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; max-width: 390px; }
.welcome-note-box a { color: var(--brand-b); }
.welcome-footer { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); }
.welcome-dots { display: flex; gap: 7px; align-items: center; }
.wd { width: 7px; height: 7px; border-radius: 50%; background: var(--border); transition: all .25s; }
.wd.active { width: 20px; border-radius: 3.5px; background: var(--text); }
.welcome-btns { display: flex; gap: 6px; align-items: center; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .app { padding: 10px; gap: 10px; }
  .cg-title { font-size: 18px; }
  .cg-brand { font-size: 26px; }
  .msg-bubble { max-width: 98%; font-size: 13px; }
  .send-btn kbd { display: none; }
  .backdrop { padding: 8px; }
  .modal-body { padding: 14px; gap: 18px; }
  .tab { padding: 9px 12px; }
  .sel-name { width: 52px; font-size: 11px; }
  .sel-arb { font-size: 8px; padding: 1px 5px; }
  .welcome-slide { padding: 30px 20px 20px; }
  .welcome-tagline { font-size: 19px; }
  .private-badge { display: none; }
  /* Larger touch targets for attachment remove buttons on mobile */
  .attach-thumb .at-x { width: 24px; height: 24px; font-size: 15px; }
  .attach-file-chip .at-x { padding: 0 5px; min-height: 28px; }
  .attach-file-chip { height: 40px; }
  .attach-strip { gap: 6px; padding: 10px 10px 0; }
}

/* ── Private badge ───────────────────────────────────────── */
.private-badge { font-size: 11px; font-weight: 700; color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 14%, transparent); border: 1px solid color-mix(in srgb, var(--brand-b) 34%, transparent); border-radius: 100px; padding: 3px 9px; white-space: nowrap; }

/* ── Rail furniture (history + menu, mounted into the shell's .ps-rail) ── */
.sb-top { padding: 10px 12px 8px; }
.sb-newchat { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; background: linear-gradient(120deg, var(--brand-a), var(--brand-b)); color: #fff; border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; font-weight: 700; padding: 11px; cursor: pointer; transition: opacity .12s; }
.sb-newchat:hover { opacity: .9; }
.sb-search-wrap { padding: 4px 14px 2px; }
.sb-search { width: 100%; box-sizing: border-box; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 13px; padding: 8px 10px; outline: none; transition: border-color .12s, box-shadow .12s; }
.sb-search::placeholder { color: var(--text-3); }
.sb-search:focus { border-color: var(--brand-a); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-a) 22%, transparent); }
.sb-search::-webkit-search-cancel-button { -webkit-appearance: none; height: 14px; width: 14px; background: var(--text-3); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 6 6 18M6 6l12 12' stroke='black' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat; cursor: pointer; }
.sb-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); padding: 6px 16px; }
.sb-date-group { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); padding: 10px 12px 3px; pointer-events: none; user-select: none; }
.sb-date-group:first-child { padding-top: 4px; }
.sb-model-dots { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; vertical-align: middle; }
.sb-model-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; opacity: .8; }
.sb-model-dot-more { font-size: 9px; color: var(--text-3); line-height: 1; }
.sb-history { flex: 1; overflow-y: auto; padding: 0 8px 8px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sb-history::-webkit-scrollbar { width: 5px; } .sb-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sb-empty { color: var(--text-2); font-size: 13px; line-height: 1.6; padding: 18px 12px; text-align: center; }
.sb-item { display: flex; align-items: center; gap: 6px; border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; transition: background .12s; }
.sb-item:hover { background: var(--surface-2); }
.sb-item.active { background: var(--surface-3); }
.sb-item-main { flex: 1; min-width: 0; }
.sb-item-title { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item-meta { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.sb-pin-dot { display: inline-flex; align-items: center; vertical-align: middle; color: var(--brand-b); opacity: .7; }
.sb-item-actions { display: flex; align-items: center; gap: 1px; flex-shrink: 0; opacity: 0; transition: opacity .12s; }
.sb-item:hover .sb-item-actions, .sb-item.active .sb-item-actions { opacity: 1; }
.sb-act { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 13px; line-height: 1; padding: 3px 5px; border-radius: 5px; flex-shrink: 0; display: inline-flex; align-items: center; }
.sb-act:hover { color: var(--text); background: var(--surface-3); }
.sb-del { font-size: 16px; }
.sb-del:hover { color: #f87171; background: rgba(248,113,113,.12); }
.sb-pin { opacity: .45; }
.sb-pin:hover { opacity: 1; }
.sb-pin.on { opacity: 1; color: var(--brand-b); }
.sb-item.pinned .sb-item-actions { opacity: 1; }
.sb-item.pinned .sb-rename, .sb-item.pinned .sb-del { opacity: 0; transition: opacity .12s; }
.sb-item.pinned:hover .sb-rename, .sb-item.pinned:hover .sb-del { opacity: 1; }
.sb-rename-input { width: 100%; box-sizing: border-box; background: var(--surface); border: 1px solid var(--brand-a); border-radius: 5px; color: var(--text); font-family: inherit; font-size: 13px; padding: 2px 6px; outline: none; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-private { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 6px 10px; font-size: 13px; }
.sb-link { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none; color: var(--text-2); font-family: inherit; font-size: 13px; font-weight: 600; padding: 8px 6px; border-radius: var(--radius-sm); cursor: pointer; transition: background .12s, color .12s; }
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link.danger { color: #f87171; }
.sb-link.danger:hover { background: rgba(248,113,113,.1); }
.sb-backup-status { padding: 2px 6px 6px; font-size: 11px; }
.sb-backup-nudge { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 2px 6px 10px; font-size: 12.5px; line-height: 1.4; color: var(--text-2); animation: cons-tip-in .22s ease; }
.sb-backup-nudge[hidden] { display: none; }
.sb-backup-nudge-actions { display: flex; justify-content: flex-end; gap: 6px; }
.sb-backup-nudge-actions .btn { font-size: 12px; padding: 5px 10px; }
@media (prefers-reduced-motion: reduce) { .sb-backup-nudge { animation: none; } }

/* ── What's new ──────────────────────────────────────────── */
/* The What's-New feed itself is the shell's (.shell-whatsnew in shell.css,
   rendered in a right panel); only the unseen dot on the rail link is ours. */
.wn-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-b); margin-left: 6px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-b) 28%, transparent); }
.wn-dot[hidden] { display: none; }

/* ── Provenance panel (EPIC 1 · P3 — "How this was formed") ─────── */
.provenance-panel { margin: 6px 0 2px; max-width: 90%; animation: cs-fade .4s ease both; }
@media (prefers-reduced-motion: reduce) { .provenance-panel { animation: none; } }

/* ── Follow-up question chips ─────────────────────────────────────────── */
.followup-chips { padding: 10px 14px 8px; border-top: 1px solid var(--border); animation: cs-fade .4s .15s ease both; }
@media (prefers-reduced-motion: reduce) { .followup-chips { animation: none; } }
.followup-label { display: block; font-size: 10.5px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 7px; }
.followup-list { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 600px) {
  .followup-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .followup-list::-webkit-scrollbar { display: none; }
  .followup-chip { flex-shrink: 0; }
}
.followup-chip { font-family: inherit; font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; padding: 5px 12px; cursor: pointer; transition: all .15s; text-align: left; line-height: 1.4; }
.followup-chip:hover { background: var(--surface-3); color: var(--text); border-color: var(--text-3); }
.followup-chip-debate { border-color: color-mix(in srgb, var(--brand-b) 45%, var(--border)); color: var(--brand-b); }
.followup-chip-debate:hover { background: color-mix(in srgb, var(--brand-b) 10%, var(--surface-2)); border-color: var(--brand-b); color: var(--brand-b); }

/* ── "Try another synthesis" re-synthesis strip ─────────────────────── */
/* Shows after follow-up chips; lets the user re-synthesize the same model
   responses with a different strategy — no extra model calls needed. */
.resynth-strip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px 12px; border-top: 1px solid var(--border);
  animation: cs-fade .4s .3s ease both;
}
@media (prefers-reduced-motion: reduce) { .resynth-strip { animation: none; } }
.resynth-label {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap; flex-shrink: 0;
}
.resynth-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.resynth-pill {
  font-family: inherit; font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 100px;
  color: var(--text-3); background: transparent;
  border: 1px solid var(--border); cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
.resynth-pill:hover { color: var(--text); background: var(--surface-3); border-color: var(--text-3); }
.resynth-pill:active { opacity: .7; }
.resynth-format-row {
  flex-basis: 100%; display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--border);
}
.resynth-format-label {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap; flex-shrink: 0;
}
.resynth-format-chip {
  font-family: inherit; font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 100px;
  color: var(--text-3); background: transparent;
  border: 1px solid var(--border); cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
.resynth-format-chip:hover { color: var(--text); background: var(--surface-3); border-color: var(--text-3); }
.resynth-format-chip:active { opacity: .7; }

/* ── "Responses at a glance" snapshot strip (Consensus tab) ─────────── */
.model-snapshots { margin: 6px 0 2px; animation: cs-fade .35s ease both; }
@media (prefers-reduced-motion: reduce) { .model-snapshots { animation: none; } }
.ms-toggle {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: none; border: none; border-top: 1px dashed var(--border);
  color: var(--text-3); cursor: pointer; font-family: inherit; font-size: 11.5px;
  font-weight: 600; padding: 9px 0 8px; text-align: left; transition: color .12s;
}
.ms-toggle:hover { color: var(--text-2); }
.ms-toggle[aria-expanded="true"] { color: var(--text-2); }
.ms-toggle-icon { display: flex; align-items: center; flex-shrink: 0; width: 12px; height: 12px; }
.ms-toggle-label { flex: 1; }
.ms-count { font-size: 10.5px; color: var(--text-3); opacity: .65; font-weight: 400; }
.ms-body {
  display: flex; gap: 8px; padding: 2px 0 8px;
  overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.ms-body::-webkit-scrollbar { height: 4px; }
.ms-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.ms-card {
  flex: 0 0 clamp(168px, 36%, 220px); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: inset 0 2px 0 var(--ms-c);
  padding: 10px 11px 9px; display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer; outline: none;
}
.ms-card:hover { border-color: color-mix(in srgb, var(--ms-c) 55%, var(--border)); box-shadow: inset 0 2px 0 var(--ms-c), 0 2px 8px rgba(0,0,0,.1); }
.ms-card:focus-visible { border-color: color-mix(in srgb, var(--ms-c) 70%, var(--border)); box-shadow: inset 0 2px 0 var(--ms-c), 0 0 0 2px color-mix(in srgb, var(--ms-c) 35%, transparent); }
.ms-card-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ms-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ms-c); flex-shrink: 0; }
.ms-label { font-size: 11.5px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-time { font-size: 10.5px; color: var(--text-3); flex-shrink: 0; }
.ms-speed-bar { height: 2px; background: var(--surface-3); border-radius: 1px; margin: 3px 0 2px; overflow: hidden; }
.ms-speed-fill { height: 100%; border-radius: 1px; opacity: .55; transition: width .55s cubic-bezier(.4,0,.2,1); }
@media (prefers-reduced-motion: reduce) { .ms-speed-fill { transition: none; } }
.ms-card-text {
  font-size: 12px; color: var(--text-2); line-height: 1.5; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.ms-distinct {
  font-size: 11px; color: var(--text-2); line-height: 1.45;
  padding: 5px 7px; margin: 2px 0 0;
  border-left: 2px solid color-mix(in srgb, var(--ms-c) 65%, transparent);
  background: color-mix(in srgb, var(--ms-c) 7%, transparent);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}
.ms-distinct-label {
  font-style: normal; font-weight: 700; color: var(--text-3);
  font-size: 9px; text-transform: uppercase; letter-spacing: .04em;
  display: block; margin-bottom: 2px;
}
.ms-read-hint {
  font-size: 11px; font-weight: 600;
  color: var(--ms-c); opacity: .75; flex-shrink: 0;
  pointer-events: none; user-select: none;
}
.ms-card:hover .ms-read-hint { opacity: 1; }
.ms-meta-row { display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.ms-stance { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 100px; line-height: 1.4; flex-shrink: 0; }
.ms-aligned { color: #059669; background: rgba(5,150,105,.10); }
.ms-partial  { color: var(--text-3); background: var(--surface-3); }
.ms-outlier  { color: #b45309; background: rgba(180,83,9,.10); }
[data-theme="dark"] .ms-aligned { color: #34d399; background: rgba(52,211,153,.12); }
[data-theme="dark"] .ms-outlier  { color: #f0a830; background: rgba(240,168,48,.12); }
.ms-wc { font-size: 10px; color: var(--text-3); margin-left: auto; }
.ms-pct { font-size: 10px; color: color-mix(in srgb, var(--ms-c, var(--brand-b)) 90%, currentColor); font-weight: 700; background: color-mix(in srgb, var(--ms-c, var(--brand-b)) 12%, transparent); padding: 1px 6px; border-radius: 100px; line-height: 1.4; flex-shrink: 0; }
.ms-mini-dots { display: none; align-items: center; gap: 3px; flex-shrink: 0; }
.ms-toggle[aria-expanded="false"] .ms-mini-dots { display: flex; }
.ms-mini-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ms-copy-btn {
  background: none; border: none; cursor: pointer; padding: 6px; margin: -4px; border-radius: 7px;
  color: var(--text-3); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
.ms-copy-btn:hover { color: var(--text); background: var(--surface-3); opacity: 1 !important; }
.ms-card:hover .ms-copy-btn,
.ms-copy-btn:focus-visible { opacity: .7; }
.ms-copy-btn.copied { color: var(--ms-c, #059669); opacity: 1 !important; }
@media (hover: none) { .ms-copy-btn { opacity: .55; } }
/* Expand-inline button — sits in card head next to copy button */
.ms-expand-btn {
  background: none; border: none; cursor: pointer; padding: 6px; margin: -4px; border-radius: 7px;
  color: var(--text-3); display: flex; align-items: center; flex-shrink: 0;
  opacity: 0; transition: opacity .12s, color .12s, background .12s, transform .2s;
  line-height: 0;
}
.ms-expand-btn:hover { color: var(--text); background: var(--surface-3); opacity: 1 !important; }
.ms-card:hover .ms-expand-btn,
.ms-expand-btn:focus-visible { opacity: .7; }
.ms-expand-btn[aria-expanded="true"] { opacity: 1 !important; color: var(--ms-c, var(--brand-b)); }
.ms-expand-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
@media (hover: none) { .ms-expand-btn { opacity: .55; } }
/* Expanded response panel — sits below the card strip */
.ms-expanded-panel {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
  animation: ms-ep-in .16s ease both;
}
@keyframes ms-ep-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .ms-expanded-panel { animation: none; } }
.ms-ep-head {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-3); flex-shrink: 0;
}
.ms-ep-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ms-ep-label { font-size: 12px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-ep-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.ms-ep-tab-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 9px; font-size: .75rem; color: var(--text-2); cursor: pointer;
  font-family: inherit; transition: background .12s, color .12s; flex-shrink: 0; white-space: nowrap;
}
.ms-ep-tab-btn:hover { background: var(--surface-2); color: var(--text); }
.ms-ep-close {
  background: none; border: none; cursor: pointer; padding: 3px; border-radius: 4px;
  color: var(--text-3); display: flex; align-items: center; transition: color .12s, background .12s;
  flex-shrink: 0;
}
.ms-ep-close:hover { color: var(--text); background: var(--border); }
.ms-ep-body {
  padding: 14px 16px; font-size: .845rem; line-height: 1.65;
  max-height: 58vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.ms-ep-body::-webkit-scrollbar { width: 4px; }
.ms-ep-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.ms-ep-body p { margin: 0 0 .5em; }
.ms-ep-body h1,.ms-ep-body h2,.ms-ep-body h3,.ms-ep-body h4 { margin: .7em 0 .2em; line-height: 1.3; }
.ms-ep-body ul,.ms-ep-body ol { padding-left: 1.4em; margin: .3em 0; }
.ms-ep-body li { margin: .15em 0; }
.ms-ep-body pre { font-size: .8em; overflow-x: auto; border-radius: 6px; padding: 10px 12px; background: var(--surface-3); margin: .4em 0; }
.ms-ep-body code:not(pre code) { font-size: .85em; background: var(--surface-3); border-radius: 4px; padding: 1px 5px; }
@media (max-width: 600px) { .ms-ep-body { max-height: 50vh; padding: 12px 13px; } }

.prov-toggle {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: none; border: none; border-top: 1px dashed var(--border);
  color: var(--text-3); cursor: pointer; font-family: inherit; font-size: 11.5px;
  font-weight: 600; padding: 9px 0 0; text-align: left; transition: color .12s;
}
.prov-toggle:hover { color: var(--text-2); }
.prov-toggle[aria-expanded="true"] { color: var(--text-2); }
.prov-toggle-icon { display: flex; align-items: center; flex-shrink: 0; width: 12px; height: 12px; }
.prov-toggle-label { flex: 1; }
.prov-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 100px; flex-shrink: 0; line-height: 1.4; }
.prov-badge.agree-high { color: #059669; background: rgba(5,150,105,.10); }
.prov-badge.agree-mid  { color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 14%, transparent); }
.prov-badge.agree-low  { color: var(--text-3); background: var(--surface-3); }
.prov-badge.prov-local { color: var(--text-3); background: var(--surface-3); }
[data-theme="dark"] .prov-badge.agree-high { color: #34d399; background: rgba(52,211,153,.13); }

.prov-body { display: flex; flex-direction: column; gap: 10px; padding: 10px 0 4px; }
.prov-section { display: flex; flex-direction: column; gap: 5px; }
.prov-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); font-weight: 700; }
.prov-approx { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Stacked 100% contribution bar */
.prov-stacked-bar { display: flex; height: 16px; border-radius: 6px; overflow: hidden; margin: 4px 0 2px; }
.prov-seg { display: flex; align-items: center; justify-content: center; flex-shrink: 0; min-width: 0; transition: filter .12s; box-shadow: inset -1.5px 0 0 rgba(255,255,255,.18); }
.prov-seg.prov-seg-last { box-shadow: none; }
.prov-seg:hover { filter: brightness(1.12); cursor: default; }
.prov-seg-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,.92); text-shadow: 0 1px 2px rgba(0,0,0,.35); pointer-events: none; white-space: nowrap; line-height: 1; }
@media (prefers-reduced-motion: reduce) { .prov-seg { transition: none; } }
/* Texture overlays so two same-color (same-provider) models stay distinguishable
   in the bar + legend. Layered over the inline background-color via background-image. */
.prov-pat-1 { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.45) 0 1.5px, transparent 1.5px 5px); }
.prov-pat-2 { background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1.4px); background-size: 5px 5px; }
.prov-pat-3 { background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,.32) 0 1.5px, transparent 1.5px 5px); }
.prov-pat-4 { background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.42) 0 1.5px, transparent 1.5px 5px); }
.prov-legend-swatch.prov-pat-2 { background-size: 4px 4px; }
.prov-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.prov-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); }
.prov-legend-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; opacity: .85; }
.prov-legend-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.prov-legend-pct { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); font-size: 11px; }
.prov-mismatch { color: var(--text-3); margin-left: 1px; cursor: help; }
.prov-stance { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 100px; flex-shrink: 0; min-width: 48px; text-align: center; }
.prov-aligned { color: #059669; background: rgba(5,150,105,.09); }
.prov-partial  { color: var(--text-3); background: var(--surface-3); }
.prov-outlier  { color: #b45309; background: rgba(180,83,9,.09); }
[data-theme="dark"] .prov-aligned { color: #34d399; background: rgba(52,211,153,.11); }
[data-theme="dark"] .prov-outlier  { color: #f0a830; background: rgba(240,168,48,.11); }

.prov-agree-section { border-top: none; }
.prov-agrees { display: flex; flex-direction: column; gap: 4px; }
.prov-agree-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); line-height: 1.5; }
.prov-agree-check { color: #059669; flex-shrink: 0; display: inline-flex; align-items: center; }
[data-theme="dark"] .prov-agree-check { color: #34d399; }

.prov-sub-section { display: flex; flex-direction: column; gap: 6px; }
.prov-details { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.prov-details summary { font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; padding: 8px 12px; user-select: none; list-style: none; display: flex; align-items: center; gap: 6px; }
.prov-details summary::-webkit-details-marker { display: none; }
.prov-details summary::before { content: '▶'; font-size: 9px; color: var(--text-3); transition: transform .15s; }
.prov-details[open] summary::before { transform: rotate(90deg); }
.prov-details summary:hover { background: var(--surface-2); color: var(--text); }
.prov-details-body { padding: 8px 12px 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); }
.prov-dis-item { font-size: 12px; }
.prov-dis-point { font-weight: 600; color: var(--text); margin-bottom: 3px; }
.prov-dis-pos { padding-left: 12px; margin: 0; display: flex; flex-direction: column; gap: 3px; list-style: none; }
.prov-dis-pos li { color: var(--text-2); padding-left: 8px; position: relative; }
.prov-dis-pos li::before { content: '·'; position: absolute; left: 0; color: var(--text-3); }
.prov-model-link { background: none; border: none; padding: 0; cursor: pointer; font-weight: 700; color: var(--text); font-size: inherit; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; font-family: inherit; }
.prov-model-link:hover, .prov-model-link:focus-visible { color: var(--brand-b); }
.prov-ask-btn {
  display: inline-block; background: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1px 7px; cursor: pointer;
  color: var(--text-3); font-size: 10px; font-weight: 600; font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
  margin: 2px 0 6px; line-height: 1.6; letter-spacing: .1px;
}
.prov-ask-btn:hover, .prov-ask-btn:focus-visible { background: var(--surface-3); color: var(--text-2); border-color: var(--text-3); }
.prov-notable-item { font-size: 12px; }
.prov-notable-claim { font-weight: 600; color: var(--text); display: block; }
.prov-notable-note { color: var(--text-3); font-size: 11px; }
.prov-notable-models { display: block; color: var(--text-3); font-size: 11px; font-style: italic; margin-top: 2px; }

@media (max-width: 600px) {
  .provenance-panel { max-width: 100%; }
  .prov-legend-name { max-width: 58px; }
  .prov-stance { display: none; }
}

/* ── Inline attribution (EPIC 1 · P4) ───────────────────── */
/* Toggle button — matches copy-btn style but glows when on */
.attr-toggle-btn { transition: color .15s, background .15s, opacity .15s; }
.attr-toggle-btn.active { color: var(--brand-b); opacity: 1; }
.attr-toggle-btn.active svg { stroke: var(--brand-b); }

/* Paragraph-level attribution — activated by .attribution-active on the bubble */
.attribution-active .attr-para {
  border-left: 3px solid transparent;
  padding-left: 10px;
  margin-left: -13px;
  border-radius: 0 4px 4px 0;
  transition: border-color .25s, background .25s, padding-left .25s;
}
.attribution-active .attr-para.attr-solo {
  border-left-color: color-mix(in srgb, var(--attr-c, #888) 70%, transparent);
  background: color-mix(in srgb, var(--attr-c, #888) 5%, transparent);
}
.attribution-active .attr-para.attr-agreed {
  border-left-color: rgba(5, 150, 105, 0.55);
  background: rgba(5, 150, 105, 0.05);
}
[data-theme="dark"] .attribution-active .attr-para.attr-agreed {
  border-left-color: rgba(52, 211, 153, 0.65);
  background: rgba(52, 211, 153, 0.04);
}
@media (prefers-reduced-motion: reduce) {
  .attribution-active .attr-para { transition: none; }
}

/* Shared floating tooltip (positioned by JS, lives on body) */
.attr-tooltip {
  position: fixed; z-index: 999; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-2); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 11px; font-weight: 500; padding: 5px 10px; border-radius: 7px;
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
}
.attr-tooltip.visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .attr-tooltip { transition: opacity .06s; transform: none !important; } }

/* ── Share modal ───────────────────────────────────────────── */
.share-modal { max-width: 680px; }
.share-modal-brand { display: flex; align-items: center; gap: 8px; }
.share-content { gap: 14px; }
.share-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); font-weight: 700; margin-bottom: 6px; }
.share-question-wrap { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; font-size: 14px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.share-models-wrap { display: flex; flex-direction: column; gap: 6px; }
.share-model-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.share-model-card > summary { padding: 8px 14px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-2); list-style: none; display: flex; align-items: center; justify-content: space-between; user-select: none; }
.share-model-card > summary::-webkit-details-marker { display: none; }
.share-model-card > summary:hover { background: var(--surface-3); }
.share-model-body { padding: 10px 14px; font-size: 13px; color: var(--text); line-height: 1.65; border-top: 1px solid var(--border); }
.share-consensus-wrap { font-size: 14px; line-height: 1.7; color: var(--text); }
.share-foot { justify-content: space-between; }
.share-brand-note { font-size: 12px; color: var(--text-3); }
.share-brand-note strong { color: var(--text-2); }

/* ── Export dialog ───────────────────────────────────────── */
.exp-overlay { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.exp-overlay::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 0; }
.exp-card { position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 380px; padding: 20px; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.exp-title { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.exp-sub { font-size: 12.5px; color: var(--text-2); margin: 6px 0 14px; line-height: 1.5; }
.exp-opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.exp-opt input { margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--brand-b); }
.exp-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Centered composer: greeting + composer sit together in the viewport center ── */
/* Applied via body.is-empty when no messages exist yet; removed on first send. */
body.is-empty .app { justify-content: center; gap: 0; }
body.is-empty .responses {
  flex: 0 0 auto;
  background: transparent;
  border-color: transparent;
  overflow: visible;
  border-radius: 0;
}
body.is-empty .chat-greeting {
  flex: 0 0 auto;
  padding-bottom: 4px;
}
body.is-empty .composer { margin-top: 8px; }

/* ── System prompt section (in Models settings) ─────────── */
.sys-prompt-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.sys-prompt-ta { resize: vertical; min-height: 68px; font-size: 13px; font-family: inherit; line-height: 1.5; }

/* ── Keyboard shortcuts cheatsheet ──────────────────────── */
.kbd-modal { max-width: 360px; }
.kbd-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 16px; }
.kbd-group { display: flex; flex-direction: column; }
.kbd-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); padding-bottom: 7px; border-bottom: 1px solid var(--border); margin-bottom: 7px; }
.kbd-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; font-size: 13px; color: var(--text-2); }
.kbd-row > span:last-child { text-align: right; }
.kbd-keys { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.kbd-plus, .kbd-sep { font-size: 11px; color: var(--text-2); padding: 0 1px; }
.kbd-body kbd { display: inline-block; font-family: inherit; font-size: 11px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--text); white-space: nowrap; line-height: 1.5; }

/* ── Compare modal (side-by-side all model responses) ─────── */
.compare-overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.compare-overlay::before {
  content: ''; position: fixed; inset: 0;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 0;
}
.compare-card {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 1100px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  animation: cs-fade .18s ease both;
}
@media (prefers-reduced-motion: reduce) { .compare-card { animation: none; } }
.compare-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.compare-title { font-size: .9rem; font-weight: 700; }
.compare-count { font-size: .78rem; color: var(--text-2); opacity: .6; }
.compare-close { margin-left: auto; }
.compare-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0; flex: 1; overflow: hidden;
}
.compare-col {
  display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid var(--border); min-width: 0;
}
.compare-col:last-child { border-right: none; }
.compare-col-head {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.cmp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cmp-label {
  font-size: .82rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.cmp-time { font-size: .75rem; color: var(--text-3); flex-shrink: 0; margin-left: auto; padding-left: 6px; }
.compare-col-body {
  overflow-y: auto; padding: 14px; flex: 1;
  font-size: .845rem; line-height: 1.65;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.compare-col-body::-webkit-scrollbar { width: 4px; }
.compare-col-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.compare-col-body p { margin: 0 0 .5em; }
.compare-col-body h1,.compare-col-body h2,.compare-col-body h3,.compare-col-body h4 { margin: .8em 0 .25em; line-height: 1.3; }
.compare-col-body ul,.compare-col-body ol { padding-left: 1.4em; margin: .35em 0; }
.compare-col-body li { margin: .18em 0; }
.compare-col-body pre { font-size: .8em; overflow-x: auto; border-radius: 6px; padding: 10px 12px; background: var(--surface-3); margin: .5em 0; }
.compare-col-body code:not(pre code) { font-size: .85em; background: var(--surface-3); border-radius: 4px; padding: 1px 5px; }
@media (max-width: 640px) {
  .compare-overlay { padding: 6px; align-items: flex-start; padding-top: 8px; }
  .compare-card { max-height: 93vh; }
  .compare-grid { grid-template-columns: 1fr; overflow-y: auto; overflow-x: hidden; }
  .compare-col { border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .compare-col:last-child { border-bottom: none; }
  .compare-col-body { overflow-y: visible; max-height: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Polecat Shell integration — the chat app's skin over the vendored frame
   (vendor/polecat-shell/, READ-ONLY). tokens.css + shell.css load BEFORE
   this file; everything here is app-side skinning and compat.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── The chat view fills the shell's main area; the app keeps its own
      internal scrolling (transcript scrolls, composer docked) ─────────── */
.ps-view { display: flex; flex-direction: column; padding: 0; overflow: hidden; scroll-behavior: auto; }
.ps-view .app { flex: 1; min-height: 0; }
.ps-topbar { padding: 9px 14px; }
.ps-tb-left { flex: 1; }

/* ── Rail: a Gemini-style content rail (New chat · search · history · menu),
      not section nav. Always open on desktop — a history list has no
      icon-only mode — so the collapse chevron is hidden; drag-resize stays. */
.ps-rail-toggle { display: none; }
.ps-rail-scroll { padding: 0 8px 10px; }
.ps-rail .sb-history { flex: none; overflow: visible; padding: 0; }
.ps-rail .sb-foot { flex: none; background: linear-gradient(180deg, transparent, var(--rail-bg2) 30%); }
.ps-rail .sb-section-label { padding: 8px 20px 4px; }
.ps-rail-brand { cursor: default; }
/* If the rail somehow lands collapsed on desktop (persisted drag-snap),
   keep the strip clean: hide the text furniture until it reopens. */
@media (min-width: 861px) {
  .ps-rail:not(.open) .sb-top, .ps-rail:not(.open) .sb-search-wrap,
  .ps-rail:not(.open) .sb-section-label, .ps-rail:not(.open) .ps-rail-scroll,
  .ps-rail:not(.open) .sb-foot { display: none; }
}

/* ── Topbar chrome sizing ─────────────────────────────────── */
.ps-tb-right .icon-btn { height: 34px; }
@media (max-width: 520px) {
  .logo-ver { display: none; }
  .icon-btn .lbl { display: none; }         /* New chat → icon-only on phones */
  .icon-btn { padding: 0 8px; }
}

/* ── Compat: the app's pre-shell classes that shell.css also defines ──────
      (app modals live in .backdrop, not the shell's .modal-back, so the
      shell's entrance transform/flex must not leak in; the pill toast keeps
      its borderless look) */
.backdrop .modal { display: block; transform: none; }
#toast { border: none; }
.send-btn kbd { background: none; border: none; padding: 0; }

/* ── Mobile input & keyboard fixes ─────────────────────────────────────────
   iOS Safari auto-zooms the whole page when a focused input's font-size is
   under 16px — and never zooms back out, leaving the UI "huge" with the send
   button off-screen. 16px on touch devices kills that at the root. */
@media (pointer: coarse) {
  .prompt-input, .sb-search, .sb-rename-input,
  input[type="text"], input[type="search"], input[type="password"],
  input[type="url"], input[type="email"], textarea, select { font-size: 16px; }
}
@media (max-width: 600px) {
  /* a long draft must never swallow the screen — the send row stays visible
     (cap kept in sync with autoGrowComposer in js/app.js) */
  .prompt-input { max-height: 120px; }
  /* In the empty/greeting state .responses sizes to its content (flex:0 auto)
     and .app center-justifies — on a phone the tall greeting + composer can
     exceed the viewport and push the send row off-screen. Let the greeting
     area shrink and scroll instead; the composer stays pinned and reachable. */
  body.is-empty .app { justify-content: flex-start; }
  body.is-empty .responses { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}
/* Keyboard-aware frame: js/app.js mirrors visualViewport.height into --vvh so
   the frame shrinks above the on-screen keyboard instead of hiding under it. */
body.ps-shell { height: 100vh; height: var(--vvh, 100dvh); }

/* One-line explainer shown when the agreement map is ON but couldn't run
   (fewer than two models answered, or the analysis failed) */
.prov-gap-note { padding: 8px 14px 10px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
