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

:root {
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --success-color: #48bb78;
    --success-hover: #38a169;
    --danger-color: #f56565;
    --secondary-color: #718096;
    --background: #f7fafc;
    --card-background: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
    margin-bottom: 15px;
}

.quick-guide {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 20px;
    margin-top: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.quick-guide p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
}

.upload-section {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--background);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #edf2f7;
    transform: translateY(-2px);
}

.upload-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-area h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.btn-primary,
.btn-success,
.btn-secondary,
.btn-danger {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-danger:hover {
    background: #e53e3e;
}

.settings {
    margin-top: 40px;
    display: grid;
    gap: 25px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.setting-item:has(.help-icon[data-tooltip]:hover) {
    z-index: 10002;
}

.setting-item label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    position: relative;
    z-index: 1;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.setting-item input[type="number"] {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* 桌面端/移动端显示控制 */
.mobile-show {
    display: none;
}

.desktop-show {
    display: block;
}

@media (max-width: 768px) {
    .mobile-show {
        display: block;
    }
    
    .desktop-show {
        display: none;
    }
}

.format-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.radio-label:hover {
    border-color: var(--primary-color);
}

.radio-label input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.preset-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-preset {
    padding: 10px 20px;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-preset.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-preset:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-preset.active:hover {
    transform: translateY(-2px);
}

.btn-preset:active {
    transform: translateY(0);
}

/* 美化 tooltip 样式 */
.btn-preset[data-tooltip] {
    cursor: help;
}

/* 桌面端悬停显示 tooltip */
@media (hover: hover) and (pointer: fine) {
    .btn-preset[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-bottom: 10px;
        padding: 12px 16px;
        background: rgba(26, 32, 44, 0.95);
        color: white;
        font-size: 0.85rem;
        font-weight: 400;
        line-height: 1.6;
        border-radius: 8px;
        white-space: pre-line;
        text-align: left;
        min-width: 250px;
        max-width: 300px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10000;
        pointer-events: none;
        animation: tooltipFadeInCentered 0.2s ease;
    }

    .btn-preset[data-tooltip]:hover::before {
        content: '';
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-bottom: 4px;
        border: 6px solid transparent;
        border-top-color: rgba(26, 32, 44, 0.95);
        z-index: 10001;
        pointer-events: none;
    }
}

/* 移动设备长按显示 tooltip - 预设按钮 */
@media (hover: none) or (pointer: coarse) {
    /* 预设按钮 - 和PC端一样，向上显示 */
    .btn-preset {
        position: relative;
    }

    .btn-preset[data-tooltip].show-mobile-tooltip::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-bottom: 10px;
        padding: 12px 16px;
        background: rgba(26, 32, 44, 0.95);
        color: white;
        font-size: 0.85rem;
        font-weight: 400;
        line-height: 1.6;
        border-radius: 8px;
        white-space: pre-line;
        text-align: left;
        min-width: 250px;
        max-width: calc(100vw - 40px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 99999;
        pointer-events: none;
        animation: tooltipFadeInCentered 0.2s ease;
    }

    .btn-preset[data-tooltip].show-mobile-tooltip::before {
        content: '';
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-bottom: 4px;
        border: 6px solid transparent;
        border-top-color: rgba(26, 32, 44, 0.95);
        z-index: 100000;
        pointer-events: none;
    }
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes tooltipFadeInUp {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tooltipFadeInCentered {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.btn-preset-special {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-preset-special:hover {
    background: var(--primary-color);
    color: white;
}

.btn-preset-special.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    background: var(--background);
}

.checkbox-label:hover {
    border-color: var(--primary-color);
    background: #edf2f7;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.checkbox-label span {
    font-size: 1.05rem;
    font-weight: 600;
}

#customColorPicker {
    display: flex;
    align-items: center;
    gap: 10px;
}

#bgColor {
    width: 60px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

/* 帮助图标样式 */
.help-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: help;
    margin-left: 6px;
    transition: all 0.3s ease;
    vertical-align: middle;
    position: relative;
    z-index: 10;
}

/* 桌面端 hover 效果 */
@media (hover: hover) and (pointer: fine) {
    .help-icon:hover {
        background: var(--primary-hover);
        transform: scale(1.1);
    }
}

/* 移动端 - 禁用 hover 效果，防止跳动 */
@media (hover: none) or (pointer: coarse) {
    .help-icon {
        transition: background 0.2s ease;
    }
    
    .help-icon:active {
        background: var(--primary-hover);
    }
}

/* 帮助图标的 tooltip - 桌面端 */
@media (hover: hover) and (pointer: fine) {
    .help-icon[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 8px;
        padding: 12px 16px;
        background: rgba(26, 32, 44, 0.95);
        color: white;
        font-size: 0.85rem;
        font-weight: 400;
        line-height: 1.6;
        border-radius: 8px;
        white-space: pre-line;
        text-align: left;
        min-width: 200px;
        max-width: 300px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10000;
        pointer-events: none;
        animation: tooltipFadeIn 0.2s ease;
    }

    .help-icon[data-tooltip]:hover::before {
        content: '';
        position: absolute;
        top: 100%;
        left: 9px;
        margin-top: 2px;
        border: 6px solid transparent;
        border-bottom-color: rgba(26, 32, 44, 0.95);
        z-index: 10001;
        pointer-events: none;
    }
    
    /* checkbox-label 内的 help-icon tooltip 向上显示 */
    .checkbox-label .help-icon[data-tooltip]:hover::after {
        top: auto;
        bottom: 100%;
        margin-top: 0;
        margin-bottom: 8px;
        animation: tooltipFadeInUp 0.2s ease;
    }
    
    .checkbox-label .help-icon[data-tooltip]:hover::before {
        top: auto;
        bottom: 100%;
        margin-top: 0;
        margin-bottom: 2px;
        border-bottom-color: transparent;
        border-top-color: rgba(26, 32, 44, 0.95);
    }

    .radio-label[data-tooltip]:hover {
        background: #edf2f7;
    }
    
    .radio-label[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 8px;
        padding: 10px 14px;
        background: rgba(26, 32, 44, 0.95);
        color: white;
        font-size: 0.85rem;
        font-weight: 400;
        line-height: 1.5;
        border-radius: 8px;
        white-space: pre-line;
        text-align: center;
        min-width: 180px;
        max-width: 280px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10000;
        pointer-events: none;
        animation: tooltipFadeInCentered 0.2s ease;
    }
    
    .radio-label[data-tooltip]:hover::before {
        content: '';
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 2px;
        border: 6px solid transparent;
        border-bottom-color: rgba(26, 32, 44, 0.95);
        z-index: 10001;
        pointer-events: none;
    }
}

/* 帮助图标的 tooltip - 移动端 */
@media (hover: none) or (pointer: coarse) {
    /* 普通帮助图标 - 向下显示，和PC端一样 */
    .help-icon[data-tooltip].show-mobile-tooltip::after {
        content: attr(data-tooltip);
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 8px;
        padding: 12px 16px;
        background: rgba(26, 32, 44, 0.95);
        color: white;
        font-size: 0.85rem;
        font-weight: 400;
        line-height: 1.6;
        border-radius: 8px;
        white-space: pre-line;
        text-align: left;
        min-width: 200px;
        max-width: 300px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10000;
        pointer-events: none;
        animation: tooltipFadeIn 0.2s ease;
    }
    
    .help-icon[data-tooltip].show-mobile-tooltip::before {
        content: '';
        position: absolute;
        top: 100%;
        left: 9px;
        margin-top: 2px;
        border: 6px solid transparent;
        border-bottom-color: rgba(26, 32, 44, 0.95);
        z-index: 10001;
        pointer-events: none;
    }
    
    /* checkbox-label 内的 help-icon - 向上显示，和PC端一样 */
    .checkbox-label .help-icon[data-tooltip].show-mobile-tooltip::after {
        top: auto;
        bottom: 100%;
        margin-top: 0;
        margin-bottom: 8px;
        animation: tooltipFadeInUp 0.2s ease;
    }
    
    .checkbox-label .help-icon[data-tooltip].show-mobile-tooltip::before {
        top: auto;
        bottom: 100%;
        margin-top: 0;
        margin-bottom: 2px;
        border-bottom-color: transparent;
        border-top-color: rgba(26, 32, 44, 0.95);
    }
    
    /* 格式选项 - 和PC端一样 */
    .radio-label[data-tooltip].show-mobile-tooltip::after {
        content: attr(data-tooltip);
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 8px;
        padding: 10px 14px;
        background: rgba(26, 32, 44, 0.95);
        color: white;
        font-size: 0.85rem;
        font-weight: 400;
        line-height: 1.5;
        border-radius: 8px;
        white-space: pre-line;
        text-align: center;
        min-width: 180px;
        max-width: 280px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10000;
        pointer-events: none;
        animation: tooltipFadeInCentered 0.2s ease;
    }
    
    .radio-label[data-tooltip].show-mobile-tooltip::before {
        content: '';
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 2px;
        border: 6px solid transparent;
        border-bottom-color: rgba(26, 32, 44, 0.95);
        z-index: 10001;
        pointer-events: none;
    }
}

/* radio label 的 tooltip */
.radio-label[data-tooltip] {
    cursor: help;
    position: relative;
}

.results {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.results h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.batch-actions {
    margin-bottom: 30px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.image-list {
    display: grid;
    gap: 20px;
}

.image-item {
    background: var(--background);
    border-radius: 15px;
    padding: 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    transition: transform 0.3s ease;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.image-preview {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid var(--border-color);
}

.image-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    word-break: break-all;
}

.image-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.size-reduction {
    color: var(--success-color);
    font-weight: 700;
}

.image-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    padding: 20px;
    opacity: 0.9;
}

footer p {
    font-size: 1rem;
}

/* 响应式设计 */
/* 平板设备 (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 15px;
    }
    
    .preset-buttons {
        gap: 8px;
    }
    
    .btn-preset {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* 手机设备 (max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }
    
    .quick-guide {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .upload-section,
    .results {
        padding: 20px;
        border-radius: 15px;
    }
    
    .upload-area {
        padding: 40px 15px;
    }
    
    .upload-icon {
        width: 60px;
        height: 60px;
    }
    
    .upload-area h2 {
        font-size: 1.4rem;
    }
    
    /* 预设按钮横向滚动 */
    .preset-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .btn-preset {
        flex: 0 0 auto;
        min-width: 90px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .btn-preset-special {
        min-width: 100px;
    }
    
    /* 设置项 */
    .settings {
        gap: 20px;
    }
    
    .setting-item {
        font-size: 0.95rem;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .radio-label {
        width: 100%;
    }

    /* 结果展示 */
    .image-item {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 15px;
        padding: 15px;
    }

    .image-preview {
        margin: 0 auto;
    }

    .image-stats {
        justify-content: center;
        gap: 15px;
    }

    .image-actions {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }
    
    .batch-actions {
        flex-direction: column;
    }
    
    .batch-actions button {
        width: 100%;
    }
}

/* 小屏手机 (max-width: 480px) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.6rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .quick-guide {
        font-size: 0.85rem;
    }
    
    .upload-section,
    .results {
        padding: 15px;
    }
    
    .upload-area {
        padding: 30px 10px;
    }
    
    .upload-icon {
        width: 50px;
        height: 50px;
    }
    
    .upload-area h2 {
        font-size: 1.2rem;
    }
    
    .upload-area p {
        font-size: 0.9rem;
    }
    
    .btn-primary,
    .btn-success,
    .btn-secondary {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .btn-preset {
        min-width: 80px;
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .setting-item label {
        font-size: 0.9rem;
    }
    
    .setting-hint {
        font-size: 0.8rem;
    }
    
    .help-icon {
        width: 16px;
        height: 16px;
        line-height: 16px;
        font-size: 0.7rem;
    }
    
    /* Tooltip 在小屏幕上的调整 */
    .btn-preset[data-tooltip]:hover::after,
    .help-icon[data-tooltip]:hover::after {
        max-width: 250px;
        font-size: 0.8rem;
        padding: 10px 12px;
    }
    
    .image-name {
        font-size: 1rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 0.9rem;
    }
}

/* 超小屏设备 (max-width: 360px) */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.4rem;
    }
    
    .preset-buttons {
        gap: 6px;
    }
    
    .btn-preset {
        min-width: 70px;
        padding: 8px;
        font-size: 0.75rem;
    }
    
    .upload-area h2 {
        font-size: 1.1rem;
    }
}

/* 横屏适配 */
@media (max-height: 600px) and (orientation: landscape) {
    .upload-area {
        padding: 20px;
    }
    
    .upload-icon {
        width: 40px;
        height: 40px;
    }
    
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .quick-guide {
        padding: 8px 15px;
    }
}

/* 加载动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

