/* ==================================================================
   KKAI-CHAT 网页版 — 主样式
   浅色为主，深色为辅。所有颜色走 CSS 变量，改主题只需改这一处。
   ================================================================== */

:root {
  --bg:            #f5f7fa;
  --surface:       #ffffff;
  --surface-2:     #eef1f6;
  --surface-3:     #e5e9f0;
  --border:        #e2e6ed;
  --border-strong: #cfd6e0;

  --text:          #171a1f;
  --text-2:        #545c6b;
  --muted:         #8a92a1;

  --accent:        #3b63f6;
  --accent-hover:  #2d51dd;
  --accent-soft:   #edf1ff;
  --accent-ring:   rgba(59, 99, 246, 0.18);

  --success:       #17a673;
  --success-soft:  #e6f7f0;
  --danger:        #e04b4b;
  --danger-soft:   #fdeded;
  --warn:          #d99518;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.14);

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

  --sidebar-w: 268px;
  --content-max: 800px;

  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system,
          BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Cascadia Mono", monospace;
}

[data-theme="dark"] {
  --bg:            #14161a;
  --surface:       #1b1e24;
  --surface-2:     #23272e;
  --surface-3:     #2c313a;
  --border:        #2b3038;
  --border-strong: #3a414c;

  --text:          #e8eaee;
  --text-2:        #a5adba;
  --muted:         #737c8b;

  --accent:        #6d8bff;
  --accent-hover:  #8099ff;
  --accent-soft:   #202741;
  --accent-ring:   rgba(109, 139, 255, 0.25);

  --success:       #35c48f;
  --success-soft:  #16281f;
  --danger:        #f06868;
  --danger-soft:   #2c1a1a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);
}

/* ------------------------------ 基础 ------------------------------ */

* { box-sizing: border-box; }

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

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

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
[hidden] { display: none !important; }

svg {
  width: 100%; height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico { width: 17px; height: 17px; flex: none; }
.ico--sm { width: 14px; height: 14px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ------------------------------ 通用控件 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .16s, border-color .16s, color .16s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background .16s, color .16s;
  flex: none;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.input {
  width: 100%;
  height: 40px;
  padding: 0 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: var(--muted); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; }
.input-group .icon-btn { position: absolute; right: 4px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  display: flex; justify-content: space-between; align-items: center;
}
.field__label b { color: var(--accent); font-variant-numeric: tabular-nums; }
.field__hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.field--row { flex-direction: row; align-items: center; gap: 9px; cursor: pointer; }
.field textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  resize: vertical;
  font-size: 14px;
  transition: border-color .16s, box-shadow .16s;
}
.field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

input[type="checkbox"] {
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}
input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-3);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border: 3px solid var(--surface);
  border-radius: 50%; background: var(--accent);
}

.btn-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ------------------------------ 品牌 ------------------------------ */

.brand { display: flex; align-items: center; gap: 9px; }
.brand__mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7b5cf0);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .3px;
  box-shadow: 0 3px 10px var(--accent-ring);
}
.brand__name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.brand--lg .brand__mark { width: 44px; height: 44px; font-size: 16px; border-radius: 13px; }
.brand--lg .brand__name { font-size: 20px; }

/* ------------------------------ 访问门 ------------------------------ */

.gate {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 200;
  padding: 20px;
}
.gate__card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 34px 28px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
  align-items: stretch;
}
.gate__card .brand { justify-content: center; margin-bottom: 4px; }
.gate__hint { margin: 0; text-align: center; color: var(--text-2); font-size: 13px; }
.gate__error { margin: 0; text-align: center; color: var(--danger); font-size: 13px; min-height: 18px; }

/* ------------------------------ 布局 ------------------------------ */

.app { display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
  transition: margin-left .24s cubic-bezier(.4,0,.2,1);
}
.app.is-collapsed .sidebar { margin-left: calc(var(--sidebar-w) * -1); }

.sidebar__head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.sidebar__search {
  position: relative;
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 11px;
  height: 36px;
  gap: 8px;
  color: var(--muted);
  transition: border-color .16s, background .16s;
}
.sidebar__search:focus-within { background: var(--surface); border-color: var(--accent); }
.sidebar__search input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  font-size: 13px;
  color: var(--text);
}

.conv-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.conv-group {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 14px 10px 6px;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-2);
  transition: background .14s, color .14s;
  position: relative;
}
.conv-item:hover { background: var(--surface-2); color: var(--text); }
.conv-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.conv-item__title {
  flex: 1; min-width: 0;
  font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item__actions { display: none; gap: 2px; }
.conv-item:hover .conv-item__actions,
.conv-item.is-active .conv-item__actions { display: flex; }
.conv-item__actions .icon-btn { width: 24px; height: 24px; border-radius: 6px; }
.conv-item__actions .icon-btn svg { width: 14px; height: 14px; }
.conv-item__pin { color: var(--accent); }
.conv-empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }

