/* ============================================================
   SenseNova WebUI — 设计系统
   ============================================================ */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

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

  --sp: 14px;
  --sidebar-w: 248px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.22s;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.36);
}

/* ---------- 深色 ---------- */
[data-theme="dark"] {
  --bg: #0a0c11;
  --bg-grad: radial-gradient(1200px 600px at 12% -8%, rgba(108, 124, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.09), transparent 55%);
  --surface: #11141c;
  --surface-2: #171b26;
  --surface-3: #1e2331;
  --elevated: #141824;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #e8ebf2;
  --text-dim: #a2abbd;
  --text-mute: #6d7688;

  --accent: #7c8bff;
  --accent-soft: rgba(124, 139, 255, 0.14);
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #6c7cff 0%, #8b5cf6 45%, #22d3ee 100%);

  --user-bubble: linear-gradient(135deg, #4f5bd5 0%, #6d4fd8 100%);
  --bot-bubble: #171b26;

  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #60a5fa;

  --code-bg: #0d1017;
  --inp-bg: #141824;
  --scroll: rgba(255, 255, 255, 0.11);
}

/* ---------- 浅色 ---------- */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-grad: radial-gradient(1100px 560px at 10% -10%, rgba(108, 124, 255, 0.13), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.11), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f8;
  --elevated: #ffffff;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);

  --text: #131a2b;
  --text-dim: #5a6478;
  --text-mute: #8b93a5;

  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-2: #0891b2;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #0891b2 100%);

  --user-bubble: linear-gradient(135deg, #5b62e8 0%, #7c4dd8 100%);
  --bot-bubble: #ffffff;

  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --info: #2563eb;

  --code-bg: #0f1420;
  --inp-bg: #fbfcfe;
  --scroll: rgba(15, 23, 42, 0.18);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
}

/* 紧凑模式 */
[data-density="compact"] { --sp: 9px; --r-lg: 12px; --r-xl: 16px; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

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

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
code { font-family: var(--font-mono); font-size: 0.88em; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }

.ico { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.only-mobile { display: none; }

/* ================= 布局 ================= */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 16px 16px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(108, 124, 255, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--text-mute); letter-spacing: 0.6px; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--text-mute); padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-md); color: var(--text-dim);
  font-size: 13.5px; font-weight: 500; transition: all var(--dur) var(--ease);
  position: relative; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-foot { padding: 12px 14px 16px; border-top: 1px solid var(--border); }
.conn-pill {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 10px; border-radius: 99px;
}
.conn-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); flex: none; }
.conn-pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }
.conn-pill.err .dot { background: var(--err); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16); }
.conn-pill.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16); }
.brand-mini { font-size: 10.5px; color: var(--text-mute); margin-top: 9px; text-align: center; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); background-image: var(--bg-grad); }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 13px 22px;
  border-bottom: 1px solid var(--border); backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 16px; font-weight: 650; letter-spacing: 0.2px; }
.topbar-title p { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.view { flex: 1; overflow: hidden; display: none; flex-direction: column; }
.view.active { display: flex; animation: fadeUp 0.3s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= 通用组件 ================= */
.ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; font-weight: 500;
  transition: all var(--dur) var(--ease);
}
.ghost-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); transform: translateY(-1px); }
.ghost-btn.sm { padding: 5px 10px; font-size: 12px; }
.ghost-btn.block { width: 100%; justify-content: center; }

.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 17px; border-radius: var(--r-md);
  background: var(--grad); color: #fff; font-weight: 600; font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(108, 124, 255, 0.3);
  transition: all var(--dur) var(--ease);
}
.primary-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(108, 124, 255, 0.4); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: grayscale(0.4); }
.primary-btn.sm { padding: 6px 12px; font-size: 12.5px; }
.primary-btn.block { width: 100%; }
.primary-btn.lg { padding: 12px 18px; font-size: 14.5px; }

.danger-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 17px;
  border-radius: var(--r-md); border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--err); background: rgba(248, 113, 113, 0.08); font-weight: 600; font-size: 13.5px;
  transition: all var(--dur) var(--ease);
}
.danger-btn:hover { background: rgba(248, 113, 113, 0.16); }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--text-dim); transition: all var(--dur) var(--ease); flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.link-btn { color: var(--accent); font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head strong { font-size: 14.5px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

.field { margin-bottom: 14px; min-width: 0; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 130px; }
.req { color: var(--err); }
.hint { font-size: 11.5px; color: var(--text-mute); margin-top: 5px; line-height: 1.5; }
.hint-inline { font-size: 12px; color: var(--text-mute); font-weight: 400; margin-left: 8px; }
.status-line { font-size: 12.5px; color: var(--text-mute); margin-top: 10px; min-height: 18px; }
.status-line.ok { color: var(--ok); } .status-line.err { color: var(--err); }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--r-md);
  background: var(--inp-bg); border: 1px solid var(--border); color: var(--text);
  outline: none; transition: border-color var(--dur), box-shadow var(--dur);
}
textarea { resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a5' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }
.sm-select { width: auto; padding: 5px 30px 5px 10px; font-size: 12.5px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-dim); }
.switch.inline { font-size: 12.5px; }
.switch input { display: none; }
.switch .slider {
  width: 38px; height: 21px; border-radius: 99px; background: var(--surface-3);
  border: 1px solid var(--border); position: relative; transition: all var(--dur) var(--ease); flex: none;
}
.switch .slider::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--text-mute); transition: all var(--dur) var(--ease);
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(17px); background: #fff; }
.switch-row { margin-bottom: 12px; }

