/* Qwen 图片工作台：沿用导演台的深色视觉体系 */
body.qw-page {
  --qw-bg-0: #070d12;
  --qw-bg-1: #0b131a;
  --qw-bg-2: #0f1922;
  --qw-bg-3: #13202b;
  --qw-line: #1f2d3b;
  --qw-line-2: #2a3b4d;
  --qw-text: #dce7f0;
  --qw-muted: #7f93a4;
  --qw-dim: #5f7387;
  --qw-accent: #2dd4a7;
  --qw-warn: #fbbf24;
  --qw-err: #fca5a5;

  margin: 0;
  min-height: 100vh;
  color: var(--qw-text);
  background:
    radial-gradient(1100px 420px at 16% -12%, rgba(45, 212, 167, .10), transparent 62%),
    radial-gradient(900px 360px at 102% -6%, rgba(96, 165, 250, .09), transparent 58%),
    var(--qw-bg-0);
  font-family: inherit;
}

body.qw-page * { scrollbar-width: thin; scrollbar-color: #2a3b4d transparent; }
body.qw-page *::-webkit-scrollbar { width: 8px; height: 8px; }
body.qw-page *::-webkit-scrollbar-thumb { background: #2a3b4d; border-radius: 999px; }
body.qw-page *::-webkit-scrollbar-track { background: transparent; }

/* ---------- 顶栏 ---------- */
.qw-page .qw-topbar {
  width: 88vw;
  max-width: none;
  margin: 0 auto;
  padding: 18px 4px 10px;
  display: flex;
  align-items: center;
  gap: 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.qw-page .qw-topbar .brand { color: var(--qw-text); font-size: 17px; }
.qw-page .qw-topbar .brand .sub { color: var(--qw-dim); font-size: 11px; }

.qw-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--qw-line);
  border-radius: 12px;
  background: rgba(8, 16, 23, .72);
}
.qw-tab {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--qw-dim);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: color .16s ease, background .16s ease;
}
.qw-tab:hover { color: var(--qw-text); }
.qw-tab.is-active {
  color: #062018;
  background: linear-gradient(135deg, #34d399, #2dd4a7);
}

.qw-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.qw-page .qw-topbar .chip {
  background: rgba(45, 212, 167, .10);
  border: 1px solid rgba(45, 212, 167, .28);
  color: #8ef0cf;
}
.qw-page .qw-topbar .btn.small-btn {
  background: #081017;
  border: 1px solid var(--qw-line-2);
  color: var(--qw-muted);
}
.qw-page .qw-topbar .btn.small-btn:hover { color: var(--qw-text); border-color: #35506a; }

/* ---------- 三栏 ---------- */
.qw-shell { width: 88vw; max-width: none; margin: 0 auto; padding: 4px 4px 36px; }
.qw-stage {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 410px;
  gap: 14px;
  align-items: stretch;
  height: calc(100vh - 118px);
  min-height: 620px;
}
/* 文生图：不需要参考图，左栏整列收起 */
.qw-stage.is-t2i { grid-template-columns: minmax(0, 1fr) 410px; }
.qw-stage.is-t2i .qw-rail { display: none; }

.qw-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--qw-line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .015), transparent 120px), var(--qw-bg-1);
  box-shadow: 0 18px 44px rgba(4, 14, 22, .22), inset 0 1px 0 rgba(255, 255, 255, .03);
}
.qw-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.qw-card-head h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.qw-note { font-size: 10.5px; color: var(--qw-dim); }

/* ---------- 左栏：参考图 ---------- */
.qw-rail { gap: 12px; }
.qw-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  padding: 12px;
  border: 1px dashed #2c4053;
  border-radius: 12px;
  background: rgba(8, 16, 23, .55);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .16s ease, background .16s ease;
  outline: none;
}
.qw-drop:hover, .qw-drop:focus-visible { border-color: rgba(45, 212, 167, .55); background: rgba(45, 212, 167, .04); }
.qw-drop.is-drag { border-color: var(--qw-accent); background: rgba(45, 212, 167, .08); }
.qw-drop.is-disabled { opacity: .45; cursor: not-allowed; }
.qw-drop-empty { text-align: center; color: var(--qw-dim); }
.qw-drop-empty p { margin: 3px 0; font-size: 12px; }
.qw-drop-icon { display: block; font-size: 26px; line-height: 1; color: #3c5062; margin-bottom: 8px; }
.qw-drop-main { color: var(--qw-muted); font-weight: 600; }
.qw-drop-sub { font-size: 10.5px !important; color: #465a6c; }
.qw-ref-img { max-width: 100%; max-height: 320px; border-radius: 10px; object-fit: contain; }
.qw-ref-tools { display: flex; gap: 8px; }
.qw-ref-tools .qw-mini { flex: 1 1 0; }
.qw-rail-tip { margin: 0; font-size: 11px; line-height: 1.7; color: #4f6477; }
.qw-rail-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px dashed var(--qw-line);
  font-size: 10.5px;
  color: #465a6c;
}
.qw-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--qw-accent); box-shadow: 0 0 0 4px rgba(45, 212, 167, .12); }

