/* ===== THEME VARIABLES ===== */
:root {
    --max-width: 1100px;
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-alt: #f5f5f4;
    --text: #1c1917;
    --text-dim: #78716c;
    --text-faint: #a8a29e;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --accent: #0d9488;
    --accent-soft: #ccfbf1;
    --side-left: #2563eb;
    --side-left-soft: #dbeafe;
    --side-right: #dc2626;
    --side-right-soft: #fee2e2;
    --score-text: #0f172a;
    --shadow: 0 1px 2px rgba(28,25,23,0.06);
    --radius-s: 4px;
    --radius: 6px;
    --radius-l: 10px;
}

[data-theme="dark"] {
    --bg: #1c1917;
    --surface: #292524;
    --surface-alt: #1c1917;
    --text: #e7e5e4;
    --text-dim: #a8a29e;
    --text-faint: #78716c;
    --border: #44403c;
    --border-strong: #57534e;
    --accent: #2dd4bf;
    --accent-soft: #042f2e;
    --side-left: #60a5fa;
    --side-left-soft: #1e3a5f;
    --side-right: #f87171;
    --side-right-soft: #5f1e1e;
    --score-text: #fafaf9;
    --shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== STATUS TOAST ===== */
#status-toast {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-110%);
    z-index: 10000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: 3px solid var(--accent);
    border-radius: 0 0 var(--radius-l) var(--radius-l);
    padding: 14px 28px;
    max-width: 640px;
    width: 92%;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.6s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

[data-theme="dark"] #status-toast {
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

#status-toast.visible {
    transform: translateX(-50%) translateY(0);
}

.status-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    animation: statusPulse 1.5s ease-in-out infinite;
    transition: background 0.6s ease;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

#status-toast.done .status-dot { animation: none; opacity: 1; }

.status-text {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; }
.hidden { display: none !important; }

a { color: var(--accent); }

/* ===== HEADER ===== */
header { margin-bottom: 36px; }

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

#feedback-btn {
    font-size: 0.8rem;
    color: var(--text-faint);
    --sl-color-primary-600: var(--text-dim);
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
    color: var(--text);
}

header h1 span { color: var(--accent); }

.subtitle {
    font-size: 1rem;
    color: var(--text-dim);
    margin: 0 0 10px;
}

.origin-note {
    font-size: 0.8rem;
    color: var(--text-faint);
    font-style: italic;
    margin: 0 0 14px;
}

.how-it-works, .algorithm { text-align: left; line-height: 1.7; color: var(--text); }
.how-it-works ol, .algorithm ol { padding-left: 20px; }
.algorithm ol li { margin-bottom: 6px; }
.algorithm code {
    background: var(--surface-alt);
    padding: 1px 5px;
    border-radius: var(--radius-s);
    font-size: 0.85em;
}

#theme-toggle {
    font-size: 1.25rem;
    cursor: pointer;
    --sl-input-border-color: transparent;
}

/* ===== SHARE BAR ===== */
.share-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius);
    padding: 8px 14px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    background: var(--surface);
}

.share-edit { border-left: 3px solid var(--side-left); }
.share-view { border-left: 3px solid var(--accent); margin-bottom: 18px; }

.share-bar code {
    background: var(--surface-alt);
    padding: 3px 8px;
    border-radius: var(--radius-s);
    font-size: 0.8rem;
    user-select: all;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
}

#view-only-banner { margin-bottom: 14px; }

.view-only #input-section { display: none; }
.view-only #argument-input { display: none; }
.view-only #argument-submit { display: none; }
.view-only #summary-btn { display: none; }

/* ===== INPUT ===== */
#input-section {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

#question-input { width: 100%; margin-bottom: 16px; }

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.model-selector label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    display: block;
    margin-bottom: 6px;
}

#model-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 4px;
}

#model-checkboxes sl-checkbox { font-size: 0.9rem; }

.model-id {
    color: var(--text-faint);
    font-size: 0.75rem;
    font-family: monospace;
}

.summarizer-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.summarizer-label-inline {
    font-size: 0.8rem;
    color: var(--text-faint);
}

#summarizer-trigger {
    font-size: 0.8rem;
    --sl-color-primary-600: var(--accent);
}

.persuasion-settings {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.persuasion-settings sl-input {
    --sl-input-label-font-size-small: 0;
}

.persuasion-settings sl-input::part(form-control-label) {
    display: none;
}

/* Summarizer badge in persuasion/chat */
.summarizer-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    padding: 4px 10px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    margin-bottom: 8px;
}

