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

:root {
    /* ── Blueberry palette ── */
    --palette-blueberry-100: #F0EEFF;
    --palette-blueberry-200: #DBD7FF;
    --palette-blueberry-300: #B3A8F7;
    --palette-blueberry-500: #2E2B74;
    --palette-blueberry-800: #1E193E;
    --palette-blueberry-900: #15122B;

    /* ── Global palette ── */
    --palette-base-100: #FBFBFD;
    --palette-base-800: #2A2A30;
    --palette-green-500: #00800C;
    --palette-yellow-500: #FFB300;
    --palette-red-500: #D32F2F;

    /* ── Semantic — Blueberry theme ── */
    --color-primary: var(--palette-blueberry-500);
    --color-primary-darker: var(--palette-blueberry-800);
    --color-primary-lighter: var(--palette-blueberry-300);
    --color-background-darkest: var(--palette-blueberry-900);
    --color-surface: var(--palette-blueberry-100);
    --color-background: var(--palette-blueberry-200);

    /* ── Semantic — Global ── */
    --color-text: var(--palette-base-800);
    --color-surface-alt: var(--palette-base-800);
    --color-success: var(--palette-green-500);
    --color-warning: var(--palette-yellow-500);
    --color-error: var(--palette-red-500);

    /* ── Export accent (orange) ── */
    --color-export: #EA580C;
    --color-export-hover: #C44A08;

    /* ── Surface ── */
    --color-surface-raised: #ffffff;
    /* panel/card surfaces above background */
    --color-on-surface: var(--palette-blueberry-900);
    --color-label: #666;
    /* muted section labels */
    --color-hint: #aaa;
    /* hints and estimates */

    /* ── App aliases (used throughout existing CSS) ── */
    --primary-color: var(--color-primary);
    --text-color: var(--color-text);
    --bg-color: var(--color-surface);
    --card-bg: var(--palette-base-100);
    --border-color: #d8d5ee;

    /* ── Type scale ── */
    --text-xs: 0.625rem;
    /* 10px — micro labels: ticks, card names */
    --text-sm: 0.6875rem;
    /* 11px — small UI: section headers, meta, hints */
    --text-md: 0.8125rem;
    /* 13px — interface: buttons, radio, controls */
}

/* ── Dark theme overrides ─────────────────────────────────────────────────── */

html.theme-dark {
    --palette-base-100: var(--palette-blueberry-800);
    --bg-color: var(--palette-blueberry-900);
    --card-bg: var(--palette-blueberry-800);
    --color-surface: var(--palette-blueberry-800);
    --color-surface-raised: var(--palette-blueberry-800);
    --color-background: var(--palette-blueberry-900);
    --color-background-darkest: var(--palette-blueberry-900);
    --text-color: var(--palette-blueberry-100);
    --color-text: var(--palette-blueberry-100);
    --color-on-surface: var(--palette-blueberry-100);
    --color-label: var(--palette-blueberry-300);
    --color-hint: var(--palette-blueberry-300);
    --border-color: rgba(179, 168, 247, 0.18);
    /* Interactive elements need a lighter primary so they're visible on dark surfaces */
    --color-primary: var(--palette-blueberry-300);
    --primary-color: var(--palette-blueberry-300);
}

/* Filled buttons: dark text on light-primary bg for contrast */
/* (export buttons use --color-export, not --color-primary, so no override needed) */

/* Radio active: border + subtle tint for visibility in both light and dark */
html.theme-dark .radio-option:has(input:checked) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--palette-blueberry-200);
    border-color: var(--palette-blueberry-300);
}

/* Section boxes: subtly differentiated in dark mode */
html.theme-dark .controls-section-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

/* Orbit hint toast: invert for dark mode */
html.theme-dark .orbit-hint-bar {
    background: var(--palette-blueberry-200);
}

html.theme-dark .orbit-hint {
    color: var(--palette-blueberry-900);
}

html.theme-dark .orbit-hint-dismiss {
    background: rgba(30, 25, 62, 0.15);
    color: var(--palette-blueberry-900);
}

/* Thumb card visible borders in dark mode */
html.theme-dark .color-option,
html.theme-dark .shading-option,
html.theme-dark .rotation-option,
html.theme-dark .dimension-option {
    border-color: rgba(179, 168, 247, 0.4);
}

html.theme-dark .loop-toggle-track {
    background: rgba(255, 255, 255, 0.2);
}

/* ══════════════════════════════════════════════════════════════════════════════
   DEFAULT (empty) STATE — normal page layout like GCoder
   ══════════════════════════════════════════════════════════════════════════════ */

html,
body {
    margin: 0;
}

body {
    font-family: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}

/* ── Header (default) ── */

header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    height: 6vh;
    width: auto;
    display: block;
    margin: 0 auto 8px;
}

header>p {
    margin: 0;
    color: #888;
    font-size: 1rem;
}

/* ── Upload section (default) ── */

.upload-section {
    text-align: center;
    padding: 40px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin-bottom: 30px;
    transition: border-color 0.2s, background 0.2s;
}

.upload-section:hover,
main.drag-over .upload-section {
    border-color: var(--primary-color);
    background: var(--color-surface);
}

.drop-hint {
    margin: 12px 0 0;
    color: #aaa;
    font-size: var(--text-md);
}

/* ── File label button ── */

.file-label {
    display: inline-flex;
    align-items: center;
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.file-label:hover {
    opacity: 0.9;
}

/* Compact select button shown only in loaded state */
.compact-btn {
    display: none;
}

input[type="file"] {
    display: none;
}

/* ── Viewer + controls: hidden in default state ── */

.viewer-section {
    display: none;
}

.controls-bar {
    display: none;
}

/* ── Footer (default) ── */

footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: #aaa;
}

footer p {
    margin: 0;
}

/* ── Shared utilities ── */