/* 文生图模式：左栏收起参考图，只留说明 */
.qw-rail.is-t2i .qw-drop,
.qw-rail.is-t2i .qw-ref-tools { display: none; }
.qw-rail.is-t2i { justify-content: flex-start; }

/* ---------- 中栏 ---------- */
.qw-main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--qw-line);
}
.qw-kicker { margin: 0 0 4px; font-size: 9.5px; font-weight: 800; letter-spacing: .2em; color: var(--qw-accent); }
.qw-main-head h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .01em; }
.qw-mode {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--qw-line-2);
  border-radius: 11px;
  background: #081017;
}
.qw-mode-btn {
  padding: 7px 15px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--qw-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: color .16s ease, background .16s ease;
}
.qw-mode-btn:hover { color: var(--qw-text); }
.qw-mode-btn.is-active { color: #062018; background: linear-gradient(135deg, #34d399, #2dd4a7); }

.qw-prompt-wrap { padding-top: 14px; }
.qw-label-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
.qw-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--qw-dim); }
.qw-prompt {
  width: 100%;
  min-height: 168px;
  padding: 13px 14px;
  border: 1px solid #263545;
  border-radius: 12px;
  background: #081017;
  color: var(--qw-text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.75;
  resize: vertical;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.qw-prompt:hover { border-color: #35506a; }
.qw-prompt:focus { border-color: var(--qw-accent); box-shadow: 0 0 0 3px rgba(45, 212, 167, .12); }
.qw-prompt::placeholder { color: #4c6176; }
.qw-prompt-foot { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.qw-prompt-tip { font-size: 10.5px; }

.qw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--qw-line-2);
  border-radius: 999px;
  background: #081017;
  color: var(--qw-muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.qw-toggle-dot { width: 8px; height: 8px; border-radius: 50%; background: #33475b; transition: background .16s ease, box-shadow .16s ease; }
.qw-toggle.is-on { color: #8ef0cf; border-color: rgba(45, 212, 167, .42); background: rgba(45, 212, 167, .08); }
.qw-toggle.is-on .qw-toggle-dot { background: var(--qw-accent); box-shadow: 0 0 0 4px rgba(45, 212, 167, .14); }

/* 参数条 */
.qw-params {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid var(--qw-line);
  border-radius: 13px;
  background: rgba(8, 16, 23, .42);
}
.qw-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.qw-field-wide { grid-column: 1 / -1; }
.qw-field-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--qw-dim); }
.qw-input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #263545;
  border-radius: 9px;
  background: #081017;
  color: var(--qw-text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.qw-input:hover { border-color: #35506a; }
.qw-input:focus { border-color: var(--qw-accent); box-shadow: 0 0 0 3px rgba(45, 212, 167, .12); }
.qw-input::placeholder { color: #4c6176; }
select.qw-input { cursor: pointer; }
select.qw-input option { background: #0f1922; color: var(--qw-text); }
.qw-seed { display: flex; gap: 6px; }
.qw-seed .qw-input { flex: 1 1 auto; }
.qw-seed .qw-mini { flex: 0 0 auto; white-space: nowrap; }

.qw-mini {
  padding: 7px 11px;
  border: 1px solid var(--qw-line-2);
  border-radius: 8px;
  background: #081017;
  color: var(--qw-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.qw-mini:hover { border-color: #35506a; color: var(--qw-text); }
.qw-mini.danger { color: #fca5a5; border-color: rgba(248, 113, 113, .32); }
.qw-mini.danger:hover { background: rgba(248, 113, 113, .10); }

.qw-size { margin: 9px 0 0; font-size: 10.5px; }
.qw-msg { margin: 10px 0 0; font-size: 12px; color: #8ef0cf; }
.qw-msg.is-err { color: var(--qw-err); }

/* 生成按钮：右下角 */
.qw-actions { margin-top: auto; padding-top: 18px; display: flex; justify-content: flex-end; }
.qw-generate {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 168px;
  height: 46px;
  padding: 0 30px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #34d399, #22b892);
  color: #04231b;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(45, 212, 167, .22);
  transition: transform .12s ease, box-shadow .16s ease, filter .16s ease;
}
.qw-generate:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 14px 30px rgba(45, 212, 167, .30); }
.qw-generate:active:not(:disabled) { transform: translateY(1px) scale(.995); }
.qw-generate:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.qw-generate.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .30) 50%, transparent 80%);
  animation: qw-sheen 1.15s linear infinite;
}
@keyframes qw-sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- 右栏：结果 ---------- */
.qw-result { max-height: 100%; overflow: hidden; }
.qw-canvas {
  flex: 1 1 auto;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border: 1px solid var(--qw-line);
  border-radius: 13px;
  background: #081017;
  overflow: hidden;
}
.qw-empty { text-align: center; color: var(--qw-dim); }
.qw-empty p { margin: 4px 0; font-size: 12px; }
.qw-empty-icon { display: block; font-size: 24px; color: #2c4053; margin-bottom: 6px; }
.qw-result-img { max-width: 100%; max-height: 46vh; border-radius: 9px; object-fit: contain; }
.qw-spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 10px;
  border: 2px solid rgba(45, 212, 167, .22);
  border-top-color: var(--qw-accent);
  border-radius: 50%;
  animation: qw-spin .8s linear infinite;
}
@keyframes qw-spin { to { transform: rotate(360deg); } }

.qw-result-tools { display: flex; gap: 8px; margin-top: 11px; }
.qw-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 1px solid rgba(45, 212, 167, .38);
  border-radius: 10px;
  background: rgba(45, 212, 167, .10);
  color: #8ef0cf;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.qw-btn:hover { background: rgba(45, 212, 167, .16); border-color: rgba(45, 212, 167, .55); }
.qw-btn.ghost { border-color: var(--qw-line-2); background: transparent; color: var(--qw-muted); }
.qw-btn.ghost:hover { color: var(--qw-text); border-color: #35506a; }

.qw-history {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--qw-line);
}
.qw-history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.qw-history-head h3 { margin: 0; font-size: 12px; font-weight: 800; }
.qw-history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 260px;
  overflow-y: auto;
  align-content: start;
}
.qw-history-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--qw-line);
  border-radius: 9px;
  overflow: hidden;
  background: #081017;
  cursor: pointer;
  transition: border-color .16s ease, transform .12s ease;
}
.qw-history-item:hover { border-color: rgba(45, 212, 167, .5); transform: translateY(-1px); }
.qw-history-item img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.qw-history-item .qw-hi-tag {
  position: absolute;
  left: 4px;
  top: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(4, 14, 22, .72);
  color: #8ef0cf;
  font-size: 9px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.qw-empty-line { grid-column: 1 / -1; margin: 6px 0; font-size: 11px; color: #465a6c; }

/* ---------- 登录 ---------- */
.qw-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 10, 15, .78);
  backdrop-filter: blur(8px);
}
.qw-gate[hidden] { display: none; }
.qw-gate-card {
  width: min(360px, 100%);
  padding: 26px 26px 22px;
  border: 1px solid var(--qw-line-2);
  border-radius: 18px;
  background: var(--qw-bg-1);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .45);
}
.qw-gate-card h2 { margin: 0 0 6px; font-size: 18px; }
.qw-gate-card p { margin: 0 0 14px; font-size: 11.5px; }
.qw-gate-card .qw-input { margin-bottom: 10px; }
.qw-gate-card .qw-generate { width: 100%; min-width: 0; margin-top: 4px; }

.qw-dim { color: var(--qw-dim); }

/* ---------- 响应式 ---------- */
@media (max-width: 1420px) {
  .qw-stage { grid-template-columns: 250px minmax(0, 1fr) 360px; }
  .qw-stage.is-t2i { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 1180px) {
  .qw-page .qw-topbar, .qw-shell { width: auto; padding-left: 16px; padding-right: 16px; }
  .qw-page .qw-topbar { flex-wrap: wrap; gap: 10px; }
  .qw-stage,
  .qw-stage.is-t2i { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .qw-rail { order: 2; }
  .qw-main { order: 1; }
  .qw-result { order: 3; max-height: none; }
  .qw-result-img { max-height: 60vh; }
  .qw-history-grid { max-height: 300px; }
}
@media (max-width: 720px) {
  .qw-page .qw-topbar { flex-wrap: wrap; gap: 10px; }
  .qw-tabs { order: 3; width: 100%; }
  .qw-tab { flex: 1 1 0; text-align: center; }
  .qw-params { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qw-history-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
