/* ============================================================
   AI 图像生成 - 现代 UI 样式
   支持：中文 (LTR) / 维吾尔语 (RTL)
   字体策略：
   - 维吾尔文优先：UKIJ Tuz Tom > Alkatip Basma Tom > Noto Sans Arabic
   - 中文优先：PingFang SC > Microsoft YaHei > Noto Sans SC
   - 数字保持 LTR：SF Mono / Roboto Mono
   ============================================================ */

/* ====== 字体变量 ====== */
:root {
    /* 中文优先字体栈（系统字体优先） */
    --font-zh: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB',
               'Noto Sans SC', 'Helvetica Neue', Arial, sans-serif;

    /* 维吾尔文优先字体栈（开罗变体支持维吾尔字符） */
    --font-ug: 'UKIJ Tuz Tom', 'UKIJ Tuz', 'UKIJ Ekran',
               'Alkatip Basma Tom', 'Alkatip Basma',
               'Noto Sans Arabic', 'Noto Naskh Arabic', 'Amiri',
               'Geeza Pro', 'Tahoma', sans-serif;

    /* 衬线维吾尔文（适合标题/装饰） */
    --font-ug-serif: 'Amiri', 'Noto Naskh Arabic', 'Scheherazade New',
                     'UKIJ Tuz', serif;

    /* 数字字体（保持 LTR） */
    --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono',
                 'Source Code Pro', Consolas, monospace;
}

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

html, body { height: 100%; }

/* ====== 默认字体：中文 ====== */
body {
    font-family: var(--font-zh);
    background: #0a0a14;
    background-image:
        radial-gradient(at 20% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 80% 100%, rgba(236, 72, 153, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(59, 130, 246, 0.08) 0px, transparent 50%);
    color: #e8e8f0;
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ====== 维吾尔文（RTL）状态：切换字体优先级 ====== */
[dir="rtl"] body,
[lang="ug-CN"] body {
    font-family: var(--font-ug);
    /* 维吾尔文需要稍大的行高和字距 */
    line-height: 1.7;
    letter-spacing: 0;
}

/* 维吾尔文标题用衬线字体更有特色 */
[dir="rtl"] .hero-title,
[dir="rtl"] .panel-title,
[dir="rtl"] .logo-text h1 {
    font-family: var(--font-ug-serif);
    font-weight: 700;
}

/* 维吾尔文按钮和标签 */
[dir="rtl"] .btn,
[dir="rtl"] .form-group label,
[dir="rtl"] .panel-tag,
[dir="rtl"] .hint,
[dir="rtl"] .stat-label {
    font-family: var(--font-ug);
    font-weight: 500;
}

/* 维吾尔文数字保持 LTR（避免反向） */
[dir="rtl"] .stat-num,
[dir="rtl"] .progress-fill,
[dir="rtl"] .status-elapsed,
[dir="rtl"] .char-count,
[dir="rtl"] .model-meta,
[dir="rtl"] .history-meta,
[dir="rtl"] input[type="text"],
[dir="rtl"] textarea {
    font-family: var(--font-ug);
}

/* 维吾尔文输入框特殊处理：保持文本 RTL，但数字 LTR */
[dir="rtl"] textarea {
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext; /* 自动按字符方向 */
}

/* 维吾尔文提示词占位符 */
[dir="rtl"] ::placeholder {
    text-align: right;
    font-family: var(--font-ug);
}

/* 维吾尔文标题字号略大（字符更复杂） */
[dir="rtl"] .hero-title { font-size: 38px; }
[dir="rtl"] .logo-text h1 { font-size: 19px; }
[dir="rtl"] .panel-title { font-size: 19px; }
[dir="rtl"] select, [dir="rtl"] input, [dir="rtl"] textarea { font-size: 14.5px; }

/* 维吾尔文统计数字用等宽数字字体 */
[dir="rtl"] .stat-num {
    font-family: var(--font-ug), var(--font-mono);
    font-feature-settings: 'tnum'; /* 等宽数字 */
}

/* ============================================================
   自定义比例/尺寸面板
   ============================================================ */
.custom-size-panel {
    margin-top: 10px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 12px;
    animation: slideDown 0.25s ease-out;
}

.supported-ratios {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(167, 139, 250, 0.06);
    border: 1px dashed rgba(167, 139, 250, 0.2);
    border-radius: 8px;
    font-size: 11px;
}
.supported-label {
    color: #8b8ba8;
    font-weight: 600;
    flex-shrink: 0;
}
.supported-list {
    color: #c4b5fd;
    font-family: var(--font-mono);
    font-weight: 500;
    line-height: 1.6;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); max-height: 0; }
    to { opacity: 1; transform: translateY(0); max-height: 400px; }
}

