:root {
    --sq-pink: #ff3385;
    --sq-hot-pink: #f0066e;
    --sq-blue: #5fb4e4;
    --sq-deep-blue: #0a7bcc;
    --sq-light: #ffffff;
    --sq-green: #38f09b;
    --sq-font: 'Helvetica Neue', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --sq-text: #0f172a;
    --sq-muted: #475569;
    --sq-panel: rgba(255, 255, 255, 0.95);
    --sq-border: rgba(15, 23, 42, 0.08);
    --sq-app-bg: linear-gradient(145deg, #f5f7ff 0%, #ffffff 40%, #f0f4ff 100%);
    --sq-drop-bg: radial-gradient(circle at 60% 40%, rgba(80, 112, 255, 0.08), transparent 60%), linear-gradient(160deg, #fdfbff 0%, #eef3ff 100%);
    --sq-shadow: 0 25px 45px rgba(15, 23, 42, 0.12);
    --sq-ghost-bg: rgba(15, 23, 42, 0.05);
    --sq-ghost-bg-hover: rgba(15, 23, 42, 0.08);
    --sq-chip-bg: rgba(15, 23, 42, 0.05);
    --sq-chip-border: rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] {
    --sq-text: #ffffff;
    --sq-muted: rgba(255, 255, 255, 0.7);
    --sq-panel: rgba(13, 20, 32, 0.92);
    --sq-border: rgba(255, 255, 255, 0.06);
    --sq-app-bg: radial-gradient(circle at 20% 20%, rgba(255, 51, 133, 0.25), transparent 55%),
        radial-gradient(circle at 80% 0%, rgba(95, 180, 228, 0.2), transparent 45%),
        linear-gradient(145deg, #050505 0%, #0b0f17 45%, #131420 100%);
    --sq-drop-bg: radial-gradient(circle at 60% 40%, rgba(230, 70, 255, 0.25), transparent 60%),
        linear-gradient(160deg, #13162a 0%, #090d16 100%);
    --sq-shadow: 0 35px 65px rgba(0, 0, 0, 0.65);
    --sq-ghost-bg: rgba(255, 255, 255, 0.05);
    --sq-ghost-bg-hover: rgba(255, 255, 255, 0.08);
    --sq-chip-bg: rgba(255, 255, 255, 0.04);
    --sq-chip-border: rgba(255, 255, 255, 0.12);
}

#content-area.content-area--full {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.squoosh-app [hidden] {
    display: none !important;
}

.squoosh-app {
    min-height: calc(100vh - var(--header-height));
    background: var(--sq-app-bg);
    padding: clamp(1.5rem, 3vw, var(--spacing-xl));
    font-family: var(--sq-font);
    color: var(--sq-text);
}

.squoosh-shell {
    max-width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.squoosh-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    background: var(--sq-panel);
    border: 1px solid var(--sq-border);
    border-radius: 18px;
    box-shadow: var(--sq-shadow);
    backdrop-filter: blur(24px);
    color: var(--sq-text);
}

.squoosh-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.squoosh-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    box-shadow: 0 15px 45px rgba(255, 51, 133, 0.4);
}

.brand-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--sq-text);
}

