/* ══════════════════════════════════════════════════════
   Fractal Explorer — Razzlestack Edition
   Dark space theme, auto-fade chrome, responsive layout
   ══════════════════════════════════════════════════════ */

:root {
    --bj-bg:       #0a0c10;
    --bj-surface:  #12161e;
    --bj-border:   #2a3040;
    --bj-text:     #c8d0e0;
    --bj-muted:    #5a6478;
    --bj-accent:   #4f9cf9;
    --bj-chrome:   rgba(255,255,255,0.85);
    --bj-btn-bg:   rgba(15,20,30,0.75);
    --bj-btn-hover:rgba(30,40,60,0.92);
    --bj-radius:   8px;
    --sans:        system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --fade-time:   0.4s;
}

/* ── Reset ─────────────────────────────── */

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

[hidden] {
    display: none !important;
}

html, body {
    margin: 0; padding: 0;
    background: var(--bj-bg);
    color: var(--bj-text);
    font-family: var(--sans);
    font-size: 15px;
    min-height: 100dvh;
}

a { color: var(--bj-accent); }

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

/* Minimal local UI layer for the small framework subset this app uses. */
.container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-right: -4px;
    margin-left: -4px;
}

.col,
.col-auto,
.col-12,
.col-sm-6,
.col-sm-12,
.col-lg-3 {
    padding-right: 4px;
    padding-left: 4px;
}

.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-12 { flex: 0 0 auto; width: 100%; }
.col-sm-6 { flex: 0 0 auto; width: 50%; }
.col-sm-12 { flex: 0 0 auto; width: 100%; }
.col-lg-3 { flex: 0 0 auto; width: 50%; }

.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.d-none { display: none !important; }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.g-1 { gap: 0.25rem 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.375rem 0.75rem;
    min-height: 2rem;
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    min-height: 1.85rem;
    font-size: 0.875rem;
}

.btn-outline-secondary {
    color: var(--bj-text);
    background: transparent;
    border-color: var(--bj-border);
}

.btn-outline-secondary:hover,
.btn-outline-secondary.active {
    color: #fff;
    background: #222c3e;
    border-color: var(--bj-accent);
}

.btn-secondary {
    color: #fff;
    background: #3a4150;
    border-color: #3a4150;
}

.btn-outline-danger {
    color: #ff8a8a;
    background: transparent;
    border-color: #8a3434;
}

.btn-outline-danger:hover {
    color: #fff;
    background: #7f1d1d;
    border-color: #a33;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    min-height: 2rem;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    font: inherit;
}

.form-control-sm,
.form-select-sm {
    min-height: 1.85rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.form-label,
.col-form-label {
    display: inline-block;
    margin-bottom: 0.25rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
}

.form-check-input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--bj-accent);
}

.form-switch .form-check-input {
    width: 2rem;
}

.form-range {
    width: 100%;
    padding: 0;
}

.julia-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.dropdown {
    position: relative;
}

.dropdown-toggle::after {
    content: "";
    display: inline-block;
    margin-left: 0.4rem;
    border-top: 0.35em solid currentColor;
    border-right: 0.35em solid transparent;
    border-left: 0.35em solid transparent;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 300;
    display: none;
    min-width: 100%;
    max-height: min(60vh, 460px);
    overflow: auto;
    padding: 0.35rem;
    margin: 0;
    list-style: none;
    background: #101620;
    border: 1px solid var(--bj-border);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.35rem 0.45rem;
    color: var(--bj-text);
    border-radius: 4px;
    text-decoration: none;
}

.dropdown-item:hover,
.dropdown-item.active {
    color: #fff;
    background: rgba(79,156,249,0.18);
}

.collapse {
    display: none;
}

.collapse.show {
    display: block;
}

/* ── Razzlestack Chrome Buttons ───────────── */

.bj-chrome-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--bj-btn-bg);
    border: 1px solid var(--bj-border);
    border-radius: var(--bj-radius);
    color: var(--bj-chrome);
    cursor: pointer;
    text-decoration: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background var(--fade-time), color var(--fade-time);
}

.bj-chrome-btn:hover {
    background: var(--bj-btn-hover);
    color: #fff;
    border-color: var(--bj-accent);
}

/* ── Home Button (top-left) ─────────────  */

#bj-home {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    transition: opacity var(--fade-time), visibility var(--fade-time);
}

/* ── Top-right cluster ──────────────────  */

#bj-top-right {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
    display: flex;
    gap: 8px;
    transition: opacity var(--fade-time), visibility var(--fade-time);
}

