.experiment-mode-nav {
    display: inline-flex;
    gap: 4px;
    max-width: 100%;
    margin: 0 0 16px;
    padding: 4px;
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #f1f5f9;
    box-shadow: inset 0 1px 2px rgb(15 23 42 / 5%);
}

.experiment-mode-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #475569;
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.experiment-mode-nav a:hover {
    color: var(--primary);
    background: rgb(255 255 255 / 70%);
}

.experiment-mode-nav a.active,
.experiment-mode-nav a[aria-current="page"] {
    border-color: #bfdbfe;
    color: #1d4ed8;
    background: #fff;
    box-shadow: 0 2px 6px rgb(15 23 42 / 8%);
}

.experiment-mode-icon {
    color: #3b82f6;
    font-size: 1rem;
}

.experiment-control-chain {
    display: flex;
    position: relative;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    margin: 0 0 16px;
    padding: 12px 14px 34px;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 72%);
    scrollbar-width: thin;
}

.experiment-control-block {
    display: grid;
    flex: 1 0 132px;
    min-height: 62px;
    place-content: center;
    gap: 4px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #334155;
    text-align: center;
    box-shadow: 0 2px 7px rgb(15 23 42 / 5%);
}

.experiment-control-block code {
    color: #1d4ed8;
    font-size: .88rem;
    font-weight: 750;
}

.experiment-control-block span {
    font-size: .78rem;
    font-weight: 700;
}

.experiment-control-block-accent {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgb(59 130 246 / 10%);
}

.experiment-control-arrow {
    flex: 0 0 auto;
    color: #3b82f6;
    font-size: 1.25rem;
    font-weight: 800;
}

.experiment-feedback-return {
    display: flex;
    position: absolute;
    right: 14px;
    bottom: 8px;
    align-items: center;
    gap: 7px;
    color: #64748b;
    font-size: .75rem;
    font-weight: 700;
}

.experiment-feedback-return code {
    color: #475569;
    font-size: .75rem;
}

.experiment-preset-panel {
    margin-bottom: 16px;
}

.experiment-preset-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.experiment-preset-row > label {
    display: grid;
    gap: 6px;
    min-width: min(320px, 100%);
    color: #475569;
    font-size: .9rem;
    font-weight: 700;
}

.experiment-preset-row select,
.experiment-speed-control select {
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 11px;
    background: #fff;
    color: #0f172a;
    font: inherit;
}

.experiment-primary-actions,
.experiment-playback-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.experiment-primary-actions .btn-primary,
.experiment-primary-actions .btn-secondary,
.experiment-playback-toolbar .btn-secondary {
    width: auto;
    min-height: 40px;
}

.experiment-comparison-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.experiment-comparison-list:empty {
    display: none;
}

.experiment-scenario-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: #334155;
    background: #f8fafc;
    font-size: .84rem;
}

.experiment-scenario-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--scenario-color, var(--primary));
}

.experiment-layout {
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(420px, 1fr) minmax(260px, 300px);
    gap: 16px;
    align-items: start;
}

.experiment-parameters,
.experiment-results-panel,
.experiment-stage-panel {
    min-width: 0;
}

.experiment-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.experiment-field-grid small {
    color: #64748b;
    font-weight: 500;
}

.experiment-field-with-help {
    display: grid;
    gap: 6px;
    color: #475569;
    font-size: .9rem;
    font-weight: 600;
}

.experiment-field-caption {
    display: flex;
    align-items: center;
    gap: 4px;
}

.experiment-field-caption > label {
    display: inline;
    color: inherit;
    font: inherit;
}

.experiment-field-help {
    display: inline-flex;
    position: relative;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    align-items: center;
    justify-content: center;
    border: 1px solid #93c5fd;
    border-radius: 50%;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: help;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1;
}

.experiment-field-help:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.experiment-field-tooltip {
    box-sizing: border-box;
    position: absolute;
    z-index: 40;
    bottom: calc(100% + 9px);
    left: 50%;
    width: min(290px, calc(100vw - 48px));
    padding: 9px 11px;
    transform: translateX(-50%) translateY(3px);
    border-radius: 8px;
    background: #0f172a;
    color: #f8fafc;
    box-shadow: 0 8px 24px rgb(15 23 42 / 24%);
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.45;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}

