:root {
    --bg-color: #020617;
    --panel-bg: rgba(30, 41, 59, 0.75);
    --control-bg: rgba(2, 6, 23, 0.6);
    --control-bg-hover: rgba(51, 65, 85, 0.8);
    --accent: #3b82f6;
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --radius: 12px;
    --glass-border: rgba(255, 255, 255, 0.15);
    --app-scale: 1;
    --frame-thick: 5px;
    --swatch-size: 24px;
    --bg-gradient-1: rgba(59, 130, 246, 0.15);
    --bg-gradient-2: rgba(139, 92, 246, 0.15);
    --input-text: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --sidebar-bg: rgba(2, 6, 23, 0.4);
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.8);
    --control-bg: rgba(241, 245, 249, 0.8);
    --control-bg-hover: rgba(226, 232, 240, 0.9);
    --accent: #2563eb;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-border: rgba(0, 0, 0, 0.1);
    --bg-gradient-1: rgba(37, 99, 235, 0.05);
    --bg-gradient-2: rgba(124, 58, 237, 0.05);
    --input-text: #0f172a;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --sidebar-bg: rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg-color: #f8fafc;
        --panel-bg: rgba(255, 255, 255, 0.8);
        --control-bg: rgba(241, 245, 249, 0.8);
        --control-bg-hover: rgba(226, 232, 240, 0.9);
        --accent: #2563eb;
        --text-main: #0f172a;
        --text-muted: #475569;
        --glass-border: rgba(0, 0, 0, 0.1);
        --bg-gradient-1: rgba(37, 99, 235, 0.05);
        --bg-gradient-2: rgba(124, 58, 237, 0.05);
        --input-text: #0f172a;
        --shadow-color: rgba(0, 0, 0, 0.1);
        --sidebar-bg: rgba(0, 0, 0, 0.04);
    }
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--bg-gradient-2) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Body never scrolls */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0; /* Full screen */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 320px 320px;
    gap: 0;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

@media (max-width: 1150px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        padding: 1rem;
    }
    .container {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        padding: 1.5rem;
        max-width: 600px;
        height: auto;
        overflow: visible;
        border-radius: 24px;
        margin: 0 auto;
        border: 1px solid var(--glass-border);
        box-shadow: 0 25px 50px -12px var(--shadow-color);
    }
}


.preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top:-1rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.base-bg-control {
    margin: 0.5rem 0.2rem 0 0;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 4.3rem;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

@media (max-width: 1150px) {
    h1 {
        font-size: 1.75rem;
    }

    .preview-header {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions button:first-child {
        flex: 1;
    }
}

.icon-canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: min(1024px, 68vh);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background-color: var(--control-bg);
    border-radius: 32px;
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 0 20px var(--shadow-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    /* Enable container queries to keep text proportional */
    container-type: inline-size;
}

@media (max-width: 1150px) {
    .icon-canvas-wrapper {
        width: 100%;
        aspect-ratio: 1/1;
        height: auto;
    }
}

.icon-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 100;
    border-radius: 32px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    filter: drop-shadow(0 0 10px var(--accent));
}

#loading-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* The actual icon layout */
.base-bg {
    position: absolute;
    width: 78%;
    height: 78%;
    aspect-ratio: 1/1;
    background: linear-gradient(90deg, #3b82f6, #1D0945);
    transition: all 0.3s ease, background 0.3s ease;
    overflow: hidden;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    /* Fix for overflow: hidden clipping breaking during transforms in some browsers */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    isolation: isolate;
}

.circle { border-radius: 50%; }
.roundrect { border-radius: 12%; }
.squircle { border-radius: 22%; }
.square { border-radius: 0; }

.base-frame {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 6;
    transition: all 0.3s ease;
}

.base-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    transition: all 0.3s ease;
    mix-blend-mode: overlay;
    opacity: 0;
}

.base-overlay.noise {
    opacity: 0.32;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    transform: translateZ(0);
}

.base-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    transition: all 0.3s ease;
    transform: translateZ(0);
}

