/* ==========================================================================
   Mia 控制台设计系统
   - 双主题：:root[data-theme="dark"|"light"] 使用同一组变量名
   - 品牌主色：青碧（teal / cyan）。选它的理由：聊天界面是长时间停留的地方，
     青绿系蓝绿在深色底上不刺眼、不抢正文，也没有明显性别倾向
   - 纯 CSS 变量 + 组件类，无构建步骤
   ========================================================================== */

/* 与主题无关的令牌：动效曲线、圆角、焦点环。
   放在这里而不是两套主题里各写一份 —— 它们描述的是"怎么动"，不是"什么颜色"。 */
:root {
  --r-xs: 6px;  --r-sm: 9px;  --r: 13px;  --r-lg: 18px;  --r-full: 999px;
  --dur-fast: .12s;
  --dur: .2s;
  --dur-slow: .34s;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.32, .64, 1);
  --ring: 0 0 0 3px var(--brand-soft);
  --blur: saturate(140%) blur(14px);

  /* 自定义背景（见 miai/theme/）。默认"没有图"，三个值由 JS 写进来。
     不透明度默认只有 25%：背景是装饰，压过正文就本末倒置了。 */
  --bg-image: none;
  --bg-opacity: .25;
  --bg-blur: 0px;
  --bg-dim: .4;
  /* 有背景图时卡片要半透明，否则整张图被盖住 —— 这个值由 [data-bg="on"] 覆盖 */
  --surface-alpha: 100%;
}

:root[data-theme="dark"] {
  --bg: #0b1416;          /* 墨青：比纯黑暖一点，深色下不"死" */
  --bg-elev: #101c1e;
  --surface: #12201f;
  --surface-2: #16292b;
  --surface-hover: #1c3336;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .17);

  --text: #eaf4f4;
  --text-dim: #a8bfc2;
  --text-mute: #7a9296;

  --brand: #22d3ee;       /* 亮青：深色底上的链接/图标/选中态 */
  --brand-strong: #0e7490;
  --brand-soft: rgba(34, 211, 238, .14);
  --brand-glow: rgba(34, 211, 238, .3);
  /* 青碧渐变（按钮、自己的气泡）。两端都够亮，所以文字用**深色**：
     白字在这条渐变上对比度只有 1.9:1 —— 好看但看不清，笔画会糊在一起。 */
  --brand-grad: linear-gradient(135deg, #06b6d4, #22d3ee);
  --brand-text: #062a33;

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .14);

  /* 两层阴影：近处一层收紧边缘，远处一层给体积感。单层大模糊看起来是"发灰"而不是"浮起"。 */
  --shadow: 0 16px 40px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, .24), 0 8px 20px rgba(0, 0, 0, .26);
  --scroll: rgba(255, 255, 255, .13);
}

:root[data-theme="light"] {
  --bg: #f5f8f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f6f6;
  --surface-hover: #e8f0f1;
  --border: rgba(14, 116, 144, .14);
  --border-strong: rgba(14, 116, 144, .3);

  --text: #10282c;
  --text-dim: #47626a;
  --text-mute: #7a9199;

  --brand: #0e7490;       /* 浅色底上用深青：亮青在白底上对比度不够，脚注都看不清 */
  --brand-strong: #0b5c73;
  --brand-soft: rgba(14, 116, 144, .10);
  --brand-glow: rgba(14, 116, 144, .2);
  /* 浅色底上反过来：渐变要够**深**才好配白字（白字在 #0891b2 上约 4.2:1） */
  --brand-grad: linear-gradient(135deg, #0b5c73, #0891b2);
  --brand-text: #ffffff;

  --ok: #0f9d63;
  --ok-soft: rgba(15, 157, 99, .12);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, .12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .1);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, .1);

  --shadow: 0 14px 36px rgba(14, 116, 144, .12), 0 2px 5px rgba(14, 116, 144, .06);
  --shadow-sm: 0 1px 2px rgba(14, 116, 144, .06), 0 6px 16px rgba(14, 116, 144, .08);
  --scroll: rgba(14, 116, 144, .22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 自定义背景（覆盖全局） ----------
   用一张固定在视口上的伪元素，而不是给每个容器设 background-image：
   容器方案要在几十个组件上各写一遍 `background-attachment: fixed`，还必然漏掉几个。
   伪元素在 `z-index: -1`，所有内容自然压在它上面。

   `transform: scale(1.06)` 是给模糊留的余量 —— 高斯模糊会把边缘往外糊，
   不放大就会在四周露出一圈透明。 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-opacity);
  filter: blur(var(--bg-blur));
  transform: scale(1.06);
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease), filter var(--dur-slow) var(--ease);
}

/* 压一层底色：光靠透明度压不住花哨的图，正文会读不清。
   它和 `--bg-opacity` 是一对反作用力 —— 一个让图更明显、一个让字更清楚，
   所以两个都留给用户调。 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease);
}
:root[data-bg="on"] body::after { opacity: var(--bg-dim); }

/* 有背景图时把各处的不透明底色放掉，让图透上来。
   只调这几个"大面"—— 气泡、表格行这些小块保持不透明，否则整页都在飘，很难读。 */
:root[data-bg="on"] {
  --surface-alpha: 82%;
  /* 兜底底色：body 变透明之后，画布取的是**根元素**的背景。不给 html 这一层，
     画布就回落到浏览器默认的白色 —— 深色主题下一整页刷白，`body::before` 的图
     也被压在白底上，"图的不透明度"滑块随之失去意义。 */
  background: var(--bg);
}
:root[data-bg="on"] body { background: transparent; }
:root[data-bg="on"] .sidebar,
:root[data-bg="on"] .topbar {
  background: color-mix(in srgb, var(--bg-elev) var(--surface-alpha), transparent);
  backdrop-filter: var(--blur);
}
:root[data-bg="on"] .card {
  background: color-mix(in srgb, var(--surface) var(--surface-alpha), transparent);
  backdrop-filter: var(--blur);
}
:root[data-bg="on"] .chat-main { background: transparent; }
:root[data-bg="on"] .chat-head,
:root[data-bg="on"] .chat-input {
  background: color-mix(in srgb, var(--bg-elev) 72%, transparent);
  backdrop-filter: var(--blur);
}
:root[data-bg="on"] .chat-side {
  background: color-mix(in srgb, var(--bg-elev) var(--surface-alpha), transparent);
  backdrop-filter: var(--blur);
}
/* 登录页自己有整块品牌面板，不需要背景图透上来，免得两层图形打架 */
:root[data-bg="on"] .auth-card { backdrop-filter: var(--blur); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); background-clip: content-box; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono {
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
}

