/* ── Simulation page styles ── */
/* Bridge simulations vars to base theme tokens */
:root {
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-bg: rgba(124, 58, 237, 0.06);
    --surface: var(--bg-secondary, #ffffff);
    --border: #e5e7eb;
    --text-muted: #a0a8ae;
}

.sim-hero {
    text-align: center;
    padding: 2.5rem 0 1.5rem;
}

.sim-hero h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.sim-hero .subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.llm-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 0.9rem;
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

.llm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.llm-dot.active {
    background: #34d399;
}

.llm-dot.inactive {
    background: #ef4444;
}

/* Mode cards */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.mode-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mode-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.15);
    border-color: var(--primary);
}

.mode-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.mode-card .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.mode-card h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.mode-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.mode-card .badge-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.mode-badge {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Config panel */
.sim-config {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin: 1.5rem 0;
    animation: slideIn 0.3s ease;
}

.sim-config.visible {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.config-title {
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Participant chips */
.participant-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.participant-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.participant-chip .remove-chip {
    cursor: pointer;
    opacity: 0.6;
    margin-left: 0.2rem;
    font-size: 0.7rem;
}

.participant-chip .remove-chip:hover {
    opacity: 1;
}

.empty-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.35rem 0;
}

/* Form row */
.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* Question builder */
.question-list {
    margin: 1rem 0;
}

.question-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
}

.question-item .q-num {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.question-item .q-body {
    flex: 1;
}

.question-item .q-text {
    font-weight: 500;
    color: var(--text-primary);
}

.question-item .q-type {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.question-item .q-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.question-item .q-remove:hover {
    color: var(--danger);
}

/* Run button */
.run-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 0.85rem 2.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
}

.run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.run-btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

.run-btn.loading .spinner {
    display: block;
}

.run-btn.loading .btn-text {
    display: none;
}

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

/* Results */
.results-area {
    display: none;
    margin-top: 2rem;
    animation: slideIn 0.4s ease;
}

.results-area.visible {
    display: block;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.results-header h2 {
    color: var(--primary);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
}

/* Conversation turns */
.conversation-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    max-height: none;
    overflow-y: auto;
}

.conv-turn {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

.conv-turn.speaker-0 {
    background: var(--primary-bg);
    border-left: 3px solid var(--primary);
    border-top: 1px solid rgba(124, 58, 237, 0.1);
    border-right: 1px solid rgba(124, 58, 237, 0.1);
    border-bottom: 1px solid rgba(124, 58, 237, 0.1);
}

.conv-turn.speaker-1 {
    background: var(--surface);
    border-left: 3px solid #636e72;
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.conv-turn.speaker-2 {
    background: rgba(52, 211, 153, 0.06);
    border-left: 3px solid #34d399;
    border-top: 1px solid rgba(52, 211, 153, 0.12);
    border-right: 1px solid rgba(52, 211, 153, 0.12);
    border-bottom: 1px solid rgba(52, 211, 153, 0.12);
}

.conv-turn.speaker-3 {
    background: rgba(249, 115, 22, 0.06);
    border-left: 3px solid #f97316;
    border-top: 1px solid rgba(249, 115, 22, 0.12);
    border-right: 1px solid rgba(249, 115, 22, 0.12);
    border-bottom: 1px solid rgba(249, 115, 22, 0.12);
}

.conv-turn .speaker-name {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.conv-turn.speaker-0 .speaker-name {
    color: var(--primary);
}

.conv-turn.speaker-1 .speaker-name {
    color: #636e72;
}

.conv-turn.speaker-2 .speaker-name {
    color: #34d399;
}

.conv-turn.speaker-3 .speaker-name {
    color: #f97316;
}

.conv-turn .turn-content {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Mini radar in conversation turns */
.turn-radar-wrap {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(124, 58, 237, 0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.turn-radar-canvas {
    flex: 0 0 160px;
    height: 160px;
}

.turn-radar-emotions {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: flex-start;
    align-content: flex-start;
    padding-top: 0.15rem;
}

.turn-radar-emotions .emo-chip {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    background: rgba(108, 92, 231, 0.06);
    border: 1px solid rgba(108, 92, 231, 0.12);
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.turn-radar-emotions .emo-chip .emo-val {
    color: var(--primary);
    font-weight: 700;
}

.radar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.2rem 0;
    margin-top: 0.35rem;
    transition: color 0.2s;
}

.radar-toggle-btn:hover {
    color: var(--primary);
}

/* Survey results */
.survey-results {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.survey-respondent {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.survey-respondent h3 {
    color: var(--primary);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.survey-answer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.survey-answer .sa-question {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.survey-answer .sa-question .sa-num {
    background: var(--primary);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.survey-answer .sa-response {
    color: var(--text-primary);
    line-height: 1.6;
    padding-left: 1.8rem;
}

.survey-answer .sa-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.15rem 0.6rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* Variations tab */
.variation-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.variation-tab {
    padding: 0.4rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.variation-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.variation-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.variation-panel {
    display: none;
}

.variation-panel.active {
    display: block;
}

/* Outcome tracking results */
.outcome-dashboard {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.outcome-summary {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: start;
}

.outcome-gauge {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.gauge-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: white;
    background: conic-gradient(var(--gauge-color, #34d399) calc(var(--gauge-pct, 0) * 1%),
            rgba(100, 100, 120, 0.12) calc(var(--gauge-pct, 0) * 1%));
    position: relative;
}

.gauge-circle::after {
    content: '';
    position: absolute;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--surface);
}

.gauge-circle .gauge-value {
    position: relative;
    z-index: 1;
    font-size: 1.6rem;
    font-weight: 800;
}

.gauge-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.gauge-sublabel {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.trait-correlations h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trait-bar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
}

.trait-bar-name {
    width: 140px;
    text-align: right;
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.trait-bar-wrap {
    flex: 1;
    height: 20px;
    background: rgba(100, 100, 120, 0.08);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.trait-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s ease;
    position: absolute;
    top: 0;
}

.trait-bar-fill.positive {
    background: linear-gradient(90deg, #34d399, #10b981);
    left: 50%;
}

.trait-bar-fill.negative {
    background: linear-gradient(90deg, #f87171, #ef4444);
    right: 50%;
}

.trait-bar-center {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-muted);
    opacity: 0.3;
}

.trait-bar-value {
    width: 50px;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.trait-bar-value.positive {
    color: #10b981;
}

.trait-bar-value.negative {
    color: #ef4444;
}

.outcome-trials {
    margin-top: 1.5rem;
}

.outcome-trials h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trial-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    transition: all 0.3s;
}

.trial-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
}

.trial-header:hover {
    background: var(--primary-bg);
}

.trial-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.trial-badge.success {
    background: rgba(52, 211, 153, 0.15);
    color: #10b981;
}

.trial-badge.failure {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.trial-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    flex: 1;
}

.trial-traits {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.trial-traits .tt {
    background: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.trial-expand {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.trial-body {
    display: none;
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border);
}

.trial-body.open {
    display: block;
}

.trial-reasoning {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    margin-top: 0.5rem;
    line-height: 1.5;
}

.trial-conv {
    margin-top: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.trial-conv .conv-turn {
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
}

.outcome-tip {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.04), rgba(52, 211, 153, 0.04));
    border: 1px solid rgba(124, 58, 237, 0.12);
    border-radius: 12px;
}

.outcome-tip h4 {
    color: var(--primary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.outcome-tip p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Vary-by radio cards */
.vary-by-options {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.vary-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.25s;
    text-align: center;
}

.vary-option:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.vary-option.active {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.06);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.vary-option input[type="radio"] {
    display: none;
}

.vary-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.vary-label {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.vary-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* ── Simulation History Panel ── */
.history-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin: 0 0 2rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.history-header:hover {
    background: var(--primary-bg);
}

.history-header h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.history-count {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    min-width: 1.2rem;
    text-align: center;
}

.history-toggle {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: transform 0.3s;
}

.history-panel.collapsed .history-toggle {
    transform: rotate(-90deg);
}

.history-list {
    max-height: 500px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.history-panel.collapsed .history-list {
    max-height: 0;
    padding: 0 0.5rem;
    opacity: 0;
    border-top: none;
    overflow: hidden;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    transition: all 0.2s;
    cursor: pointer;
}

.history-item:hover {
    background: var(--primary-bg);
}

.history-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.history-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .history-actions {
    opacity: 1;
}

.history-replay-btn,
.history-delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s;
}

.history-replay-btn {
    color: var(--primary);
}

.history-replay-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.history-delete-btn {
    color: var(--text-muted);
}

.history-delete-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

/* Replay loading indicator on history item */
.history-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.history-item.loading .history-icon {
    animation: spin 0.8s linear infinite;
}