/* ============================================================================
   画境 · AI 画室 —— 全站样式
   设计取向：深色玻璃质感 + 双色渐变（紫 #7b6cff → 青 #3ec9d6），
   信息密度偏松，参数区可长期停留，结果区给图当主角。
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* ★ 关键一行：下面有多个组件把 display 写成 grid/flex（.lightbox/.canvas-busy…），
   作者样式优先级高于 UA 的 `[hidden]{display:none}`，不写这句就会出现
   「hidden 了但还在上面盖一层黑色遮罩」。实测踩过。 */
[hidden] { display: none !important; }

:root {
  --bg: #0a0b0f;
  --bg-2: #0e1017;
  --panel: rgba(255, 255, 255, .038);
  --panel-2: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .14);
  --text: #eceef5;
  --text-2: #a2a7b8;
  --text-3: #6d7387;
  --a1: #7b6cff;
  --a2: #3ec9d6;
  --ok: #38d39f;
  --warn: #f5b544;
  --err: #ff6b6b;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .55);
  --ease: cubic-bezier(.22, .8, .28, 1);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 背景光晕 */
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: .5;
}
.glow--a {
  width: 620px; height: 620px; top: -240px; left: -160px;
  background: radial-gradient(circle, rgba(123, 108, 255, .55), transparent 68%);
}
.glow--b {
  width: 700px; height: 700px; bottom: -320px; right: -220px;
  background: radial-gradient(circle, rgba(62, 201, 214, .38), transparent 68%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 26px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ------------------------------------------------------------- 顶栏 ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 40px; height: 40px; display: block; flex: none; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: .06em;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .02em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  box-shadow: 0 0 0 0 rgba(56, 211, 159, .5);
  transition: background .3s;
}
.pill.is-ok .dot { background: var(--ok); animation: pulse 2.4s infinite; }
.pill.is-bad .dot { background: var(--err); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 211, 159, .45); }
  70% { box-shadow: 0 0 0 7px rgba(56, 211, 159, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 211, 159, 0); }
}

/* ------------------------------------------------------------- 布局 ---- */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 396px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel,
.stage {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .022));
  backdrop-filter: blur(18px);
}

.panel {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 19px;
  position: sticky;
  top: 22px;
}

/* ------------------------------------------------------------- 字段 ---- */
.field { display: flex; flex-direction: column; gap: 9px; }
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.field-head label,
.adv-row label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--text-2);
  text-transform: uppercase;
}
.opt {
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-3);
  text-transform: none;
  margin-left: 6px;
}
.counter, .hint { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter.is-near { color: var(--warn); }

textarea,
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(8, 9, 13, .6);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.62;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
textarea { resize: vertical; min-height: 104px; }
textarea::placeholder, input::placeholder { color: #5b6073; }
textarea:focus, input:focus {
  outline: none;
  border-color: rgba(123, 108, 255, .62);
  box-shadow: 0 0 0 3px rgba(123, 108, 255, .16);
  background: rgba(8, 9, 13, .82);
}

/* ------------------------------------------------------------- 上传区 ---- */
.drop {
  position: relative;
  min-height: 108px;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--line-2);
  background: rgba(8, 9, 13, .42);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  overflow: hidden;
}
.drop:hover, .drop:focus-visible {
  outline: none;
  border-color: rgba(123, 108, 255, .55);
  background: rgba(123, 108, 255, .07);
}
.drop.is-over { border-color: var(--a2); background: rgba(62, 201, 214, .1); }
.drop.is-filled { border-style: solid; padding: 0; }

.drop-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 16px 12px;
  color: var(--text-3);
  font-size: 12.5px;
  text-align: center;
}
.drop-empty svg {
  width: 20px; height: 20px;
  flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .82;
}
.drop-empty small { font-size: 11px; opacity: .6; white-space: nowrap; }

.drop-preview { position: relative; width: 100%; }
.drop-preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: #06070a;
}
.drop-badge {
  position: absolute;
  top: 9px; left: 9px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(6px);
  font-size: 11px;
  letter-spacing: .04em;
  color: #dfe3ee;
}

