/* open-closed-loop — taller Bodes beside plane/step, compact knobs. */

.oc-page .cl-walk .mt-part-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ai-gray-500);
}

.oc-page .cl-workspace {
    align-items: stretch;
    min-height: calc(100dvh - 108px);
}

.oc-page .cl-lab {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.oc-page .cl-lab .cl-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
    padding: 10px 12px 12px;
}

.cl-panel .mt-panel-head {
    margin-bottom: 8px;
    align-items: center;
    flex-shrink: 0;
}

.cl-panel .mt-panel-head h2 { margin: 0; font-size: 1rem; }

.oc-hs-dock {
    position: static;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0 0 8px;
    padding: 8px 10px;
    background: #f8fbff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    overflow-x: auto;
}

.tf-h-lhs {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e3a8a;
    white-space: nowrap;
}
.tf-h-lhs i, .tf-frac i {
    font-family: "Times New Roman", Times, serif;
    font-style: italic;
    font-weight: 500;
}
.oc-k { font-family: var(--ai-font-mono, ui-monospace, monospace); font-weight: 700; color: var(--ai-blue-800); }
.oc-times { color: var(--ai-gray-500); }

.tf-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
}
.tf-frac-outer { font-size: 0.95rem; }
.tf-frac-inner { font-size: 0.72rem; }
.tf-frac-bar { display: block; width: 100%; height: 1.5px; background: #1e3a8a; margin: 2px 0; }
.tf-frac-num, .tf-frac-den { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.pz-lit, .pz-plus, .pz-dot { font-weight: 600; }
.pz-origin { font-family: "Times New Roman", Times, serif; font-style: italic; }
.pz-origin.is-s { font-size: 1.5em; font-weight: 700; color: #111827; }
.pz-group { position: relative; padding: 0 0.45em; display: inline-flex; align-items: center; gap: 4px; }
.pz-group::before { content: "("; }
.pz-group::after { content: ")"; }
.pz-term { display: inline-flex; align-items: center; gap: 4px; }
.pz-group.is-off, .pz-term.is-off, .pz-origin.is-off { opacity: 0.38; }
.oc-k.is-flash,
.pz-term.is-flash,
.pz-group.is-flash,
.pz-origin.is-flash,
.oc-toggle.is-flash,
.oc-toggle-k.is-flash,
.oc-toggle-origin.is-flash,
.oc-toggle-lf.is-flash,
.oc-toggle-z.is-flash,
.oc-toggle-hf.is-flash {
    outline: 2px solid #3b82f6;
    background: #dbeafe;
    border-radius: 5px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.oc-k, .pz-term, .pz-group, .pz-origin, .oc-toggle {
    transition: outline 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.tf-fz { color: #16a34a; font-weight: 700; }
.tf-flf { color: #e11d48; font-weight: 700; }
.tf-fhf { color: #ca8a04; font-weight: 700; }

.oc-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.oc-presets button {
    font-size: 0.78rem; font-weight: 600; padding: 4px 10px;
    border: 1px solid var(--ai-gray-200); border-radius: 999px;
    background: #fff; color: var(--ai-gray-700); cursor: pointer;
}
.oc-presets button:hover { border-color: var(--ai-gold); background: #fef9e7; }
.oc-presets button.active { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }

.oc-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: stretch;
    margin: 0 0 8px;
    flex-shrink: 0;
}
.oc-toggle {
    display: flex; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 6px 8px;
    padding: 5px 8px; background: #fff;
    border: 1px solid var(--ai-gray-200); border-radius: 8px;
    font-size: 0.76rem; color: var(--ai-gray-700);
}
.oc-toggle-k { border-left: 3px solid #2563eb; }
.oc-toggle-origin { border-left: 3px solid #111827; }
.oc-toggle-lf { border-left: 3px solid #e11d48; }
.oc-toggle-z { border-left: 3px solid #16a34a; }
.oc-toggle-hf { border-left: 3px solid #ca8a04; }
.oc-toggle-z:has(input:checked) { background: #f0fdf4; }
.oc-toggle-lf:has(input:checked) { background: #fff1f2; }
.oc-toggle-hf:has(input:checked) { background: #fefce8; }
.oc-toggle-origin:has(input:checked) { background: #f8fafc; }
.oc-freq { display: flex; align-items: center; gap: 6px; }
.oc-freq input[type="number"], .oc-toggle input[type="number"] {
    width: 5.2rem; padding: 3px 6px; border: 1px solid var(--ai-gray-300); border-radius: 6px;
}
.oc-live {
    display: flex; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 2px 14px;
    flex: 1 1 220px;
    padding: 5px 8px; background: #f8fafc; border-radius: 8px;
    font-size: 0.76rem; color: var(--ai-gray-700);
}
.oc-live .output { font-weight: 700; color: #1e3a8a; }

.oc-viz {
    flex: 1 1 auto;
    min-height: 420px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(280px, 0.7fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
        "ol cl plane"
        "ol cl step";
    gap: 8px;
}
.oc-plot[data-plot="ol"] { grid-area: ol; }
.oc-plot[data-plot="cl"] { grid-area: cl; }
.oc-plot[data-plot="plane"] { grid-area: plane; }
.oc-plot[data-plot="step"] { grid-area: step; }
.oc-plot {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--ai-gray-200);
    border-radius: 10px;
    padding: 6px 8px 4px;
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.oc-plot.is-lit {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}
.oc-plot .im-chart-label { flex-shrink: 0; }
.oc-chart-wrap,
.oc-chart-wrap.tall {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}
.oc-chart-wrap canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.oc-algebra {
    flex-shrink: 0;
    margin: 8px 0 0;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid var(--ai-gray-200);
    border-radius: 10px;
    font-size: 0.76rem;
    color: var(--ai-gray-700);
    line-height: 1.35;
}
.oc-algebra strong { color: #1e3a8a; }
.oc-cubic {
    display: block;
    margin: 6px 0;
    font-family: var(--ai-font-mono, ui-monospace, monospace);
    font-size: 0.76rem;
    color: #0f172a;
    white-space: pre-wrap;
}
.oc-cubic-note { display: block; margin-top: 4px; color: var(--ai-gray-500); font-family: inherit; font-size: 0.75rem; }
.oc-slow-hint { margin: 6px 0 0; color: #c026d3; font-weight: 600; }
.oc-cl-bode-note {
    margin: 4px 0 0;
    font-size: 0.74rem;
    line-height: 1.35;
    color: #c026d3;
    font-weight: 600;
}
.oc-fn-hint {
    display: block;
    margin-top: 2px;
    font-weight: 500;
    color: var(--ai-gray-500);
    font-size: 0.74rem;
}
.scope-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--ai-gray-600);
    flex-shrink: 0;
}
.scope-legend .swatch {
    display: inline-block; width: 12px; height: 3px; margin-right: 5px; vertical-align: middle; border-radius: 1px;
}
.leg-ol .swatch { background: #2563eb; }
.leg-olph .swatch { background: #64748b; }
.leg-cl .swatch { background: #0f766e; }
.leg-clph .swatch { background: #c2410c; }
.leg-pz {
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.01em;
}
.leg-pz.pz-origin { color: #111827; }
.leg-pz.pz-lf { color: #e11d48; }
.leg-pz.pz-z { color: #16a34a; }
.leg-pz.pz-hf { color: #ca8a04; }
.leg-pz.pz-cl { color: #c026d3; }

.oc-partb {
    margin: 0;
    padding: 12px 16px 16px;
    max-width: none;
}
.oc-partb-lead {
    margin: 0 0 16px;
    color: var(--ai-gray-700);
    line-height: 1.5;
    max-width: 900px;
}
.oc-grind {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: grind;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 900px;
}
.oc-grind > li {
    counter-increment: grind;
    position: relative;
    padding: 12px 14px 12px 48px;
    background: #fff;
    border: 1px solid var(--ai-gray-200);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--ai-gray-700);
    line-height: 1.5;
}
.oc-grind > li::before {
    content: counter(grind);
    position: absolute;
    left: 12px;
    top: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1e3a8a;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.oc-grind > li.is-off { opacity: 0.45; }
.oc-g-num {
    font-family: var(--ai-font-mono, ui-monospace, monospace);
    font-weight: 700;
    font-size: 0.86em;
    color: #1e3a8a;
    background: #eff6ff;
    padding: 0 4px;
    border-radius: 4px;
}
.oc-g-factored {
    margin: 8px 0 0;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    font-family: var(--ai-font-mono, ui-monospace, monospace);
    font-size: 0.8rem;
    color: #0f172a;
    overflow-x: auto;
}
.oc-partb-moral {
    margin: 14px 0 0;
    padding: 10px 14px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    color: #9a3412;
    font-weight: 600;
    line-height: 1.45;
    max-width: 900px;
}

.cl-page .control-loops-series-mount--bottom { display: none; }

@media (prefers-reduced-motion: reduce) {
    .oc-plot, .oc-k, .pz-term, .pz-group, .pz-origin, .oc-toggle { transition: none; }
}

@media (max-width: 1400px) {
    .oc-viz {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "ol cl"
            "plane step";
    }
}
@media (max-width: 1100px) {
    .oc-page .cl-workspace { height: auto; min-height: 0; }
    .oc-viz {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas: none;
        height: auto;
        min-height: 0;
    }
    .oc-plot[data-plot="ol"],
    .oc-plot[data-plot="cl"],
    .oc-plot[data-plot="plane"],
    .oc-plot[data-plot="step"] { grid-area: auto; }
    .oc-chart-wrap,
    .oc-chart-wrap.tall { height: 280px; min-height: 280px; flex: none; }
}
