/* classical-feedback-primer/styles.css */

.tool-page {
    padding-top: var(--ai-space-4);
    padding-bottom: var(--ai-space-8);
}

.cfb-section {
    max-width: none;
    margin: 0 0 var(--ai-space-6);
}

.cfb-section .intro-lead {
    font-size: 1.02rem;
    line-height: 1.65;
    color: #1e293b;
    margin-bottom: var(--ai-space-4);
}

.cfb-section p strong {
    color: #1e293b;
}

.cfb-section mjx-container[display="true"] {
    display: block;
    margin: var(--ai-space-3) 0 var(--ai-space-4);
    padding: 14px 20px;
    max-width: 100%;
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-md);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.cfb-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ai-space-5);
    align-items: start;
    margin-top: var(--ai-space-3);
}

.cfb-split-prose {
    min-width: 0;
}

.cfb-split-viz {
    min-width: 0;
    position: sticky;
    top: 12px;
}

.cfb-split-viz .loop-diagram-wrap {
    margin: 0;
    max-width: none;
}

.cfb-split-viz .loop-diagram-wrap img {
    max-width: 100%;
}

.cfb-interactive {
    margin: var(--ai-space-5) 0;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--ai-radius-lg);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.cfb-interactive h3 {
    margin: 0 0 var(--ai-space-3);
    font-size: 1.05rem;
    color: var(--ai-blue-800);
}

.cfb-interactive .panel-hint {
    margin: 0 0 12px;
    font-size: 0.86rem;
    color: var(--ai-gray-600);
    line-height: 1.45;
}

.cfb-interactive-split {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.1fr);
    gap: var(--ai-space-4);
    align-items: start;
}

.cfb-interactive-controls {
    min-width: 0;
}

.cfb-interactive-plots {
    min-width: 0;
}

.pm-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.pm-preset-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    border-radius: var(--ai-radius-md);
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pm-preset-btn[data-pm="10"] { border-color: #fecaca; }
.pm-preset-btn[data-pm="30"] { border-color: #fca5a5; }
.pm-preset-btn[data-pm="45"] { border-color: #fdba74; }
.pm-preset-btn[data-pm="60"] { border-color: #86efac; }
.pm-preset-btn[data-pm="75"] { border-color: #93c5fd; }
.pm-preset-btn[data-pm="120"] { border-color: #c4b5fd; }

.pm-preset-btn.active {
    color: #fff;
    border-color: transparent;
}

.pm-preset-btn[data-pm="10"].active { background: #7f1d1d; }
.pm-preset-btn[data-pm="30"].active { background: #dc2626; }
.pm-preset-btn[data-pm="45"].active { background: #ea580c; }
.pm-preset-btn[data-pm="60"].active { background: #16a34a; }
.pm-preset-btn[data-pm="75"].active { background: #2563eb; }
.pm-preset-btn[data-pm="120"].active { background: #7c3aed; }

.phase-mode-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.84rem;
    color: #334155;
}

.phase-mode-row label {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    cursor: pointer;
    line-height: 1.4;
}

.k-control-row,
.ta-control-row {
    display: grid;
    grid-template-columns: 1fr 72px;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--ai-radius-md);
}

.k-control-row label,
.ta-control-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #78350f;
    grid-column: 1;
}

.k-control-row input[type="number"],
.ta-control-row input[type="number"] {
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-sm);
    font-size: 0.85rem;
}

.k-control-row input[type="range"],
.ta-control-row input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
}

.bode-readouts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.bode-readout {
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-sm);
    font-size: 0.82rem;
}

.bode-readout .label {
    display: block;
    font-weight: 600;
    color: #475569;
    margin-bottom: 2px;
}

.bode-readout .value {
    font-family: var(--ai-font-mono);
    color: var(--ai-blue-800);
}

.pm-math-readout,
.ta-readout {
    font-size: 0.82rem;
    color: #475569;
    padding: 8px 10px;
    background: #eef2ff;
    border-left: 3px solid #6366f1;
    border-radius: 0 var(--ai-radius-sm) var(--ai-radius-sm) 0;
    margin-bottom: 10px;
    line-height: 1.45;
}

.chart-pane-square {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-height: 480px;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-sm);
    padding: 6px;
    background: #fafafa;
}

.chart-coordinates {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--ai-gray-600);
    text-align: center;
    font-family: var(--ai-font-mono);
}

.tf-factored {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.tf-legend {
    font-size: 0.82rem;
    color: #475569;
    padding: 6px 0;
    overflow-x: auto;
}

.tf-form-card mjx-container[display="true"],
.tf-legend mjx-container[display="true"] {
    margin: 0;
    padding: 4px 0;
    overflow-x: auto;
}

.bode-stack-square {
    display: flex;
    flex-direction: column;
    gap: 6px;
    aspect-ratio: 1;
    max-height: 520px;
    width: 100%;
}

.bode-stack-square .chart-pane {
    flex: 1;
    min-height: 0;
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-sm);
    padding: 4px;
    background: #fafafa;
}

.bode-stack-square .chart-pane-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0 0 2px 4px;
}

.chart-pane canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-pane-compact {
    position: relative;
    height: 220px;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-sm);
    padding: 4px;
    background: #fafafa;
    margin-bottom: 8px;
}

.ta-step-pane {
    position: relative;
    height: 200px;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-sm);
    padding: 4px;
    background: #fafafa;
    margin-bottom: 8px;
}

.tf-compare {
    display: grid;
    gap: 8px;
    margin: 12px 0;
}

.tf-form-card {
    padding: 10px 12px;
    border-radius: var(--ai-radius-sm);
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.88rem;
    overflow-x: auto;
}

.tf-form-card.high-entropy {
    border-color: #e2e8f0;
}

.tf-form-card.low-entropy {
    border-color: #86efac;
    background: #f0fdf4;
}

.tf-form-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 6px;
}

