/* ============================================================
   CoupleLove Admin — 暖纸编辑部 (Warm Paper Editorial)
   暖米白纸底 + 印章红 + 中文衬线标题 + 深咖墨侧栏
   ============================================================ */
:root {
  --paper: #f5f1e8;
  --paper-deep: #ece6d8;
  --card: #fffdf7;
  --line: #e4dccb;
  --line-soft: #efe9da;
  --ink: #2b251c;
  --ink-soft: #5d5444;
  --muted: #988d78;
  --brand: #bd2b45;          /* 印章红 */
  --brand-2: #d94f64;
  --brand-soft: #f9e9e6;
  --accent: #3f568c;         /* 黛青 */
  --ok: #3d7a44;
  --ok-soft: #ebf3e8;
  --err: #b3362b;
  --err-soft: #faece8;
  --warn: #9a6b1a;
  --warn-soft: #f9f1dd;
  --shadow-sm: 0 1px 2px rgba(72, 58, 38, .05);
  --shadow-md: 0 4px 14px rgba(72, 58, 38, .07);
  --shadow-lg: 0 16px 44px rgba(64, 50, 30, .16);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-body: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(189, 43, 69, .055), transparent 62%),
    radial-gradient(900px 460px at 100% -8%, rgba(63, 86, 140, .05), transparent 58%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
/* 纸面噪点 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.05'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
#loginCard, #app, #modalRoot, .toast-stack { position: relative; z-index: 1; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 通用控件 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.warn { color: var(--warn); }
.status { font-size: 13px; color: var(--muted); }

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  background: #fffefb;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(189, 43, 69, .12);
}
input:disabled, select:disabled, textarea:disabled { background: var(--line-soft); color: var(--muted); }
input, select { min-height: 36px; }
textarea {
  min-height: 320px;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: #fffefb;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .12s, background .12s, border-color .12s, color .12s;
  white-space: nowrap;
  letter-spacing: .2px;
  font-family: inherit;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

.btn-primary {
  border: none;
  color: #fff8f5;
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 5px 14px rgba(189, 43, 69, .26);
}
.btn-primary:hover { box-shadow: 0 9px 20px rgba(189, 43, 69, .34); }

.btn-danger {
  border: none;
  color: #fff;
  background: linear-gradient(150deg, #ad3326, #cd5a44);
  box-shadow: 0 5px 14px rgba(173, 51, 38, .22);
}
.btn-danger:hover { box-shadow: 0 9px 20px rgba(173, 51, 38, .3); }

.btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { border-color: #cfc4a9; color: var(--ink); background: #fbf8f0; }

/* ===== 登录页 ===== */
#loginCard {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-shell {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: loginIn .5s cubic-bezier(.22, .8, .3, 1) both;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.login-hero {
  position: relative;
  overflow: hidden;
  padding: 40px 34px 30px;
  color: #f7ecdd;
  background:
    radial-gradient(420px 200px at 90% -30%, rgba(217, 79, 100, .5), transparent 70%),
    linear-gradient(160deg, #241d17 0%, #322820 60%, #3a2c22 100%);
}
/* 印章 */
.login-hero::after {
  content: "囍";
  position: absolute;
  top: 26px;
  right: 26px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 26px;
  color: #f3b7b7;
  border: 2px solid rgba(217, 79, 100, .65);
  border-radius: 8px;
  background: rgba(189, 43, 69, .22);
  transform: rotate(8deg);
  letter-spacing: 0;
}
.login-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 5px;
  opacity: .65;
  font-family: var(--font-mono);
}
.login-logo::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: .6;
}
.login-title {
  margin: 18px 0 8px;
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 2px;
}
.login-subtitle {
  font-size: 13px;
  opacity: .6;
  letter-spacing: 1px;
}
.login-body { padding: 30px 34px 34px; }
.login-body label { display: block; margin-bottom: 15px; }
.login-body label > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 2px;
}
.login-body input { width: 100%; }
.login-body #btnLogin {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  letter-spacing: 8px;
  margin-top: 10px;
}
#loginStatus {
  margin-top: 14px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  letter-spacing: 1px;
}

/* ===== 主应用布局 ===== */
#app {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

