/* ═══════════════════════════════════════════════════════════
   Pixel Forge — 设计令牌
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f0efea;
  --line: #e6e4dd;
  --line-strong: #d5d2c9;

  --ink: #16161a;
  --ink-2: #4e4e57;
  --ink-3: #8a8a93;
  --ink-4: #b3b2ab;

  --accent: #d0492a;
  --accent-hover: #b83d21;
  --accent-soft: #fbeee9;
  --accent-line: #f2cfc3;

  --ok: #2f8f5b;
  --warn: #b8791f;
  --err: #c33b32;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 25, .05);
  --shadow-md: 0 6px 20px -8px rgba(20, 20, 25, .16);
  --shadow-lg: 0 24px 60px -20px rgba(20, 20, 25, .28);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); color: var(--accent); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d8d6cf; border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #c0beb6; background-clip: content-box; }

.mono { font-family: var(--mono); font-size: .92em; }
.spacer { flex: 1; }

/* ═══════════════════════════════════════════════════════════
   布局
   ═══════════════════════════════════════════════════════════ */
.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 370px;
  height: 100vh;
  height: 100dvh;
}

/* ═══════════════════════════════════════════════════════════
   左栏
   ═══════════════════════════════════════════════════════════ */
.rail {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  min-height: 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, #e2572f, #b8381c);
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .5px;
  display: grid; place-items: center; flex: none;
  box-shadow: 0 4px 12px -4px rgba(208, 73, 42, .55);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; letter-spacing: -.2px; }
.brand-text span { font-size: 11px; color: var(--ink-3); letter-spacing: .2px; }

.rail-block { display: flex; flex-direction: column; min-height: 0; padding: 0 8px; }
.rail-grow { flex: 1; padding-bottom: 6px; }

.rail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}

.mini-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-3);
  height: 22px; min-width: 22px; padding: 0 4px; border-radius: 6px;
  display: inline-grid; place-items: center;
  font-size: 11px; line-height: 1; transition: .15s; white-space: nowrap; flex: none;
}
.mini-btn:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line); }

.provider-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-bottom: 4px; }

.provider-item {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--r-sm); border: 1px solid transparent;
  transition: .15s; text-align: left; background: transparent; width: 100%;
}
.provider-item:hover { background: var(--surface-3); }
.provider-item.active { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.provider-item.active::before {
  content: ""; position: absolute; left: -1px; top: 9px; bottom: 9px;
  width: 2.5px; border-radius: 99px; background: var(--accent);
}

.pv-avatar {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center; flex: none; border: 1px solid var(--line);
}
.provider-item.active .pv-avatar { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.pv-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; flex: 1; }
.pv-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-sub { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pv-edit {
  opacity: 0; width: 20px; height: 20px; border-radius: 5px;
  border: 1px solid transparent; background: transparent; color: var(--ink-3);
  display: grid; place-items: center; font-size: 11px; transition: .15s; flex: none;
}
.provider-item:hover .pv-edit { opacity: 1; }
.pv-edit:hover { background: var(--surface-3); border-color: var(--line); color: var(--ink); }

.empty-note { padding: 14px 10px; font-size: 12px; color: var(--ink-3); line-height: 1.6; }

.history-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.history-item {
  display: flex; gap: 9px; align-items: center; padding: 6px 8px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; text-align: left; transition: .15s; width: 100%;
}
.history-item:hover { background: var(--surface-3); }

.hi-thumb {
  width: 34px; height: 34px; border-radius: 6px; object-fit: cover;
  background: var(--surface-3); flex: none; border: 1px solid var(--line);
}
.hi-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.hi-prompt { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hi-time { font-size: 10px; color: var(--ink-4); }

.rail-foot {
  display: flex; align-items: center; gap: 7px; padding: 10px 16px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); flex: none;
}
.dot { width: 6px; height: 6px; border-radius: 99px; background: var(--ink-4); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 143, 91, .13); }
.dot.bad { background: var(--err); }

/* ═══════════════════════════════════════════════════════════
   中间：生图工作台
   ═══════════════════════════════════════════════════════════ */
.studio { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 52px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 243, 239, .82);
  backdrop-filter: blur(12px);
  flex: none; z-index: 5;
}

