
/* ================= 主题 ================= */
:root, [data-theme="light"] {
  --bg: #f4f0e8;
  --card: rgba(255,253,248,.92);
  --border: #d8d4c9;
  --border-soft: #e7e2d5;
  --text: #17252a;
  --muted: #6e7977;
  --faint: #9a9d97;
  --ink-soft: #29434a;
  --input-bg: #fffdf8;
  --input-border: #d8d4c9;
  --code-bg: #eef0ec;
  --shadow: 0 18px 45px rgba(52,64,58,.08);
  --accent: #e86d52;
  --accent-hover: #d55a3e;
  --accent-soft: #fdeee8;
  --accent-text: #e86d52;
  --teal: #0d8d87;
  --teal-soft: #e0f0ef;
  --teal-bright: #12a8a0;
  --amber: #9a6514; --amber-bg: #faf0dc; --amber-border: #e8cf9a;
  --green: #137a69; --green-bg: #e2f2ee; --green-border: #a9d8cc;
  --red: #b6424d;   --red-bg: #fae9e9;   --red-border: #eec3c3;
  --gray-bg: #f1ede3;
  --topbar-bg: transparent;
  --preview-bg: #ffffff;
  --radius: 18px;
}
[data-theme="dark"] {
  --bg: #141311;
  --card: rgba(30,29,26,.94);
  --border: #3a372f;
  --border-soft: #2c2a24;
  --text: #ece7d9;
  --muted: #a09a8a;
  --faint: #6e6a5e;
  --ink-soft: #cfc9b8;
  --input-bg: #1e1c18;
  --input-border: #3a372f;
  --code-bg: #1a1917;
  --shadow: 0 18px 45px rgba(0,0,0,.4);
  --accent: #e86d52;
  --accent-hover: #f07f63;
  --accent-soft: #3a241e;
  --accent-text: #f07f63;
  --teal: #2bb5ad;
  --teal-soft: #173936;
  --teal-bright: #3ec9c0;
  --amber: #e8b34f; --amber-bg: #2e2410; --amber-border: #5c4a1e;
  --green: #4ade80; --green-bg: #14291b; --green-border: #245632;
  --red: #f87171;   --red-bg: #2e1515;   --red-border: #5c2626;
  --gray-bg: #22201b;
  --topbar-bg: transparent;
  --preview-bg: #ffffff;
}
/* ================= 基础 ================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  background:
    radial-gradient(700px 420px at 8% -60px, rgba(240,179,79,.16), transparent 60%),
    radial-gradient(760px 460px at 92% -80px, rgba(13,141,135,.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.6;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(23,37,42,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,37,42,.05) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 75%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 75%);
}
[data-theme="dark"] body::before { opacity: .4; }
.topbar, .layout { position: relative; z-index: 1; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.fill { fill: currentColor; stroke: none; }
/* ================= 顶栏 ================= */
.topbar { flex: none; }
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 14px 24px 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, #0d8d87, #12a8a0);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(13,141,135,.3), inset 0 1px 0 rgba(255,255,255,.25);
}
.logo svg { width: 30px; height: 30px; }
.kicker {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; letter-spacing: .14em; color: var(--teal); font-weight: 600;
  text-transform: uppercase;
}
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -.03em; line-height: 1.25; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex: none; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .45; transform: scale(.8);} }
.top-right { display: flex; align-items: center; gap: 14px; padding-top: 4px; }
.top-tagline { margin: 0; font-size: 12px; color: var(--muted); text-align: right; line-height: 1.7; }
@media (max-width: 760px) { .top-tagline { display: none; } }
@media (max-width: 640px) { .brand-sub { display: none; } }
.top-rule {
  max-width: 1440px; margin: 0 auto; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 120px, #f0b34f 340px, transparent 620px);
  opacity: .85;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; flex: none;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--teal); }