/* ----- 侧边栏:深咖墨 ----- */
.sidebar {
  background: linear-gradient(180deg, #221c16 0%, #2a221b 100%);
  color: #c9bfae;
  padding: 26px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 240, 215, .14) transparent;
}
.sidebar-brand {
  padding: 2px 12px 20px;
  border-bottom: 1px solid rgba(255, 240, 215, .08);
  margin-bottom: 12px;
}
.sidebar-brand .name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  color: #f5ecdc;
  letter-spacing: 1px;
  font-family: var(--font-display);
}
.sidebar-brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 0 3px rgba(217, 79, 100, .22);
}
.sidebar-brand .sub {
  margin-top: 7px;
  font-size: 10px;
  color: rgba(245, 236, 220, .32);
  letter-spacing: 4px;
  font-family: var(--font-mono);
}

.nav-section {
  font-size: 10px;
  color: rgba(245, 236, 220, .3);
  letter-spacing: 3px;
  padding: 16px 12px 6px;
  font-family: var(--font-mono);
}

.tabs { display: flex; flex-direction: column; gap: 1px; }
.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: rgba(235, 224, 204, .68);
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .12s, color .12s;
}
.tab:hover {
  background: rgba(245, 236, 220, .06);
  color: #f5ecdc;
  transform: none;
}
.tab .marker {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(235, 224, 204, .22);
  flex-shrink: 0;
  transition: background .15s, height .15s, border-radius .15s;
}
.tab.active {
  background: linear-gradient(90deg, rgba(189, 43, 69, .28), rgba(189, 43, 69, .07) 80%);
  color: #fff6ec;
}
.tab.active .marker {
  height: 16px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  box-shadow: 0 0 8px rgba(217, 79, 100, .55);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 240, 215, .08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(245, 236, 220, .05);
}
.admin-chip .avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff6ec;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.admin-chip .meta { flex: 1; min-width: 0; overflow: hidden; }
.admin-chip .meta .name {
  color: #f5ecdc;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-chip .meta .role { font-size: 11px; color: rgba(235, 224, 204, .42); }

.sidebar-footer button {
  background: rgba(245, 236, 220, .05);
  border: 1px solid rgba(245, 236, 220, .08);
  color: rgba(235, 224, 204, .8);
}
.sidebar-footer button:hover {
  background: rgba(245, 236, 220, .1);
  color: #fff6ec;
}

/* ----- 主内容区 ----- */
.main { padding: 0 30px 44px; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -30px 20px;
  padding: 16px 30px;
  background: rgba(245, 241, 232, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 1px;
  font-family: var(--font-display);
}
.topbar .pill {
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #ecc8c4;
  font-family: var(--font-mono);
  letter-spacing: 1px;
}
.topbar .grow { flex: 1; }
#statusText {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 12px;
  border: 1px solid #cfe0c8;
}

/* 概览数字:合并为一条带分隔线的横幅 */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadein .3s ease;
}
.card.metric {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 18px 22px 16px;
  overflow: hidden;
}
.card.metric + .card.metric { border-left: 1px dashed var(--line); }
.metric::before {
  content: "";
  position: absolute;
  inset: auto -18% -45% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: .07;
  background: radial-gradient(circle, var(--brand), transparent 70%);
}
.metric:nth-child(2)::before { background: radial-gradient(circle, #b07818, transparent 70%); }
.metric:nth-child(3)::before { background: radial-gradient(circle, var(--accent), transparent 70%); }
.metric:nth-child(4)::before { background: radial-gradient(circle, #2e6e62, transparent 70%); }
.metric .k {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.metric .k::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.metric:nth-child(2) .k::before { background: #b07818; }
.metric:nth-child(3) .k::before { background: var(--accent); }
.metric:nth-child(4) .k::before { background: #2e6e62; }
.metric .v {
  margin-top: 9px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* 面板 */
.panel { animation: fadein .28s ease; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  letter-spacing: 1px;
}
.panel h2::before {
  content: "";
  width: 5px;
  height: 19px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  box-shadow: 1.5px 0 0 rgba(189, 43, 69, .18);
}
.panel h3 {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 26px 0 10px;
  font-family: var(--font-display);
  letter-spacing: 1px;
}
.panel p.muted { margin: 0 0 14px; line-height: 1.7; }

/* 表格:hairline 编辑部风 */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 9px 10px;
  background: transparent;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 1.5px;
}
th:first-child { border-top-left-radius: 0; }
th:last-child { border-top-right-radius: 0; }
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: #faf6ec; }
tbody tr:last-child td { border-bottom: none; }
td input, td select { min-height: 32px; padding: 6px 9px; }
td button { padding: 5px 12px; font-size: 12px; }
td button + button { margin-left: 4px; }

/* 表单网格 */
.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.form-grid input, .form-grid select { width: 100%; }

/* 状态徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #cfe0c8; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: #eccbc2; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #e8d9b4; }
.badge.muted { background: var(--line-soft); color: var(--muted); border-color: var(--line); }

/* ==== 移动端适配 ==== */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(35, 28, 20, .5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card.metric + .card.metric { border-left: none; }
  .card.metric:nth-child(even) { border-left: 1px dashed var(--line); }
  .card.metric:nth-child(n+3) { border-top: 1px dashed var(--line); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }

  /* 侧边栏改为抽屉 */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 272px;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 36px rgba(20, 14, 8, .35);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: block; }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* 主区调整 */
  .main { padding: 0 14px 32px; }
  .topbar { margin: 0 -14px 14px; padding: 12px 14px; gap: 8px; flex-wrap: wrap; }
  .nav-toggle { display: inline-flex; }
  .topbar h1 { font-size: 18px; flex: 1 1 auto; }
  .topbar .pill { display: none; }
  #btnReloadAll { padding: 7px 12px; font-size: 12px; }
  #statusText { display: none; }

  /* 数字卡 */
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
  .card.metric { padding: 13px 16px 12px; }
  .card.metric + .card.metric { border-left: none; }
  .card.metric:nth-child(even) { border-left: 1px dashed var(--line); }
  .card.metric:nth-child(n+3) { border-top: 1px dashed var(--line); }
  .metric .v { font-size: 24px; }

  /* 面板内边距 */
  .panel.card { padding: 14px; border-radius: 12px; }
  .panel h2 { font-size: 16px; margin-bottom: 12px; }
  .panel h3 { margin-top: 18px; }

  /* 表格横向滚动:用 wrapper 让 thead/tbody 列对齐 */
  .panel.card { overflow: hidden; }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px 4px;
  }
  .table-wrap > table {
    width: max-content;
    min-width: 100%;
  }
  .table-wrap th,
  .table-wrap td { white-space: nowrap; }
  td input, td select { min-width: 110px; }

  /* 表头紧凑工具栏 */
  .panel.card > .row { gap: 8px; }
  .panel.card > .row > input,
  .panel.card > .row > select { flex: 1 1 140px; min-width: 0; }
  .panel.card > .row > button { flex: 0 0 auto; }

  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* 系统运维按钮排成一列更舒服 */
  #tab-system .row > button,
  #tab-system .row > select { flex: 1 1 100%; }

  /* 模态自适应 */
  #userModal > .card,
  #chatModal > .card,
  #planFeatModal > .card {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    padding: 14px !important;
  }
  #chatModal > .card { width: calc(100vw - 24px) !important; }

  /* 登录页紧凑 */
  .login-shell { max-width: 100%; }
  .login-hero { padding: 30px 24px 24px; }
  .login-hero::after { top: 20px; right: 20px; width: 46px; height: 46px; font-size: 22px; }
  .login-title { font-size: 26px; }
  .login-body { padding: 24px; }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr; }
  .card.metric:nth-child(even) { border-left: none; }
  .card.metric:nth-child(n+2) { border-top: 1px dashed var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 0 10px 24px; }
  .topbar { margin: 0 -10px 12px; padding: 10px; }
  .topbar h1 { font-size: 16px; }
  .login-title { font-size: 22px; }
}

/* 隐藏 base 输入框,仍保留以便登录提交 */
#apiBaseWrap { display: none; }

/* ===== Split-page shell ===== */
.page-stack { display: grid; gap: 0; }
.page { min-width: 0; }
.toolbar { margin-bottom: 14px; }
.table-actions { white-space: nowrap; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.summary-list { display: grid; gap: 8px; margin: 12px 0; }
.summary-item { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.summary-item span:first-child { color: var(--muted); font-size: 12px; }
.summary-item span:last-child { color: var(--ink); text-align: right; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(35, 27, 18, .52);
  backdrop-filter: blur(5px);
  animation: fadein .15s ease;
}
.modal-card {
  width: min(680px, calc(100vw - 28px));
  max-height: 88vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: modalIn .22s cubic-bezier(.22, .8, .3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.modal-wide { width: min(860px, calc(100vw - 28px)); }
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 {
  margin: 0;
  flex: 1;
  font-size: 16px;
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: 1px;
}
.modal-close { padding: 4px 10px; }
.form-stack { display: grid; gap: 11px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; letter-spacing: 1px; }
.field input, .field select, .field textarea { width: 100%; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.danger-zone { margin-top: 14px; padding-top: 14px; border-top: 1px dashed #e3c1bb; }
.chat-list { overflow: auto; max-height: 58vh; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #faf7f0; }
.chat-item { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); }
.chat-meta { font-size: 11px; color: var(--muted); }
.chat-content { margin-top: 3px; color: var(--ink); }
.clip-text {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-list {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #faf7f0;
  line-height: 1.7;
  word-break: break-all;
}
.media-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--line-soft);
}
.media-preview-wrap {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf7f0;
  text-align: center;
  word-break: break-all;
}
.media-preview {
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.check-list { display: grid; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.check-row:hover { background: var(--line-soft); }
.check-row input { min-height: auto; width: 16px; height: 16px; accent-color: var(--brand); }
.admin-permission-field { margin: 12px 0 16px; }
.permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}
.permission-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffefb;
  cursor: pointer;
}
.permission-option:hover { border-color: #cfc4a9; background: #fbf8f0; }
.permission-option.disabled { cursor: not-allowed; background: var(--line-soft); color: var(--muted); }
.permission-option input { min-height: auto; width: 16px; height: 16px; accent-color: var(--brand); }
.permission-option code {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  background: transparent;
  font-family: var(--font-mono);
}
.permission-pills { display: flex; flex-wrap: wrap; gap: 4px; min-width: 160px; }
.permission-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--line-soft);
}
.permission-pill.all {
  color: var(--brand);
  background: var(--brand-soft);
}

.toast-stack {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 12000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .97);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  pointer-events: auto;
  animation: toastIn .18s ease;
}
.toast.ok { border-color: #cfe0c8; background: rgba(243, 248, 240, .97); }
.toast.err { border-color: #eccbc2; background: rgba(250, 240, 236, .97); }
.toast-dot {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(61, 122, 68, .14);
}
.toast.err .toast-dot {
  background: var(--err);
  box-shadow: 0 0 0 4px rgba(179, 54, 43, .14);
}
.toast-text {
  min-width: 0;
  line-height: 1.45;
  font-size: 13px;
  word-break: break-word;
}
.toast-close {
  border: none;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  padding: 0 2px;
  min-height: auto;
  line-height: 1;
}
.toast-close:hover { transform: none; color: var(--ink); background: transparent; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .field-grid { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal { padding: 12px; align-items: flex-start; }
  .modal-card { width: calc(100vw - 24px) !important; max-height: 90vh !important; padding: 14px !important; }
  .toast-stack {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }
}

@media (max-width: 520px) {
  .permission-grid { grid-template-columns: 1fr; }
}

/* ===== 聊天会话气泡 ===== */
.chat-thread-card { width: min(720px, 92vw); }
.chat-thread-meta {
  font-size: 12px; color: var(--ink-soft);
  padding: 4px 10px 8px; border-bottom: 1px dashed var(--line-soft);
}
.chat-thread {
  height: 60vh; max-height: 540px;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, #f3eee3 0%, #f7f3ea 100%);
  border-radius: 6px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-bubble {
  position: relative;
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  word-break: break-word;
}
.chat-bubble.left {
  align-self: flex-start;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
}
.chat-bubble.right {
  align-self: flex-end;
  background: #fbe3da;
  border: 1px solid #ecc2b4;
  border-top-right-radius: 4px;
}
.chat-bubble .chat-meta {
  font-size: 11px; color: var(--ink-soft); margin-bottom: 4px;
}
.chat-bubble .chat-body { font-size: 14px; line-height: 1.5; }
.chat-bubble .chat-body img.chat-bubble-img {
  max-width: 220px; max-height: 220px; border-radius: 6px; display: block;
}
.chat-bubble .chat-del {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fffdf7; border: 1px solid var(--line);
  font-size: 14px; line-height: 1;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.chat-bubble:hover .chat-del { opacity: 1; }
.chat-bubble .chat-del:hover { background: var(--err-soft); color: var(--err); }
