/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* WalletCon Palette */
    --accent: #0080FF; /* Electric Blue */
    --accent-rgb: 0, 128, 255;
    --white: #FFFFFF;
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    
    /* Layout Tokens */
    --border-subtle: rgba(255, 255, 255, 0.15);
    --border-solid: #FFFFFF;
    --radius: 0px; /* Sharp corners per reference */
    
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'Space Mono', monospace;
    
    /* Mesh Gradient Components */
    --mesh-bg: #0047FF;
    --mesh-color1: #00D1FF;
    --mesh-color2: #7000FF;
    --mesh-color3: #FF00C7;
    
    --transition: all 0.2s ease;
}

@keyframes mesh-pulse {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--mesh-bg);
    background-image: 
        radial-gradient(at 0% 0%, var(--mesh-color1) 0px, transparent 50%),
        radial-gradient(at 50% 0%, var(--mesh-color2) 0px, transparent 50%),
        radial-gradient(at 100% 0%, var(--mesh-color3) 0px, transparent 50%),
        radial-gradient(at 50% 100%, var(--mesh-bg) 0px, transparent 50%);
    background-size: 200% 200%;
    animation: mesh-pulse 15s ease infinite;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Noise Texture Overlay */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("noise.png");
    background-repeat: repeat;
    opacity: 0.05; /* Lowered for png texture */
    pointer-events: none;
    z-index: 1;
}

/* Blueprint Grid Lines */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(var(--border-subtle) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

#topText {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.2rem;
}

#bottomText {
    font-family: 'Passions Conflict', cursive;
    font-size: 2.5rem;
}

/* ===== Particles Background ===== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.08;
    animation: floatParticle linear infinite;
}

@keyframes floatParticle {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.08; }
    90% { opacity: 0.08; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 3rem 1.5rem 2rem;
    position: relative;
    z-index: 10;
}

.header-main {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 1.5rem;
    padding: 0 1rem;
}

.wallet-connection {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

/* Mobile Fixes */
@media (max-width: 600px) {
    .header-main {
        flex-direction: column;
        gap: 1.5rem;
        padding-top: 1rem;
    }
    
    .wallet-connection {
        position: static;
        transform: none;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .logo-text {
        font-size: 1.8rem;
    }
    
    .tagline {
        margin-top: 1rem;
        font-size: 0.75rem;
    }
}

/* ===== Connect Wallet Button ===== */
#connectWalletBtn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.7rem 1.6rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px; /* pill shape */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#connectWalletBtn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: 0.5s;
}

#connectWalletBtn:hover::before {
    left: 100%;
}

#connectWalletBtn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

#connectWalletBtn.connected {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 229, 255, 0.1));
    border-color: #00E5FF;
    color: #00E5FF;
    font-weight: 800;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

#connectWalletBtn.connected::after {
    content: "";
    width: 6px;
    height: 6px;
    background: #00E5FF;
    border-radius: 50%;
    box-shadow: 0 0 8px #00E5FF;
    animation: status-pulse 1.5s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 1; shadow: 0 0 0px #00E5FF; }
    50% { transform: scale(1.5); opacity: 0.5; shadow: 0 0 10px #00E5FF; }
    100% { transform: scale(1); opacity: 1; shadow: 0 0 0px #00E5FF; }
}

#connectWalletBtn.connected:hover {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.3), rgba(0, 229, 255, 0.2));
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.5);
}

/* ===== Wallet Dropdown ===== */
.wallet-dropdown-container {
    position: relative;
    display: inline-block;
}

.wallet-dropdown {
    position: absolute;
    top: 100%; /* No gap to prevent hover loss */
    right: 0;
    min-width: 140px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 0.5rem;
    display: none;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-top: 8px; /* Visual gap while maintaining hover via bridge */
    transform-origin: top right;
    animation: dropdownFade 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wallet-dropdown::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
    background: transparent;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.wallet-dropdown.active {
    display: block;
}

#disconnectBtn {
    width: 100%;
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    transition: var(--transition);
}