.tf-form-card.low-entropy .tf-form-tag {
    color: #15803d;
}

.scope-panel-cfb {
    border: 1px solid #334155;
    border-radius: var(--ai-radius-md);
    overflow: hidden;
    background: #0a0a0a;
}

.cfb-scope-canvas {
    display: block;
    width: 100%;
    height: 320px;
}

.scope-note {
    margin: 10px 0 0;
    font-size: 0.84rem;
    color: var(--ai-gray-600);
    line-height: 1.45;
}

.cfb-callout {
    margin: var(--ai-space-3) 0 0;
    padding: 12px 14px;
    background: #f0f9ff;
    border-left: 3px solid var(--ai-blue-600);
    border-radius: 0 var(--ai-radius-sm) var(--ai-radius-sm) 0;
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.55;
}

.cfb-list {
    margin: 12px 0 16px 20px;
    line-height: 1.6;
    color: #475569;
}

.cfb-list li {
    margin-bottom: 6px;
}

.next-links {
    margin: 12px 0 0 20px;
    line-height: 1.7;
}

.next-links a {
    color: var(--ai-blue-600);
    font-weight: 600;
}

.loop-diagram-wrap {
    text-align: center;
}

.loop-diagram-wrap img {
    display: block;
    width: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--ai-radius-md);
    padding: 12px;
}

.loop-diagram-wrap figcaption {
    margin-top: 10px;
    font-size: 0.88rem;
    color: var(--ai-gray-600);
    line-height: 1.5;
}

@media (max-width: 960px) {
    .cfb-split,
    .cfb-interactive-split {
        grid-template-columns: 1fr;
    }

    .cfb-split-viz {
        position: static;
    }

    .bode-stack-square {
        max-height: none;
        aspect-ratio: auto;
    }

    .bode-stack-square .chart-pane {
        min-height: 180px;
    }
}

@media (max-width: 520px) {
    .k-control-row,
    .ta-control-row {
        grid-template-columns: 1fr;
    }
}