:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #111111;
  --text-soft: #525252;
  --muted: #a3a3a3;
  --ink: #111111;
  --ink-soft: #404040;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-strong: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }

/* ===== 顶部导航 ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: var(--ink); }
.brand-text h1 { font-size: 18px; letter-spacing: .5px; color: var(--ink); font-weight: 700; }
.brand-text p { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.ghost-btn { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 9px; cursor: pointer; background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); font-size: 13px; transition: all .18s ease; }
.ghost-btn:hover { color: var(--ink); border-color: var(--ink); }
.ghost-btn.danger:hover { color: #fff; background: var(--ink); border-color: var(--ink); }
.ghost-btn .badge { position: absolute; top: -7px; right: -7px; font-style: normal; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 11px; display: grid; place-items: center; }

/* ===== 纵向堆叠布局 ===== */
.stack { max-width: 1180px; margin: 24px auto; padding: 0 26px 70px; display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 20px 22px 6px; }
.panel-head.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-head h2 { font-size: 16px; font-weight: 700; }
.panel-head .muted { font-size: 12px; }
.muted { color: var(--muted); }

/* ===== 输入面板（置顶） ===== */
.input-panel { padding: 18px 22px 20px; }
.io-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; flex-wrap: wrap; gap: 10px; }
.io-head label { font-size: 14px; font-weight: 700; }
.io-tools { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.counter { font-size: 12px; color: var(--muted); }
.counter em { color: var(--text-soft); font-style: normal; }
.model-pill { font-size: 11.5px; padding: 4px 11px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); }
.model-pill.ok { background: var(--ink); color: #fff; border-color: var(--ink); }
.mini-btn { padding: 6px 12px; border-radius: 7px; font-size: 12px; cursor: pointer; background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); transition: all .16s; }
.mini-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); }
.mini-btn:disabled { opacity: .4; cursor: not-allowed; }

textarea#inputText { width: 100%; min-height: 150px; resize: vertical; padding: 16px 18px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 15px; line-height: 1.75; font-family: inherit; transition: border-color .18s; }
textarea#inputText:focus { outline: none; border-color: var(--ink); }
textarea#inputText::placeholder { color: var(--muted); }

.action-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.action-summary { font-size: 12px; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.action-summary .sm-tag { padding: 3px 10px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.action-summary .sm-tag b { color: var(--ink); font-weight: 600; }
.primary-btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border: 1px solid var(--ink); border-radius: 9px; cursor: pointer; color: #fff; font-size: 14px; font-weight: 600; background: var(--ink); transition: all .18s; white-space: nowrap; }
.primary-btn.small { padding: 7px 15px; font-size: 12.5px; }
.primary-btn:hover { background: #000; box-shadow: var(--shadow-strong); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: .5; cursor: wait; transform: none; }

/* ===== 结果对比区 ===== */
.result-panel { padding-bottom: 22px; }
.result-toolbar { display: flex; gap: 8px; }
.meta-pill { font-size: 11.5px; padding: 4px 11px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); }
.meta-pill b { color: var(--ink); font-weight: 600; }
.result-grid { padding: 14px 22px 0; }
.result-cards { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 14px; }
.result-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 11px; display: flex; flex-direction: column; min-height: 180px; overflow: hidden; transition: all .2s; animation: fadeIn .3s ease; }
.result-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.result-card.chosen { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.result-card.error { opacity: .8; }
.result-card.skeleton { align-items: center; justify-content: center; }
.rc-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; gap: 8px; }
.rc-title { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.rc-no { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; display: grid; place-items: center; }
.rc-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.rc-body { flex: 1; padding: 4px 14px 12px; font-size: 13.5px; line-height: 1.8; color: var(--text); white-space: pre-wrap; }
.rc-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); gap: 8px; flex-wrap: wrap; }
.rc-meta { font-size: 11.5px; color: var(--muted); }
.rc-actions { display: flex; gap: 6px; }
.result-note { margin: 16px 0 0; font-size: 12px; color: var(--text-soft); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 11px 14px; line-height: 1.6; }

.empty-state { text-align: center; padding: 40px 10px; color: var(--text-soft); }
.empty-icon { color: var(--muted); margin-bottom: 12px; display: flex; justify-content: center; }
.empty-state p { font-size: 13.5px; margin-bottom: 6px; }
.empty-state .muted { font-size: 12px; }