.experiment-field-tooltip::after {
    position: absolute;
    top: 100%;
    left: 50%;
    border: 5px solid transparent;
    border-top-color: #0f172a;
    transform: translateX(-50%);
    content: "";
}

.experiment-field-help:hover .experiment-field-tooltip,
.experiment-field-help:focus .experiment-field-tooltip {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.experiment-advanced {
    margin-top: 18px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.experiment-advanced summary {
    color: #334155;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 12px;
}

.experiment-time-readout {
    color: #1d4ed8;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.experiment-speed-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    font-size: .86rem;
    font-weight: 700;
}

.experiment-speed-control select {
    padding: 7px 26px 7px 9px;
}

.experiment-timeline-control {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin: 12px 0;
    color: #475569;
    font-size: .86rem;
    font-weight: 700;
}

.experiment-timeline-control input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.experiment-animation-stage {
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 330px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #eff6ff;
}

.experiment-animation-stage svg {
    display: block;
    width: 100%;
    height: 100%;
}

.crane-track {
    stroke: #334155;
    stroke-width: 12;
    stroke-linecap: round;
}

.crane-target {
    stroke: #dc2626;
    stroke-width: 2;
    stroke-dasharray: 8 7;
    opacity: .7;
}

.crane-empty-state {
    opacity: .25;
    fill: #64748b;
    stroke: #64748b;
    stroke-width: 4;
}

.crane-empty-state line {
    fill: none;
}

.crane-scenario-rope {
    stroke: var(--scenario-color);
    stroke-width: 4;
    stroke-linecap: round;
}

.crane-scenario-trolley {
    fill: #fff;
    stroke: var(--scenario-color);
    stroke-width: 5;
}

.crane-scenario-wheel {
    fill: var(--scenario-color);
}

.crane-scenario-load {
    fill: var(--scenario-color);
    stroke: #fff;
    stroke-width: 4;
}

.crane-scenario-label {
    fill: #0f172a;
    font: 700 16px "Segoe UI", sans-serif;
}

.crane-scenario-comparison {
    opacity: .58;
}

.crane-scenario-comparison .crane-scenario-rope {
    stroke-dasharray: 8 6;
}

.experiment-metrics,
.experiment-controller-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px 12px;
    margin: 0;
    font-size: .86rem;
}

.experiment-metrics dt,
.experiment-controller-summary dt {
    color: #64748b;
    font-weight: 650;
}

.experiment-metrics dd,
.experiment-controller-summary dd {
    margin: 0;
    color: #0f172a;
    text-align: right;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.experiment-event-flags {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.experiment-flag {
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
    font-size: .8rem;
    font-weight: 700;
}

.experiment-flag.is-active {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.experiment-flag.is-danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.experiment-note-list {
    margin: 0;
    padding-left: 19px;
    color: #475569;
    font-size: .86rem;
    line-height: 1.45;
}

.experiment-warning-list {
    color: #9a3412;
}

.experiment-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.experiment-plot {
    width: 100%;
    height: 330px;
    min-width: 0;
}

@media (max-width: 1180px) {
    .experiment-layout {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    }

    .experiment-results-panel {
        grid-column: 1 / -1;
    }

    .experiment-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr) max-content);
    }
}

@media (max-width: 820px) {
    .experiment-layout,
    .experiment-charts {
        grid-template-columns: 1fr;
    }

    .experiment-stage-panel {
        grid-row: 1;
    }

    .experiment-results-panel {
        grid-column: auto;
    }

    .experiment-metrics {
        grid-template-columns: minmax(0, 1fr) max-content;
    }
}

@media (max-width: 640px) {
    .experiment-field-tooltip {
        width: min(220px, calc(100vw - 48px));
    }

    .experiment-preset-row > label {
        min-width: 100%;
    }

    .experiment-primary-actions,
    .experiment-playback-toolbar {
        width: 100%;
    }

    .experiment-primary-actions .btn-primary,
    .experiment-primary-actions .btn-secondary,
    .experiment-playback-toolbar .btn-secondary {
        flex: 1 1 auto;
    }

    .experiment-field-grid {
        grid-template-columns: 1fr;
    }

    .experiment-animation-stage {
        min-height: 260px;
    }

    .experiment-plot {
        height: 290px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .experiment-field-tooltip,
    .crane-scenario-load,
    .crane-scenario-trolley,
    .crane-scenario-rope {
        transition: none;
    }
}
