:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #0f172a;
    --accent: #f59e0b;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --line: #dbe5f1;
    --text: #1e293b;
    --muted: #64748b;
    --success: #15803d;
    --error: #b91c1c;
    --shadow: 0 25px 60px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 24%),
        linear-gradient(180deg, #eff6ff 0%, #f8fafc 24%, #eef2ff 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.hidden {
    display: none !important;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(219, 229, 241, 0.85);
}

.header-inner {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand img {
    width: 46px;
    height: 46px;
    object-fit: contain;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 22px;
    font-weight: 500;
}

.main-nav > a,
.nav-dropdown-toggle {
    color: var(--secondary);
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 10px 0;
}

.main-nav > a:hover,
.nav-dropdown-toggle:hover {
    color: var(--primary);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.nav-dropdown-menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
    background: #eff6ff;
    color: var(--primary);
}

.header-cta,
.primary-btn,
.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 14px;
    font-weight: 600;
    transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.header-cta,
.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: 0;
    cursor: pointer;
}

.download-btn {
    background: #e8fff0;
    color: var(--success);
}

.header-cta:hover,
.primary-btn:hover,
.download-btn:hover {
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.hero {
    padding: 68px 0 28px;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
    gap: 28px;
    align-items: stretch;
}

.hero-copy,
.info-card,
.panel-card,
.controls-card {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(219, 229, 241, 0.95);
    box-shadow: var(--shadow);
}

.hero-copy,
.info-card {
    border-radius: 28px;
    padding: 32px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
    font-weight: 600;
    font-size: 0.92rem;
}

.hero-copy h1 {
    margin: 18px 0 14px;
    font-size: clamp(2.3rem, 4vw, 4rem);
    line-height: 1.08;
    color: var(--secondary);
}

.hero-copy p {
    margin: 0 0 18px;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--muted);
    max-width: 62ch;
}

.hero-points {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-points li {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    font-size: 0.95rem;
}

.info-card h2,
.controls-card h3,
.panel-head h3 {
    margin: 0 0 10px;
    font-size: 1.15rem;
}

.info-card p {
    margin: 0 0 24px;
    color: var(--muted);
    line-height: 1.7;
}

.info-stats {
    display: grid;
    gap: 16px;
}

.info-stats div {
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.info-stats strong,
.info-stats span {
    display: block;
}

.info-stats strong {
    margin-bottom: 4px;
}

.info-stats span {
    color: var(--muted);
}

.workspace-section {
    padding: 0 0 56px;
}

.tool-shell {
    display: grid;
    grid-template-columns: minmax(290px, 0.9fr) minmax(0, 1.1fr);
    gap: 24px;
}

.upload-panel {
    display: grid;
    gap: 20px;
}

.drop-zone,
.controls-card,
.panel-card {
    border-radius: 24px;
}

.drop-zone {
    position: relative;
    padding: 34px 24px;
    min-height: 320px;
    border: 2px dashed #93c5fd;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(239, 246, 255, 0.86));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragover,
.drop-zone:focus-visible {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    outline: none;
}

.drop-zone-icon {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 2.4rem;
    font-weight: 300;
}

.drop-zone h2 {
    margin: 8px 0 0;
    font-size: 1.5rem;
}

.drop-zone p,
.drop-zone-hint,
.status-message,
.panel-head span,
.image-placeholder {
    color: var(--muted);
}

.controls-card,
.panel-card {
    padding: 24px;
}

.format-group {
    display: grid;
    gap: 12px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface-alt);
    cursor: pointer;
}

.radio-option input {
    margin: 0;
}

.status-message {
    min-height: 24px;
    font-size: 0.95rem;
}

.status-message.success {
    color: var(--success);
}

.status-message.error {
    color: var(--error);
}

.loading-state {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eff6ff;
    color: var(--primary);
    font-weight: 500;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(37, 99, 235, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

.preview-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.image-stage {
    position: relative;
    min-height: 360px;
    border-radius: 18px;
    border: 1px solid var(--line);
    overflow: hidden;
    display: grid;
    place-items: center;
    background-color: #fff;
}

.checkerboard {
    background-image:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
        linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
    background-size: 28px 28px;
    background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

.image-stage img {
    display: none;
    max-width: 100%;
    max-height: 360px;
    object-fit: contain;
}

.image-stage.has-image img {
    display: block;
}

.image-stage.has-image .image-placeholder {
    display: none;
}

.download-btn {
    margin-top: 18px;
    width: 100%;
}

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

@media (max-width: 980px) {
    .hero-grid,
    .tool-shell,
    .preview-panel {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-wrap: wrap;
        justify-content: center;
    }

    .main-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .container {
        width: min(100% - 20px, 1180px);
    }

    .hero {
        padding-top: 32px;
    }

    .hero-copy,
    .info-card,
    .controls-card,
    .panel-card {
        padding: 20px;
    }

    .drop-zone {
        min-height: 250px;
        padding: 28px 18px;
    }

    .image-stage {
        min-height: 280px;
    }

    .header-cta,
    .main-nav {
        width: 100%;
    }

    .header-cta {
        justify-content: center;
    }
}
