/* ============================================
   Leemng UI Theme — Tavily-inspired
   统一设计系统：所有页面共用此文件的变量和组件类
   改配色/圆角/间距只需要改这里，不要在各页面模板里写死颜色值
   ============================================ */

/* --- View Transitions API：跨页面导航丝滑过渡 ---
   浏览器原生能力（Chrome 126+ / Safari 18.2+），零 JS、零额外网络请求。
   点击链接走正常整页跳转，浏览器自动截图旧页面+新页面做交叉淡入淡出。
   不支持的浏览器（如老版 Firefox）自动降级为普通跳转，不会报错也不会难看。
   替代了之前自定义 XHR fetch + DOM 替换的“假 SPA”方案（更简单、更少 bug 面）。 */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.18s;
  animation-timing-function: ease-out;
}

/* --- CSS Variables --- */
:root {
  /* 背景色：暖米白色系，从浅到深分层。卡片要比页面背景更深一点的米黄，不能是纯白 */
  --bg-page: #FAF9F6;
  --bg-sidebar: #FAF9F6;
  --bg-card: #F3F1EA;
  --bg-card-outer: #F3F1EA;
  --bg-card-inner: #ECE9E0;
  --bg-hover: #EDEBE3;
  --bg-active: #E8ECF0;

  --sidebar-w: 240px;
  --topbar-h: 60px;

  /* 边框：极淡灰色细线，仅用于卡片内部分层；sidebar/topbar 等大区块分割不用线，靠背景色一致+投影过渡 */
  --border: rgba(20, 20, 19, 0.08);
  --border-strong: rgba(20, 20, 19, 0.14);
  --divider-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
  --divider-shadow-bottom: 0 2px 8px rgba(0, 0, 0, 0.03);

  /* 文字：深灰阶梯，不用纯黑 */
  --text-primary: #171717;
  --text-secondary: #52525B;
  --text-muted: #8A8A85;

  /* 主色：深炭黑，用于主按钮/强调元素（Tavily 风格：黑白对比而非彩色） */
  --accent: #171717;
  --accent-hover: #333330;
  --black: #171717;

  /* 语义色：功能性状态标签统一从这里取色，不要在页面里写死 hex */
  --success-bg: #D1FAE5;
  --success-text: #059669;
  --danger-bg: #FEF2F2;
  --danger-text: #DC2626;
  --danger-border: #FECACA;
  --warning-bg: #FFF7ED;
  --warning-text: #EA580C;
  --info-bg: #EEF2F6;
  --info-text: #2563EB;

  /* 圆角：整体收紧，Tavily 走 8-12px 中等圆角，不用大圆角 */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* 阴影：极轻，扁平化风格主要靠 --border 分层 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--bg-page); }

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

/* --- Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar-theme {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  box-shadow: var(--divider-shadow);
}

.sidebar-theme .logo {
  padding: 0 24px;
  font-size: 16px;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}
.sidebar-logo {
  padding: 28px 24px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.01em;
  margin-bottom: 16px;
  border-bottom: none;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 24px;
  margin-bottom: 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--bg-active);
  color: var(--info-text);
  font-weight: 600;
}

.sidebar-item .icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
}
.nav-icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  opacity: 0.5;
}
.sidebar-item:hover .nav-icon,
.sidebar-item.active .nav-icon {
  opacity: 1;
}

.sidebar-item .badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

.badge-ready { background: var(--success-bg); color: var(--success-text); }
.badge-dev  { background: var(--warning-bg); color: var(--warning-text); }

.sidebar-spacer { flex: 1; }

/* --- Main Content --- */
.main-theme {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Page Header --- */
.main-content-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-left: 40px;
  padding-right: 40px;
}

.page-header {
  padding: 32px 32px 16px;
  flex-shrink: 0;
}

.page-header .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 32px 32px;
}