.thinking { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px; }
.thinking-dots { display: flex; gap: 7px; }
.thinking-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); animation: bounce 1.2s infinite ease-in-out; }
.thinking-dots span:nth-child(2) { animation-delay: .18s; }
.thinking-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .35; } 40% { transform: scale(1); opacity: 1; } }
.thinking p { font-size: 12.5px; color: var(--text-soft); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== 配置面板（下移） ===== */
.config-panel { padding-bottom: 18px; }
.config-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0; padding: 6px 0 0; }
.cfg-block { padding: 14px 22px; border-top: 1px solid var(--border); }
.config-cols .cfg-block { border-top: 1px solid var(--border); border-right: 1px solid var(--border); }
.config-cols .cfg-block:last-child { border-right: none; }
.dim-block { border-top: 1px solid var(--border); }
.cfg-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.add-mini { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); cursor: pointer; font-size: 15px; line-height: 1; transition: all .16s; }
.add-mini:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px; background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); transition: color .16s ease, background .16s ease, border-color .16s ease; user-select: none; }
.chip-grid.editable .chip { padding-right: 52px; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { color: #fff; border-color: var(--ink); background: var(--ink); font-weight: 500; }
.chip-ops { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 3px; opacity: 0; pointer-events: none; transition: opacity .16s ease; }
.chip:hover .chip-ops { opacity: 1; pointer-events: auto; }
.chip-op { font-style: normal; width: 17px; height: 17px; flex-shrink: 0; border-radius: 5px; display: grid; place-items: center; font-size: 10px; background: rgba(0,0,0,.08); transition: background .14s; }
.chip.active .chip-op { background: rgba(255,255,255,.2); }
.chip-op:hover { background: rgba(0,0,0,.16); }
.chip.active .chip-op:hover { background: rgba(255,255,255,.35); }

/* ===== 维度滑块 ===== */
.slider-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.slider-item .slider-top { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; margin-bottom: 8px; }
.slider-item .slider-val { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.slider-item input[type=range] { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 4px; cursor: pointer; background: linear-gradient(90deg, var(--ink) var(--p,50%), var(--surface-2) var(--p,50%)); }
.slider-item input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform .14s; }
.slider-item input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.18); }
.slider-item .slider-desc { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ===== 抽屉 ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40; opacity: 0; visibility: hidden; transition: all .26s; }
.drawer-mask.show { opacity: 1; visibility: visible; }
.drawer { position: fixed; top: 0; left: 0; height: 100%; width: 460px; max-width: 92vw; z-index: 45; background: #fff; border-right: 1px solid var(--border); box-shadow: var(--shadow-strong); transform: translateX(-100%); transition: transform .3s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; }
.drawer.right { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); transform: translateX(100%); }
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: 16px; font-weight: 700; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text-soft); cursor: pointer; transition: all .18s; font-size: 14px; }
.icon-btn:hover { color: #fff; background: var(--ink); border-color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cfg-foot { flex-direction: column; align-items: stretch; gap: 12px; }
.cfg-foot-io { display: flex; gap: 8px; }
.cfg-foot-io .ghost-btn { flex: 1; justify-content: center; }
.cfg-foot-main { display: flex; justify-content: space-between; gap: 10px; }

/* ===== AI 配置 ===== */
.ai-field { margin-bottom: 22px; }
.ai-field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.field-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.field-row label { font-size: 13px; font-weight: 600; }
.field-desc { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.ai-select, .ai-input, .ai-textarea { width: 100%; padding: 10px 13px; background: #fff; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; font-family: inherit; }
.ai-select:focus, .ai-input:focus, .ai-textarea:focus { outline: none; border-color: var(--ink); }
.ai-textarea { min-height: 190px; resize: vertical; line-height: 1.7; font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 12.5px; }
.seg-control { display: flex; gap: 5px; background: var(--surface-2); padding: 4px; border-radius: 9px; border: 1px solid var(--border); }
.seg-control button { flex: 1; padding: 9px; border: none; background: transparent; color: var(--text-soft); border-radius: 6px; cursor: pointer; font-size: 12.5px; transition: all .18s; }
.seg-control button.active { background: var(--ink); color: #fff; }

/* 模型卡片 */
.model-list { display: flex; flex-direction: column; gap: 10px; }
.model-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); transition: all .18s; }
.model-card.active { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--ink); }
.mc-main { min-width: 0; flex: 1; }
.mc-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mc-badge { font-size: 10px; font-weight: 500; padding: 1px 7px; border-radius: 10px; background: var(--ink); color: #fff; }
.mc-sub { font-size: 11px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-ops { display: flex; gap: 5px; flex-shrink: 0; }
.empty-models { font-size: 12.5px; color: var(--text-soft); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 16px; line-height: 1.7; text-align: center; }

/* 开关 */
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 10px; }
.switch-row .sw-label { font-size: 13px; font-weight: 600; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 24px; transition: .2s; cursor: pointer; }
.switch .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::before { transform: translateX(18px); }
.prompt-vars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.prompt-vars code { font-size: 11px; padding: 3px 8px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-soft); cursor: pointer; }
.prompt-vars code:hover { border-color: var(--ink); }

/* 历史记录 */
.history-item { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; cursor: pointer; transition: all .18s; }
.history-item:hover { border-color: var(--ink); }
.history-item .hi-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.history-item .hi-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.history-item .hi-tag { font-size: 10.5px; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-soft); }
.history-item .hi-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.history-item .hi-text { font-size: 12.5px; color: var(--text-soft); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-empty { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 13px; line-height: 1.8; }

/* ===== 通用弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all .22s; padding: 20px; }
.modal-mask.show { opacity: 1; visibility: visible; }
.modal { width: 460px; max-width: 100%; max-height: 90vh; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-strong); display: flex; flex-direction: column; transform: scale(.96); transition: transform .22s; overflow: hidden; }
.modal-mask.show .modal { transform: scale(1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.mb-field { margin-bottom: 16px; }
.mb-field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 7px; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow-strong); opacity: 0; visibility: hidden; transition: all .26s; z-index: 100; }
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== 响应式 ===== */
@media (max-width: 980px) {
  .result-cards { grid-template-columns: repeat(2, 1fr) !important; }
  .config-cols { grid-template-columns: 1fr; }
  .config-cols .cfg-block { border-right: none; }
  .slider-list { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .stack { padding: 0 14px 40px; }
  .brand-text p { display: none; }
  .ghost-btn span { display: none; }
  .result-cards { grid-template-columns: 1fr !important; }
}
