* {
            box-sizing: border-box;
            margin: 0;
            padding: 0
        }

        body {
            background: #1a1a22;
            font-family: system-ui, sans-serif;
            color: #e0e0e0;
            min-height: 100vh;
            display: flex;
            flex-direction: column
        }

        #topbar {
            background: #12121a;
            border-bottom: 1px solid #2a2a3a;
            padding: 9px 14px;
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            flex-shrink: 0
        }

        #topbar h2 {
            font-size: 14px;
            font-weight: 600;
            color: #d0d0f0;
            white-space: nowrap;
            margin-right: 4px
        }

        #topbar select,
        #topbar input[type=text] {
            font-size: 13px;
            padding: 4px 8px;
            border: 1px solid #3a3a5a;
            border-radius: 5px;
            background: #1e1e2e;
            color: #e0e0e0;
            height: 28px;
            outline: none
        }

        #topbar select:focus,
        #topbar input:focus {
            border-color: #7F77DD
        }

        #topbar label {
            font-size: 12px;
            color: #9090b0;
            white-space: nowrap
        }

        #renderBtn {
            padding: 4px 14px;
            font-size: 13px;
            font-weight: 500;
            background: #534AB7;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            height: 28px
        }

        #renderBtn:hover {
            background: #3C3489
        }

        #renderBtn:disabled {
            background: #333;
            color: #666;
            cursor: not-allowed
        }

        #pyStatus {
            font-size: 11px;
            color: #9090b0;
            padding: 3px 8px;
            background: #1e1e2e;
            border: 1px solid #3a3a5a;
            border-radius: 4px;
            white-space: nowrap
        }

        #densityVal {
            font-size: 12px;
            font-weight: 500;
            min-width: 28px;
            color: #d0d0f0
        }

        #main {
            display: grid;
            grid-template-columns: 320px 1fr;
            flex: 1;
            min-height: 0;
            overflow: hidden
        }

        #sidebar {
            background: #12121a;
            border-right: 1px solid #2a2a3a;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            overflow-y: auto
        }

        .plabel {
            font-size: 10px;
            font-weight: 500;
            color: #7070a0;
            text-transform: uppercase;
            letter-spacing: .05em;
            margin-bottom: 3px
        }

        #created {
            color: #7070a0;
            justify-content: center;
            text-align: center;
            display: flex;
            font-size: 13px;
        }

        .social-links {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 14px;
            padding: 6px 0 4px;
        }

        .social-links a {
            color: #5a5a7a;
            font-size: 16px;
            text-decoration: none;
            transition: color .18s, transform .18s;
            display: flex;
            align-items: center;
        }

        .social-links a:hover {
            color: #7F77DD;
            transform: translateY(-2px);
        }

        .website-link a {
            color: #5a5a7a;
            text-decoration: none;
            cursor: pointer;
            justify-content: center;
            text-align: center;
            display: flex;
        }

        #promptbar {
            font-size: 13px;
            /* font-style: italic; */
            color: #838383;
        }

        #csvUpload {
            display: none
        }

        #uploadArea {
            border: 1.5px dashed #3a3a5a;
            border-radius: 7px;
            padding: 12px 8px;
            text-align: center;
            cursor: pointer;
            font-size: 11px;
            color: #7070a0;
            transition: all .2s
        }

        #uploadArea:hover {
            border-color: #7F77DD;
            color: #9090d0
        }

        #uploadArea.loaded {
            border-color: #1D9E75;
            background: rgba(29, 158, 117, 0.1);
            color: #1D9E75
        }

        #statusBox {
            font-size: 11px;
            color: #9090b0;
            padding: 6px 8px;
            background: #1e1e2e;
            border-radius: 5px;
            border: 1px solid #2a2a3a;
            min-height: 30px;
            line-height: 1.5
        }

        #sampleDatasetSelect {
            width: 100%;
            background: #1e1e2e;
            color: #e0e0e0;
            border: 1px solid #3a3a5a;
            border-radius: 5px;
            height: 28px;
            font-size: 13px;
            outline: none;
            cursor: pointer;
        }

        #signalCanvas,
        #histCanvas {
            width: 100%;
            border-radius: 5px;
            background: #1e1e2e;
            border: 1px solid #2a2a3a;
            display: block
        }

        input[type=range] {
            width: 100%;
            accent-color: #7F77DD
        }

        #dataPreviewWrap {
            display: none;
            border: 1px solid #2a2a3a;
            border-radius: 5px;
            overflow: hidden;
        }

        #dataPreviewTable {
            width: 100%;
            max-height: 160px;
            overflow-y: auto;
            overflow-x: auto;
            display: block;
            background: #1e1e2e;
        }

        #dataPreviewTable table {
            width: 100%;
            border-collapse: collapse;
            font-size: 10px;
            font-family: monospace;
            white-space: nowrap;
        }

        #dataPreviewTable thead th {
            position: sticky;
            top: 0;
            background: #252535;
            color: #9090d0;
            font-weight: 600;
            padding: 4px 8px;
            text-align: left;
            border-bottom: 1px solid #3a3a5a;
            letter-spacing: .03em;
            z-index: 1;
        }

        #dataPreviewTable tbody tr:nth-child(even) {
            background: #1a1a28;
        }

        #dataPreviewTable tbody tr:hover {
            background: #2a2a40;
        }

        #dataPreviewTable tbody td {
            padding: 3px 8px;
            color: #b0b0cc;
            border-bottom: 1px solid #23233a;
            max-width: 90px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        #dataPreviewMeta {
            font-size: 9px;
            color: #5a5a7a;
            padding: 3px 8px 4px;
            background: #191926;
            border-top: 1px solid #2a2a3a;
        }

        #eqBox {
            font-size: 10px;
            color: #d0d0f0;
            font-family: monospace;
            line-height: 1;
            background: #1e1e2e;
            border-radius: 5px;
            padding: 3px 3px;
            border: 1px solid #2a2a3a;
            text-align: center
        }

        #eqMath {
            color: #c0c0e8;
            font-size: 15px
        }

        #hints {
            font-size: 10px;
            color: #606080;
            line-height: 1.7;
            margin-top: auto;
            padding-top: 4px
        }

        #canvasWrap {
            position: relative;
            flex: 1;
            background: #c1c1c1;
            overflow: hidden;
            min-height: 0
        }

        #artCanvas {
            display: block;
            width: 100%;
            height: 100%;
        }

        #rightCol {
            display: flex;
            flex-direction: column;
            flex: 1;
            min-height: 0;
            overflow: hidden
        }

        #colorbarWrap {
            position: absolute;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 3px
        }

        #colorbar {
            width: 30px;
            height: 500px;
            border-radius: 2px;
            border: 0.5px solid #3a3a5a
        }

        #cbMax,
        #cbMin {
            font-size: 13px;
            color: #9090b0
        }

        #artTitle {
            position: absolute;
            bottom: 8px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 11px;
            font-weight: 500;
            color: #ccc;
            background: rgba(0, 0, 0, 0.6);
            padding: 2px 10px;
            border-radius: 4px;
            white-space: nowrap
        }

        #progressOuter {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: transparent;
            z-index: 5
        }

        #canvasLoadingLabel {
            font-size: 15px !important;
        }

        #progressBar {
            height: 3px;
            background: #7F77DD;
            width: 0%;
            transition: width .08s
        }

        /* ── chart thumbnails ── */
        .chart-wrap {
            position: relative;
        }

        .chart-wrap .expand-hint {
            position: absolute;
            top: 4px;
            right: 5px;
            font-size: 9px;
            color: #4a4a6a;
            pointer-events: none;
            transition: color .15s;
        }

        .chart-wrap:hover .expand-hint {
            color: #9090cc;
        }

        #signalCanvas,
        #histCanvas {
            cursor: zoom-in;
            transition: border-color .15s;
        }

        #signalCanvas:hover,
        #histCanvas:hover {
            border-color: #7F77DD !important;
        }

        /* ── modal overlay ── */
        #chartModal {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 9999;
            background: rgba(6, 6, 12, .85);
            backdrop-filter: blur(5px);
        }

        #chartModal.open {
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #chartModalBox {
            background: #12121a;
            border: 1px solid #3a3a5a;
            border-radius: 10px;
            padding: 16px 18px 16px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-width: 88vw;
            max-height: 90vh;
            box-shadow: 0 10px 60px rgba(0, 0, 0, .8);
            margin: auto;
            align-items: center;
        }

        #chartModalHeader {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            flex-shrink: 0;
            width: 100%;
        }

        #chartModalTitle {
            font-size: 11px;
            font-weight: 600;
            color: #9090c0;
            text-transform: uppercase;
            letter-spacing: .06em;
        }

        #chartModalClose {
            background: #252535;
            border: 1px solid #3a3a5a;
            color: #b0b0c0;
            font-size: 15px;
            width: 28px;
            height: 28px;
            border-radius: 5px;
            cursor: pointer;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        #chartModalClose:hover {
            background: #7F77DD;
            color: #fff;
            border-color: #7F77DD;
        }

        #chartModalCanvas {
            border-radius: 6px;
            background: #1e1e2e;
            border: 1px solid #2a2a3a;
            display: block;
            max-width: 80vw;
            max-height: 62vh;
            flex-shrink: 0;
        }

        #chartModalTableWrap {
            display: none;
            background: #1e1e2e;
            border: 1px solid #2a2a3a;
            border-radius: 6px;
            overflow: auto;
            max-width: 88vw;
            max-height: 62vh;
            min-width: 420px;
            flex-shrink: 0;
        }

        #chartModalTableWrap table {
            border-collapse: collapse;
            font-size: 12px;
            font-family: monospace;
            white-space: nowrap;
            width: 100%;
        }

        #chartModalTableWrap thead th {
            position: sticky;
            top: 0;
            background: #252535;
            color: #9090d0;
            font-weight: 600;
            padding: 7px 14px;
            text-align: left;
            border-bottom: 1px solid #3a3a5a;
            letter-spacing: .03em;
            z-index: 1;
        }

        #chartModalTableWrap tbody tr:nth-child(even) {
            background: #1a1a28;
        }

        #chartModalTableWrap tbody tr:hover {
            background: #2a2a40;
        }

        #chartModalTableWrap tbody td {
            padding: 5px 14px;
            color: #b0b0cc;
            border-bottom: 1px solid #23233a;
        }

        #chartModalTableWrap tbody td.num {
            color: #a0c8a0;
        }

        #chartModalFooter {
            flex-shrink: 0;
            border-top: 1px solid #2a2a3a;
            padding-top: 10px;
            display: flex;
            flex-direction: column;
            gap: 6px;
            width: 100%;
        }

        #chartModalMeta {
            font-size: 11px;
            color: #5a5a7a;
        }

        #chartModalDesc {
            font-size: 13px;
            color: #9898bb;
            line-height: 1.65;
            background: #1a1a28;
            border: 1px solid #2a2a3a;
            border-radius: 6px;
            padding: 11px 14px;
        }

        #chartModalDesc strong {
            color: #b0b0d8;
            font-weight: 600;
        }

        /* ── python loading overlay on canvas ── */
        #canvasLoadingOverlay {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 16px;
            background: rgba(13, 13, 18, 0.82);
            z-index: 10;
            pointer-events: none;
        }

        #canvasLoadingOverlay.hidden {
            display: none;
        }

        #canvasLoadingLabel {
            font-size: 18px;
            font-weight: 600;
            color: #58586b;
            letter-spacing: .03em;
            justify-content: center;
            text-align: center;
            display: flex;
            font-style: bold;
        }

        #canvasLoadingBarTrack {
            width: 180px;
            height: 3px;
            background: #2a2a3a;
            border-radius: 2px;
            overflow: hidden;
        }

        #canvasLoadingBarFill {
            height: 3px;
            width: 0%;
            background: #7F77DD;
            border-radius: 2px;
            animation: pyLoadPulse 1.6s ease-in-out infinite;
        }

        @keyframes pyLoadPulse {
            0% {
                width: 0%;
                margin-left: 0%;
            }

            50% {
                width: 60%;
                margin-left: 20%;
            }

            100% {
                width: 0%;
                margin-left: 100%;
            }
        }

        /* ── zoom cursor ── */
        #canvasWrap {
            cursor: crosshair;
        }

        #canvasWrap.panning {
            cursor: grabbing;
        }

        /* ── zoom indicator ── */
        #zoomIndicator {
            position: absolute;
            bottom: 32px;
            left: 12px;
            font-size: 11px;
            font-weight: 600;
            color: #c0c0e0;
            background: rgba(12, 12, 20, 0.80);
            padding: 3px 9px;
            border-radius: 4px;
            pointer-events: none;
            opacity: 0;
            transition: opacity .35s;
            z-index: 20;
        }

        #zoomIndicator.show {
            opacity: 1;
        }

        #zoomResetBtn {
            position: absolute;
            bottom: 32px;
            left: 12px;
            font-size: 11px;
            font-weight: 500;
            color: #9090b0;
            background: rgba(12, 12, 20, 0.80);
            border: 1px solid #3a3a5a;
            padding: 3px 9px;
            border-radius: 4px;
            cursor: pointer;
            display: none;
            z-index: 20;
            transition: background .15s, color .15s;
        }

        #zoomResetBtn:hover {
            background: rgba(83, 74, 183, 0.85);
            color: #fff;
            border-color: #7F77DD;
        }

        /* ── export button ── */
        #exportWrap {
            position: absolute;
            top: 10px;
            right: 60px;
            z-index: 20;
            display: none;
        }

        #exportWrap.visible {
            display: block;
        }

        #exportBtn {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 5px 11px;
            font-size: 12px;
            font-weight: 500;
            background: rgba(18, 18, 26, 0.88);
            color: #c0c0e0;
            border: 1px solid #3a3a5a;
            border-radius: 6px;
            cursor: pointer;
            white-space: nowrap;
            backdrop-filter: blur(4px);
            transition: background .15s, border-color .15s;
        }

        #exportBtn:hover {
            background: rgba(83, 74, 183, 0.85);
            border-color: #7F77DD;
            color: #fff;
        }

        #exportDropdown {
            display: none;
            position: absolute;
            top: calc(100% + 5px);
            right: 0;
            background: #12121a;
            border: 1px solid #3a3a5a;
            border-radius: 7px;
            overflow: hidden;
            box-shadow: 0 6px 24px rgba(0, 0, 0, .7);
            min-width: 160px;
        }

        #exportDropdown.open {
            display: block;
        }

        .export-option {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 9px 14px;
            font-size: 12px;
            color: #b0b0cc;
            cursor: pointer;
            transition: background .12s, color .12s;
            white-space: nowrap;
        }

        .export-option:hover {
            background: #252535;
            color: #fff;
        }

        .export-option .ext-badge {
            font-size: 10px;
            font-weight: 700;
            letter-spacing: .04em;
            padding: 1px 5px;
            border-radius: 3px;
            background: #1e1e30;
            color: #7F77DD;
        }