/* ============================================================================
   CSS — sections:
     1) Base / reset & CSS Variables
     2) Top bar
     3) Bot picker
     4) Mobile tabs
     5) Response grid + column anatomy
     6) Thinking block
     7) Similarity / disagreement
     8) Action row + debate + synthesis
     9) Setup modal
    10) Animations & Toasts
    11) Mobile breakpoint (<=768px)
   ============================================================================ */

/* 1) Base / reset & CSS Variables */
:root {
    --bg: #0f1115;
    --surface: #161a22;
    --surface-hover: #1c2029;
    --border: #232831;
    --text-main: #e7e7e7;
    --text-muted: #888888;
    --topbar-bg: rgba(20, 23, 29, 0.95);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --input-bg: #1c2029;
    --code-bg: #0e1117;
    --error-bg: #2a1414;
    --error-border: #5a2020;
    --warning-bg: #1f2330;
    --warning-border: #f0b13a;

    --brand-oai: #e7e7e7;
    --brand-ant: #D97757;
    --brand-gem: #4285F4;
    --brand-ds:  #4974b8;
    --brand-oai: #e7e7e7;
    --brand-ant: #D97757;
    --brand-gem: #4285F4;
    --brand-ds:  #4974b8;

    /* Phase 5 — new tokens. Defined here so both themes inherit (the light
       block overrides only theme-divergent values like --brand-oai). */
    --error-text:   #d04040;   /* error text colour (matches existing inline #d04040) */
    --accent-green: #2e9e5b;   /* "free / no commitment" accent for the sample CTA */
    --accent-share: #38BDF8;   /* social/outward blue-cyan; distinct from --brand-gem #4285F4 */
}

:root[data-theme="light"] {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-main: #1a202c;
    --text-muted: #64748b;
    --topbar-bg: rgba(255, 255, 255, 0.95);
    --shadow-color: rgba(0, 0, 0, 0.08);
    --input-bg: #ffffff;
    --code-bg: #f8fafc;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --warning-bg: #fffbeb;
    --warning-border: #fbbf24;
    --brand-oai: #212121;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s, color 0.2s;
}
button, input, textarea, select {
    font-family: inherit; font-size: inherit; color: inherit;
}
button { cursor: pointer; background: none; border: none; }
a { color: var(--brand-gem); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 2) Top bar */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    background: var(--topbar-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px var(--shadow-color);
}
.topbar .brand { 
    font-weight: 800; font-size: 18px; letter-spacing: -0.2px; white-space: nowrap; 
    display: flex; align-items: center;
}
.topbar .prompt-wrap { 
    flex: 1; display: flex; align-items: center; gap: 10px; justify-content: center;
}
.topbar textarea {
    flex: 1; width: 100%; max-width: 520px;
    min-height: 42px; max-height: 200px;
    padding: 10px 14px; resize: none;
    background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.topbar textarea:focus { 
    outline: none; border-color: var(--brand-gem); 
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.15);
}
.btn-primary {
    background: var(--brand-gem); color: #fff;
    padding: 10px 18px; border-radius: 8px; font-weight: 600;
    white-space: nowrap; transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; transform: none; filter: none; }