/* ------------------------------------------------------------- 模型 ---- */
/* 双列卡片：名字 + 说明 + 标签，信息全在卡上（原先的单行胶囊太挤，已改回） */
.models {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.model {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .022);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: all .16s var(--ease);
  min-width: 0;
}
.models > .model:last-child:nth-child(odd) { grid-column: 1 / -1; }
.model:hover { border-color: var(--line-2); background: rgba(255, 255, 255, .045); }
.model.is-on {
  border-color: rgba(123, 108, 255, .68);
  background: linear-gradient(135deg, rgba(123, 108, 255, .18), rgba(62, 201, 214, .1));
  box-shadow: 0 0 0 1px rgba(123, 108, 255, .28) inset;
}
.model-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line-2);
  flex: none;
  margin-top: 6px;
  transition: background .16s;
}
.model.is-on .model-dot { background: linear-gradient(135deg, var(--a1), var(--a2)); }
.model-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.model-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  flex-wrap: wrap;
}
.model.is-on .model-name { color: var(--text); }
.model-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.model-tag {
  flex: none;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .05);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--text-3);
  white-space: nowrap;
}
.model-tag.tag-fast { border-color: rgba(62, 201, 214, .45); color: #8fe4ec; }
.model-tag.tag-best {
  border-color: rgba(123, 108, 255, .55);
  color: #c3b8ff;
  background: rgba(123, 108, 255, .14);
}
.model-tag.tag-en { border-color: rgba(255, 176, 92, .45); color: #ffc888; }

/* ------------------------------------------------------------- 分段控件 ---- */
.seg { display: flex; flex-wrap: wrap; gap: 7px; }
.seg button {
  flex: 1 1 auto;
  min-width: 62px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .022);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s var(--ease);
  white-space: nowrap;
}
.seg button:hover { border-color: var(--line-2); color: var(--text); }
.seg button.is-on {
  border-color: rgba(123, 108, 255, .68);
  background: rgba(123, 108, 255, .17);
  color: #d6d1ff;
  font-weight: 600;
}

/* ------------------------------------------------------------- 高级 ---- */
.advanced {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .018);
  overflow: hidden;
}
.advanced summary {
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after {
  content: "";
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s var(--ease);
}
.advanced[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.adv-body {
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--line);
}
.adv-row { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.adv-row input { padding: 9px 12px; font-size: 13.5px; }

/* ------------------------------------------------------------- 主按钮 ---- */
.draw-actions {
  margin: 2px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.draw-actions .primary { width: 100%; }
.draw-actions .foot-note { margin: 0; text-align: center; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--a1), #5f8bff 48%, var(--a2));
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .04em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 30px -10px rgba(123, 108, 255, .8);
  transition: transform .16s var(--ease), box-shadow .16s, filter .16s;
  position: relative;
  overflow: hidden;
}
.primary svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.primary:hover:not(:disabled) {
  transform: translateY(-1.5px);
  box-shadow: 0 16px 38px -10px rgba(123, 108, 255, .9);
  filter: brightness(1.06);
}
.primary:active:not(:disabled) { transform: translateY(0); }
.primary:disabled { cursor: not-allowed; filter: grayscale(.35) brightness(.8); }
.primary.sm { height: 36px; padding: 0 15px; font-size: 13px; border-radius: var(--r-sm); }

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .035);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s var(--ease);
  white-space: nowrap;
}
.ghost:hover { border-color: var(--line-2); color: var(--text); background: rgba(255, 255, 255, .07); }
.ghost.icon { width: 34px; height: 34px; padding: 0; font-size: 14px; }
.ghost svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ghost.wide { width: 100%; }

.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--text-3);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color .15s;
}
.link:hover { color: var(--text); }

.foot-note {
  margin: -6px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
}
kbd {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .06);
  font-family: inherit;
  font-size: 10.5px;
}

