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

:root {
    --bg: #f4f4f4;
    --card: #ffffff;
    --text: #141414;
    --muted: #666666;
    --line: #d9d9d9;
    --dark: #111111;
    --dark-hover: #2a2a2a;
    --disabled: #a8a8a8;
    --radius: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    padding: 12px;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    overflow: hidden;
    padding: 24px;
}

header {
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

header h1 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--dark);
}

header h1 i {
    color: var(--dark);
}

.subtitle {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.98rem;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

#languageSelect {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
}

.upload-area {
    background: #fafafa;
    border: 2px dashed #b7b7b7;
    border-radius: var(--radius);
    padding: 40px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    margin-bottom: 22px;
    position: relative;
}

.upload-area:hover,
.upload-area.dragover {
    background: #f0f0f0;
    border-color: #555;
}

.upload-icon {
    font-size: 2.4rem;
    color: #2c2c2c;
    margin-bottom: 10px;
}

.upload-area h2 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.upload-area p {
    color: var(--muted);
}

.file-types {
    margin-top: 8px;
    font-size: 0.88rem;
}

#fileInput {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.controls {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, minmax(120px, 1fr));
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.quality-control {
    border: 1px solid var(--line);
    padding: 14px;
    border-radius: 10px;
    background: #fcfcfc;
}

.quality-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

#quality {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #d1d1d1;
    border-radius: 3px;
    outline: none;
}

#quality::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #1b1b1b;
    border-radius: 50%;
    cursor: pointer;
}

#quality::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #1b1b1b;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.btn {
    border: 1px solid var(--dark);
    background: var(--dark);
    color: #fff;
    border-radius: 10px;
    padding: 12px 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn:hover:not(:disabled) {
    background: var(--dark-hover);
}

.btn:disabled {
    border-color: var(--disabled);
    background: var(--disabled);
    cursor: not-allowed;
}

.clear-btn {
    background: #fff;
    color: var(--dark);
}

.clear-btn:hover:not(:disabled) {
    background: #ececec;
}

.preview-section {
    margin-bottom: 24px;
}

.preview-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    min-height: 160px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px 12px;
    color: #7a7a7a;
    border: 1px dashed var(--line);
    border-radius: 10px;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 8px;
}

.image-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.image-preview {
    width: 100%;
    height: 170px;
    object-fit: cover;
    background: #ededed;
}

.image-info {
    padding: 10px;
}

.image-name {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-size {
    color: var(--muted);
    font-size: 0.86rem;
    margin-bottom: 8px;
}

.image-actions {
    display: flex;
    gap: 8px;
}

.image-actions button {
    flex: 1;
    border: 1px solid #1e1e1e;
    background: #1e1e1e;
    color: #fff;
    border-radius: 8px;
    font-size: 0.84rem;
    padding: 7px 6px;
    cursor: pointer;
}

.image-actions .remove-image {
    border-color: #8a8a8a;
    background: #fff;
    color: #111;
}

.info-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.info-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    background: #fcfcfc;
}

.info-card h4 {
    font-size: 1rem;
    margin-bottom: 6px;
}

.info-card p {
    color: var(--muted);
    font-size: 0.92rem;
}

footer {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    color: var(--muted);
    font-size: 0.9rem;
}

footer a {
    color: #111;
}

.footer-note {
    margin-top: 4px;
    font-size: 0.82rem;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 18px;
}

.loading-content {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #cfcfcf;
    padding: 20px;
    text-align: center;
    min-width: 200px;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #ddd;
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 10px;
}

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

@media (max-width: 900px) {
    .controls {
        grid-template-columns: 1fr 1fr;
    }

    .quality-control {
        grid-column: 1 / -1;
    }

    .info-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    body {
        padding: 0;
        background: #fff;
    }

    .container {
        border-radius: 0;
        border: none;
        min-height: 100vh;
        padding: 16px;
    }

    .header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .language-switcher {
        justify-content: space-between;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
    }

    .upload-area {
        padding: 28px 12px;
    }

    .preview-container {
        grid-template-columns: 1fr;
    }
}