/* --- Topbar --- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--divider-shadow-bottom);
  flex-shrink: 0;
  background: var(--bg-page);
}
.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.topbar-breadcrumb a:hover { color: var(--text-primary); }
.topbar-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  border: none;
  position: relative;
}
.topbar-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.topbar-icon-btn svg {
  width: 20px;
  height: 20px;
}
.topbar-pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  transition: all 0.15s;
  margin-right: 4px;
}
.topbar-pill-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F5E9C8;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border-strong);
  transition: all 0.15s;
  margin-left: 4px;
  padding: 0;
}
.avatar:hover {
  border-color: var(--text-primary);
}
/* 已登录：米黄 → 浅绿 */
.avatar.is-authed {
  background: #D6EFD8;
  border-color: #86C28B;
}
.avatar svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* 超管下拉菜单：绝对定位，不影响周围布局 */
.acct-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.acct-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 232px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 12px;
  z-index: 200;
  display: none;
}
.acct-menu.open {
  display: block;
}
.acct-menu h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.acct-menu input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm, 8px);
  font-size: 13px;
  background: #fff;
}
.acct-menu button {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-sm, 8px);
  background: var(--black);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.acct-menu button.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  margin-top: 6px;
}
.acct-menu a.acct-link {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm, 8px);
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
  margin-bottom: 6px;
}
.acct-menu a.acct-link:hover {
  background: var(--bg-hover);
}
.acct-user {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  word-break: break-all;
}
/* 记住我：固定高度，不挤动下方错误行与按钮 */
.acct-remember {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
}
.acct-remember input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--text-primary);
  cursor: pointer;
}

/* 预留错误行高度，出现提示时不挤动其他元素 */
.acct-err {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger-text);
  margin-bottom: 6px;
  line-height: 16px;
}
.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger-text);
  border: 2px solid var(--bg-page);
}

/* --- Cards：扁平化，靠边框分层，阴影极轻 --- */
.card {
  background: var(--bg-card-outer);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.card:hover {
  border-color: var(--border-strong);
}

.card-header {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.card-inner {
  background: var(--bg-card-inner);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.card-inner:hover {
  background: var(--bg-hover);
}
.card-inner:last-child { margin-bottom: 0; }

/* --- Buttons：黑白对比为主，克制使用彩色 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  letter-spacing: -0.01em;
  line-height: 1;
}

.btn-primary {
  background: var(--black);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-accent {
  background: var(--black);
  color: #fff;
}

.btn-accent:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-danger {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-danger:hover {
  color: var(--danger-text);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

/* --- Forms --- */
.input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.input:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.08);
}

.input::placeholder { color: var(--text-muted); }

textarea.input {
  resize: vertical;
  min-height: 40px;
}

/* ─────────── 管理面板（自建中文后台） ─────────── */
/* 两栏结构：左菜单 + 右内容，对应设计稿 */
.pnl-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .pnl-wrap { grid-template-columns: 1fr; }
}

/* 左侧菜单卡片 */
.pnl-menu {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
}
/* 菜单分组（大项）：大项标题 + 子项缩进 */
.pnl-group { margin-bottom: 6px; }
.pnl-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 7px 10px 8px;
}
.pnl-group > a {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.pnl-group > a.on {
  border-left-color: var(--text-primary);
}
.pnl-menu-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 4px 10px 10px;
}
.pnl-menu a {
  display: block;
  padding: 8px 12px;
  margin-bottom: 3px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
}
.pnl-menu a:hover { background: var(--bg-hover); color: var(--text-primary); }
.pnl-menu a.on {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
}
.pnl-back { font-size: 12px !important; color: var(--text-muted) !important; }
.pnl-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 10px 6px;
}

/* 右侧内容卡片 */
.pnl-main {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 22px;
}
.pnl-crumb {
  font-size: 12px;
  color: var(--text-muted);
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.pnl-crumb b { color: var(--text-primary); font-weight: 600; }

/* 搜索条 */
.pnl-search {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pnl-search .input { width: 240px; }

/* 表格：列宽固定、表头清晰、隔行底色 */
.pnl-table-scroll { overflow-x: auto; }
.pnl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 880px;
}
.pnl-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-card-inner);
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.pnl-table th:first-child { border-radius: var(--radius) 0 0 0; }
.pnl-table th:last-child  { border-radius: 0 var(--radius) 0 0; }
.pnl-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.pnl-table tbody tr:hover { background: var(--bg-hover); }
.pnl-table .c-user { font-weight: 600; }
.pnl-table .c-note { color: var(--text-secondary); }
/* 权限列：勾选框居中，列宽固定防止表格抖动 */
.pnl-table .c-perm { text-align: center; width: 92px; }
.pnl-table .c-act  { white-space: nowrap; width: 1%; }
/* 超管资格列：用左边框 + 底色跟前面的功能权限明确隔开。
   这一列改的是「能不能进后台、管所有人、删任意账号」，
   跟「能不能用某个功能」不是一个量级，误点代价太大，所以刻意分区。 */