/* ------------------------------------------------------------- 舞台 ---- */
.stage { padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.canvas {
  --ar: 1.4545;              /* 宽 / 高，JS 会按出图比例改写 */
  --cap: min(calc(100vh - 208px), 780px);   /* 可用高度：视口减去页头/内边距/结果条 */
  position: relative;
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(123, 108, 255, .1), transparent 62%),
    #07080c;
  border: 1px solid var(--line);
  overflow: hidden;
  /* ★ 画布自身按图片比例取宽高：先让高度不超过视口上限，
     再由 --ar 反推宽度，这样竖图不会撑满整行再被压扁出黑边 */
  width: min(100%, calc(var(--cap) * var(--ar)));
  aspect-ratio: var(--ar);
  max-height: var(--cap);
  min-height: 240px;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-empty {
  text-align: center;
  padding: 30px;
  max-width: 440px;
  position: relative;
  z-index: 1;
}
.canvas-empty h2 {
  margin: 20px 0 7px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .01em;
}
.canvas-empty p { margin: 0; font-size: 12.5px; color: var(--text-3); }

.empty-art { position: relative; height: 92px; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  animation: float 7s ease-in-out infinite;
}
.orb--1 {
  width: 54px; height: 54px; left: 50%; top: 6px; transform: translateX(-50%);
  background: radial-gradient(circle at 34% 30%, #b3a8ff, #7b6cff 55%, transparent 72%);
}
.orb--2 {
  width: 30px; height: 30px; left: 14%; top: 40px;
  background: radial-gradient(circle at 34% 30%, #8fe6f0, #3ec9d6 58%, transparent 74%);
  animation-delay: -2.3s;
}
.orb--3 {
  width: 22px; height: 22px; right: 16%; top: 30px;
  background: radial-gradient(circle at 34% 30%, #f8d9a8, #f5b544 58%, transparent 74%);
  animation-delay: -4.6s;
}
@keyframes float {
  0%, 100% { transform: translateY(0) translateX(var(--tx, 0)); }
  50% { transform: translateY(-11px) translateX(var(--tx, 0)); }
}
.orb--1 { --tx: -50%; }

/* 结果图 */
/* ★ 关键：grid + place-items:center 会让 img 的 max-height:100% 参照到 auto 行高，
   图片按原始高度铺开 → 竖图被裁掉一半（864×1152 实测渲染成 817×1089，画布只有 580 高）。
   用绝对定位 + inset + object-fit:contain，让图片始终被完整装进画布。 */
.canvas-result { position: absolute; inset: 0; padding: 12px; }
.canvas-result img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: reveal .5s var(--ease);
}
@keyframes reveal {
  from { opacity: 0; transform: scale(.975); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* 生成中 */
.canvas-busy { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.busy-shimmer {
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg, transparent 0 62%, rgba(123, 108, 255, .3) 72%, rgba(62, 201, 214, .26) 82%, transparent 92%);
  animation: spin 3.6s linear infinite;
  filter: blur(26px);
  opacity: .85;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-info {
  position: relative;
  z-index: 1;
  width: min(78%, 340px);
  padding: 20px 22px;
  border-radius: var(--r-lg);
  background: rgba(10, 11, 16, .78);
  border: 1px solid var(--line-2);
  backdrop-filter: blur(14px);
  text-align: center;
}
.busy-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .16);
  border-top-color: var(--a1);
  animation: spin 1s linear infinite;
  flex: none;
}
.bar {
  height: 4px;
  margin: 14px 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 6%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--a1), var(--a2));
  transition: width .6s var(--ease);
}
.busy-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* 错误 */
.canvas-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px;
  text-align: center;
  background: rgba(7, 8, 12, .86);
}
.canvas-error svg {
  width: 34px; height: 34px;
  fill: none; stroke: var(--err); stroke-width: 1.6;
  stroke-linecap: round;
}
.canvas-error p { margin: 0; font-size: 13.5px; color: #ffb3b3; max-width: 460px; line-height: 1.65; }

/* 结果操作条 */
.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
}
.result-bar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.meta b { color: var(--text-2); font-weight: 600; }

/* ------------------------------------------------------------- 画廊 ---- */
.gallery { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tabs { display: flex; gap: 5px; }
.tab {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s;
}
.tab em { font-style: normal; opacity: .65; margin-left: 3px; }
.tab:hover { color: var(--text-2); }
.tab.is-active {
  border-color: var(--line);
  background: rgba(255, 255, 255, .055);
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 9px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}
.grid::-webkit-scrollbar { width: 7px; }
.grid::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 99px; }
.grid::-webkit-scrollbar-track { background: transparent; }

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0b0c11;
  cursor: zoom-in;
  padding: 0;
  transition: transform .16s var(--ease), border-color .16s;
}
.tile:hover { transform: translateY(-2px); border-color: rgba(123, 108, 255, .6); }
/* contain：竖图/横图都完整显示，不再被 1:1 方框裁掉两边 */
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-cap {
  position: absolute;
  inset: auto 0 0;
  padding: 16px 8px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .82));
  font-size: 10.5px;
  line-height: 1.35;
  color: #c9cddb;
  text-align: left;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0;
  transition: opacity .18s;
}
.tile:hover .tile-cap { opacity: 1; }