.custom-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 3px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}
.custom-tab {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #8b8ba8;
    border-radius: 6px;
    transition: all 0.2s;
}
.custom-tab:hover { color: #d4d4e8; }
.custom-tab.active {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    color: #fff;
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.3);
}

.custom-mode-panel { animation: fadeIn 0.2s; }

.custom-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.custom-input-row input[type="number"] {
    flex: 1;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
    font-family: var(--font-mono);
    /* 隐藏 number input 上下箭头 */
    -moz-appearance: textfield;
    appearance: textfield;
}
.custom-input-row input::-webkit-outer-spin-button,
.custom-input-row input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.custom-input-row input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
    background: rgba(0, 0, 0, 0.4);
}
.custom-sep {
    color: #a78bfa;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.custom-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.custom-presets button {
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #c4b5fd;
    background: rgba(167, 139, 250, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 6px;
    transition: all 0.2s;
    font-family: var(--font-mono);
}
.custom-presets button:hover {
    background: rgba(167, 139, 250, 0.25);
    border-color: rgba(167, 139, 250, 0.5);
    transform: translateY(-1px);
}
.custom-presets button:active { transform: translateY(0); }

.custom-error {
    padding: 6px 10px;
    background: rgba(236, 72, 153, 0.1);
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 11px;
    margin-bottom: 8px;
    animation: shake 0.3s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.custom-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}
.custom-preview.invalid { opacity: 0.5; }
.preview-shape {
    width: 80px;
    height: 60px;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.4), rgba(236, 72, 153, 0.4));
    border: 1px solid rgba(167, 139, 250, 0.6);
    border-radius: 4px;
    transition: all 0.3s;
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.2);
    flex-shrink: 0;
}
.preview-text {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #c4b5fd;
    font-weight: 600;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; outline: none; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(167, 139, 250, 0.4); }

/* ============================================================
   布局
   ============================================================ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* 顶部 */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 32px;
    background: rgba(10, 10, 20, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky; top: 0; z-index: 100;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 32px; filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.5)); }
