/* AI 生图工作台 · 样式 */
:root {
  --bg: #0d1220;
  --panel: #141a2e;
  --panel2: #1b2340;
  --line: #2a3355;
  --txt: #e6ebff;
  --muted: #8ea0c8;
  --accent: #4f7cff;
  --green: #1fcf7a;
  --red: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px; overflow: hidden;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #33406a; border-radius: 4px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: var(--txt); }
.hidden { display: none !important; }

/* 顶部栏 */
.topbar {
  height: 46px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: #10162a; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.brand .logo { font-size: 18px; }
.user { display: flex; align-items: center; gap: 10px; }
.email { color: var(--muted); font-size: 12px; }
.credits { font-size: 12px; color: var(--muted); }
.credits b { color: var(--accent); font-size: 14px; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--txt);
  padding: 5px 10px; border-radius: 6px; font-size: 12px;
}
.ghost:hover { border-color: var(--accent); }

.warnbar {
  padding: 8px 16px; font-size: 12px; color: #ffd98a;
  background: rgba(255, 180, 60, .08); border-bottom: 1px solid rgba(255,180,60,.15);
}

.main { display: grid; grid-template-columns: 360px 1fr; gap: 12px; height: calc(100vh - 78px); padding: 12px; }

/* 左侧设置 */
.settings { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; overflow-y: auto; }
.p-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--txt); margin-bottom: 6px; }
.req { color: var(--accent); font-size: 11px; font-weight: 400; }
.opt { color: var(--muted); font-size: 11px; font-weight: 400; }
.sel { color: var(--accent); float: right; font-size: 11px; font-weight: 600; }
.hint { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
input[type="text"], input[type="password"], input:not([type]), textarea, select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; font-size: 13px; color: var(--txt);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.ai-btn { background: var(--accent); border: none; color: #fff; border-radius: 7px; padding: 8px 12px; font-size: 12px; white-space: nowrap; }
.ai-btn:hover { filter: brightness(1.08); }

/* 参考图上传 */
.dropzone {
  background: var(--panel2); border: 1px dashed var(--line); border-radius: 9px;
  padding: 12px; text-align: center; cursor: pointer; min-height: 90px;
}
.dropzone.drag { border-color: var(--accent); background: rgba(79,124,255,.08); }
.dz-hint { color: var(--muted); font-size: 12px; }
.ref-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ref-thumb { position: relative; width: 64px; height: 64px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-rm { position: absolute; top: 1px; right: 1px; background: rgba(0,0,0,.6); color: #fff; border: none; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 1; }

/* 类型/风格 chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 11px; border-radius: 8px; font-size: 12px;
}
.chip.active, .chip:hover { border-color: var(--accent); color: #fff; background: rgba(79,124,255,.12); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; }
.seg-btn { flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.seg-btn.active, .seg-btn:hover { border-color: var(--accent); color: #fff; background: rgba(79,124,255,.14); }

.gen-btn {
  width: 100%; background: linear-gradient(135deg, #1fcf7a, #17b06a); border: none; color: #06210f;
  font-weight: 700; font-size: 15px; padding: 12px; border-radius: 10px; margin-top: 6px;
}
.gen-btn:disabled { opacity: .5; cursor: not-allowed; }
.gen-btn .heart { color: #fff; }

/* 右侧结果 */
.results { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.tabs { display: flex; align-items: center; padding: 10px 14px; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.tab.active { background: var(--accent); color: #fff; }
.tabs-right { margin-left: auto; display: flex; gap: 6px; }
.mini { background: var(--panel2); border: 1px solid var(--line); color: var(--txt); padding: 5px 10px; border-radius: 6px; font-size: 12px; }
.mini:hover { border-color: var(--accent); }
.mini.danger:hover { border-color: var(--red); color: #ff9b9b; }

.gallery {
  flex: 1; overflow-y: auto; padding: 14px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start;
}
.empty, .gallery-hint { grid-column: 1/-1; padding: 40px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.gallery-hint { padding: 10px; font-size: 11px; }

.tcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.tcard-img { position: relative; aspect-ratio: 1; background: #0a0f1e; }
.tcard-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tcard-tag { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.tcard-body { padding: 8px; }
.tcard-title { font-size: 12px; color: var(--txt); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard-btns { display: flex; gap: 5px; }
.tcard-btns button { flex: 1; background: #131b34; border: 1px solid var(--line); color: var(--txt); padding: 5px 0; border-radius: 6px; font-size: 11px; }
.tcard-btns button:hover { border-color: var(--accent); }

/* 历史分组 */
.hist-group { grid-column: 1/-1; }
.hist-cap { font-size: 12px; color: var(--accent); margin: 8px 0 6px; font-weight: 600; }
.hist-group .gallery { padding: 0; gap: 10px; }

/* 弹窗 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal { width: min(460px, 92%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
.x { background: transparent; border: none; color: var(--muted); font-size: 20px; }
.x:hover { color: var(--red); }
.modal-body { padding: 16px 18px; }
.modal-body label { display: block; font-size: 12px; margin: 10px 0 4px; color: var(--muted); }
.modal-body .gen-btn { margin-top: 16px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 70;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 充值 */
.tiers { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.tier { display: flex; align-items: center; justify-content: space-between; background: var(--panel2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 10px; cursor: pointer; }
.tier:hover, .tier.active { border-color: var(--accent); background: rgba(79,124,255,.1); }
.tier b { color: var(--accent); font-size: 16px; }
.contact { background: rgba(79,124,255,.07); border: 1px solid rgba(79,124,255,.25); border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.c-line { font-size: 14px; margin: 4px 0; color: var(--txt); }
.c-line b { color: var(--accent); font-size: 16px; }
.steps { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 8px 0; padding-left: 18px; }
.admin-box { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.admin-box summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.admin-box label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.admin-box .gen-btn { margin-top: 12px; }

/* 图片放大灯箱 */
.zoomable { cursor: zoom-in; }
.modal-foot { display: flex; gap: 10px; margin-top: 14px; }
.modal-foot .gen-btn { flex: 1; }
.modal-foot .ghost { flex: 0 0 auto; }
/* 底部-右侧 生成进度提示 */
.gen-progress { position: fixed; right: 16px; bottom: 16px; background: #1a2740; border: 1px solid #2c3a5e; padding: 8px 14px; border-radius: 10px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.45); font-size: 13px; color: #dfe6f5; }
.gen-progress b { color: #7cc4ff; }
.lightbox {
  position: fixed; inset: 0; z-index: 95; background: rgba(6, 8, 14, .9);
  display: flex; align-items: center; justify-content: center; padding: 24px; overflow: auto;
  cursor: zoom-out;
}
.lightbox.hidden { display: none; }
.lb-img {
  max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 8px;
  box-shadow: 0 12px 50px rgba(0,0,0,.7); transition: transform .18s ease; cursor: zoom-in;
}
.lb-img.zoomed { transform: scale(1.6); }
.lb-close { position: fixed; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.55); border: none; color: #fff; font-size: 24px; cursor: pointer; }
.lb-close:hover { background: var(--red); }
.lb-hint { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); color: #cdd6ea; font-size: 12px; background: rgba(0,0,0,.5); padding: 6px 14px; border-radius: 20px; }

/* 登录 */
.login-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0a0f1e, #121a33);
}
.login-box { width: min(360px, 90%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 18px; }
.login-box input { width: 100%; margin-bottom: 10px; }
.login-box .gen-btn { margin-top: 4px; }
.auth-toggle { width: 100%; background: transparent; border: none; color: var(--accent); font-size: 12px; margin-top: 12px; cursor: pointer; }
.auth-toggle:hover { text-decoration: underline; }
/* 模式切换 + 海报风格 */
.mode-tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.mode-tab { flex: 1; padding: 10px 0; background: #16223c; border: 1px solid #2c3a5e; color: #9fb0d8; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; }
.mode-tab.active { background: linear-gradient(135deg, #2b4a86, #3a63ad); color: #fff; border-color: transparent; }
.poster-styles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.poster-style { text-align: center; padding: 11px 6px; background: #16223c; border: 1px solid #2c3a5e; border-radius: 9px; cursor: pointer; font-size: 13px; color: #c4d2f0; }
.poster-style.active { border-color: #7cc4ff; box-shadow: 0 0 0 1px #7cc4ff; color: #7cc4ff; }
.garment-thumb { width: 100%; height: 100%; max-height: 170px; object-fit: contain; border-radius: 8px; }
#garmentDrop { display: flex; align-items: center; justify-content: center; }
.sec-title { margin: 14px 0 8px; font-size: 13px; font-weight: 700; color: #9fb0d8; }
.cost-line { margin: 4px 0 10px; padding: 8px 12px; background: #16223c; border: 1px solid #2c3a5e; border-radius: 8px; font-size: 13px; color: #c4d2f0; }
.cost-line b { color: #7cc4ff; font-size: 15px; }

@media (max-width: 1000px) {
  .main { grid-template-columns: 300px 1fr; }
}
