/* ========================================
   Agnes Image Studio - 现代化样式
   ======================================== */

/* CSS 变量定义 */
:root {
    /* 主色调 - 紫蓝渐变 */
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --accent: #06b6d4;
    --accent-light: #22d3ee;
    --gradient: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
    --gradient-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(6, 182, 212, 0.1) 100%);
    --gradient-bg: linear-gradient(135deg, #f5f3ff 0%, #ecfeff 100%);

    /* 语义色 */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* 中性色 */
    --bg: #fafafa;
    --bg-elevated: #ffffff;
    --bg-soft: #f4f4f5;
    --text: #18181b;
    --text-secondary: #52525b;
    --text-tertiary: #a1a1aa;
    --border: #e4e4e7;
    --border-light: #f4f4f5;

    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.3);

    /* 圆角 */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* 过渡 */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* 字体 */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

/* 暗色主题 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #09090b;
        --bg-elevated: #18181b;
        --bg-soft: #27272a;
        --text: #fafafa;
        --text-secondary: #a1a1aa;
        --text-tertiary: #71717a;
        --border: #27272a;
        --border-light: #1f1f23;
        --gradient-bg: linear-gradient(135deg, #18181b 0%, #0c0a1e 100%);
    }
}

/* 手动切换暗色 */
[data-theme="dark"] {
    --bg: #09090b;
    --bg-elevated: #18181b;
    --bg-soft: #27272a;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --border: #27272a;
    --border-light: #1f1f23;
    --gradient-bg: linear-gradient(135deg, #18181b 0%, #0c0a1e 100%);
}

/* ========================================
   基础重置
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--gradient-bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
    font-size: inherit;
}

input, textarea {
    font-family: inherit;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   背景装饰
   ======================================== */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #ec4899 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
    opacity: 0.2;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -30px) scale(1.1); }
    66% { transform: translate(-30px, 50px) scale(0.9); }
}

.blob-3 {
    animation-name: float-center;
}

@keyframes float-center {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
}

/* ========================================
   导航栏
   ======================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
    .navbar {
        background: rgba(24, 24, 27, 0.7);
    }
}

[data-theme="dark"] .navbar {
    background: rgba(24, 24, 27, 0.7);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
    display: block;
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* ========================================
   通用按钮
   ======================================== */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition);
    background: transparent;
}

.btn-icon:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--primary);
    background: var(--gradient-soft);
    transition: all var(--transition);
    font-weight: 500;
}

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

.btn-mini svg {
    width: 12px;
    height: 12px;
}

/* 文本框底部右侧按钮容器 */
.btn-mini-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* 回撤按钮 */
.btn-undo {
    color: var(--text-secondary);
    background: var(--bg-soft);
    border: 1px solid var(--border-light);
    transition: all var(--transition);
}

.btn-undo .icon-undo {
    width: 13px;
    height: 13px;
    transition: transform var(--transition);
}

.btn-undo:hover {
    background: var(--bg-card);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn-undo:hover .icon-undo {
    transform: translateX(-2px);
}

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

.btn-undo:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.btn-mini.hidden {
    display: none !important;
}

/* AI 优化按钮 */
.btn-ai-optimize {
    position: relative;
    gap: 5px;
    color: var(--primary);
    background: var(--gradient-soft);
    border: 1px solid transparent;
    overflow: hidden;
}

.btn-ai-optimize .icon-sparkle {
    width: 13px;
    height: 13px;
    transition: transform var(--transition);
}

.btn-ai-optimize:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.btn-ai-optimize:hover .icon-sparkle {
    transform: rotate(15deg) scale(1.1);
}

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

.btn-ai-optimize:disabled {
    cursor: not-allowed;
    opacity: 0.85;
    transform: none;
    box-shadow: none;
}

.btn-ai-optimize .btn-spinner {
    display: none;
    width: 12px;
    height: 12px;
    border: 1.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ai-optimize-spin 0.8s linear infinite;
}

.btn-ai-optimize.is-loading .btn-spinner {
    display: inline-block;
}

.btn-ai-optimize.is-loading .icon-sparkle {
    display: none;
}

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

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    background: var(--gradient);
    color: white;
    font-weight: 600;
    font-size: 15px;
    transition: all var(--transition);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:hover::before {
    left: 100%;
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius);
    background: var(--bg-soft);
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition);
    border: 1px solid var(--border);
}

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