.logo-text h1 {
    font-size: 18px; font-weight: 700;
    background: linear-gradient(135deg, #a78bfa 0%, #ec4899 50%, #fbbf24 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}
.logo-sub { font-size: 11px; color: #7c7ca0; font-weight: 500; }

/* 语言切换 */
.lang-switch {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 4px;
    position: relative;
    backdrop-filter: blur(8px);
}

/* 翻译工具按钮组 */
.i18n-tools {
    display: inline-flex;
    gap: 6px;
    margin-inline-end: 8px;
}
.tool-btn {
    width: 36px; height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    color: #b8b8d1;
}
.tool-btn:hover {
    background: rgba(167, 139, 250, 0.15);
    border-color: rgba(167, 139, 250, 0.4);
    transform: translateY(-1px);
}
.tool-btn.active {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(167, 139, 250, 0.4);
}

/* 编辑模式下的可编辑元素 */
.i18n-editable {
    position: relative;
    cursor: text !important;
    transition: all 0.2s;
    outline: 1px dashed rgba(251, 191, 36, 0.3);
    outline-offset: 2px;
    border-radius: 4px;
}
.i18n-editable:hover {
    outline: 1px dashed rgba(251, 191, 36, 0.7);
    background: rgba(251, 191, 36, 0.05) !important;
}
.i18n-editable:focus {
    outline: 2px solid #fbbf24 !important;
    background: rgba(251, 191, 36, 0.1) !important;
}
body.edit-mode-active {
    /* 编辑模式指示 */
}
body.edit-mode-active::before {
    content: '✏️ 翻译编辑模式 · 点击任意文字修改 · 失焦自动保存';
    position: fixed;
    top: 0; left: 0; right: 0;
    padding: 8px 16px;
    background: linear-gradient(90deg, #fbbf24, #ec4899);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    z-index: 9999;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
.lang-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    font-size: 13px; font-weight: 500;
    color: #8b8ba8;
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}
.lang-btn:hover { color: #d4d4e8; }
.lang-btn.active { color: #fff; }
.lang-btn .lang-flag {
    font-size: 11px;
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-weight: 600;
}
.lang-btn.active .lang-flag { background: rgba(255, 255, 255, 0.15); }
.lang-btn.active::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    border-radius: 20px;
    z-index: -1;
    box-shadow: 0 4px 12px rgba(167, 139, 250, 0.4);
}

/* Hero */
.hero {
    max-width: 1600px; width: 100%;
    margin: 0 auto;
    padding: 32px 32px 24px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 32px;
    flex-wrap: wrap;
}
.hero-content { flex: 1; min-width: 280px; }
.hero-title {
    font-size: 36px; font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #c4b5fd 50%, #f9a8d4 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -1px;
}
.hero-desc { font-size: 14px; color: #9c9cb8; max-width: 560px; }

.hero-stats {
    display: flex; align-items: center; gap: 20px;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    backdrop-filter: blur(8px);
}
.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-num {
    font-size: 22px; font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 11px; color: #7c7ca0; margin-top: 2px; }
.stat-divider { width: 1px; height: 28px; background: rgba(255, 255, 255, 0.08); }

/* 主体 */
.main {
    flex: 1;
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 24px;
    padding: 0 32px 32px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}
@media (max-width: 960px) {
    .main { grid-template-columns: 1fr; padding: 0 16px 16px; }
    .hero { padding: 20px 16px 16px; }
    .hero-title { font-size: 24px; }
    .topbar { padding: 12px 16px; }
}

/* 面板 */
.panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.panel-title {
    font-size: 18px; font-weight: 700; color: #fff;
    letter-spacing: -0.3px;
}
.panel-tag {
    font-size: 10px; font-weight: 600;
    padding: 3px 8px;
    background: rgba(236, 72, 153, 0.15);
    color: #f9a8d4;
    border-radius: 8px;
    letter-spacing: 0.5px;
}
.panel-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 32px; height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.icon-btn:hover { background: rgba(167, 139, 250, 0.2); border-color: rgba(167, 139, 250, 0.4); }

/* ============================================================
   表单
   ============================================================ */
.form-group { margin-bottom: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group label {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; color: #b8b8d1; margin-bottom: 8px; font-weight: 600;
}
.required { color: #ec4899; }
.hint { font-size: 11px; color: #7c7ca0; font-weight: 400; }

/* 输入框 */
.select-wrapper { position: relative; }
select, input[type="text"], textarea {
    width: 100%;
    padding: 11px 14px;
    padding-inline-end: 36px; /* RTL 适配 */
    background: rgba(0, 0, 0, 0.3);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}
select {
    background-image: none; /* 用自定义箭头 */
    cursor: pointer;
}
select option { background: #1a1a2e; color: #fff; }
.select-arrow {
    position: absolute;
    inset-inline-end: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #7c7ca0;
    font-size: 12px;
    transition: color 0.2s;
}
select:focus ~ .select-arrow,
.select-wrapper:hover .select-arrow { color: #a78bfa; }
select:focus, input:focus, textarea:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.12);
    background: rgba(0, 0, 0, 0.4);
}
textarea {
    resize: vertical;
    min-height: 110px;
    line-height: 1.6;
    padding: 12px 14px;
    padding-inline-end: 14px;
}
.char-count {
    text-align: end;
    font-size: 11px;
    color: #7c7ca0;
    margin-top: 4px;
}

/* 模型元信息 */
.model-meta {
    margin-top: 8px;
    font-size: 12px;
    color: #9c9cb8;
    min-height: 18px;
    display: flex; flex-wrap: wrap; gap: 12px;
}
.model-meta .meta-vendor { color: #c4b5fd; }
.model-meta .meta-price {
    color: #fbbf24;
    padding: 1px 8px;
    background: rgba(251, 191, 36, 0.1);
    border-radius: 6px;
}
.model-meta .meta-ref { color: #34d399; }

/* 按钮 */
.btn-mini {
    background: rgba(167, 139, 250, 0.12);
    color: #c4b5fd;
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 600;
}
.btn-mini:hover { background: rgba(167, 139, 250, 0.25); }

.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.btn {
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, #a78bfa 0%, #ec4899 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(167, 139, 250, 0.3);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(167, 139, 250, 0.45);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
    background: rgba(255, 255, 255, 0.06);
    color: #b8b8d1;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.btn-icon { font-size: 16px; }
.btn-shine {
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}
.btn-primary:hover .btn-shine { left: 100%; }

/* ============================================================
   上传
   ============================================================ */
.upload-area {
    position: relative;
    border: 1.5px dashed rgba(167, 139, 250, 0.3);
    border-radius: 12px;
    padding: 18px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.25s;
    min-height: 90px;
}
.upload-area:hover, .upload-area.dragover {
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.06);
    transform: scale(1.005);
}
.upload-placeholder {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    color: #8b8ba8; font-size: 13px;
    text-align: center;
}
.upload-icon { font-size: 28px; }
.upload-placeholder small { font-size: 11px; color: #6b6b85; }

.upload-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.upload-preview:empty { display: none; }
.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: transform 0.2s;
}
.preview-item:hover { transform: scale(1.05); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-remove {
    position: absolute; top: 4px;
    inset-inline-end: 4px;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(0, 0, 0, 0.8); color: #fff;
    font-size: 14px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.preview-remove:hover { background: #ec4899; transform: rotate(90deg); }

/* ============================================================
   状态卡
   ============================================================ */
.status-card {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
}
.status-empty, .status-running, .status-error {
    text-align: center; width: 100%;
}
.empty-illustration, .error-illustration {
    position: relative;
    width: 80px; height: 80px;
    margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
}
.empty-glow {
    position: absolute; inset: 0;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.3) 0%, transparent 70%);
    animation: pulse 2.5s ease-in-out infinite;
}
.empty-icon, .error-icon { font-size: 48px; position: relative; z-index: 1; }
.empty-text { color: #d4d4e8; font-size: 14px; margin-bottom: 4px; font-weight: 500; }
.empty-sub { color: #6b6b85; font-size: 12px; }
.error-text { color: #fca5a5; font-size: 14px; margin-bottom: 12px; }
.hidden { display: none !important; }

.status-text {
    color: #fff; font-size: 16px; margin-bottom: 6px;
    font-weight: 600;
}
.status-detail { color: #8b8ba8; font-size: 12px; margin-bottom: 16px; }
.status-elapsed {
    font-size: 11px; color: #6b6b85;
    margin-top: 8px;
    font-family: 'SF Mono', Monaco, monospace;
}

.spinner-advanced {
    position: relative;
    width: 50px; height: 50px;
    margin: 0 auto 16px;
}
.spinner-ring {
    position: absolute; inset: 0;
    border: 2px solid transparent;
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
.spinner-ring:nth-child(2) {
    inset: 6px;
    border-top-color: #ec4899;
    animation-duration: 1.4s;
    animation-direction: reverse;
}
.spinner-ring:nth-child(3) {
    inset: 12px;
    border-top-color: #fbbf24;
    animation-duration: 1.8s;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.progress-bar {
    width: 100%; max-width: 360px; height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #a78bfa, #ec4899, #fbbf24);
    background-size: 200% 100%;
    border-radius: 3px;
    width: 10%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: gradientShift 2s linear infinite;
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.6);
}
@keyframes gradientShift {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================================
   结果网格
   ============================================================ */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.result-grid:empty { display: none; }
.result-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.5s ease-out;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.result-item:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: rgba(167, 139, 250, 0.5);
    box-shadow: 0 12px 32px rgba(167, 139, 250, 0.25);
}
.result-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-actions {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 10px;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.9));
    display: flex; gap: 6px;
    opacity: 0; transition: opacity 0.25s;
}
.result-item:hover .result-actions { opacity: 1; }
.result-actions button, .result-actions a {
    flex: 1;
    padding: 6px 8px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    transition: all 0.2s;
}
.result-actions button:hover, .result-actions a:hover {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    transform: translateY(-1px);
}

/* ============================================================
   历史
   ============================================================ */
.history-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.history-header h3 {
    font-size: 14px; color: #d4d4e8; font-weight: 600;
}
.history-list {
    display: flex; flex-direction: column; gap: 8px;
    max-height: 280px; overflow-y: auto;
    padding-inline-end: 4px;
}
.history-empty {
    color: #6b6b85; font-size: 13px; text-align: center; padding: 24px;
}
.history-item {
    display: flex; gap: 12px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.history-item:hover {
    background: rgba(167, 139, 250, 0.08);
    border-color: rgba(167, 139, 250, 0.2);
}
.history-thumb {
    width: 54px; height: 54px; border-radius: 8px;
    object-fit: cover; flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}
.history-info { flex: 1; min-width: 0; }
.history-prompt {
    font-size: 12px; color: #d4d4e8;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.4;
}
.history-meta { font-size: 11px; color: #6b6b85; margin-top: 2px; }

/* ============================================================
   弹窗
   ============================================================ */
.modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
}
.modal-content {
    position: relative;
    max-width: 92vw; max-height: 92vh;
    background: #15152a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.modal-close {
    position: absolute; top: 12px;
    inset-inline-end: 12px;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.1); color: #fff;
    font-size: 22px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    z-index: 2;
}
.modal-close:hover { background: #ec4899; transform: rotate(90deg); }
.modal-content img {
    max-width: 100%; max-height: 72vh;
    border-radius: 10px; object-fit: contain;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
    text-align: center; padding: 24px;
    color: #6b6b85; font-size: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 24px;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed; bottom: 30px;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    padding: 12px 22px;
    background: rgba(20, 20, 30, 0.95);
    color: #fff;
    border-radius: 12px;
    font-size: 13px;
    z-index: 2000;
    animation: slideUp 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    max-width: 90vw;
}
.toast.error { border-color: rgba(236, 72, 153, 0.5); color: #fca5a5; }
.toast.success { border-color: rgba(52, 211, 153, 0.5); color: #6ee7b7; }
.toast.info { border-color: rgba(167, 139, 250, 0.5); color: #c4b5fd; }
@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   RTL 支持（维吾尔语）
   ============================================================ */
[dir="rtl"] {
    text-align: right;
}
[dir="rtl"] .topbar { direction: rtl; }
[dir="rtl"] .panel { text-align: right; }
[dir="rtl"] .form-group label { flex-direction: row-reverse; }
[dir="rtl"] .hero-stats { direction: rtl; }
[dir="rtl"] .form-row { direction: rtl; }
[dir="rtl"] .result-actions { direction: rtl; }
[dir="rtl"] .history-item { direction: rtl; }
[dir="rtl"] .preview-remove { left: 4px; right: auto; }
[dir="rtl"] .modal-close { left: 12px; right: auto; }
[dir="rtl"] .status-elapsed { direction: ltr; display: inline-block; } /* 保持数字 LTR */
[dir="rtl"] .toast { direction: rtl; }
[dir="rtl"] textarea { direction: rtl; text-align: right; }
[dir="rtl"] input[type="text"] { direction: rtl; text-align: right; }
[dir="rtl"] .model-meta { direction: rtl; }
[dir="rtl"] .panel-header { direction: rtl; }
[dir="rtl"] .panel-actions { direction: ltr; } /* 图标按钮保持 LTR */