.base-effects.effect-glow {
    box-shadow: inset 0 0 60px rgba(255, 255, 255, 0.4);
}

.base-effects.effect-vignette {
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4);
}

.base-effects.effect-glow.effect-vignette {
    box-shadow: 
        inset 0 0 60px rgba(255, 255, 255, 0.4),
        inset 0 0 60px rgba(0, 0, 0, 0.4);
}

/* Funny/Extra Effects */
.base-bg.effect-deep-fried {
    filter: contrast(300%) saturate(1000%) brightness(1.2) sepia(10%) !important;
}

.base-bg.effect-deep-fried::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.4;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 5;
}

.base-bg.effect-monochrome {
    filter: grayscale(100%) contrast(1.2) brightness(1.1) !important;
}

.base-effects.effect-crt {
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.04));
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0.8;
}

.base-effects.effect-crt::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 11;
    pointer-events: none;
    animation: crt-flicker 0.15s infinite;
}

@keyframes crt-flicker {
    0% { opacity: 0.1; }
    50% { opacity: 0.15; }
    100% { opacity: 0.1; }
}

/* Glossy Shine Effect */
.base-frame.shine {
    background: transparent;
    overflow: hidden;
}

.base-frame.shine::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        transparent 28.99%, 
        rgba(255, 255, 255, 0) 33.19%, 
        rgba(255, 255, 255, 0.5) 53.78%, 
        rgba(255, 255, 255, 0.1) 100%
    );
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.8;
}

/* Border Effect */
.base-frame.border {
    border: var(--frame-thick) solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.2);
}

/* Metallic Effect */
.base-frame.metallic {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 35%,
        rgba(255, 255, 255, 0.4) 45%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.4) 55%,
        rgba(255, 255, 255, 0) 65%,
        rgba(255, 255, 255, 0) 100%
    );
    mix-blend-mode: overlay;
    opacity: 0.8;
}

/* Glass Effect - Semi-transparent icon + Border styles */
.base-bg.frame-glass {
    backdrop-filter: blur(12px) brightness(1.5);
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.base-bg.frame-glass .base-text,
.base-bg.frame-glass .base-icon {
    opacity: 0.85;
    filter: brightness(1.2);
}

.base-frame.glass {
    border: var(--frame-thick) solid rgba(255, 255, 255, 0.5);
    box-shadow: 
        inset 0 0 20px rgba(255, 255, 255, 0.2),
        0 10px 30px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    z-index: 1; /* Place behind text if we want text sharp */
}

/* Emboss Effect */
.base-frame.emboss {
    box-shadow: 
        inset 4px 4px 8px rgba(255, 255, 255, 0.4),
        inset -4px -4px 8px rgba(0, 0, 0, 0.5),
        0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Ensure text is above the glass frame when in glass mode for sharpness */
.base-bg.frame-glass .base-text {
    z-index: 10;
}

.base-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.3));
    transition: all 0.3s ease, filter 0.3s ease;
    z-index: 1; /* Behind text and overlays */
    background: transparent !important;
    will-change: transform;
}

.base-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    z-index: 2;
    pointer-events: none;
    user-select: none;
    transition: all 0.3s ease;
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: normal;
    padding: 10%;
}

.badge-container {
    position: absolute;
    width: 48%;
    height: 48%;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 12px 20px rgba(0,0,0,0.4));
    transition: all 0.3s ease;
    z-index: 10;
}

/* Badge Position Variants */
.badge-container.pos-top-left { top: 8%; left: 8%; }
.badge-container.pos-top-right { top: 8%; right: 8%; }
.badge-container.pos-bottom-left { bottom: 8%; left: 8%; }
.badge-container.pos-bottom-right { bottom: 8%; right: 8%; }