.btn-text {
    color: var(--text-tertiary);
    font-size: 13px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-text:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   主内容区
   ======================================== */
.main-content {
    padding: 32px 0 64px;
    min-height: calc(100vh - 80px);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ========================================
   模式切换器
   ======================================== */
.mode-switcher {
    display: inline-flex;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 24px;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: color var(--transition);
    position: relative;
    z-index: 2;
}

.mode-btn svg {
    width: 16px;
    height: 16px;
}

.mode-btn.active {
    color: white;
}

.mode-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    background: var(--gradient);
    border-radius: var(--radius-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    box-shadow: var(--shadow-md);
}

/* ========================================
   工作区
   ======================================== */
.workspace {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 24px;
    align-items: start;
    animation: pageFadeIn 0.3s ease;
}

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

.control-panel,
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    background: var(--gradient-soft);
    color: var(--primary);
    letter-spacing: 0.3px;
}

/* ========================================
   表单
   ======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.label-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.label-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

.form-textarea,
.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    transition: all var(--transition);
    resize: vertical;
}

.form-textarea {
    min-height: 100px;
    font-family: inherit;
}

.form-textarea:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.textarea-wrapper {
    position: relative;
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.char-count {
    font-size: 11px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .form-input {
    padding-right: 44px;
}

.input-with-icon .btn-icon {
    position: absolute;
    right: 4px;
    width: 32px;
    height: 32px;
}

.form-tip {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.form-tip svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ========================================
   上传区域
   ======================================== */
.upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    transition: all var(--transition);
    overflow: hidden;
}

.upload-area.dragover {
    border-color: var(--primary);
    background: var(--gradient-soft);
}

.upload-area.has-files {
    border-style: solid;
    border-color: var(--primary);
    background: var(--bg-elevated);
}

.upload-placeholder {
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition);
}

.upload-placeholder:hover {
    color: var(--primary);
}

.upload-placeholder svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.upload-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.upload-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.upload-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 12px;
}

.upload-preview:empty {
    display: none;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-soft);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

.preview-item:hover {
    transform: scale(1.02);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    backdrop-filter: blur(8px);
    transition: all var(--transition);
}

.preview-item .remove-btn:hover {
    background: var(--error);
    transform: scale(1.1);
}

.preview-item .remove-btn svg {
    width: 12px;
    height: 12px;
}

.preview-item .index-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
}

/* ========================================
   尺寸选择
   ======================================== */
.size-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.size-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition);
    cursor: pointer;
}

.size-chip small {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 400;
    margin-top: 2px;
}

.size-chip:hover {
    border-color: var(--primary);
    background: var(--gradient-soft);
}

.size-chip.active {
    border-color: var(--primary);
    background: var(--gradient-soft);
    color: var(--primary);
}

.size-chip.active small {
    color: var(--primary);
    opacity: 0.7;
}

.size-chip svg {
    width: 14px;
    height: 14px;
}

.custom-size {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.custom-size input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    text-align: center;
    width: 0;
}

.custom-size input:focus {
    outline: none;
    border-color: var(--primary);
}

.custom-size span {
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ========================================
   高级选项
   ======================================== */
.advanced-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 0;
    transition: color var(--transition);
}

.advanced-toggle:hover {
    color: var(--primary);
}

.advanced-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition);
}

.advanced-toggle.expanded svg {
    transform: rotate(180deg);
}

.advanced-options {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-soft);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.radio-card {
    position: relative;
    cursor: pointer;
}

.radio-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-content {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    transition: all var(--transition);
    text-align: center;
}

.radio-content strong {
    display: block;
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 2px;
}

.radio-content small {
    font-size: 11px;
    color: var(--text-tertiary);
}

.radio-card input:checked + .radio-content {
    border-color: var(--primary);
    background: var(--gradient-soft);
}

.radio-card input:checked + .radio-content strong {
    color: var(--primary);
}

/* ========================================
   生成按钮
   ======================================== */
.btn-generate {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    margin-top: 8px;
}

.btn-generate svg {
    width: 18px;
    height: 18px;
}

.btn-loader {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* ========================================
   结果展示
   ======================================== */
.result-section {
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.result-display {
    flex: 1;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.empty-state,
.result-loading,
.result-error {
    text-align: center;
    padding: 40px 20px;
    width: 100%;
}

.empty-icon,
.error-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: var(--gradient-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon svg,
.error-icon svg {
    width: 40px;
    height: 40px;
}

.error-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.empty-state h4,
.result-loading h4,
.result-error h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p,
.result-loading p,
.result-error p {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

.result-error .btn-secondary {
    margin-top: 16px;
}

/* 加载动画 */
.loading-animation {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.loading-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gradient);
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-circle:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-circle:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-progress {
    width: 200px;
    height: 4px;
    background: var(--bg-soft);
    border-radius: var(--radius-full);
    margin: 20px auto 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient);
    border-radius: var(--radius-full);
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; margin-left: 0; }
    50% { width: 60%; margin-left: 20%; }
    100% { width: 0%; margin-left: 100%; }
}

/* 结果图片 */
.result-image {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-soft);
}

.result-image img {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

.result-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(-4px);
    transition: all var(--transition);
}

.result-image:hover .result-actions {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .result-actions {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(8px);
    transition: all var(--transition);
}

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

.btn-action svg {
    width: 14px;
    height: 14px;
}

.result-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
}

.result-tab {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.result-tab.active {
    background: var(--primary);
    color: white;
}

.result-tab:hover:not(.active) {
    background: var(--border);
}

/* ========================================
   历史记录
   ======================================== */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 2px;
}

.history-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-soft);
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}