.brand-subtitle {
    margin: 0;
    color: var(--sq-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.ghost-btn {
    position: relative;
    border: 1px solid var(--sq-border);
    background: var(--sq-ghost-bg);
    color: var(--sq-text);
    padding: 0.65rem 1.25rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.ghost-btn:hover {
    border-color: rgba(95, 180, 228, 0.4);
    background: var(--sq-ghost-bg-hover);
    transform: translateY(-1px);
}

.ghost-btn--outline {
    background: transparent;
}

.squoosh-main {
    display: grid;
    gap: var(--spacing-lg);
    grid-template-columns: 1.4fr 0.85fr;
    grid-template-areas:
        "drop controls"
        "preview preview";
}

.squoosh-drop-panel {
    grid-area: drop;
    position: relative;
    min-height: 280px;
    border-radius: 28px;
    background: var(--sq-drop-bg);
    border: 1px solid var(--sq-border);
    overflow: hidden;
    box-shadow: var(--sq-shadow);
}

.squoosh-drop-panel.is-dragover {
    border-color: rgba(95, 180, 228, 0.6);
    box-shadow: 0 45px 85px rgba(95, 180, 228, 0.25);
}

.squoosh-drop-panel.is-dragover .drop-inner {
    transform: translateY(-2px);
}

.drop-inner {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-align: center;
    padding: var(--spacing-lg);
    transition: transform var(--transition-base);
    color: var(--sq-text);
    cursor: pointer;
}

.drop-inner small {
    color: var(--sq-muted);
}

.drop-inner button {
    cursor: pointer;
}

.drop-inner a {
    color: var(--sq-blue);
}

.blob-canvas {
    position: absolute;
    inset: 0;
    opacity: 0.2;
    filter: blur(60px);
    background: radial-gradient(circle at 30% 30%, rgba(255, 51, 133, 0.9), transparent 45%),
        radial-gradient(circle at 70% 70%, rgba(95, 180, 228, 0.9), transparent 40%);
}

.drop-icon {
    font-size: 3rem;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.45));
}

.pill-btn {
    border: none;
    border-radius: 999px;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(120deg, var(--sq-pink), var(--sq-hot-pink));
    color: var(--sq-light);
    box-shadow: 0 25px 45px rgba(255, 51, 133, 0.35);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.pill-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 35px 65px rgba(255, 51, 133, 0.4);
}

.pill-btn--primary {
    width: 100%;
}

.pill-btn--outline {
    border: 1px solid var(--sq-border);
    background: var(--sq-ghost-bg);
    color: var(--sq-text);
    box-shadow: none;
    text-align: center;
}

.pill-btn--outline:hover {
    box-shadow: none;
    background: var(--sq-ghost-bg-hover);
}

.squoosh-preview {
    grid-area: preview;
    border-radius: 28px;
    background: var(--sq-panel);
    border: 1px solid var(--sq-border);
    box-shadow: var(--sq-shadow);
    min-height: 500px;
    max-height: 800px;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.two-up {
    --reveal: 50%;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .two-up {
    background: rgba(255, 255, 255, 0.02);
}

.two-up__image:not([hidden]) ~ .preview-empty {
    display: none;
}

.two-up__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity var(--transition-base);
}

.two-up__image[hidden] {
    opacity: 0;
}

.two-up__image--output {
    clip-path: inset(0 calc(100% - var(--reveal)) 0 0);
}

.two-up__divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    left: var(--reveal);
    background: var(--sq-blue);
    transform: translateX(-1px);
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.two-up__handle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--sq-blue);
    background: rgba(9, 15, 25, 0.75);
    margin-top: calc(50% - 21px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}

.two-up__range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--sq-muted);
    font-size: 1.1rem;
    font-weight: 500;
}

.squoosh-controls {
    grid-area: controls;
    border-radius: 28px;
    background: var(--sq-panel);
    border: 1px solid var(--sq-border);
    padding: var(--spacing-xl);
    box-shadow: var(--sq-shadow);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    position: relative;
    color: var(--sq-text);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.control-label {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-sm);
}

.format-chip {
    border-radius: 16px;
    border: 1px solid var(--sq-chip-border);
    background: var(--sq-chip-bg);
    color: var(--sq-text);
    padding: 0.75rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.format-chip.active {
    background: linear-gradient(120deg, var(--sq-blue), var(--sq-deep-blue));
    border-color: transparent;
    box-shadow: 0 15px 35px rgba(95, 180, 228, 0.35);
    color: white;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.12);
    outline: none;
}

[data-theme="dark"] input[type="range"] {
    background: rgba(255, 255, 255, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--sq-blue);
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(95, 180, 228, 0.35);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--sq-blue);
    cursor: pointer;
    border: none;
    box-shadow: 0 6px 18px rgba(95, 180, 228, 0.35);
}

.control-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--sq-muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--spacing-md);
    text-align: center;
}

.stat-label {
    margin: 0;
    color: var(--sq-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--sq-text);
}

.stat-value--accent {
    color: var(--sq-green);
}

.buttons-row {
    display: flex;
    gap: var(--spacing-sm);
}

.processing-state {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--sq-chip-bg);
    border-radius: 18px;
    padding: var(--spacing-sm) var(--spacing-md);
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(95, 180, 228, 0.2);
    border-top-color: var(--sq-blue);
    animation: spin 0.9s linear infinite;
}

.error-banner {
    background: rgba(255, 51, 133, 0.12);
    border: 1px solid rgba(255, 51, 133, 0.4);
    border-radius: 14px;
    padding: var(--spacing-md);
    color: var(--sq-text);
}

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

@media (max-width: 1024px) {
    .squoosh-main {
        grid-template-columns: 1fr !important;
        grid-template-areas:
            "drop"
            "controls"
            "preview" !important;
    }

    .squoosh-preview {
        grid-column: 1 / -1;
    }

    .squoosh-controls {
        max-width: none;
    }
}

@media (max-width: 640px) {
    .squoosh-app {
        padding: var(--spacing-md);
    }

    .squoosh-header,
    .squoosh-controls,
    .squoosh-drop-panel,
    .squoosh-preview {
        border-radius: 18px;
        padding: var(--spacing-lg);
    }

    .buttons-row {
        flex-direction: column;
    }
}