.cost-display { 
    color: var(--text-muted); font-size: 13px; white-space: nowrap; font-weight: 500;
    align-self: center; flex-shrink: 0;
}
#session-cost-display {
    color: var(--text-muted); font-size: 13px; white-space: nowrap;
    font-weight: 500; cursor: pointer; user-select: none;
    width: auto; height: auto; border-radius: 0; background: transparent;
    border: none; padding: 0; line-height: 1.5;
}
#session-cost-display:hover { color: var(--text-main); background: transparent; }
.info-wrap.show #session-cost-display { background: transparent; color: var(--text-main); border: none; }
#session-cost-wrap { align-self: center; flex-shrink: 0; }
.session-cost-line { display: block; margin-bottom: 4px; }
.session-cost-total { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 700; color: var(--text-main); }
.session-cost-disclaimer { display: block; margin-top: 8px; font-size: 11px; font-style: italic; color: var(--text-muted); }
.icon-btn, .keys-btn {
    color: var(--text-muted); padding: 8px; font-size: 16px; border-radius: 6px; 
    transition: background 0.2s, color 0.2s; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover, .keys-btn:hover { color: var(--text-main); background: var(--surface-hover); }

/* 1a) History button shares the icon-btn style; hidden until signed-in */
#history-btn { display: none; }
#history-btn.is-visible { display: flex; }

/* 1b) Stack multiple synthesis cards with breathing room */
.synthesis-output + .synthesis-output { margin-top: 14px; }

/* 1c) Bot picker lock — disables clicks while any stream is active */
.bot-picker.is-locked {
    pointer-events: none;
    opacity: 0.55;
    filter: saturate(0.7);
    transition: opacity 0.2s, filter 0.2s;
}

/* 1d) History modal (dedicated styles; reuses theme tokens) */
.history-modal {
    position: fixed; inset: 0; z-index: 250;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 60px 16px 16px; overflow-y: auto;
}
.history-modal .panel {
    background: var(--surface); color: var(--text-main);
    border: 1px solid var(--border); border-radius: 12px;
    width: 100%; max-width: 760px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
    display: flex; flex-direction: column; max-height: calc(100vh - 76px);
}
.history-modal .panel-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.history-modal .panel-head h2 {
    margin: 0; font-size: 16px; font-weight: 700; flex: 1;
}
.history-modal .quota-pill {
    font-size: 11px; padding: 3px 8px; border-radius: 10px;
    background: var(--surface-hover); color: var(--text-muted);
    border: 1px solid var(--border);
}
.history-modal .quota-pill.full {
    background: var(--warning-bg); color: var(--text-main);
    border-color: var(--warning-border);
}
.history-modal .close-btn {
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; cursor: pointer; padding: 0 4px;
    line-height: 1;
}
.history-modal .close-btn:hover { color: var(--text-main); }
.history-modal .search-row {
    padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.history-modal .search-row input {
    width: 100%; padding: 8px 12px; font-size: 13px;
    background: var(--input-bg); color: var(--text-main);
    border: 1px solid var(--border); border-radius: 6px;
    font-family: inherit;
}
.history-modal .list {
    overflow-y: auto; flex: 1;
}
.history-modal .empty {
    padding: 30px 18px; text-align: center; color: var(--text-muted);
    font-size: 13px;
}
.history-modal .item {
    padding: 12px 18px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.15s;
    display: flex; flex-direction: column; gap: 6px;
}
.history-modal .item:hover { background: var(--surface-hover); }
.history-modal .item:last-child { border-bottom: none; }
.history-modal .item-title-row {
    display: flex; align-items: center; gap: 10px;
}
.history-modal .item-title {
    font-weight: 600; font-size: 14px; flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-modal .item-time {
    font-size: 11px; color: var(--text-muted); flex-shrink: 0;
}
.history-modal .item-preview {
    font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
    -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.history-modal .item-meta {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 11px; color: var(--text-muted);
}
.history-modal .item-meta .model-logos { display: inline-flex; gap: 3px; }
.history-modal .item-meta .model-logos img {
    width: 16px; height: 16px; border-radius: 3px;
    background: var(--surface); padding: 1px;
    border: 1px solid var(--border);
}
.history-modal .item-meta .tag {
    padding: 1px 6px; border-radius: 8px;
    background: var(--surface-hover); border: 1px solid var(--border);
}
.history-modal .item-actions {
    display: flex; gap: 8px; margin-top: 4px;
}
.history-modal .item-actions button {
    background: none; border: 1px solid var(--border);
    color: var(--text-muted); font-size: 11px; padding: 3px 10px;
    border-radius: 4px; cursor: pointer; font-family: inherit;
}
.history-modal .item-actions button:hover {
    color: var(--text-main); background: var(--surface-hover);
}
.history-modal .item-actions button.danger:hover {
    color: #ff6b6b; border-color: #ff6b6b;
}

/* ── Phase 5.75 — condensed Sessions rows + pin / overflow / tooltip / pagination ──
   Scoped to .item[data-session-id] so Shared Links rows (no data-session-id,
   still using .item-title-row/.item-meta/.item-actions above) are unaffected. */
.history-modal .item[data-session-id] {
    min-height: 50px; height: auto;
    padding: 8px 18px; gap: 4px;
    cursor: default;
}
.history-modal .item[data-session-id] .item-title { cursor: pointer; }
.history-modal .item[data-session-id] .item-title:hover { text-decoration: underline; }
.history-modal .item-row1 {
    display: flex; align-items: center; gap: 8px;
    width: 100%; min-width: 0;
}
.history-modal .model-logos {
    display: inline-flex; gap: 3px; flex-shrink: 0;
}
.history-modal .model-logos img {
    width: 16px; height: 16px; border-radius: 3px;
    background: var(--surface); padding: 1px;
    border: 1px solid var(--border);
}

.btn-pin {
    background: none; border: none; cursor: pointer;
    font-size: 14px; padding: 0 2px; line-height: 1;
    flex-shrink: 0; color: var(--text-muted);
    transition: color 0.15s;
}
.btn-pin.is-pinned { color: var(--warning-border); }
.btn-pin:hover { color: var(--text-main); }

.btn-overflow {
    background: none; border: none; cursor: pointer;
    font-size: 16px; padding: 0 4px; line-height: 1;
    flex-shrink: 0; color: var(--text-muted);
    opacity: 0.55; transition: opacity 0.15s, color 0.15s;
    font-family: inherit;
}
.history-modal .item:hover .btn-overflow { opacity: 1; }
.btn-overflow:hover { color: var(--text-main); }

.history-overflow-menu {
    position: fixed; z-index: 300;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    min-width: 140px; padding: 4px 0; display: none;
}
.history-overflow-menu.open { display: block; }
.history-overflow-menu button {
    display: block; width: 100%; text-align: left;
    background: none; border: none; padding: 8px 16px;
    font-size: 13px; color: var(--text-main); cursor: pointer;
    font-family: inherit;
}
.history-overflow-menu button:hover { background: var(--surface-hover); }
.history-overflow-menu button.danger:hover { color: #ff6b6b; }

.history-tooltip {
    position: fixed; z-index: 400; pointer-events: none; display: none;
    max-width: 360px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    padding: 8px 12px; font-size: 12px; line-height: 1.5;
    color: var(--text-main); word-wrap: break-word;
}
.history-tooltip.visible { display: block; }

.history-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; padding: 10px 18px;
    border-top: 1px solid var(--border); flex-shrink: 0;
}
.history-pagination button {
    background: none; border: 1px solid var(--border);
    color: var(--text-muted); font-size: 12px; padding: 4px 12px;
    border-radius: 4px; cursor: pointer; font-family: inherit;
}
.history-pagination button:hover:not(:disabled) {
    color: var(--text-main); background: var(--surface-hover);
}
.history-pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
.history-pagination .page-info { font-size: 12px; color: var(--text-muted); }

.history-section-label {
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    padding: 6px 18px 4px;
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

/* 2a) Auth widget (top bar, right side) */
.auth-widget {
    display: none; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-muted); flex-shrink: 0;
}
.auth-widget .email {
    max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text-main);
}
.auth-widget .tier-badge {
    padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700;
    letter-spacing: 0.2px; text-transform: uppercase;
    background: var(--surface-hover); color: var(--text-main);
    border: 1px solid var(--border);
}
.auth-widget .tier-badge.paid {
    background: var(--brand-gem); color: #fff; border-color: var(--brand-gem);
}
.auth-widget .tier-badge.free {
    background: var(--surface-hover); color: var(--text-main);
}
.auth-widget .tier-badge.sample {
    background: var(--warning-bg); color: var(--text-main);
    border-color: var(--warning-border);
}
.auth-widget a.signin-link,
.auth-widget button.signout-btn {
    color: var(--brand-gem); text-decoration: none; font-weight: 600;
    background: none; border: none; cursor: pointer; padding: 0; font-size: 13px;
    font-family: inherit;
}
.auth-widget a.signin-link:hover,
.auth-widget button.signout-btn:hover { text-decoration: underline; }
.auth-widget form { display: inline; margin: 0; }

/* 3) Bot picker */
.bot-picker {
    display: flex; gap: 14px; padding: 16px 20px; justify-content: center;
    background: var(--bg); border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.bot-btn {
    width: 82px; height: 76px; flex-shrink: 0;
    border-radius: 12px; border: 2px solid transparent;
    background: var(--surface); box-shadow: 0 2px 8px var(--shadow-color);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: 600; font-size: 12px; color: var(--text-muted);
}
.bot-btn:hover { transform: translateY(-3px); background: var(--surface-hover); box-shadow: 0 6px 14px var(--shadow-color); }
.bot-btn .svg-icon { margin-bottom: 6px; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; }
.bot-btn .svg-icon img {
    width: 32px; height: 32px; object-fit: contain;
    filter: grayscale(100%) opacity(35%);
    transition: filter 0.2s ease; display: block;
}
.bot-btn { opacity: 0.55; border-width: 2px; }
.bot-btn.selected { opacity: 1; }
.bot-btn.selected .svg-icon img { filter: none; }
.bot-btn.selected { color: var(--text-main); background: var(--surface); }
.bot-btn.selected[data-bot="openai"]    { border-color: var(--brand-oai); background: color-mix(in srgb, var(--brand-oai) 6%, var(--surface)); }
.bot-btn.selected[data-bot="anthropic"] { border-color: var(--brand-ant); background: color-mix(in srgb, var(--brand-ant) 8%, var(--surface)); }
.bot-btn.selected[data-bot="gemini"]    { border-color: var(--brand-gem); background: color-mix(in srgb, var(--brand-gem) 8%, var(--surface)); }
.bot-btn.selected[data-bot="deepseek"]  { border-color: var(--brand-ds);  background: color-mix(in srgb, var(--brand-ds) 8%, var(--surface)); }
/* Tier-locked bots: visibly inert, hint at upgrade path on click */
.bot-btn.tier-locked {
    opacity: 0.4; cursor: not-allowed;
    background: var(--surface);
}
.bot-btn.tier-locked:hover {
    transform: none; box-shadow: 0 2px 8px var(--shadow-color);
    background: var(--surface);
}
.bot-btn.tier-locked .svg-icon img { filter: grayscale(100%) opacity(40%); }
.bot-btn.tier-locked::after {
    content: '🔒'; position: absolute; top: 4px; right: 6px; font-size: 10px;
}
.bot-btn { position: relative; }

/* 4) Mobile tabs */
.mobile-tabs { display: none; }

/* 5) Response grid + column anatomy */
.grid-wrap { padding: 20px; }
.response-grid {
    display: flex; gap: 20px;
    width: 100%;
}
.bot-col {
    flex: 1 1 0%;
    background: var(--surface); border-radius: 12px; overflow: clip;
    display: flex; flex-direction: column; min-height: 220px;
    border-bottom: 4px solid transparent;
    box-shadow: 0 4px 16px var(--shadow-color);
    position: relative;
    animation: smoothPopIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: min-width 0.25s ease, max-width 0.25s ease, flex 0.25s ease, flex-grow 0.25s ease, flex-basis 0.25s ease;
    min-width: 0; max-width: 100%;
}
.bot-col[data-bot="openai"]    { order: 1; border-bottom-color: var(--brand-oai); }
.bot-col[data-bot="anthropic"] { order: 2; border-bottom-color: var(--brand-ant); }
.bot-col[data-bot="gemini"]    { order: 3; border-bottom-color: var(--brand-gem); }
.bot-col[data-bot="deepseek"]  { order: 4; border-bottom-color: var(--brand-ds); }
.bot-col.compare-selected { box-shadow: 0 0 0 2px var(--text-main); }
.bot-col[data-bot="openai"].compare-selected    { box-shadow: 0 0 0 2px var(--brand-oai); }
.bot-col[data-bot="anthropic"].compare-selected { box-shadow: 0 0 0 2px var(--brand-ant); }
.bot-col[data-bot="gemini"].compare-selected    { box-shadow: 0 0 0 2px var(--brand-gem); }
.bot-col[data-bot="deepseek"].compare-selected  { box-shadow: 0 0 0 2px var(--brand-ds); }

.col-head {
    padding: 12px 16px; display: flex; justify-content: space-between; align-items: center;
    gap: 8px; border-bottom: 1px solid var(--border);
    position: sticky; top: var(--topbar-h, 66px); z-index: 10; background: var(--surface); min-height: 0; border-radius: 10px 10px 0 0;
}
.bot-col[data-bot="openai"]    .col-head { border-top: 4px solid var(--brand-oai); }
.bot-col[data-bot="anthropic"] .col-head { border-top: 4px solid var(--brand-ant); }
.bot-col[data-bot="gemini"]    .col-head { border-top: 4px solid var(--brand-gem); }
.bot-col[data-bot="deepseek"]  .col-head { border-top: 4px solid var(--brand-ds); }
.col-head .name { font-weight: 700; font-size: 14px; letter-spacing: -0.2px; }
.col-head .col-head-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.col-head .col-head-right { display: flex; align-items: center; gap: 8px; }
.col-head .model-select {
    background: var(--input-bg); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px;
    color: var(--text-main); font-size: 12px; max-width: 100%; cursor: pointer; transition: border-color 0.2s;
}
.col-collapse-btn {
    color: var(--text-muted); font-size: 16px; line-height: 1; padding: 4px 8px;
    border-radius: 6px; transition: background 0.2s, color 0.2s, transform 0.25s ease;
    display: inline-flex; align-items: center; justify-content: center;
}
.col-collapse-btn:hover { background: var(--surface-hover); color: var(--text-main); }

/* Horizontal collapse */
.bot-col.col-collapsed {
    min-width: 44px;
    max-width: 44px;
    flex: 0 0 44px;
    overflow: visible;
    cursor: pointer;
}
.bot-col.col-collapsed:hover {
    background: var(--surface-hover);
}
.col-collapsed-strip {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 8px;
}
.bot-col[data-bot="openai"]    .col-collapsed-strip { border-top: 4px solid var(--brand-oai); }
.bot-col[data-bot="anthropic"] .col-collapsed-strip { border-top: 4px solid var(--brand-ant); }
.bot-col[data-bot="gemini"]    .col-collapsed-strip { border-top: 4px solid var(--brand-gem); }
.bot-col[data-bot="deepseek"]  .col-collapsed-strip { border-top: 4px solid var(--brand-ds); }
.bot-col.col-collapsed .col-collapsed-strip { display: flex; position: sticky; top: var(--topbar-h, 66px); z-index: 10; border-radius: 10px 10px 0 0; }
.bot-col.col-collapsed .col-head,
.bot-col.col-collapsed .col-body,
.bot-col.col-collapsed .col-footer,
.bot-col.col-collapsed .col-debate-root { display: none; }
.col-collapsed-name {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes borderPulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.col-spinner {
    display: none;
    width: 13px; height: 13px;
    border: 2px solid transparent;
    border-top-color: var(--col-brand-color, #888);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
.bot-col.is-loading .col-spinner,
.col-debate-section.is-loading .col-spinner,
.synthesis-output.is-loading .col-spinner { display: inline-block; }

.col-timer {
    font-family: 'SF Mono', 'Fira Code', 'Menlo', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: var(--text-muted);
    min-width: 7ch;
    text-align: right;
    opacity: 0;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

@keyframes shimmer-sweep {
    0% { background-position: 250% center; }
    100% { background-position: -250% center; }
}

.col-timer.shimmer-winner {
    background: linear-gradient(
        90deg,
        #4ade80 0%,
        #fbbf24 25%,
        #4ade80 50%,
        #fbbf24 75%,
        #4ade80 100%
    );
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer-sweep 1.8s ease-in-out forwards;
}

.col-timer.winner-solid {
    color: #4ade80;
    -webkit-text-fill-color: #4ade80;
}

.bot-col.is-loading,
.col-debate-section.is-loading,
.synthesis-output.is-loading { animation: borderPulse 1.2s ease-in-out infinite; }

.response-section { position: relative; }
.copy-btn {
    position: absolute; top: 8px; right: 8px;
    opacity: 0; transition: opacity 0.2s, color 0.2s, border-color 0.2s;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 3px 8px; font-size: 11px;
    cursor: pointer; color: var(--text-muted);
    font-weight: 600; z-index: 2;
}
.response-section:hover .copy-btn { opacity: 1; }
.copy-btn:focus { opacity: 1; outline: none; }
.copy-btn:hover { color: var(--text-main); }
.copy-btn.copied { color: #2ea043; border-color: #2ea043; opacity: 1; }

.col-body {
    padding: 16px; overflow-y: auto; max-height: 65vh;
    white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.7; cursor: default;
}
.col-body.empty { color: var(--text-muted); font-style: italic; cursor: default; }
.col-body .cursor-blink::after {
    content: "▊"; opacity: 0.6; animation: blink 1s steps(2, start) infinite;
}

/* 6) Thinking block */
.thinking-block {
    margin-bottom: 16px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; font-size: 13px; transition: all 0.2s;
}
.thinking-block summary {
    cursor: pointer; user-select: none; color: var(--text-muted); font-weight: 600;
    list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary::after { content: "▾"; opacity: 0.6; transition: transform 0.2s; }
.thinking-block[open] summary::after { transform: rotate(180deg); }
.thinking-content {
    margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
    color: var(--text-muted); font-style: italic; white-space: pre-wrap; max-height: 200px; overflow-y: auto; line-height: 1.6;
}

/* 7) Similarity / disagreement */
.col-footer {
    padding: 12px 16px; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--bg);
}
.debate-toggle {
    display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted);
    cursor: pointer; user-select: none; font-weight: 500;
}
.debate-toggle input { accent-color: var(--brand-gem); width: 14px; height: 14px; }
.sim-badge {
    padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 700;
    background: var(--surface-hover); color: var(--text-muted); animation: fadeIn 0.3s ease;
}
.sim-badge.high { background: rgba(46,160,67,0.15);  color: #2ea043; }
.sim-badge.mid  { background: rgba(240,177,58,0.15); color: #d6981e; }
.sim-badge.low  { background: rgba(208,64,64,0.15);  color: #c93b3b; }
.sim-badge.group { background: rgba(66,133,244,0.15); color: var(--brand-gem); }

.error-state {
    margin: 10px 0; padding: 14px; background: var(--error-bg); border: 1px solid var(--error-border); border-radius: 8px;
    color: #cc4444; font-size: 13px;
}
.error-state .retry {
    margin-top: 10px; padding: 6px 14px; background: var(--surface); border: 1px solid var(--error-border); border-radius: 6px; color: inherit; font-size: 12px; font-weight: 600;
}
.error-state .retry:hover { background: var(--error-border); color: #fff; }

.disagreement {
    display: inline-flex; align-items: center; gap: 12px; margin: 0 20px; padding: 10px 20px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 30px;
    box-shadow: 0 4px 16px var(--shadow-color); animation: fadeIn 0.5s ease;
}
.disagreement-stack { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 20px; }
.disagreement-stack .disagreement { margin: 0; }
.disagreement .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.disagreement.green  .dot { background: #2ea043; box-shadow: 0 0 8px rgba(46,160,67,0.6); }
.disagreement.yellow .dot { background: #f0b13a; box-shadow: 0 0 8px rgba(240,177,58,0.6); }
.disagreement.red    .dot { background: #d04040; box-shadow: 0 0 8px rgba(208,64,64,0.6); }
.disagreement .label { font-weight: 700; font-size: 14px; }
.disagreement .explain { color: var(--text-muted); font-size: 13px; }

/* 8) Action row + debate + synthesis */
.action-row { padding: 24px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.synth-row { justify-content: center; }
.btn-debate, .btn-synth {
    color: #fff; padding: 12px 24px; border-radius: 8px; font-weight: 700; font-size: 14px;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn-debate { background: var(--brand-ant); box-shadow: 0 4px 12px rgba(217, 119, 87, 0.3); }
.btn-debate:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 6px 16px rgba(217, 119, 87, 0.4); }
.btn-debate:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(1); }

.btn-synth { background: var(--brand-ds); box-shadow: 0 4px 12px rgba(73, 116, 184, 0.3); }
.btn-synth:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 6px 16px rgba(73, 116, 184, 0.4); }
.btn-synth:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.cost-inline { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.debate-warning {
    background: var(--warning-bg); border-left: 4px solid var(--warning-border); padding: 12px 16px; font-size: 13.5px; color: var(--text-main);
    border-radius: 6px; flex-basis: 100%; font-weight: 500; box-shadow: 0 2px 8px var(--shadow-color);
}
.synthesis-output {
    position: relative;
    margin: 8px 20px 40px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand-ds);
    border-radius: 12px; box-shadow: 0 4px 20px var(--shadow-color); line-height: 1.7; font-size: 14px;
}
.synthesis-output:hover .copy-btn { opacity: 1; }
.syn-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.syn-logo {
    width: 20px; height: 20px; object-fit: contain; flex-shrink: 0;
}
.syn-label {
    font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase;
    font-weight: 800; color: var(--col-brand-color, var(--brand-ds));
    margin-bottom: 0;
}

/* 9) Setup modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 20px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal {
    background: var(--surface); border-radius: 16px; max-width: 560px; width: 100%; padding: 32px;
    border: 1px solid var(--border); box-shadow: 0 8px 32px var(--shadow-color); max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 12px; font-size: 24px; letter-spacing: -0.3px; }
.modal .lede { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; line-height: 1.6; }
.modal .key-input { margin-bottom: 16px; }
.modal .key-input label {
    display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 6px;
}
.modal .key-input input {
    width: 100%; padding: 10px 12px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: var(--text-main);
}
.modal .key-input input:focus { outline: none; border-color: var(--brand-gem); }

/* ─── Sync API keys section (inside settings modal) ───────────────────── */
.sync-section {
    background: color-mix(in srgb, var(--brand-gem) 6%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--brand-gem) 25%, var(--border));
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 22px;
}
.sync-toggle-row {
    display: flex; align-items: flex-start; gap: 12px;
    cursor: pointer;
}
.sync-toggle-row input[type="checkbox"] {
    width: 18px; height: 18px; margin-top: 2px;
    accent-color: var(--brand-gem);
    flex-shrink: 0;
}
.sync-toggle-label {
    display: flex; flex-direction: column; gap: 2px;
}
.sync-toggle-label strong { font-size: 14px; color: var(--text-main); }
.sync-toggle-sub {
    font-size: 11px; color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.sync-details {
    margin-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--brand-gem) 18%, var(--border));
    padding-top: 10px;
}
.sync-details summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    user-select: none;
}
.sync-details summary:hover { color: var(--text-main); }
.sync-pros-cons { margin-top: 8px; font-size: 12px; color: var(--text-main); line-height: 1.6; }
.sync-pros-cons strong { color: var(--text-main); }
.sync-pros-cons ul { margin: 4px 0 12px 18px; padding: 0; }
.sync-pros-cons li { margin: 3px 0; color: var(--text-muted); }
.sync-pros-cons li strong { color: var(--text-main); }
.sync-pros-cons code {
    background: var(--code-bg); padding: 1px 5px; border-radius: 3px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
    border: 1px solid var(--border);
}

.modal .modal-actions {
    display: flex; gap: 12px; margin-top: 24px; align-items: center; flex-wrap: wrap; justify-content: space-between;
}
.btn-secondary {
    padding: 10px 18px; border-radius: 8px; font-weight: 600; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main);
    font-size: 14px; transition: background 0.2s;
}
.btn-secondary:hover { background: var(--surface-hover); }
.free-info { font-size: 13px; color: var(--text-muted); }

/* 10) Animations & Toasts */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes tooltipFadeIn { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes blink  { 0%, 49% { opacity: 0.6; } 50%, 100% { opacity: 0; } }
@keyframes smoothPopIn { 0% { opacity: 0; transform: translateY(20px) scale(0.96); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes mdFadeIn { from { opacity: 0.4; } to { opacity: 1; } }
@keyframes errorShake {
    0%, 100% { transform: translateX(0); border-color: var(--error-border); color: #d04040; }
    20%, 60% { transform: translateX(-4px); border-color: #d04040; color: #d04040; }
    40%, 80% { transform: translateX(4px); border-color: #d04040; color: #d04040; }
}
.error-shake { animation: errorShake 0.4s ease forwards !important; }
.error-shake img { filter: grayscale(0%) sepia(1) hue-rotate(-50deg) saturate(5) !important; }
@keyframes gearGlow {
    0%, 100% { background: transparent; box-shadow: none; color: var(--text-muted); }
    30%, 70% { background: var(--brand-gem); color: #fff; box-shadow: 0 0 15px var(--brand-gem); }
}
.gear-glow { animation: gearGlow 1.5s ease; }

.error-toast {
    position: absolute; background: var(--error-bg); color: #d04040; border: 1px solid var(--error-border);
    padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; pointer-events: none;
    z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: toastFade 2.5s forwards; white-space: nowrap;
}
@keyframes toastFade {
    0% { opacity: 0; transform: translateY(5px) translateX(-50%); }
    10%, 80% { opacity: 1; transform: translateY(0) translateX(-50%); }
    100% { opacity: 0; transform: translateY(-5px) translateX(-50%); }
}

.info-wrap { position: relative; display: inline-block; }
.info-btn {
    width: 26px; height: 26px; border-radius: 50%; background: var(--surface-hover); color: var(--text-muted);
    font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); transition: background 0.2s, color 0.2s, border-color 0.2s; line-height: 1;
}
.info-btn:hover { background: var(--border); color: var(--text-main); border-color: var(--text-muted); }
.info-wrap.show .info-btn { background: var(--brand-gem); color: #fff; border-color: var(--brand-gem); }
.info-tooltip {
    display: none; position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
    width: 340px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px 18px; box-shadow: 0 8px 28px var(--shadow-color); z-index: 60;
    font-size: 13px; line-height: 1.55; color: var(--text-main); text-align: left; font-weight: 400; white-space: normal;
}
.info-wrap.show .info-tooltip { display: block; animation: tooltipFadeIn 0.2s ease forwards; }
.info-tooltip .info-title { display: block; margin-bottom: 8px; font-weight: 700; font-size: 14px; color: var(--text-main); }
.info-tooltip p { margin-bottom: 0; }

/* ─── Server stats footer ─────────────────────────────────────────────── */
.stat-footer {
    margin: 28px auto 14px;
    padding: 6px 16px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: max-content;
    max-width: calc(100vw - 32px);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.stat-footer .stat-sep { opacity: 0.45; }
.stat-footer .stat {
    position: relative;
    cursor: help;
    padding: 1px 2px;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}
.stat-footer .stat .label { color: var(--text-muted); }
.stat-footer .stat .val { font-weight: 600; color: var(--text-main); }
.stat-footer .stat .val.green  { color: #4caf50; }
.stat-footer .stat .val.yellow { color: #ff9800; }
.stat-footer .stat .val.red    { color: #f44336; }
.stat-footer .stat-tip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 8px 28px var(--shadow-color);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-main);
    z-index: 70;
    text-align: left;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.stat-footer .stat:hover .stat-tip,
.stat-footer .stat:focus-within .stat-tip { opacity: 1; }
.stat-footer .stat-tip .tip-title {
    display: flex; align-items: center; gap: 6px;
    font-weight: 700; font-size: 13px; margin-bottom: 6px;
}
.stat-footer .stat-tip ul {
    margin: 6px 0 0 16px; padding: 0; font-size: 11px; color: var(--text-muted);
}
.stat-footer .stat-tip li { margin: 2px 0; }
.stat-footer .stat-tip .swatch {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    margin-left: 4px; vertical-align: middle;
}

@media (max-width: 480px) {
    .stat-footer { font-size: 10px; gap: 6px; padding: 5px 12px; }
}

/* Subtle indicator when session save fails silently — easy to ignore unless
 * you're debugging, but loud enough to notice. */
body[data-save-failed]::before {
    content: "⚠ Session save failed (status: " attr(data-save-failed) ") — see DevTools console";
    position: fixed;
    bottom: 12px;
    right: 12px;
    background: var(--error-bg);
    color: var(--text-main);
    border: 1px solid var(--error-border);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    z-index: 9999;
    box-shadow: 0 4px 12px var(--shadow-color);
    max-width: 360px;
}

.response-text { white-space: pre-wrap; }
.response-text.md-rendered { white-space: normal; animation: mdFadeIn 0.3s ease; }

/* 12) Markdown rendering overrides */
.col-body p { margin-bottom: 12px; }
.col-body p:last-child { margin-bottom: 0; }
.col-body h1,.col-body h2,.col-body h3,.col-body h4 { margin: 16px 0 8px; font-weight: 700; line-height: 1.3; color: var(--text-main); }
.col-body h1 { font-size: 18px; } .col-body h2 { font-size: 16px; } .col-body h3 { font-size: 15px; }
.col-body ul,.col-body ol { margin: 8px 0 12px 20px; }
.col-body li { margin-bottom: 4px; }
.col-body code { background: var(--code-bg); padding: 2px 6px; border-radius: 4px; font-family: ui-monospace,"SF Mono",Menlo,monospace; font-size: 13px; color: #e2a0ff; border: 1px solid var(--border); }
.col-body pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); }
.col-body pre code { background: none; padding: 0; color: inherit; border: none; }
.col-body strong { color: var(--text-main); font-weight: 700; }
.col-body em { color: var(--text-muted); }
.col-body blockquote { border-left: 4px solid var(--border); padding-left: 12px; color: var(--text-muted); margin: 12px 0; font-style: italic; }
.col-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.col-body table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.col-body th,.col-body td { border: 1px solid var(--border); padding: 8px 10px; }
.col-body th { background: var(--surface-hover); font-weight: 700; text-align: left; }

/* 13) Inline debate section */
.col-debate-section { border-top: 2px dashed var(--border); background: var(--surface); }
.col-debate-divider {
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; background: var(--bg);
}
.col-debate-divider span {
    font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 800;
}
.debate-tabs { display: flex; gap: 6px; }
.debate-tab {
    background: var(--input-bg); border: 1px solid var(--border); color: var(--text-muted);
    padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; cursor: pointer;
    transition: all 0.2s;
}
.debate-tab:hover { background: var(--surface-hover); color: var(--text-main); }
.debate-tab.active { background: var(--surface-hover); border-color: var(--brand-gem); color: var(--text-main); }

.col-debate-body { padding: 16px; font-size: 14px; line-height: 1.7; max-height: 65vh; overflow-y: auto; }

/* Autoscroll indicator */
.autoscroll-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.3s;
}
.autoscroll-indicator .scroll-stop-icon {
    width: 10px; height: 10px;
    background: var(--text-muted);
    border-radius: 2px;
    flex-shrink: 0;
}

/* 11) Mobile (<= 768px) Overrides */
@media (max-width: 768px) {
    .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
    .topbar .prompt-wrap { order: 3; flex-basis: 100%; max-width: none; flex-wrap: wrap; }
    .topbar textarea { flex: 1 1 100%; max-width: none; }
    .auth-widget { font-size: 12px; gap: 6px; }
    .auth-widget .email { max-width: 110px; }
    .auth-widget .tier-badge { padding: 1px 6px; font-size: 10px; }
    .bot-picker { padding: 12px 16px; gap: 10px; justify-content: flex-start; }
    .bot-btn { width: 70px; height: 64px; font-size: 11px; }
    .bot-btn .svg-icon { transform: scale(0.85); margin-bottom: 2px; }
    .mobile-tabs { display: flex; overflow-x: auto; background: var(--topbar-bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
    .mobile-tab { padding: 12px 16px; white-space: nowrap; border-bottom: 3px solid transparent; color: var(--text-muted); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
    .mobile-tab.active { color: var(--text-main); }
    .mobile-tab[data-bot="openai"].active { border-bottom-color: var(--brand-oai); }
    .mobile-tab[data-bot="anthropic"].active { border-bottom-color: var(--brand-ant); }
    .mobile-tab[data-bot="gemini"].active { border-bottom-color: var(--brand-gem); }
    .mobile-tab[data-bot="deepseek"].active { border-bottom-color: var(--brand-ds); }
    .grid-wrap { padding: 0; }
    .response-grid { display: block; gap: 0; }
    .bot-col { display: none; border-radius: 0; min-height: 70vh; box-shadow: none; border-top: 4px solid transparent; border-bottom: 4px solid transparent; }
    .bot-col.mobile-active { display: flex; animation: smoothPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
    .col-body { max-height: none; }
    .col-head { position: static; top: auto; z-index: auto; }
    .disagreement { margin: 16px 16px 0; display: flex; }
    .disagreement-stack { padding: 0 16px; align-items: stretch; }
    .disagreement-stack .disagreement { margin: 0; }
}

/* ─── Phase 3: Shareable Links & Read-Only View ───────────────────────── */
.ro-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(66, 133, 244, 0.15); color: var(--brand-gem);
    padding: 6px 10px; border-radius: 6px; font-size: 12px; font-weight: 700;
    white-space: nowrap; border: 1px solid rgba(66, 133, 244, 0.3);
}
.btn-fork {
    background: var(--brand-gem); color: #fff; border: none; padding: 8px 16px; border-radius: 8px; 
    font-weight: 600; font-size: 13px; cursor: pointer; transition: transform 0.2s, filter 0.2s;
    white-space: nowrap; flex-shrink: 0;
}
.btn-fork:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-fork:disabled { opacity: 0.6; cursor: not-allowed; transform: none; filter: none; }

.history-tabs { display: flex; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.history-tab { padding: 14px 0; font-weight: 600; font-size: 14px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.history-tab:hover { color: var(--text-main); }
.history-tab.active { color: var(--text-main); border-bottom-color: var(--brand-gem); }

.share-inline-form {
    margin-top: 10px; padding: 14px; background: var(--surface-hover); 
    border: 1px solid var(--border); border-radius: 8px; display: none;
}
.share-inline-form.active { display: block; animation: fadeIn 0.2s ease; }
.share-inline-form .row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.share-inline-form select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-main); font-size: 13px; outline: none; }
.share-link-result { display: flex; gap: 8px; margin-top: 10px; }
.share-link-result input { flex: 1; padding: 8px 12px; font-size: 13px; border-radius: 6px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-main); font-family: ui-monospace, monospace; }

.centered-msg-card {
    max-width: 440px; margin: 120px auto; padding: 40px 30px; background: var(--surface); 
    border: 1px solid var(--border); border-radius: 16px; text-align: center; box-shadow: 0 12px 40px var(--shadow-color);
}
.centered-msg-card h2 { margin-bottom: 12px; font-size: 20px; }
.centered-msg-card p { color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }

/* Lifetime badge mirrors the Pro (paid) badge styling. */
.auth-widget .tier-badge.lifetime {
    background: var(--brand-gem); color: #fff; border-color: var(--brand-gem);
}

/* ── Phase 4: account / plan modal ─────────────────────────────────────────── */
/* The tier badge is the single entry point — make it read as clickable. */
.tier-badge.tier-badge-clickable { cursor: pointer; transition: filter 0.15s, transform 0.15s; }
.tier-badge.tier-badge-clickable:hover { filter: brightness(1.08); transform: translateY(-1px); }
.tier-badge.tier-badge-clickable:focus-visible { outline: 2px solid var(--brand-gem); outline-offset: 2px; }

/* Reuses the shared .modal-backdrop / .modal shell; these are the extras. */
.account-modal { position: relative; max-width: 480px; }
.account-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
    padding: 2px 6px; border-radius: 6px;
}
.account-close:hover { background: var(--surface-hover); color: var(--text-main); }

.account-title { font-size: 22px; letter-spacing: -0.3px; margin-bottom: 18px; padding-right: 28px; }
.account-body { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }

.account-benefits { list-style: none; margin: 0 0 22px; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.account-benefits li { position: relative; padding-left: 26px; font-size: 14px; color: var(--text-main); line-height: 1.5; }
.account-benefits li::before { content: '✓'; position: absolute; left: 0; top: 0; color: var(--brand-gem); font-weight: 700; }
.benefit-note { color: var(--text-muted); font-weight: 400; }

.account-plan { font-size: 14px; font-weight: 700; color: var(--text-main); margin-bottom: 18px; }

.account-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.account-buy { display: inline-flex; align-items: baseline; gap: 6px; }
.account-buy:disabled { opacity: 0.6; cursor: not-allowed; }
.account-price { font-weight: 700; font-size: 12px; opacity: 0.9; }

.account-fineprint { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin: 0; }

/* ── Phase 5: ask-button pulse, onboarding modal, contact/feedback modal ───── */

/* 1) Ask All button pulse — fires when ?prompt= prefills the box. Modelled on
   gearGlow; 3 cycles then stops. #ask-btn is already --brand-gem, so we pulse
   the glow only. */
@keyframes askBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    50%      { box-shadow: 0 0 16px 2px var(--brand-gem); }
}
.ask-btn-glow  { animation: askBtnPulse 1.2s ease infinite; }   /* glows until hover/click */
.keys-btn-glow { animation: gearGlow  1.5s ease infinite; }     /* reuses the existing gearGlow keyframes */

/* 2) Onboarding ("About PolyCog") modal — reuses .modal-backdrop / .modal. */
.onboarding-modal { position: relative; }
.onboarding-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
    padding: 2px 6px; border-radius: 6px;
}
.onboarding-close:hover { background: var(--surface-hover); color: var(--text-main); }

.onboarding-logos { display: flex; gap: 14px; align-items: center; justify-content: center; margin-bottom: 16px; }
.onboarding-logos img { width: 24px; height: 24px; }

.onboarding-modal h1 { font-size: 22px; letter-spacing: -0.3px; margin: 4px 0 12px; }
.onboarding-lead { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 14px; }

.onboarding-points { margin: 0 0 4px; padding-left: 20px; }
.onboarding-points li { margin: 7px 0; font-size: 14px; color: var(--text-main); line-height: 1.5; }

.onboarding-hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.onboarding-subhead { font-size: 15px; font-weight: 700; color: var(--text-main); margin: 0 0 8px; }
.onboarding-keys-blurb { color: var(--text-muted); font-size: 13px; line-height: 1.6; margin: 0 0 8px; }

.onboarding-api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.onboarding-api-btn {
    padding: 10px 12px; border-radius: 8px; font-weight: 600; font-size: 13px;
    background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main);
    transition: background 0.2s, border-color 0.2s; text-align: center;
}
.onboarding-api-btn:hover { background: var(--surface-hover); border-color: var(--brand-gem); }

/* Collapsible "What exactly is an API key?" — suppress the native marker so the
   manual ▸ glyph in the summary text is the only disclosure indicator. */
.onboarding-details { margin: 6px 0 2px; }
.onboarding-details summary {
    cursor: pointer; font-size: 13px; color: var(--text-muted); user-select: none; list-style: none;
}
.onboarding-details summary::-webkit-details-marker { display: none; }
.onboarding-details summary::marker { content: ''; }
.onboarding-details summary:hover { color: var(--text-main); }
.onboarding-details p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-top: 8px; }

.onboarding-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.onboarding-footer label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.onboarding-footer-center { display: flex; align-items: center; gap: 10px; }
.onboarding-sample-btn {
    background: var(--accent-green); color: #fff;
    padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px;
    border: none; white-space: nowrap; cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}
.onboarding-sample-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }

/* 3) Contact / Feedback modal — reuses .modal-backdrop / .modal, and the
   existing .history-tab label styling. Only the tab container is new. */
.contact-modal { position: relative; }
.contact-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
    padding: 2px 6px; border-radius: 6px;
}
.contact-close:hover { background: var(--surface-hover); color: var(--text-main); }

.contact-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }

.contact-form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.contact-form-group label { font-size: 13px; font-weight: 600; color: var(--text-main); }
.contact-form-group input,
.contact-form-group select,
.contact-form-group textarea {
    width: 100%; padding: 10px 12px; background: var(--input-bg);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text-main);
    font-size: 14px; font-family: inherit;
}
.contact-form-group textarea { resize: vertical; min-height: 120px; }
.contact-form-group input:focus,
.contact-form-group select:focus,
.contact-form-group textarea:focus { outline: none; border-color: var(--brand-gem); }

.contact-note { font-size: 12px; color: var(--text-muted); margin: -6px 0 14px; line-height: 1.5; }
.contact-note a { color: var(--brand-gem); }

.contact-inline-error { font-size: 13px; color: var(--error-text); font-weight: 600; margin-top: 10px; }

.contact-success { text-align: center; padding: 24px 8px; }
.contact-success h3 { font-size: 18px; margin-bottom: 16px; color: var(--text-main); }

/* ── Phase 6: sample → login conversion modal (reuses .modal shell) ────────── */
.convert-modal { position: relative; max-width: 460px; }
.convert-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
    padding: 2px 6px; border-radius: 6px;
}
.convert-close:hover { background: var(--surface-hover); color: var(--text-main); }
.convert-modal .account-fineprint a { color: var(--brand-gem); }

/* ── Phase 6: header share button glow + bottom toast ──────────────────────── */
@keyframes shareGlow {
    0%, 100% { box-shadow: none; color: var(--text-muted); }
    30%, 70% { box-shadow: 0 0 14px var(--accent-share); color: var(--accent-share); }
}
.share-glow { animation: shareGlow 1.8s ease 3; }
.share-btn-locked { cursor: not-allowed; opacity: 0.55; }

.bottom-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-share);
    border-radius: 6px; padding: 12px 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex; align-items: center; gap: 12px; font-size: 13px;
    color: var(--text-main); white-space: nowrap; animation: slideUpToast 0.25s ease;
}
@keyframes slideUpToast {
    from { transform: translateX(-50%) translateY(16px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.share-manage-modal { position: relative; max-width: 480px; }
.share-manage-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
    padding: 2px 6px; border-radius: 6px;
}
.share-manage-close:hover { background: var(--surface-hover); color: var(--text-main); }
.share-manage-modal .btn-revoke.danger {
    background: var(--input-bg); border: 1px solid var(--error-border);
    color: var(--error-text); padding: 10px 18px; border-radius: 8px;
    font-weight: 600; font-size: 14px;
}
.share-manage-modal .btn-revoke.danger:hover { background: var(--error-bg); }

/* ── Phase 6.5: split copy button, bottom action bar, export modal, toast ──── */

/* Split copy button. NOTE: position is absolute (spec said relative) so the
   button floats top-right of the response box and reveals on hover, matching
   the old .copy-btn behavior; absolute still anchors the dropdown below it. */
.copy-split-btn {
    position: absolute;
    top: 8px; right: 8px;
    display: inline-flex;
    align-items: stretch;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}
.response-section:hover .copy-split-btn,
.synthesis-output:hover .copy-split-btn,
.copy-split-btn:focus-within,
.copy-split-btn.menu-open { opacity: 1; }

.copy-main-btn {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.copy-main-btn:hover, .copy-main-btn.copied { color: var(--text-main); background: var(--surface-hover); }
.copy-chevron-btn {
    padding: 3px 6px;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.copy-chevron-btn:hover { color: var(--text-main); background: var(--surface-hover); }
.copy-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow-color);
    z-index: 60;
    min-width: 210px;
    overflow: hidden;
}
.copy-dropdown[hidden] { display: none; }
.copy-opt {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}
.copy-opt:hover { background: var(--surface-hover); }
.copy-opt + .copy-opt { border-top: 1px solid var(--border); }
.copy-opt-tip {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
    white-space: normal;
}

/* Bottom action bar */
#bottom-action-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    margin: 16px auto 8px;
    padding: 0;
}
.bottom-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s, transform 0.15s;
    padding: 8px;
    border-radius: 10px;
}
.bottom-action-btn:hover { color: var(--text-main); transform: translateY(-2px); }
.bottom-action-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.bottom-action-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Export modal */
.export-modal { position: relative; max-width: 460px; }
.export-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
    padding: 2px 6px; border-radius: 6px;
}
.export-close:hover { background: var(--surface-hover); color: var(--text-main); }
.export-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.export-opt-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    color: var(--text-main);
}
.export-opt-btn:hover { border-color: var(--brand-gem); background: var(--surface); }
.export-opt-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.export-opt-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    color: var(--text-muted);
    transition: color 0.15s;
}
.export-opt-icon svg { width: 26px; height: 26px; display: block; }
.export-opt-btn:hover .export-opt-icon { color: var(--brand-gem); }
.export-opt-text { display: block; min-width: 0; }
.export-opt-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}
.export-opt-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Toast notification */
.toast-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    box-shadow: 0 4px 16px var(--shadow-color);
    z-index: 200;
    pointer-events: none;
    animation: toastIn 0.2s ease, toastOut 0.3s ease 1.7s forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }