/* Multi-Hop Reasoning Demo */
:root {
    --bg-dark: #0d1117;
    --bg-panel: #161b22;
    --bg-input: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-dim: #7d8590;
    --accent: #58a6ff;
    --success: #3fb950;
    --danger: #f85149;
    --warning: #d29922;
    --gold: #ffd700;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
    gap: 10px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.header h1 { font-size: 16px; }

.mode-tabs {
    display: flex;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 2px;
}

.tab {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
}

.tab.active { background: var(--accent); color: white; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

#speed-slider { width: 100px; }
#speed-label { width: 36px; }

.sim-badge {
    margin-left: auto;
    padding: 4px 10px;
    background: rgba(210, 153, 34, 0.15);
    border: 1px solid var(--warning);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--warning);
}

/* Views */
.view { display: none; flex-direction: column; flex: 1; gap: 10px; }
.view.active { display: flex; }

/* Phase bar */
.phase-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.phase-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-input);
    border-radius: 6px;
    opacity: 0.5;
    transition: all 0.3s;
}

.phase-item.active {
    opacity: 1;
    border: 1px solid var(--accent);
    background: rgba(88, 166, 255, 0.1);
}

.phase-item.complete {
    opacity: 1;
    border: 1px solid var(--success);
}

.phase-item.skipped {
    opacity: 0.6;
    position: relative;
}

.phase-item.skipped .phase-name,
.phase-item.skipped .phase-acc,
.phase-item.skipped .phase-desc {
    text-decoration: line-through;
    text-decoration-color: var(--text-dim);
}

.phase-skip-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--warning);
    color: var(--bg-dark);
    font-size: 8px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
}

.phase-name { font-weight: 600; font-size: 13px; }
.phase-acc { font-size: 18px; font-weight: 700; color: var(--success); }
.phase-desc { font-size: 10px; color: var(--text-dim); }
.phase-arrow { color: var(--text-dim); font-size: 18px; }

/* Panels */
.panel {
    background: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

.status-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 3px;
}

.status-badge.active { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.status-badge.inactive { background: rgba(248, 81, 73, 0.2); color: var(--danger); }

/* Training main layout */
.training-main {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* Graph panel - vertical layout */
.graph-panel { flex: 0 0 280px; }

.graph-container {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
}

.graph-node {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    opacity: 0.4;
    transition: all 0.3s;
}

.graph-node.highlighted {
    opacity: 1;
}

.graph-node.active {
    opacity: 1;
    background: rgba(63, 185, 80, 0.1);
    margin: 0 -12px;
    padding: 8px 12px;
    border-radius: 4px;
}

.node-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.3s;
}

.graph-node.highlighted .node-circle {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg-dark);
}

.graph-node.active .node-circle {
    background: var(--success);
    border-color: var(--success);
    color: white;
    transform: scale(1.2);
}

.node-label {
    font-size: 12px;
    color: var(--text-dim);
}

.graph-node.highlighted .node-label,
.graph-node.active .node-label {
    color: var(--text);
    font-weight: 500;
}

.node-arrow {
    width: 24px;
    display: flex;
    justify-content: center;
    padding: 4px 0;
    color: var(--border);
    font-size: 14px;
}

.graph-node.highlighted + .node-arrow,
.graph-node.active + .node-arrow {
    color: var(--gold);
}

/* Example panel */
.example-panel { flex: 1; }

.example-content {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.question-box, .output-box {
    background: var(--bg-input);
    border-radius: 6px;
    padding: 10px;
}

.question-box label, .output-box label {
    display: block;
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.question-box p { font-size: 13px; line-height: 1.4; }

.typewriter {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
    line-height: 1.5;
    min-height: 50px;
    color: var(--success);
}

.typewriter .cursor { animation: blink 0.7s infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

.answer-box { text-align: center; padding: 8px 0; }

.answer-badge {
    display: inline-block;
    padding: 6px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
}

.answer-badge.correct { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.answer-badge.incorrect { background: rgba(248, 81, 73, 0.2); color: var(--danger); }

/* Reward panel */
.reward-panel { flex: 0 0 220px; }

.reward-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reward-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    opacity: 0.4;
    transition: all 0.3s;
}

.reward-step.active { opacity: 1; }
.reward-step.total { border: 1px solid var(--border); }

.step-label { font-size: 11px; color: var(--text-dim); }
.step-value { font-size: 16px; font-weight: 600; font-family: monospace; }
.step-value.positive { color: var(--success); }
.step-value.negative { color: var(--danger); }

.reward-decision {
    text-align: center;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.reward-decision.keep { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.reward-decision.discard { background: rgba(248, 81, 73, 0.2); color: var(--danger); }

/* Training progress */
.training-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.progress-section { flex: 1; height: 60px; }
#progress-canvas { width: 100%; height: 100%; }

.stats-section { display: flex; gap: 24px; }
.stat { text-align: center; }
.stat-value { display: block; font-size: 24px; font-weight: 700; color: var(--success); }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }

.controls-section { display: flex; gap: 8px; }

.action-btn {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    cursor: pointer;
}

.action-btn:hover { filter: brightness(1.1); }
.action-btn.secondary { background: var(--bg-input); border: 1px solid var(--border); }
.action-btn.running { background: var(--danger); }

/* Inference view */
.inference-banner {
    padding: 8px 16px;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--danger);
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

.inference-main { display: flex; gap: 10px; flex: 1; min-height: 0; }
.question-panel { flex: 0 0 35%; }
.output-panel { flex: 1; }
.no-graph-panel { flex: 0 0 200px; }

.question-content, .output-content { padding: 12px; flex: 1; overflow-y: auto; }
.question-content p { font-size: 14px; margin-bottom: 12px; }

.options-list { display: flex; flex-direction: column; gap: 6px; }

.option-item {
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: 4px;
    font-size: 12px;
    border: 2px solid transparent;
}

.option-item.correct { border-color: var(--success); background: rgba(63, 185, 80, 0.1); }
.option-item.selected.wrong { border-color: var(--danger); background: rgba(248, 81, 73, 0.1); }

.answer-display {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-input);
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

.answer-display.correct { color: var(--success); }
.answer-display.incorrect { color: var(--danger); }

.no-graph-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
}

.no-graph-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }
.no-graph-content p { font-size: 12px; color: var(--text-dim); }
.no-graph-content .subtext { font-size: 11px; margin-top: 6px; }

/* Inference progress */
.inference-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.results-display { display: flex; gap: 20px; }
.result-item { text-align: center; }
.result-value { display: block; font-size: 22px; font-weight: 700; }
.result-value.correct { color: var(--success); }
.result-value.wrong { color: var(--danger); }
.result-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }

.progress-bar-container {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s; }

/* ========== TRY IT VIEW ========== */
.tryit-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 13px;
}

