/* Rappture2Web Stylesheet */
:root {
    --rp-primary: #1a3a5c;
    --rp-primary-hover: #274f79;
    --rp-accent: #e87722;
    --rp-accent-soft: #f59d57;
    --rp-bg: #eef3f8;
    --rp-bg-secondary: #e8eef6;
    --rp-sidebar-bg: #ffffff;
    --rp-border: #ccd8e6;
    --rp-text: #1f2d3d;
    --rp-text-muted: #516377;
    --rp-success: #216d48;
    --rp-error: #a22b2b;
    --rp-danger: #b93838;
    --rp-toolbar-bg: #132f4c;
    --rp-radius: 8px;
    --rp-header-height: 76px;
    --rp-header-height-with-toolbar: 124px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* ── Custom tooltip ──────────────────────────────────────────────────────── */
#rp-tooltip {
    position: fixed;
    z-index: 9999;
    max-width: 280px;
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: none;
}
#rp-tooltip.rp-tooltip-visible {
    display: block;
}
#rp-tooltip .rp-tooltip-desc {
    margin-bottom: 4px;
}
#rp-tooltip .rp-tooltip-meta {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#rp-tooltip .rp-tooltip-meta span b {
    color: #cbd5e1;
}

/* Accessibility utilities */
.rp-sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.rp-skip-link {
    position: absolute; top: -100px; left: 12px; z-index: 9999;
    padding: 8px 16px; background: var(--rp-primary); color: #fff;
    border-radius: 0 0 var(--rp-radius) var(--rp-radius);
    font-weight: 600; text-decoration: none; font-size: 14px;
    transition: top 0.1s;
}
.rp-skip-link:focus { top: 0; outline: 3px solid #fff; outline-offset: 2px; }

/* Global focus-visible: consistent across all interactive elements */
:focus-visible {
    outline: 3px solid var(--rp-primary);
    outline-offset: 2px;
}

body {
    font-family: "Source Sans 3", "IBM Plex Sans", "Segoe UI", Tahoma, sans-serif;
    font-size: 14px;
    color: var(--rp-text);
    background:
        radial-gradient(circle at 15% 15%, rgba(255,255,255,0.9) 0, rgba(255,255,255,0) 38%),
        linear-gradient(155deg, #eef3f8 0%, #e7eef7 46%, #dde7f4 100%);
    line-height: 1.4;
}

/* Header / Toolbar */
.rp-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(14, 28, 44, 0.15);
}
.rp-brand-bar {
    min-height: 76px;
    display: flex;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(90deg, #ffffff 0%, #f4f8fc 100%);
    border-bottom: 1px solid #d6e0eb;
}
.rp-powered-by {
    margin-left: auto;
    align-self: flex-end;
    font-size: 11px;
    color: #8fa3b5;
    white-space: nowrap;
    padding-bottom: 2px;
}
.rp-powered-by a {
    color: #8fa3b5;
    text-decoration: none;
    font-weight: 600;
}
.rp-powered-by a:hover {
    color: var(--rp-primary, #2563eb);
    text-decoration: underline;
}
.rp-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}
.rp-nanohub-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
    border-right: 1px solid #d6e0eb;
    padding-right: 14px;
}
.rp-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.rp-brand-platform {
    font-size: 11px;
    line-height: 1.1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5c7084;
    font-weight: 700;
}
.rp-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--rp-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rp-toolbar {
    background: linear-gradient(90deg, var(--rp-toolbar-bg) 0%, #1c3f63 100%);
    border-bottom: 2px solid var(--rp-accent);
}
.rp-toolbar-inner {
    min-height: 48px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.rp-toolbar-actions {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rp-toolbar-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 14px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.32);
    color: #f8fbff;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.rp-toolbar-link[type="button"] {
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.rp-toolbar-link:hover {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.6);
}
.rp-toolbar-link-danger {
    border-color: rgba(255, 176, 176, 0.45);
    color: #ffd8d8;
}
.rp-toolbar-link-danger:hover {
    background: rgba(185, 56, 56, 0.28);
    border-color: rgba(255, 176, 176, 0.72);
}
.rp-toolbar-link:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}
.rp-cache-toggle svg {
    display: block;
}
.rp-cache-toggle-off {
    opacity: 0.4;
}
.rp-cache-toggle-off svg {
    filter: grayscale(1);
}

/* Layout */
:root { --rp-footer-height: 36px; }
.rp-main { height: calc(100vh - var(--rp-header-height) - var(--rp-footer-height)); }
.rp-header-has-toolbar + .rp-main {
    height: calc(100vh - var(--rp-header-height-with-toolbar) - var(--rp-footer-height));
}
.rp-layout {
    display: flex;
    height: 100%;
    gap: 12px;
    padding: 12px;
}
.rp-sidebar {
    position: relative;
    width: min(40vw, 780px);
    min-width: 320px;
    max-width: 78vw;
    background: var(--rp-sidebar-bg);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    box-shadow: 0 2px 7px rgba(19, 42, 66, 0.08);
    overflow-y: auto;
    padding: 18px;
    resize: horizontal;
}
.rp-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    background: #ffffff;
    box-shadow: 0 2px 7px rgba(19, 42, 66, 0.08);
}