.hidden {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   LOADED STATE — full-viewport flex layout (set via html.loaded class)
   ══════════════════════════════════════════════════════════════════════════════ */

html.loaded,
html.loaded body {
    height: 100%;
    overflow: hidden;
}

html.loaded body {
    padding: 0;
    box-sizing: border-box;
}

html.loaded .container {
    height: 100%;
    padding: 0;
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

html.loaded .app-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

html.loaded main {
    flex: 0 0 45vh;
    min-height: 200px;
    overflow: hidden;
}

html.loaded .sidebar {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

@media (min-width: 900px) {
    html.loaded .app-body {
        flex-direction: row;
    }

    html.loaded main {
        flex: 1;
        min-height: 0;
    }

    html.loaded .sidebar {
        flex: none;
        width: 350px;
        border-left: 1px solid var(--border-color);
        overflow: hidden;
        transition: width 0.2s ease;
    }

    html.loaded.sidebar-collapsed .sidebar {
        width: 0;
        border-left: none;
    }

    /* Collapsed: tab flips to point left (expand) */
    html.loaded.sidebar-collapsed .sidebar-edge-tab svg {
        transform: rotate(180deg);
    }

    html.loaded .controls-bar {
        border-top: none;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        /* Allow min-height: 100% on the bar to push info btn to bottom */
        display: flex;
        flex-direction: column;
    }

    .controls-row {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
    }

    .controls-row--motion {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .range-label {
        min-width: 0;
    }
}

/* ── Header (loaded) ── */

html.loaded header {
    display: none;
}

html.loaded .logo {
    height: 32px;
    margin: 0;
}

html.loaded header>p {
    display: none;
}

html.loaded .compact-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.5em 1.25em;
    min-height: 2.5em;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    line-height: 1.2;
    flex-shrink: 0;
    background: var(--palette-blueberry-500);
    border: none;
    color: #fff;
    border-radius: 9999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: background 0.15s, transform 0.1s;
}

html.loaded .compact-btn:hover {
    background: var(--palette-blueberry-800);
}

html.loaded .compact-btn:active {
    transform: scale(0.95);
}

/* ── Main canvas area (loaded) ── */

html.loaded main {
    display: flex;
    flex-direction: column;
    position: relative;
}

html.loaded main.drag-over {
    background: rgba(46, 43, 116, 0.04);
}

html.loaded .viewer-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

html.loaded .viewer-section.hidden {
    display: none !important;
}

.canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: var(--color-background-darkest);
}

.canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.file-chip {
    display: none;
    align-items: center;
    gap: 4px;
    min-height: 2.5em;
    padding: 0 8px 0 14px;
    background: var(--palette-blueberry-200);
    color: var(--palette-blueberry-900);
    border-radius: 9999px;
    cursor: default;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    font-size: var(--text-md);
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

html.loaded .file-chip {
    display: inline-flex;
}

.file-chip-x:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-radius: 50%;
}

.file-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

.file-chip-x {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.5em;
    height: 1.5em;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
}

.canvas-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 5;
    pointer-events: none;
}

html.loaded .canvas-logo {
    height: clamp(32px, 6vh, 64px);
    width: auto;
    top: 20px;
}

/* On narrow viewports swap the wordmark for the square favicon */
@media (max-width: 899px) {
    html.loaded .canvas-logo {
        content: url('favicon.svg');
        height: 36px;
    }
}

.canvas-top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 80px);
    min-width: 0;
}

html.loaded .canvas-replace-btn {
    flex-shrink: 0;
}

.scroll-hint {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: var(--text-md);
    font-weight: 600;
    pointer-events: none;
    transition: opacity 0.3s;
}

.pause-btn {
    z-index: 1;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(21, 18, 43, 0.85);
    color: var(--palette-blueberry-200);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s, color 0.15s, transform 0.1s;
    font-size: 0;
    font-family: "Source Sans 3", system-ui, sans-serif;
}

#btnFrameOverlay {
    gap: 0;
}

#btnFrameOverlay .frame-overlay-icon--confirm,
#btnFrameOverlay .frame-overlay-label {
    display: none;
}

#btnFrameOverlay.is-crop-confirm {
    width: auto;
    min-width: 2.5rem;
    padding: 0 12px;
    gap: 6px;
    border-radius: 9999px;
    background: var(--color-export);
    color: #fff;
    border-color: color-mix(in srgb, var(--color-export) 70%, #fff);
    font-size: var(--text-sm);
    font-weight: 700;
}

#btnFrameOverlay.is-crop-confirm .frame-overlay-icon--frame {
    display: none;
}

#btnFrameOverlay.is-crop-confirm .frame-overlay-icon--confirm,
#btnFrameOverlay.is-crop-confirm .frame-overlay-label {
    display: inline-flex;
}

#btnFrameOverlay.is-crop-confirm:hover {
    background: var(--color-export-hover);
    color: #fff;
    border-color: color-mix(in srgb, var(--color-export-hover) 70%, #fff);
}

.pause-btn:hover {
    background: rgba(21, 18, 43, 0.96);
    color: var(--palette-blueberry-100);
}

.pause-btn:active {
    transform: scale(0.95);
}

.pause-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

html.none-mode #btnPause {
    opacity: 0.3;
    pointer-events: none;
}

.reset-zoom-btn {
    left: 50px;
}

.rotate-ccw-btn {
    left: 50px;
}

.rotate-x-btn {
    left: 90px;
}

.cam-nav {
    display: grid;
    grid-template-areas:
        ".    up   ."
        "left mid  right"
        ".    down .";
    grid-template-columns: repeat(3, 2rem);
    grid-template-rows: repeat(3, 2rem);
    gap: 2px;
    z-index: 1;
    pointer-events: auto;
}

.cam-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(21, 18, 43, 0.85);
    color: var(--palette-blueberry-200);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.cam-btn:hover {
    background: rgba(21, 18, 43, 0.96);
    color: var(--palette-blueberry-100);
}

.cam-btn:active {
    transform: scale(0.9);
}

.cam-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

.cam-btn-up {
    grid-area: up;
}

.cam-btn-left {
    grid-area: left;
}

.cam-btn-center {
    grid-area: mid;
}

.cam-btn-right {
    grid-area: right;
}

.cam-btn-down {
    grid-area: down;
}

/* ── Controls bar reset camera button ── */

.reset-cam-btn {
    margin-left: auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: var(--text-md);
    font-weight: 600;
    background: transparent;
    border: 1px solid #ccc;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.reset-cam-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ── Controls bar (loaded) ── */

html.loaded .controls-bar {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    position: relative;
    gap: 16px;
    border-top: none;
    padding: 20px;
    background: var(--color-surface);
    transition: background 0.2s, border-color 0.2s;
}

html.loaded .controls-bar.hidden {
    display: none !important;
}

/* ── Section boxes inside controls bar ── */

.controls-section-box {
    background: var(--color-surface-raised);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(30, 25, 62, 0.06);
    min-width: 0;
    overflow: hidden;
    flex-shrink: 0;
}

/* ── Footer (loaded) ── */

html.loaded footer {
    display: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   CONTROLS & EXPORT — shared between states
   ══════════════════════════════════════════════════════════════════════════════ */

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.controls-row--copy {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 2;
    padding: 0;
    border: none;
}

.controls-row--motion {
    align-items: flex-start;
}

.section-divider {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color) 15%, var(--border-color) 85%, transparent);
    flex-shrink: 0;
    margin: 0;
    align-self: stretch;
}

.controls-row--theme {
    display: none;
    /* button is now fixed-position, not in the flow */
}