/* ── Auto-fade ──────────────────────────  */

.bj-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ── Layout ─────────────────────────────  */

body {
    padding: 10px;
}

#main {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 0;
    padding-top: 60px; /* clear chrome buttons */
}

/* ── Canvas area ─────────────────────────  */

#mandelbrot {
    position: relative;
    width: 800px;
    height: 600px;
    flex-shrink: 0;
    border-radius: var(--bj-radius);
    overflow: hidden;
    box-shadow: 0 4px 40px rgba(0,0,0,0.7);
}

#mandelbrot-canvas {
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
    display: block;
}

#mandelbrot.travelling #mandelbrot-canvas {
    image-rendering: auto;
    will-change: transform;
    transition: filter 0.2s;
    filter: saturate(1.08) brightness(1.04);
}

#progress-canvas {
    position: absolute;
    top: 8px;
    left: 48px; /* clear home button in fullscreen */
    z-index: 1;
    border-radius: 4px;
}

/* Menu-toggle (close button shown in fullscreen) */
#menu-toggle {
    position: absolute;
    top: 0; left: 0;
    width: 32px; height: 32px;
    z-index: 3;
    border: none;
    padding: 5px;
    cursor: pointer;
    background-color: rgba(0,0,0,0.5);
    display: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.89 4.89a1 1 0 1 0 1.41 1.41L12 13.41l4.89 4.89a1 1 0 0 0 1.41-1.41L13.41 12l4.89-4.89a1 1 0 0 0 .01-1.4z"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: opacity var(--fade-time), visibility var(--fade-time);
}

#palette-canvas {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 20px;
    z-index: 1;
    border-radius: 0 0 var(--bj-radius) var(--bj-radius);
}

/* ── Settings panel ──────────────────────  */

#settings {
    margin: 0 0 0 20px;
    padding: 10px;
    min-width: 320px;
    max-width: 400px;
    background: var(--bj-surface);
    border: 1px solid var(--bj-border);
    border-radius: var(--bj-radius);
    transition: opacity var(--fade-time), visibility var(--fade-time);
}

#gallery-panel {
    margin: 12px -2px 6px;
    padding-top: 10px;
    border-top: 1px solid var(--bj-border);
}

.gallery-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 2px 8px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
}

.gallery-header small {
    color: var(--bj-muted);
    font-size: 0.75rem;
    font-weight: 400;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.gallery-tile {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 3px;
    width: 100%;
    padding: 6px;
    border: 1px solid var(--bj-border);
    border-radius: 6px;
    background: #0d121a;
    color: var(--bj-text);
    cursor: pointer;
    text-align: left;
    min-width: 0;
}

.gallery-tile:hover {
    border-color: var(--bj-accent);
    background: #151d2a;
}

.gallery-tile canvas {
    display: block;
    width: 100%;
    aspect-ratio: 5 / 3;
    height: auto;
    border-radius: 4px;
    background: #05070a;
}

.gallery-tile span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.78rem;
}

.gallery-tile small {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--bj-muted);
    font-size: 0.68rem;
}

/* Dark-mode label colour fix */
.form-label,
.col-form-label,
.form-check-label {
    color: var(--bj-text);
}

.form-control,
.form-range {
    background-color: #1a2030;
    border-color: var(--bj-border);
    color: var(--bj-text);
}

.form-control:focus {
    background-color: #1a2030;
    color: #fff;
    border-color: var(--bj-accent);
    box-shadow: 0 0 0 2px rgba(79,156,249,0.25);
}

/* ── Collapse/Info section ───────────────  */

.collapse-ruler button {
    height: 1.5rem;
    font-size: 75%;
    color: var(--bj-muted);
    padding: .25rem .5rem;
    background: transparent;
    border: 0;
    border-radius: .25rem;
    margin-top: 0.25rem;
    cursor: pointer;
}

.collapse-ruler button:hover {
    color: #fff;
    background-color: var(--bj-accent);
}

.collapse-ruler .col { padding-right: 0; }

hr { border-color: var(--bj-border); }

/* ── Footer ──────────────────────────────  */

footer {
    font-family: var(--sans);
    font-size: 80%;
    text-align: center;
    padding-top: 10px;
    color: var(--bj-muted);
}

footer a { color: var(--bj-muted); }
footer a:hover { color: var(--bj-accent); }

/* ── Debug textarea ──────────────────────  */

#debug {
    font-size: inherit;
    position: absolute;
    top: 30px; left: 5px;
    z-index: 1;
    background: rgba(0,0,0,0.7);
    color: #0f0;
    border: none;
}

