/* ===== Design System ===== */
:root {
    /* Typography */
    --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    
    /* Default (dark) theme colors */
    --color-bg: #0a0a0a;
    --color-bg-elevated: #141414;
    --color-bg-hover: #1a1a1a;
    --color-surface: #0f0f0f;
    --color-border: #252525;
    --color-border-subtle: #1c1c1c;
    
    --color-text: #fafafa;
    --color-text-secondary: #888888;
    --color-text-muted: #555555;
    
    --color-accent: #e8e8e8;
    --color-accent-dim: #333333;
    
    --noise-opacity: 0.03;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

/* Light theme */
body[data-theme="light"] {
    --color-bg: #f5f5f7;
    --color-bg-elevated: #ffffff;
    --color-bg-hover: #ebebeb;
    --color-surface: #fafafa;
    --color-border: #d1d1d6;
    --color-border-subtle: #e5e5ea;
    
    --color-text: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-text-muted: #aeaeb2;
    
    --color-accent: #1d1d1f;
    --color-accent-dim: #e5e5ea;
    
    --noise-opacity: 0.02;
    --shadow-color: rgba(0, 0, 0, 0.06);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme transition for all elements */
body.theme-transition,
body.theme-transition *,
body.theme-transition *::before,
body.theme-transition *::after {
    transition: background-color 0.3s ease, 
                border-color 0.3s ease, 
                color 0.3s ease,
                box-shadow 0.3s ease !important;
}

/* Noise texture overlay */
.noise-overlay {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: var(--noise-opacity);
    pointer-events: none;
    z-index: 1000;
}

.container {
    position: relative;
    max-width: 920px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: var(--space-3xl);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.logo-mark {
    font-family: var(--font-mono);
    font-size: 24px;
    letter-spacing: -2px;
    color: var(--color-text-secondary);
}

.logo-bracket {
    color: var(--color-text-muted);
}

.logo-icon {
    color: var(--color-text);
}

.logo h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--color-text);
}

.tagline {
    font-size: 15px;
    color: var(--color-text-secondary);
    font-weight: 400;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-out);
    z-index: 100;
}

.theme-toggle:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: all var(--duration-normal) var(--ease-out);
}

body[data-theme="dark"] .theme-toggle .icon-sun,
body:not([data-theme="light"]) .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

body[data-theme="dark"] .theme-toggle .icon-moon,
body:not([data-theme="light"]) .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(-90deg);
}

body[data-theme="light"] .theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(90deg);
}

body[data-theme="light"] .theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

/* ===== Upload Area ===== */
.upload-section {
    margin-bottom: var(--space-2xl);
}

.upload-area {
    position: relative;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-3xl) var(--space-xl);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    background: var(--color-surface);
}

.upload-area:hover {
    border-color: var(--color-text-muted);
    background: var(--color-bg-elevated);
}

.upload-area.drag-over {
    border-color: var(--color-text);
    border-style: solid;
    background: var(--color-bg-elevated);
    transform: scale(1.005);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    pointer-events: none;
}

.upload-visual {
    position: relative;
}

.upload-circle {
    width: 72px;
    height: 72px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: all var(--duration-normal) var(--ease-out);
}

.upload-area:hover .upload-circle {
    border-color: var(--color-text-muted);
    color: var(--color-text);
    transform: scale(1.05);
}

.upload-circle svg {
    width: 28px;
    height: 28px;
}

.upload-text {
    text-align: center;
}

.upload-text h2 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    color: var(--color-text);
}

.upload-text p {
    font-size: 14px;
    color: var(--color-text-muted);
}

.upload-specs {
    display: flex;
    gap: var(--space-sm);
}

.spec-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-bg);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Preview Section ===== */
.preview-section {
    animation: fadeUp 0.5s var(--ease-out);
}

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

.section-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.section-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-secondary);
}

.label-dot {
    width: 6px;
    height: 6px;
    background: var(--color-text-muted);
    border-radius: 50%;
}

/* Source Preview */
.source-preview {
    margin-bottom: var(--space-2xl);
}

.source-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
}

.source-image {
    flex-shrink: 0;
}

.source-image img {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-md);
}

.source-meta {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.8;
}

.source-meta strong {
    color: var(--color-text);
    font-weight: 500;
}

/* Output Section */
.output-section {
    margin-bottom: var(--space-2xl);
}

.style-toggle {
    display: flex;
    background: var(--color-bg);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.toggle-option {
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--duration-fast) var(--ease-out);
}

.toggle-option:hover {
    color: var(--color-text-secondary);
}

.toggle-option.active {
    background: var(--color-text);
    color: var(--color-bg);
}

/* Icons Grid */
.icons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-md);
}

.icon-card {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    transition: all var(--duration-fast) var(--ease-out);
}

.icon-card:hover {
    border-color: var(--color-border);
    transform: translateY(-2px);
}

.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
}

.icon-wrapper img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.icon-label {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 2px;
}

.icon-size {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-muted);
}

.icon-scale {
    display: inline-block;
    margin-top: var(--space-sm);
    padding: 2px 6px;
    background: var(--color-bg);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
}

/* Download Bar */
.download-bar {
    text-align: center;
    padding: var(--space-xl);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.btn-icon {
    font-size: 18px;
    font-weight: 400;
}

.btn-format {
    font-family: var(--font-mono);
    font-size: 12px;
    opacity: 0.6;
}

.download-note {
    margin-top: var(--space-md);
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ===== Buttons ===== */
.btn-reset {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.btn-reset:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

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

/* ===== AI Prompt Section ===== */
.prompt-section {
    margin-top: var(--space-2xl);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-bg-elevated);
}

.prompt-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.prompt-toggle:hover {
    color: var(--color-text-secondary);
    background: var(--color-bg-hover);
}

.prompt-toggle svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.prompt-toggle span {
    flex: 1;
    text-align: left;
}

.prompt-toggle .chevron {
    transition: transform var(--duration-normal) var(--ease-out);
}

.prompt-section.open .prompt-toggle .chevron {
    transform: rotate(180deg);
}

.prompt-content {
    display: none;
    padding: 0 var(--space-lg) var(--space-lg);
    animation: fadeIn 0.3s var(--ease-out);
}

.prompt-section.open .prompt-content {
    display: block;
}

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

.prompt-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.prompt-box {
    position: relative;
    background: var(--color-bg);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.prompt-box pre {
    padding: var(--space-lg);
    padding-right: 80px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.7;
    color: var(--color-text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.btn-copy {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.btn-copy:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

.btn-copy.copied {
    border-color: #4ade80;
    color: #4ade80;
}

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

/* ===== Footer ===== */
.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-3xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border-subtle);
    font-size: 13px;
    color: var(--color-text-muted);
}

.footer-dot {
    opacity: 0.5;
}

.counter {
    font-family: var(--font-mono);
}

#iconCount {
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(8px);
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-text);
    border-radius: 50%;
    margin: 0 auto var(--space-md);
    animation: spin 0.8s linear infinite;
}

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

.loading-content p {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ===== Error Toast ===== */
.error-toast {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #ff6b6b;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    border: 1px solid #ff6b6b33;
    font-size: 14px;
    z-index: 1001;
    animation: slideUp 0.3s var(--ease-out);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: var(--space-lg);
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .icons-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }
    
    .source-card {
        flex-direction: column;
        text-align: center;
    }
    
    .section-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .upload-area {
        padding: var(--space-2xl) var(--space-md);
    }
    
    .icons-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