.pnl-table .c-super,
.pnl-table th.c-super {
    border-left: 2px solid var(--border);
    background: var(--bg-hover);
    text-align: center;
    white-space: nowrap;
    width: 1%;
}
.pnl-table input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--text-primary);
}
.pnl-table .note-input {
  width: 100%;
  min-width: 120px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
}
.pnl-table .note-input:hover { border-color: var(--border-strong); background: #fff; }
.pnl-table .note-input:focus { outline: none; border-color: var(--text-primary); background: #fff; }

/* 表单：标签 + 说明 + 控件竖排，预留说明行高度避免跳动 */
.pnl-form { max-width: 460px; }
.pnl-field { margin-bottom: 18px; }
.pnl-field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.pnl-field .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 7px;
  line-height: 1.5;
}
.pnl-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg-card-inner);
  cursor: pointer;
}
.pnl-check:hover { border-color: var(--border-strong); }
.pnl-check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--text-primary); }
.pnl-check .ck-body { flex: 1; }
.pnl-check .ck-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.pnl-check .ck-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

/* 提示条：高度预留，出现时不挤动下方内容 */
.pnl-msg {
  min-height: 20px;
  line-height: 20px;
  font-size: 13px;
  margin-bottom: 10px;
}
.pnl-msg.ok  { color: var(--success-text); }
.pnl-msg.err { color: var(--danger-text); }

.pnl-empty {
  text-align: center;
  padding: 44px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* 弹框：修改密码 */
.pnl-modal-bg {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.pnl-modal-bg.show { display: flex; }
.pnl-modal {
  background: var(--bg-page);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  width: 340px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
.pnl-modal h3 { margin: 0 0 6px; font-size: 15px; color: var(--text-primary); }
.pnl-modal .sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.pnl-modal .row { display: flex; gap: 8px; margin-top: 14px; }
.pnl-modal .row .btn { flex: 1; }

/* 身份切换下拉 */
.role-sel {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-primary);
  background: #fff;
  cursor: pointer;
  max-width: 118px;
}
.role-sel:focus { outline: none; border-color: var(--text-primary); }

/* 状态圆点 */
.pnl-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.pnl-dot i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.pnl-dot.on i  { background: #22C55E; }
.pnl-dot.off i { background: #C4C4BE; }
.pnl-dot.on    { color: var(--success-text); }
.pnl-dot.off   { color: var(--text-muted); }

/* --- Tags / Pills / 语义化状态标签 --- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.tag-success { background: var(--success-bg); color: var(--success-text); }
.tag-danger { background: var(--danger-bg); color: var(--danger-text); }
.tag-warning { background: var(--warning-bg); color: var(--warning-text); }
.tag-info { background: var(--info-bg); color: var(--info-text); }

/* --- Toast 提示：统一样式，各页面不要再自己定义颜色 --- */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 999;
  animation: toastIn .3s;
  box-shadow: var(--shadow-lg);
}
.toast.ok { background: var(--success-bg); color: var(--success-text); }
.toast.err { background: var(--danger-bg); color: var(--danger-text); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 600;
}

.empty-state p {
  font-size: 13px;
}

/* --- Table --- */
.table-minimal {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table-minimal thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}
.table-minimal tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.table-minimal tbody tr:hover td {
  background: var(--bg-hover);
}
.table-minimal tbody tr:last-child td {
  border-bottom: none;
}

/* --- Utility --- */
.flex-row { display: flex; align-items: center; gap: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-secondary); font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.ml-auto { margin-left: auto; }


.pill-tab {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 8px 18px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-secondary) !important;
  border-radius: var(--radius-sm) !important;
  border: none !important;
  background: transparent !important;
  text-decoration: none !important;
  transition: all 0.15s !important;
  line-height: 1 !important;
}

.pill-tab:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

.pill-tab.active {
  background: var(--bg-active) !important;
  color: var(--info-text) !important;
  font-weight: 600 !important;
}

.pill-tab-icon {
  width: 15px;
  height: 15px;
  vertical-align: middle;
  margin-right: 4px;
  opacity: 0.5;
}
.pill-tab:hover .pill-tab-icon,
.pill-tab.active .pill-tab-icon {
  opacity: 1;
}

/* ============================================================
   聊天室（/chat/）
   Line 风格气泡：自己靠右、他人靠左带头像与用户名。
   每位用户一种气泡底色，由前端按用户名哈希取 .chat-c0 ~ .chat-c7。
   全部为浅底 + 深灰字，对比度 ≥ 4.5:1（WCAG AA），不会出现浅字压浅底。
   ============================================================ */

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 190px);
  min-height: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty {
  margin: auto;
  color: var(--text-muted);
  font-size: 13px;
}

/* 日期分隔线 */
.chat-day {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 2px;
}
.chat-day span {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}
.chat-row.is-me    { justify-content: flex-end; }
.chat-row.is-other { justify-content: flex-start; }

.chat-col {
  display: flex;
  flex-direction: column;
  max-width: 76%;
  min-width: 0;
}

.chat-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-top: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #1F2937;
  user-select: none;
}