/* Base Image Compensation - opposite corner of badge */
.icon-canvas.pos-top-left .base-bg { bottom: 4%; right: 4%; }
.icon-canvas.pos-top-right .base-bg { bottom: 4%; left: 4%; }
.icon-canvas.pos-bottom-left .base-bg { top: 4%; right: 4%; }
.icon-canvas.pos-bottom-right .base-bg { top: 4%; left: 4%; }

.badge-shape {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--accent);
    transition: all 0.3s ease;
}

.badge-shape.circle { border-radius: 50%; }
.badge-shape.roundrect { border-radius: 20%; }
.badge-shape.square-hard { border-radius: 0%; }
.badge-shape.squircle {
    border-radius: 22%;
}
.badge-shape.hexagon {
    clip-path: polygon(50% 0%, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%);
}
.badge-shape.hexagon-h {
    clip-path: polygon(25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0% 50%);
}
.badge-shape.diamond {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.badge-shape.shield {
    clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 50% 100%, 0% 75%);
}

.badge-icon {
    position: relative;
    color: white;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 1;
    width: 85%;
    height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.badge-icon span {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    line-height: 1.1;
    display: block;
    text-align: center;
    width: 100%;
}

.badge-icon.diamond-scaling {
    transform: scale(0.7);
}

.badge-icon i, .badge-icon svg {
    width: 100%;
    height: 100%;
}

.controls-section {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 1.25rem;
    border-left: 1px solid var(--glass-border);
    padding: 2.5rem 1.75rem;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    zoom: var(--app-scale);
    background: var(--sidebar-bg); /* Use theme-aware variable */
    box-shadow: inset 10px 0 30px -10px rgba(0, 0, 0, 0.3); /* Depth shadow */
}

.controls-section::-webkit-scrollbar {
    width: 6px;
}

.controls-section::-webkit-scrollbar-track {
    background: transparent;
}

.controls-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.controls-section::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 1150px) {
    .controls-section {
        border-left: none;
        padding: 1.5rem;
        max-height: none;
        overflow-y: visible;
        zoom: 1 !important;
        background: transparent;
        box-shadow: none;
    }
}

.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    height: 100%;
    padding: 2.5rem 2rem;
    overflow: hidden;
    zoom: var(--app-scale);
    position: relative;
    z-index: 2; /* Sit above the darker side panels */
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.25); /* Subtle shadow onto the controls */
}

@media (max-width: 1150px) {
    .preview-section {
        zoom: 1 !important;
        height: auto;
        padding: 1rem;
    }
}

.char-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s ease;
}

.char-count.at-limit {
    color: #ef4444;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group.disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.5);
    cursor: not-allowed;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
    display: block;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.label-row label {
    margin-bottom: 0;
}

.base-color-picker {
    position: relative;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--glass-border);
    cursor: pointer;
    background: #ffffff;
    transition: all 0.2s;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.base-color-picker:hover {
    transform: scale(1.1);
    border-color: rgba(255,255,255,0.4);
}

.base-color-picker input[type="color"] {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0;
    cursor: pointer;
}

input[type="text"], 
input[type="number"],
select {
    width: 100%;
    background: var(--control-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--input-text);
    font-family: inherit;
    outline: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.2s cubic-bezier(.36,.07,.19,.97) both;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.shape-btn {
    background: var(--control-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
}

.shape-btn:hover {
    background: var(--control-bg-hover);
}

.shape-btn.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-main);
}

@media (max-width: 1150px) {
    .shape-btn {
        padding: 0.75rem 0.5rem; /* Larger touch targets */
    }
}

.compact-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem;
    align-items: flex-start;
}

#base-angle-group {
    margin-top: 1.25rem;
}

.shape-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
}

.shape-grid-4x2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
}

.shape-btn-sm {
    font-size: 0.7rem;
    padding: 0.4rem 0.25rem;
}

.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding: 5px 2px; /* Give room for active rings */
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1150px) {
    .color-presets {
        overflow-x: auto;
    }
}

.color-presets::-webkit-scrollbar {
    display: none;
}