/* ── Custom palette editor ───────────────  */

#custom-palette-colors { font-family: monospace; }

.custom-palette-row  { cursor: grab; }
.custom-palette-row.dragging { opacity: 0.5; }
.custom-palette-row.hidden-drag { display: none !important; }

.custom-palette-drag-handle {
    cursor: grab;
    user-select: none;
    background: #1a2030;
    border: 1px solid var(--bj-border);
    color: var(--bj-muted);
    min-width: 2em;
    text-align: center;
}

.custom-palette-color-input {
    width: 3em; min-width: 3em; max-width: 3em;
    padding: 0;
    border: 1px solid var(--bj-border);
}

.custom-palette-drop-indicator {
    height: 0;
    border-top: 2px solid var(--bj-accent);
    margin: 0 0.5em;
    pointer-events: none;
}

#custom-palette-preview {
    border-radius: 5px;
    height: 20px;
    width: 100%;
}

/* Palette actions in dropdown */
.palette-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.palette-action {
    background: transparent;
    border: none;
    padding: 2px 6px;
    color: inherit;
    cursor: pointer;
    font-size: 0.9em;
    line-height: 1;
}

.palette-action:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

.dropdown-item.flex-grow-1 {
    display: flex;
    align-items: center;
}

.form-select {
    background-color: #1a2030;
    border-color: var(--bj-border);
    color: var(--bj-text);
}

.form-select:focus {
    background-color: #1a2030;
    color: #fff;
    border-color: var(--bj-accent);
    box-shadow: 0 0 0 2px rgba(79,156,249,0.25);
}

/* ── Auto-cycle button active state ─────────────────  */

#cycle-toggle.active {
    background: var(--bj-accent);
    border-color: var(--bj-accent);
    color: #fff;
}

/* ══════════════════════════════════════════════════════
   v2 — Export Modal
   ══════════════════════════════════════════════════════ */

#export-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#export-modal {
    background: var(--bj-surface);
    border: 1px solid var(--bj-border);
    border-radius: 12px;
    padding: 32px 28px 24px;
    width: min(420px, 94vw);
    position: relative;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.7);
}

#export-modal h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 20px;
}

.exp-field {
    margin-bottom: 16px;
}

.exp-label {
    display: block;
    font-size: 0.85rem;
    color: var(--bj-muted);
    margin-bottom: 6px;
}

.exp-radios {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

#exp-presets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.exp-preset {
    min-height: 2.2rem;
    padding: 6px 8px;
    border: 1px solid var(--bj-border);
    border-radius: 6px;
    background: #1a2030;
    color: var(--bj-text);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.exp-preset:hover,
.exp-preset.active {
    color: #fff;
    border-color: var(--bj-accent);
    background: rgba(79,156,249,0.22);
}

.exp-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--bj-text);
    cursor: pointer;
}

.exp-radio small { color: var(--bj-muted); }

.exp-cycle-info {
    font-size: 0.9rem;
    color: var(--bj-text);
    padding: 4px 0;
}

.exp-cycle-info small { color: var(--bj-muted); }

.exp-select {
    background: #1a2030;
    border: 1px solid var(--bj-border);
    border-radius: 5px;
    color: var(--bj-text);
    padding: 6px 10px;
    font-size: 0.9rem;
    width: 100%;
}

/* Progress bar */
#exp-progress-wrap {
    margin: 16px 0;
}

#exp-progress-track {
    height: 6px;
    background: var(--bj-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

#exp-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--bj-accent);
    border-radius: 3px;
    transition: width 0.2s;
}

#exp-progress-text {
    font-size: 0.8rem;
    color: var(--bj-muted);
    margin: 0;
}

.exp-btns {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.exp-btns .donate-go-btn { flex: 1; }

.exp-cancel { background: #333 !important; }
.exp-cancel:hover { filter: brightness(1.3); }

/* ══════════════════════════════════════════════════════
   v2 — Hide UI mode
   ══════════════════════════════════════════════════════ */

/* Floating restore button — hidden by default, shown when UI is hidden */
#bj-show-btn {
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 500;
    display: none;
    padding: 8px 14px;
    background: rgba(20, 28, 44, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.15s, color 0.15s;
}

#bj-show-btn:hover { background: rgba(40, 55, 90, 0.95); color: #fff; }

/* When UI is hidden: canvas fills viewport, chrome disappears */
body.ui-hidden #bj-home,
body.ui-hidden #bj-top-right,
body.ui-hidden #settings {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.ui-hidden #mandelbrot {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    z-index: 10;
}

body.ui-hidden #bj-show-btn {
    display: block;
}

