@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ─── O'Bend Design System v1.9.2 ─────────────────────────────────────────── */
:root {
    --ob-font: 'Inter', sans-serif;
    --ob-body-size: 11px;
    --ob-title-weight: 600;

    /* Backgrounds */
    --ob-bg:      #1e1e1e;
    --ob-panel:   #2c2c2c;
    --ob-panel-2: #383838;
    --ob-hover:   #4a4a4a;

    /* Text */
    --ob-ink:   #ffffff;
    --ob-muted: #b3b3b3;

    /* Accents */
    --ob-blue:         #18a0fb;
    --ob-blue-hover:   #0d8de3;
    --ob-success:      #1bc47d;
    --ob-danger:       #f24822;
    --ob-accent:       #ff0055;   /* O'Displace brand */

    /* Borders */
    --ob-line:   #444444;
    --ob-line-2: #555555;

    /* Radii — nested rule: outer = inner + gap */
    --ob-radius-shell:   8px;   /* panel */
    --ob-radius-surface: 6px;   /* card inside panel  (gap ≈ 2px) */
    --ob-radius-control: 4px;   /* input/button inside card */

    /* Spacing */
    --ob-space: 8px;
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background-color: var(--ob-line-2);
    border-radius: 6px;
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--ob-muted); }

/* ─── Base ─────────────────────────────────────────────────────────────────── */
body {
    background: var(--ob-bg);
    color: var(--ob-ink);
    font-family: var(--ob-font);
    font-size: var(--ob-body-size);
    margin: 0;
    padding: 20px;
    display: flex;
    gap: 20px;
    height: 100vh;
    overflow: hidden;
}

/* ─── Layout: Left Panel ───────────────────────────────────────────────────── */
.controls {
    width: 400px;
    flex-shrink: 0;
    background: var(--ob-panel);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-shell);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ob-muted);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    padding: 4px 0;
    transition: color 0.15s;
    width: fit-content;
}
.back-btn:hover { color: var(--ob-ink); }
.back-btn svg { flex-shrink: 0; }

.panel-title {
    font-size: 14px;
    font-weight: var(--ob-title-weight);
    color: var(--ob-ink);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.panel-title .back-btn {
    padding: 0;
    color: var(--ob-muted);
    flex-shrink: 0;
}

/* ─── Layout: Viewport ─────────────────────────────────────────────────────── */
.viewport {
    flex: 1;
    background: #000;
    border-radius: var(--ob-radius-shell);
    border: 1px solid var(--ob-line);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

svg.canvas-svg { width: 100%; height: 100%; }

/* ─── Seed Row ──────────────────────────────────────────────────────────────── */
.seed-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--ob-panel-2);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-surface);
}

.seed-row label { flex-shrink: 0; }

.seed-row input[type="text"] {
    flex: 1;
    min-width: 0;
    background: var(--ob-bg);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-control);
    color: var(--ob-muted);
    font-family: monospace;
    font-size: 11px;
    padding: 4px 8px;
    height: 26px;
}

.seed-row .live-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    color: var(--ob-muted);
}

/* ─── Label typography (O'Bend standard) ──────────────────────────────────── */
label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ob-muted);
    user-select: none;
}

/* ─── Selects ───────────────────────────────────────────────────────────────── */
select {
    width: 100%;
    background: var(--ob-panel-2);
    color: var(--ob-ink);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-control);
    padding: 6px 28px 6px 8px;
    font-family: var(--ob-font);
    font-size: 11px;
    height: 28px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b3b3b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    transition: border-color 0.15s;
}
select:focus { border-color: var(--ob-line-2); }
select:hover { border-color: var(--ob-line-2); }

/* ─── Number + text inputs ──────────────────────────────────────────────────── */
input[type="text"],
input[type="number"] {
    background: var(--ob-panel-2);
    color: var(--ob-ink);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-control);
    padding: 4px 8px;
    height: 28px;
    font-family: var(--ob-font);
    font-size: 11px;
    outline: none;
    transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="number"]:focus { border-color: var(--ob-line-2); }

/* hide number spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ─── Range sliders (O'Gravity style) ──────────────────────────────────────── */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: transparent;
    outline: none;
    cursor: pointer;
    margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 999px;
    background: var(--slider-track-bg, #3a3a3a);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ececec;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: transform 0.1s, background 0.1s;
    margin-top: -2px;
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.03);
    background: #fff;
}

input[type="range"]::-moz-range-track {
    height: 8px;
    border-radius: 999px;
    border: none;
    background: var(--slider-track-bg, #3a3a3a);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    background: #ececec;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.03);
    background: #fff;
}

/* ─── Checkbox ──────────────────────────────────────────────────────────────── */
input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--ob-blue);
    cursor: pointer;
    flex-shrink: 0;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