.icon-btn svg.icon { width: 18px; height: 18px; }
/* ================= 布局：左功能 / 右结果 ================= */
.layout {
  flex: 1; min-height: 0; width: 100%;
  max-width: 1440px; margin: 0 auto; padding: 18px 24px 22px;
  display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 18px;
}
/* 左列：两个窗口，无滚动条，内容必须在面板内放下 */
.col-left { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 0; overflow: visible; }
.col-left .card { flex: 1 1 0; min-height: 0; overflow: visible; display: flex; flex-direction: column; }
.col-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* ================= 卡片 ================= */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}
.card-pad { padding: 16px 18px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.card-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px; letter-spacing: .1em; color: var(--faint); white-space: nowrap;
}
.card-h2 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-h2 .spacer { flex: 1; }
/* ================= 表单 ================= */
.field { margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px; font-weight: 700; font-size: 13px; color: var(--ink-soft);
}
.field label svg.icon { width: 14px; height: 14px; color: var(--faint); }
.field input[type="text"], .field input[type="password"], .field select {
  width: 100%; padding: 8px 12px; font-size: 14px; font-family: inherit;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--input-border); border-radius: 11px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft);
}
.field input::placeholder { color: var(--faint); }
.key-wrap { position: relative; }
.key-wrap input { padding-right: 42px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.eye-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 8px; cursor: pointer; color: var(--faint);
}
.eye-btn:hover { color: var(--text); background: var(--gray-bg); }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.opt-row { display: flex; gap: 18px; margin-top: 6px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { accent-color: var(--teal); width: 14px; height: 14px; margin: 0; cursor: pointer; }
.btn-row .btn.primary { flex: 1; min-width: 0; }
.btn-row .btn.ghost { flex: none; white-space: nowrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; font-family: inherit;
  background: linear-gradient(135deg, var(--teal), var(--teal-bright)); color: #fffdf8;
  box-shadow: 0 7px 16px rgba(13,141,135,.24), inset 0 1px 0 rgba(255,255,255,.22);
  transition: filter .15s, transform .05s, opacity .15s, box-shadow .15s;
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 7px 20px rgba(13,141,135,.34), inset 0 1px 0 rgba(255,255,255,.22); }
.btn.primary:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: var(--gray-bg); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover:not(:disabled) { border-color: var(--faint); }
.btn.block { width: 100%; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
[data-theme="dark"] .btn.primary .spinner { border-color: rgba(20,20,26,.3); border-top-color: #14141a; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-line { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--muted); min-height: 22px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.status-dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.status-dot.busy { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.connected-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border);
}
.connected-badge[hidden] { display: none; }
.connected-badge svg.icon { width: 12px; height: 12px; }
/* ================= 分段选择 ================= */
.seg { display: inline-flex; border: 1px solid var(--input-border); border-radius: 10px; overflow: hidden; background: var(--input-bg); }
.seg button {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 18px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--teal); color: #fffdf8; }
.seg button:not(.active):hover { background: var(--gray-bg); }
.param-stack { display: flex; flex-direction: column; gap: 10px; }
details.test-desc {
  margin-top: 10px; border: 1px solid var(--border-soft); border-radius: 10px;
  background: var(--gray-bg); font-size: 13px; color: var(--muted);
}
details.test-desc summary {
  cursor: pointer; padding: 10px 14px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px; list-style: none;
}
details.test-desc summary::-webkit-details-marker { display: none; }
details.test-desc summary svg.icon { transition: transform .2s; color: var(--faint); }
details.test-desc[open] summary svg.icon { transform: rotate(90deg); }
details.test-desc .desc-body { padding: 0 14px 12px; }
details.test-desc ol { margin: 8px 0 0; padding-left: 20px; }
/* ================= 面板头与小按钮 ================= */
.mini-btn {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); font-size: 12.5px; font-weight: 600; font-family: inherit;
  padding: 6px 11px;
}
.mini-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
.mini-btn:disabled { opacity: .45; cursor: not-allowed; }
.mini-btn svg.icon { width: 13px; height: 13px; }
/* ================= 结果卡片（右侧单卡片：标题 + 双窗格 + 观测说明） ================= */
.results-card { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.results-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 15px 17px 10px; flex: none;
}
.run-state {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; color: var(--muted); white-space: nowrap; padding-top: 4px;
  display: flex; align-items: center; gap: 7px;
}
.run-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.run-state.busy::before { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.run-state.ok::before { background: var(--green); }
.run-state.err::before { background: var(--red); }
.output-grid {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1.12fr; gap: 12px;
  padding: 0 17px 12px;
}
.out-pane {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  border: 1px solid var(--border-soft); border-radius: 11px; overflow: hidden;
  background: var(--input-bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.pane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--border-soft); flex: none;
}
.pane-title { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.pane-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px; letter-spacing: .1em; color: var(--faint); white-space: nowrap;
}
.pane-head .spacer { flex: 1; }
/* ---------------- 日志窗格（终端风深色内嵌） ---------------- */
.log-pane { background: #101218; border-color: #262b36; }
.log-pane .pane-head { border-bottom-color: #262b36; }
.log-pane .pane-title { color: #e6e9ef; }
.log-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  background: none; border: none; color: #8b949e; flex: none;
}
.log-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.log-btn svg.icon { width: 15px; height: 15px; transition: transform .2s; }
.log-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.75;
}
.log-line { word-break: break-all; }
.log-line .log-time { color: #6e7681; }
.log-line.info { color: #9aa4b2; }
.log-line.ok { color: #7ee787; }
.log-line.warn { color: #e3b341; }
.log-line.err { color: #ff7b72; }
/* 日志内的上游原始输出（可折叠，纯文本） */
.log-raw {
  margin: 4px 0; border: 1px solid #262b36; border-radius: 8px;
  background: rgba(255,255,255,.02); word-break: break-all;
}
.log-raw summary {
  cursor: pointer; padding: 6px 10px; font-size: 12px;
  color: #79c0ff; list-style: none; user-select: none;
}
.log-raw summary::-webkit-details-marker { display: none; }
.log-raw summary::before { content: "\25b8  "; color: #6e7681; }
.log-raw[open] summary::before { content: "\25be  "; }
.log-raw pre {
  margin: 0; padding: 10px 12px; border-top: 1px solid #262b36;
  font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
  color: #c9d1d9; max-height: 320px; overflow: auto;
}
/* ---------------- 预览窗格（纯白渲染区） ---------------- */
.preview-pane { background: #fff; }
.preview-body { position: relative; flex: 1; min-height: 0; background: #fff; }
iframe.preview { width: 100%; height: 100%; border: none; background: #fff; display: block; }
.preview-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  padding: 32px; color: #6f7977; background: #fff;
}
.preview-empty .art {
  width: 120px; height: 90px; border: 2px dashed var(--border); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; color: var(--faint);
  background: var(--gray-bg);
}
.preview-empty .art svg.icon { width: 40px; height: 40px; }
.preview-empty p { margin: 0; font-size: 13.5px; max-width: 340px; }
.preview-empty strong { color: var(--muted); display: block; margin-bottom: 4px; font-size: 14px; }
/* ================= 矮屏适配：压缩左列，杜绝滚动条 ================= */
@media (max-height: 820px) {
  .topbar-inner { padding: 8px 24px 6px; }
  .brand .kicker { display: none; }
  .brand-name { font-size: 18px; }
  .brand-sub { font-size: 11px; }
  .logo { width: 38px; height: 38px; border-radius: 12px; }
  .logo svg { width: 24px; height: 24px; }
  .top-rule { margin-top: 2px; }
  .layout { padding-top: 12px; }
  .card-pad { padding: 10px 16px; }
  .card-top { margin-bottom: 2px; }
  .card-top .kicker { font-size: 10px; }
  .card-h2 { font-size: 15px; margin-bottom: 3px; }
  .card-desc { font-size: 11.5px; margin: 0 0 6px; padding-bottom: 6px; }
  .field { margin-bottom: 6px; }
  .field label { margin-bottom: 3px; font-size: 12.5px; }
  .field input[type="text"], .field input[type="password"], .field select { padding: 7px 12px; font-size: 13.5px; }
  .btn { padding: 8px 16px; font-size: 13.5px; }
  .btn-row { gap: 8px; }
  .status-line { margin-top: 6px; font-size: 12.5px; min-height: 20px; }
  .param-stack { gap: 6px; }
  .seg button { padding: 6px 14px; font-size: 12.5px; }
  details.test-desc { margin-top: 6px; font-size: 12.5px; }
  details.test-desc summary { padding: 8px 12px; }
}
/* ================= 响应式 ================= */
@media (max-width: 1080px) {
  body { height: auto; min-height: 100vh; overflow: visible; display: block; }
  .layout { display: block; padding: 14px 12px 48px; }
  .col-left { overflow: visible; margin-bottom: 18px; }
  .col-left .card { flex: none; overflow: visible; margin-bottom: 18px; }
  .results-card { min-height: 80vh; }
  .output-grid { grid-template-columns: 1fr; }
  .log-pane { height: 260px; flex: none; }
  .preview-pane { height: 60vh; flex: none; }
}
@media (max-width: 640px) {
  .layout { padding: 14px 12px 48px; }
  .topbar-inner { padding: 0 14px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }
  .col-left .status-line .card-meta { display: none; }
  .panel-title { font-size: 18px; }
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}


/* ================= v2 追加：设置项、标签页、验收清单 ================= */
/* 左列字段变多，允许自身滚动；右列保持整屏工作台 */
.col-left { overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
.col-left::-webkit-scrollbar { width: 8px; }
.col-left::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.field textarea, .topic-card textarea {
  width: 100%; padding: 9px 12px; font-size: 13px; font-family: inherit; line-height: 1.6;
  background: var(--input-bg); color: var(--text); resize: none; min-height: 66px;
  border: 1px solid var(--input-border); border-radius: 11px; outline: none;
}
.field textarea:focus, .topic-card textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.hint { margin: 6px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--faint); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; color: var(--muted);
  border: 1px solid var(--input-border); background: var(--input-bg);
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--teal); color: var(--text); }
.chip.active { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }

/* 标签页 */
.tabs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 0 17px 10px; flex: none; border-bottom: 1px solid var(--border-soft);
}
.tabs .spacer { flex: 1 1 auto; }
.tab {
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--muted);
}
.tab:hover { color: var(--text); background: var(--gray-bg); }
.tab.active { color: var(--text); background: var(--card); border-color: var(--border); box-shadow: var(--shadow); }

/* 面板区 */
.pane-area { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding: 12px 17px 4px; }
.pane { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.pane[hidden] { display: none; }
.pane .log-pane { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.pane .log-body { flex: 1 1 0; min-height: 120px; }
#pane-preview { position: relative; }
#pane-preview .preview { flex: 1 1 0; min-height: 0; border: 1px solid var(--border-soft); border-radius: 12px; }
/* ---------------- 作品广场（本机历史网格） ---------------- */
.gallery-grid {
  flex: 1 1 0; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px; align-content: start; padding: 2px 4px 8px 2px;
}
.gallery-grid::-webkit-scrollbar { width: 8px; }
.gallery-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.gallery-empty { grid-column: 1 / -1; margin: 8px 2px; }
.gallery-card {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 12px;
  overflow: hidden; cursor: pointer; user-select: none;
  box-shadow: 0 2px 8px rgba(52,64,58,.06);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.gallery-card:hover, .gallery-card:focus-visible {
  transform: translateY(-2px); border-color: var(--teal);
  box-shadow: 0 10px 22px rgba(13,141,135,.16);
  outline: none;
}
.gallery-thumb {
  position: relative; height: 180px; overflow: hidden;
  background: var(--preview-bg); border-bottom: 1px solid var(--border-soft);
}
.gallery-thumb-frame {
  width: 200%; height: 200%; border: 0; display: block; background: #fff;
  transform: scale(.5); transform-origin: 0 0; pointer-events: none;
}
.gallery-thumb-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 12px; background: var(--gray-bg);
}
.gallery-info { padding: 10px 12px 11px; }
.gallery-info b {
  display: block; font-size: 12.5px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gallery-info small { display: block; margin-top: 2px; font-size: 11px; color: var(--faint); }
/* 作品大图弹层 */
.gallery-overlay {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(15, 20, 19, .58);
  animation: gallery-fade .18s ease-out;
}
@keyframes gallery-fade { from { opacity: 0; } }
.gallery-panel {
  display: flex; flex-direction: column; width: 100%; max-width: 980px;
  height: min(760px, 100%);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  animation: gallery-pop .18s ease-out;
}
@keyframes gallery-pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.gallery-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-soft); flex: none; min-width: 0;
}
.gallery-panel-head b {
  display: block; font-size: 14px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gallery-panel-head small { display: block; font-size: 11.5px; color: var(--muted); }
.gallery-stage { flex: 1 1 0; min-height: 0; background: var(--preview-bg); }
.gallery-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.gallery-stage-empty {
  margin: 0; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 13px;
}
.gallery-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--border-soft); flex: none;
}
.gallery-actions .btn { padding: 7px 14px; font-size: 13px; }
@media (max-width: 640px) {
  .gallery-overlay { padding: 12px; }
  .gallery-actions .btn { flex: 1 1 40%; }
}

/* ================= v2 左列紧凑化 ================= */
.field { margin-bottom: 8px; }
.field label { margin-bottom: 5px; }
.label-hint { font-weight: 500; font-size: 11.5px; color: var(--faint); letter-spacing: 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-grid .field { margin-bottom: 8px; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; padding-left: 0; padding-right: 0; }
.seg.compact { display: flex; width: 100%; }
.seg.compact button { flex: 1; padding: 8px 0; font-size: 12.5px; }
.token-line { display: flex; align-items: center; gap: 8px; }
.token-line input { flex: 0 0 86px; width: 86px; }
.token-line .chip-row { margin-top: 0; flex: 1; min-width: 0; }
.connect-row { margin-top: 0; }
.connect-row .btn.ghost { flex: 1; }
.btn.ghost .spinner { border-color: rgba(23,37,42,.2); border-top-color: var(--ink-soft); }
[data-theme="dark"] .btn.ghost .spinner { border-color: rgba(236,231,217,.25); border-top-color: var(--text); }
/* 单卡流：标题区 + 状态行 */
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 0; color: var(--text); }
.col-left .status-line {
  justify-content: space-between; margin-top: 10px; margin-bottom: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-soft);
}
.col-left .status-line #statusText { flex: 1; }
/* API Key 脚注行 */
.key-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 5px; }
.key-foot .hint { margin: 0; }
/* 题目卡 / 配置块 */
.topic-card {
  border: 1px solid var(--border-soft); background: var(--gray-bg);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.topic-card textarea { background: var(--input-bg); min-height: 66px; font-size: 12.5px; }
.topic-card .hint { margin-bottom: 0; }
.topic-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.topic-title { font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: .02em; }
.topic-action {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--teal);
}
.topic-action:hover { text-decoration: underline; }
.cfg-block { margin-bottom: 12px; }
.cfg-summary {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.more-settings {
  border: 1px solid var(--border-soft); border-radius: 10px; background: var(--input-bg);
}
.more-settings summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.more-settings summary::-webkit-details-marker { display: none; }
.more-settings summary::before { content: "\25b8"; color: var(--faint); font-size: 11px; transition: transform .15s; }
.more-settings[open] summary::before { transform: rotate(90deg); }
.more-settings[open] summary { border-bottom: 1px solid var(--border-soft); }
.more-body { padding: 10px 12px 12px; }
.more-body .field { margin-bottom: 8px; }
.more-body .opt-row { margin-top: 2px; gap: 12px; }
.more-body .btn-row { margin-top: 8px; }
.more-body .btn.ghost { padding: 7px 14px; font-size: 13px; }
/* 大 CTA */
.start-btn { padding: 13px 18px; font-size: 15px; border-radius: 12px; justify-content: flex-start; gap: 10px; }
.start-arrow { width: 17px; height: 17px; margin-left: auto; flex: none; }
.start-btn:disabled .start-arrow { opacity: .5; }
.foot-note { margin: 9px 0 0; font-size: 11px; color: var(--faint); text-align: center; line-height: 1.7; }
@media (max-height: 820px) {
  .conn-foot { margin-top: 6px; }
  .field-grid { gap: 6px; }
  .field-grid .field { margin-bottom: 6px; }
  .field { margin-bottom: 6px; }
  .field label { margin-bottom: 3px; }
  .token-line { gap: 6px; }
  .panel-title { font-size: 17px; }
  .col-left .status-line { margin-top: 6px; margin-bottom: 8px; padding-bottom: 8px; }
  .topic-card { padding: 8px 10px; }
  .start-btn { padding: 10px 16px; font-size: 14px; }
}