/* ── Donate Modal ────────────────────────  */

#donate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#donate-modal {
    background: var(--bj-surface);
    border: 1px solid var(--bj-border);
    border-radius: 12px;
    padding: 32px 28px 24px;
    width: min(380px, 92vw);
    position: relative;
    box-shadow: 0 8px 48px rgba(0,0,0,0.7);
    text-align: center;
}

#donate-modal h2 {
    font-size: 1.35rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 8px;
}

#donate-modal p {
    color: var(--bj-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.donate-close-btn {
    position: absolute;
    top: 12px; right: 14px;
    background: none;
    border: none;
    color: var(--bj-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
}

.donate-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

#donate-amounts {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

.donate-amount {
    flex: 1;
    padding: 9px 0;
    background: #1a2030;
    border: 1px solid var(--bj-border);
    border-radius: 6px;
    color: var(--bj-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.donate-amount:hover { background: #222c3e; border-color: var(--bj-accent); }
.donate-amount.active {
    background: var(--bj-accent);
    border-color: var(--bj-accent);
    color: #fff;
    font-weight: 600;
}

#donate-custom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    background: #1a2030;
    border: 1px solid var(--bj-border);
    border-radius: 6px;
    padding: 0 12px;
}

#donate-custom-row span { color: var(--bj-muted); font-size: 1rem; }

#donate-custom {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--bj-text);
    font-size: 0.95rem;
    padding: 10px 0;
    outline: none;
}

#donate-custom::placeholder { color: var(--bj-muted); }

.donate-go-btn {
    width: 100%;
    padding: 11px;
    background: var(--bj-accent);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
}

.donate-go-btn:hover { filter: brightness(1.15); }

/* ── Responsive ──────────────────────────  */

@media (max-width: 1200px) {
    :root { font-size: 5vw; }
    #main {
        flex-direction: column;
        align-items: center;
        padding-top: 56px;
    }
    #settings {
        min-width: 100%;
        max-width: min(800px, 100vw);
        margin: 12px 0 0;
        border-radius: var(--bj-radius);
    }
    #gallery-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    #mandelbrot {
        width: min(800px, 100vw);
        height: min(600px, 75svw);
        border-radius: 0;
    }
}

@media (max-width: 800px) {
    :root { font-size: clamp(12px, 4vw, 15px); }
    body { padding: 0; }
    #main { padding-top: 52px; }
    #mandelbrot { border-radius: 0; }
    #gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    #exp-presets {
        grid-template-columns: 1fr;
    }
}

/* ── Fullscreen ──────────────────────────  */

#main:fullscreen {
    position: relative;
    display: block;
    padding: 0;
    background: #000;
}

#mandelbrot.fullscreen {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    border-radius: 0;
    z-index: 0;
}

#settings.fullscreen {
    position: fixed;
    top: 56px;
    left: 8px;
    z-index: 100;
    border-radius: var(--bj-radius);
    max-width: min(380px, 80vw);
    background: rgba(10,12,16,0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity var(--fade-time), visibility var(--fade-time);
}

#footer.fullscreen { display: none; }

#menu-toggle.fullscreen { display: block; }

#menu-toggle.hidden.fullscreen,
#settings.hidden.fullscreen {
    visibility: hidden;
    opacity: 0;
}

/* ==========================================================================
   Refresh layer, 2026-10
   --------------------------------------------------------------------------
   Appended rather than woven into the rules above on purpose. The markup is a
   fork of bertbaron/mandelbrot with a lot of local additions, and every id and
   class in it is wired to index.js; the safe way to restyle it is to override
   from the end of the cascade and leave the existing rules where they are.

   Three things this fixes:
     - the app is a page that scrolls, when it should fill the window with the
       fractal and let only the controls scroll
     - the fractal is boxed into a corner with dead space around it
     - the controls are cramped and inconsistent with each other
   ========================================================================== */

:root {
    --bj-accent:      #5aa9ff;
    --bj-accent-soft: rgba(90, 169, 255, 0.16);
    --bj-surface-2:   #161b25;
    --bj-radius:      10px;
    --bj-radius-sm:   7px;
    --bj-gap:         0.65rem;
    --bj-shadow:      0 10px 30px -12px rgba(0, 0, 0, 0.8);
}

/* ---- the window is the app ---------------------------------------------- */

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