button {
    height: 28px;
    padding: 0 12px;
    border: none;
    border-radius: var(--ob-radius-control);
    background: var(--ob-panel-2);
    color: var(--ob-ink);
    font-family: var(--ob-font);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}
button:hover { background: var(--ob-hover); }
button:active { opacity: 0.8; }

.btn-generate {
    background: var(--ob-panel-2);
    color: var(--ob-ink);
}
.btn-generate:hover { background: var(--ob-hover); }

.btn-export {
    background: var(--ob-blue);
    color: #fff;
}
.btn-export:hover { background: var(--ob-blue-hover); }

.btn-png {
    background: var(--ob-blue);
    color: #fff;
}
.btn-png:hover { background: var(--ob-blue-hover); }

.btn-reset {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
    font-size: 16px;
    background: var(--ob-panel-2);
}
.btn-reset:hover { background: var(--ob-hover); }

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ─── Control row (label + control) ────────────────────────────────────────── */
.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.row label { flex-shrink: 0; }

.row input[type="number"] { width: 58px; text-align: center; }
.row input[type="range"] { width: 55%; }

/* ─── Module cards ──────────────────────────────────────────────────────────── */
.module-group {
    background: var(--ob-panel-2);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-surface);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.module-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ob-ink);
    letter-spacing: 0.02em;
}

.module-title svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    opacity: 0.7;
    flex-shrink: 0;
}

/* ─── Select row with icon button ─────────────────────────────────────────── */
.select-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.select-row select { flex: 1; }

/* ─── Action buttons (2×2 grid, equal size) ────────────────────────────────── */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.actions-grid button { height: 32px; width: 100%; }

/* ─── PNG scale popup ───────────────────────────────────────────────────────── */
.png-popup {
    position: relative;
}

.png-popup-inner {
    background: var(--ob-panel);
    border: 1px solid var(--ob-line-2);
    border-radius: var(--ob-radius-shell);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.scale-group {
    display: flex;
    gap: 6px;
}

.scale-btn {
    flex: 1;
    height: 48px;
    padding: 0;
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-control);
    background: var(--ob-panel-2);
    color: var(--ob-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}

.scale-btn span {
    font-size: 9px;
    font-weight: 400;
    color: var(--ob-muted);
    opacity: 0.7;
}

.scale-btn:hover { background: var(--ob-hover); color: var(--ob-ink); border-color: var(--ob-line-2); }

.scale-btn.active {
    background: var(--ob-blue);
    color: #fff;
    border-color: var(--ob-blue);
}
.scale-btn.active span { color: rgba(255,255,255,0.75); opacity: 1; }

.btn-png-confirm { width: 100%; height: 32px; }

/* ─── Console panel ─────────────────────────────────────────────────────────── */
.console-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 2px;
}

.console-panel textarea {
    background: var(--ob-bg);
    color: #1bc47d;
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-control);
    font-family: monospace;
    font-size: 10px;
    padding: 6px 8px;
    height: 72px;
    resize: none;
    outline: none;
}

/* ─── Palette Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--ob-panel);
    border: 1px solid var(--ob-line-2);
    border-radius: var(--ob-radius-shell);
    padding: 20px;
    width: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ob-ink);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ob-line);
}

.color-slots {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.color-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--ob-panel-2);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-surface);
}

.color-slot input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--ob-radius-control);
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-slot .hex-input {
    flex: 1;
    font-family: monospace;
    text-transform: uppercase;
}

.modal-paste {
    background: var(--ob-panel-2);
    color: var(--ob-ink);
    border: 1px solid var(--ob-line);
    border-radius: var(--ob-radius-control);
    font-family: var(--ob-font);
    font-size: 11px;
    padding: 8px;
    height: 64px;
    resize: none;
    outline: none;
    width: 100%;
}

.modal-paste::placeholder { color: var(--ob-muted); }

.modal-actions {
    display: flex;
    gap: 8px;
}
.modal-actions button { flex: 1; height: 30px; }

/* ─── Segment / mode button group ──────────────────────────────────────────── */
.seg-group {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 2px 0 6px;
}

.seg-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ob-muted);
    font-family: var(--ob-font);
    font-size: 11px;
    padding: 3px 7px 4px;
    cursor: pointer;
    border-radius: var(--ob-radius-control) var(--ob-radius-control) 0 0;
    transition: color 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.seg-btn:hover { color: var(--ob-ink); }

.seg-btn.active {
    color: var(--ob-ink);
    font-weight: 600;
    border-bottom-color: var(--ob-blue);
}
