:root {
    --bg-gradient: linear-gradient(135deg, #f6f8fd 0%, #f1f5f9 100%);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;

    --primary-color: #10b981;
    --primary-hover: #059669;
    --primary-light: #ecfdf5;

    --danger-color: #ef4444;
    --danger-hover: #dc2626;

    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 0 0 20px 20px;
    padding: 3rem;
    width: 100%;
    max-width: 1200px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #10b981, #0ea5e9);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header h1 span {
    color: var(--text-color);
    background-clip: unset;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
}

.input-group {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group.line-break {
    flex-basis: 100%;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

input[type="number"],
select {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    background: white;
}

select option {
    background: white;
    color: var(--text-color);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.warning-text {
    color: #b45309;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    background: #fffbeb;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #fde68a;
    animation: fadeIn 0.3s ease;
}

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.02);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.drop-zone p {
    font-size: 1.2rem;
}

.drop-zone strong {
    color: var(--primary-color);
}

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

#fileInput {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.status-panel,
.ready-panel {
    margin-top: 2rem;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.4s ease;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    margin: 1.5rem 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #34d399, #10b981);
    transition: width 0.3s ease;
}

#statusText {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#statsText {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Base Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Green Primary Buttons */
.primary-btn {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    color: white;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.primary-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    border-color: #cbd5e1;
    box-shadow: none;
    cursor: not-allowed;
    text-shadow: none;
}

/* Preset Buttons */
.preset-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* Red Cancel Buttons */
#cancelBtn,
.btn.danger-btn {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: white;
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#cancelBtn:hover,
.btn.danger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(239, 68, 68, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.preview-area {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.file-item {
    position: relative;
    background: white;
    border-radius: 10px;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
    transition: transform 0.2s;
}

.file-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.file-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid #f1f5f9;
}

.file-item-name {
    font-size: 0.75rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.file-item-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Red Remove Button inside thumbnails */
.remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
    transition: all 0.2s;
}

.remove-btn:hover {
    transform: scale(1.15) rotate(90deg);
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.5);
}

.add-more-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    margin-top: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.add-more-zone:hover,
.add-more-zone.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.add-more-zone p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.add-more-zone strong {
    color: var(--primary-color);
}

.preview-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
    transition: transform 0.2s;
    background: white;
    border: 1px solid #e2e8f0;
}

.preview-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preview-thumb {
    width: 100%;
    object-fit: cover;
    display: block;
}

.preview-download-btn {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    color: var(--primary-hover);
    border: none;
    padding: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.preview-download-btn:hover {
    background: var(--primary-color);
    color: white;
}

.seo-footer {
    max-width: 1200px;
    margin: 3rem auto 2rem;
    padding: 0 2rem;
}

.seo-footer article {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    line-height: 1.8;
    color: #475569;
}

.seo-footer h2 {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 1rem;
}

.seo-footer h3 {
    font-size: 1.15rem;
    color: #334155;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.seo-footer p {
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.seo-footer ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.seo-footer li {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Navigation ===== */
.top-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem 0;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 10px 10px 0 0;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #e2e8f0;
    border-bottom: none;
    transition: all 0.25s ease;
    position: relative;
    top: 1px;
}

.nav-link:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.8);
}

.nav-link.active {
    color: var(--primary-color);
    background: var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: 0 -4px 12px rgba(16, 185, 129, 0.08);
}

.nav-link svg {
    flex-shrink: 0;
}

/* ===== Info Banner ===== */
.info-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    color: #1e40af;
    font-size: 0.9rem;
    line-height: 1.6;
    animation: fadeIn 0.4s ease;
}

.info-banner svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #3b82f6;
}

.info-banner strong {
    color: #1e40af;
}

/* ===== Background Removal Preview ===== */
.bg-compare {
    position: relative;
}

.bg-result-wrapper {
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
}

.bg-result-wrapper img {
    display: block;
    width: 100%;
    object-fit: contain;
    max-height: 320px;
}


/* ===== Spritesheet editor ===== */
.tool-toggle {
    display: flex;
    gap: 0.25rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 4px;
    border-radius: 8px;
}

.tool-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 0;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    color: var(--text-muted);
    transition: all 0.15s;
}

.tool-btn svg {
    display: block;
}

.tool-btn:hover:not(.active) {
    color: var(--text-color);
}

.tool-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.cell-size {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    overflow: auto;
    max-height: 75vh;
}

.canvas-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: none;
}

.canvas-wrapper canvas.is-moving {
    cursor: grabbing;
}

.canvas-wrapper canvas.over-selection {
    cursor: grab;
}

.canvas-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.75rem 0 1rem;
}

.canvas-hint kbd,
.selection-tools kbd {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text-color);
}

.selection-tools {
    margin-top: 1rem;
    flex-wrap: wrap;
}

.selection-tools .btn {
    padding: 0.55rem 1rem;
    font-size: 0.92rem;
}

.selection-tools .btn kbd {
    margin-left: 0.4rem;
    background: rgba(255, 255, 255, 0.6);
}

/* ===== Responsive Navigation ===== */
@media (max-width: 600px) {
    .top-nav {
        gap: 0.25rem;
        padding: 0.75rem 0.75rem 0;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        gap: 0.35rem;
    }

    .nav-link svg {
        width: 14px;
        height: 14px;
    }

    .info-banner {
        font-size: 0.82rem;
        padding: 0.85rem 1rem;
    }
}