#themeToggleLabel {
    display: none;
}

@media (min-width: 600px) {
    #themeToggleLabel {
        display: inline;
    }
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 0.75em;
    min-height: 2.5em;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    line-height: 1.2;
    color: var(--palette-blueberry-200);
    background: rgba(21, 18, 43, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9999px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s, color 0.15s;
}

.theme-toggle-btn:hover {
    background: rgba(21, 18, 43, 0.96);
    color: var(--palette-blueberry-100);
}

/* ── Canvas bottom-left overlay group ── */

.canvas-overlay-bl {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Canvas bottom-right overlay group ── */

.canvas-overlay-br {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pause-btn--active {
    background: var(--palette-blueberry-500) !important;
    color: var(--palette-blueberry-100) !important;
    border-color: var(--palette-blueberry-300) !important;
}

.export-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    padding-top: 14px;
    margin-top: 2px;
    border-top: 2px solid var(--border-color);
}

.downloads-section {
    flex: 1 1 100%;
    min-width: 0;
}

/* ── Export list (macOS-style action rows) ── */
.export-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 0;
}

.export-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid;
    border-image: linear-gradient(to right, transparent, var(--border-color) 15%, var(--border-color) 85%, transparent) 1;
}

.export-list-item:last-child {
    border-bottom: none;
    border-image: none;
}

.export-list-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.control-label {
    display: flex;
    flex-direction: column;
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-label, #666);
    letter-spacing: 0.01em;
    gap: 10px;
    min-width: 0;
}

.range-label {
    flex: 1;
    min-width: 140px;
    gap: 2px;
}

.speed-label {
    flex-basis: 100%;
}

.tilt-range-label {
    display: none;
}

html.tilt-mode .tilt-range-label {
    display: flex;
}

.wobble-spin-range-label {
    display: none;
}

html.wobble-mode .wobble-spin-range-label {
    display: none;
}

html.spin-ccw .rotation-thumb--spin .rot-icon {
    transform: scaleX(-1);
}

.range-label>span {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-label);
}

.range-label>span span {
    font-weight: 600;
    color: var(--color-label);
}

/* ── Slider reset button ── */

.slider-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1.5px solid var(--color-primary);
    border-radius: 50%;
    background: var(--color-surface-raised);
    color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, color 0.12s, border-color 0.12s, transform 0.12s;
}

.slider-reset-btn svg {
    width: 11px;
    height: 11px;
}

.slider-reset-btn.is-changed {
    opacity: 1;
    pointer-events: auto;
}

.slider-reset-btn.is-changed:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    transform: rotate(-30deg);
}

.slider-ticks {
    display: none;
    /* replaced by inline snap dots */
}

/* Export card: ticks must align with the slider thumb inside setting rows */
.export-card-settings .slider-ticks {
    display: none;
}

/* ── Snap-point dots overlay on slider track ── */

.range-wrap {
    position: relative;
}

.snap-dots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.snap-dots span {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--color-primary);
    opacity: 0.45;
}

/* ── Export section (Figma-style) ── */

/* Format + Quality dropdowns row */
.export-selects-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.export-select-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.export-dimensions-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.export-dimensions-row[hidden] {
    display: none !important;
}

.dimension-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.dimension-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--palette-blueberry-200);
    box-shadow: 0 0 0 2px transparent;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.dimension-option input[type="radio"] {
    display: none;
}

.dimension-option:has(input:checked) {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.dimension-option:hover {
    border-color: var(--color-primary-lighter);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(46, 43, 116, 0.15);
}

.dimension-option:has(input:checked):hover {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--primary-color), 0 4px 10px rgba(46, 43, 116, 0.15);
    transform: translateY(-1px);
}

.dimension-thumb {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--palette-blueberry-500);
}

.dimension-shape {
    display: block;
    border: 2px solid currentColor;
    border-radius: 3px;
    background: color-mix(in srgb, #fff 74%, var(--palette-blueberry-100) 26%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.dimension-thumb--square .dimension-shape {
    width: 24px;
    height: 24px;
}

.dimension-thumb--portrait12 .dimension-shape {
    width: 14px;
    height: 28px;
}

.dimension-thumb--landscape21 .dimension-shape {
    width: 28px;
    height: 14px;
}

.dimension-thumb--landscape43 .dimension-shape {
    width: 25px;
    height: 19px;
}

.export-select-label {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-label);
}

.export-select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1.5px solid var(--color-border, rgba(0, 0, 0, 0.12));
    background: var(--color-surface-raised);
    color: var(--color-on-surface);
    font-size: var(--text-sm);
    font-family: inherit;
    cursor: pointer;
    appearance: auto;
}

.export-select:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

/* Format-specific options panel */
.export-format-opts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    margin-bottom: 8px;
}

.export-format-opts[hidden] {
    display: none !important;
}

/* Preview thumbnail */
.export-preview-wrap {
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-background);
    margin-top: 6px;
    margin-bottom: 0;
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1.5px solid var(--color-border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.export-preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Checkerboard when preview is rendered with alpha */
.export-preview-wrap.is-transparent {
    background-color: transparent;
    background-image:
        linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.06) 75%),
        linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.06) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}

/* Main export button */
.export-btn--main {
    display: block;
    width: 100%;
    margin-bottom: 4px;
    padding: 0.55em 1em;
    font-size: var(--text-md);
    font-weight: 700;
    background: var(--color-export);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: background 0.12s;
    margin-bottom: 6px;
    font-family: inherit;
}

.export-btn--main:hover {
    background: var(--color-export-hover);
}

.export-btn--main:active {
    opacity: 0.88;
}

.export-btn--main:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}



input[type="color"] {
    width: 44px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
}

select {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: var(--text-md);
    background: var(--color-surface-raised, white);
    color: var(--color-on-surface, #222);
    min-width: 100px;
    cursor: pointer;
}

.radio-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.radio-option {
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--color-on-surface, #555);
    background: var(--color-surface-raised, white);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.rot-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.radio-option:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option:has(input:checked) {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
    font-weight: 700;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right,
            var(--color-primary) calc(var(--pct, 0) * 100%),
            var(--palette-blueberry-200) calc(var(--pct, 0) * 100%));
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 1px 3px rgba(46, 43, 116, 0.25);
}

input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--palette-blueberry-200);
}

input[type="range"]::-moz-range-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--color-primary);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    cursor: pointer;
}

html.theme-dark input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right,
            var(--color-primary) calc(var(--pct, 0) * 100%),
            var(--palette-blueberry-800) calc(var(--pct, 0) * 100%));
}

html.theme-dark input[type="range"]::-moz-range-track {
    background: var(--palette-blueberry-800);
}

.export-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--text-md);
    font-weight: 600;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    opacity: 0.9;
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background-color: #eee;
    color: #333;
}