/* ---------- 布局：侧栏 + 主区 ---------- */

/* 高度用 dvh 而不是 vh：手机上地址栏收起/展开会改可视高度，vh 取的是「最大可能高度」，
   底部输入框会被顶到屏幕外。--app-h 由 app.js 从 visualViewport 写入，兜住
   iOS Safari / 微信这类「软键盘只缩 visual viewport」的浏览器（见 installViewportHeight）。 */
.shell { display: flex; height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); overflow: hidden; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  font-weight: 600; font-size: 16px; letter-spacing: .3px;
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid; place-items: center;
  border-radius: 9px; font-size: 15px; color: var(--brand-text);
  background: var(--brand-grad);
}
.brand small { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-mute); letter-spacing: 0; }

.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-group { margin-top: 12px; }
.nav-group > .nav-label {
  padding: 6px 8px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-mute);
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 9px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--text); font-weight: 600; }
.nav-item .ico { width: 17px; text-align: center; opacity: .85; flex: 0 0 17px; }
.nav-item .badge-dot { margin-left: auto; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 54px; flex: 0 0 54px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.topbar h1 { margin: 0; font-size: 15.5px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--text-mute); }

.content { flex: 1; overflow-y: auto; padding: 20px; }
.content.no-pad { padding: 0; overflow: hidden; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--text-mute); }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 10px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* 状态卡 */
.stat { padding: 16px 18px; }
.stat .label { font-size: 12px; color: var(--text-mute); display: flex; align-items: center; gap: 6px; }
.stat .value { margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -.4px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--text-mute); margin-left: 4px; }
.stat .meter { margin-top: 10px; }

.meter { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand-strong), var(--brand)); transition: width .4s; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s, transform .08s;
}
/* 悬停底色必须排除 .primary / .danger。
   本规则的特异性是 5 个类，而 `.btn.primary` 只有 2 个 —— 不排除的话，
   鼠标一移到主按钮上，渐变背景就被换成浅色底，而 color 仍是白色，
   按钮直接"消失"（白字白底）。danger 同理。 */
.btn:not(.primary):not(.danger):hover:not(:disabled) {
  background: var(--surface-hover); border-color: var(--border-strong);
}
.btn:hover:not(:disabled) { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand-grad); color: var(--brand-text); border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 表单 ---------- */

.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--text-dim); }
.field .hint { margin-top: 4px; font-size: 11.5px; color: var(--text-mute); }
.field .err { margin-top: 4px; font-size: 12px; color: var(--danger); }

input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
  width: 100%;
  padding: 8px 11px;
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
textarea.code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; min-height: 320px; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: auto; }

.switch { position: relative; display: inline-block; width: 38px; height: 21px; flex: 0 0 38px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--surface-hover); border: 1px solid var(--border);
  border-radius: 999px; transition: background .2s;
}
.switch .track::before {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--text-mute); transition: transform .2s, background .2s;
}
.switch input:checked + .track { background: var(--brand-soft); border-color: var(--brand); }
.switch input:checked + .track::before { transform: translateX(17px); background: var(--brand); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-mute); white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: 4px; }
table.data td.wrap { white-space: normal; word-break: break-word; max-width: 380px; }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-hover); color: var(--text-dim);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 7px; }

.tag {
  display: inline-block; padding: 1px 7px; margin: 2px 3px 2px 0;
  border-radius: 6px; font-size: 11.5px;
  background: var(--surface-hover); color: var(--text-dim);
}

/* ---------- 杂项 ---------- */

.empty {
  padding: 44px 20px; text-align: center; color: var(--text-mute);
}
.empty .big { font-size: 30px; opacity: .5; display: block; margin-bottom: 8px; }

.spinner {
  width: 16px; height: 16px; flex: 0 0 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { display: flex; align-items: center; gap: 9px; padding: 26px; justify-content: center; color: var(--text-mute); }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb0 { margin-bottom: 0; }

pre.code-block {
  margin: 0; padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto; line-height: 1.5;
  color: var(--text-dim);
}

/* ---------- 标签页 ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 18px; }
.tab {
  padding: 10px 14px; margin-bottom: -1px;
  font-size: 13px; color: var(--text-mute);
  border-bottom: 2px solid transparent; cursor: pointer; user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------- 弹层 ---------- */

.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(10, 8, 14, .55);
  backdrop-filter: blur(3px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  box-shadow: var(--shadow);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.3);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; padding: 16px 18px 10px; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 6px 18px 4px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 16px; }
.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: none; border-radius: 8px; background: transparent;
  color: var(--text-mute); cursor: pointer; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 120; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.toast {
  min-width: 240px; max-width: 420px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: slide .2s ease;
}
@keyframes slide { from { opacity: 0; transform: translateX(16px); } }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