/* About */
.rp-about {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--rp-radius);
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--rp-text-muted);
}

/* Form */
.rp-form { display: flex; flex-direction: column; gap: 6px; }

/* Widgets — base */
.rp-widget {
    padding: 6px 0;
}
.rp-widget.rp-disabled {
    opacity: 0.4;
    pointer-events: none;
}
.rp-widget[hidden] { display: none !important; }

/* Leaf input widgets: grid with label left, input right */
.rp-number,
.rp-integer,
.rp-string:not(.rp-string-multiline),
.rp-choice,
.rp-boolean {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: center;
    gap: 4px 8px;
}
/* Label in column 1 */
.rp-number > .rp-label,
.rp-integer > .rp-label,
.rp-string:not(.rp-string-multiline) > .rp-label,
.rp-choice > .rp-label {
    grid-column: 1;
    white-space: normal;
    word-break: break-word;
    align-self: center;
}
/* Input / controls in column 2 */
.rp-number > .rp-input,
.rp-number > .rp-number-controls,
.rp-integer > .rp-input,
.rp-string:not(.rp-string-multiline) > .rp-input,
.rp-choice > .rp-input {
    grid-column: 2;
    width: 100%;
    min-width: 0;
}
/* Hints and color bar in column 2 */
.rp-number > .rp-hints,
.rp-number > .rp-color-bar,
.rp-integer > .rp-hints,
.rp-integer > .rp-color-bar,
.rp-string:not(.rp-string-multiline) > .rp-hints,
.rp-choice > .rp-hints {
    grid-column: 2;
}
/* sr-only hidden from layout */
.rp-number > .rp-sr-only,
.rp-integer > .rp-sr-only,
.rp-string > .rp-sr-only,
.rp-choice > .rp-sr-only {
    display: none;
}

/* Boolean: label wraps the checkbox — single flex row */
.rp-boolean {
    display: flex;
    align-items: center;
    grid-template-columns: unset;
}
.rp-boolean > .rp-label {
    width: auto;
    flex: none;
}

/* Column-layout widgets */
.rp-string-multiline,
.rp-multichoice,
.rp-image,
.rp-loader {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

/* Container widgets: block layout, no grid */
.rp-group,
.rp-group-tabbed,
.rp-structure-input {
    display: block !important;
    padding: 0;
}

.rp-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--rp-text);
    cursor: help;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 4px;
    line-height: 1.4;
}
.rp-label > .rp-units {
    white-space: nowrap;
    flex-shrink: 0;
}
.rp-widget-icon {
    width: 16px;
    height: 22px;
    flex-shrink: 0;
    object-fit: contain;
    vertical-align: middle;
}
.rp-therm-icon {
    width: 12px;
    height: 22px;
}
.rp-units {
    font-weight: 400;
    color: var(--rp-text-muted);
    font-size: 12px;
}
.rp-hints {
    font-size: 12px;
    color: var(--rp-text-muted);
}