.sidebar__foot { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.side-action {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background .14s, color .14s;
  text-align: left;
}
.side-action:hover { background: var(--surface-2); color: var(--text); }

.sidebar-scrim { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ------------------------------ 顶栏 ------------------------------ */

.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.topbar__spacer { flex: 1; }
.topbar__menu { display: none; }
.topbar__expand { display: none; }
.app.is-collapsed .topbar__expand { display: inline-flex; }

.model-picker { position: relative; }
.model-picker__btn {
  display: flex; align-items: center; gap: 8px;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: background .14s;
  max-width: 46vw;
}
.model-picker__btn:hover { background: var(--surface-2); }
.model-picker__btn > span:nth-child(2) {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  flex: none;
  transition: background .2s;
}
.dot.is-on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.is-error { background: var(--danger); }

.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 330px;
  max-width: 88vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  overflow: hidden;
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-5px); } }
.dropdown__search { padding: 10px; border-bottom: 1px solid var(--border); }
.dropdown__search input {
  width: 100%; height: 34px; padding: 0 11px;
  background: var(--surface-2);
  border: 1px solid transparent; border-radius: 9px;
  outline: none; font-size: 13px;
}
.dropdown__search input:focus { border-color: var(--accent); background: var(--surface); }
.dropdown__list { max-height: 340px; overflow-y: auto; padding: 6px; }
.dropdown__foot { padding: 8px; border-top: 1px solid var(--border); }
.model-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background .12s;
}
.model-opt:hover { background: var(--surface-2); }
.model-opt.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.model-opt__id { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-opt__tag {
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 5px;
  background: var(--surface-3); color: var(--text-2);
  flex: none;
}
.dropdown__empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all .16s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-on {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

/* ------------------------------ 参数面板 ------------------------------ */

.param-panel {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 22px;
  animation: slideDown .18s ease-out;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } }
.param-panel__grid {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 22px;
}
.param-panel__grid .field:first-child { grid-column: 1 / -1; }

/* ------------------------------ 消息区 ------------------------------ */

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 8px 0 20px;
}
.msg-inner { max-width: var(--content-max); margin: 0 auto; padding: 0 22px; }

.msg { padding: 18px 0; animation: fadeUp .22s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
.msg + .msg { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }

.msg__head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.msg__avatar {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800;
  flex: none;
}
.msg--user .msg__avatar { background: var(--surface-3); color: var(--text-2); }
.msg--assistant .msg__avatar {
  background: linear-gradient(135deg, var(--accent), #7b5cf0);
  color: #fff;
}
.msg__name { font-size: 13px; font-weight: 600; }
.msg__meta { font-size: 11.5px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.msg__body { padding-left: 35px; }
.msg--user .msg__body { color: var(--text); }

.msg__actions {
  display: flex; gap: 2px;
  padding-left: 32px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .16s;
}
.msg:hover .msg__actions { opacity: 1; }
.msg__actions .icon-btn { width: 28px; height: 28px; border-radius: 7px; }
.msg__actions .icon-btn svg { width: 15px; height: 15px; }

.msg__edit textarea {
  width: 100%;
  min-height: 100px;
  padding: 11px 13px;
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--surface);
  outline: none;
  resize: vertical;
  font-size: 15px;
  line-height: 1.65;
}

/* 附件展示 */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.msg-img {
  max-width: 220px; max-height: 220px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  cursor: zoom-in;
  object-fit: cover;
  display: block;
}
.msg-file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  max-width: 260px;
}
.msg-file__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file__size { color: var(--muted); font-size: 11.5px; flex: none; }

/* 思考中 */
.thinking { display: inline-flex; align-items: center; gap: 4px; height: 22px; }
.thinking span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.3s infinite ease-in-out both;
}
.thinking span:nth-child(2) { animation-delay: .16s; }
.thinking span:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8);} 40% { opacity: 1; transform: scale(1);} }

