/*
  GG LaserPrep Studio Pro -- styles.css
  Grain & Glow -- Stephanie Adams
  Mobile-first dark professional laser studio UI
*/

/* --- RESET & ROOT ------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-base: #0d0d0f;
    --bg-panel: #13131a;
    --bg-section: #1a1a24;
    --bg-input: #0f0f18;
    --bg-hover: #22222e;
    --bg-active: #2a2a3a;

    --accent: #e8a045;
    --accent-dim: #b07228;
    --accent-glow: rgba(232, 160, 69, 0.15);
    --accent-pulse: rgba(232, 160, 69, 0.08);

    --text-primary: #e8e8f0;
    --text-secondary: #9494a8;
    --text-muted: #5a5a70;
    --text-accent: #e8a045;

    --border: #252535;
    --border-light: #2e2e42;

    --ok: #4caf86;
    --warn: #e8a045;
    --error: #e05454;
    --info: #5b8dee;

    --hdr-h: 48px;
    --footer-h: 52px;
    --panel-l: 270px;
    --panel-r: 200px;
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;

    --font-ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

    --touch: 44px;
}

html,
body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* --- SCROLLBARS --------------------------------------- */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: var(--bg-panel);
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* --- HEADER ------------------------------------------- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--hdr-h);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 200;
    padding: 0 8px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding-right: 10px;
    border-right: 1px solid var(--border);
}

.brand-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.brand-sub {
    font-size: 9px;
    color: var(--text-accent);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

@media (max-width: 380px) {
    .brand-sub {
        display: none;
    }
    .brand-name {
        font-size: 11px;
    }
}

/* --- HEADER NAV (desktop) ----------------------------- */
.header-nav {
    display: none;
    align-items: center;
    gap: 2px;
    margin: 0 8px;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 5px 11px;
    font-size: 11.5px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    font-family: var(--font-ui);
    white-space: nowrap;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.nav-btn.active {
    color: var(--accent);
    background: var(--accent-pulse);
    border: 1px solid var(--accent-dim);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
    flex-shrink: 0;
}

.hdr-btn {
    background: var(--bg-section);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    min-width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.hdr-btn:active {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.hdr-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.cv-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    padding: 3px 6px;
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

@media (max-width: 500px) {
    .cv-status {
        display: none;
    }
}

.cv-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.cv-dot.ready {
    background: var(--ok);
    box-shadow: 0 0 4px var(--ok);
}
.cv-dot.error {
    background: var(--error);
}
.cv-dot.loading {
    background: var(--warn);
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* --- BOTTOM TAB NAV (mobile) -------------------------- */
.tab-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-h);
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 9px;
    cursor: pointer;
    padding: 4px 2px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: color 0.15s;
    min-height: var(--footer-h);
    font-family: var(--font-ui);
}

.tab-btn .tab-icon {
    font-size: 18px;
    line-height: 1;
}
.tab-btn .tab-label {
    font-size: 9px;
    letter-spacing: 0.03em;
}
.tab-btn.active {
    color: var(--accent);
    border-top: 2px solid var(--accent);
}

/* --- MAIN LAYOUT -------------------------------------- */
.studio-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: var(--hdr-h);
    padding-bottom: var(--footer-h);
}

/* --- PANEL DRAWER (mobile) ---------------------------- */
.panel-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--footer-h);
    background: var(--bg-panel);
    border-top: 1px solid var(--border-light);
    z-index: 150;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 65vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel-drawer.open {
    transform: translateY(0);
}

.drawer-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.drawer-pip {
    width: 36px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
}

.drawer-title {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-accent);
    padding: 0 16px 8px;
}

/* --- SECTION ----------------------------------------- */
.ctrl-section {
    padding: 10px 12px 14px;
    border-bottom: 1px solid var(--border);
}
.ctrl-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* --- INPUT ROWS -------------------------------------- */
.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 36px;
}

.input-row label {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 80px;
    flex-shrink: 0;
}

.input-row input[type="number"],
.input-row select {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
    min-width: 0;
    min-height: 36px;
}