#disconnectBtn:hover {
    background: rgba(255, 59, 48, 0.2); /* Soft red */
    color: #FF3B30;
}

.onboarding-message {
    text-align: center;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--white);
    border-radius: var(--radius);
    margin: 2rem auto;
    max-width: 600px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.logo-stamp {
    height: 48px;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--white);
    padding: 6px;
}

.logo-stamp img {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

.logo-text {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--white);
    text-transform: uppercase;
}

.tagline {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 1rem;
}

/* ===== Main Content ===== */
.main-content {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem 3rem;
}

/* ===== Upload Section ===== */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.upload-area {
    width: 100%;
    max-width: 600px;
    padding: 5rem 3rem;
    border: 1px solid var(--white);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, var(--accent-glow), transparent 70%);
    opacity: 0;
    transition: var(--transition);
}

.upload-area:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

.upload-area:hover::before {
    opacity: 1;
}

.upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(232, 93, 58, 0.08);
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.upload-area:hover .upload-icon {
    color: var(--accent);
    transform: scale(1.1);
}

.upload-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

@media (max-width: 600px) {
    .upload-area {
        padding: 3rem 1.5rem;
    }
    .upload-title {
        font-size: 1.1rem;
    }
}

/* ===== Editor Section ===== */
.editor-section {
    animation: fadeInUp 0.6s ease-out;
}

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

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    align-items: start;
}

/* ===== Preview Panel ===== */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.preview-wrapper {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.preview-wrapper::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(232, 93, 58, 0.2), transparent, rgba(245, 166, 35, 0.2));
    z-index: -1;
    filter: blur(1px);
}

#stampCanvas {
    max-width: 100%;
    max-height: 65vh; /* Keep even the tallest aspect ratios on screen without clipping */
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.preview-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: var(--white);
    color: var(--accent);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

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

.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--white);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn-accent {
    background: #00E5FF; /* Vibrant Cyan from screenshot */
    color: #000; /* Dark text for contrast */
    border: none;
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
}

.btn-accent:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(0, 229, 255, 0.5);
}

/* ===== Controls Panel ===== */
.controls-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--white) transparent;
}

.controls-panel::-webkit-scrollbar {
    width: 5px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: var(--border-accent);
    border-radius: 10px;
}

.controls-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.control-group {
    margin-bottom: 1.25rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    font-family: var(--font-mono);
}

.control-value {
    color: var(--white);
    opacity: 0.8;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ===== Range Slider ===== */
.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 1px;
    background: var(--white);
    outline: none;
    cursor: pointer;
    margin: 1rem 0;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--white);
    border: 1px solid var(--accent);
    cursor: pointer;
    transition: var(--transition);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* ===== Preset Grid ===== */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1px;
    background: var(--white);
    border: 1px solid var(--white);
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.8rem 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 0;
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.preset-btn.active {
    background: var(--white);
    color: var(--accent);
}

.preset-icon, .btn-icon {
    font-size: 1.2rem;
}

/* ===== Frame Buttons (Dedicated Styles) ===== */
.frame-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.8rem 0.15rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    min-height: 70px;
}

.frame-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.frame-btn.active {
    background: var(--white);
    color: var(--accent);
    border-color: var(--white);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* ===== Color Swatches ===== */
.color-swatches {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.swatch:hover {
    transform: scale(1.15);
}

.swatch.active {
    border-color: white;
    box-shadow: 0 0 12px var(--accent-glow);
}

.swatch.active::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ===== Text Input ===== */
.text-input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--white);
    border-radius: var(--radius);
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.text-input:focus {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

.text-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* ===== Toggle ===== */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: rgba(232, 93, 58, 0.2);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(18px);
    background: var(--accent);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        max-height: none;
    }

    .preview-wrapper {
        padding: 1.25rem;
    }

    .header {
        padding: 2rem 1rem 1rem;
    }

    .logo-text {
        font-size: 1.6rem;
    }

    .logo-stamp {
        font-size: 2rem;
    }

    .upload-area {
        padding: 3rem 2rem;
    }

    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .preview-wrapper {
        padding: 0.75rem;
    }

    .controls-panel {
        padding: 1.25rem;
    }

    .upload-area {
        padding: 2.5rem 1.5rem;
    }
}

