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

:root {
  --bg: #0e0e12;
  --bg2: #17171e;
  --bg3: #1e1e28;
  --border: #2a2a38;
  --primary: #7c5ff5;
  --primary-h: #6a4fe0;
  --primary-glow: rgba(124,95,245,0.35);
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #5a5a70;
  --success: #4caf82;
  --danger: #e05757;
  --radius: 10px;
  --radius-lg: 16px;
}

html, body { height: 100%; font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: var(--bg2); } ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Layout ===== */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ===== Header ===== */
.header { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 56px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; background: linear-gradient(135deg, #7c5ff5, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.header-right { display: flex; align-items: center; gap: 12px; }
.api-status { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--gray { background: var(--text3); }
.dot--green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot--red { background: var(--danger); }

/* ===== Main ===== */
.main { display: flex; flex: 1; overflow: hidden; }

/* ===== Sidebar ===== */
.sidebar { width: 340px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.panel { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.panel__title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 10px; letter-spacing: 0.5px; }
.panel__title .tip { font-weight: 400; color: var(--text3); font-size: 12px; }

/* ===== Form Elements ===== */
.textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 10px 12px; font-size: 13px; line-height: 1.6; resize: vertical; transition: border-color .2s; font-family: inherit; }
.textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.textarea--neg { border-color: rgba(224,87,87,0.3); }
.textarea--neg:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(224,87,87,0.2); }
.char-count { text-align: right; font-size: 11px; color: var(--text3); margin-top: 4px; }

.select, .input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 8px 12px; font-size: 13px; transition: border-color .2s; font-family: inherit; }
.select:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
select option { background: var(--bg2); }

.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.form-row:last-child { margin-bottom: 0; }
.form-row label { color: var(--text2); font-size: 13px; white-space: nowrap; min-width: 80px; }
.form-row .select, .form-row .input { flex: 1; }
.form-row--col { flex-direction: column; align-items: stretch; }
.form-row--col label { margin-bottom: 6px; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }

.count-control { display: flex; align-items: center; gap: 10px; }
.count-btn { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.count-btn:hover { border-color: var(--primary); color: var(--primary); }
#countVal { min-width: 20px; text-align: center; font-weight: 600; }

/* ===== Tags ===== */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--bg); border: 1px solid var(--border); color: var(--text2); padding: 4px 10px; border-radius: 20px; font-size: 12px; cursor: pointer; transition: all .2s; }
.tag:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: var(--radius); cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 500; transition: all .2s; white-space: nowrap; }
.btn--primary { background: var(--primary); color: #fff; padding: 10px 20px; }
.btn--primary:hover { background: var(--primary-h); box-shadow: 0 4px 20px var(--primary-glow); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(0); }
.btn--outline { background: transparent; border: 1px solid var(--border); color: var(--text2); padding: 6px 14px; }
.btn--outline:hover { border-color: var(--primary); color: var(--primary); }
.btn--ghost { background: transparent; border: 1px solid var(--border); color: var(--text2); padding: 8px 16px; }
.btn--ghost:hover { background: var(--bg3); }
.btn--sm { font-size: 13px; padding: 5px 12px; }
.btn--full { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; margin-top: 4px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ===== Gallery ===== */
.gallery-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.gallery-header { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.gallery-title { font-size: 16px; font-weight: 600; }
.gallery-actions { display: flex; gap: 8px; }

.gallery { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-content: start; }

.gallery-empty { grid-column: 1/-1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; color: var(--text3); gap: 12px; }
.empty-icon { font-size: 64px; opacity: 0.4; }
.gallery-empty p { font-size: 15px; }

/* ===== Gallery Item ===== */
.gallery-item { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; transition: all .3s; animation: fadeIn .4s ease; }
.gallery-item:hover { border-color: var(--primary); box-shadow: 0 8px 32px rgba(0,0,0,.4); transform: translateY(-2px); }
@keyframes fadeIn { from { opacity:0; transform: scale(.95); } to { opacity:1; transform: scale(1); } }

.gallery-item__img-wrap { position: relative; aspect-ratio: 1; background: var(--bg); cursor: pointer; overflow: hidden; }
.gallery-item__img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.gallery-item:hover .gallery-item__img { transform: scale(1.03); }
.gallery-item__overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s; }
.gallery-item:hover .gallery-item__overlay { opacity: 1; }
.overlay-icon { font-size: 32px; }

.gallery-item__info { padding: 12px; }
.gallery-item__prompt { font-size: 12px; color: var(--text2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gallery-item__meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.gallery-item__size { font-size: 11px; color: var(--text3); }
.gallery-item__actions { display: flex; gap: 6px; }
.icon-btn { background: var(--bg); border: 1px solid var(--border); color: var(--text2); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all .2s; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ===== 加载骨架屏 ===== */
.skeleton { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.skeleton__img { aspect-ratio: 1; background: linear-gradient(90deg, var(--bg3) 25%, var(--bg2) 50%, var(--bg3) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.skeleton__text { height: 12px; margin: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--bg3) 25%, var(--bg2) 50%, var(--bg3) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.skeleton__text--short { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== 进度条 ===== */
.progress-wrap { padding: 0 12px 12px; }
.progress-bar { height: 3px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.progress-bar__fill { height: 100%; background: linear-gradient(90deg, var(--primary), #c084fc); border-radius: 2px; transition: width .3s; animation: progress-pulse 1.5s infinite; }
@keyframes progress-pulse { 0%,100% { opacity:1; } 50% { opacity:.6; } }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 999; backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 440px; max-width: 90vw; animation: slideUp .2s ease; }
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__header h3 { font-size: 16px; font-weight: 600; }
.modal__close { background: none; border: none; color: var(--text3); font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 4px; transition: color .2s; }
.modal__close:hover { color: var(--text); }
.modal__body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal__footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal__tip { background: rgba(124,95,245,0.1); border: 1px solid rgba(124,95,245,0.2); border-radius: var(--radius); padding: 10px 14px; color: var(--text2); font-size: 12px; line-height: 1.6; }

/* ===== 预览弹窗 ===== */
.preview-modal { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 90vw; max-height: 90vh; }
.preview-modal img { max-width: 80vw; max-height: 75vh; object-fit: contain; border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.preview-actions { display: flex; gap: 12px; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; color: var(--text); font-size: 14px; z-index: 9999; animation: slideInRight .3s ease; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast--success { border-color: var(--success); }
.toast--error { border-color: var(--danger); }
@keyframes slideInRight { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
