:root {
    --bg-base: #0a0f1d;
    --bg-card: rgba(17, 24, 39, 0.88);
    --bg-card-sub: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --accent: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-focus: #60a5fa;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
}

.app-header {
    max-width: 1380px;
    width: 100%;
    margin: 0 auto 0.75rem auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    background: linear-gradient(120deg, #93c5fd, #ffffff, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-stats-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.badge-version {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    flex-shrink: 0;
}

.studio-container {
    max-width: 1380px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    flex: 1;
    min-width: 0;
}

@media (max-width: 1080px) {
    .studio-container {
        grid-template-columns: minmax(0, 1fr);
    }
}

.panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    min-width: 0;
    max-width: 100%;
}

/* Mode Tabs */
.tabs-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 3px;
    margin-bottom: 0.85rem;
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 6px;
    border-radius: calc(var(--radius-md) - 4px);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.tab-btn:not(.active):hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

/* Form Controls */
.form-group {
    margin-bottom: 0.85rem;
}

.form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    font-weight: 500;
    color: #cbd5e1;
    margin-bottom: 0.35rem;
}

.form-label .hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-text {
    width: 100%;
    padding: 0.65rem 0.85rem;
    padding-right: 5.5rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.25s ease;
}

.input-text:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    background: rgba(15, 23, 42, 0.95);
}

.input-action-btn {
    position: absolute;
    right: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.input-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* File Upload Dropzone */
.dropzone {
    border: 2px dashed rgba(96, 165, 250, 0.35);
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.dropzone-icon {
    width: 42px;
    height: 42px;
    color: #60a5fa;
    margin-bottom: 0.5rem;
}

.dropzone-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.25rem;
}

.dropzone-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.dropzone-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 0.75rem;
}

.btn-mini {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
    color: #cbd5e1;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-mini:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.btn-mini.primary {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
}

.btn-mini.primary:hover {
    background: rgba(59, 130, 246, 0.35);
}

/* Subpanels & Presets */
.controls-subpanel {
    background: var(--bg-card-sub);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin-top: 0.65rem;
}

.section-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #93c5fd;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-bottom: 0.65rem;
}

.btn-preset {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-glass);
    color: #cbd5e1;
    padding: 6px 3px;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.btn-preset svg {
    width: 14px;
    height: 14px;
}

.btn-preset:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #fff;
}

.btn-preset.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.range-group {
    margin-bottom: 0.65rem;
}

.range-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: #cbd5e1;
    margin-bottom: 0.25rem;
}

.range-value {
    color: #60a5fa;
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    cursor: pointer;
}

.toggle-label {
    font-size: 0.92rem;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #3b82f6;
    cursor: pointer;
}

.color-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 1rem;
}

.color-item {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-glass);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-item label {
    font-size: 0.85rem;
    color: #cbd5e1;
}

.color-item input[type="color"] {
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.tip-box {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.8rem;
    color: #93c5fd;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right Panel: Preview Area */
.preview-panel {
    position: sticky;
    top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.preview-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    min-height: 540px;
    justify-content: center;
}

.preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border-glass);
}

.preview-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.6);
    padding: 3px 9px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

.canvas-wrapper {
    position: relative;
    max-width: 100%;
    min-height: 480px;
    max-height: 580px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: repeating-conic-gradient(#1e293b 0% 25%, #0f172a 0% 50%) 50% / 20px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-glass);
    padding: 12px;
}

#mainCanvas {
    max-width: 100%;
    max-height: 550px;
    height: auto;
    width: auto;
    display: block;
    cursor: default;
    user-select: none;
    touch-action: none;
}

#mainCanvas.can-drag {
    cursor: grab;
}

#mainCanvas.is-dragging {
    cursor: grabbing;
}

.action-toolbar {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 0.85rem;
}

.mobile-sticky-bar {
    display: none;
}

.btn-text-mobile,
.preview-title-mobile {
    display: none;
}

.btn-action {
    padding: 0.68rem 0.85rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s ease;
    text-decoration: none;
}

.btn-action.download-jpg {
    background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
    border: none;
}

.btn-action.download-jpg:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(14, 165, 233, 0.65);
}

.btn-action.download-png {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-action.download-png:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-action.copy-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    border: 1px solid var(--border-glass);
}

.btn-action.copy-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

/* QR Style Grid */
/* Frame Styles (Horizontal Scrollable Grid) */
.frame-scroll-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 6px 2px 10px 2px;
    margin-top: 6px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.frame-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.frame-scroll-container::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 3px;
}

.frame-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.4);
    border-radius: 3px;
}

.frame-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

.btn-frame {
    flex: 0 0 68px;
    background: rgba(15, 23, 42, 0.85);
    border: 2px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    padding: 6px 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.btn-frame:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
    color: #fff;
    transform: translateY(-2px);
}

/* Highlight active frame with green border like user screenshot */
.btn-frame.active {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.frame-preview-box {
    width: 44px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 2px;
}

.frame-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.frame-label {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
    text-align: center;
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 0.65rem;
}

.btn-style {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-glass);
    color: #cbd5e1;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.btn-style svg {
    width: 20px;
    height: 20px;
}

.btn-style:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: #fff;
}

.btn-style.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Logo Box */
.logo-upload-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.logo-thumb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    object-fit: cover;
    background: #ffffff;
    display: none;
}

.btn-action:active {
    transform: translateY(0);
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #3b82f6;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

#tempQrContainer, #imageInput {
    display: none;
}