.history-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-item .delete-history {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
}

.history-item:hover .delete-history {
    display: flex;
}

.history-item .delete-history svg {
    width: 10px;
    height: 10px;
}

/* ========================================
   弹窗
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    position: relative;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.help-content {
    max-height: 60vh;
}

.help-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.help-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.help-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.help-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 4px;
}

.help-section p strong {
    color: var(--text);
    font-weight: 600;
}

/* ========================================
   Toast 提示
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    color: var(--text);
    min-width: 240px;
    max-width: 360px;
    pointer-events: auto;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--info);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-icon svg {
    width: 18px;
    height: 18px;
}

.toast-content {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    color: var(--text);
    background: var(--bg-soft);
}

.toast-close svg {
    width: 12px;
    height: 12px;
}

.toast.removing {
    animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ========================================
   全屏查看
   ======================================== */
.fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    animation: fadeIn 0.2s ease;
}

.fullscreen-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(8px);
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.fullscreen-close svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        order: -1;
    }

    .result-section {
        min-height: auto;
    }

    .result-display {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        padding: 12px 16px;
    }

    .logo-text h1 {
        font-size: 16px;
    }

    .logo-subtitle {
        font-size: 10px;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .main-content {
        padding: 20px 0 40px;
    }

    .container {
        padding: 0 16px;
    }

    .panel-section {
        padding: 16px;
    }

    .mode-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .size-presets {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .btn-action span,
    .btn-action {
        font-size: 11px;
    }

    .result-actions {
        top: 8px;
        right: 8px;
        flex-wrap: wrap;
    }

    .btn-action {
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .size-presets {
        grid-template-columns: repeat(2, 1fr);
    }

    .radio-group {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: 0;
        max-width: 100%;
    }
}

/* ========================================
   滚动条
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ========================================
   动画
   ======================================== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

.fade-in-up {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   视频生成相关样式
   ======================================== */

/* 视频子标签 */
.video-sublabel {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-sublabel::before {
    content: '';
    width: 3px;
    height: 12px;
    background: var(--gradient);
    border-radius: var(--radius-full);
}

/* 视频元信息 */
.video-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--gradient-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.meta-item svg {
    width: 14px;
    height: 14px;
    color: var(--primary);
}

.meta-item strong {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* 行式布局字段 */
.inline-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.inline-fields .form-group {
    margin-bottom: 0;
}

/* 设置分组分隔线 */
.setting-divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
    position: relative;
}

.setting-divider::after {
    content: '视频 API';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-elevated);
    padding: 0 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 视频结果展示 */
.result-video {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    position: relative;
    box-shadow: var(--shadow-md);
}

.result-video video {
    width: 100%;
    height: auto;
    max-height: 70vh;
    display: block;
    background: #000;
}

.result-video .result-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(-4px);
    transition: all var(--transition);
    z-index: 2;
}

.result-video:hover .result-actions {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .result-video .result-actions {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-soft);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.video-info:empty {
    display: none;
}

.video-info-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.video-info-item strong {
    color: var(--text);
    font-weight: 600;
}

/* 加载元信息 */
.loading-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.loading-meta:empty {
    display: none;
}

.loading-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-soft);
    border-radius: var(--radius-full);
}

.loading-meta-item strong {
    color: var(--text);
    font-weight: 600;
}

/* 进度条增强 */
.progress-bar {
    transition: width 0.3s ease;
}

@keyframes spin-progress {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 视频模式下的进度条带脉冲 */
.video-progress {
    position: relative;
    width: 200px;
    height: 4px;
    background: var(--bg-soft);
    border-radius: var(--radius-full);
    margin: 20px auto 0;
    overflow: hidden;
}

.video-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--gradient);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.video-progress-shine {
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
    0% { left: -30%; }
    100% { left: 100%; }
}

/* 模式按钮适配更多选项 */
.mode-switcher {
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .mode-switcher {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    .mode-btn {
        padding: 8px 10px;
        font-size: 12px;
        justify-content: center;
    }

    .mode-btn span {
        font-size: 12px;
    }

    .mode-btn svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 380px) {
    .mode-btn span {
        display: none;
    }

    .mode-btn {
        padding: 8px;
    }
}

/* 历史项目支持视频 */
.history-item .video-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.history-item .video-badge svg {
    width: 10px;
    height: 10px;
}

.history-item .play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.history-item:hover .play-overlay {
    opacity: 1;
}

.play-overlay svg {
    width: 24px;
    height: 24px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