.summarized-block {
    margin-top: 12px;
    padding: 14px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

/* Individual model tabs inside persuasion */
.persuasion-individual { margin-bottom: 8px; }

/* Chat: expandable individual responses */
.chat-individual-details {
    margin-bottom: 4px;
}

.chat-individual-details::part(base) {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.chat-individual-details::part(header) {
    font-size: 0.8rem;
    padding: 6px 12px;
    color: var(--text-dim);
}

.chat-individual-content {
    font-size: 0.85rem;
    line-height: 1.5;
}

.chat-individual-content .model-resp-label {
    font-weight: 600;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 8px 0 4px;
}

.chat-individual-content .model-resp-label:first-child { margin-top: 0; }

.submit-btn { width: 100%; }

/* ===== LOADING ===== */
#loading-section { text-align: center; padding: 40px; }
#loading-status { color: var(--text-dim); margin-top: 12px; }

/* ===== PARSED ===== */
#parsed-section { margin-bottom: 20px; }

/* ===== RESULTS ===== */
#results-section { margin-bottom: 24px; }

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.result-side {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 16px;
    border: 1px solid var(--border);
    border-top: 3px solid;
}

.side-left { border-top-color: var(--side-left); }
.side-right { border-top-color: var(--side-right); }

.side-header h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.question-text {
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 12px;
    font-style: italic;
    white-space: pre-wrap;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.model-response {
    padding: 12px 0;
    line-height: 1.65;
    white-space: normal;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.92rem;
}

.model-response p { margin: 0 0 10px; }
.model-response h1, .model-response h2, .model-response h3 {
    margin: 14px 0 6px;
    color: var(--text);
}
.model-response ul, .model-response ol { padding-left: 20px; }

.response-scores {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
}

.response-scores .score-a { color: var(--side-left); }
.response-scores .score-b { color: var(--side-right); }

/* ===== SCORES ===== */
#scores-section {
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 24px;
    border: 1px solid var(--border);
}

#scores-section h3 {
    margin: 0 0 16px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
}

.scores-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.score-card {
    padding: 14px 24px;
    border-radius: var(--radius);
    background: var(--surface-alt);
    min-width: 110px;
    border: 1px solid var(--border);
}

.score-name {
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.score-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--score-text);
    letter-spacing: -0.02em;
}

.score-vs {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== STATS ===== */
/* ===== FINAL SCORE ===== */
#final-score-section { margin-bottom: 40px; }

.final-score-card {
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--radius-l);
    padding: 32px 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.final-score-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--side-left), var(--accent), var(--side-right));
}

.final-score-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 20px;
}

.final-score-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
}

.final-score-side {
    min-width: 140px;
}

.final-score-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.final-score-number {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 10px;
}

.final-side-a .final-score-number { color: var(--side-left); }
.final-side-b .final-score-number { color: var(--side-right); }

.final-score-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
}

.final-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.final-bar-a { background: var(--side-left); }
.final-bar-b { background: var(--side-right); }

.final-score-vs {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.final-score-verdict {
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-dim);
    font-style: italic;
}

#stats-content:not(:empty) {
    margin-top: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 20px;
}

/* Live stats — always at bottom during processing */
#live-stats-section { margin-bottom: 40px; }

#live-stats-content:not(:empty) {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 20px;
}

.stats-overview {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.stat-pill strong {
    color: var(--text);
    font-weight: 700;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stats-table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    padding: 6px 10px;
    border-bottom: 2px solid var(--border);
}

.stats-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.stats-table tr:last-child td { border-bottom: none; }

.stats-table .model-col { font-weight: 600; }

.stats-table .num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', monospace;
}

.stats-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
    min-width: 60px;
}

.stats-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* ===== PERSUASION ===== */
#persuasion-section { margin-bottom: 24px; }

#persuasion-section h3 {
    margin: 0 0 14px;
    font-size: 1rem;
    font-weight: 600;
}

.persuasion-round {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.persuasion-round h4 {
    margin: 0 0 10px;
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.persuasion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.persuasion-side {
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.persuasion-side.left { border-left: 3px solid var(--side-left); }
.persuasion-side.right { border-left: 3px solid var(--side-right); }

.persuasion-label {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.persuasion-content {
    line-height: 1.6;
    white-space: normal;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.round-scores {
    text-align: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 1rem;
    font-weight: 600;
}

/* ===== CHAT ===== */
#chat-section { margin-bottom: 24px; }

#chat-section h3 {
    margin: 0 0 14px;
    font-size: 1rem;
    font-weight: 600;
}

.chat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 14px;
}

.chat-side {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 16px;
    border: 1px solid var(--border);
}

.chat-side h4 {
    margin: 0 0 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 12px;
    min-height: 50px;
}

.chat-msg {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9rem;
}

.chat-msg.user {
    background: var(--side-left-soft);
    margin-left: 20%;
    text-align: right;
    border: 1px solid var(--border);
}

.chat-msg.ai {
    background: var(--surface-alt);
    margin-right: 20%;
    border: 1px solid var(--border);
}

.chat-input-row { display: flex; gap: 8px; }
.chat-input { flex: 1; }

.chat-scores-update {
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 14px;
    border: 1px solid var(--border);
}

.chat-scores-update h4 {
    margin: 0 0 10px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    font-weight: 600;
}

/* ===== SUMMARY ===== */
#summary-section { text-align: center; margin-bottom: 40px; }

#summary-result {
    text-align: left;
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 24px;
    border: 1px solid var(--border);
    margin-top: 14px;
    line-height: 1.65;
    font-size: 0.92rem;
}

#summary-content { white-space: normal; word-wrap: break-word; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .results-grid, .persuasion-grid, .chat-grid { grid-template-columns: 1fr; }
    .settings-row { flex-direction: column; align-items: stretch; }
    header h1 { font-size: 1.4rem; }
    .scores-display { flex-direction: column; gap: 10px; }
    .score-vs { transform: rotate(90deg); }
    .final-score-display { flex-direction: column; gap: 16px; }
    .final-score-vs { transform: rotate(90deg); }
    .final-score-number { font-size: 2.5rem; }
}
