/* SoulBox · 微信白（WeChat clean white）· 移动优先
   白色打底 + 灰白交接面（顶栏/次级面）+ 微信绿强调，清爽简洁 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* 全局 button/控件常被设了 display，必须保证 hidden 属性始终隐藏 */
[hidden] { display: none !important; }

:root {
  --bg: #ffffff;          /* 页面打底：纯白（微信会话页那种白） */
  --card: #ffffff;        /* 卡面白（靠边框与阴影分层） */
  --panel: #f7f7f7;       /* 次级面：灰一点的白色（交接处） */
  --border: #e5e5e5;      /* 中性浅灰描边 */
  --border-strong: #d4d4d4;
  --text: #1a1a1a;        /* 中性近黑 */
  --muted: #8a8a8a;       /* 中性灰 */
  --faint: #b8b8b8;       /* 极浅元信息 */
  --accent: #1677ff;      /* 清爽蓝（唯一强调色） */
  --accent-dark: #0958d9;
  --accent-soft: #e8f1ff; /* 蓝淡染 */
  --ink: #1f1f1f;         /* 深色面板/深色按钮 */
  --danger: #e64340;      /* 微信红 */
  --danger-soft: #fdecec;
  --ok: #07c160;
  --ok-soft: #e8f7ee;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
}

html, body { height: 100%; }
html { overflow-x: hidden; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  font-size: 14px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
/* 暖色细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ============ 顶栏 ============ */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  background: rgba(247, 247, 247, 0.92);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
  position: sticky; top: 0;
}
.menu-btn {
  width: 38px; height: 38px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 4px;
  background: transparent; border: none; cursor: pointer;
  padding: 8px; border-radius: 10px;
  transition: background 0.15s;
}
.menu-btn:hover { background: var(--panel); }
.menu-btn span {
  display: block; width: 19px; height: 1.5px;
  background: var(--text); border-radius: 2px;
}
.brand { font-size: 16px; font-weight: 700; flex: 1; letter-spacing: 0.01em; }
.brand-en { font-size: 11px; font-weight: 600; color: var(--faint); margin-left: 4px; letter-spacing: 0.08em; text-transform: uppercase; }
.svc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.svc-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.svc-dot.bad { background: var(--danger); }