.secondary-btn:hover {
    background-color: #ddd;
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5em 1.25em;
    min-height: 2.5em;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    line-height: 1.2;
    background: var(--color-export);
    color: #fff;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.export-btn:hover {
    background: var(--color-export-hover);
}

.export-btn:active {
    transform: scale(0.95);
}

.export-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Small export button variant (in section headers) ── */
.export-btn--sm {
    padding: 0.3em 0.75em;
    min-height: 2em;
    font-size: var(--text-sm);
    gap: 4px;
}

/* ── Section header row (label + export buttons) ── */
.controls-row--section-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 8px;
}

.section-heading {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-label);
    flex: 1;
    min-width: 0;
}

.section-export-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Per-format settings block (GIF, Video) ── */
.anim-format-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0 4px;
    border-top: 2px solid var(--color-border, rgba(0, 0, 0, 0.13));
    margin-top: 4px;
}

.format-block-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.format-block-header .export-quality-select {
    flex: 1;
    min-width: 0;
}

.format-block-label {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-label);
    flex-shrink: 0;
    min-width: 36px;
}

.format-hint {
    font-size: var(--text-xs);
    color: var(--color-hint);
    font-weight: 400;
}


.export-status {
    font-size: var(--text-md);
    color: var(--color-label, #666);
    font-style: italic;
    align-self: center;
}

/* ── Animation export footer (progress bar + status) ── */

.anim-export-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 2px;
}

.anim-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--color-border, rgba(0, 0, 0, 0.1));
    overflow: hidden;
}

.anim-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary, #3b3a8e);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.export-estimate {
    font-size: var(--text-sm);
    color: var(--color-label, #666);
    text-align: right;
    flex: 1;
}

/* ── GIF group (stacked button + loop toggle) ── */

.gif-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.gif-loop-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-label);
    cursor: pointer;
    user-select: none;
}

.gif-loop-label input[type="checkbox"] {
    display: none;
}

.gif-loop-label:has(input:checked) .loop-toggle-track {
    background: var(--color-primary);
}

.gif-loop-label:has(input:checked) .loop-toggle-thumb {
    transform: translateX(12px);
}

html.none-mode .gif-loop-label {
    opacity: 0.38;
    pointer-events: none;
}

.loop-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    min-height: 2.5em;
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--color-export);
    background: color-mix(in srgb, var(--color-export) 10%, white);
    border: 1px solid color-mix(in srgb, var(--color-export) 35%, white);
    border-radius: 9999px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.loop-toggle-label input[type="checkbox"] {
    display: none;
}

.loop-toggle-track {
    position: relative;
    width: 28px;
    height: 16px;
    background: #ccc;
    border-radius: 8px;
    flex-shrink: 0;
    overflow: hidden;
    transition: background 0.2s;
}

.loop-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.loop-toggle-label:has(input:checked) .loop-toggle-track {
    background: var(--color-export);
}

.loop-toggle-label:has(input:checked) .loop-toggle-thumb {
    transform: translateX(12px);
}

/* ── Toggle check/X icons ── */

.toggle-check-icon,
.toggle-x-icon {
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    pointer-events: none;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.toggle-check-icon {
    left: 7px;
    transform: translate(-50%, -50%);
    color: white;
    opacity: 0;
}

.toggle-x-icon {
    left: 21px;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.45);
    opacity: 1;
}

.gif-loop-label:has(input:checked) .toggle-check-icon,
.rotation-power-toggle:has(input:checked) .toggle-check-icon {
    opacity: 1;
}

.gif-loop-label:has(input:checked) .toggle-x-icon,
.rotation-power-toggle:has(input:checked) .toggle-x-icon {
    opacity: 0;
}

.rotation-power-toggle:has(input:checked) .loop-toggle-track {
    background: var(--color-primary);
}

.rotation-power-toggle:has(input:checked) .loop-toggle-thumb {
    transform: translateX(12px);
}

/* ── Texture tuning panel ── */

.texture-control {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    min-width: 0;
    align-self: stretch;
}

.texture-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding-right: 2.75rem;
    min-height: 2.5rem;
    width: 100%;
}

.texture-tune-wrap {
    position: absolute;
    top: 2px;
    right: 6px;
    z-index: 4;
}

.texture-tune-btn {
    position: relative;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--color-label);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    opacity: 0.72;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.texture-tune-btn::before {
    content: "";
    position: absolute;
    inset: -10px;
}

.texture-tune-btn img {
    width: 17px;
    height: 17px;
    display: block;
    filter: var(--icon-filter, none);
}

.texture-tune-btn:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.texture-tune-btn[aria-expanded="true"] {
    opacity: 1;
}

.texture-new-badge {
    position: absolute;
    top: -12px;
    right: -20px;
    min-width: 22px;
    height: 13px;
    padding: 0 4px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 999px;
    background: #f2791a;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 11px;
    text-align: center;
    font-family: inherit;
    box-shadow: 0 2px 6px rgba(121, 59, 11, 0.18);
    pointer-events: none;
    /* Make it unclickable and allow clicks to pass through */
}

.texture-new-badge[hidden] {
    display: none !important;
}

.texture-news-popover {
    position: absolute;
    top: 26px;
    right: -4px;
    width: min(230px, 78vw);
    padding: 10px 28px 10px 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--color-primary) 22%, var(--color-border));
    background: color-mix(in srgb, var(--color-surface-raised) 92%, #fff 8%);
    box-shadow: 0 10px 26px rgba(31, 25, 66, 0.16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.texture-news-popover::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 16px;
    width: 10px;
    height: 10px;
    background: inherit;
    border-top: inherit;
    border-left: inherit;
    transform: rotate(45deg);
}

.texture-news-popover::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -12px;
    height: 12px;
}

.texture-news-popover.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.texture-news-popover[hidden] {
    display: none !important;
}

.texture-news-title {
    font-size: var(--text-xs);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    margin-bottom: 6px;
}

.texture-news-item {
    position: relative;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-label);
    line-height: 1.35;
    padding-left: 10px;
}

.texture-news-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-primary) 80%, #fff 20%);
}

.texture-news-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--color-label);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.texture-news-close:hover {
    background: color-mix(in srgb, var(--color-primary) 18%, transparent);
    color: var(--color-primary);
}

.texture-tune-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    width: 100%;
}

.texture-tune-panel[hidden] {
    display: none !important;
}

.texture-tune-row {
    margin: 0;
    gap: 2px;
}

.texture-tune-row[hidden] {
    display: none !important;
}

.texture-tune-row>span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.texture-tune-row.gif-option-check {
    margin-top: 2px;
    font-size: var(--text-sm);
}