.ctx { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; }
.ctx-site { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-sep { color: var(--ink-4); }
.ctx-model { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }

.top-actions { margin-left: auto; display: flex; gap: 6px; flex: none; }

.ghost-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 6px 11px; border-radius: var(--r-sm); font-size: 12.5px;
  transition: .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.ghost-btn:hover { border-color: var(--line-strong); color: var(--ink); background: #fff; }
.ghost-btn.wide { width: 100%; justify-content: center; }
.ghost-btn.icon-only { display: none; padding: 6px 8px; }
.accent-ghost { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.accent-ghost:hover { background: #f8e2da; border-color: var(--accent); color: var(--accent-hover); }

.solid-btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 8px 15px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  transition: .15s; white-space: nowrap;
}
.solid-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.solid-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── 画布 ── */
.canvas { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px 24px 8px; }

.result-set {
  max-width: 920px; margin: 0 auto 26px;
  animation: rise .35s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.result-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.result-prompt { font-size: 13px; color: var(--ink-2); line-height: 1.5; flex: 1; min-width: 0; }
.result-meta { display: flex; gap: 5px; flex-wrap: wrap; flex: none; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 99px;
  background: var(--surface-3); border: 1px solid var(--line);
  font-size: 10.5px; color: var(--ink-2); white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.img-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px; width: 100%; align-items: start;
}
.img-grid.single { grid-template-columns: minmax(0, 520px); justify-content: center; }

.img-card {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--line);
  cursor: zoom-in; line-height: 0;
  animation: fade .4s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.img-card img {
  width: 100%; height: auto; min-height: 90px;
  object-fit: contain; display: block;
  transition: transform .5s cubic-bezier(.22, 1, .36, 1);
}
.img-card:hover img { transform: scale(1.02); }

.img-actions {
  position: absolute; right: 8px; bottom: 8px;
  display: flex; gap: 6px; opacity: 0; transform: translateY(4px); transition: .2s;
}
.img-card:hover .img-actions { opacity: 1; transform: none; }

.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; border: none;
  background: rgba(22, 22, 26, .78); color: #fff;
  display: grid; place-items: center; backdrop-filter: blur(6px); transition: .15s;
}
.icon-btn:hover { background: var(--accent); }

/* 空状态 */
.canvas-empty {
  max-width: 540px; margin: 7vh auto 0; text-align: center;
  animation: rise .5s cubic-bezier(.22, 1, .36, 1) both;
}
.canvas-empty .mark {
  width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 16px;
  background: linear-gradient(145deg, #e2572f, #b8381c);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 14px 30px -12px rgba(208, 73, 42, .6);
}
.canvas-empty h1 { font-size: 21px; margin: 0 0 8px; letter-spacing: -.4px; font-weight: 680; }
.canvas-empty p { color: var(--ink-3); font-size: 13.5px; margin: 0 0 22px; line-height: 1.7; }

.wsteps { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.wstep {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 13px; color: var(--ink-2); box-shadow: var(--shadow-sm);
}
.wstep b { color: var(--ink); font-weight: 600; }
.wstep .num {
  width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft);
  color: var(--accent); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; flex: none; margin-top: 1px;
}

/* 生成中 / 错误 */
.pending {
  max-width: 920px; margin: 0 auto 26px;
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 12.5px; color: var(--ink-3);
  box-shadow: var(--shadow-sm);
}
.typing { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.typing i { width: 5px; height: 5px; border-radius: 99px; background: var(--ink-4); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.err-box {
  max-width: 920px; margin: 0 auto 26px;
  padding: 12px 16px; border-radius: var(--r-md);
  background: #fdf4f2; border: 1px solid #f0c9c4; color: #a8322a;
  font-size: 12.5px; line-height: 1.6;
}

/* ── 底部输入区 ── */
.dock {
  flex: none; padding: 10px 24px 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(to top, var(--surface-2) 70%, rgba(250, 249, 246, .4));
}

.strip {
  max-width: 920px; margin: 0 auto 9px;
  display: flex; gap: 7px; flex-wrap: wrap; align-items: center;
  min-height: 30px;
}

.pchip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 2px 3px 2px 9px;
  font-size: 11.5px; color: var(--ink-3); transition: .15s;
}
.pchip:hover { border-color: var(--line-strong); }
.pchip > span { white-space: nowrap; }
.pchip select, .pchip input {
  border: none; background: transparent; outline: none;
  font-size: 11.5px; color: var(--ink); padding: 3px 2px;
  border-radius: 5px; max-width: 200px;
}
.pchip select:focus, .pchip input:focus { background: var(--accent-soft); }
.pchip input[type="number"] { width: 42px; text-align: center; }
.pchip.toggle { padding-right: 6px; cursor: pointer; user-select: none; }
.pchip.toggle.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

.strip-empty { font-size: 11.5px; color: var(--ink-4); }

.prompt-row { max-width: 920px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }

.prompt-row textarea {
  flex: 1; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--r-lg); padding: 11px 15px;
  resize: none; outline: none; max-height: 150px;
  line-height: 1.6; font-size: 14px;
  transition: border-color .18s, box-shadow .18s;
}
.prompt-row textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.prompt-row textarea::placeholder { color: var(--ink-4); }

.gen-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: var(--r-lg);
  font-size: 13.5px; font-weight: 500; transition: .16s; flex: none;
}
.gen-btn:hover:not(:disabled) { background: var(--accent); transform: translateY(-1px); }
.gen-btn:disabled { opacity: .45; cursor: not-allowed; }

.dock-hint {
  max-width: 920px; margin: 7px auto 0;
  font-size: 11px; color: var(--ink-4);
  display: flex; align-items: center; gap: 4px;
}
kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px;
  border-radius: 4px; background: var(--surface-3);
  border: 1px solid var(--line); color: var(--ink-3);
}

/* ═══════════════════════════════════════════════════════════
   右栏：接入会话
   ═══════════════════════════════════════════════════════════ */
.copilot {
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; flex-direction: column; min-height: 0;
}

.copilot-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 11px;
  border-bottom: 1px solid var(--line); flex: none;
}

.copilot-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 650; letter-spacing: .02em; }