/* ===== Showcase Gallery (Omou Style) ===== */
.gallery-section {
    margin-top: 1rem;
    padding: 0 0 1.5rem 0;
    text-align: center;
}

.gallery-title {
    display: none; /* Hidden for top gallery */
}

.stamp-stack-container {
    height: 140px; /* Scaled down room for fan out */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    perspective: 1000px;
}

.stamp-stack {
    position: relative;
    width: 120px;
    height: 160px;
    cursor: zoom-in;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gallery-stamp {
    position: absolute;
    width: 80px; /* Scaled down stamp size */
    height: auto;
    object-fit: contain;
    transition: transform 380ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 380ms ease;
    will-change: transform;
    border-radius: 4px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

/* Static Stack State (Tighter offsets for smaller size) */
.gallery-stamp:nth-child(1) { z-index: 1; transform: translate(-4px, 1px) rotate(-9deg); }
.gallery-stamp:nth-child(2) { z-index: 2; transform: translate(-2px, -1px) rotate(-5deg); }
.gallery-stamp:nth-child(3) { z-index: 3; transform: translate(0px, 0px) rotate(0deg); }
.gallery-stamp:nth-child(4) { z-index: 4; transform: translate(2px, -1px) rotate(2deg); }
.gallery-stamp:nth-child(5) { z-index: 5; transform: translate(4px, 1px) rotate(5deg); }

/* Hover Stack State (Reduced fan-out spread) */
.stamp-stack:hover .gallery-stamp:nth-child(1) { transform: translate(-70px, 4px) rotate(-18deg); box-shadow: 0 6px 15px rgba(0,0,0,0.3); }
.stamp-stack:hover .gallery-stamp:nth-child(2) { transform: translate(-35px, 2px) rotate(-9deg); box-shadow: 0 6px 15px rgba(0,0,0,0.3); }
.stamp-stack:hover .gallery-stamp:nth-child(3) { transform: translate(0px, -2px) rotate(0deg); box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.stamp-stack:hover .gallery-stamp:nth-child(4) { transform: translate(35px, 2px) rotate(9deg); box-shadow: 0 6px 15px rgba(0,0,0,0.3); }
.stamp-stack:hover .gallery-stamp:nth-child(5) { transform: translate(70px, 4px) rotate(18deg); box-shadow: 0 6px 15px rgba(0,0,0,0.3); }

/* Fullscreen Preview Modal */
.stamp-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: color-mix(in srgb, var(--mesh-bg, #0047FF) 85%, rgba(0,0,0,0.6));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

.stamp-preview-modal.active {
    opacity: 1;
    pointer-events: auto;
}

#stampPreviewImage {
    width: auto;
    height: auto;
    max-width: 280px;
    max-height: 400px;
    object-fit: contain;
    transform: scale(0.95);
    transition: transform 380ms cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border-radius: 4px;
    cursor: zoom-out;
}

.stamp-preview-modal.active #stampPreviewImage {
    transform: scale(1);
}

.close-preview-btn {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    cursor: zoom-out;
    z-index: 1;
}

@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .controls-panel {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    /* Scale down the hover spread for mobile devices so they don't overflow screen width */
    .stamp-stack:hover .gallery-stamp:nth-child(1) { transform: translate(-50px, 4px) rotate(-18deg); }
    .stamp-stack:hover .gallery-stamp:nth-child(2) { transform: translate(-25px, 2px) rotate(-9deg); }
    .stamp-stack:hover .gallery-stamp:nth-child(4) { transform: translate(25px, 2px) rotate(9deg); }
    .stamp-stack:hover .gallery-stamp:nth-child(5) { transform: translate(50px, 4px) rotate(18deg); }
}

/* ===== Loading Animation ===== */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: var(--radius-lg);
    z-index: 100;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}