/* Keep texture tuning sliders visually consistent: no snap-dot overlays. */
.texture-tune-panel .snap-dots {
    display: none;
}

/* ── Shading thumbnail cards ── */

left: 0;
right: 0;
bottom: 0;
border-radius: 5px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.shading-group {
    display: flex;
    gap: 10px;
}

.shading-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 8px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--palette-blueberry-200);
    cursor: pointer;
    box-shadow: 0 0 0 2px transparent;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s;
}

.shading-option input[type="radio"] {
    display: none;
}

/* Double-ring selection: white inner gap + primary-color outer ring.
   Readable regardless of card or canvas background color. */
.shading-option:has(input:checked) {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.shading-option:hover {
    border-color: var(--color-primary-lighter);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(46, 43, 116, 0.15);
}

.shading-option:has(input:checked):hover {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary-color), 0 4px 10px rgba(46, 43, 116, 0.15);
    transform: translateY(-1px);
}

.shading-thumb {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
}


.shading-thumb--matte {
    background: radial-gradient(circle at 36% 32%, #ffffffc2 5%, #7f7ad2 34%, #55509a 70%, #3c3774 100%);
}

.shading-thumb--phong {
    background: radial-gradient(circle at 38% 35%, #ffffffcc 4%, var(--palette-blueberry-500) 40%, var(--palette-blueberry-800) 100%);
}

.shading-thumb--metallic {
    background: radial-gradient(circle at 32% 30%, #fff 4%, #ffffffcc 10%, var(--palette-blueberry-500) 36%, var(--palette-blueberry-800) 62%, var(--palette-blueberry-900) 90%);
}

/* ── Slider tooltip (Chrome-style hover bubble) ── */

.range-wrap {
    position: relative;
    width: 100%;
}

.slider-tooltip {
    margin-left: auto;
    margin-right: 6px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-label);
    white-space: nowrap;
    font-family: "Source Sans 3", system-ui, sans-serif;
}

/* ── Thumb card wrap (shared by Color, Texture, Rotation) ── */

.thumb-card-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.thumb-label {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-label);
    line-height: 1;
}

/* ── Sidebar header (sticky hamburger bar) ── */

.sidebar-header {
    display: none;
    flex-shrink: 0;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0;
    background: var(--color-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

html.loaded .sidebar-header {
    display: flex;
}

/* ── Sidebar collapse edge tab ── */

.sidebar-edge-tab {
    display: none;
    position: fixed;
    right: 350px;
    /* flush with sidebar left edge when open */
    top: 50%;
    transform: translate(0, -50%);
    z-index: 30;
    width: 20px;
    height: 64px;
    padding: 0;
    border: 1px solid var(--palette-blueberry-300);
    border-right: none;
    border-radius: 6px 0 0 6px;
    background: var(--palette-blueberry-200);
    color: var(--palette-blueberry-500);
    cursor: pointer;
    transition: right 0.2s ease, background 0.12s, color 0.12s;
    align-items: center;
    justify-content: center;
}

.sidebar-edge-tab svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sidebar-edge-tab:hover {
    background: var(--color-primary, #3b3a8e);
    color: #fff;
    border-color: var(--color-primary, #3b3a8e);
}

@media (min-width: 900px) {
    html.loaded .sidebar-edge-tab {
        display: flex;
    }

    html.loaded.sidebar-collapsed .sidebar-edge-tab {
        right: 0;
    }
}

/* ── Hamburger menu ── */

.menu-wrap {
    position: relative;
}

.menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 8px;
    background: var(--color-surface-raised, white);
    color: var(--color-primary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

html.loaded .menu-btn {
    display: flex;
}

.menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.menu-btn:hover {
    background: var(--palette-blueberry-100);
    border-color: var(--color-primary);
}

.menu-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

/* ── Info overlay extras ── */

.settings-overlay.info-overlay {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 16px;
}

.info-made-by {
    display: block;
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-on-surface);
    padding: 2px 14px 4px;
}

/* ── Info button row ── */

.info-btn-row {
    display: flex;
    justify-content: flex-end;
    padding: 0 0 4px;
    margin-top: auto;
    /* pushes to bottom of flex column */
    padding-top: 24px;
    /* gap between last control and icon */
}

.info-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-label);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.info-icon-btn:hover {
    color: var(--color-on-surface);
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.info-icon-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

/* ── Info panel extras ── */

.info-panel {
    width: 300px;
}

.info-panel-body {
    padding: 14px 16px 16px !important;
    gap: 8px !important;
}

.info-description {
    margin: 0;
    padding-left: 14px;
    font-size: var(--text-sm);
    color: var(--color-label);
    line-height: 1.5;
}

.info-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 14px;
    font-size: var(--text-xs);
    color: var(--color-label);
    opacity: 0.75;
}

.info-link-btn {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Settings overlay panel ── */

.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 12px;
}

.settings-overlay[hidden] {
    display: none;
}

.settings-panel {
    background: var(--color-surface-raised, white);
    border-radius: 16px;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.18), 0 1.5px 4px rgba(0, 0, 0, 0.06);
    width: 280px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    transition: background 0.2s;
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-color);
}

.settings-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-on-surface, #222);
}

.settings-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--color-on-surface, #555);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.12s;
}

.settings-close-btn:hover {
    background: var(--palette-blueberry-100);
}

.settings-close-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

.settings-panel-body {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    background: transparent;
    color: var(--color-on-surface, #2E2B74);
    border: none;
    border-radius: 10px;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
    box-sizing: border-box;
}

.settings-action-btn:hover {
    background: var(--palette-blueberry-100);
}

.settings-action-btn:active {
    transform: scale(0.98);
}

.settings-action-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 14px;
}

html.theme-dark .settings-action-btn:hover {
    background: rgba(179, 168, 247, 0.1);
}

html.theme-dark .settings-close-btn:hover {
    background: rgba(179, 168, 247, 0.1);
}

/* ── Color picker cards ── */

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