.input-row input:focus,
.input-row select:focus {
    outline: none;
    border-color: var(--accent-dim);
}

.input-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
}

.input-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-panel);
}

.input-row input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-panel);
}

.range-val {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-accent);
    min-width: 32px;
    text-align: right;
}

/* --- PIXEL INFO -------------------------------------- */
.pixel-info {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-align: center;
    padding: 5px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-top: 4px;
}

/* --- TOGGLE BUTTONS ---------------------------------- */
.toggle-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    min-height: 36px;
    min-width: 56px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.toggle-btn[data-on="true"] {
    background: var(--accent-glow);
    border-color: var(--accent-dim);
    color: var(--accent);
}

.toggle-btn:active {
    background: var(--bg-hover);
}

/* --- SLIDER GROUP ------------------------------------ */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-item {
    display: grid;
    grid-template-columns: 100px 1fr 36px;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    min-height: 36px;
}

.slider-item label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slider-item input[type="range"] {
    accent-color: var(--accent);
    cursor: pointer;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
}

.slider-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-panel);
}

.slider-item input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-panel);
}

.slider-item .sv {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-accent);
    text-align: right;
}

/* --- PIPELINE STEPS ---------------------------------- */
.pipeline-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.pipe-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
}

.pipe-step:active {
    background: var(--bg-hover);
}

.pipe-step input[type="checkbox"] {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

/* --- CURVES CANVAS ----------------------------------- */
.curves-canvas {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    cursor: crosshair;
    touch-action: none;
}

.curves-btns {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.sm-btn {
    flex: 1;
    background: var(--bg-section);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.sm-btn:active {
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* --- HISTOGRAM --------------------------------------- */
.histogram-canvas {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
}

.hist-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 2px;
}

/* --- MATERIAL SELECT --------------------------------- */
.material-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    min-height: var(--touch);
    font-family: var(--font-ui);
}

.mat-preset-box {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-input);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.mat-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 4px;
}

.mat-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- DITHER LISTS ------------------------------------ */
.dither-list {
    display: flex;
    flex-direction: column;
}

.dither-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 9px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
}

.dither-list label:active {
    background: var(--bg-hover);
}

.dither-list input[type="radio"] {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

/* --- EXPORT BUTTONS ---------------------------------- */
.export-btn {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg-section);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    margin-bottom: 6px;
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.export-btn:active {
    background: var(--bg-hover);
    border-color: var(--accent-dim);
    color: var(--accent);
}

.export-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ei-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.ei-row span:first-child {
    color: var(--text-muted);
}
.ei-row span:last-child {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* --- PRESET CONTROLS --------------------------------- */
.preset-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
    min-height: var(--touch);
    font-family: var(--font-ui);
}

.preset-input:focus {
    outline: none;
    border-color: var(--accent-dim);
}

.full-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: var(--bg-section);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    margin-bottom: 6px;
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.full-btn:active {
    border-color: var(--accent-dim);
    color: var(--text-primary);
}

.upload-label {
    cursor: pointer;
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preset-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: var(--touch);
}

.preset-item-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preset-item-material {
    font-size: 10px;
    color: var(--accent);
}

.preset-load-btn,
.preset-del-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    min-height: 32px;
    -webkit-tap-highlight-color: transparent;
    font-family: var(--font-ui);
}

.preset-load-btn:active {
    color: var(--ok);
    border-color: var(--ok);
}
.preset-del-btn:active {
    color: var(--error);
    border-color: var(--error);
}

.empty-state {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 8px;
    font-style: italic;
}

/* --- DROP ZONE --------------------------------------- */
.drop-zone {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
    background: var(--bg-base);
    transition: background 0.2s;
}

.drop-zone.drag-over {
    background: var(--accent-pulse);
}
.drop-zone.hidden {
    display: none;
}

.drop-inner {
    text-align: center;
    padding: 32px 24px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    max-width: 340px;
    width: 90%;
}

.drop-zone.drag-over .drop-inner {
    border-color: var(--accent);
}

.drop-icon {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1;
}

.drop-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.drop-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.drop-formats {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
}

