/* wan-gen 出图台 —— 视觉语言沿用出图手册 / 界面稿:青花瓷蓝 + 冷灰绿中性色 + IBM Plex 风味(系统字体兜底)。
   浅/深两套,跟随系统。 */
:root {
  --paper: #F1F4F4; --surface: #FFFFFF; --ink: #121E24; --muted: #5C707A; --faint: #8A9CA4;
  --rule: #DBE3E5; --line: #C9D6D9; --accent: #0B6E8C; --accent-soft: #E2EEF2;
  --ok: #2F7D57; --ok-soft: #E4F0E9; --warn: #9A5B08; --warn-soft: #F6EBD8;
  --danger: #A9302E; --danger-soft: #F7E4E2; --dead: #F7F9F9;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0C1316; --surface: #131E22; --ink: #E4EDEF; --muted: #9AACB3; --faint: #71858D;
    --rule: #233238; --line: #2C3D44; --accent: #5FB8D4; --accent-soft: #14313C;
    --ok: #6FC28A; --ok-soft: #14311F; --warn: #E0A857; --warn-soft: #33270F;
    --danger: #E88A85; --danger-soft: #3A1E1D; --dead: #0F181C;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.6 var(--sans); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.warn { color: var(--warn); } .ok { color: var(--ok); } .err { color: var(--danger); }
code { font-family: var(--mono); font-size: 11px; color: var(--faint); }
b { font-weight: 600; }
.grow { flex: 1 1 auto; }
.divider { width: 1px; height: 24px; background: var(--rule); }

/* 门 */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 26px 24px; display: flex; flex-direction: column; gap: 12px; }
.gate-card form { display: flex; gap: 8px; }
.gate-card input { flex: 1; }

.wordmark { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--accent); }
.wordmark span { font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--faint); margin-left: 6px; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; height: 58px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.field-inline { display: flex; align-items: center; gap: 8px; }
.lbl { font-size: 13px; font-weight: 500; white-space: nowrap; }
.note-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--muted); white-space: nowrap; }
.note-chip.ref { background: var(--ok-soft); color: var(--ok); }
.cost-chip { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; white-space: nowrap; }

/* 控件 */
input[type=text], input[type=password], select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
}
textarea { height: auto; padding: 9px 11px; line-height: 1.7; resize: vertical; font-family: var(--sans); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
select { padding-right: 26px; }
.btn { height: 34px; padding: 0 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; padding: 0 20px; }
.btn.primary:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.tiny { height: 26px; padding: 0 10px; font-size: 12px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 布局 */
.grid { display: grid; grid-template-columns: 320px 320px minmax(0, 1fr); gap: 16px; padding: 16px 20px 40px; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.dead { background: var(--dead); border-color: var(--rule); }
.eyebrow { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: -4px; }
.row-foot > :first-child { white-space: nowrap; }
.row-head .muted { text-align: right; }
.chip { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.green { background: var(--ok-soft); color: var(--ok); }
.chip.amber { background: var(--warn-soft); color: var(--warn); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg-btn { flex: 1; height: 32px; border: 0; background: var(--surface); color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--accent); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.size-chip { height: 30px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 12px var(--mono); cursor: pointer; }
.size-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.size-custom input { font-family: var(--mono); font-size: 12.5px; }
.px-meter { padding: 10px 12px; border-radius: 6px; background: var(--paper); display: flex; flex-direction: column; gap: 6px; }
.px-head, .px-foot { display: flex; justify-content: space-between; }
.px-foot { font-size: 10.5px; color: var(--faint); }
.px-track { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.px-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.px-fill.top { background: var(--warn); } .px-fill.bad { background: var(--danger); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: flex; align-items: center; height: 34px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.stepper button { width: 34px; height: 100%; border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.stepper span { flex: 1; text-align: center; font-weight: 500; }
.seed { display: flex; height: 34px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seed input { border: 0; border-radius: 0; height: 100%; font-family: var(--mono); }
.seed button { width: 36px; border: 0; border-left: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 15px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--rule); cursor: pointer; }
.toggle-row > span { display: flex; flex-direction: column; gap: 2px; }
.toggle-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle { width: 40px; height: 23px; border-radius: 12px; background: var(--line); position: relative; flex-shrink: 0; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 9px; background: #fff; transition: left .15s; }
.toggle-row input:checked + .toggle { background: var(--accent); }
.toggle-row input:checked + .toggle::after { left: 20px; }

.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 96px; border: 1px dashed var(--line); border-radius: 7px; background: var(--paper); cursor: pointer; overflow: hidden; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop img { max-height: 160px; max-width: 100%; display: block; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
#refCard.off .drop { opacity: .45; pointer-events: none; }

/* 进度 */
.pbar { display: flex; height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.pbar i { display: block; width: 0; transition: width .3s; }
.pbar .ok { background: var(--ok); } .pbar .bad { background: var(--danger); } .pbar .mod { background: var(--warn); }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 12.5px; }
.plist li:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--line); flex-shrink: 0; }
.dot.done { background: var(--ok); } .dot.failed { background: var(--danger); } .dot.moderation { background: var(--warn); } .dot.running { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.plist .name { font-family: var(--mono); width: 120px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .st { font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--paper); color: var(--muted); white-space: nowrap; }
.plist .st.done { background: var(--ok-soft); color: var(--ok); } .plist .st.failed { background: var(--danger-soft); color: var(--danger); } .plist .st.moderation { background: var(--warn-soft); color: var(--warn); } .plist .st.running { background: var(--accent-soft); color: var(--accent); }
.plist .msg { flex: 1; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .t { font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* 画廊 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb { display: flex; flex-direction: column; gap: 5px; cursor: pointer; }
.thumb .img { aspect-ratio: 1 / 1; border-radius: 7px; overflow: hidden; background: var(--paper); border: 2px solid transparent; }
.thumb.on .img { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .cap { font-family: var(--mono); font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.meta-grid > div { background: var(--surface); padding: 9px 12px; display: flex; flex-direction: column; gap: 2px; }
.meta-grid .k { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--faint); }
.meta-grid .v { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-actions { display: flex; flex-wrap: wrap; gap: 8px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 20; max-width: min(90vw, 560px); }
.drawer { position: fixed; top: 0; right: 0; width: min(520px, 100vw); height: 100vh; background: var(--surface); border-left: 1px solid var(--rule); padding: 18px 20px; overflow: auto; z-index: 30; display: flex; flex-direction: column; gap: 12px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.settings-body { display: flex; flex-direction: column; }
.settings-body .kv { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 12.5px; }
.settings-body .kv .k { font-family: var(--mono); font-size: 12px; }
.settings-body .kv .v { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.settings-body .kv .d { color: var(--muted); font-size: 11.5px; grid-column: 2; margin-top: -6px; }

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .col.wide { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .divider { display: none; }
  .cost-chip { order: 5; }
  .grid { grid-template-columns: 1fr; padding: 12px 14px 40px; }
  .col.wide { grid-column: auto; }
  .two { grid-template-columns: 1fr; }
  .btn, input[type=text], select, .stepper, .seed { min-height: 44px; }
  .stepper button, .seed button { width: 44px; }
}
