/* ── Controls bar buttons ────────────────────────────────────────────── */
.rs-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--whs-ui-accent-border, rgba(206,255,26,0.35));
    color: var(--whs-ui-accent-text, #ceff1a);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.15s;
}
.rs-ctrl:hover { background: var(--whs-ui-accent-soft, rgba(206,255,26,0.08)); color: var(--whs-ui-accent-text, #ceff1a); text-decoration: none; }

/* ── Scenario panel ──────────────────────────────────────────────────── */
.rs-ctrl.accent { background: #ceff1a; color: var(--whs-ui-on-accent, #1a1a1a); border-color: var(--whs-ui-accent-border, #ceff1a); font-weight: 600; }
.rs-ctrl.accent:hover { background: #b8e600; color: var(--whs-ui-on-accent, #1a1a1a); }
.rs-scenario-btn { border-color: var(--whs-ui-accent-border, rgba(206,255,26,0.55)); }

.rs-scenario-overlay {
    position: fixed; inset: 0;
    background: var(--whs-ui-scrim, rgba(0,0,0,0.55));
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s;
    z-index: 1050;
}
.rs-scenario-overlay.open { opacity: 1; visibility: visible; }

.rs-scenario-panel {
    position: fixed; top: var(--top-nav-height, 60px); right: 0; bottom: 0;
    width: 440px; max-width: 100vw;
    color: var(--whs-ui-text, #cedada);
    font-family: var(--font-primary, 'Source Sans 3', sans-serif);
    background: var(--whs-ui-surface, #141414);
    border-left: 1px solid var(--whs-ui-border, rgba(255,255,255,0.12));
    box-shadow: -8px 0 30px var(--whs-ui-shadow, rgba(0,0,0,0.5));
    transform: translateX(100%);
    transition: transform 0.24s ease;
    z-index: 1060;
    display: flex; flex-direction: column;
}
.rs-scenario-panel.open { transform: translateX(0); }
.rs-scenario-panel :focus-visible { outline: 2px solid var(--whs-ui-accent-border, #ceff1a); outline-offset: 3px; }

.rs-scenario-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; padding: 1.25rem 1.5rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--whs-ui-border, rgba(255,255,255,0.08));
}
.rs-scenario-title { color: var(--whs-ui-text, #cedada); font-weight: 600; font-size: 1.25rem; letter-spacing: -0.02em; margin: 0; }
.rs-scenario-sub { color: var(--whs-ui-muted, rgba(255,255,255,0.4)); font-size: 0.78rem; margin-top: 0.2rem; line-height: 1.5; }
.rs-scenario-close {
    background: transparent; border: none; color: var(--whs-ui-muted, rgba(255,255,255,0.45));
    font-size: 1rem; cursor: pointer; padding: 0.5rem; line-height: 1;
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; flex-shrink: 0;
}
.rs-scenario-close:hover { color: var(--whs-ui-text, #fff); background: var(--whs-ui-surface-muted, rgba(255,255,255,0.06)); }

.rs-scenario-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 1.5rem; scrollbar-width: thin; }
.rs-scenario-group { padding: 1.25rem 0; border-bottom: 1px solid var(--whs-ui-border, rgba(255,255,255,0.06)); }
.rs-scenario-group:last-child { border-bottom: none; }
.rs-scenario-group-label {
    color: var(--whs-ui-text, #cedada); font-size: 0.85rem;
    margin-bottom: 0.85rem; font-weight: 600;
}

.rs-fld { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.85rem; min-width: 0; }
.rs-fld > span { color: var(--whs-ui-muted, rgba(255,255,255,0.7)); font-size: 0.8rem; }
.rs-fld select, .rs-fld input:not([type="checkbox"]) {
    background: var(--whs-ui-surface, #1f1f1f); border: 1px solid var(--whs-ui-border, rgba(255,255,255,0.14));
    color: var(--whs-ui-text, #fff); border-radius: 6px; padding: 0.55rem 0.65rem; font: inherit; font-size: 0.875rem;
    width: 100%; min-width: 0; min-height: 40px; box-sizing: border-box;
}
.rs-fld select:focus-visible, .rs-fld input:not([type="checkbox"]):focus-visible {
    outline: 2px solid var(--whs-ui-accent-border, #ceff1a); outline-offset: 2px; border-color: var(--whs-ui-accent-border, #ceff1a); box-shadow: 0 0 0 2px rgba(206,255,26,0.15);
}
.rs-fld-check { flex-direction: row; align-items: center; gap: 0.45rem; }
.rs-fld-check input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; accent-color: #ceff1a; }
.rs-fld-check > span { color: var(--whs-ui-muted, rgba(255,255,255,0.7)); font-size: 0.82rem; }
.rs-fld-sub {
    padding: 0.5rem 0.6rem; margin: 0.1rem 0 0.5rem;
    background: var(--whs-ui-surface-muted, rgba(255,255,255,0.03)); border-radius: 5px;
    border: 1px solid var(--whs-ui-border, rgba(255,255,255,0.05));
}
.rs-fld-sub .rs-fld:last-child { margin-bottom: 0; }
.rs-fixed-storage-list { display: flex; flex-direction: column; gap: 0.4rem; }
.rs-fixed-storage-master {
    display: flex; align-items: flex-start; gap: 0.55rem; padding: 0.6rem;
    background: var(--whs-ui-accent-soft, rgba(206,255,26,0.06)); border: 1px solid var(--whs-ui-accent-border, rgba(206,255,26,0.25));
    border-radius: 5px; color: var(--whs-ui-text, rgba(255,255,255,0.86)); font-size: 0.82rem;
    cursor: pointer;
}
.rs-fixed-storage-master input { margin-top: 0.15rem; accent-color: #ceff1a; }
.rs-fixed-storage-master small {
    display: block; color: var(--whs-ui-muted, rgba(255,255,255,0.48)); margin-top: 0.15rem;
}
.rs-fixed-storage-details { margin-top: 0.55rem; }
.rs-fixed-storage-details > summary {
    cursor: pointer; color: var(--whs-ui-muted, rgba(255,255,255,0.65)); font-size: 0.8rem;
}
.rs-fixed-storage-details .rs-fixed-storage-list { margin-top: 0.5rem; }
.rs-fixed-storage-item {
    display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.45rem 0.5rem;
    background: var(--whs-ui-surface-muted, rgba(255,255,255,0.03)); border: 1px solid var(--whs-ui-border, rgba(255,255,255,0.06));
    border-radius: 5px; color: var(--whs-ui-text, rgba(255,255,255,0.76)); font-size: 0.8rem;
}
.rs-fixed-storage-item input { margin-top: 0.15rem; accent-color: #ceff1a; }
.rs-fixed-storage-item small { display: block; color: var(--whs-ui-muted, rgba(255,255,255,0.4)); margin-top: 0.1rem; }
.rs-collapsible-group > summary { cursor: pointer; list-style-position: outside; }
.rs-collapsible-group > summary .rs-group-summary {
    display: block; color: var(--whs-ui-muted, rgba(255,255,255,0.55)); font-size: 0.76rem;
    text-transform: none; letter-spacing: normal; margin-top: 0.2rem;
}
.rs-capability-unavailable {
    margin-top: 0.55rem; padding: 0.5rem 0.6rem;
    border: 1px solid var(--whs-ui-danger, rgba(245,158,11,.35)); border-radius: 5px;
    background: rgba(245,158,11,.08); color: var(--whs-ui-danger, #ffd27a);
}
.rs-capability-unavailable > summary { cursor: pointer; font-weight: 600; }
.rs-capability-list { margin: 0.45rem 0 0; padding-left: 1.1rem; }
.rs-beam-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 0.6rem;
}
@media (max-width: 520px) {
    .rs-beam-grid { grid-template-columns: 1fr; }
}

.rs-scenario-error {
    color: var(--whs-ui-danger, #f87171); font-size: 0.82rem; margin-top: 0.5rem;
    background: rgba(248,113,113,0.08); border: 1px solid var(--whs-ui-danger, rgba(248,113,113,0.25));
    border-radius: 5px; padding: 0.5rem 0.6rem;
}
.rs-scenario-footer {
    display: flex; gap: 0.5rem; justify-content: flex-end;
    padding: 1rem 1.5rem max(1rem, env(safe-area-inset-bottom)); flex-shrink: 0; border-top: 1px solid var(--whs-ui-border, rgba(255,255,255,0.08));
}
.rs-scenario-footer .rs-ctrl { justify-content: center; min-height: 40px; padding: 0.55rem 0.85rem; border-radius: 6px; font-size: 0.85rem; white-space: normal; }
.rs-scenario-footer .rs-ctrl:not(.accent) { color: var(--whs-ui-text, #cedada); border-color: var(--whs-ui-border, rgba(255,255,255,0.14)); }
.rs-recalc-overlay {
    position: fixed; inset: 0; z-index: 1070;
    background: var(--whs-ui-surface, rgba(0,0,0,0.75));
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1rem; color: var(--whs-ui-accent-text, #ceff1a);
}
.rs-recalc-spinner {
    width: 46px; height: 46px; border-radius: 50%;
    border: 4px solid var(--whs-ui-accent-border, rgba(206,255,26,0.2)); border-top-color: var(--whs-ui-accent-border, #ceff1a);
    animation: rs-spin 0.8s linear infinite;
}
@keyframes rs-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .rs-scenario-panel, .rs-scenario-overlay { transition: none; }
    .rs-recalc-spinner { animation: none; }
}

/* Keep presets and advanced controls in the same form hierarchy. */
.rs-scenario-panel .op-picker {
    background: transparent; border: 0; border-bottom: 1px solid var(--whs-ui-border, rgba(255,255,255,0.08));
    border-radius: 0; padding: 1.25rem 0; margin: 0;
}
.rs-scenario-panel .op-field { margin: 0; gap: 0.4rem; }
.rs-scenario-panel .op-field > span { font-size: 0.85rem; font-weight: 600; }
.rs-scenario-panel .op-field select { min-height: 40px; font-size: 0.875rem; }
.rs-scenario-panel .op-actions { margin-top: 0.75rem; }
.rs-scenario-panel .op-actions button { font-size: 0.8rem; }
.rs-scenario-panel .op-error { font-size: 0.8rem; margin: 0.65rem 0 0; }
.rs-scenario-group > .rs-fld:last-child { margin-bottom: 0; }
.rs-fld small { color: var(--whs-ui-muted, rgba(255,255,255,0.5)); font-size: 0.75rem; line-height: 1.5; }
.rs-scenario-sub:empty { display: none; }
.rs-dimension-input { display: flex; gap: 0.5rem; align-items: center; }
.rs-dimension-input > span { font-size: 0.8rem; color: var(--whs-ui-muted, rgba(255,255,255,0.5)); }
.rs-scenario-advanced { margin-top: 0.75rem; }
.rs-scenario-advanced > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    min-height: 36px; color: var(--whs-ui-muted, #9da9ad); font-size: 0.8rem; font-weight: 500;
    cursor: pointer; list-style: none;
}
.rs-scenario-advanced > summary::-webkit-details-marker { display: none; }
.rs-scenario-advanced > summary::after {
    content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-right: 4px;
}
.rs-scenario-advanced[open] > summary::after { transform: rotate(225deg); }
.rs-scenario-advanced > summary:hover { color: var(--whs-ui-text, #cedada); }
.rs-scenario-advanced-body { padding-top: 0.75rem; }
@media (max-width: 520px) {
    .rs-scenario-header, .rs-scenario-footer { padding-left: 1rem; padding-right: 1rem; }
    .rs-scenario-body { padding-left: 1rem; padding-right: 1rem; }
    .rs-scenario-footer .rs-ctrl { flex: 1 1 140px; }
}

.rs-fld > .rs-scenario-group-label { margin-bottom: 0; color: var(--whs-ui-text, #cedada); font-size: 0.85rem; }
.rs-scenario-panel .op-field select {
    background: var(--whs-ui-surface, #1f1f1f);
    border-color: var(--whs-ui-border, rgba(255,255,255,0.14));
}