.drop-tap-hint {
    margin-top: 14px;
    font-size: 12px;
    color: var(--accent);
}

/* --- CANVAS AREA ------------------------------------- */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* --- PREVIEW TOOLBAR --------------------------------- */
.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.preview-toolbar::-webkit-scrollbar {
    display: none;
}

.preview-modes {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.pm-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
    min-height: 34px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.pm-btn:active {
    color: var(--text-primary);
}

.pm-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent-dim);
    color: var(--accent);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    flex-shrink: 0;
}

.zm-btn {
    background: var(--bg-section);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.zm-btn:active {
    color: var(--text-primary);
}

#zoomLabel {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    min-width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.process-btn {
    background: var(--accent);
    border: none;
    color: #000;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    height: 34px;
    flex-shrink: 0;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: var(--font-ui);
}

.process-btn:active {
    background: #f0b060;
}

.process-btn.processing {
    background: var(--accent-dim);
    cursor: wait;
    animation: pulse 1s infinite;
}

/* --- CANVAS VIEWPORT --------------------------------- */
.canvas-viewport {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    background: repeating-linear-gradient(0deg, transparent, transparent 19px, var(--border) 19px, var(--border) 20px),
        repeating-linear-gradient(90deg, transparent, transparent 19px, var(--border) 19px, var(--border) 20px);
    background-color: var(--bg-base);
}

.canvas-container {
    position: relative;
    display: inline-block;
    box-shadow: 0 0 0 1px var(--border), 0 8px 32px rgba(0, 0, 0, 0.5);
    margin: 16px;
    flex-shrink: 0;
}

#mainCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- SPLIT HANDLE ------------------------------------ */
.split-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
    cursor: ew-resize;
    z-index: 5;
    box-shadow: 0 0 8px var(--accent);
    touch-action: none;
}

.split-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-base);
}

/* --- STATUS BAR -------------------------------------- */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    height: 28px;
}

#statusMsg {
    font-size: 11px;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-bar {
    width: 80px;
    height: 3px;
    background: var(--bg-section);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s;
}

#statusCoords {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    min-width: 70px;
    text-align: right;
    flex-shrink: 0;
}