.chat-name {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 3px 4px;
}

/* 气泡与时间同一行，时间贴在气泡外侧底部（Line 的做法） */
.chat-line {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
}

.chat-bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: #1F2937;
  white-space: pre-wrap;      /* 保留 Shift+回车 换出来的换行 */
  word-break: break-word;
  overflow-wrap: anywhere;    /* 长串英文/链接不撑破布局 */
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

/* 气泡小尾巴 */
.chat-bubble::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
}
.chat-row.is-other .chat-bubble {
  border-top-left-radius: 6px;
}
.chat-row.is-other .chat-bubble::after {
  left: -5px;
  border-right-color: inherit;
  display: none;              /* 用圆角切角表达方向，避免尾巴与底色不一致 */
}
.chat-row.is-me .chat-bubble {
  border-top-right-radius: 6px;
}

.chat-time {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-muted);
  padding-bottom: 3px;
  white-space: nowrap;
}

/* 自己的气泡：沿用站点主色调的浅绿，与他人配色区分 */
.chat-bubble.mine {
  background: #D9F2C6;
  border: 1px solid #C4E7AB;
  color: #1B3A16;
}

/* 他人气泡配色：8 组低饱和浅底，配深灰字 */
.chat-c0 { background: #E8F1FB; border: 1px solid #D2E4F7; }  /* 浅蓝 */
.chat-c1 { background: #F3EBFA; border: 1px solid #E5D8F3; }  /* 浅紫 */
.chat-c2 { background: #FDF0E4; border: 1px solid #F7E1CB; }  /* 奶油橙 */
.chat-c3 { background: #E6F5F0; border: 1px solid #CFEAE1; }  /* 薄荷 */
.chat-c4 { background: #FBEBF0; border: 1px solid #F5D8E2; }  /* 浅粉 */
.chat-c5 { background: #F0F2E6; border: 1px solid #E1E5CF; }  /* 浅橄榄 */
.chat-c6 { background: #E9EEF5; border: 1px solid #D6DEEA; }  /* 灰蓝 */
.chat-c7 { background: #FCF3D9; border: 1px solid #F3E6BC; }  /* 浅黄 */

/* 头像沿用同一套底色 */
.chat-avatar.chat-c0, .chat-avatar.chat-c1, .chat-avatar.chat-c2,
.chat-avatar.chat-c3, .chat-avatar.chat-c4, .chat-avatar.chat-c5,
.chat-avatar.chat-c6, .chat-avatar.chat-c7 { box-shadow: var(--shadow-sm); }

/* 输入区 */
.chat-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-card-outer);
}
.chat-composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
}
.chat-composer textarea:focus {
  border-color: var(--accent);
}
.chat-composer .btn { flex: 0 0 auto; height: 40px; }

.chat-hint {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card-outer);
  min-height: 14px;
}

/* 后台聊天记录页头部 */
.pnl-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .chat-col { max-width: 86%; }
  .chat-wrap { height: calc(100vh - var(--topbar-h) - 150px); }
}
