/* CSS 自定义属性（变量）- 集中管理主题色 */
:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --secondary-pink: #fa709a;
    --secondary-gold: #fee140;
    --accent-pink: #f093fb;
    --accent-red: #f5576c;
    --accent-cyan: #4facfe;
    --accent-cyan-light: #00f2fe;
    --accent-green: #43e97b;
    --accent-teal: #38f9d7;
    --text-dark: #333;
    --text-muted: #666;
    --text-lighter: #adb5bd;
    --border-light: #dee2e6;
    --bg-light: #f8f9fa;
    --bg-lighter: #e9ecef;
    --stage-width: min(92vw, 960px);
    --glow-color: rgba(102, 126, 234, 0.18);
}

.external-link {
    display: inline-block;
    margin-top: 0;
    color: #9aa0a6; /* default gray */
    text-decoration: none;
    font-size: 0.95rem;
    padding: 2px 6px;
    border-radius: 6px;
}

body.light-mode .external-link {
    color: #6b7176;
    background: rgba(0,0,0,0.02);
}

body:not(.light-mode) .external-link {
    color: #c5c9cc;
    background: rgba(255,255,255,0.02);
}

.external-link:hover {
    text-decoration: underline;
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 页面基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Microsoft YaHei', sans-serif;
    background: transparent;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-dark);
    margin: 0;
    transition: background 0.8s ease, color 0.8s ease, filter 0.8s ease;
    position: relative;
}

body.light-mode {
    background: transparent;
}

/* 页面中间舞台，用于上下对齐主控卡片和图片容器 */
.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    gap: 36px;
    position: relative;
    z-index: 1;
}

body.light-mode {
    background: #fff;
}

/* 容器样式 */
.container {
    display: block;
    width: var(--stage-width);
    max-width: var(--stage-width);
    box-sizing: border-box;
}

.controls-card {
    background: #1a1a1a;
    border-radius: 16px;
    padding: 30px 30px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.6s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transition: background 0.8s ease, box-shadow 0.8s ease, transform 0.5s ease;
    position: relative;
}

