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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    color: #e0e0e0;
    -webkit-user-select: none;
    user-select: none;
}

/* ---------- Canvas ---------- */

#mandelbrot-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/* ---------- Error message ---------- */

#error-message {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    font-size: 1.25rem;
    text-align: center;
    background: #111;
    color: #f44;
    z-index: 100;
}

/* ---------- Dashboard ---------- */

.dashboard {
    position: fixed;
    top: 12px;
    left: 12px;
    background: rgba(12, 12, 14, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    z-index: 50;
    pointer-events: auto;
    font-size: 12px;
    line-height: 1.5;
    width: 340px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.10) transparent;
    color: #b0b0b0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.dashboard.hidden { display: none; }

/* Section dividers */
.dash-divider {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.28);
    margin: 14px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Live stats */
.dash-stats {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    row-gap: 4px;
    padding: 2px 0;
}
.stat-label {
    color: rgba(255, 255, 255, 0.35);
    font-size: 11px;
    white-space: nowrap;
    line-height: 1.6;
}
.stat-value {
    color: rgba(255, 255, 255, 0.65);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.6;
}

/* Setting rows */
.dash-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.dash-row--wrap { flex-wrap: wrap; }

.dash-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11.5px;
    white-space: nowrap;
    flex-shrink: 0;
    width: 120px;
}

/* Segmented control */
.seg-control {
    display: flex;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    overflow: hidden;
    padding: 3px;
    gap: 2px;
}
.seg-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 11.5px;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.seg-btn + .seg-btn { border-left: none; }
.seg-btn.active {
    background: rgba(255,255,255,0.14);
    color: #e8e8e8;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.seg-btn:hover:not(.active) { background: rgba(255,255,255,0.06); }

/* Slider + number group */
.dash-slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.dash-slider {
    flex: 1;
    height: 3px;
    accent-color: rgba(255,255,255,0.5);
    cursor: pointer;
    min-width: 0;
}
.dash-number {
    width: 54px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 5px;
    color: #ccc;
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    padding: 3px 6px;
    text-align: right;
    outline: none;
    transition: border-color 0.15s;
}
.dash-number:focus { border-color: rgba(255,255,255,0.30); }

/* Gradient preview */
.gradient-preview {
    display: block;
    width: 100%;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 8px;
}

/* Color stops */
.color-stops {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
}
.color-swatch {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 5px;
    padding: 0;
    cursor: pointer;
    background: none;
    transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border-radius: 5px; border: 1px solid rgba(255,255,255,0.15); }

/* Sublabel */
.dash-sublabel {
    font-size: 10px;
    color: rgba(255,255,255,0.25);
    margin: 8px 0 5px;
}

/* Segment weights */
.weights-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}
.weight-input {
    width: 42px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 5px;
    color: #ccc;
    font-size: 11px;
    padding: 3px 4px;
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}
.weight-input:focus { border-color: rgba(255,255,255,0.30); }

/* Generic buttons */
.dash-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 6px;
    color: #b0b0b0;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.dash-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.16); }
.dash-btn--danger { color: #c06060; border-color: rgba(200,70,70,0.18); }
.dash-btn--danger:hover { background: rgba(200,70,70,0.12); border-color: rgba(200,70,70,0.28); }
.dash-btn--go {
    padding: 5px 8px;
    color: #6bc;
    border-color: rgba(80,180,220,0.18);
    flex-shrink: 0;
}
.dash-btn--go:hover { background: rgba(80,180,220,0.10); border-color: rgba(80,180,220,0.28); }
.dash-btn--icon {
    padding: 3px 7px;
    font-size: 13px;
    line-height: 1.2;
    flex-shrink: 0;
}

/* Text input */
.dash-text-input {
    flex: 1;
    min-width: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 6px;
    color: #ccc;
    font-size: 12px;
    padding: 5px 8px;
    outline: none;
    transition: border-color 0.15s;
}
.dash-text-input:focus { border-color: rgba(255,255,255,0.30); }

/* Bookmarks */
.bookmarks-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.bookmarks-empty { font-size: 11px; color: rgba(255,255,255,0.25); padding: 4px 0; }
.bookmark-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    padding: 6px 8px;
    transition: background 0.1s;
}
.bookmark-row:hover { background: rgba(255,255,255,0.05); }
.bookmark-info { flex: 1; min-width: 0; }
.bookmark-name {
    font-size: 12px;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bookmark-zoom {
    font-size: 10px;
    color: rgba(255,255,255,0.3);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Action bar */
.action-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.action-btn { justify-content: center; text-align: center; }
/* Screenshot spans both columns, share + save share a row, reset goes full width */
.action-btn:nth-child(1) { grid-column: 1 / -1; }   /* Screenshot — full row */
.action-btn:nth-child(4) { grid-column: 1 / -1; }   /* Reset — full row */

/* Help */
.dash-help {
    margin-top: 10px;
    font-size: 10px;
    color: rgba(255,255,255,0.22);
    line-height: 1.7;
}

/* ---------- Floating toggle button (smartphone mode) ---------- */

.float-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 60;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(12, 12, 14, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ccc;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    touch-action: manipulation;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.float-toggle-btn:hover,
.float-toggle-btn.panel-open { background: rgba(50, 50, 55, 0.95); color: #fff; border-color: rgba(255,255,255,0.2); }

/* ---------- Utility ---------- */

.hidden {
    display: none !important;
}