.grid-empty {
  margin: 0;
  padding: 26px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ------------------------------------------------------------- 页脚 ---- */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 26px 4px 0;
  font-size: 11.5px;
  color: var(--text-3);
}
.foot a { color: var(--text-3); text-decoration: none; transition: color .15s; }
.foot a:hover { color: var(--text-2); }

/* ------------------------------------------------------------- 抽屉 ---- */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 8, .6);
  backdrop-filter: blur(3px);
  animation: fade .2s ease;
}
.drawer-body {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  padding: 22px;
  background: #0c0e14;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  animation: slideIn .26s var(--ease);
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.hint-line { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  font-size: 12.5px;
}
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- 大图 ---- */
.lightbox { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 26px; }
.lightbox-backdrop {
  position: absolute; inset: 0;
  background: rgba(3, 4, 7, .9);
  backdrop-filter: blur(8px);
  animation: fade .2s ease;
}
.lightbox-body {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: min(1080px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: reveal .3s var(--ease);
}
.lightbox-body img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  background: #06070a;
}
.lightbox-body figcaption {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(12, 14, 20, .9);
  border: 1px solid var(--line);
}
.lightbox-body figcaption p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  max-height: 66px;
  overflow-y: auto;
}
.lightbox-body figcaption .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lightbox-close {
  position: absolute;
  top: -14px; right: -14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: rgba(14, 16, 23, .95);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* ------------------------------------------------------------- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(18, 20, 28, .96);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn .22s var(--ease);
  max-width: 88vw;
  text-align: center;
}
.toast.is-err { border-color: rgba(255, 107, 107, .5); color: #ffc4c4; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }

/* ------------------------------------------------------------- 响应式 ---- */
@media (max-width: 1080px) {
  .main { grid-template-columns: 348px minmax(0, 1fr); gap: 18px; }
  .panel { padding: 19px; }
}

@media (max-width: 900px) {
  .app { padding: 16px 14px 32px; }
  .main { grid-template-columns: 1fr; }
  .panel { position: static; order: 2; }
  .stage { order: 1; padding: 14px; }
  .models { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-text p { display: none; }
  .grid { max-height: none; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .result-bar { flex-direction: column; align-items: stretch; }
  .result-bar .actions { justify-content: stretch; }
  .result-bar .actions > * { flex: 1; }
  .topbar { padding-bottom: 14px; }
  .lightbox { padding: 12px; }
  .lightbox-close { top: 6px; right: 6px; }
}

@media (max-width: 560px) {
  .app { padding: 12px 11px 28px; }
  .brand-text h1 { font-size: 17px; }
  .pill { height: 29px; padding: 0 10px; font-size: 11.5px; }
  .panel { padding: 16px; gap: 16px; }
  /* 窄屏直接吃满宽度，比例仍由 --ar 决定 */
  .canvas { width: 100%; max-height: 70vh; }
  .canvas-empty h2 { font-size: 15px; }
  .primary { height: 50px; }
  .foot { flex-direction: column; gap: 6px; padding-top: 20px; }
  .seg button { min-width: 54px; font-size: 12px; padding: 8px 6px; }
  /* 手机上模型卡单列，说明不挤 */
  .models { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
