* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --bg: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --text: #1e293b;
    --text-muted: #64748b;
    --border: rgba(148, 163, 184, 0.25);
    --shadow: 0 20px 60px -15px rgba(99, 102, 241, 0.08), 0 8px 24px -8px rgba(0, 0, 0, 0.06);
    --radius: 20px;
    --radius-sm: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    padding: 20px;
    color: var(--text);
    overflow-x: hidden;
}

/* Background decoration */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
}

.circle-1 {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, #c7d2fe, #a5b4fc);
    top: -250px;
    right: -150px;
    animation-delay: 0s;
}

.circle-2 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, #fbcfe8, #f9a8d4);
    bottom: -200px;
    left: -150px;
    animation-delay: -7s;
}

.circle-3 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #a5f3fc, #67e8f9);
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(20px, 30px) scale(1.02); }
}

.container {
    max-width: 960px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    margin-bottom: 20px;
    padding-top: 12px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
}

.header-text {
    text-align: left;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #1e293b 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Main panel - side by side layout */
.main-panel {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease forwards;
}

.card:hover {
    background: var(--bg-card-hover);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

/* Upload area */
.upload-card {
    padding: 0;
    display: flex;
    align-items: stretch;
}

.upload-area {
    flex: 1;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px dashed transparent;
    border-radius: var(--radius);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px dashed var(--border);
    border-radius: 14px;
    transition: all 0.3s ease;
    pointer-events: none;
}

.upload-area:hover::before,
.upload-area.dragover::before {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
}

.upload-area:hover {
    transform: scale(1.01);
}

.upload-area.dragover {
    transform: scale(1.02);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 12px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.upload-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Mode switch */
.mode-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: rgba(148, 163, 184, 0.08);
    border-radius: 10px;
    padding: 4px;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-muted);
}

.mode-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}

.mode-btn:hover:not(.active) {
    color: var(--text);
}

/* Settings */
.settings-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-with-presets {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preset-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.preset-tag {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(248, 250, 252, 0.8);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-tag:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.preset-tag.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.label-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.label-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 10px;
    border-radius: 20px;
}

/* Range slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    appearance: none;
    background: linear-gradient(to right, var(--primary), var(--primary-light));
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 3px var(--primary);
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Inputs */
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
}

input[type="number"]:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

select {
    cursor: pointer;
}

/* Lossless info */
.lossless-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: rgba(99, 102, 241, 0.04);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.lossless-info svg {
    flex-shrink: 0;
    color: var(--primary);
    margin-top: 1px;
}

/* Compress button */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    width: 100%;
    margin-top: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: #fff;
    padding: 8px 16px;
    font-size: 0.82rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

/* Preview grid */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.preview-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    animation: fadeInUp 0.3s ease forwards;
    transition: all 0.2s ease;
}

.preview-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.preview-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.preview-info {
    padding: 8px 10px;
}

.preview-name {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.preview-size {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Results section */
.results-section {
    margin-top: 4px;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.results-header .card-title {
    margin-bottom: 0;
}

/* Results */
.results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    animation: fadeInUp 0.4s ease forwards;
    transition: all 0.3s ease;
}

.result-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.result-card .preview {
    flex-shrink: 0;
}

.result-card .preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.result-card .info {
    flex: 1;
    min-width: 0;
}

.result-card .filename {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-card .size-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.size-info .arrow {
    color: var(--primary);
}

.result-card .compression-rate {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.08);
    color: var(--success);
}

.result-card .compression-rate.increased {
    background: rgba(234, 179, 8, 0.08);
    color: #eab308;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.result-card .btn-download {
    flex-shrink: 0;
    padding: 8px 14px;
    background: rgba(99, 102, 241, 0.06);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-card .btn-download:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px 20px;
}

.loading .spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.spinning {
    animation: spin 1s linear infinite;
}

/* Responsive */
@media (max-width: 700px) {
    .main-panel {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .result-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-card .btn-download {
        width: 100%;
        justify-content: center;
    }

    .circle-1 { width: 300px; height: 300px; }
    .circle-2 { width: 250px; height: 250px; }
    .circle-3 { width: 200px; height: 200px; }
}