body.light-mode .controls-card {
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* 主题切换时的卡片动画 */
body.theme-transition .controls-card {
    transform: translateY(-10px);
    transition: background 0.8s ease, box-shadow 0.8s ease, transform 0.5s ease;
}

/* 夜间模式切换按钮 */
.theme-toggle {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 100;
    background: #333;
    border: none;
    border-radius: 10px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.18s ease;
}

.theme-toggle:hover {
    background: #555;
    transform: scale(1.1);
    box-shadow: 0 8px 30px var(--glow-color);
}

body.light-mode .theme-toggle {
    background: #e0e0e0;
}

body.light-mode .theme-toggle:hover {
    background: #d0d0d0;
}

/* 标题样式 */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.description {
    max-width: 600px;
    margin: 0 auto 40px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.8;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.8s ease;
}

body.light-mode .description {
    background: #f0f0f0;
    color: #666;
}

/* 主题切换时的描述文本动画 */
body.theme-transition .description {
    transform: scale(0.98);
    transition: all 0.8s ease, transform 0.5s ease;
}

/* 响应式设计 */
/* 平板设备 */
@media (max-width: 1024px) {
    .stage {
        padding: 30px 15px;
        gap: 30px;
    }
    
    .container {
        width: 98vw;
        max-width: 98vw;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    .button-group {
        gap: 12px;
    }
    
    .normal_button {
        min-width: 110px;
        height: 46px;
        line-height: 46px;
        font-size: 0.95rem;
        padding: 0 20px;
    }
}

/* 移动设备 */
@media (max-width: 768px) {
    .stage {
        padding: 20px 10px;
        gap: 24px;
        min-height: 100vh;
        justify-content: flex-start;
    }
    
    .container {
        padding: 0;
        gap: 16px;
        width: 100vw;
        max-width: 100vw;
    }

    .controls-card {
        padding: 16px;
        border-radius: 12px;
        margin: 0 10px;
        width: calc(100% - 20px);
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 16px;
        text-align: center;
    }

    .description {
        font-size: 0.85rem;
        padding: 12px;
        margin: 0 10px 16px;
    }

    .button-group {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .normal_button {
        min-width: 90px;
        height: 42px;
        line-height: 42px;
        font-size: 0.85rem;
        padding: 0 12px;
        border-radius: 10px;
        flex: 1;
        max-width: 120px;
    }

    .settings-container {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 12px;
        flex-wrap: wrap;
    }

    .settings-panel {
        min-width: 100%;
        max-width: 100%;
        margin: 0 5px;
    }

    .radio-group.vertical .radio-option {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .image-container {
        min-height: 280px;
        padding: 12px;
        width: calc(100vw - 20px);
        margin: 0 10px;
        border-radius: 12px;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
        font-size: 18px;
    }
}

/* 小屏幕手机 */
@media (max-width: 480px) {
    .stage {
        padding: 15px 8px;
        gap: 20px;
    }
    
    .controls-card {
        padding: 12px;
        margin: 0 8px;
        width: calc(100% - 16px);
    }
    
    h1 {
        font-size: 1.6rem;
        margin-bottom: 12px;
    }
    
    .button-group {
        gap: 6px;
    }
    
    .normal_button {
        min-width: 80px;
        height: 38px;
        line-height: 38px;
        font-size: 0.8rem;
        padding: 0 10px;
        border-radius: 8px;
        max-width: 100px;
    }
    
    .settings-panel {
        margin: 0 3px;
    }
    
    .radio-group.vertical .radio-option {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    .image-container {
        min-height: 250px;
        padding: 10px;
        width: calc(100vw - 16px);
        margin: 0 8px;
        border-radius: 10px;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
        top: 8px;
        right: 8px;
        font-size: 16px;
    }
}

/* 加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 自定义滚动条样式 - 与主题匹配 */
/* 整个滚动条 */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

/* 滚动条轨道 */
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

body.light-mode ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.3s ease;
}

body.light-mode ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
}

/* 滚动条滑块悬停效果 */
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

body.light-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* 滚动条滑块激活状态 */
::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.7);
}

body.light-mode ::-webkit-scrollbar-thumb:active {
    background: rgba(0, 0, 0, 0.7);
}

/* 滚动条角落 */
::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox 滚动条样式 */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.05);
}

body.light-mode * {
    scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.05);
}

/* ==================== 页脚样式 ==================== */
.app-footer {
    position: relative;
    width: 100%;
    margin-top: auto;
    padding: 20px 0;
    z-index: 10;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--stage-width);
    margin: 0 auto;
    padding: 0 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    opacity: 0.8;
    transition: all 0.3s ease;
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-text {
    color: inherit;
}

.github-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: rgba(102, 126, 234, 0.1);
}

.github-link:hover {
    color: var(--primary-dark);
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.github-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.footer-version {
    font-size: 0.85rem;
    opacity: 0.7;
}

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

/* 个人项目归属地址样式 */
.footer-personal-project {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-mode .footer-personal-project {
    border-top-color: rgba(0, 0, 0, 0.1);
}

.personal-github-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-pink);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: rgba(240, 147, 251, 0.1);
    font-weight: 500;
    font-size: 0.95rem;
}

.personal-github-link:hover {
    color: var(--accent-red);
    background: rgba(240, 147, 251, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.4);
}

/* 响应式页脚 */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .footer-info {
        justify-content: center;
    }
    
    .app-footer {
        padding: 15px 0;
    }
    
    .footer-personal-project {
        margin-top: 12px;
        padding-top: 12px;
    }
    
    .personal-github-link {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
}

/* ==================== 移动端触摸上传样式 ==================== */
.image-container.touch-hint {
    position: relative;
    animation: touchHintPulse 1.5s ease-in-out infinite;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4) !important;
}

.image-container.touch-hint::after {
    content: '长按选择图片';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
    animation: touchHintFade 1.5s ease-in-out infinite;
}

@keyframes touchHintPulse {
    0%, 100% {
        transform: scale(1);
        border-color: var(--primary-color);
    }
    50% {
        transform: scale(1.02);
        border-color: var(--accent-pink);
    }
}

@keyframes touchHintFade {
    0%, 100% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* 移动端触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .image-container {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .image-container:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}