.color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.color-option:focus-within {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.color-option input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.color-swatch {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.color-name {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-label);
    line-height: 1;
}

.color-option:hover {
    border-color: var(--color-primary-lighter);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(46, 43, 116, 0.15);
}

.color-edit-icon {
    position: absolute;
    top: 6px;
    /* aligns with .color-option padding-top */
    left: 8px;
    /* aligns with .color-option padding-left */
    width: 44px;
    /* matches .color-swatch width */
    height: 44px;
    /* matches .color-swatch height */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.48);
    border-radius: 4px;
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.color-edit-icon svg {
    width: 20px;
    height: 20px;
}

.color-option:hover .color-edit-icon {
    opacity: 1;
}

/* ── Unified Styles group (colors + shading) ── */

.styles-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.colors-sub {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.shading-sub {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.shading-sub-label {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-label, #666);
    line-height: 1;
}

.shading-items {
    display: flex;
    gap: 10px;
}

/* ── Export buttons row ── */

.export-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.export-gif-group {
    display: inline-flex;
    align-items: stretch;
}

/* ── GIF compound pill (button + loop inline) ── */

.gif-compound {
    display: inline-flex;
    align-items: stretch;
    border-radius: 9999px;
    overflow: hidden;
}

.gif-btn {
    border-radius: 9999px 0 0 9999px;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
}

.gif-loop-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    min-height: 2.5em;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    color: white;
    background: var(--color-export);
    border-radius: 0 9999px 9999px 0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.gif-loop-inline:hover {
    background: var(--color-export-hover);
}

.gif-loop-inline input[type="checkbox"] {
    display: none;
}

.gif-loop-inline .loop-toggle-track {
    background: rgba(255, 255, 255, 0.35);
}

.gif-loop-inline:has(input:checked) .loop-toggle-track {
    background: rgba(255, 255, 255, 0.9);
}

.gif-loop-inline .loop-toggle-thumb {
    background: var(--color-export);
    box-shadow: none;
}

.gif-loop-inline:has(input:checked) .loop-toggle-thumb {
    background: var(--color-export);
}

/* ── Export quality settings (legacy; no longer in DOM) ── */

.export-quality-settings {
    display: none;
}

.export-quality-item {
    display: none;
}

.quality-label {
    display: none;
}

/* ── Export frame overlay canvas ── */

#exportFrameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    display: block;
}

/* ── Crop mode controls overlay ── */

#cropControls {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    gap: 12px;
    pointer-events: none;
}

#cropControls[hidden] {
    display: none;
}

.crop-dimensions-dock {
    position: absolute;
    z-index: 7;
    pointer-events: auto;
}

.crop-dimensions-dock[hidden] {
    display: none !important;
}

.crop-dimensions-dock .export-dimensions-row {
    margin: 0;
    gap: 6px;
}

.crop-dimensions-dock .export-select-label {
    display: none;
}

.crop-dimensions-dock .dimension-group {
    flex-direction: column;
    gap: 10px;
}

.crop-dimensions-dock .thumb-card-wrap {
    gap: 4px;
}