.color-swatch {
    width: var(--swatch-size);
    height: var(--swatch-size);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.custom-color-wrapper {
    position: relative;
    width: var(--swatch-size);
    height: var(--swatch-size);
    border-radius: 50%;
    cursor: pointer;
    background: conic-gradient(from 0deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    flex-shrink: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 1px var(--glass-border);
}

.custom-color-wrapper::after {
    content: '';
    position: absolute;
    inset: 2px;
    background-color: var(--swatch-color, #3b82f6);
    border-radius: 50%;
    transition: background-color 0.2s;
    z-index: 0;
    border: 2px solid rgba(15, 23, 42, 0.3);
}

.custom-color-wrapper.rect {
    width: var(--swatch-size);
    height: var(--swatch-size);
    border-radius: 50%;
    margin: 0 auto 0.2rem auto;
}

.custom-color-wrapper.rect::after {
    border-radius: 50%;
    inset: 2px;
    border: 2px solid rgba(15, 23, 42, 0.3);
    background-color: var(--swatch-color);
}

.custom-color-wrapper.rect:hover {
    filter: brightness(1.1);
}

.text-color-row {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    justify-content: space-between;
}

.text-input-wrapper {
    max-width: 210px;
}

.custom-color-wrapper i {
    position: relative;
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.custom-color-wrapper:hover {
    transform: scale(1.1);
}

.custom-color-wrapper.active {
}

.custom-color-wrapper input[type="color"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    padding: 0;
    margin: 0;
    opacity: 0;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    z-index: 2;
}

.custom-color-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.custom-color-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
}

.preview-actions {
    display: flex;
    gap: 1rem;
    width: 100%;
    margin-top: 0.5rem;
}

.preview-actions button {
    flex: 1;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (max-width: 1150px) {
    .preview-actions {
        flex-wrap: wrap;
    }
    
    .preview-actions button.primary {
        width: 100%;
        flex: none;
    }
    
    .preview-actions button.secondary {
        flex: 1;
    }
}

button.primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button.primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

button.secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

button.secondary.success {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
}

button.danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button i {
    width: 16px;
    height: 16px;
}

button.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* --- Theme Toggle --- */
.theme-toggle {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--control-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-main);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                background-color 0.3s ease,
                border-color 0.3s ease,
                opacity 0.3s ease,
                box-shadow 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-color);
    opacity: 0.9;
    flex-shrink: 0;
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--control-bg-hover);
    opacity: 1;
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-status {
    position: absolute;
    top: 50%;
    right: calc(100% + 12px);
    transform: translateY(-50%) translateX(10px) scale(0.9);
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.theme-status.visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0) scale(1);
}

/* Small speech bubble tail */
.theme-status::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    width: 8px;
    height: 8px;
    background: inherit;
    border-right: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border);
    transform: translateX(-50%) translateY(-50%) rotate(45deg);
}