/* ---------- 登录页 ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% 8%, var(--brand-soft), transparent 60%),
    radial-gradient(700px 480px at 88% 92%, var(--brand-soft), transparent 62%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  padding: 34px 30px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-card .logo {
  width: 50px; height: 50px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 15px; font-size: 24px; color: var(--brand-text);
  background: var(--brand-grad);
}
.auth-card h1 { margin: 0 0 6px; font-size: 20px; text-align: center; }
.auth-card .sub { margin: 0 0 22px; font-size: 13px; color: var(--text-mute); text-align: center; }

/* 左右分栏：左侧品牌区 + 右侧表单。窄屏时品牌区收起，退回单卡片。 */
.auth-split {
  width: 100%; max-width: 940px;
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.auth-brand {
  position: relative;
  padding: 44px 40px;
  color: #fff;
  /* 由浅到深：logo 在浅的一端（字号大、无所谓），正文落在深的一端保证对比度。
     不要拿 --brand-soft 当渐变端点 —— 它是半透明色，压在白底上会把整块冲淡，
     白字就糊了（试过，13px 的正文直接看不清）。 */
  background: linear-gradient(155deg, #0e7490, #0b4a5c);
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(420px 260px at 85% 15%, rgba(255,255,255,.14), transparent 70%);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .logo {
  width: 46px; height: 46px; margin: 0 0 20px;
  display: grid; place-items: center;
  border-radius: 14px; font-size: 22px; font-weight: 700;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
}
.auth-brand h1 { margin: 0 0 10px; font-size: 24px; }
.auth-brand p { margin: 0 0 22px; font-size: 13.5px; line-height: 1.7; opacity: .9; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.auth-points li {
  position: relative; padding-left: 22px;
  font-size: 13px; opacity: .95;
}
.auth-points li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  font-size: 12px; opacity: .85;
}
.auth-panel { display: grid; place-items: center; padding: 34px 30px; }
.auth-panel .auth-card {
  width: 100%; max-width: 380px;
  padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent;
}
.auth-panel .auth-card .logo { display: none; }

.auth-title { margin: 0 0 6px; font-size: 20px; text-align: center; }
.auth-alt {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px;
}
.auth-alt a { color: var(--brand); text-decoration: none; font-weight: 600; }
.auth-alt a:hover { text-decoration: underline; }
.auth-done { text-align: center; padding: 12px 0; }
.auth-done .big {
  width: 54px; height: 54px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 26px; color: var(--brand-text);
  background: var(--brand-grad);
}
.auth-done h2 { margin: 0 0 8px; font-size: 18px; }
.auth-done p { margin: 0 0 20px; }
.field.ok > div, .field.ok { color: var(--ok, #2f855a); font-size: 12.5px; }

/* 窄屏：分栏塌成上下两段，品牌区收成一条窄头图（保留 logo，砍掉卖点列表） */
@media (max-width: 760px) {
  .auth-split { grid-template-columns: 1fr; max-width: 420px; }
  .auth-brand { padding: 24px 26px; }
  .auth-brand .logo { margin-bottom: 12px; }
  .auth-brand h1 { font-size: 19px; margin-bottom: 6px; }
  .auth-brand p { margin: 0; font-size: 12.5px; }
  .auth-points { display: none; }
  .auth-panel { padding: 24px 22px 28px; }
}

/* ---------- 日志 / 追踪 ---------- */

.log-list { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; line-height: 1.65; }
.log-line { display: flex; gap: 10px; padding: 3px 18px; border-bottom: 1px solid var(--border); }
.log-line:hover { background: var(--surface-2); }
.log-line .t { color: var(--text-mute); flex: 0 0 76px; }
.log-line .lv { flex: 0 0 62px; font-weight: 600; }
.log-line .tag { flex: 0 0 120px; color: var(--brand); background: none; padding: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line .msg { flex: 1; white-space: pre-wrap; word-break: break-word; color: var(--text-dim); }
.lv-DEBUG { color: var(--text-mute); }
.lv-INFO { color: var(--info); }
.lv-SUCCESS { color: var(--ok); }
.lv-WARNING { color: var(--warn); }
.lv-ERROR, .lv-CRITICAL { color: var(--danger); }

/* ---------- 聊天 ---------- */

.chat-layout { display: flex; height: 100%; min-height: 0; }
.chat-side {
  width: 232px; flex: 0 0 232px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
}
.chat-side .side-head { padding: 12px; border-bottom: 1px solid var(--border); }
.chat-sessions { flex: 1; overflow-y: auto; padding: 8px; }
.sess {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 3px;
  border-radius: 9px; cursor: pointer; font-size: 13px;
  color: var(--text-dim);
}
.sess:hover { background: var(--surface-hover); }
.sess.active { background: var(--brand-soft); color: var(--text); font-weight: 600; }
.sess .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .del { opacity: 0; font-size: 14px; color: var(--text-mute); }
.sess:hover .del { opacity: 1; }
.sess .del:hover { color: var(--danger); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px 20px; }
.msg { display: flex; margin-bottom: 14px; }
.msg.user { justify-content: flex-end; }
/* 机器人消息有两块内容（身份头 + 气泡）。默认的 flex row 会把它们并排放，
   气泡被挤成"每行两个字"。必须改成纵向堆叠。 */
.msg.bot { flex-direction: column; align-items: flex-start; }
.msg.bot > div:last-child { max-width: 100%; }
/* 宽度上限挂在 .msg 的**直接子元素**上，而不是 .bubble 上。
   .msg 的宽度是确定的（整行），百分比能正常解析；而 .bubble 的包裹层
   （那个 position:relative 的 div，用来放「复制」按钮）是按内容收缩的，
   百分比参照它就成了循环依赖 —— 浏览器只能按百分比把气泡压扁，
   表现就是中文每行只放得下两个字。 */
.msg > div { max-width: min(660px, 78%); }
.bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px; line-height: 1.65;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--border);
}
.msg.user .bubble { background: var(--brand-grad); color: var(--brand-text); border-color: transparent; }

/* 表情图：贴在文字里时跟行高走，别把行撑开；不加边框 —— 它是"贴纸"不是内容图。
   单独发一条时气泡里只有它，`display:block` 之下会自然居中偏左，看着像一张贴纸。 */
.emoji-img {
  width: 88px; height: 88px;
  object-fit: contain;
  vertical-align: middle;
  border: 0;
  border-radius: 6px;
}
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre {
  margin: 8px 0; padding: 10px 12px;
  background: var(--bg); border-radius: 9px; overflow-x: auto;
  border: 1px solid var(--border);
}
.msg.user .bubble pre { background: color-mix(in srgb, currentColor 14%, transparent); border-color: transparent; }
.bubble code { background: var(--surface-hover); padding: 1px 5px; border-radius: 5px; }
.bubble pre code { background: none; padding: 0; }
/* 复制按钮：绝对定位在气泡内侧右上角，悬停消息时浮现（JS 里它是 .bubble 的兄弟节点） */
.msg > div[style*="position:relative"] { position: relative; }
.msg .copy {
  position: absolute; top: 5px; right: 9px; z-index: 2;
  padding: 1px 6px; border-radius: 6px;
  font-size: 11px; cursor: pointer; color: var(--text-mute);
  background: var(--surface-hover);
  opacity: 0; transition: opacity .15s;
}
.msg.bot:hover .copy { opacity: 1; }
.msg .copy:hover { color: var(--brand); }

/* ---- 消息级操作（FR-CH-04）：复制/引用/编辑/重新生成/删除 ---- */
.msg { position: relative; }
.msg .acts {
  position: absolute; top: 4px; right: 6px; z-index: 2;
  display: flex; gap: 4px; opacity: 0; transition: opacity .15s;
}
.msg:hover .acts, .msg .acts:focus-within { opacity: 1; }
/* 操作条里的按钮改成静态排布 —— 上面那条 .msg .copy 是绝对定位的单按钮老样式 */
.msg .acts .copy { position: static; top: auto; right: auto; opacity: 1; }
.msg .acts .copy.danger:hover { color: var(--danger); }
/* 触屏没有 hover：常驻显示，否则手机上永远点不到 */
@media (hover: none) {
  .msg .acts { opacity: 1; }
}

/* 引用块与"已编辑"标记 */
.bubble .quote {
  display: flex; gap: 6px; align-items: baseline;
  padding: 5px 9px; margin-bottom: 7px;
  border-left: 3px solid var(--brand); border-radius: 4px;
  background: var(--surface-hover); font-size: 12px; cursor: pointer;
}
/* 引用条用 currentColor 的透明度：气泡文字在深色主题里是深色、浅色主题里是白色，
   写死白色会在其中一套主题里消失 */
.msg.user .bubble .quote { background: color-mix(in srgb, currentColor 12%, transparent); border-left-color: color-mix(in srgb, currentColor 55%, transparent); }
.bubble .quote-who { color: var(--text-mute); flex: 0 0 auto; }
.msg.user .bubble .quote-who, .msg.user .bubble .quote-txt { color: color-mix(in srgb, currentColor 82%, transparent); }
.bubble .quote-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble .edited { font-size: 11px; color: var(--text-mute); margin-left: 6px; }
.msg.user .bubble .edited { color: color-mix(in srgb, currentColor 72%, transparent); }

/* 跳转到被引用的消息时闪一下，否则用户不知道跳到哪了 */
.msg.flash .bubble { box-shadow: 0 0 0 2px var(--brand); transition: box-shadow .2s; }

/* 引用栏（输入框上方） */
.reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin-bottom: 8px;
  border-left: 3px solid var(--brand); border-radius: 6px;
  background: var(--surface-hover); font-size: 12px;
}
.reply-bar .reply-body { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: baseline; }
.reply-bar .reply-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* @ 工作流提示 */
.mention-menu {
  max-height: 220px; overflow-y: auto; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.mention-item { padding: 7px 11px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.mention-item:hover { background: var(--surface-hover); }

/* 工作流调用状态条（FR-CH-15） */
.wf-status {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-hover); font-size: 12px;
}
/* 本轮用到的 Skill（FR-CH-09） */
.skill-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 12px; }

/* 会话重命名/归档（FR-CH-02） */
.sess .del { opacity: .55; }
.sess.archived { opacity: .6; }
.sess.archived .txt { text-decoration: line-through; }
.sess-archived-toggle {
  padding: 8px 10px; font-size: 12px; color: var(--text-mute);
  cursor: pointer; border-top: 1px solid var(--border);
}
.sess-archived-toggle:hover { color: var(--brand); }

.caret { display: inline-block; width: 7px; height: 14px; background: var(--brand); vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* 「正在思考」：等待首个 token 期间的状态，避免只看到一个空气泡 */
.thinking { color: var(--text-mute); font-size: 13px; display: inline-flex; align-items: center; gap: 3px; }
.thinking i {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; display: inline-block;
  animation: think-bounce 1.2s infinite ease-in-out;
}
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes think-bounce { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- 工作流画布 ---------- */

.canvas-wrap { display: flex; height: calc(100vh - 150px); min-height: 520px; }
.canvas-palette {
  width: 240px; flex: 0 0 240px; padding: 12px; overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg-elev);
}
.canvas-panel {
  width: 290px; flex: 0 0 290px; padding: 12px; overflow-y: auto;
  border-left: 1px solid var(--border); background: var(--bg-elev);
}
.pal-group { margin: 10px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute); }
.pal-item {
  padding: 6px 9px; margin-bottom: 3px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; font-size: 12.5px;
}
.pal-item:hover { background: var(--surface-hover); border-color: var(--border); }
.pal-list { max-height: none; }

.canvas-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.canvas-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg-elev);
}
.canvas-toolbar .spacer { flex: 1; }

.canvas-viewport {
  position: relative; flex: 1; overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab;
}
.canvas-viewport:active { cursor: grabbing; }

.canvas-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.canvas-wires { position: absolute; left: 0; top: 0; overflow: visible; width: 1px; height: 1px; pointer-events: none; }
.wire { fill: none; stroke: var(--brand); stroke-width: 2; pointer-events: stroke; cursor: pointer; }
.wire:hover { stroke: var(--danger); stroke-width: 3; }
.wire-temp { fill: none; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 5 4; }
.wire-temp.bad { stroke: var(--danger); }

.wf-node {
  position: absolute; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-sm); user-select: none; font-size: 12px;
}
.wf-node.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow-sm); }
.wf-node .hd {
  padding: 7px 9px; border-bottom: 1px solid var(--border);
  border-radius: 9px 9px 0 0; cursor: move;
  background: linear-gradient(180deg, var(--surface-2), transparent);
}
.wf-node .hd .nm { font-weight: 600; font-size: 12.5px; }
.wf-node .hd .tp { color: var(--text-mute); font-size: 11px; }
.wf-node .bd { padding: 4px 0; }
.wf-node .ports { display: flex; align-items: flex-start; }
.wf-node .side { flex: 1; min-width: 0; }
.wf-node .mid { width: 6px; }
.wf-node .prow { height: 22px; display: flex; align-items: center; }