/* Inputs */
.rp-input {
    padding: 4px 8px;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    font-size: 13px;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
}
.rp-input:focus {
    outline: none;
    border-color: var(--rp-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.rp-input-number, .rp-input-integer {
    width: 100%;
    font-variant-numeric: tabular-nums;
}
.rp-input-string, .rp-input-textarea {
    width: 100%;
}
.rp-input-textarea {
    resize: vertical;
    font-family: "SF Mono", Monaco, "Cascadia Mono", monospace;
    font-size: 13px;
}
.rp-input-choice {
    width: 100%;
}

/* Number with presets */
.rp-number-controls {
    display: flex;
    gap: 6px;
    width: 100%;
    min-width: 0;
}
.rp-number-controls .rp-input-number {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}
.rp-preset-select {
    padding: 6px 8px;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    font-size: 12px;
    background: white;
    cursor: pointer;
    max-width: 160px;
}

/* UQ distribution controls */
.rp-uq-dist-select {
    padding: 4px 6px;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    font-size: 11px;
    background: #f0f4ff;
    cursor: pointer;
    color: #3355aa;
    min-width: 80px;
}
.rp-uq-dist-params {
    margin-top: 4px;
    padding: 6px 8px;
    background: #f7f9ff;
    border: 1px solid #d0d8f0;
    border-radius: var(--rp-radius);
    grid-column: 1 / -1;
}
.rp-uq-uniform,
.rp-uq-gaussian {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.rp-uq-param-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #555;
}
.rp-uq-input {
    width: 80px !important;
    padding: 3px 5px !important;
    font-size: 12px !important;
}
.rp-uq-preview {
    border-radius: 4px;
    border: 1px solid #d0d8f0;
    background: #f8fafc;
}

/* Boolean */
.rp-boolean-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.rp-input-boolean {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Group visual styles */
.rp-group {
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    padding: 12px !important;
    background: #fbfdff;
}
.rp-group-legend {
    font-weight: 600;
    font-size: 13px;
    padding: 0 6px;
    color: var(--rp-text);
}
.rp-group-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rp-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
}
.rp-horizontal > .rp-widget {
    flex: 1;
    min-width: 120px;
}
.rp-horizontal > .rp-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Tabs */
.rp-group-tabbed {
    border: 1px solid var(--rp-border, #cbd5e1);
    border-radius: 8px;
    padding: 0;
    margin-bottom: 4px;
}
.rp-group-tabbed > .rp-group-header {
    font-weight: 600;
    font-size: 13px;
    padding: 8px 10px 4px;
    color: var(--rp-text);
}
.rp-group-tabbed > .rp-tabs > .rp-tab-buttons {
    padding: 6px 6px 0 6px;
    background: var(--rp-surface, #f8fafc);
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid var(--rp-border);
}
.rp-group-tabbed > .rp-tabs > .rp-tab-panel.active {
    padding: 8px 10px 10px;
}
.rp-tab-buttons {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--rp-border);
    flex-wrap: wrap;
}
.rp-tab-btn {
    min-height: 32px;
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: 6px 6px 0 0;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--rp-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.rp-tab-btn:hover { color: var(--rp-text); background: #e8f0f8; }
.rp-tab-btn.active, .rp-tab-btn[aria-selected="true"] {
    color: var(--rp-primary);
    border-bottom-color: var(--rp-primary);
    border-color: var(--rp-border);
    background: #fff;
}
.rp-tab-btn:focus-visible { outline-offset: 1px; }
.rp-tab-panel {
    display: none;
}
.rp-tab-panel.active { display: flex; flex-direction: column; gap: 10px; }

/* multichoice fieldset reset */
.rp-multichoice-fieldset { border: none; padding: 0; min-inline-size: 0; }

/* Phase */
.rp-phase {
    border-left: 3px solid var(--rp-primary);
    padding-left: 12px;
}
.rp-phase-header {
    font-weight: 600;
    color: var(--rp-primary);
    margin-bottom: 8px;
}

/* Phase tab strip row (tabs + inline simulate button) */
.rp-phase-tabs-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}
.rp-phase-tabs-row .rp-phase-tabs {
    flex: 1 1 auto;
    margin-bottom: 0;
}
.rp-phase-tabs-row > .rp-btn-simulate {
    flex-shrink: 0;
    margin-bottom: 0;
    align-self: flex-end;
}

/* Phase tab strip (top-level phases) */
.rp-phase-tabs {
    display: flex;
    border-bottom: 2px solid var(--rp-border);
    margin-bottom: 12px;
    gap: 2px;
    flex-wrap: wrap;
}
.rp-phase-tab {
    min-height: 36px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    background: transparent;
    color: var(--rp-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.rp-phase-tab:hover {
    background: #edf3fa;
    color: var(--rp-text);
}
.rp-phase-tab-active {
    background: var(--rp-sidebar-bg);
    color: var(--rp-primary);
    border-color: var(--rp-border);
    margin-bottom: -2px;
    padding-bottom: 8px;
}
.rp-phase-tab:focus-visible { outline-offset: 1px; }
.rp-phase-panel {
    animation: fadeIn 0.15s ease;
}

/* Top-level groups container (tab strip + panels + non-group siblings) */
.rp-top-groups-container {
    border: 1px solid var(--rp-border, #cbd5e1);
    border-radius: 8px;
    padding: 0;
    margin: 0 0 8px 0;
    min-width: 0;
}
.rp-top-groups-container .rp-phase-tabs {
    border-bottom: 2px solid var(--rp-border, #cbd5e1);
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
    padding: 6px 6px 0 6px;
    background: var(--rp-surface, #f8fafc);
}
.rp-top-groups-container .rp-phase-panel,
.rp-top-groups-container .rp-phase-content {
    padding: 8px 10px;
}
.rp-top-groups-container > .rp-widget {
    padding: 6px 10px 8px 10px;
    border-top: 1px solid var(--rp-border, #cbd5e1);
}

/* Separator */
.rp-separator {
    border: none;
    border-top: 1px solid var(--rp-border);
    margin: 8px 0;
}

/* Actions */
.rp-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--rp-border);
}
.rp-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--rp-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.rp-btn-simulate {
    background: var(--rp-primary);
    color: white;
    min-height: 36px;
}
.rp-btn-simulate:hover { background: var(--rp-primary-hover); }
.rp-btn-simulate:disabled {
    background: var(--rp-text-muted);
    cursor: not-allowed;
}
.rp-btn-simulate.running {
    background: var(--rp-text-muted);
}
.rp-btn-upload {
    background: #f1f5f9;
    color: var(--rp-text);
    border: 1px solid var(--rp-border);
    min-height: 36px;
}
.rp-btn-upload:hover { background: #e2e8f0; }
.rp-status {
    font-size: 13px;
    color: var(--rp-text-muted);
    font-weight: 600;
}
.rp-status.error { color: var(--rp-error); text-decoration: underline dotted; }
.rp-status.success { color: var(--rp-success); }

/* Footer status bar */
.rp-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--rp-footer-height);
    background: var(--rp-surface, #f8fafc);
    border-top: 1px solid var(--rp-border, #e2e8f0);
    display: flex;
    align-items: center;
    padding: 0 18px;
    z-index: 1000;
    gap: 10px;
}
.rp-footer[hidden] { display: none; }
.rp-footer-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--rp-text-muted);
}
.rp-footer-status.error { color: var(--rp-error); }
.rp-footer-status.success { color: var(--rp-success); }
.rp-footer-sep {
    flex: 1;
}
.rp-footer-stats {
    font-size: 12px;
    color: var(--rp-text-muted);
    opacity: 0.8;
}

/* Disable inputs while running */
.rp-form.rp-running .rp-top-groups-container,
.rp-form.rp-running .rp-widget:not(.rp-actions) {
    pointer-events: none;
    opacity: 0.75;
    user-select: none;
}

/* Results */
.rp-results { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rp-results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--rp-text-muted);
    font-size: 15px;
    gap: 16px;
    padding: 32px;
    text-align: center;
}
.rp-results-about {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.7;
    color: var(--rp-text);
    background: var(--rp-surface, #f8fafc);
    border: 1px solid var(--rp-border, #cbd5e1);
    border-radius: 8px;
    padding: 16px 20px;
    white-space: pre-wrap;
    text-align: left;
    overflow: auto;
}
.rp-results-warn {
    flex-direction: column;
    text-align: center;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--rp-radius);
    padding: 24px;
    margin: 16px;
}

/* Output selector bar */
.rp-output-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--rp-border);
    background: var(--rp-bg-secondary);
    flex-shrink: 0;
}
.rp-output-selector {
    flex: 1;
    max-width: 420px;
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    background: var(--rp-bg);
    color: var(--rp-text);
    cursor: pointer;
    outline-offset: 2px;
}
.rp-output-selector:focus-visible {
    outline: 3px solid var(--rp-primary);
}
.rp-output-panels { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.rp-output-panel { display: none; padding: 16px; box-sizing: border-box; overflow: hidden; }
.rp-output-panel.active { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Output items */
.rp-output-item {
    margin-bottom: 20px;
    background: white;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    overflow: auto;
}
.rp-output-item.rp-output-plot-item {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.rp-output-item.rp-output-plot-item .rp-output-body {
    flex: 1;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}
.rp-output-header {
    padding: 10px 14px;
    background: #f1f5f9;
    border-bottom: 1px solid var(--rp-border);
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.rp-output-header-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rp-fullscreen-btn {
    flex-shrink: 0;
    margin-left: 8px;
    background: #ffffff;
    border: 1px solid var(--rp-border);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    color: #1f2937;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.2px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.rp-fullscreen-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.rp-fullscreen-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Fullscreen state */
.rp-output-item.rp-output-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.rp-output-item.rp-output-fullscreen .rp-output-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.rp-output-item.rp-output-fullscreen .rp-output-header {
    justify-content: flex-start;
    gap: 12px;
}
.rp-output-item.rp-output-fullscreen .rp-output-header-label {
    display: none;
}
.rp-fs-toolbar {
    display: none;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.rp-fs-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}
.rp-fs-controls .rp-output-selector {
    max-width: 360px;
}
.rp-fs-runmenu {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.rp-fs-runbtn {
    background: #ffffff;
    border: 1px solid var(--rp-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}
.rp-fs-runbtn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.rp-fs-runmenu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    max-width: 320px;
    max-height: 200px;
    overflow: auto;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid var(--rp-border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    display: none;
    z-index: 2;
}
.rp-fs-runmenu-panel.open { display: flex; flex-direction: column; gap: 6px; }
.rp-fs-runmenu-disabled { opacity: 0.6; }
.rp-fs-runitem {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--rp-text);
    white-space: nowrap;
}
.rp-fs-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--rp-text-muted, #64748b);
}
.rp-fs-label span { font-weight: 600; }
.rp-fs-actions {
    margin-left: auto;
}
.rp-output-item.rp-output-fullscreen .rp-fs-toolbar {
    display: flex;
}
.rp-output-body {
    padding: 14px;
}

/* Output: number */
.rp-output-number .rp-output-value {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.rp-output-number .rp-output-units {
    font-size: 16px;
    color: var(--rp-text-muted);
    margin-left: 4px;
}

/* Output: string/log */
.rp-output-log,
.rp-output-string {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}
.rp-output-log .rp-output-body {
    flex: 1;
    min-height: 0;
    font-family: "SF Mono", Monaco, "Cascadia Mono", monospace;
    font-size: 13px;
    white-space: pre-wrap;
    overflow-y: auto;
    background: #1e293b;
    color: #e2e8f0;
    padding: 14px;
}
.rp-output-string .rp-output-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Output: image */
.rp-output-image img {
    max-width: 100%;
    height: auto;
}

/* Output: curve/histogram (Plotly container) */
.rp-output-plot {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Output: 3D field */
.rp-output-field { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rp-output-field .rp-output-body { flex: 1; min-height: 0; padding: 0; overflow: hidden; border-radius: 0 0 var(--rp-radius) var(--rp-radius); display: flex; flex-direction: column; }
.rp-3d-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.rp-3d-inner-row { flex: 1; min-height: 0; display: flex; flex-direction: row; align-items: stretch; }
.rp-3d-canvas-wrap { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.rp-3d-canvas-wrap canvas { display: block; width: 100% !important; flex: 1; min-height: 0; cursor: grab; }
.rp-3d-canvas-wrap canvas:active { cursor: grabbing; }

/* Right-side collapsible control panel */
.rp-3d-panel-wrap {
    display: flex; flex-direction: row; flex-shrink: 0;
    align-self: stretch; min-height: 0;
    position: relative;
}
.rp-3d-panel-tab {
    width: 20px; flex-shrink: 0; cursor: pointer;
    background: #475569;
    border-left: 2px solid #94a3b8; border-right: 2px solid #94a3b8;
    display: flex; align-items: center; justify-content: center;
    color: #f1f5f9; font-size: 14px; font-weight: bold; user-select: none;
    transition: background 0.15s, color 0.15s;
    box-shadow: -2px 0 6px rgba(0,0,0,0.35);
}
.rp-3d-panel-tab:hover { background: #64748b; color: #fff; }
.rp-3d-panel {
    width: 240px; flex-shrink: 0; overflow-y: auto;
    background: #1e293b; border-left: 1px solid #334155;
    padding: 8px; display: flex; flex-direction: column; gap: 6px;
    font-size: 12px; align-self: stretch;
    transition: width 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
}
.rp-3d-panel-wrap.collapsed .rp-3d-panel {
    width: 0; padding: 0; opacity: 0; overflow: hidden; border: none;
}
.rp-3d-panel-tab .rp-tab-chevron { transition: transform 0.2s; }
.rp-3d-panel-wrap.collapsed .rp-tab-chevron { transform: rotate(180deg); }
.rp-panel-section {
    background: #0f172a; border-radius: 4px; padding: 8px;
    display: flex; flex-direction: column; gap: 4px;
}
.rp-panel-title {
    font-size: 12px; font-weight: 700; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px;
}
.rp-panel-btns { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 2px; }
.rp-panel-section label {
    display: flex; flex-direction: column; gap: 2px;
    color: #94a3b8; font-size: 12px;
}
.rp-panel-section input[type=range] { width: 100%; cursor: pointer; }
.rp-panel-section input[type=number] {
    width: 100%; padding: 2px 4px; font-size: 12px;
    background: #1e293b; color: #e2e8f0;
    border: 1px solid #334155; border-radius: 3px;
}

/* Legacy toolbar styles kept for any remaining uses */
.rp-3d-toolbar {
    display: flex; flex-direction: column; gap: 0;
    background: var(--rp-bg-secondary);
    border-top: 1px solid var(--rp-border); font-size: 12px;
}
.rp-3d-toolbar-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 5px 10px; border-bottom: 1px solid var(--rp-border);
}
.rp-3d-toolbar-row:last-child { border-bottom: none; }
.rp-3d-toolbar label { color: var(--rp-text-muted); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.rp-3d-toolbar input[type=range] { width: 80px; cursor: pointer; vertical-align: middle; }
.rp-3d-toolbar input[type=number] {
    width: 72px; padding: 2px 4px; font-size: 12px;
    background: var(--rp-bg); color: var(--rp-text);
    border: 1px solid var(--rp-border); border-radius: 3px;
}
.rp-3d-btn {
    padding: 3px 8px; border: 1px solid var(--rp-border); border-radius: 4px;
    background: var(--rp-bg); color: var(--rp-text); cursor: pointer; font-size: 12px;
    white-space: nowrap;
}
.rp-3d-btn:hover { background: var(--rp-primary); color: #fff; border-color: var(--rp-primary); }
.rp-3d-btn.active { background: var(--rp-primary); color: #fff; border-color: var(--rp-primary); }
.rp-3d-sep { color: var(--rp-border); user-select: none; padding: 0 2px; }
.rp-3d-colorbar {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px; font-size: 12px; color: var(--rp-text-muted);
    background: var(--rp-bg-secondary);
}
.rp-3d-colorbar-gradient {
    flex: 1; height: 10px; border-radius: 3px;
    background: linear-gradient(to right,#00008b,#0000ff,#00ffff,#00ff00,#ffff00,#ff0000);
}

/* Loader */
.rp-loader-controls { display: flex; flex-direction: column; gap: 4px; }
.rp-input-file {
    padding: 6px;
    border: 1px dashed var(--rp-border);
    border-radius: var(--rp-radius);
}

/* Note */
.rp-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--rp-radius);
    padding: 10px 12px;
    overflow: hidden;
}
.rp-note img { max-width: 100%; height: auto; display: block; }
.rp-note-label { font-weight: 600; margin-bottom: 4px; }
.rp-note-text { font-size: 13px; color: var(--rp-text-muted); }

/* Multichoice */
.rp-multichoice-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rp-multichoice-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* Image display */
.rp-image-display img {
    max-width: 100%;
    border-radius: var(--rp-radius);
}

/* Run history */
.rp-run-history-panel {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--rp-border);
}
.rp-run-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rp-text-muted);
    margin-bottom: 8px;
}
.rp-run-select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.rp-run-history {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.rp-run-empty {
    font-size: 13px;
    color: var(--rp-text-muted);
}

/* Run row */
.rp-run-row {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 5px;
    border-radius: var(--rp-radius);
    border: 1px solid transparent;
    transition: background 0.1s;
    cursor: grab;
}
.rp-run-row:hover { background: #f1f5f9; }
.rp-run-row.rp-run-top {
    background: #eff6ff;
    border-color: #bfdbfe;
    box-shadow: inset 0 0 0 1px rgba(26, 58, 92, 0.18);
}
.rp-run-row.rp-run-dragging { opacity: 0.4; }
.rp-run-row.rp-run-drag-over { outline: 2px dashed var(--rp-primary); }

.rp-run-check { cursor: pointer; flex-shrink: 0; }

/* Color swatch */
.rp-color-wrap {
    position: relative;
    flex-shrink: 0;
}
.rp-run-color {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 2px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    cursor: pointer;
    display: block;
}
.rp-run-color:hover { border-color: var(--rp-primary); }

.rp-color-popup {
    position: absolute;
    left: 0;
    top: 22px;
    z-index: 999;
    background: white;
    border: 1px solid var(--rp-border);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    width: 140px;
}
.rp-color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}
.rp-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}
.rp-color-dot:hover { transform: scale(1.2); }
.rp-color-dot.active { border-color: #1e293b; }
.rp-color-hex-row { display: flex; }
.rp-color-hex-input {
    width: 100%;
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid var(--rp-border);
    border-radius: 4px;
    font-family: monospace;
}

/* Up/down reorder buttons */
.rp-run-reorder-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: none;
    color: var(--rp-text-muted);
    font-size: 12px;
    cursor: pointer;
    line-height: 1.2;
    opacity: 0.5;
}
.rp-run-reorder-btn:hover:not(:disabled) { opacity: 1; color: var(--rp-primary); }
.rp-run-reorder-btn:disabled { opacity: 0.15; cursor: default; }

/* Run label */
.rp-run-label {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    padding: 2px 4px;
    border-radius: 3px;
}
.rp-run-label:hover { background: #e2e8f0; }
.rp-run-label-top {
    font-weight: 600;
    color: var(--rp-primary);
}
.rp-run-rename-input {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 2px 4px;
    border: 1px solid var(--rp-primary);
    border-radius: 3px;
    outline: none;
}

.rp-run-status {
    font-size: 12px;
    color: var(--rp-error);
    flex-shrink: 0;
}
.rp-run-upload-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 1px 4px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: default;
}
.rp-run-reload {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--rp-radius);
    color: var(--rp-text-muted);
    font-size: 13px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s;
}
.rp-run-reload:hover {
    background: #dbeafe;
    border-color: var(--rp-primary);
    color: var(--rp-primary);
}

.rp-run-delete {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--rp-radius);
    color: var(--rp-text-muted);
    font-size: 13px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s;
}
.rp-run-delete:hover {
    background: #fee2e2;
    border-color: var(--rp-error);
    color: var(--rp-error);
}

/* Responsive */
@media (max-width: 768px) {
    .rp-brand-bar { padding: 10px 12px; min-height: 68px; }
    .rp-nanohub-logo { height: 30px; padding-right: 10px; }
    .rp-title { font-size: 18px; }
    .rp-brand-platform { font-size: 10px; }
    .rp-toolbar-inner {
        padding: 6px 12px;
        justify-content: flex-start;
        min-height: 0;
    }
    .rp-toolbar-actions { flex-wrap: wrap; }
    .rp-toolbar-link {
        min-height: 36px;
        padding: 7px 12px;
    }
    .rp-main { height: calc(100vh - 68px); }
    .rp-header-has-toolbar + .rp-main { height: calc(100vh - 118px); }
    .rp-layout { flex-direction: column; }
    .rp-sidebar {
        width: 100%;
        max-width: none;
        max-height: 50vh;
        resize: none;
    }
    .rp-content { min-height: 42vh; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Periodic Element */
.rp-periodicelement .rp-pe-selected-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    padding: 5px 8px;
    border: 1px solid var(--rp-border);
    border-radius: 4px;
    background: var(--rp-sidebar-bg, #ffffff);
    user-select: none;
}
.rp-periodicelement .rp-pe-selected-row:hover {
    border-color: var(--rp-accent);
}
.rp-pe-arrow {
    margin-left: auto;
    color: var(--rp-text-muted);
    display: flex;
    align-items: center;
    transition: transform 0.15s;
}
.rp-pe-arrow.rp-pe-arrow-open {
    transform: rotate(180deg);
}
.rp-pe-table-wrap {
    border: 1px solid var(--rp-border);
    border-radius: 4px;
    padding: 6px;
    background: #f0f0f0;
    margin-bottom: 4px;
    overflow-x: auto;
}
.rp-pe-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #555;
    flex-shrink: 0;
    background: #444;
}
.rp-pe-selected-name {
    color: var(--rp-text);
}
.rp-pe-table {
    border-collapse: collapse;
    table-layout: fixed;
}
.rp-pe-cell {
    width: 24px;
    height: 22px;
    font-size: 9px;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.15);
    color: #111;
    font-weight: 600;
    user-select: none;
    transition: filter 0.1s, outline 0.1s;
}
.rp-pe-cell:hover:not(.rp-pe-disabled):not(.rp-pe-empty) {
    filter: brightness(1.15);
    outline: 2px solid #fff;
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}
.rp-pe-cell.rp-pe-selected {
    outline: 2px solid #fff;
    outline-offset: -2px;
    filter: brightness(1.2);
    z-index: 2;
    position: relative;
}
.rp-pe-cell.rp-pe-disabled {
    background: #ccc !important;
    cursor: default;
    color: #999;
    font-weight: 400;
}
.rp-pe-cell.rp-pe-empty {
    background: transparent !important;
    border-color: transparent;
    cursor: default;
}

/* Plain data table fallback */
.rp-data-table {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
}
.rp-data-table th {
    background: #1a1a2e;
    color: #8892b0;
    padding: 4px 10px;
    text-align: left;
    border-bottom: 1px solid #333;
    font-weight: 600;
}
.rp-data-table td {
    padding: 3px 10px;
    border-bottom: 1px solid #222;
    color: #8892b0;
}
.rp-data-table tbody tr:hover td {
    background: #0d1117;
}

/* Sequence slider controls */
.rp-seq-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    padding: 8px 14px;
}
.rp-seq-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rp-seq-btn {
    background: var(--rp-primary, #2563eb);
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
}
.rp-seq-btn:hover {
    background: var(--rp-primary-hover, #1d4ed8);
}
.rp-seq-locky-label {
    font-size: 0.8em;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}
.rp-seq-label {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: var(--rp-text, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rp-seq-slider-wrap {
    padding: 2px 0;
}
.rp-seq-slider {
    width: 100%;
    height: 6px;
    cursor: pointer;
    accent-color: var(--rp-primary, #2563eb);
}

/* ── Structure input widget ──────────────────────────────────────────────── */
.rp-structure-input {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px !important;
    border: 1px solid var(--rp-border, #cbd5e1);
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    background: var(--rp-surface, #f8fafc);
}
.rp-structure-input > .rp-label {
    font-weight: 600;
}
.rp-structure-parameters {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}
.rp-structure-parameters .rp-number,
.rp-structure-parameters .rp-integer,
.rp-structure-parameters .rp-string {
    grid-template-columns: 130px 1fr;
    padding: 3px 0;
}
.rp-structure-parameters .rp-widget > .rp-label {
    width: 130px;
}
.rp-structure-parameters .rp-input-number,
.rp-structure-parameters .rp-input-string {
    width: 100%;
    box-sizing: border-box;
}
.rp-drawing-preview {
    width: 100%;
    overflow: visible;
}
.rp-drawing-preview svg {
    width: 100%;
    max-width: 100%;
    display: block;
}

/* Init overlay */
#rp-init-overlay {
    position: absolute;
    inset: 0;
    background: var(--rp-bg, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.3s ease;
}
#rp-init-overlay.rp-init-overlay-hidden {
    opacity: 0;
    pointer-events: none;
}
.rp-init-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--rp-border, #ddd);
    border-top-color: var(--rp-accent, #1a73e8);
    border-radius: 50%;
    animation: rp-spin 0.8s linear infinite;
}
@keyframes rp-spin {
    to { transform: rotate(360deg); }
}