.pulse {
  width: 7px; height: 7px; border-radius: 99px; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(208, 73, 42, .5); animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(208, 73, 42, .45); }
  70% { box-shadow: 0 0 0 7px rgba(208, 73, 42, 0); }
  100% { box-shadow: 0 0 0 0 rgba(208, 73, 42, 0); }
}

.chat {
  flex: 1; overflow-y: auto; padding: 14px 13px;
  display: flex; flex-direction: column; gap: 13px;
}

.cm { display: flex; gap: 8px; animation: rise .3s cubic-bezier(.22, 1, .36, 1) both; }
.cm.user { flex-direction: row-reverse; }

.cm-avatar {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700; letter-spacing: .3px; margin-top: 1px;
}
.cm.assistant .cm-avatar { background: linear-gradient(145deg, #e2572f, #b8381c); color: #fff; }
.cm.user .cm-avatar { background: var(--surface-3); color: var(--ink-3); border: 1px solid var(--line); }

.cm-body { min-width: 0; max-width: calc(100% - 32px); display: flex; flex-direction: column; gap: 7px; }
.cm.user .cm-body { align-items: flex-end; }

.cm-bubble {
  padding: 8px 11px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.62;
  white-space: pre-wrap; word-break: break-word;
}
.cm.assistant .cm-bubble {
  background: var(--surface); border: 1px solid var(--line);
  border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm);
}
.cm.user .cm-bubble { background: var(--ink); color: #f6f5f2; border-bottom-right-radius: 4px; }
.cm-bubble b { font-weight: 650; }
.cm-bubble code {
  font-family: var(--mono); font-size: 11px;
  background: var(--surface-3); border-radius: 4px; padding: 1px 4px;
  border: 1px solid var(--line);
}

/* 工具调用轨迹 */
.tool-trace {
  display: flex; flex-direction: column; gap: 3px;
  padding: 6px 9px; border-radius: 8px;
  background: var(--surface); border: 1px dashed var(--line-strong);
  font-size: 10.5px; color: var(--ink-3); font-family: var(--mono);
  line-height: 1.5;
}
.tool-trace .t-row { display: flex; gap: 5px; align-items: baseline; }
.tool-trace .t-name { color: var(--accent); flex: none; }
.tool-trace .t-arg { color: var(--ink-3); word-break: break-all; }
.tool-trace .t-ok { color: var(--ok); flex: none; }
.tool-trace .t-fail { color: var(--err); flex: none; }

.choices { display: flex; flex-wrap: wrap; gap: 5px; }
.choice {
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 99px; padding: 4px 10px;
  font-size: 11.5px; color: var(--ink-2); transition: .15s;
}
.choice:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.choice.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.choice.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.chat-chips { display: flex; gap: 5px; flex-wrap: wrap; padding: 0 13px 7px; flex: none; }
.chat-chips:empty { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  padding: 3px 9px; border-radius: 99px; font-size: 11px;
  transition: .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

.chat-form { display: flex; gap: 7px; align-items: flex-end; padding: 0 12px 13px; flex: none; }

.chat-form textarea {
  flex: 1; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 12px; padding: 8px 11px;
  resize: none; outline: none; font-size: 12.5px; line-height: 1.55;
  max-height: 100px; transition: border-color .18s, box-shadow .18s;
}
.chat-form textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-form textarea::placeholder { color: var(--ink-4); }

.chat-send {
  width: 33px; height: 33px; border-radius: 10px;
  border: none; background: var(--ink); color: #fff;
  display: grid; place-items: center; flex: none; transition: .15s;
}
.chat-send:hover:not(:disabled) { background: var(--accent); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* 文本模型未配置时的引导卡片 */
.setup-card {
  margin: 16px 13px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 11px;
}
.setup-card h3 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.1px; }
.setup-card p { margin: 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.setup-card .sf { display: flex; flex-direction: column; gap: 4px; }
.setup-card label { font-size: 11px; color: var(--ink-2); font-weight: 600; }
.setup-card input, .setup-card select {
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 7px; padding: 7px 9px; font-size: 12px; outline: none;
  transition: .15s; width: 100%;
}
.setup-card input:focus, .setup-card select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.setup-card .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.setup-actions { display: flex; gap: 7px; align-items: center; margin-top: 2px; }
.setup-msg { font-size: 11px; color: var(--ink-3); line-height: 1.5; }
.setup-msg.ok { color: var(--ok); }
.setup-msg.err { color: var(--err); }

.llm-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--ink-3);
  padding: 2px 8px; border-radius: 99px;
  background: var(--surface-3); border: 1px solid var(--line);
}
.llm-badge .dot { width: 5px; height: 5px; }

/* ═══════════════════════════════════════════════════════════
   抽屉
   ═══════════════════════════════════════════════════════════ */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(22, 22, 26, .3);
  backdrop-filter: blur(2px); opacity: 0; pointer-events: none;
  transition: opacity .25s; z-index: 40;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 460px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
  z-index: 41; display: flex; flex-direction: column;
}
.drawer.show { transform: none; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.2px; }

.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }

.drawer-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--line);
  background: var(--surface-2); flex: none;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.field-hint { margin: 0; font-size: 11px; color: var(--ink-4); line-height: 1.5; }

.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--r-sm); padding: 8px 10px; outline: none;
  transition: .15s; font-size: 13px;
}
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-4); }

.protocol-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.proto-card {
  text-align: left; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--r-sm); padding: 9px 10px; transition: .15s;
  display: flex; flex-direction: column; gap: 1px;
}
.proto-card:hover { border-color: var(--ink-4); }
.proto-card.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.proto-card strong { font-size: 12.5px; font-weight: 600; }
.proto-card span { font-size: 10.5px; color: var(--ink-3); line-height: 1.35; }
.proto-card.active span { color: var(--accent); opacity: .8; }

.probe-box { display: flex; align-items: center; gap: 10px; }
.probe-status { font-size: 11.5px; color: var(--ink-3); }
.probe-result { display: flex; flex-direction: column; gap: 8px; }
.probe-result:empty { display: none; }

.probe-ok {
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-size: 12px; color: var(--accent); line-height: 1.6;
}
.probe-fail {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-size: 12px; color: var(--ink-2); line-height: 1.6;
}

.model-pills { display: flex; flex-wrap: wrap; gap: 5px; max-height: 130px; overflow-y: auto; }
.model-pill {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 99px; padding: 3px 9px;
  font-size: 11px; font-family: var(--mono); color: var(--ink-2); transition: .15s;
}
.model-pill:hover { border-color: var(--accent); color: var(--accent); }
.model-pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.adv {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); overflow: hidden;
}
.adv summary {
  padding: 10px 12px; font-size: 12px; font-weight: 550; color: var(--ink-2);
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::after { content: "＋"; color: var(--ink-4); font-size: 12px; }
.adv[open] summary::after { content: "－"; }
.adv-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 11px; }

/* Toast / 灯箱 */
.toast {
  position: fixed; left: 50%; bottom: 34px;
  transform: translate(-50%, 16px);
  background: var(--ink); color: #fff;
  padding: 9px 18px; border-radius: 99px;
  font-size: 12.5px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 60;
  box-shadow: var(--shadow-md); max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); }

.lightbox {
  position: fixed; inset: 0; background: rgba(14, 14, 17, .88);
  display: grid; place-items: center; z-index: 80; padding: 40px;
  cursor: zoom-out; animation: fade .2s ease both; backdrop-filter: blur(4px);
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); }

/* ═══════════════════════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1180px) {
  .app { grid-template-columns: 236px minmax(0, 1fr); }
  .copilot {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 370px; max-width: 92vw;
    transform: translateX(102%);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
    z-index: 36; box-shadow: var(--shadow-lg);
  }
  .copilot.show { transform: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  #btnRailToggle { display: inline-flex; }
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 252px; z-index: 36;
    transform: translateX(-102%);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
    box-shadow: var(--shadow-lg);
  }
  .rail.show { transform: none; }
  .canvas { padding: 16px 14px 8px; }
  .dock { padding: 8px 14px 10px; }
  .topbar { padding: 0 14px; }
  .ctx-model { max-width: 110px; }
  .gen-btn span { display: none; }
  .gen-btn { padding: 12px 14px; }
}

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