.port { display: flex; align-items: center; gap: 5px; height: 22px; cursor: crosshair; max-width: 100%; }
.port.in { padding-left: 4px; }
.port.out { padding-right: 4px; flex-direction: row-reverse; }
.port .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px;
  background: var(--surface-2); border: 2px solid var(--brand);
}
.port.out .dot { background: var(--brand); }
.port:hover .dot { transform: scale(1.25); }
.port .plabel { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
  .canvas-wrap { flex-direction: column; height: auto; }
  .canvas-palette { width: auto; flex: none; max-height: 180px; border-right: none; border-bottom: 1px solid var(--border); }
  .canvas-panel { width: auto; flex: none; max-height: 260px; border-left: none; border-top: 1px solid var(--border); }
  .canvas-viewport { height: 460px; flex: none; }
}

/* 历史恢复时的骨架，避免内容跳动 */
.msg-skeleton { display: flex; margin-bottom: 14px; }
.msg-skeleton .bar {
  height: 42px; border-radius: 14px; background: var(--surface-2);
  animation: sk-pulse 1.4s ease-in-out infinite;
}
@keyframes sk-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* 附件相关 */
.attach-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); font-size: 12px; max-width: 240px;
}
.attach-chip img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.attach-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .rm { cursor: pointer; color: var(--text-mute); }
.attach-chip .rm:hover { color: var(--danger); }
.attach-chip.uploading { opacity: .6; }
.chat-drop-active { outline: 2px dashed var(--brand); outline-offset: -6px; }
.bubble .attach-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.bubble .attach-thumbs img { max-width: 180px; max-height: 180px; border-radius: 8px; cursor: zoom-in; display: block; }