#main {
    height: 100dvh;
    padding: 56px 0 0;
    gap: 0;
    align-items: stretch;
}

/* The fractal takes whatever is left, which is most of it. */
#mandelbrot {
    flex: 1 1 auto;
    min-width: 0;
    /* The rule above sets an explicit 800x600. Width is taken care of by the
       flex grow, but the height has to be released by hand or the fractal sits
       in a 600px letterbox in the middle of a taller window. */
    height: auto;
    align-self: stretch;
    display: flex;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #000;
}

#mandelbrot-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Only the controls scroll, and they keep their own scrollbar to themselves. */
#settings {
    flex: 0 0 auto;
    width: clamp(300px, 26vw, 390px);
    max-width: none;
    margin: 0;
    padding: 0.9rem 0.95rem 1.4rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-left: 1px solid var(--bj-border);
    border-radius: 0;
    background: var(--bj-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--bj-border) transparent;
}

#settings::-webkit-scrollbar { width: 9px; }
#settings::-webkit-scrollbar-thumb {
    background: var(--bj-border);
    border-radius: 99px;
}

@media (max-width: 820px) {
    html, body { overflow: auto; }
    #main { height: auto; min-height: 100dvh; }
    #mandelbrot { aspect-ratio: 4 / 3; flex: 0 0 auto; width: 100%; }
    #settings {
        width: 100%;
        border-left: 0;
        border-top: 1px solid var(--bj-border);
        overflow: visible;
    }
}

/* ---- controls ------------------------------------------------------------ */

#settings .row { margin-bottom: var(--bj-gap); }

#settings .form-label,
#settings .col-form-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--bj-muted);
    margin-bottom: 0.25rem;
}

#settings .form-control,
#settings .form-select {
    background: var(--bj-surface-2);
    border: 1px solid var(--bj-border);
    border-radius: var(--bj-radius-sm);
    color: var(--bj-text);
    padding: 0.42rem 0.55rem;
    font-size: 0.86rem;
    width: 100%;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

#settings .form-control:focus-visible,
#settings .form-select:focus-visible,
#settings .btn:focus-visible {
    outline: none;
    border-color: var(--bj-accent);
    box-shadow: 0 0 0 3px var(--bj-accent-soft);
}

#settings .btn {
    background: var(--bj-surface-2);
    border: 1px solid var(--bj-border);
    border-radius: var(--bj-radius-sm);
    color: var(--bj-text);
    padding: 0.46rem 0.7rem;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background 120ms ease, border-color 120ms ease, transform 90ms ease;
}

#settings .btn:hover:not(:disabled) {
    background: #1d2432;
    border-color: #3a4457;
}

#settings .btn:active:not(:disabled) { transform: translateY(1px); }
#settings .btn:disabled { opacity: 0.42; }

/* Sliders read as one control rather than three different ones. */
#settings .form-range {
    width: 100%;
    accent-color: var(--bj-accent);
    height: 26px;
    background: transparent;
}

#settings .form-check-input {
    accent-color: var(--bj-accent);
    width: 1.05rem;
    height: 1.05rem;
}

#settings .form-check-label,
#settings .form-check-labels {
    font-size: 0.84rem;
    color: var(--bj-text);
}

/* ---- gallery ------------------------------------------------------------- */

.gallery-header {
    margin: 1.1rem 0 0.5rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--bj-border);
}

.gallery-tile {
    border-radius: var(--bj-radius-sm);
    overflow: hidden;
    border: 1px solid var(--bj-border);
    transition: border-color 140ms ease, transform 140ms ease;
}

.gallery-tile:hover {
    border-color: var(--bj-accent);
    transform: translateY(-2px);
}

/* ---- top chrome ---------------------------------------------------------- */

.bj-chrome-btn {
    border-radius: var(--bj-radius);
    border: 1px solid var(--bj-border);
    background: rgba(12, 15, 21, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 140ms ease, border-color 140ms ease;
}

.bj-chrome-btn:hover {
    background: rgba(28, 36, 50, 0.9);
    border-color: #3a4457;
}

/* ---- the floating panel in fullscreen ------------------------------------ */

#settings.fullscreen {
    border: 1px solid var(--bj-border);
    border-radius: var(--bj-radius);
    box-shadow: var(--bj-shadow);
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    background: rgba(10, 12, 16, 0.9);
}

@media (prefers-reduced-motion: reduce) {
    #settings .btn,
    .gallery-tile,
    .bj-chrome-btn { transition: none; }
}