.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); border: 1px solid var(--border); margin-bottom: 16px; }
.seg-item { flex: 1; padding: 7px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; color: var(--text-dim); transition: all var(--dur) var(--ease); }
.seg-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.ok { background: rgba(52, 211, 153, 0.13); color: var(--ok); border-color: transparent; }
.badge.warn { background: rgba(251, 191, 36, 0.13); color: var(--warn); border-color: transparent; }
.badge.err { background: rgba(248, 113, 113, 0.13); color: var(--err); border-color: transparent; }

.banner {
  display: flex; align-items: center; gap: 10px; margin: 14px 22px 0;
  padding: 11px 15px; border-radius: var(--r-md); font-size: 13px;
  background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.3); color: var(--warn);
}
.banner .ico { color: var(--warn); }
.banner code { background: rgba(0, 0, 0, 0.15); padding: 1px 5px; border-radius: 4px; }

/* ================= 对话 ================= */
.chat-layout { flex: 1; display: flex; min-height: 0; position: relative; }

.chat-sessions { width: 244px; flex: none; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
.cs-head { padding: 12px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--border); }
.cs-head input { flex: 1; }
.cs-list { flex: 1; overflow-y: auto; padding: 8px; }
.cs-item {
  padding: 9px 11px; border-radius: var(--r-md); cursor: pointer; margin-bottom: 3px;
  transition: all var(--dur) var(--ease); border: 1px solid transparent; position: relative;
}
.cs-item:hover { background: var(--surface-2); }
.cs-item.active { background: var(--accent-soft); border-color: rgba(124, 139, 255, 0.3); }
.cs-title { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-meta { font-size: 11px; color: var(--text-mute); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.cs-del { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; }
.cs-item:hover .cs-del { opacity: 1; }
.cs-foot { padding: 10px; border-top: 1px solid var(--border); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 22px 0 8px; scroll-behavior: smooth; }
.chat-messages { max-width: 860px; margin: 0 auto; padding: 0 26px; }

.msg { margin-bottom: 26px; animation: fadeUp 0.32s var(--ease); }
.msg-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.avatar { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 11px; font-weight: 700; }
.avatar.user { background: var(--grad); color: #fff; }
.avatar.bot { background: var(--surface-3); color: var(--accent); border: 1px solid var(--border); }
.msg-role { font-size: 12.5px; font-weight: 650; }
.msg-time { font-size: 11px; color: var(--text-mute); }
.msg-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur); }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions .icon-btn { width: 26px; height: 26px; }
.msg-actions .ico { width: 14px; height: 14px; }

.bubble { border-radius: var(--r-lg); padding: 13px 16px; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; }
.msg.assistant .bubble { background: var(--bot-bubble); border: 1px solid var(--border); }
.msg.error .bubble { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.35); color: var(--err); }

.reasoning { margin-bottom: 10px; border: 1px dashed var(--border-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); }
.reasoning summary { padding: 8px 12px; cursor: pointer; font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 7px; user-select: none; font-weight: 600; }
.reasoning summary:hover { background: var(--surface-3); }
.reasoning .rbody { padding: 4px 14px 12px; font-size: 12.5px; color: var(--text-mute); border-top: 1px dashed var(--border); max-height: 340px; overflow-y: auto; white-space: pre-wrap; line-height: 1.7; }
.thinking-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.25); } }

.tool-card {
  border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 10px;
  background: var(--surface-2); overflow: hidden;
}
.tool-card-h { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); }
.tool-card pre { padding: 10px 12px; font-size: 11.5px; color: var(--text-dim); white-space: pre-wrap; word-break: break-all; font-family: var(--font-mono); }

.msg-usage { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--text-mute); }
.msg-usage .badge { font-size: 10.5px; padding: 1px 7px; }

.retry-note {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 9px;
  padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: rgba(251, 191, 36, 0.13); color: var(--warn);
  border: 1px solid rgba(251, 191, 36, 0.32);
}
.spinner {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 2px solid rgba(251, 191, 36, 0.3); border-top-color: var(--warn);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cursor-blink { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; border-radius: 1px; }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0; } }