/* --- TOASTS ------------------------------------------ */
.toast-container {
    position: fixed;
    bottom: calc(var(--footer-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    width: 90%;
    max-width: 340px;
}

.toast {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 12.5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.2s ease;
    text-align: center;
}

.toast.ok {
    border-left-color: var(--ok);
}
.toast.error {
    border-left-color: var(--error);
}
.toast.info {
    border-left-color: var(--info);
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* --- MATERIAL LIBRARY (in panel) --------------------- */
#matPresetList {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mat-lib-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
}

.mat-lib-item:active {
    border-color: var(--accent-dim);
}

.mat-lib-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mat-lib-name {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- RIGHT PANEL (desktop) --------------------------- */
.panel-right {
    display: none;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 0;
}

.quick-section {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
}
.quick-section:last-child {
    border-bottom: none;
}

.q-title {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.quick-sliders {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.qs-item {
    display: grid;
    grid-template-columns: 54px 1fr;
    align-items: center;
    gap: 6px;
    min-height: 28px;
}

.qs-item label {
    font-size: 10px;
    color: var(--text-secondary);
}

.qs-item input[type="range"] {
    accent-color: var(--accent);
    height: 3px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
}

.qs-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.mini-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}

.mini-mode-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 4px;
    font-size: 9.5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    min-height: 28px;
    font-family: var(--font-ui);
}

.mini-mode-btn.active {
    color: var(--accent);
    border-color: var(--accent-dim);
    background: var(--accent-pulse);
}
.mini-mode-btn:hover {
    color: var(--text-primary);
}

.burn-canvas {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #1a0a00;
    margin-bottom: 6px;
}

.wgl-status {
    font-size: 10px;
    color: var(--text-muted);
    padding: 4px 6px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    word-break: break-all;
}

/* --- DESKTOP (min-width: 768px) ---------------------- */
@media (min-width: 768px) {
    :root {
        --hdr-h: 46px;
        --footer-h: 0px;
    }

    .tab-nav {
        display: none;
    }

    .header-nav {
        display: flex;
    }

    .studio-layout {
        display: grid;
        grid-template-columns: var(--panel-l) 1fr var(--panel-r);
        grid-template-rows: 1fr;
        height: 100vh;
        padding-top: var(--hdr-h);
        padding-bottom: 0;
    }

    .panel-drawer {
        position: static;
        transform: none;
        max-height: none;
        height: 100%;
        border-radius: 0;
        border-top: none;
        border-right: 1px solid var(--border);
        overflow-y: auto;
        display: none;
        background: var(--bg-panel);
    }

    .panel-drawer.active-panel {
        display: block;
    }

    .drawer-handle {
        display: none;
    }
    .drawer-title {
        display: none;
    }

    .panel-right {
        display: block;
    }

    /* Tighter spacing on desktop */
    html,
    body {
        font-size: 12.5px;
    }

    .slider-item {
        grid-template-columns: 90px 1fr 32px;
        min-height: 28px;
    }
    .slider-item label {
        font-size: 10.5px;
    }
    .slider-item .sv {
        font-size: 10px;
    }
    .slider-item input[type="range"]::-webkit-slider-thumb {
        width: 14px;
        height: 14px;
    }

    .input-row {
        min-height: 28px;
    }
    .input-row label {
        font-size: 10.5px;
        min-width: 72px;
    }
    .input-row input[type="number"],
    .input-row select {
        min-height: 28px;
        font-size: 11px;
        padding: 3px 6px;
    }
    .input-row input[type="range"]::-webkit-slider-thumb {
        width: 14px;
        height: 14px;
    }

    .pipe-step {
        font-size: 11px;
        padding: 4px 4px;
        min-height: 26px;
    }
    .pipe-step input[type="checkbox"] {
        width: 14px;
        height: 14px;
    }

    .dither-list label {
        font-size: 11px;
        padding: 4px 4px;
        min-height: 28px;
    }
    .dither-list input[type="radio"] {
        width: 14px;
        height: 14px;
    }

    .export-btn {
        padding: 8px 10px;
        font-size: 11.5px;
        min-height: 34px;
    }

    .ctrl-section {
        padding: 8px 10px 12px;
    }
    .section-title {
        font-size: 9px;
        margin-bottom: 8px;
    }

    .toggle-btn {
        min-height: 28px;
        padding: 3px 10px;
        font-size: 11px;
    }
    .sm-btn {
        min-height: 30px;
        padding: 5px;
        font-size: 11px;
    }
    .full-btn {
        min-height: 30px;
        font-size: 11px;
    }
    .preset-input {
        min-height: 30px;
        font-size: 12px;
    }

    .mat-lib-item {
        min-height: 32px;
        padding: 6px 8px;
    }
    .mat-lib-name {
        font-size: 11px;
    }

    .preview-toolbar {
        padding: 4px 8px;
        gap: 3px;
    }
    .pm-btn {
        padding: 4px 9px;
        font-size: 10.5px;
        min-height: 28px;
    }
    .zm-btn {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }
    .process-btn {
        font-size: 11px;
        height: 28px;
        padding: 0 12px;
    }

    .toast-container {
        bottom: 16px;
        left: auto;
        right: 16px;
        transform: none;
        width: auto;
        max-width: 300px;
    }
    .toast {
        text-align: left;
    }
}

/* --- UTILITY ----------------------------------------- */
.hidden {
    display: none !important;
}

*:focus-visible {
    outline: 2px solid var(--accent-dim);
    outline-offset: 2px;
}

/* --- BUY ME A COFFEE --------------------------------- */
.coffee-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: var(--accent);
    color: #0d0d0f;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: var(--radius);
    margin-top: 4px;
    transition: background 0.15s, transform 0.1s;
}
.coffee-btn:hover {
    background: #f0b060;
    transform: translateY(-1px);
}
.coffee-btn:active {
    transform: translateY(0);
}
.coffee-sub {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}