/* 搜索来源 */
.sources {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.sources__head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.sources__head:hover { background: var(--surface-2); }
.sources__count {
  margin-left: auto;
  font-size: 11.5px; font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 8px; border-radius: 99px;
}
.sources__list { border-top: 1px solid var(--border); padding: 6px; }
.source-item {
  display: block;
  padding: 8px 10px;
  border-radius: 9px;
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.source-item:hover { background: var(--surface-2); }
.source-item__title { font-size: 13.5px; font-weight: 500; color: var(--accent); }
.source-item__url { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item__snippet { font-size: 12.5px; color: var(--text-2); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.status-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  padding: 7px 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  width: fit-content;
}
.spinner {
  width: 13px; height: 13px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------ 欢迎页 ------------------------------ */

.welcome {
  max-width: 660px;
  margin: 0 auto;
  padding: 8vh 22px 40px;
  text-align: center;
}
.welcome__logo {
  width: 60px; height: 60px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #7b5cf0);
  color: #fff;
  font-size: 20px; font-weight: 800;
  box-shadow: 0 10px 30px var(--accent-ring);
}
.welcome h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: -.5px; }
.welcome__sub { margin: 0 0 26px; color: var(--text-2); font-size: 14.5px; }
.welcome__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
  text-align: left;
}
.wcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
.wcard:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.wcard__title { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.wcard__desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ------------------------------ 输入区 ------------------------------ */

.composer-wrap {
  flex: none;
  padding: 0 22px 12px;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}
.composer {
  max-width: var(--content-max);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  transition: border-color .16s, box-shadow .16s;
  overflow: hidden;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-md); }
.composer__row { display: flex; align-items: flex-end; gap: 6px; padding: 7px 8px 7px 7px; }
.composer textarea {
  flex: 1;
  min-height: 26px;
  max-height: 220px;
  padding: 8px 4px;
  border: none;
  outline: none;
  background: none;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  overflow-y: auto;
}
.composer textarea::placeholder { color: var(--muted); }
.composer__attach { margin-bottom: 1px; }

.send-btn {
  width: 34px; height: 34px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  margin-bottom: 1px;
  transition: background .16s, opacity .16s;
}
.send-btn svg { width: 17px; height: 17px; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.send-btn.is-stop { background: var(--danger); }
.send-btn.is-stop svg { fill: currentColor; stroke: none; }

.composer__note {
  max-width: var(--content-max);
  margin: 7px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

.attach-strip {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 10px 2px;
}
.attach-item {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 30px 7px 9px;
  font-size: 12.5px;
  max-width: 230px;
}
.attach-item__thumb {
  width: 30px; height: 30px;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
  background: var(--surface-3);
}
.attach-item__icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.attach-item__icon svg { width: 15px; height: 15px; }
.attach-item__info { min-width: 0; }
.attach-item__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.attach-item__sub { color: var(--muted); font-size: 11px; }
.attach-item__x {
  position: absolute; top: 50%; right: 5px;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--muted);
}
.attach-item__x:hover { background: var(--surface-3); color: var(--danger); }
.attach-item__x svg { width: 12px; height: 12px; }
.attach-item.is-loading { opacity: .6; }

.drop-overlay {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border: 2.5px dashed var(--accent);
  border-radius: var(--r-lg);
  display: none;
  place-items: center;
  z-index: 90;
  margin: 10px;
  pointer-events: none;
}
.drop-overlay.is-active { display: grid; }
.drop-overlay div { font-size: 17px; font-weight: 600; color: var(--accent); }

/* ------------------------------ 弹窗 ------------------------------ */

.modal { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 20px; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(16, 22, 32, .42);
  backdrop-filter: blur(3px);
  animation: fade .16s;
}
@keyframes fade { from { opacity: 0; } }
.modal__panel {
  position: relative;
  width: 100%; max-width: 540px;
  max-height: 88vh;
  background: var(--bg);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .2s cubic-bezier(.2,.8,.3,1);
}
.modal__panel--wide { max-width: 760px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
.modal__head h2 { margin: 0; font-size: 16px; }
.modal__body { padding: 20px 22px 26px; overflow-y: auto; }
.modal__version { text-align: center; color: var(--muted); font-size: 11.5px; margin: 24px 0 0; }

.setting-group { margin-bottom: 26px; display: flex; flex-direction: column; gap: 14px; }
.setting-group:last-of-type { margin-bottom: 0; }
.setting-group h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .5px;
  text-transform: uppercase;
}
.conn-status { font-size: 13px; }
.conn-status.is-ok { color: var(--success); }
.conn-status.is-err { color: var(--danger); }

.prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color .16s, transform .16s;
}
.prompt-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.prompt-card__title { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.prompt-card__desc {
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ------------------------------ Toast ------------------------------ */

.toasts {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 17px;
  border-radius: 99px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.2,.8,.3,1);
  max-width: 86vw;
}
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-success { background: var(--success); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* 图片灯箱 */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(10, 14, 20, .88);
  z-index: 400;
  display: grid; place-items: center;
  cursor: zoom-out;
  animation: fade .16s;
  padding: 30px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 860px) {
  :root { --content-max: 100%; }
  .topbar__menu { display: inline-flex; }
  .topbar__expand,
  .app.is-collapsed .topbar__expand { display: none; }
  .sidebar__collapse { display: none; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 120;
    box-shadow: var(--shadow-lg);
    margin-left: calc(var(--sidebar-w) * -1);
  }
  .app.is-mobile-open .sidebar { margin-left: 0; }
  .app.is-mobile-open .sidebar-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(16, 22, 32, .4);
    z-index: 110;
  }
  .msg-inner, .composer-wrap { padding-left: 14px; padding-right: 14px; }
  .param-panel { padding: 14px; }
  .welcome { padding-top: 5vh; }
  .msg__body, .msg__actions { padding-left: 0; }
}