.empty-state { max-width: 520px; margin: 8vh auto; text-align: center; padding: 0 20px; }
.empty-state.sm { margin: 40px auto; }
.empty-logo { width: 62px; height: 62px; margin: 0 auto 18px; border-radius: 20px; display: grid; place-items: center; background: var(--grad); color: #fff; box-shadow: 0 12px 34px rgba(108, 124, 255, 0.35); }
.empty-state h2 { font-size: 21px; margin-bottom: 8px; font-weight: 650; }
.empty-state p { color: var(--text-mute); font-size: 13.5px; }
.prompt-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.chip {
  padding: 8px 14px; border-radius: 99px; font-size: 12.5px; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border); transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.composer-wrap { padding: 10px 26px 18px; }
.composer {
  max-width: 860px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  padding: 8px 8px 8px 10px; box-shadow: var(--shadow-md); transition: border-color var(--dur);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md); }
.composer textarea { flex: 1; border: none; background: none; resize: none; max-height: 220px; padding: 8px 4px; outline: none; box-shadow: none; }
.composer textarea:focus { box-shadow: none; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(108, 124, 255, 0.35);
  transition: all var(--dur) var(--ease);
}
.send-btn:hover { transform: scale(1.07); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.send-btn.stop { background: var(--err); box-shadow: 0 4px 14px rgba(248, 113, 113, 0.35); }
.composer-hint { max-width: 860px; margin: 7px auto 0; font-size: 11px; color: var(--text-mute); text-align: center; }

.attach-preview { max-width: 860px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.ap-item { position: relative; width: 66px; height: 66px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); }
.ap-item img { width: 100%; height: 100%; object-fit: cover; }
.ap-del { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, 0.65); color: #fff; display: grid; place-items: center; font-size: 12px; line-height: 1; }
.attached-img { max-width: 260px; border-radius: var(--r-md); margin: 4px 0; display: block; border: 1px solid var(--border); }

/* 参数面板 */
.chat-params { width: 306px; flex: none; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; }
.cp-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.cp-head strong { font-size: 13.5px; }
.cp-body { flex: 1; overflow-y: auto; padding: 14px 15px 24px; }
.cp-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-mute); font-weight: 700; margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.cp-sec:first-child { margin-top: 0; }
.range-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.range-row label { flex: 1; font-size: 12.5px; color: var(--text-dim); }
.range-row .val { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 5px; min-width: 46px; text-align: center; }
input[type="range"] { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 99px; background: var(--surface-3); outline: none; padding: 0; margin: 6px 0 12px; border: none; }
input[type="range"]:focus { box-shadow: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }
.cp-body textarea { min-height: 76px; font-size: 12.5px; }

/* ================= 图像 ================= */
.img-layout { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; grid-template-columns: 400px 1fr; gap: 18px; align-items: start; }
.img-form { position: sticky; top: 0; }
.img-result { min-height: 320px; display: flex; flex-direction: column; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.gcard { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); transition: all var(--dur) var(--ease); }
.gcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.gcard-img { position: relative; aspect-ratio: 1; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; }
.gcard-img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gcard-meta { padding: 9px 11px; font-size: 11.5px; color: var(--text-mute); display: flex; flex-direction: column; gap: 5px; }
.gcard-meta .prompt { color: var(--text-dim); max-height: 38px; overflow: hidden; line-height: 1.4; }
.gcard-actions { display: flex; gap: 6px; margin-top: 3px; }
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); padding: 22px 14px;
  text-align: center; cursor: pointer; color: var(--text-mute); transition: all var(--dur) var(--ease); background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .ico { width: 22px; height: 22px; margin-bottom: 6px; }
