:root {
    --bg-dark: #0f1115;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #ec4899;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --input-bg: rgba(0, 0, 0, 0.2);
    --border-radius: 16px;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.36);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    /* Reset from centralized single-view */
    display: flex;
    flex-direction: column;
}

/* Background Effects */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #8b5cf6;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
    opacity: 0.2;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 50px) scale(1.1);
    }
}

/* Layout */
.container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    z-index: 10;
    margin: 0 auto;
}

main.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80vh;
}

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

.header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.app-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        /* Default single column until we have result */
    }

    .app-layout.has-result {
        grid-template-columns: 1.2fr 1fr;
        /* Split when result is visible */
    }
}

/* Glass Card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* Input Section */
.upload-section {
    width: 100%;
    min-height: 200px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.1);
}

.upload-section:hover,
.upload-section.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-content {
    text-align: center;
    color: var(--text-muted);
}

.upload-content .icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.highlight {
    color: var(--primary);
    font-weight: 600;
}

/* Preview */
.preview-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

.preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.hidden {
    display: none !important;
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.remove-btn:hover {
    background: rgba(236, 72, 153, 0.8);
}

/* Settings Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.value-badge {
    color: var(--primary);
    font-family: monospace;
}

.select-wrapper {
    position: relative;
}

select,
input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    appearance: none;
    outline: none;
    transition: border-color 0.2s;
}

select:focus,
input[type="number"]:focus {
    border-color: var(--primary);
}

.chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    pointer-events: none;
    opacity: 0.5;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--input-bg);
    border-radius: 3px;
    appearance: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.dimensions-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), #4338ca);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #4b5563;
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    /* Default padding if width is not forced */
    width: 100%;
    /* Make it full width like primary button */
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s;
    cursor: pointer;
    margin-top: 1rem;
    box-sizing: border-box;
    /* Ensure padding doesn't affect width if set */
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.icon-sm {
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

/* Result Panel */
.panel-right {
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.result-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.badge {
    font-size: 0.75rem;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.result-view {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    margin-bottom: 1rem;
}

.result-view img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -10px;
    margin-top: -10px;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error-msg {
    margin-top: 1rem;
    color: #f87171;
    font-size: 0.9rem;
    text-align: center;
}

.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    position: relative;
    z-index: 10;
}

/* Features Section */
.features-section {
    padding: 2rem 0;
    position: relative;
    z-index: 10;
}

.section-header.center-text {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.feature-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Formats Section */
.formats-section {
    padding: 2rem 0 4rem 0;
    position: relative;
    z-index: 10;
}

.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.format-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.format-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.1);
}

.format-card.popular {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.popular-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.format-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    align-self: flex-start;
}

.format-badge.png {
    background: #3b82f6;
    color: white;
}

.format-badge.jpeg {
    background: #f59e0b;
    color: black;
}

.format-badge.webp {
    background: #10b981;
    color: white;
}

.format-badge.avif {
    background: #8b5cf6;
    color: white;
}

.format-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    font-weight: 600;
}

.format-specs {
    list-style: none;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.format-specs li {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.format-specs strong {
    color: #e2e8f0;
}

.check {
    color: #10b981;
    font-weight: bold;
}

.cross {
    color: #f43f5e;
    font-weight: bold;
}