.crop-dimensions-dock .thumb-label {
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.crop-dimensions-dock .dimension-option {
    padding: 6px;
    border-width: 1.5px;
    border-color: rgba(255, 255, 255, 0.58);
    background: rgba(12, 10, 36, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.crop-dimensions-dock .dimension-option:hover {
    border-color: rgba(255, 255, 255, 0.9);
    transform: none;
    box-shadow: 0 4px 12px rgba(8, 6, 26, 0.34);
}

.crop-dimensions-dock .dimension-option:has(input:checked) {
    border-color: #fff;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 72%, #fff);
    background: rgba(255, 255, 255, 0.15);
}

.crop-dimensions-dock .dimension-option:has(input:checked) .dimension-shape {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: none;
}

.crop-dimensions-dock .dimension-option:has(input:checked):hover {
    border-color: #fff;
    transform: none;
}

.crop-dimensions-dock .dimension-thumb {
    width: 34px;
    height: 34px;
    color: #f4f4ff;
}

.crop-dimensions-dock .dimension-shape {
    border-width: 1.5px;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
}

.crop-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 24px;
    height: 3rem;
    font-size: var(--text-md);
    font-weight: 700;
    font-family: "Source Sans 3", system-ui, sans-serif;
    border-radius: 9999px;
    border: 1.5px solid transparent;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.crop-action-btn:active {
    transform: scale(0.95);
}

.crop-action-btn--ghost {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
}

.crop-action-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.8);
}

.crop-action-btn--primary {
    background: var(--color-primary);
    color: #fff;
    border-color: color-mix(in srgb, var(--color-primary) 70%, #fff);
}

.crop-action-btn--primary:hover {
    background: var(--color-primary-darker);
    border-color: color-mix(in srgb, var(--color-primary-darker) 70%, #fff);
}

html.crop-mode #btnFrameOverlay,
html.crop-mode .canvas-overlay-br,
html.crop-mode .canvas-bottom-center,
html.crop-mode .canvas-overlay-bl,
html.crop-mode .orbit-hint-bar {
    display: none;
}

html.crop-mode .ruler-hud {
    top: 10px;
}

/* ── Ruler / dimensions HUD ── */

.ruler-hud {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(10, 9, 28, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(179, 168, 247, 0.22);
    pointer-events: none;
    white-space: nowrap;
}

.ruler-hud[hidden] {
    display: none;
}

.ruler-dim {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.ruler-axis {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: rgba(179, 168, 247, 0.75);
    text-transform: uppercase;
    line-height: 1;
}

.ruler-val {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.1;
}

.ruler-sep {
    color: rgba(255, 255, 255, 0.25);
    font-size: 14px;
    line-height: 1;
    align-self: center;
}

.ruler-unit {
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.04em;
    align-self: flex-end;
    padding-bottom: 2px;
}

.frame-dim-region {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    display: none;
}

html.crop-mode .frame-dim-region {
    display: block;
    pointer-events: auto;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Crop corner drag handles ── */
.crop-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    z-index: 8;
    display: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

html.crop-mode .crop-corner {
    display: block;
}

.crop-corner--tl {
    cursor: nw-resize;
}

.crop-corner--tr {
    cursor: ne-resize;
}

.crop-corner--bl {
    cursor: sw-resize;
}

.crop-corner--br {
    cursor: se-resize;
}

/* ── Export section header row ── */

.export-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    min-width: 0;
    overflow: hidden;
}

.export-section-title {
    font-size: var(--text-md);
    font-weight: 700;
    white-space: nowrap;
}

.export-transparent-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-label, #888);
    cursor: pointer;
    white-space: nowrap;
    padding: 3px 7px;
    border: 1.5px solid var(--color-border, rgba(0, 0, 0, 0.15));
    border-radius: 6px;
    transition: border-color 0.12s, color 0.12s;
}

.export-transparent-label:has(input:checked) {
    border-color: var(--palette-blueberry-400, #6c63ff);
    color: var(--palette-blueberry-500, #5a52d5);
}

.export-transparent-label input {
    accent-color: var(--palette-blueberry-400, #6c63ff);
    width: 12px;
    height: 12px;
}

.export-transparent-label:has(input:disabled) {
    opacity: 0.4;
    pointer-events: none;
}

.export-quality-select {
    flex: 1;
    font-size: var(--text-sm);
    padding: 4px 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loop-count-select {
    font-size: var(--text-sm);
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
    background: var(--color-surface, #f5f5f7);
    color: var(--color-label);
    cursor: pointer;
}

/* frame-toggle-btn kept for CSS history, now hidden (button moved to canvas) */
.frame-toggle-btn {
    display: none;
}

/* ── Estimate row inside export cards ── */

.export-size-est-row {
    padding: 5px 12px 7px;
    font-size: var(--text-md);
    color: var(--color-label, #999);
    margin-top: 2px;
    min-height: 24px;
}

.export-info-time {
    font-weight: 700;
    font-size: var(--text-lg, 0.9rem);
    color: var(--color-on-surface, #222);
    font-style: normal;
}

.export-size-est-row:empty,
.export-size-est-row span:empty {
    display: none;
}

/* ── Per-format export cards ── */

.export-format-card {
    background: var(--color-surface, #f5f5f7);
    border: 1.5px solid var(--color-border, rgba(0, 0, 0, 0.09));
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.export-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 8px 12px;
    background: var(--color-surface-raised, rgba(0, 0, 0, 0.04));
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.09));
}

.export-card-title {
    font-size: var(--text-sm, 12px);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-label, #777);
}

.export-btn--card {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: var(--text-sm, 12px);
    min-height: unset;
    height: 28px;
    border-radius: 6px;
}

.export-card-settings {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
}

.export-setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    min-height: 32px;
    cursor: default;
}

.export-setting-row:hover {
    background: var(--color-surface-raised, rgba(0, 0, 0, 0.025));
}

.export-setting-row select,
.export-setting-row input[type="range"],
.export-setting-row input[type="number"] {
    flex: 1;
    min-width: 0;
}

.export-setting-label {
    min-width: 52px;
    font-size: var(--text-sm, 12px);
    font-weight: 600;
    color: var(--color-label, #777);
    white-space: nowrap;
    flex-shrink: 0;
}

.export-setting-hint {
    font-size: var(--text-sm);
    color: var(--color-label, #999);
    white-space: nowrap;
}

.export-number-input {
    -webkit-appearance: none;
    appearance: none;
    width: 56px;
    padding: 4px 6px;
    font-size: var(--text-sm, 12px);
    font-family: inherit;
    background: var(--color-input-bg, var(--color-surface));
    border: 1.5px solid var(--color-border, rgba(0, 0, 0, 0.15));
    border-radius: 6px;
    color: inherit;
    text-align: center;
    flex: 0 0 auto;
}

.export-number-input:focus {
    outline: none;
    border-color: var(--color-accent, #6c63ff);
}

/* image format radios — compact inline version */
.radio-group--sm {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.radio-group--sm .radio-option {
    padding: 3px 10px;
    font-size: var(--text-sm, 12px);
    min-height: unset;
    height: 26px;
    border-radius: 6px;
}

/* ── GIF inline checkbox options ── */
.gif-options-row {
    display: flex;
    gap: 14px;
    align-items: center;
}

.gif-options-row--select {
    gap: 8px;
}

.gif-option-label {
    font-size: var(--text-sm, 12px);
    font-weight: 500;
    color: var(--color-on-surface, #555);
    white-space: nowrap;
}

.gif-option-check {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-sm, 12px);
    font-weight: 500;
    color: var(--color-on-surface, #555);
    cursor: pointer;
    white-space: nowrap;
}

.gif-option-check input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Inline export section inside animation / image boxes ── */

.anim-export-inner,
.img-export-inner {
    display: flex;
    flex-direction: column;
    padding: 4px 0 0;
    gap: 6px;
}

.export-format-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.export-save-row {
    display: flex;
    justify-content: flex-end;
    padding-top: 6px;
}

.export-save-row .export-btn {
    flex: 1;
}

/* ── GIF type dropdown ── */

.gif-type-select {
    -webkit-appearance: none;
    appearance: none;
    padding: 0 2em 0 1em;
    min-height: 2.5em;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    line-height: 1.2;
    background-color: var(--color-export);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6em center;
    color: #fff;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0 9999px 9999px 0;
    cursor: pointer;
    transition: background-color 0.15s;
}

.gif-type-select:hover {
    background-color: var(--color-export-hover);
}

.gif-type-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

.gif-type-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Controls bar footer (Reset settings) ── */

.controls-bar-footer {
    height: 0;
    padding: 0;
    overflow: visible;
}

#btnResetSettings {
    color: var(--color-label);
    border-color: var(--color-primary);
}

#btnResetSettings:hover {
    color: var(--palette-red-500);
    border-color: var(--palette-red-500);
}

.canvas-bottom-center {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 5;
    pointer-events: none;
}

.orbit-hint-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 16px;
    background: var(--palette-blueberry-100);
    border-radius: 9999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
}

.orbit-hint-bar.visible {
    display: inline-flex;
    position: absolute;
    left: 16px;
    pointer-events: auto;
}

@media (min-width: 900px) {
    .orbit-hint-bar.visible {
        position: absolute;
        left: 50%;
        bottom: calc(100% + 10px);
        transform: translateX(-50%);
        max-width: min(78vw, 720px);
        z-index: 7;
    }
}

.orbit-hint {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--palette-blueberry-800);
    font-family: "Source Sans 3", system-ui, sans-serif;
}

.orbit-hint-dismiss {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: rgba(30, 25, 62, 0.1);
    color: var(--palette-blueberry-800);
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.orbit-hint-dismiss:hover {
    background: rgba(30, 25, 62, 0.2);
}

@media (max-width: 899px) {
    .canvas-bottom-center {
        bottom: 12px;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 0 12px;
    }

    .orbit-hint-bar.visible {
        position: static;
        left: auto;
        max-width: calc(100vw - 32px);
    }

    .orbit-hint-bar {
        padding: 7px 10px;
        border-radius: 16px;
    }

    .orbit-hint {
        white-space: normal;
        text-align: center;
        line-height: 1.25;
    }

    .orbit-hint-bar.visible+.cam-nav {
        margin-top: 12px;
    }
}

.copy-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.375em 0.75em;
    min-height: 2.5em;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: "Source Sans 3", system-ui, sans-serif;
    line-height: 1.2;
    color: var(--color-primary);
    background: transparent;
    border: 1px solid var(--color-primary);
    border-radius: 9999px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.copy-link-btn:hover {
    background: color-mix(in srgb, var(--color-primary) 6%, transparent);
}

.copy-link-btn:active {
    transform: scale(0.95);
}

.copy-link-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--palette-blueberry-300);
}

.copy-link-btn--secondary {
    color: var(--color-label, #666);
    border-color: var(--color-primary);
}

.copy-link-btn--secondary:hover {
    background: color-mix(in srgb, var(--color-label, #666) 6%, transparent);
}

html.none-mode .range-label {
    opacity: 0.38;
    pointer-events: none;
}

html.none-mode .loop-toggle-label {
    opacity: 0.38;
    pointer-events: none;
}

html.none-mode .rotation-group {
    opacity: 0.38;
    pointer-events: none;
}

/* ── Rotation thumbnail cards ── */

.rotation-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Section header row (label + power toggle) ── */

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* ── Rotation power toggle (macOS-style) ── */

.rotation-power-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.rotation-power-toggle input[type="checkbox"] {
    display: none;
}

.rotation-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--palette-blueberry-200);
    cursor: pointer;
    box-shadow: 0 0 0 2px transparent;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.rotation-option input[type="radio"] {
    display: none;
}

.rotation-option:has(input:checked) {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.rotation-option:hover {
    border-color: var(--color-primary-lighter);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(46, 43, 116, 0.15);
}

.rotation-option:has(input:checked):hover {
    border-color: white;
    box-shadow: 0 0 0 2px var(--primary-color), 0 4px 10px rgba(46, 43, 116, 0.15);
    transform: translateY(-1px);
}

.rotation-thumb {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--palette-blueberry-500);
}

.rotation-thumb .rot-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

/* ── Rotation hover demo animations ── */

@keyframes rot-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes rot-tilt {
    0% {
        transform: translateY(0);
    }

    25% {
        transform: translateY(-6px);
    }

    75% {
        transform: translateY(6px);
    }

    100% {
        transform: translateY(0);
    }
}

.rotation-option:hover .rotation-thumb--spin .rot-icon {
    animation: rot-spin 2.4s linear 3;
}

/* When Spin is active (checked), hovering previews switching to the opposite direction */
html:not(.spin-ccw) .rotation-option:has(input[value="spin"]:checked):hover .rotation-thumb--spin .rot-icon {
    animation: rot-spin-ccw 2.4s linear 3;
}

html.spin-ccw .rotation-option:has(input[value="spin"]:checked):hover .rotation-thumb--spin .rot-icon {
    animation: rot-spin 2.4s linear 3;
}

@keyframes rot-spin-ccw {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}

.rotation-option:hover .rotation-thumb--tilt .rot-icon {
    animation: rot-tilt 1.4s ease-in-out 3;
}

@keyframes rot-wobble {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(90deg) scale(1.1);
    }

    50% {
        transform: rotate(180deg) scale(1);
    }

    75% {
        transform: rotate(270deg) scale(1.1);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

.rotation-option:hover .rotation-thumb--wobble .rot-icon {
    animation: rot-wobble 1.6s ease-in-out 3;
}

/* ── Theme transition ────────────────────────────────────────────────────────── */

html {
    transition: background-color 0.25s, color 0.25s;
}

.container,
.controls-bar,
.settings-panel,
.radio-option,
.color-option,
select {
    transition: background 0.25s, border-color 0.25s, color 0.2s;
}



/* ── Rotation re-click pause hint ── */

.preset-group .thumb-card-wrap {
    min-width: 0;
    max-width: 100%;
}

.preset-group .thumb-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: 10px;
}

.preset-add-slot {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
}

.preset-add-slot:hover {
    border-color: var(--palette-blueberry-400);
    color: var(--palette-blueberry-500);
}

/* ── Advanced Settings (compact collapsible inside Theme box) ── */
.adv-settings {
    margin-top: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 4px;
}

.adv-settings>summary {
    cursor: pointer;
    font-size: var(--text-sm, 12px);
    font-weight: 600;
    color: var(--color-text-muted);
    outline: none;
    user-select: none;
    padding: 8px 0 4px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.adv-settings>summary::before {
    content: '›';
    display: inline-block;
    transition: transform 0.15s;
    font-size: 14px;
    line-height: 1;
}

.adv-settings[open]>summary::before {
    transform: rotate(90deg);
}

/* ── Programmatic selection state for preset thumbs ── */
.shading-option.is-selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--color-primary);
}

/* ── Custom slot overwrite button ── */
.preset-save-btn {
    display: none;
    font-size: 9px;
    font-weight: 700;
    font-family: inherit;
    color: var(--color-primary);
    background: none;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 1px 5px;
    cursor: pointer;
    margin-top: 2px;
    white-space: nowrap;
    line-height: 1.4;
    transition: background 0.12s, color 0.12s;
}

.thumb-card-wrap:hover .preset-save-btn {
    display: block;
}

.preset-save-btn:hover {
    background: var(--color-primary);
    color: #fff;
}

/* ── Sidebar tabs ─────────────────────────────────────────────────────────── */

.sidebar-tabs {
    display: none;
    /* hidden until app loaded */
    flex-shrink: 0;
    border-bottom: 2px solid var(--border-color);
    background: var(--color-surface);
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 9;
}

html.loaded .sidebar-tabs {
    display: flex;
}

.sidebar-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 10px 8px;
    font-size: var(--text-sm, 12px);
    font-weight: 600;
    color: var(--color-label);
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.01em;
    transition: color 0.12s, border-color 0.12s;
}

.sidebar-tab.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.sidebar-tab:hover:not(.is-active) {
    color: var(--color-on-surface, var(--color-text));
}

/* ── Tab panels ── */

.tab-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tab-panel[hidden] {
    display: none;
}

/* ── Box headings (Model / Environment cards) ── */
.box-heading {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: -0.3px;
    margin-bottom: 2px;
}

.box-sub-heading {
    font-size: var(--text-sm, 12px);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    opacity: 0.7;
}

/* ── Slider sections (always expanded) ── */
.adv-section {
    margin-top: 12px;
}

.model-sliders,
.light-sliders {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

/* Extra sliders revealed by Show All */
.adv-extra {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 4px;
}

.adv-extra[hidden] {
    display: none;
}

/* Show All / Show Less underlined text link */
.show-all-link {
    display: inline-block;
    background: none;
    border: none;
    padding: 4px 0;
    margin-top: 10px;
    font-size: var(--text-sm, 12px);
    font-weight: 500;
    font-family: inherit;
    color: var(--color-text-muted);
    text-decoration: underline;
    cursor: pointer;
}

.show-all-link:hover {
    color: var(--color-text);
}

/* Fine Tuning row at bottom of Theme panel */
.fine-tuning-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 0 4px;
}

.fine-tuning-hint {
    font-size: var(--text-xs, 10px);
    color: var(--color-text-muted);
    opacity: 0.65;
    padding-left: 22px;
}

/* Checkbox row */
.adv-section-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm, 12px);
    color: var(--color-text);
    padding: 4px 0;
}

/* ── Preset group inside new cards (no extra margin needed) ── */
#modelBox .preset-group,
#environmentBox .preset-group {
    margin-top: 0;
    margin-bottom: 0;
}