/* ============ 抽屉 ============ */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 288px; max-width: 86vw;
  background: var(--card);
  z-index: 50;
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
}
.drawer.open { transform: translateX(0); }
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.drawer-user {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 22px 18px 16px;
  border: none; border-bottom: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.drawer-user:hover { background: var(--panel); }
.avatar {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.uname { font-size: 15px; font-weight: 700; color: var(--text); }
.umeta { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: "SF Mono", ui-monospace, Consolas, monospace; }
.drawer-user-info { flex: 1; min-width: 0; }
.drawer-user-edit {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--panel);
  position: relative;
  flex-shrink: 0;
}
.drawer-user-edit::after {
  content: "✎";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted);
}
.drawer-user:hover .drawer-user-edit::after { color: var(--accent); }
.drawer-nav { flex: 1; padding: 12px 12px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.drawer-nav a {
  position: relative;
  display: flex; align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.drawer-nav a:hover { background: var(--panel); color: var(--text); }
.drawer-nav a.active { background: transparent; color: var(--text); font-weight: 700; }
/* 选中：陶土竖条从行首探出，不用整块填色 */
.drawer-nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 20px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.drawer-nav a .ic { width: 18px; height: 18px; margin-right: 12px; flex-shrink: 0; opacity: 0.7; }
.drawer-nav a:hover .ic, .drawer-nav a.active .ic { opacity: 1; }
.drawer-nav a.active .ic { color: var(--accent); }
.drawer-foot {
  padding: 12px 18px;
  font-size: 11px; color: var(--faint);
  border-top: 1px solid var(--border);
}

/* ============ 视图 ============ */
.view-main { flex: 1; overflow-y: auto; padding: 22px; -webkit-overflow-scrolling: touch; }
.view { max-width: 1080px; margin: 0 auto; min-width: 0; }
.view h2 { font-size: 15px; margin-bottom: 8px; }
.view h3 { font-size: 13px; margin: 10px 0 6px; }
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 22px; font-weight: 700; margin-bottom: 3px; letter-spacing: -0.02em; }

/* ============ 通用组件 ============ */
@media (max-width: 760px) {
  .view-main { padding: 14px; }
}

/* 内联 SVG 图标 */
.ic { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }
.ic-18 { width: 18px; height: 18px; vertical-align: -4px; }
.ic-20 { width: 20px; height: 20px; vertical-align: -5px; }
h2 .ic, h3 .ic, h4 .ic { width: 17px; height: 17px; margin-right: 7px; color: var(--accent); vertical-align: -3.5px; }
button .ic, .btn-like .ic { width: 14px; height: 14px; }

.card-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

input, select, textarea {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button, .btn-like {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btn-like:hover { border-color: var(--text); color: var(--text); background: var(--panel); }
button:active, .btn-like:active { transform: scale(0.97); }
button.primary, .btn-like.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: none;
}
button.primary:hover, .btn-like.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--panel); }
button.danger { background: transparent; border-color: var(--border-strong); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
button.big { padding: 12px 22px; font-size: 15px; border-radius: 12px; }
button.small-btn, .btn-like.small-btn { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 120px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.muted { color: var(--muted); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; font-weight: normal; }
.guide { font-size: 13px; line-height: 2; padding-left: 18px; }
.guide a { color: var(--accent); }
.status { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; min-height: 16px; }
.status.ok { color: var(--ok); }
.chip {
  font-size: 11px; padding: 2px 10px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap; font-weight: 500;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: #c3dccb; }
.small-out {
  font-size: 12px; color: var(--text);
  background: var(--panel); padding: 10px;
  border-radius: var(--radius-sm); overflow: auto;
  max-height: 170px; white-space: pre-wrap; word-break: break-word;
  margin-top: 8px; min-width: 0;
  font-family: "SF Mono", ui-monospace, Consolas, monospace;
}
.small-out.tall { max-height: 420px; line-height: 1.65; }
.qr-box {
  background: #fff; color: #000;
  padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-family: Consolas, monospace;
  font-size: 10px; line-height: 1.05;
  overflow: auto; max-height: 340px; margin-bottom: 10px;
}
.qr-img {
  margin: 4px 0 8px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: fit-content;
}
.qr-img img { display: block; width: min(240px, 100%); height: auto; image-rendering: pixelated; }
.qr-link { display: block; font-size: 12px; color: var(--accent); margin-bottom: 10px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.cap-checks { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.cap-checks label { display: flex; align-items: center; gap: 5px; color: var(--text); cursor: pointer; }

/* toast */
.toast {
  z-index: 300;
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #ffffff;
  padding: 10px 18px; border-radius: 12px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100; max-width: 86vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ============ 首页 ============ */
.home-hero {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--ink);
  border-radius: 22px;
  padding: 30px 30px;
  margin-bottom: 16px;
  color: #ffffff;
  overflow: hidden;
}
/* 纸纹脉络：极淡斜向条纹，替代廉价渐变 */
.home-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(189, 92, 57, 0.28), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 9px);
}
.home-hero-main { position: relative; z-index: 1; }
.home-hero-hi { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.home-hero-sub { font-size: 13px; margin-top: 8px; color: #b8b09f; font-family: "SF Mono", ui-monospace, Consolas, monospace; letter-spacing: 0; }
.home-hero-avatar {
  position: relative; z-index: 1;
  width: 60px; height: 60px;
  border-radius: 18px;
  background: rgba(243, 229, 221, 0.12);
  border: 1px solid rgba(243, 229, 221, 0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 25px; font-weight: 800; color: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
}
.home-hero-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 560px) {
  .home-hero { padding: 22px; }
  .home-hero-hi { font-size: 20px; }
}
.home-notice-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.home-notice-head h3 { margin: 0; flex: 1; }
.home-notice-body { font-size: 13.5px; line-height: 1.75; margin-top: 8px; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.home-notice-body.muted { font-size: 13px; color: var(--muted); }
.home-quick {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 760px) { .home-quick { grid-template-columns: repeat(3, 1fr); } }
.quick-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 6px 13px;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.14s, box-shadow 0.2s;
}
.quick-item .ic { width: 20px; height: 20px; color: var(--accent); opacity: 0.9; }
.quick-item:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow); }
.quick-item:active { transform: scale(0.97); }
.home-cards-head { display: flex; align-items: center; justify-content: space-between; }
.home-cards-head h3 { margin: 0; flex: 1; }
.home-cards-head a { color: var(--accent); font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.mini-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}
.mini-card:hover { border-color: var(--border-strong); background: var(--card); }
.mini-card:active { transform: scale(0.97); }
.mini-avatar {
  width: 52px; height: 52px;
  margin: 0 auto 8px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-name { font-size: 13.5px; font-weight: 700; }
.home-empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 30px 0 20px;
  color: var(--muted);
  font-size: 13px;
}
.home-empty .ic { width: 30px; height: 30px; opacity: 0.4; }

/* ============ 卡库布局 ============ */
.cards-layout { display: grid; grid-template-columns: 250px 1fr; gap: 12px; align-items: start; }
@media (max-width: 860px) { .cards-layout { grid-template-columns: 1fr; } }
.cards-side {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  position: sticky; top: 64px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
@media (max-width: 860px) {
  .cards-side { position: static; max-height: 38vh; }
}
.cards-side h2 { font-size: 12.5px; color: var(--muted); margin: 12px 0 8px; font-weight: 600; }
.side-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card-list { list-style: none; }
.card-list li {
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--card);
}
.card-list li:hover { border-color: var(--accent); }
.card-list li.active { border-color: var(--accent); background: var(--accent-soft); }
.card-list .name { font-size: 13.5px; font-weight: 600; }
.cards-editor { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.editor-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.editor-head h2 { font-size: 14.5px; margin: 0; }
.editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card-form-area { min-width: 0; }

/* ============ 卡库（RP-Hub 式头像网格） ============ */
.lib-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lib-actions input[type="text"], .lib-actions input:not([type]) { width: 200px; }
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.char-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.2s;
}
.char-card:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow); }
.char-card:active { transform: scale(0.97); }
.char-card-img {
  aspect-ratio: 2 / 2.6;
  background: var(--panel);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.char-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char-card-ph { font-size: 44px; font-weight: 800; color: var(--border-strong); }
.char-card-info { padding: 11px 13px; }
.char-card-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-head { margin-bottom: 10px; }

/* ============ 卡片表单 ============ */
.cf-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.cf-section h3 { font-size: 13.5px; margin: 0 0 10px; }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 8px; }
.cf-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .cf-grid2 { grid-template-columns: 1fr; } }
.cf-avatar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cf-avatar {
  width: 64px; height: 64px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.cf-avatar-row input { max-width: 240px; }
/* 做卡页：封面大图 + 名称/简介（首位显眼） */
.cf-hero {
  display: flex; gap: 20px; align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.cf-cover { flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.cf-cover-frame {
  width: 172px; height: 172px;
  border-radius: 20px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
}
.cf-cover-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cf-cover-empty { color: var(--faint); font-size: 13px; }
.cf-cover-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.cf-hero-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 560px) {
  .cf-hero { flex-direction: column; align-items: center; }
  .cf-hero-info { width: 100%; }
}
/* AI 生成草稿区块（做卡页） */
.ai-draft-box {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.ai-draft-head {
  font-size: 17px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  color: var(--accent);
}
.ai-draft-box .hint { margin-bottom: 10px; }
/* AI 草稿的模型选择行（做卡页） */
.ai-draft-model { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ai-draft-model label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.ai-draft-model select { width: auto; min-width: 120px; }
#ai-idea { width: 100%; }
.ai-draft-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
#btn-ai-draft { flex-shrink: 0; }
#ai-msg.status { min-height: 20px; }
/* 正则行：与世界书条目同款折叠 */
.rx-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--card);
  overflow: hidden;
}
.rx-summary { display: flex; gap: 9px; align-items: center; padding: 11px 13px; }
.rx-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rx-summary-meta { font-size: 11.5px; color: var(--faint); font-family: "SF Mono", ui-monospace, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-detail { border-top: 1px solid var(--border); padding: 13px; display: flex; flex-direction: column; gap: 10px; }
.wb-entry {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--card);
  overflow: hidden;
}
.wb-summary {
  display: flex; gap: 9px; align-items: center;
  padding: 11px 13px;
}
.wb-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wb-summary-meta { font-size: 11px; color: var(--accent-dark); background: var(--accent-soft); padding: 2px 9px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; }
/* 重描写专属条目：与常驻/关键词条目区分开，一眼看出它只在重描写风格下生效 */
.wb-summary-meta.rich-only { color: #5b4b8a; background: #ece7f7; }
/* 世界书「模板 + 添加」一行 */
.wb-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wb-add-row select { flex: 1; min-width: 160px; max-width: 260px; }
#cf-book-hint { margin-bottom: 10px; }
.wb-spacer-flex { flex: 1; min-width: 8px; }
.wb-enable { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.wb-edit, .rx-edit { padding: 4px 11px; flex-shrink: 0; }
/* 展开态：整条微微抬起，摘要行成为标题栏 */
.wb-entry.open, .rx-row.open { border-color: var(--border-strong); box-shadow: var(--shadow); }
.wb-entry.open .wb-summary, .rx-row.open .rx-summary { background: var(--panel); }
/* 展开后底部的 保存/取消 */
.wb-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

/* 折叠区块（正则等次要配置） */
.cf-fold summary {
  cursor: pointer; font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  list-style: none;
}
.cf-fold summary::-webkit-details-marker { display: none; }
.cf-fold summary::before { content: "▸"; color: var(--faint); font-size: 11px; }
.cf-fold[open] summary::before { content: "▾"; color: var(--accent); }
.cf-fold summary .hint { font-weight: 400; }
.cf-fold[open] > *:not(summary) { margin-top: 12px; }
/* 简介/开场白自动撑高，不出现内滚动条 */
.cf-autogrow { overflow: hidden; line-height: 1.75; }
.wb-detail {
  border-top: 1px dashed var(--border);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
/* hidden 折叠：类里的 display:flex 会盖过浏览器给 [hidden] 的 display:none，必须显式压回去 */
.wb-detail[hidden], .rx-detail[hidden] { display: none; }
.wb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wb-grid3 { grid-template-columns: 1fr 1fr 1fr; }
.wb-field { display: flex; flex-direction: column; gap: 4px; }
.wb-field label { font-size: 12px; color: var(--muted); }
.wb-adv-row { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.wb-adv-row label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.create-actions {
  display: flex; gap: 10px; justify-content: center;
  position: sticky; bottom: 12px; flex-wrap: wrap;
}

/* ============ 提供商 ============ */
.prov-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.prov-item.default { border-color: var(--border-strong); background: var(--card); position: relative; }
.prov-item.default::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.prov-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.prov-head b { font-size: 14.5px; }
/* 提供商头像：知名厂商=品牌色淡底 + 官方 logo；自定义=名字首字（中性色） */
.prov-avatar {
  width: 34px; height: 34px; border-radius: 9px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--muted);
  font-size: 15px; font-weight: 700;
}
.prov-avatar svg { width: 19px; height: 19px; }
.prov-avatar-text { background: var(--panel); color: var(--muted); }
/* 官方站头像：站点 logo 图片铺满圆角方块 */
.prov-avatar-img { background: #fff; overflow: hidden; border: 1px solid var(--border); }
.prov-avatar-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prov-item.disabled .prov-avatar { opacity: 0.6; }
.prov-btns { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.model-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.model-chip {
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 6px 13px;
  font-size: 12.5px; color: var(--muted);
  cursor: pointer; font-family: "SF Mono", ui-monospace, Consolas, monospace;
  transition: all 0.15s;
}
.model-chip:hover { border-color: var(--accent); color: var(--accent); }
.model-chip.on {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark);
  font-weight: 600;
}

/* TTS 通道行的「使用」圆圈开关：亮=使用中，不亮=未用（最右小圆点，不用文字） */
.tts-use-btn {
  width: 20px; height: 20px;
  border: 2px solid var(--border-strong);
  background: transparent; border-radius: 50%;
  cursor: pointer; padding: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}
.tts-use-btn:hover { border-color: var(--accent); }
.tts-use-btn.on {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.prov-item.on { border-color: var(--accent); }
.prov-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 音色 combo：输入框 + 右侧箭头 + 弹出官方列表 */
.tts-combo { position: relative; display: flex; align-items: center; }
.tts-combo input { flex: 1; min-width: 0; }
.tts-combo-btn {
  border: 1px solid var(--border-strong);
  border-left: none; background: var(--panel);
  color: var(--muted); cursor: pointer;
  padding: 0 10px; font-size: 12px;
  border-radius: 0 8px 8px 0; height: 38px;
}
.tts-combo-btn:hover { color: var(--accent); border-color: var(--accent); }
.tts-combo-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 8px; max-height: 220px; overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.tts-combo-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 12px; font-size: 12.5px;
  background: none; border: none; cursor: pointer;
  color: var(--text);
}
.tts-combo-item:hover { background: var(--accent-soft); color: var(--accent-dark); }
.tts-combo-empty { padding: 10px 12px; font-size: 12px; color: var(--muted); }

/* ============ 聊天 ============ */
.chat-test {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow);
}
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-head h3 { font-size: 13.5px; margin: 0; }
.chat-opts {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px;
  padding: 9px;
  background: var(--bg);
  border-radius: 10px;
}
.opt-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.opt-group label { display: flex; align-items: center; gap: 4px; color: var(--text); cursor: pointer; font-size: 12.5px; }
.opt-group select { padding: 3px 8px; font-size: 12.5px; width: auto; }
.chat-log {
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 7px;
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  min-height: 110px; max-height: 260px;
}
.bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.me { align-self: flex-end; background: var(--ink); color: #ffffff; }
.bubble.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--border); }
.bubble { position: relative; }
.tts-speak-btn {
  position: absolute; top: -8px; right: -8px;
  width: 24px; height: 24px; padding: 0;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); font-size: 12px; line-height: 1;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow); opacity: 0.8;
}
.bubble.bot:hover .tts-speak-btn { display: flex; }
.tts-speak-btn:hover { opacity: 1; }
.approve-row { display: flex; gap: 8px; align-self: flex-start; }
#btn-work-mode.active { background: var(--ink); border-color: var(--ink); color: #ffffff; }

/* ===== 记忆管理行 ===== */
.mem-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); border-radius: 8px; }
.mem-row:last-child { border-bottom: none; }
/* 关键记忆分区：红色卡片，醒目、方便查看 */
.mem-key-section { margin-bottom: 12px; border: 1px solid var(--danger); border-radius: 10px; overflow: hidden; background: var(--danger-soft); }
.mem-sec-head { display: flex; align-items: center; gap: 7px; padding: 8px 12px; background: var(--danger); color: #fff; font-weight: 700; font-size: 13px; }
.mem-sec-icon { display: inline-flex; align-items: center; }
.mem-key-section .mem-row { background: transparent; border-left: none; border-radius: 0; }
.mem-key-section .mem-row .mem-fact { color: #b02e2b; }
/* 关键记忆：整行高亮 + 左侧色条，一眼可辨（用于搜索命中时的普通列表） */
.mem-row.mem-key-row { background: var(--danger-soft); border-left: 3px solid var(--danger); }
.mem-row.mem-key-row .mem-fact { font-weight: 600; color: #b02e2b; }
.mem-badge { font-size: 11px; padding: 2px 9px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; flex-shrink: 0; font-weight: 600; }
.mem-badge.mem-key { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 700; }
.mem-badge.mem-ns { background: #e8eef7; color: #4a6a9a; border-color: #c9d8ee; font-weight: 500; }
.mem-kw { color: var(--accent-dark); font-size: 12px; font-weight: 500; }
.mem-fact { flex: 1; font-size: 13px; line-height: 1.5; word-break: break-word; min-width: 0; }
.mem-meta { font-size: 11px; color: var(--faint); white-space: nowrap; flex-shrink: 0; font-family: "SF Mono", ui-monospace, Consolas, monospace; }
.mem-ops { display: flex; gap: 5px; flex-shrink: 0; }
.mem-edit input.mem-edit-fact { flex: 1; min-width: 120px; }
.mem-edit input.mem-edit-kw { flex-shrink: 0; }
.mem-key-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; cursor: pointer; }
.mem-key-label.on { color: var(--danger); font-weight: 600; }

/* ===== 椭圆形开关（关键记忆 / 通用小开关） ===== */
.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: 0.18s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.18s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .slider { background: var(--danger); }
.switch input:checked + .slider::before { transform: translateX(14px); }
.mem-edit .switch .slider { background: var(--border-strong); }
.mem-edit .switch input:checked + .slider { background: var(--danger); }

/* ===== 生图配置页 / 图片展示 ===== */
.img-provider-row { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
.radio { display: flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; margin-top: 4px; }
.ig-pane { border: 1px dashed var(--border); border-radius: 10px; padding: 12px; margin-top: 6px; }
.ig-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ig-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.ig-item img { width: 100%; height: 140px; object-fit: cover; cursor: zoom-in; display: block; }
.ig-item-meta { font-size: 11px; color: var(--muted); padding: 6px 8px; word-break: break-all; line-height: 1.4; }
.ig-item .danger { width: 100%; border-radius: 0; border-top: 1px solid var(--border); }
.chat-img {
  display: block; max-width: 100%; max-height: 300px; margin: 8px 0 2px;
  border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in;
}
.lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.82);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 20px;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 6px 30px rgba(0,0,0,.5); }

/* ============ 卡片机器人入口 + 配置弹窗 ============ */
.char-card-img { position: relative; }
.char-card-bot {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.96); border: 1px solid var(--border-strong);
  font-size: 16px; line-height: 1; padding: 0;
  box-shadow: var(--shadow);
  opacity: 0; transition: opacity 0.15s, transform 0.15s;
}
.char-card:hover .char-card-bot { opacity: 1; }
.char-card-bot.on { opacity: 1; border-color: var(--ok); }
.char-card-bot:hover { transform: scale(1.12); }
.bot-tag { color: var(--ok); font-weight: 600; }

/* 卡片右下角操作（导出 PNG / JSON / 删除），悬停浮现 */
.char-card-ops {
  position: absolute; bottom: 8px; right: 8px;
  display: flex; gap: 5px;
  opacity: 0; transition: opacity 0.15s;
}
.char-card:hover .char-card-ops { opacity: 1; }
.cc-op {
  width: 28px; height: 28px; padding: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.cc-op .ic { width: 14px; height: 14px; }
.cc-op:hover { background: var(--card); border-color: var(--text); transform: translateY(-1px); }
.cc-op.cc-del { color: var(--danger); }
.cc-op.cc-del:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.bot-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.bot-dialog {
  background: var(--card); border-radius: 20px;
  width: min(560px, 94vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  border: 1px solid var(--border);
  padding: 20px 22px;
}
.bot-dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.bot-dialog-head h3 { margin: 0; font-size: 16px; }

/* 图片裁切弹窗（1:1 方格） */
.crop-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.crop-dialog {
  background: var(--card); border-radius: 20px;
  width: min(380px, 94vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  border: 1px solid var(--border);
  padding: 18px 20px;
}
.crop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 700; font-size: 15px; }
.crop-stage {
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: 14px; overflow: hidden;
  background: #111;
  touch-action: none;
}
.crop-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.crop-controls { margin-top: 14px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.crop-controls input[type="range"] { flex: 1; accent-color: var(--accent); }
.crop-dialog .hint { margin-top: 8px; font-size: 12px; }
.crop-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.bot-form { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bot-form label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bot-form select, .bot-form input {
  flex: 1; padding: 8px 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; font-size: 13px; background: var(--card);
}
.bot-detail { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--panel); }
.bot-detail-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.bot-detail-row > span:first-child { width: 76px; color: var(--muted); flex: none; }
.bot-detail-row code { background: var(--accent-soft); color: var(--accent-dark); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.ok-badge { color: var(--ok); font-weight: 600; font-size: 12px; }
.warn-badge { color: var(--accent); font-weight: 600; font-size: 12px; }
.bot-login-area { margin-top: 10px; }

/* ============ 高级配置弹窗（编辑卡右上角入口） ============ */
.adv-dialog { width: min(640px, 94vw); }
.adv-sec { border-top: 1px solid var(--border); padding: 12px 0 4px; margin-top: 8px; }
.adv-sec h4 { margin: 0 0 8px; font-size: 13.5px; }
.adv-abilities { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.adv-switch {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px;
}
.adv-switch:hover { border-color: var(--accent); }
.adv-switch input { margin-top: 2px; }
.adv-switch span { display: flex; flex-direction: column; gap: 2px; }
.adv-switch small { color: var(--muted); font-size: 11.5px; }

/* 高级配置：能力开关做成高亮按钮（点一下切换，不用勾选框） */
.cap-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.cap-toggle {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.cap-toggle:hover { border-color: var(--text); color: var(--text); background: var(--panel); }
.cap-toggle.on {
  background: var(--ink); border-color: var(--ink); color: #ffffff;
}
.cap-toggle.on:hover { background: #333333; border-color: #333333; color: #fff; }

/* 高级配置里的紧凑表单栅格 */
.adv-grid2, .adv-grid3 { display: grid; gap: 10px; }
.adv-grid2 { grid-template-columns: 1fr 1fr; }
.adv-grid3 { grid-template-columns: 110px 1fr 1fr; }
.adv-grid2 > label, .adv-grid3 > label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px; color: var(--muted); font-weight: 500;
}
@media (max-width: 560px) {
  .adv-grid2, .adv-grid3 { grid-template-columns: 1fr; }
}
/* 高级配置底部按钮：一行并排、等宽（手机上也不上下堆叠，省纵向空间） */
.adv-foot { display: flex; gap: 10px; margin-top: 10px; }
.adv-foot button { flex: 1; }
/* 机器人区块自带的「连接 / 创建」行在高级配置里不显示：
   底部统一有一个同款按钮，这个只作为逻辑入口被程序点击 */
.adv-dialog .bot-create-row { display: none; }

/* ============ 用户资料 / 公告编辑弹窗 ============ */
.profile-dialog { width: min(460px, 94vw); }
.profile-body { display: flex; flex-direction: column; gap: 8px; }
.profile-body label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.profile-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.profile-avatar-row > div:last-child { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 圆形图标按钮里的 SVG */
.char-card-bot .ic { width: 17px; height: 17px; color: var(--text); }
.char-card-bot.on .ic { color: var(--ok); }
.tts-speak-btn .ic { width: 14px; height: 14px; }

/* ================= MCP 表单化配置 ================= */
.mcp-list { display: flex; flex-direction: column; gap: 8px; }
.mcp-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.mcp-enable { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; cursor: pointer; }
.mcp-type { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-dark); white-space: nowrap; }
.mcp-sum { flex: 1; min-width: 120px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcp-tools { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.mcp-form { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-top: 10px; background: var(--panel); }
.mcp-form h4 { margin: 0 0 8px; font-size: 13.5px; }
.mcp-form .form { margin: 0; }
.mcp-tool { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; padding: 3px 0; }
.mcp-tool small { display: block; color: var(--muted); font-weight: 400; }
.mcp-tools-head { font-size: 12.5px; font-weight: 600; display: block; margin-top: 8px; }
.mcp-json { margin-top: 12px; }
.mcp-json summary { cursor: pointer; font-size: 12.5px; color: var(--accent); }

/* 工作区概览 */
.ws-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 12.5px; }
.ws-row code { font-size: 12px; }
.ws-meta { color: var(--muted); font-size: 11.5px; }

/* 预设库页 */
.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset-item { border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; background: var(--panel); }
.preset-item-head { display: flex; align-items: center; gap: 8px; }
.preset-badge { font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.preset-badge.builtin { background: var(--accent-soft); color: var(--accent-dark); }
.preset-badge.custom { background: var(--ok-soft); color: var(--ok); }
.preset-preview { margin: 8px 0 0; white-space: pre-wrap; font-size: 12px; color: var(--muted); max-height: 90px; overflow: hidden; line-height: 1.6; }

/* ============ 插件商店 ============ */
.plug-tabs { display: flex; gap: 6px; margin: 4px 0 10px; flex-wrap: wrap; }
.plug-tab {
  padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 20px;
  background: var(--card); cursor: pointer; font-size: 13px; color: var(--muted);
}
.plug-tab.on { background: var(--ink); border-color: var(--ink); color: #ffffff; font-weight: 600; }
.plug-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.plug-cat {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 14px;
  background: transparent; cursor: pointer; font-size: 12px; color: var(--muted);
}
.plug-cat.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }
.plug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.plug-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.plug-card-top { display: flex; gap: 12px; }
.plug-emoji { font-size: 30px; line-height: 1; }
.plug-main { flex: 1; min-width: 0; }
.plug-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plug-desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.plug-meta { color: var(--faint); font-size: 11.5px; margin-top: 5px; }
.plug-badge { font-size: 11px; background: var(--accent-soft); color: var(--accent-dark); padding: 1px 8px; border-radius: 10px; }
.plug-price { font-size: 13px; color: var(--accent); font-weight: 700; }
.plug-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 表情包库（全局共享） ---------- */
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.emoji-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card);
  padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center;
}
.emoji-item img { width: 72px; height: 72px; object-fit: contain; }
.emoji-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.emoji-exp { color: var(--muted); font-size: 11.5px; line-height: 1.4; min-height: 2.8em; }
.emoji-item .row { gap: 6px; justify-content: center; }
/* 表情分组标签栏 */
.emoji-groups { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
/* 设置页：长条按键列表（点击展开对应面板） */
.setting-rows { display: flex; flex-direction: column; gap: 8px; }
.setting-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); padding: 14px 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--text); text-decoration: none; /* <a> 链接重置：去掉默认蓝色/下划线 */
}
.setting-row:hover { border-color: var(--accent); }
.setting-row:hover .sr-title { color: var(--accent); }
/* 设置子页返回按钮（<a> 链接，需重置默认蓝色/下划线） */
.btn-back {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text); text-decoration: none;
  font-size: 12.5px; margin-top: 6px; opacity: .7; cursor: pointer;
  transition: opacity .15s;
}
.btn-back:hover { opacity: 1; color: var(--accent); }
.btn-back svg { transform: rotate(180deg); width: 13px; height: 13px; }
.setting-row .sr-icon { font-size: 18px; opacity: .8; flex-shrink: 0; }
.setting-row .sr-body { flex: 1; min-width: 0; }
.setting-row .sr-title { font-weight: 600; font-size: 14px; }
.setting-row .sr-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.setting-row .sr-chevron { opacity: .4; transition: transform .15s; }
.setting-row.open .sr-chevron { transform: rotate(90deg); }
.setting-panel { display: none; margin-top: 8px; }
.setting-panel.open { display: block; }
.setting-panel .card-box { margin: 0; }
.emoji-group-tab {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.emoji-group-tab:hover { border-color: var(--accent); }
.emoji-group-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.emoji-group-tab .g-count { font-size: 11px; opacity: .7; }
.emoji-group-tab .g-del, .emoji-group-tab .g-rename { opacity: .55; font-size: 12px; padding: 0 2px; }
.emoji-group-tab .g-del:hover, .emoji-group-tab .g-rename:hover { opacity: 1; color: var(--danger, #e05); }
.emoji-group-add { border: 1px dashed var(--border); background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.emoji-group-add:hover { border-color: var(--accent); color: var(--accent); }
/* 聊天气泡里的表情图：QQ/微信 正常表情大小（此前 44px 太小，用户点名） */
.chat-emoji { max-width: 110px; max-height: 110px; vertical-align: middle; margin: 0 2px; border-radius: 6px; }
/* 独立成气泡的表情（一条就是一个表情）再大一档 */
.lc-root .bubble:has(> img.chat-emoji:only-child) .chat-emoji { max-width: 140px; max-height: 140px; }

/* ============ 通道页：机器人连接区 ============ */
.conn-sub { font-size: 12.5px; font-weight: 700; color: #6a7186; margin: 10px 0 6px; }
.conn-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px;
  background: var(--card);
}
.conn-card { font-weight: 600; font-size: 13px; }

/* ================= 技能库（设置页） ================= */
.skill-list { display: flex; flex-direction: column; gap: 8px; }
.skill-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.skill-name { font-weight: 600; font-size: 13px; white-space: nowrap; }
.skill-tag { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.skill-enable { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.skill-prompt { flex: 1; min-width: 120px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= 本地聊天（整页聊天视图） ================= */
/* 结构：顶栏固定 + 消息区独立滚动 + 底部输入浮岛。整体撑满可视高度，页面自身不滚动 */
.lc-root {
  position: relative;
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  max-width: 900px; margin: 0 auto;
}
/* 聊天视图下让容器铺满，避免出现双滚动条 */
.view-main.lc-host { padding: 0; overflow: hidden; }

/* ---- 顶栏 ---- */
.lc-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}
.lc-who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.lc-avatar {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; overflow: hidden; flex-shrink: 0;
  border: 1px solid var(--border);
}
.lc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lc-who-text { min-width: 0; }
.lc-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lc-top-actions button.reset { color: var(--danger); }
.lc-top-actions button.reset:hover { background: var(--danger-soft); border-color: var(--danger); }
.lc-card-sel { max-width: 150px; font-size: 12.5px; padding: 5px 8px; }
@media (max-width: 600px) {
  .lc-card-sel { max-width: 96px; }
  .lc-top-actions button { padding: 5px 8px; font-size: 11.5px; }
}

/* ---- 消息区 ---- */
.lc-log {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.lc-log .bubble { max-width: 78%; }
@media (max-width: 600px) { .lc-log .bubble { max-width: 88%; } }

/* ---- 底部输入浮岛 ---- */
.lc-dock { flex-shrink: 0; padding: 8px 14px 14px; }
.lc-island {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 18px;
  padding: 8px 10px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
/* 工具行：联网 / 思考深度 / 模型 */
.lc-tools { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.lc-tools-gap { flex: 1; }
.lc-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.lc-chip:hover { border-color: var(--accent); color: var(--accent); }
.lc-chip .ic { width: 13px; height: 13px; }
.lc-chip input[type="checkbox"] { margin: 0; }
/* 联网搜索开启态 */
.lc-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* 带下拉的 chip：把原生 select 融进胶囊里 */
.lc-chip-sel select {
  border: none; background: transparent; padding: 0; margin: 0;
  font-size: 12px; color: inherit; cursor: pointer;
  max-width: 120px;
}
.lc-chip-sel select:focus { outline: none; box-shadow: none; }
.lc-model-chip select { max-width: 190px; }
@media (max-width: 600px) { .lc-model-chip select { max-width: 130px; } }

/* 输入行：自适应高度 textarea + 圆形发送键 */
.lc-input-row { display: flex; align-items: flex-end; gap: 8px; }
.lc-input-row textarea {
  flex: 1; min-width: 0;
  min-height: 42px; max-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  font-size: 13.5px; line-height: 1.5;
  resize: none; overflow-y: auto;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.lc-input-row textarea:focus { border-color: var(--accent); background: var(--card); outline: none; }
.lc-send {
  flex-shrink: 0;
  width: 42px; height: 42px; padding: 0;
  border-radius: 14px;
  background: var(--ink); color: #ffffff;
  border: none;
  display: flex; align-items: center; justify-content: center;
}
.lc-send:hover { background: var(--accent); color: #fff; }
.lc-send:disabled { opacity: 0.45; }
.lc-send .ic { width: 17px; height: 17px; }

/* 本地聊天：纯图标开关（高亮=开启，无文字） */
.lc-icon-btn {
  width: 30px; height: 30px; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lc-icon-btn .ic { width: 15px; height: 15px; }
.lc-icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.lc-icon-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.lc-icon-btn.on:hover { background: var(--accent-dark); color: #fff; }

/* TTS 朗读中：按钮常显并高亮，提示"再点一次停止" */
.tts-speak-btn.playing { display: flex !important; color: var(--accent); background: var(--accent-soft); }

/* 提供商：已停用的条目整体压暗 */
.prov-item.disabled { opacity: 0.55; }
.prov-item.disabled .prov-head b { text-decoration: line-through; }

/* 记忆页：卡片列表上方的分组标题 */
.mem-cards-head { font-size: 12.5px; color: var(--muted); margin: 0 0 6px 2px; }

/* ============ 群聊对话记忆（记忆页底部）============ */
/* 记忆页 单聊 / 群聊 切换 */
.mem-tabs { display: flex; gap: 8px; margin: 10px 0 8px; }
.mem-tab {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.mem-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mem-group-section { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel); }
.mem-group-section .hint { margin: 4px 0 10px; }
.mem-group-list { display: flex; flex-direction: column; gap: 8px; }
.mem-group-item { display: flex; align-items: center; gap: 8px; }
.mem-group-box {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card);
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.mem-group-box:hover { border-color: var(--accent); background: var(--accent-soft); }
.mem-group-name { font-weight: 700; font-size: 13.5px; }
.mem-group-meta { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) {
  .mem-group-box { flex-wrap: wrap; row-gap: 2px; }
}

/* ---------- 运行日志面板 ---------- */
.log-toolbar { gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.log-row {
  display: grid; grid-template-columns: 62px 72px 1fr; gap: 8px;
  padding: 4px 6px; border-bottom: 1px solid var(--border);
  font-size: 12px; line-height: 1.5; align-items: baseline;
}
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--faint); font-variant-numeric: tabular-nums; }
.log-tag { color: var(--muted); }
.log-msg { word-break: break-word; }
.log-err { background: var(--danger-soft); }
.log-err .log-msg { color: var(--danger); }
.log-warn .log-msg { color: var(--accent-dark); }
.log-detail { grid-column: 1 / -1; margin: 2px 0 2px 70px; }
.log-detail summary { cursor: pointer; color: var(--muted); font-size: 11.5px; }
.log-detail pre {
  white-space: pre-wrap; word-break: break-all; margin: 4px 0 0;
  padding: 6px 8px; background: var(--panel); border-radius: var(--radius-sm);
  font-size: 11.5px; color: var(--muted);
}

/* ---------- 画师串列表 ---------- */
.artist-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--border);
}
.artist-item:last-child { border-bottom: 0; }
.artist-main { flex: 1; min-width: 0; }
.artist-name { font-weight: 600; font-size: 13px; }
/* 一行一个：只显示名称，点名称=选用（高亮=生效中），右侧只有 编辑 / 删除 */
.artist-item .artist-name-btn {
  flex: 1; min-width: 0; text-align: left;
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
/* 内置默认串的编辑键：变灰禁用（用户点名：看得见但调不动） */
.artist-item .small-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
  color: var(--muted); border-style: dashed;
}
.artist-item .small-btn:disabled:hover { border-color: var(--border); background: var(--card); color: var(--muted); }
.artist-item .artist-name-btn:hover { border-color: var(--accent); color: var(--accent); }
/* 生效中的画师串整行高亮 */
.artist-item.on { background: var(--accent-soft); border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.artist-item.on .artist-name-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.artist-item.on .artist-name-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* 生图配置页的测试出图区：一整块图片展示位 */
.ig-aspect-row { flex-wrap: wrap; }
.ig-test-img {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 260px;
  border: 1px dashed var(--border); border-radius: 12px;
  background: var(--panel); padding: 12px;
}
.ig-test-pic {
  max-width: 100%; max-height: 70vh;
  border-radius: 10px; cursor: zoom-in; display: block;
}
.ig-test-meta { font-size: 12px; }
.artist-content {
  color: var(--muted); font-size: 12px; margin-top: 2px;
  /* 长画师串只显示一行，超出省略——不加这个会被逐字符折行糊成一列 */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conn-arrow { color: #9aa1b5; font-size: 13px; }

/* 换卡进行中：整行转圈态，不响应重绘 */
.conn-row.busy { opacity: 0.85; }
.conn-loading {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--accent); font-weight: 600;
}
.conn-loading::before {
  content: ""; width: 13px; height: 13px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: conn-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes conn-spin { to { transform: rotate(360deg); } }

/* 账号名、按钮、下拉不被打散：窄屏整组换行而不是按钮单独掉行 */
.conn-row > .chip, .conn-row > .small-btn, .conn-row > select { flex-shrink: 0; white-space: nowrap; }
.conn-row > select { max-width: 190px; min-width: 0; }

/* ===== 预设组卡（可点击的按钮式组卡；此前无样式渲染成裸文字） ===== */
.preset-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.preset-group-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
.preset-group-card:hover { border-color: var(--accent); }
.preset-group-card:active { transform: scale(0.97); }
.preset-group-name { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; }
.preset-group-meta { font-size: 12px; color: var(--muted); }

/* ===== 手机端/触屏适配（2026-09-06 专项） ===== */
/* 1) 无 hover 的触屏设备：悬停才出现的操作按钮常显 */
@media (hover: none) {
  .char-card-ops, .char-card-bot { opacity: 1; }
  .bubble.bot .tts-speak-btn { display: flex; }
}

/* 危险操作确认弹窗（替代原生 confirm） */
.wb-confirm-ov {
  position: fixed; inset: 0; z-index: 320;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: wbcFade .14s ease;
}
@keyframes wbcFade { from { opacity: 0 } to { opacity: 1 } }
.wb-confirm {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(420px, 94vw);
  padding: 20px 22px 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  animation: wbcPop .16s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes wbcPop { from { transform: translateY(8px) scale(.97); opacity: .6 } to { transform: none; opacity: 1 } }
.wb-confirm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wb-confirm-head h3 { margin: 0; font-size: 16.5px; }
.wb-confirm-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-dark);
}
.wb-confirm.danger .wb-confirm-icon { background: var(--danger-soft); color: var(--danger); }
.wb-confirm-lead { margin: 0 0 10px; font-size: 13.5px; line-height: 1.7; color: var(--text); }
.wb-confirm-points {
  margin: 0 0 10px; padding: 10px 12px 10px 28px;
  background: var(--panel); border-radius: 10px;
  font-size: 12.5px; line-height: 1.85; color: var(--muted);
}
.wb-confirm-points li { margin: 0; }
.wb-confirm-note { margin: 0 0 14px; font-size: 12px; color: var(--danger); font-weight: 600; }
.wb-confirm-foot { display: flex; gap: 10px; }
.wb-confirm-foot button { flex: 1; }

/* 2) 工作台文件弹窗（此前 wb-modal 类缺失，弹窗以裸内容挂在页尾） */
.wb-modal-overlay {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.wb-modal {
  background: var(--card); border-radius: 20px;
  width: min(480px, 94vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  border: 1px solid var(--border);
  padding: 20px 22px;
}
.wb-modal h3 { margin: 0 0 10px; font-size: 16px; }
.wb-modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.wb-modal input, .wb-modal textarea { width: 100%; box-sizing: border-box; }

/* 3) 世界书/正则摘要行：窄屏标题独占一行、整行可换行，按钮不再被挤出 */
@media (max-width: 560px) {
  .wb-summary, .rx-summary { flex-wrap: wrap; row-gap: 6px; }
  .wb-title, .rx-title { flex-basis: 100%; white-space: normal; word-break: break-all; }
}

/* 4) 记忆行窄屏：事实独占一行，徽标/时间/按钮收进第一行 */
@media (max-width: 560px) {
  .mem-row { flex-wrap: wrap; row-gap: 4px; }
  .mem-row .mem-fact { flex-basis: 100%; order: 10; }
  .mem-row .mem-ops { order: 5; margin-left: auto; }
  .mem-edit { flex-wrap: wrap; row-gap: 6px; }
  .mem-edit input.mem-edit-fact { flex-basis: 100%; order: 10; }
  .mem-edit .mem-ops { order: 5; margin-left: auto; }
  .mem-edit input.mem-edit-kw { flex: 1; min-width: 0; max-width: none; }
  /* 预设条目行：名称独占一行，徽标/按钮换行排布 */
  .preset-item-head { flex-wrap: wrap; row-gap: 6px; }
  .preset-item-head > b { flex-basis: 100%; }
  /* 世界书表单三列塌单列 */
  .wb-grid3 { grid-template-columns: 1fr; }
  /* 输入控件 16px：防 iOS Safari 聚焦自动放大 */
  input, select, textarea { font-size: 16px; }
  /* 弹窗顶部对齐：软键盘弹出时内容不被顶出屏幕 */
  .bot-overlay, .wb-modal-overlay { align-items: flex-start; }
  .bot-overlay { padding-top: max(16px, env(safe-area-inset-top)); }
  .bot-dialog { max-height: 82vh; }
}

/* 5) 全面屏安全区（非全面屏 env()=0，无副作用） */
.lc-dock { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.create-actions { bottom: calc(12px + env(safe-area-inset-bottom)); }
.drawer-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

/* 6) 聊天顶栏窄屏：保持单行（菜单+头像+名字+圆点+按钮），名字自动收缩 */
@media (max-width: 600px) {
  .lc-top { flex-wrap: nowrap; }
  .lc-top .menu-btn { width: 32px; height: 32px; padding: 6px; }
  .lc-avatar { width: 32px; height: 32px; }
  .lc-top-actions button { padding: 5px 8px; font-size: 11.5px; }
  .lc-who { flex: 1; min-width: 0; }
  .lc-name { font-size: 13.5px; }
}

/* ===== 本地聊天气泡头像（卡面中心圆裁 / 用户头像） ===== */
.bubble-row { display: flex; gap: 8px; align-items: flex-start; }
.bubble-row.me { flex-direction: row-reverse; align-self: flex-end; }
.bubble-row.bot { align-self: flex-start; }
.bubble-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; object-position: center; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--border);
}
.bubble-row .bubble { max-width: min(78%, 560px); }
@media (max-width: 600px) { .bubble-row .bubble { max-width: 88%; } }

/* ===== 滑杆跟随标签（记忆/主动发消息） ===== */
.slider-wrap { position: relative; padding-top: 20px; }
.slider-val {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 12.5px; color: var(--accent-dark); white-space: nowrap;
}
.slider-wrap input[type="range"] { width: 100%; }

/* ===== 表情库紧凑格子 + 放大详情 ===== */
.emoji-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.emoji-item { padding: 6px 4px; gap: 4px; cursor: pointer; }
.emoji-item img { width: 56px; height: 56px; }
.emoji-item .emoji-name { font-size: 12px; }
.emoji-detail { max-width: 340px; text-align: center; }
.emoji-detail-img { max-width: 100%; max-height: 240px; object-fit: contain; border-radius: 12px; margin: 4px 0 8px; }
.emoji-detail-exp { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 10px; word-break: break-word; }

/* ===== 首页卡库速览：横排紧凑卡（头像左名字右，不再一圈空白） ===== */
#home-card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.home-card-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 7px 10px; cursor: pointer; min-width: 0;
  transition: border-color 0.15s;
}
.home-card-item:hover { border-color: var(--accent); }
.home-card-avatar {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  font-size: 15px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.home-card-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home-card-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 本地聊天 RP-Hub 式接管：隐藏 SoulBox 顶栏，对话占满整页 ===== */
body.lc-fullscreen .topbar { display: none; }
body.lc-fullscreen .lc-root { height: 100dvh; }
.lc-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: #fff; border: 1px solid var(--border-strong); margin-left: 2px;
}
.lc-dot.on { background: var(--ok); border-color: var(--ok); }
.lc-dot.err { background: var(--danger); border-color: var(--danger); }
/* 头像/名字不可点（卡片配置统一走右上角三个点 → 聊天设置） */
.lc-back-btn {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--lc-line, var(--border));
  background: var(--lc-field, var(--card));
  color: #444; border-radius: 9px;
  cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.lc-back-btn svg { width: 17px; height: 17px; }
.lc-back-btn:hover { background: #ececec; color: #111; }
.lc-who-text .lc-sub { display: none; }

/* 单行输入岛：搜索 / 思考深度 / 输入 / 发送（RP-Hub 式） */
/* 输入行：表情 / 输入 / 发送（高度比 RP-Hub 基准缩约 1/3） */
.lc-input-row { display: flex; align-items: flex-end; gap: 6px; }
.lc-input-row textarea {
  flex: 1; min-width: 0;
  min-height: 30px; max-height: 120px;
  border-radius: 14px; padding: 6px 12px;
  font-size: 13.5px; line-height: 1.45;
}
.lc-input-row .lc-icon-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}
.lc-input-row .lc-icon-btn:hover { color: var(--accent); }
.lc-send {
  width: 30px !important; height: 30px !important; border-radius: 11px !important;
}
.lc-send .ic { width: 13px !important; height: 13px !important; }

/* ===== 长按多选删除 ===== */
#chat-log.selecting .bubble-row[data-conv-id] { cursor: pointer; }
#chat-log.selecting .bubble-row[data-conv-id]::after {
  content: "✓"; font-size: 11px; align-self: center; flex-shrink: 0;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: transparent; border: 1px solid var(--border-strong);
}
#chat-log.selecting .bubble-row.me[data-conv-id]::after { order: 10; }
.bubble-row.sel { outline: 2px solid var(--danger); border-radius: 12px; }
.bubble-row.sel::after { background: var(--danger) !important; color: #fff !important; border-color: var(--danger) !important; }
#wb-select-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 300;
  display: flex; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px 12px; box-shadow: var(--shadow); font-size: 13px;
}
#wb-select-bar #wb-select-count { margin-right: 4px; color: var(--muted); }

/* ===== 表情导入弹窗 ===== */
.emoji-pick { cursor: pointer; }
.emoji-pick.picked { outline: 2px solid var(--accent); border-radius: var(--radius-sm); }
.emoji-pick.picked::after { content: "✓"; }


/* ===== 输入岛上排按键（模型商/模型/思考深度，RP-Hub 式弹层） ===== */
.lc-tools-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; padding: 0 2px; }
.lc-pop-wrap { position: relative; }
.lc-pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 13px;
  background: var(--bg); color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer;
  max-width: 130px; white-space: nowrap;
}
.lc-pill:hover { border-color: var(--accent); color: var(--accent); }
.lc-pill-caret { font-size: 9px; color: var(--muted); }
.lc-pop {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 60;
  min-width: 150px; max-width: 240px; max-height: 260px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
  padding: 5px; display: flex; flex-direction: column; gap: 2px;
}
.lc-pop-right { left: auto; right: 0; }
.lc-pop-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 7px 10px; border: none; border-radius: 10px;
  background: transparent; color: var(--text);
  font-size: 12.5px; font-weight: 600; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lc-pop-item:hover { background: var(--bg); }
.lc-pop-item.on { background: var(--accent-soft); color: var(--accent-dark); }
.lc-pop-check { color: var(--accent); font-weight: 700; }
.lc-pop-empty { padding: 10px; font-size: 12px; color: var(--muted); text-align: center; }
/* hidden 属性必须压过 .lc-pop 的 display:flex（否则隐藏弹层照样渲染并挡住按键） */
.lc-pop[hidden] { display: none; }

/* 图片加载失败的灰色提示 */
.chat-img-fail {
  display: inline-block;
  color: var(--muted);
  font-size: 12.5px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

/* ================= 本地聊天：QQ / 微信 式灰白配色 =================
   只在 .lc-root 作用域内覆盖调色变量，其余页面仍是暖纸风。
   对齐微信：会话底 #ededed 灰、角色（对方）气泡纯白、自己的气泡绿色。 */
.lc-root {
  --lc-chat-bg: #ededed;      /* 会话背景灰（微信同款） */
  --lc-bubble-bot: #ffffff;   /* 角色气泡：纯白（用户点名要求） */
  --lc-bubble-me: #95ec69;    /* 自己的气泡：微信绿 */
  --lc-bubble-me-text: #10130f;
  --lc-bar: #f7f7f7;          /* 顶栏 / 输入区浅灰白 */
  --lc-line: #dedede;         /* 分隔线 */
  --lc-field: #ffffff;        /* 输入框白底 */
}
/* 顶栏与消息区：灰白分层 */
.lc-root .lc-top { background: var(--lc-bar); border-bottom-color: var(--lc-line); }
.lc-root .lc-log { background: var(--lc-chat-bg); }
/* 气泡：角色纯白 + 极淡描边；自己绿色。圆角比原来收一点，更接近 IM 观感 */
.lc-root .bubble { border-radius: 8px; padding: 9px 12px; box-shadow: none; }
.lc-root .bubble.bot {
  background: var(--lc-bubble-bot);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
}
.lc-root .bubble.me {
  background: var(--lc-bubble-me);
  border: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--lc-bubble-me-text);
}
/* 气泡小尖角（指向头像一侧），QQ/微信 观感的关键细节 */
.lc-root .bubble-row .bubble { position: relative; }
.lc-root .bubble-row.bot .bubble::before,
.lc-root .bubble-row.me .bubble::before {
  content: ""; position: absolute; top: 12px;
  border: 5px solid transparent;
}
.lc-root .bubble-row.bot .bubble::before {
  left: -10px; border-right-color: var(--lc-bubble-bot);
}
.lc-root .bubble-row.me .bubble::before {
  right: -10px; border-left-color: var(--lc-bubble-me);
}
/* 头像：IM 里是小圆角方形，不是圆形 */
.lc-root .bubble-avatar { border-radius: 6px; border-color: rgba(0, 0, 0, 0.06); }
/* 输入区：浅灰白底 + 白输入框（微信输入条观感） */
.lc-root .lc-dock { background: var(--lc-bar); border-top: 1px solid var(--lc-line); padding-top: 8px; }
.lc-root .lc-island { background: transparent; border: none; box-shadow: none; border-radius: 0; padding: 0 4px 4px; }
.lc-root .lc-input-row textarea {
  background: var(--lc-field);
  border: 1px solid var(--lc-line);
  color: #1a1a1a;
}
.lc-root .lc-input-row textarea:focus { background: var(--lc-field); border-color: #c8c8c8; }
/* 上排按键（模型商/模型/思考深度）跟着灰白走 */
.lc-root .lc-pill { background: var(--lc-field); border-color: var(--lc-line); }
/* 朗读按钮在白气泡上要有对比 */
.lc-root .tts-speak-btn { background: var(--lc-bubble-bot); border-color: var(--lc-line); }
/* 纯表情气泡：QQ/微信 里表情是裸图、没有气泡底和尖角 */
.lc-root .bubble:has(> img.chat-emoji:only-child) {
  background: transparent; border: none; padding: 0;
}
.lc-root .bubble:has(> img.chat-emoji:only-child)::before { display: none; }

/* 顶栏「更多」：三个点（对齐微信聊天页右上角） */
.lc-more-btn {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--lc-line, var(--border));
  background: var(--lc-field, var(--card));
  color: #444; border-radius: 9px;
  font-size: 19px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lc-more-btn:hover { background: #ececec; color: #111; }

/* 搜索命中定位：短暂高亮那一条消息 */
.bubble-row.hit-flash .bubble {
  outline: 2px solid var(--accent);
  animation: hitFlash 2.2s ease-out;
}
@keyframes hitFlash {
  0%, 30% { background: #d9f7e5; }
  100% { background: inherit; }
}

/* 时间戳分隔条（微信式：相邻消息隔久了显示时间） */
.lc-time-sep {
  align-self: center;
  font-size: 11px;
  color: #808080;
  text-align: center;
  margin: 10px 0 2px;
  user-select: none;
}
.lc-log .lc-time-sep:first-child { margin-top: 4px; }

/* ================= 通讯录（微信式会话列表） =================
   一条 = 一个人：头像靠左固定尺寸，右侧上行名字+时间、下行最后一句预览。 */
.chat-search-wrap { padding: 0 0 10px; }
.chat-search-wrap input {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
}
.chat-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; min-width: 0;
  transition: background 0.12s;
}
.chat-item:last-child { border-bottom: none; }
.chat-item:hover { background: var(--panel); }
.chat-item.pinned { background: #f7f7f7; }
.chat-item.pinned:hover { background: var(--panel); }
/* 头像：只在最左边占一个合适的大小（微信是 48px 小圆角方形） */
.chat-av {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700;
}
.chat-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.chat-line1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.chat-name {
  font-size: 15px; font-weight: 600; color: var(--text);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-time { font-size: 11.5px; color: var(--faint); flex-shrink: 0; }
.chat-line2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-preview {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-pin-flag {
  font-size: 10.5px; color: var(--accent); background: var(--accent-soft);
  padding: 1px 6px; border-radius: 20px; flex-shrink: 0;
}
@media (max-width: 600px) {
  .chat-av { width: 42px; height: 42px; }
  .chat-name { font-size: 14.5px; }
}

/* ================= 单卡聊天设置页 ================= */
.ci-head { display: flex; align-items: center; gap: 10px; }
.ci-head h2 { margin: 0; }
.ci-who { display: flex; align-items: center; gap: 12px; }
.ci-av {
  width: 54px; height: 54px; border-radius: 10px; overflow: hidden; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.ci-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ci-who-text { flex: 1; min-width: 0; }
.ci-name { font-size: 16px; font-weight: 700; }
.ci-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ci-row-label { font-size: 14px; font-weight: 600; }
.ci-danger { border-color: var(--danger); }
.ci-search-out { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.ci-hit {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 9px; border-radius: 8px; background: var(--panel);
  cursor: pointer; font-size: 12.5px;
}
.ci-hit:hover { background: var(--accent-soft); }
.ci-hit-who { flex-shrink: 0; color: var(--muted); font-weight: 600; }
.ci-hit-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-hit-text mark { background: #d9f7e5; padding: 0 1px; border-radius: 2px; }
.ci-hit-time { flex-shrink: 0; color: var(--faint); font-size: 11px; }
/* 聊天记录搜索页的筛选条（微信式：关键词 + 图片 + 日期） */
.cs-filters { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.cs-chip {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--card);
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.cs-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.cs-date {
  padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 13px;
}
/* 记忆二分按键的选中态（复用 ghost 按钮底子） */
.row .ghost.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }

/* 聊天设置页：记忆/世界书/正则 导航按键（一个框两个键，各占一半） */
.ci-mem-nav { display: flex; gap: 10px; }
.ci-mem-nav .ghost { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 8px; font-size: 14px; }
.ci-mem-nav .ghost .ic { width: 15px; height: 15px; }
/* 一键删除：裸按钮不套框 */
.ci-wipe-btn { width: 100%; margin-top: 12px; padding: 10px; font-size: 13px; }

/* 聊天记忆页：关键记忆折叠按键 */
.cm-key-toggle {
  width: 100%; padding: 10px 12px; text-align: left;
  border: 1px solid var(--danger); border-radius: 10px;
  background: var(--danger-soft); color: #b02e2b;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.cm-key-toggle.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cm-key-toggle + .mem-key-section { border-top-left-radius: 0; border-top-right-radius: 0; margin-top: -1px; }

/* 世界书 / 正则 查看页条目 */
.cw-list { display: flex; flex-direction: column; gap: 8px; }
.cw-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 13px;
}
.cw-item.disabled .cw-name { color: var(--faint); text-decoration: line-through; }
.cw-head { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.cw-name {
  font-weight: 700; font-size: 14px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 状态 chip（点击切换启用/停用） */
.cw-state {
  flex-shrink: 0; padding: 2px 9px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  font-size: 11px; cursor: pointer; white-space: nowrap;
}
.cw-state.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* 编辑/删除 符号小键 */
.cw-icon-btn {
  flex-shrink: 0; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.cw-icon-btn .ic { width: 14px; height: 14px; }
.cw-icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.cw-icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
/* 编辑态：常驻按键 + 顺序 */
.cw-row2 { display: flex; align-items: center; gap: 12px; margin: 10px 0 0; }
.cw-constant {
  padding: 6px 16px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  font-size: 13px; cursor: pointer;
}
.cw-constant.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.cw-order-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.cw-order-label input { width: 64px; text-align: center; }
.cw-detail { margin-top: 10px; }
.cw-summary-meta { flex-shrink: 0; font-size: 11.5px; color: var(--faint); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-keys { margin-top: 6px; font-size: 12px; color: var(--muted); word-break: break-all; }
.cw-keys code { background: var(--panel); padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }
.cw-content {
  margin-top: 8px; padding: 9px 11px; border-radius: 8px;
  background: var(--panel); font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}

/* ================= API 提供商编辑二级页 + 模型选取 bottom sheet ================= */
.pv-edit-head { display: flex; align-items: center; justify-content: space-between; }
.pv-close-btn {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--card); color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.pv-close-btn:hover { background: #ececec; color: #111; }
/* API Key 行：输入框 + 眼睛按钮 */
.pv-key-row { display: flex; gap: 8px; align-items: stretch; }
.pv-key-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.5px; }
.pv-eye-btn {
  width: 42px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pv-eye-btn .ic { width: 17px; height: 17px; }
.pv-eye-btn:hover { color: var(--accent); border-color: var(--accent); }
/* 模型选取 bottom sheet：从底部弹上来，最高到顶栏下方一点 */
.pv-sheet-ov { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); z-index: 420; }
.pv-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto;
  max-width: 720px;
  max-height: calc(100dvh - 60px); /* 最高到 SoulBox 顶栏下方一点 */
  background: var(--card);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.2);
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
}
.pv-sheet-head { display: flex; align-items: center; gap: 8px; }
.pv-sheet-head b { font-size: 15px; }
.pv-sheet-foot { display: flex; justify-content: flex-end; }
/* 模型列表框：纵向滚动（首屏约 8-10 个），长名称在行内左右滑动看全貌 */
.pv-model-list {
  overflow-y: auto;
  max-height: 46vh;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg);
}
.pv-model-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 8px;
  min-width: 0;
}
.pv-model-item.on { background: var(--accent-soft); }
.pv-model-check {
  width: 20px; height: 20px; padding: 0; flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: #fff;
  color: #fff; font-size: 12px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pv-model-item.on .pv-model-check { background: var(--accent); border-color: var(--accent); }
/* 长模型名：单行不换行，行内左右滑动看全貌（隐藏横向滚动条） */
.pv-model-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  font-size: 13px;
  cursor: default;
}
.pv-model-name::-webkit-scrollbar { display: none; }
.pv-def-tag { color: var(--accent); font-size: 11px; }

/* 编辑页的提供商级操作：设为默认 / 停用·启用 */
.pve-actions { display: flex; flex-direction: column; gap: 4px; }
.pve-action-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.pve-action-row:last-child { border-bottom: none; padding-bottom: 2px; }
.pve-action-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pve-action-text b { font-size: 14px; }
.pve-action-text .hint { font-size: 12px; line-height: 1.4; }
.pve-action-row button { flex-shrink: 0; }
.pve-action-row button:disabled { opacity: 0.55; cursor: default; }

/* ===== 表情面板：输入框「下方」展开（QQ 式），输入岛随之上移 =====
   面板在 .lc-dock 内、紧跟 .lc-island 之后。消息区 .lc-log 是 flex:1，
   面板一出现 dock 变高、log 被压缩 → 视觉上就是「输入框上移、下方让出表情区」。 */
.lc-root .lc-dock { display: flex; flex-direction: column; }
.lc-emoji-panel {
  flex-shrink: 0;
  height: 40vh; max-height: 320px; min-height: 180px;
  background: var(--lc-bar);
  border-top: 1px solid var(--lc-line);
  /* 抵掉 lc-dock 的左右/底部内边距（8px 14px 14px + safe-area），让面板铺满宽度贴到底 */
  margin: 8px -14px calc(-14px - env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.lc-emoji-panel[hidden] { display: none; }
.lc-emoji-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 12px 14px;
  display: grid;
  /* 桌面自适应列数；手机固定 4 列（下方媒体查询） */
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px 8px;
  align-content: start;
}
.lc-emoji-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 2px;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  cursor: pointer; min-width: 0;
}
.lc-emoji-item:hover { background: #fff; border-color: var(--lc-line); }
.lc-emoji-item img {
  width: 52px; height: 52px; object-fit: contain; display: block;
}
.lc-emoji-label {
  font-size: 11px; color: #5a5a5a; line-height: 1.2;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lc-emoji-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px 0; }
/* 表情按钮激活态（面板展开中）：灰白主题下用淡底 + 深色图标。
   注意别只改 color——基础态 .lc-icon-btn.on 是「陶土底 + 白图标」，
   单独改 color 会变成底色与图标同色的实心圆点（看不见图标）。 */
.lc-root .lc-input-row .lc-icon-btn.on {
  background: #e4e4e4;
  border-color: #cfcfcf;
  color: #333;
}
.lc-root .lc-input-row .lc-icon-btn.on:hover { background: #dcdcdc; color: #111; }
/* 灰白主题下未激活态也跟着走（默认的暖色 panel 底在灰白页里发黄） */
.lc-root .lc-input-row .lc-icon-btn { background: var(--lc-field); border-color: var(--lc-line); color: #6b6b6b; }
/* 手机：每行固定 4 个，格子再小一点（用户点名要求） */
@media (max-width: 600px) {
  .lc-emoji-scroll {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px 6px; padding: 10px 8px 12px;
  }
  .lc-emoji-item img { width: 46px; height: 46px; }
  .lc-emoji-label { font-size: 10.5px; }
  .lc-emoji-panel { height: 42vh; min-height: 170px; }
}

/* ==================== 本地存储 / 图片管理（2026-09-15） ==================== */
/* 图片过期后的提示词卡片（URL 失效兜底，替代裂图） */
.chat-img-dead {
  display: inline-block;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12.5px;
  line-height: 1.5;
}
.chat-img-dead .cid-t { font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.chat-img-dead .cid-p { color: var(--text); word-break: break-word; }
.chat-img-dead .cid-copy { margin-top: 6px; }

.oc-card { padding: 14px 16px; }
.oc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.oc-card-head h3 { margin: 0; }

/* 存储空间：数值行 + 进度条 */
.oc-space-row { display: flex; align-items: baseline; gap: 6px; margin: 10px 0 8px; }
.oc-space-val { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.oc-space-total { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.oc-meter { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.oc-meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s; }

/* 列表行：彩条 + 名称 + 数值 + 箭头（行间以分隔线明确划分） */
.oc-rows { margin-top: 4px; }
.oc-row { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-top: 1px solid var(--border); }
.oc-row:first-child { border-top: 0; }
.oc-row[data-go], .oc-row[data-slug] { cursor: pointer; }
.oc-row[data-go]:hover, .oc-row[data-slug]:hover { background: var(--accent-soft); }
.oc-bar { width: 4px; height: 18px; border-radius: 999px; flex: 0 0 auto; }
.oc-row-label { font-size: 13.5px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-row-val { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.oc-chev { color: var(--faint); font-size: 16px; }
.oc-row button:disabled { opacity: .4; cursor: not-allowed; }
.oc-empty { padding: 26px 0; text-align: center; font-size: 12.5px; color: var(--faint); }

.oc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.oc-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
}
.oc-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.oc-cell-mark {
  position: absolute; left: 4px; bottom: 4px;
  font-size: 10px; padding: 1px 5px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff;
}
.oc-cell-del {
  position: absolute; right: 4px; top: 4px;
  width: 20px; height: 20px; line-height: 18px; padding: 0;
  border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 12px;
}
/* 批量保存的勾选圆圈（微信式：选中变灰 + 圆圈变蓝打勾） */
.oc-pick {
  position: absolute; right: 5px; top: 5px;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9);
  background: rgba(0, 0, 0, .28);
  box-sizing: border-box;
}
.oc-cell.sel::after {
  content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .55);
}
.oc-cell.sel .oc-pick {
  background: var(--accent); border-color: var(--accent);
}
.oc-cell.sel .oc-pick::after {
  content: "✓"; position: absolute; inset: 0; color: #fff; font-size: 13px;
  line-height: 16px; text-align: center;
}

.oc-au-text { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 「更多」展开面板（聊天记录行内：图片 / 语音） */
.oc-more-panel { display: flex; gap: 8px; padding: 0 2px 10px 16px; border-top: 0; }

/* 保存设置：开关行把开关推到最右，与数值行对齐 */
.oc-row .switch { margin-left: auto; }