.dropzone p { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.dropzone:hover p { color: var(--accent); }
.dropzone span { font-size: 11px; }
.thumb-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; width: 62px; height: 62px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .thumb-del { position: absolute; top: 1px; right: 1px; width: 17px; height: 17px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; display: grid; place-items: center; border-radius: 50%; }
.size-custom { display: flex; align-items: center; gap: 6px; }
.size-custom input { text-align: center; padding: 9px 6px; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-mute); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ================= 调试 ================= */
.pg-layout { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.code-box {
  background: var(--code-bg); color: #d5dbe8; border-radius: var(--r-md); padding: 13px;
  overflow: auto; max-height: 460px; font-family: var(--font-mono); font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; border: 1px solid var(--border);
}
.code-box.sm { max-height: 150px; font-size: 11.5px; }

/* ================= 接入 ================= */
.integ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.integ-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 15px; background: var(--surface-2); transition: all var(--dur) var(--ease); }
.integ-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.integ-card h4 { font-size: 13.5px; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.integ-card .tagline { font-size: 11.5px; color: var(--text-mute); margin-bottom: 11px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 5px 10px; font-size: 12px; margin-bottom: 11px; }
.kv dt { color: var(--text-mute); }
.kv dd { font-family: var(--font-mono); font-size: 11.5px; word-break: break-all; color: var(--text-dim); }
.integ-card pre { background: var(--code-bg); color: #cfd6e4; border-radius: var(--r-sm); padding: 10px; font-size: 11.5px; overflow-x: auto; font-family: var(--font-mono); line-height: 1.6; margin-bottom: 10px; }

/* ================= 文档 ================= */
.docs-panel { flex: 1; display: grid; grid-template-columns: 190px 1fr; gap: 22px; overflow: hidden; min-height: 0; }
.docs-nav { overflow-y: auto; border-right: 1px solid var(--border); padding-right: 12px; }
.docs-nav button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--text-dim); transition: all var(--dur); }
.docs-nav button:hover { background: var(--surface-2); color: var(--text); }
.docs-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.docs-content { overflow-y: auto; padding-right: 8px; max-width: 900px; }

/* Markdown 渲染 */
.md h1 { font-size: 22px; margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.md h2 { font-size: 17px; margin: 24px 0 10px; }
.md h3 { font-size: 14.5px; margin: 18px 0 8px; color: var(--accent); }
.md h4 { font-size: 13.5px; margin: 14px 0 6px; }
.md p { margin: 0 0 11px; color: var(--text-dim); }
.md ul, .md ol { margin: 0 0 12px 22px; color: var(--text-dim); }
.md li { margin-bottom: 4px; }
.md blockquote { border-left: 3px solid var(--accent); padding: 6px 14px; margin: 0 0 12px; background: var(--accent-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--text-dim); }
.md code { background: var(--surface-3); padding: 1.5px 6px; border-radius: 5px; font-size: 12px; color: var(--accent-2); }
.md pre { background: var(--code-bg); color: #d5dbe8; padding: 13px; border-radius: var(--r-md); overflow-x: auto; margin: 0 0 13px; border: 1px solid var(--border); }
.md pre code { background: none; padding: 0; color: inherit; font-size: 12px; line-height: 1.65; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.md table { margin-bottom: 14px; }
.md a { color: var(--accent); }

/* Markdown 气泡内 */
.bubble .md p:last-child { margin-bottom: 0; }
.bubble .md pre { margin: 9px 0; }
.bubble .md ul, .bubble .md ol { margin: 0 0 9px 20px; }
.msg.user .bubble .md code { background: rgba(255, 255, 255, 0.2); color: #fff; }
.msg.user .bubble .md pre { background: rgba(0, 0, 0, 0.24); border-color: rgba(255, 255, 255, 0.16); }
.msg.user .bubble .md pre code { color: #fff; }
.msg.user .bubble a { color: #fff; text-decoration: underline; }

/* 代码高亮 */
.hl-key { color: #c792ea; } .hl-str { color: #a5e844; } .hl-com { color: #5f6b85; font-style: italic; }
.hl-num { color: #f78c6c; } .hl-fn { color: #82aaff; } .hl-tag { color: #f07178; }

.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-mute); }
.msg.user .bubble .code-head { background: rgba(0, 0, 0, 0.2); }
.copy-code { font-size: 11px; color: var(--text-mute); padding: 2px 8px; border-radius: 5px; border: 1px solid var(--border); }
.copy-code:hover { color: var(--accent); border-color: var(--accent); }

/* ================= 设置 ================= */
.settings-panel { max-width: 620px; margin: 20px auto; width: calc(100% - 44px); }
.key-input { display: flex; gap: 8px; align-items: center; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ================= 弹窗 / Toast ================= */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fadeIn 0.18s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); width: min(760px, 100%); max-height: 86vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop 0.24s var(--ease); }
@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body img { max-width: 100%; border-radius: var(--r-md); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--elevated); border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px 20px; border-radius: 99px; font-size: 13px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all 0.32s var(--ease); z-index: 200;
  display: flex; align-items: center; gap: 9px; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }

.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 39; }

/* ================= 响应式 ================= */
@media (max-width: 1240px) { .chat-params { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow-lg); } }
@media (max-width: 1080px) {
  .img-layout, .pg-layout { grid-template-columns: 1fr; }
  .img-form { position: static; }
}
@media (max-width: 860px) {
  .only-mobile { display: grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform 0.28s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-mask.show { display: block; }
  .chat-sessions { position: absolute; left: 0; top: 0; bottom: 0; z-index: 29; transform: translateX(-100%); transition: transform 0.28s var(--ease); box-shadow: var(--shadow-lg); }
  .chat-sessions.open { transform: none; }
  .docs-panel { grid-template-columns: 1fr; }
  .docs-nav { display: none; }
  .chat-messages { padding: 0 14px; }
  .composer-wrap { padding: 8px 14px 14px; }
  .topbar-title p { display: none; }
}