.tryit-notice.hidden { display: none; }
.tryit-notice.error {
    background: rgba(248, 81, 73, 0.1);
    border-color: var(--danger);
}

.notice-icon { font-size: 18px; }

.tryit-notice code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
}

.tryit-main {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.tryit-input-panel { flex: 0 0 40%; }
.tryit-output-panel { flex: 1; }

.tryit-input-content, .tryit-output-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

#tryit-question {
    flex: 1;
    min-height: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    resize: none;
}

#tryit-question:focus {
    outline: none;
    border-color: var(--accent);
}

.example-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.example-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.example-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
}

.example-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tryit-ask {
    align-self: flex-start;
    font-size: 14px;
    padding: 10px 24px;
}

.tryit-ask.loading {
    opacity: 0.7;
    pointer-events: none;
}

.output-section {
    background: var(--bg-input);
    border-radius: 6px;
    padding: 10px;
}

.output-section label {
    display: block;
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.tryit-trace {
    min-height: 80px;
    white-space: pre-wrap;
    word-break: break-word;
}

.tryit-answer {
    font-size: 16px;
    font-weight: 600;
    color: var(--success);
    min-height: 24px;
}

.metrics-section {
    display: flex;
    gap: 20px;
    padding: 12px;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.metric-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

.model-info {
    font-size: 10px;
    color: var(--text-dim);
    font-family: 'SF Mono', Monaco, monospace;
}

/* ========== DISTRIBUTION VIEW ========== */
.distribution-header {
    text-align: center;
    padding: 16px;
    background: var(--bg-panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.distribution-header h2 {
    font-size: 18px;
    margin-bottom: 6px;
}

.distribution-header p {
    font-size: 14px;
    color: var(--text-dim);
}

.distribution-header em {
    color: var(--danger);
    font-style: italic;
}

.distribution-main {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.comparison-panel { flex: 1; }
.explanation-panel { flex: 0 0 350px; }

.comparison-content, .explanation-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.comparison-table th, .comparison-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.comparison-table th {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 600;
}

.comparison-table td {
    font-size: 14px;
}

.highlight-row {
    background: rgba(63, 185, 80, 0.1);
}

.approach-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.approach-badge.sft {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent);
}

.approach-badge.rsft-easy {
    background: rgba(210, 153, 34, 0.2);
    color: var(--warning);
}

.approach-badge.rsft-hard {
    background: rgba(63, 185, 80, 0.2);
    color: var(--success);
}

.accuracy-value {
    font-weight: 600;
    font-size: 16px;
}

.accuracy-value.worse { color: var(--danger); }
.accuracy-value.best { color: var(--success); }

.arrow-down {
    color: var(--danger);
    font-size: 14px;
}

.star {
    color: var(--gold);
    font-size: 14px;
}

.insight-box {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(88, 166, 255, 0.05);
    border: 1px solid var(--accent);
    border-radius: 8px;
}

.insight-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.insight-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-dim);
}

.insight-text strong {
    color: var(--text);
}

.insight-text em {
    color: var(--danger);
    font-style: italic;
}

/* Distribution Visual */
.distribution-visual {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: 8px;
}

.distribution-visual.correct {
    background: rgba(63, 185, 80, 0.05);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.dist-label {
    width: 110px;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    flex-shrink: 0;
}

.dist-bar {
    flex: 1;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
}

.dist-bar.easy-bar {
    background: linear-gradient(90deg, var(--accent), transparent);
    width: 50%;
    color: white;
}

.dist-bar.hard-bar {
    background: linear-gradient(90deg, var(--warning), var(--danger));
    color: white;
}

.mismatch-indicator, .match-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.mismatch-x {
    font-size: 16px;
    font-weight: 700;
    color: var(--danger);
}

.match-check {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
}

.mismatch-indicator { color: var(--danger); }
.match-indicator { color: var(--success); }

/* Comparison Examples */
.examples-panel {
    margin-top: 10px;
}

.comparison-examples {
    display: flex;
    gap: 16px;
    padding: 16px;
    overflow-x: auto;
}

.example-card {
    flex: 0 0 280px;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 12px;
}

.example-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.example-card-body {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    line-height: 1.5;
    color: var(--success);
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}