.theme-toggle svg {
    position: absolute;
    width: 20px;
    height: 20px;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Toggle Animation State */
[data-theme="dark"] .sun-icon,
[data-theme="dark"] .system-icon {
    opacity: 0;
    transform: rotate(45deg) scale(0.5);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="light"] .moon-icon,
[data-theme="light"] .system-icon {
    opacity: 0;
    transform: rotate(-45deg) scale(0.5);
}

[data-theme="light"] .sun-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* System / Auto state (no data-theme attribute) */
:root:not([data-theme]) .sun-icon,
:root:not([data-theme]) .moon-icon {
    opacity: 0;
    transform: rotate(-45deg) scale(0.5);
}

:root:not([data-theme]) .system-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Responsive adjustment for mobile */
@media (max-width: 768px) {
    .theme-toggle {
        width: 32px;
        height: 32px;
    }
}

.screenshot-mode .controls-section,
.screenshot-mode .preview-header,
.screenshot-mode .preview-actions,
.screenshot-mode .theme-toggle,
.screenshot-mode .instruction-text {
    display: none;
}

.screenshot-toolbar {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 2000;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 0.75rem;
    border-radius: 20px;
    gap: 0.75rem;
    align-items: center;
}

.toolbar-main {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.toolbar-sub {
    width: 100%;
    display: flex;
    justify-content: center;
    border-top: 1px solid var(--glass-border);
    padding-top: 0.5rem;
}

.screenshot-mode .screenshot-toolbar {
    display: flex;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 32px;
}

.toolbar-group label {
    color: white;
    font-size: 0.85rem;
    margin: 0;
    text-transform: none;
    cursor: pointer;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.toolbar-btn.primary {
    background: var(--accent);
}

.toolbar-btn:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.toolbar-btn.secondary {
    background: rgba(255,255,255,0.1);
}

.screenshot-mode {
    padding: 0;
    background: transparent;
}

.screenshot-mode .container {
    background: transparent;
    border: none;
    box-shadow: none;
    grid-template-columns: 1fr;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.return-btn {
    display: none;
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    cursor: pointer;
    z-index: 1000;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.return-btn:hover {
    background: rgba(30, 41, 59, 1);
    transform: translateY(-2px);
}

.screenshot-mode .icon-canvas-wrapper {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.screenshot-mode .reset-btn-sidebar {
    display: none !important;
}

.screenshot-mode .icon-canvas-wrapper {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

@media (max-width: 1150px) {
    .screenshot-mode .icon-canvas-wrapper {
        width: 100vw;
        height: 100vw;
    }
}

.instruction-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

.footer-utility {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 0.5rem;
}

/* Tooltip style icon list */
.icon-suggestions {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    line-height: 1.4;
}

.suggestion-tag {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
    color: var(--text-muted);
}

.suggestion-tag:hover {
    color: var(--text-main);
}

.icon-picker-wrapper {
    position: relative;
    width: 100%;
}

.icon-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
}

.icon-dropdown.active {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
}

.dropdown-item {
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.dropdown-item:hover, .dropdown-item.selected {
    background: rgba(59, 130, 246, 0.2);
    color: white;
}

.dropdown-item svg {
    width: 20px;
    height: 20px;
}

.icon-dropdown::-webkit-scrollbar {
    width: 4px;
}

.icon-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.range-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.range-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.2rem;
}

.range-val {
    font-size: 0.75rem;
    color: white;
    font-weight: 600;
}

input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    height: 4px;
}
/* Mobile Drawer System (Expand in Place) */
.mobile-only {
    display: none !important;
}

@media (max-width: 1150px) {
    .mobile-only {
        display: flex !important;
    }
}

.drawer-trigger {
    width: 100%;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    margin: 0.25rem 0 0.75rem 0;
}

.drawer-trigger:hover,
.drawer-trigger.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.drawer-trigger:active {
    transform: scale(0.98);
}

.drawer-trigger .arrow-icon {
    transition: transform 0.3s ease;
}

.drawer-trigger.active .arrow-icon {
    transform: rotate(180deg);
}

.mobile-drawer,
.drawer-content,
.drawer-scroll-area {
    display: contents;
}

@media (max-width: 1150px) {
    .mobile-drawer {
        display: block;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                    opacity 0.3s ease,
                    margin 0.3s ease;
        width: 100%;
    }

    .mobile-drawer:not(.active) {
        max-height: 0;
        opacity: 0;
        margin-top: 0;
        pointer-events: none;
    }

    .mobile-drawer.active {
        max-height: 2000px; /* High enough for all controls */
        opacity: 1;
        margin-top: 1rem;
        pointer-events: auto;
    }

    .drawer-content {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid var(--glass-border);
        margin-bottom: 1rem;
    }

    .drawer-scroll-area {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }
}

/* Horizontal Dividers for Mobile */
.mobile-divider {
    display: none;
    border: none;
    border-top: 1px solid var(--glass-border);
    width: 100%;
    margin: 0;
}

@media (max-width: 1150px) {
    .mobile-divider {
        display: block;
    }
    
    .container {
        gap: 1.25rem; /* Reduced gap since we have dividers contributing space */
    }
}