.chat-input { border-top: 1px solid var(--border); padding: 12px 16px; }
.chat-input textarea { min-height: 46px; max-height: 180px; }
.chat-input .tip { margin-top: 6px; font-size: 11.5px; color: var(--text-mute); }
.chat-input .btn { min-width: 74px; height: 34px; }
.chat-input .stack { gap: 6px; }

/* ---------- 响应式 ---------- */

/* 会话列表的「抽屉」按钮：宽屏不显示，窄屏才出现（见下） */
.chat-head .side-toggle { display: none; }
/* 窄屏抽屉遮罩：定位放在基础规则里，只由媒体查询切换可见性 */
.chat-backdrop {
  display: none;
  position: absolute; inset: 0; z-index: 25;
  background: rgba(0, 0, 0, .35);
}

@media (max-width: 900px) {
  .sidebar { width: 60px; flex-basis: 60px; }
  .sidebar .brand span:not(.brand-mark), .nav-label, .nav-item > span:not(.ico) { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  /* 只收窄，绝不占满 —— 之前写成 flex-basis:100% 会把聊天主区压成 0 宽，
     中文于是逐字换行（用户看到的「单字竖排」）。 */
  .chat-side { width: 180px; flex-basis: 180px; }
}

@media (max-width: 640px) {
  /* 更窄时把会话列表改成浮层抽屉，主区独占整宽 */
  .chat-layout { position: relative; }
  .chat-side {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 30;
    width: 250px; flex-basis: 250px;
    transform: translateX(-101%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .chat-layout.show-side .chat-side { transform: translateX(0); }
  .chat-layout.show-side .chat-backdrop { display: block; }
  .chat-head .side-toggle { display: inline-flex; }
}

/* ==========================================================================
   多用户界面：身份、用户管理、只读聊天、细节打磨
   ========================================================================== */

/* ---------- 顶栏身份 ---------- */

.who {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  max-width: 220px;
}
.who-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.who-role { font-size: 10.5px; color: var(--text-mute); }
.who-avatar {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border);
}
.who-avatar.fallback {
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--brand-text);
  background: var(--brand-grad);
  border-color: transparent;
}

/* ---------- 小头像（用户列表 / 详情） ---------- */

.mini-avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border);
}
.mini-avatar.fallback {
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--brand-text);
  background: var(--brand-grad);
  border-color: transparent;
}
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-txt { display: flex; align-items: center; gap: 6px; min-width: 0; }

/* ---------- 详情页小件 ---------- */