footer {
    max-width: 1380px;
    width: 100%;
    margin: 0.75rem auto 0 auto;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Stats Strip */
.stats-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--border-glass);
    padding: 6px 14px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    color: #cbd5e1;
    white-space: nowrap;
}

.stat-divider {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.12);
}

.stat-label {
    color: var(--text-muted);
}

.stat-val {
    font-weight: 700;
    color: #38bdf8;
    font-variant-numeric: tabular-nums;
}

.stat-icon {
    color: #94a3b8;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    display: inline-block;
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    body {
        padding: 0.5rem 0.5rem 72px 0.5rem;
    }

    .app-header {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 10px !important;
        margin-bottom: 0.45rem !important;
        gap: 8px !important;
    }

    .brand-box {
        gap: 6px;
        flex: 0 0 auto;
    }

    .brand-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .brand-title {
        font-size: 0.95rem;
        line-height: 1.2;
        white-space: nowrap;
    }

    .brand-subtitle {
        display: none !important;
    }

    .header-stats-wrapper {
        display: flex;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
    }

    .stats-strip {
        padding: 4px 8px !important;
        gap: 5px !important;
        width: auto !important;
        border-radius: 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    }

    .stat-pill {
        font-size: 0.74rem !important;
        gap: 3px !important;
    }

    .stat-label {
        display: none !important;
    }

    .badge-version {
        display: none !important;
    }

    /* Mobile Layout Order: Preview at Top */
    .studio-container {
        display: flex;
        flex-direction: column;
        gap: 0.65rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .studio-container > * {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .preview-panel {
        order: -1;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-bottom: 0.25rem;
    }

    .preview-card {
        padding: 0.85rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .preview-header {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        margin-bottom: 0.5rem;
    }

    .preview-title {
        font-size: 0.88rem;
    }

    .preview-info {
        font-size: 0.72rem;
    }

    /* Compact Canvas for Mobile */
    .canvas-wrapper {
        min-height: 220px;
        max-height: 320px;
        padding: 8px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #mainCanvas {
        max-height: 300px;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain;
    }

    .btn-text-desktop,
    .preview-title-desktop {
        display: none !important;
    }

    .btn-text-mobile,
    .preview-title-mobile {
        display: inline !important;
    }

    /* Mobile 3-Column Single Row Action Buttons */
    .action-toolbar {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        margin-top: 8px !important;
        width: 100% !important;
    }

    .action-toolbar .btn-action {
        padding: 9px 4px !important;
        font-size: 0.82rem !important;
        font-weight: 600 !important;
        min-height: 40px !important;
        border-radius: var(--radius-sm) !important;
        gap: 4px !important;
        white-space: nowrap !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .action-toolbar .btn-action svg {
        width: 16px !important;
        height: 16px !important;
        flex-shrink: 0 !important;
    }

    /* Controls Subpanel on Mobile */
    .panel {
        padding: 0.85rem 0.75rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .controls-subpanel,
    #standardControlsSection,
    #posterControlsSection,
    .range-group,
    .preset-grid,
    .style-grid,
    .color-row {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .frame-scroll-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: auto !important;
    }

    .tabs-header {
        padding: 3px;
        gap: 3px;
        margin-bottom: 0.65rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .tab-btn {
        padding: 0.6rem 0.35rem;
        font-size: 0.82rem;
        gap: 4px;
    }

    .tab-btn svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .form-group {
        margin-bottom: 0.85rem;
    }

    .form-label {
        font-size: 0.84rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .form-label .hint {
        font-size: 0.72rem;
    }

    /* Frame Carousel on Mobile */
    .frame-scroll-container {
        gap: 8px;
        scroll-snap-type: x mandatory;
        padding: 4px 2px 10px 2px;
        -webkit-overflow-scrolling: touch;
    }

    .btn-frame {
        flex: 0 0 74px;
        scroll-snap-align: start;
        padding: 8px 4px;
    }

    .btn-frame:hover {
        transform: none;
    }

    /* Touch Sliders */
    input[type="range"] {
        height: 8px;
        margin: 6px 0;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    }

    /* Presets on Mobile */
    .preset-grid {
        gap: 3px;
    }

    .btn-preset {
        padding: 8px 2px;
        font-size: 0.72rem;
        min-height: 36px;
    }

    /* Mobile Sticky Bottom Quick-Action Bar */
    .mobile-sticky-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 990;
        background: rgba(15, 23, 42, 0.94);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--border-glass);
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
        gap: 10px;
        box-shadow: 0 -6px 25px rgba(0, 0, 0, 0.6);
    }

    .btn-sticky-preview {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid var(--border-glass);
        color: #e2e8f0;
        font-size: 0.88rem;
        font-weight: 600;
        border-radius: var(--radius-sm);
        padding: 10px 8px;
        cursor: pointer;
        min-height: 44px;
        transition: background 0.2s;
    }

    .btn-sticky-preview:active {
        background: rgba(255, 255, 255, 0.16);
    }

    .btn-sticky-download {
        flex: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
        border: none;
        color: #ffffff;
        font-size: 0.95rem;
        font-weight: 700;
        border-radius: var(--radius-sm);
        padding: 10px 12px;
        cursor: pointer;
        min-height: 44px;
        box-shadow: 0 2px 10px rgba(56, 189, 248, 0.4);
        transition: transform 0.15s;
    }

    .btn-sticky-download:active {
        transform: scale(0.98);
    }

    footer {
        padding: 0.5rem 0.5rem 75px 0.5rem !important;
        font-size: 0.72rem !important;
        line-height: 1.4 !important;
        max-width: 100% !important;
    }
}