.sec-title {
  margin: 0 0 12px; font-size: 12px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-mute);
}
.kv {
  display: flex; gap: 12px; padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { flex: 0 0 96px; color: var(--text-mute); }
.kv .v { color: var(--text); word-break: break-all; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }

/* ---------- 只读聊天记录（管理员查看用户会话） ---------- */

.readonly-chat { display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.ro-msg { display: flex; flex-direction: column; gap: 4px; max-width: 78%; }
.ro-msg.user { align-self: flex-end; align-items: flex-end; }
.ro-msg.bot { align-self: flex-start; }
.ro-role { font-size: 11px; color: var(--text-mute); }
.ro-bubble {
  padding: 9px 13px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.65; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.ro-msg.user .ro-bubble {
  background: var(--brand-grad);
  color: var(--brand-text); border-color: transparent;
}
.ro-text { white-space: pre-wrap; }

/* ---------- 细节打磨 ---------- */

/* 卡片：hover 时轻微抬升，提示"可点/可交互" */
.card { transition: box-shadow .18s ease, transform .18s ease; }
.stat { transition: transform .18s ease, border-color .18s ease; }
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }

/* 表格：斑马纹 + 行悬停 + 粘性表头 */
table.data thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.data tbody tr:hover { background: var(--surface-hover); }

/* 表单：统一焦点环，键盘可达 */
input, select, textarea { transition: border-color .15s, box-shadow .15s; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
/* 链接与按钮的键盘焦点 */
a:focus-visible, .btn:focus-visible, .nav-item:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px;
}

/* 空状态加一点存在感 */
.empty { padding: 40px 20px; text-align: center; color: var(--text-mute); }
.empty .big { font-size: 34px; opacity: .5; margin-bottom: 10px; }

/* 分区标题与列表项入场（克制：一次 160ms） */
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg, .ro-msg, .sess { animation: fadeUp .16s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 900px) {
  .who-txt { display: none; }
  .who { padding: 4px; }
}

/* ---------- 聊天：助手身份与消息头 ---------- */

.msg-head {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 5px; padding-left: 2px;
}
.msg-head .mini-avatar { width: 22px; height: 22px; flex: 0 0 22px; font-size: 11px; }
.msg-name { font-size: 12px; color: var(--text-mute); font-weight: 500; }
.chat-head select { max-width: 170px; }

/* 只读字段要有明确的视觉区分，否则用户会一直点它想改 */
input:disabled, input[readonly], textarea[readonly] {
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: not-allowed;
}
textarea[readonly] { opacity: .92; }
.sess .badge { flex: 0 0 auto; }

/* ---------- 角色共享对话框 ---------- */

.share-list {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 6px;
}
.share-user {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 8px;
  font-size: 13px; cursor: pointer;
}
.share-user:hover { background: var(--surface-hover); }
.share-user.granted { cursor: default; opacity: .85; }
.share-user .share-name { font-weight: 500; }
.share-user .spacer { flex: 1; }
.share-user input[type="checkbox"] { flex: 0 0 auto; }

/* ==========================================================================
   聊天界面打磨
   ========================================================================== */

/* ---------- 顶部工具条 ---------- */

.chat-head {
  background: var(--bg-elev);
  gap: 8px;
  min-height: 52px;
}
.chat-head .chat-title {
  font-weight: 600; font-size: 14px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 选择器统一收敛成"胶囊"样式，别让原生下拉那么抢眼 */
.chat-head select {
  height: 30px; padding: 0 8px;
  font-size: 12.5px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.chat-head select:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- 消息区 ---------- */

.chat-msgs { padding: 20px 24px; }
.msg { margin-bottom: 16px; }
.bubble { border-radius: 16px; box-shadow: var(--shadow-sm); }
.msg.bot .bubble { background: var(--surface); }
/* 用户气泡右下角收一点，形成"从右边发出"的指向感 */
.msg.user .bubble { border-bottom-right-radius: 5px; box-shadow: none; }
.msg.bot .bubble { border-bottom-left-radius: 5px; }
.msg-head { margin-bottom: 6px; }
.msg-name { font-weight: 500; }

/* 时间戳（JS 可选注入），弱化显示 */
.msg-time { font-size: 10.5px; color: var(--text-mute); margin-left: 6px; }

/* ---------- 输入区 ---------- */

.chat-input {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.chat-input .row { gap: 10px; }
.chat-input textarea {
  min-height: 40px; max-height: 180px;
  padding: 10px 13px;
  border-radius: 12px;
  line-height: 1.55;
  resize: none;
}
.chat-input .btn { min-width: 78px; height: 40px; border-radius: 11px; }
.chat-input .tip { margin-top: 7px; font-size: 11.5px; color: var(--text-mute); }

/* 附件按钮做成方块，和发送按钮对齐 */
.chat-input .attach-btn {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; padding: 0;
}

/* ---------- 会话列表 ---------- */

.chat-sessions { padding: 10px; }
.sess {
  padding: 9px 11px; margin-bottom: 4px;
  border-radius: 10px;
  transition: background .15s, color .15s;
}
.sess.active {
  background: var(--brand-soft);
  box-shadow: inset 2px 0 0 var(--brand);
}

/* ---------- 只读/二次确认 ---------- */

.chat-backdrop { backdrop-filter: blur(1px); }

/* ---------- 可搜索下拉（app.js 的 searchSelect） ---------- */

.combo { position: relative; }
.combo > input { width: 100%; }
.combo.disabled > input { opacity: .6; cursor: not-allowed; }
.combo-panel {
  display: none;
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 100%; max-height: 280px; overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.combo.open .combo-panel { display: block; }
.combo-group {
  padding: 7px 8px 3px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-mute);
}
.combo-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 7px;
  font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.combo-item.active { background: var(--surface-hover); }
.combo-item.selected { color: var(--brand); font-weight: 600; }
.combo-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.combo-hint { flex: 0 0 auto; }
.combo-empty { padding: 8px; }
.badge.cap { padding: 0 5px; font-size: 11px; }

/* ==========================================================================
   移动端 / 触摸适配
   - 断点沿用既有约定：760 = 分栏塌陷（同 .auth-split），640 = 手机（同聊天抽屉）
   - 触摸能力用 @media (hover: none) 判定，不按宽度猜设备
   - 一条硬规矩：凡是要在断点下改变的值，都必须来自类，不能留在行内 style ——
     媒体查询命中不了行内 style（唯一的例外是 flex-basis 能盖掉行内 width）
   ========================================================================== */

/* ---------- 视口高度与基础 ---------- */

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

/* 复制按钮的定位基准。原来是 `.msg > div[style*="position:relative"]` 这种依赖 JS
   行内字符串的属性选择器，改个行内写法就静默失效，换成显式类名。 */
.msg-body { position: relative; }

/* 模型/角色选择器：宽屏是一组紧凑的胶囊，窄屏整组换行（见下面的 640 媒体查询）。
   min-width:0 不能省：`.chat-pickers` 在窄屏是 flex-basis:100% 的弹性项，它的
   `min-width:auto` 会解析成内容最小宽度（实测 398px，比 390 的视口还宽）→ 横向溢出。 */
.chat-pickers { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* 桌面宽度。这两个值原来写在 chat.js 的行内 style 上（170/180px），
   而行内值同样会参与上面的 min-content 计算，所以一并收编到这里。
   注：原本那个 180px 一直被 `.chat-head select{max-width:170px}` 压成 170，此处照实写 170。 */
.chat-pickers .sel-model, .chat-pickers .sel-prompt { width: 170px; flex: 0 0 auto; }

/* ---------- 角色页左右分栏 ---------- */
/* 这几个值原来写在 roles.js 的行内 style 上，媒体查询打不到，收编成类 */
.roles-split { display: flex; gap: 16px; align-items: flex-start; }
.roles-list { width: 260px; flex: 0 0 260px; max-height: 60vh; overflow-y: auto; }
.roles-editor { flex: 1; min-width: 0; }
.roles-editor textarea.code { min-height: 380px; }
.roles-back { display: none; }

@media (max-width: 760px) {
  /* 复制按钮：从「浮在气泡右上角、压住第一行正文」改成「气泡下方右对齐」 */
  .msg .copy {
    position: static; display: block; width: fit-content;
    margin: 4px 0 0 auto; padding: 2px 0; background: transparent;
  }

  /* 标题栏按钮多时换行，别被 nowrap 的按钮/徽标撑破 */
  .card-head { flex-wrap: wrap; row-gap: 8px; }

  /* 弹窗按可视高度居中：软键盘弹起时底部按钮不会被盖住 */
  .modal-mask { bottom: auto; height: var(--app-h, 100vh); }
  .toast-wrap { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); align-items: stretch; }
  .toast { min-width: 0; max-width: none; }

  /* 角色页：列表 ⇄ 编辑器 主从切换（class 由 roles.js 切；宽屏下这些规则不生效） */
  .roles-split { display: block; }
  .roles-list { width: auto; flex: none; max-height: none; overflow: visible; }
  .roles-split .roles-editor { display: none; }
  .roles-split.show-editor .roles-list { display: none; }
  .roles-split.show-editor .roles-editor { display: block; }
  .roles-editor textarea.code { min-height: 240px; }
  .roles-back { display: inline-flex; }
}

@media (max-width: 640px) {
  .content { padding: 12px; }

  /* 聊天顶栏折成两行：① ☰会话 / 标题 / 管理   ② 模型 + 角色 各占一半。
     order:10 必须给 —— 否则「管理」按钮会被挤到第三行，头部从两行变三行。 */
  .chat-head { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px; }
  .chat-head .chat-title { max-width: 32vw; }
  .chat-pickers { flex: 1 1 100%; order: 10; min-width: 0; }
  /* flex-basis:0 + min-width:0 才能让 select 缩到比最长 option 还窄 ——
     否则长模型名会把整个页面撑出横向滚动。选择器要写成两个类（0-2-0），
     才盖得过上面那条 `.chat-pickers .sel-model` 的宽度。 */
  .chat-pickers .sel-model, .chat-pickers .sel-prompt {
    width: auto; flex: 1 1 0; min-width: 0; max-width: none;
  }

  .chat-msgs { padding: 12px; }
  .msg > div { max-width: 90%; }
  .chat-input { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  /* 窄屏放不下「📎 + 输入框 + 发送」一行，按钮会换行 —— 既然换行了就占满整行，
     否则留一个半宽按钮悬在左边更难看，顺带把点击区做到最大 */
  .chat-input .stack { flex: 1 1 100%; }
  .chat-input .stack .btn { width: 100%; }
  .chat-input .tip { display: none; }        /* 「Shift+Enter / 拖入」在手机上是误导 */
  .chat-input textarea { max-height: 120px; }
  .hide-sm { display: none; }

  /* iOS 聚焦字号 < 16px 的输入框会自动放大整页。选择器要写到与被覆盖规则同级
     或更高特异性（现有规则是 `.chat-head select`（0-1-1）这种）。 */
  input[type=text], input[type=password], input[type=number], input[type=email],
  select, textarea,
  .chat-head select, .chat-input textarea, .roles-editor textarea.code { font-size: 16px; }
  .chat-head select { height: 34px; }

  /* 触摸目标放大一档 */
  .btn { padding: 9px 15px; }
  .btn.sm { padding: 6px 11px; }
}

/* ---------- 触摸设备：没有 hover，就不能「悬停才出现」 ---------- */
/* 修的是两个真问题：手机上一个会话都删不掉（✕ 永远 opacity:0）、消息复制按钮点不到 */
@media (hover: none), (hover: on-demand) {
  .sess .del, .msg .copy { opacity: 1; }
  .sess .del {
    width: 32px; height: 32px; flex: 0 0 32px;
    display: grid; place-items: center;
    margin: -6px -6px -6px 0; border-radius: 8px;
  }
  /* 用按压反馈替代悬停反馈 */
  .sess:active, .nav-item:active, .tab:active, .share-user:active { background: var(--surface-hover); }
  .btn, .sess, .nav-item, .tab { touch-action: manipulation; }
}

/* ============ 工作项看板（PRD FR-WK-04） ============ */
.board {
  display: flex; gap: 12px; padding: 14px 16px;
  overflow-x: auto; align-items: flex-start;
}
.board-col {
  flex: 1 1 0; min-width: 200px;
  background: var(--surface-hover); border-radius: 10px; padding: 8px;
}
.board-col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 10px; font-size: 13px;
}
.board-col-body { display: flex; flex-direction: column; gap: 8px; }
.board-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; cursor: pointer; font-size: 13px;
}
.board-card:hover { border-color: var(--brand); }

/* 窄屏：看板竖排，横向滚动在手机上很难用 */
@media (max-width: 700px) {
  .board { flex-direction: column; overflow-x: visible; }
  .board-col { width: 100%; }
}

/* ==========================================================================
   视觉与动效
   --------------------------------------------------------------------------
   一条纪律：**动效只用来表达状态变化**（出现了、被选中了、正在处理），
   不用来"显得活泼"。所以这里的动画都很短（.12~.34s）、幅度很小（2~6px），
   并且统一受 `prefers-reduced-motion` 管辖 —— 前庭敏感的用户关掉系统动效之后，
   这里不该还有东西在晃。
   ========================================================================== */

@keyframes fadeUp   { from { opacity: 0; transform: translateY(6px); }  to { opacity: 1; transform: none; } }
@keyframes fadeIn   { from { opacity: 0; }                                to { opacity: 1; } }
@keyframes popIn    { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideInR { from { opacity: 0; transform: translateX(14px); }   to { opacity: 1; transform: none; } }
@keyframes shimmer  { from { background-position: -200% 0; }              to { background-position: 200% 0; } }
@keyframes bounce   { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes blink    { 50% { opacity: 0; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulseRing{ 0% { box-shadow: 0 0 0 0 var(--brand-glow); } 100% { box-shadow: 0 0 0 8px transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 组件动效 ---------- */

.card {
  border-radius: var(--r);
  animation: fadeUp var(--dur-slow) var(--ease) both;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* 同一屏里多张卡片时错开一点点，看起来是"依次落位"而不是"整块闪一下"。
   只排前 6 张 —— 再多就会被感知成"页面加载很慢"。 */
.card:nth-of-type(2) { animation-delay: .03s; }
.card:nth-of-type(3) { animation-delay: .06s; }
.card:nth-of-type(4) { animation-delay: .09s; }
.card:nth-of-type(5) { animation-delay: .12s; }
.card:nth-of-type(6) { animation-delay: .15s; }

/* 卡片悬停只提边框、不提阴影：整屏卡片一起浮起来会像页面在抖 */
.card:hover { border-color: var(--border-strong); }

.btn {
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--brand-grad);
  border-color: transparent;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 18px var(--brand-glow); }

/* 键盘焦点环：`:focus-visible` 而不是 `:focus` —— 鼠标点一下也画出蓝框很吵 */
.btn:focus-visible, .nav-item:focus-visible, .tab:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.nav-item { border-radius: var(--r-sm); }
.nav-item.active { position: relative; }
/* 选中项左侧的一条细高光：比整块变色克制，也比加粗字重更省地方 */
.nav-item.active::before {
  content: ""; position: absolute; left: -6px; top: 50%;
  width: 3px; height: 16px; margin-top: -8px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
}
.nav-item .ico { display: grid; place-items: center; }
.nav-item .ico svg { width: 16px; height: 16px; }

.brand-mark {
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  box-shadow: 0 3px 10px var(--brand-glow);
}

.tab { border-radius: var(--r-sm) var(--r-sm) 0 0; transition: color var(--dur) var(--ease); }
.tab::after { transition: transform var(--dur) var(--ease); }

.badge { border-radius: var(--r-full); }
.stat .value { font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.meter > i, .meter > div { transition: width var(--dur-slow) var(--ease); }

/* 图标统一在方块里居中。竖排文字基线对齐对 SVG 不生效，居中会歪半像素。 */
.stat-ico, .ico, .icon-btn {
  display: inline-grid; place-items: center;
  vertical-align: -2px;
}
.stat-ico { color: var(--brand); margin-right: 2px; }
.stat .label .stat-ico { opacity: .9; }

/* 表格：表头吸顶 + 行悬停。长表格滚动时不知道自己在哪一列，是很常见的体验问题。 */
.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  backdrop-filter: var(--blur);
}
.data tbody tr { transition: background var(--dur-fast) var(--ease); }
.data tbody tr:hover { background: var(--surface-hover); }

.modal { animation: popIn var(--dur) var(--ease-spring) both; border-radius: var(--r-lg); }
.modal-mask { animation: fadeIn var(--dur) var(--ease) both; backdrop-filter: var(--blur); }
.toast { animation: slideInR var(--dur) var(--ease-spring) both; border-radius: var(--r-sm); }

input, select, textarea { border-radius: var(--r-sm); transition: border-color var(--dur) var(--ease); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--border-strong); }

/* 加载态统一成流光条：静态骨架屏容易被误认成"加载完了但是空的" */
.msg-skeleton .bar, .skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.spin { animation: spin .9s linear infinite; display: inline-block; }

/* ---------- 聊天界面（重点） ----------
   聊天页和其他页不一样：它是**长时间停留**的界面，所以这里的手感比别处更值得抠 ——
   气泡的圆角、头像的克制、消息之间该松还是该紧，看久了差别很明显。 */

.chat-main { background: var(--bg); }
.chat-head {
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
}
.chat-side { background: var(--bg-elev); border-right: 1px solid var(--border); }
/* 左右留白比别处宽一点：气泡贴着边缘看久了很累，而且圆角会被视口切掉半个 */
.chat-msgs { padding: 20px 26px; scroll-behavior: smooth; scroll-padding-bottom: 20px; }

/* 消息进入：轻微上浮。幅度刻意只有 4px —— 大位移在长列表里滚动时很晕。 */
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg { animation: msgIn var(--dur) var(--ease) both; }

/* 连续同一个人的消息收紧间距：整段对话读起来是一个"话轮"而不是一堆碎片。
   头像只在该轮第一条出现（JS 侧没区分，所以这里用相邻选择器把重复的藏起来） */
.msg.bot + .msg.bot .msg-head { display: none; }
.msg.bot + .msg.bot { margin-top: -6px; }
.msg.user + .msg.user { margin-top: -6px; }

.bubble {
  border-radius: var(--r) var(--r) var(--r) 4px;
  line-height: 1.62;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.msg.bot .bubble { background: var(--surface-2); border: 1px solid var(--border); }
.msg.bot:hover .bubble { border-color: var(--border-strong); }

/* 自己的消息：右下角收一个小角，方向感来自形状而不是颜色 */
.msg.user .bubble {
  border-radius: var(--r) var(--r) 4px var(--r);
  background: var(--brand-grad);
  box-shadow: 0 2px 10px var(--brand-glow);
}

.mini-avatar {
  box-shadow: 0 0 0 1px var(--border), 0 2px 6px rgba(0, 0, 0, .18);
  transition: transform var(--dur) var(--ease-spring);
}
.msg-head:hover .mini-avatar { transform: scale(1.08); }
.mini-avatar.fallback {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  font-weight: 600;
}

.msg-name { letter-spacing: .2px; }

/* 「正在思考」：三个点依次起伏。比转圈更能表达"在生成文字"这件事。
   老浏览器不认识 `:nth-child` 的 delay 也无所谓，静态三点同样能读懂。 */
.thinking { display: inline-flex; align-items: center; gap: 4px; color: var(--text-mute); font-size: 13px; }
.thinking i {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; display: inline-block;
  animation: bounce 1.25s var(--ease) infinite;
}
.thinking i:nth-child(2) { animation-delay: .16s; }
.thinking i:nth-child(3) { animation-delay: .32s; }

/* 流式输出的光标 */
.caret {
  display: inline-block; width: 2px; height: 1em; margin-left: 2px;
  vertical-align: text-bottom; border-radius: 1px;
  background: var(--brand); animation: blink 1s step-end infinite;
}

/* 输入区：聚焦时整块边框亮起来而不是只亮输入框 —— 这块区域是"会话的一部分" */
.chat-input {
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: var(--blur);
  border-top: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}
.chat-input:focus-within { border-top-color: var(--brand); }
.chat-input textarea {
  border-radius: var(--r);
  resize: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.chat-input textarea:focus { border-color: var(--brand); box-shadow: var(--ring); }
.chat-input .btn { border-radius: var(--r-full); min-width: 72px; }

.chat-backdrop { backdrop-filter: var(--blur); animation: fadeIn var(--dur) var(--ease) both; }
.chat-drop-active { border-radius: var(--r); animation: fadeIn var(--dur-fast) var(--ease) both; }
.bubble .attach-thumbs img { border-radius: var(--r-sm); transition: transform var(--dur) var(--ease-spring); }
.bubble .attach-thumbs img:hover { transform: scale(1.03); }

/* 会话列表项 */
.sess { border-radius: var(--r-sm); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.sess.active { background: var(--brand-soft); }
.sess.active::before { content: none; }

/* 空状态：给一个会呼吸的圆点，让"这里现在没东西"看起来是正常状态而不是加载失败 */
.empty .big { animation: pulseRing 2.4s var(--ease) infinite; border-radius: 50%; }

/* 顶部进度条：页面切换时的一条细线。比转圈不打扰，又不至于让人以为没反应。 */
.route-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--info));
  z-index: 9999; opacity: 0;
  /* 不吃点击：盖在页面顶部的一条细线不该拦截任何鼠标事件 */
  pointer-events: none;
  transition: width var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
}
.route-progress.on { opacity: 1; width: 70%; }
.route-progress.done { width: 100%; opacity: 0; }

/* 工作项看板卡片 */
.board-card { border-radius: var(--r-sm); transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.board-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.board-col { border-radius: var(--r); }

/* 插件市场的卡片 */
.plugin-card .card-body { padding: 14px 16px; }
.plugin-card { animation: fadeUp var(--dur-slow) var(--ease) both; }

.row.wrap { flex-wrap: wrap; }

/* ==========================================================================
   外观设置（设置页 → 外观）
   ========================================================================== */

.palette-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}
.palette-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.palette-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); }
/* 选中态用**边框 + 背景**而不是只换文字色：色块本身颜色各异，
   光靠文字变色，在一屏马卡龙里根本看不出哪个被选中了 */
.palette-chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--ring);
}
/* 色块画成"左深右浅"的小渐变，正好对应按钮和气泡的观感 */
.palette-dot {
  width: 18px; height: 18px; flex: 0 0 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .18);
}
.palette-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-check { color: var(--brand); font-weight: 700; }

/* 配色预览：两条气泡，用真实的 --brand-grad，所见即所得 */
.appearance-preview { margin-top: 14px; }
.appearance-preview-inner {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
}
.ap-bubble {
  max-width: 70%; padding: 8px 12px; font-size: 13px;
  border-radius: var(--r) var(--r) var(--r) 4px;
}
.ap-bubble.bot { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.ap-bubble.user {
  background: var(--brand-grad); color: var(--brand-text);
  border-radius: var(--r) var(--r) 4px var(--r);
  align-self: flex-end;
  box-shadow: 0 2px 10px var(--brand-glow);
}

/* 滑块行：标签固定宽度，滑块占满，数值右对齐 —— 三行对齐后一眼能横向比较 */
.slider-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.slider-row label { flex: 0 0 76px; font-size: 12.5px; color: var(--text-dim); }
.slider-row input[type="range"] { flex: 1; min-width: 120px; }
.slider-row > span:last-child { flex: 0 0 56px; text-align: right; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: var(--surface-hover);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface);
  cursor: pointer;
}
