/* ============================================================
   智域 · 设计系统
   深色 / 浅色双主题  ·  三栏桌面布局  ·  卡片式手机界面
   ============================================================ */

/* ───────────── 主题变量 ───────────── */

:root,
[data-theme="light"] {
  --bg:           #f7f8fc;
  --bg-soft:      #f2f4fa;
  --surface:      #ffffff;
  --surface-2:    #f5f7fc;
  --surface-3:    #edf0f8;
  --border:       #e8ebf4;
  --border-soft:  #f0f2f8;
  --text:         #1f2430;
  --text-2:       #4a5165;
  --muted:        #8a90a6;
  --accent:       #6c63ff;
  --accent-hover: #5b5fef;
  --accent-soft:  #eeedff;
  --accent-2:     #7c5cfc;
  --accent-2-soft:#f2ecff;
  --green:        #22c55e;
  --green-soft:   #e9fbf0;
  --amber:        #f59e0b;
  --amber-soft:   #fff6e5;
  --rose:         #f43f5e;
  --rose-soft:    #ffedf0;
  --shadow-sm: 0 1px 3px rgba(23, 28, 48, .04);
  --shadow-md: 0 4px 20px rgba(23, 28, 48, .06);
  --shadow-lg: 0 12px 40px rgba(23, 28, 48, .10);
  --ring:      0 0 0 3px rgba(108, 99, 255, .14);
  --grad:      linear-gradient(135deg, #5b5fef 0%, #7c5cfc 100%);
  --r-sm:      10px;
  --r:         14px;
  --r-lg:      18px;
  --r-xl:      22px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:           #0e111a;
  --bg-soft:      #131722;
  --surface:      #171c28;
  --surface-2:    #1d2331;
  --surface-3:    #242b3c;
  --border:       #262e40;
  --border-soft:  #1e2534;
  --text:         #e9edf7;
  --text-2:       #a5afc7;
  --muted:        #6e7891;
  --accent:       #7c78ff;
  --accent-hover: #8f8bff;
  --accent-soft:  rgba(124, 120, 255, .16);
  --accent-2:     #9b7cfc;
  --accent-2-soft:rgba(155, 124, 252, .16);
  --green:        #34d399;
  --green-soft:   rgba(52, 211, 153, .14);
  --amber:        #fbbf24;
  --amber-soft:   rgba(251, 191, 36, .14);
  --rose:         #fb7185;
  --rose-soft:    rgba(251, 113, 133, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  --ring:      0 0 0 3px rgba(124, 120, 255, .25);
  --grad:      linear-gradient(135deg, #6c63ff 0%, #9b7cfc 100%);
  --r-sm:      10px;
  --r:         14px;
  --r-lg:      18px;
  --r-xl:      22px;
  color-scheme: dark;
}

/* ───────────── 基础 ───────────── */

* { box-sizing: border-box; }
/* html 也要有背景色：手机浏览器顶部状态栏、下拉回弹露出来的就是这一层，
   不设的话会是白的 */
html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); }

/* ───────────── 三栏布局 ───────────── */

.layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 320px;
  gap: 24px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px;
  align-items: start;
}

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app { flex: 1; padding: 20px 0 48px; }

/* ───────────── 左侧栏 ───────────── */

.rail {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 0 20px;
  gap: 18px;
}

/* 抽屉关闭按钮：只在手机抽屉展开时出现 */
.rail-close { display: none; }

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 11px;
  background: transparent;
}
.brand-mark img { display: block; width: 100%; height: 100%; border-radius: inherit; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand-text em { font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }

.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: background .16s, color .16s;
  position: relative;
}
.rail-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.rail-nav a:hover { background: var(--surface); color: var(--text); }
.rail-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rail-badge {
  position: absolute; left: 26px; top: 8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--rose); color: #fff;
  font-size: 10px; font-weight: 700; font-style: normal;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
}

/* 顶栏消息红点 */
.topbar-bell { position: relative; }
.bell-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rose); border: 1.5px solid var(--bg);
}
.topbar-avatar {
  display: grid; place-items: center;
  border-radius: 50%; padding: 2px;
  border: 1px solid var(--border);
  transition: border-color .16s;
}
.topbar-avatar:hover { border-color: var(--accent); }

/* 模型小标签 */
.model-chip {
  flex-shrink: 0;
  padding: 0 6px; border-radius: 5px;
  font-size: 10px; font-weight: 700; font-style: normal;
  line-height: 16px; letter-spacing: .2px;
  background: var(--surface-3);
}

.rail-section { flex: 1; min-height: 0; overflow-y: auto; }
.rail-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 8px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.rail-title a { font-size: 11.5px; color: var(--muted); }
.rail-title a:hover { color: var(--accent); }

.rail-models { display: flex; flex-direction: column; gap: 1px; }
.model-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 9px;
  transition: background .16s;
}
.model-row:hover { background: var(--surface); }
.model-logo {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 9px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.model-info { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.model-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.model-sub { font-size: 11px; color: var(--muted); }

.rail-foot {
  padding: 14px 12px 0;
  border-top: 1px solid var(--border-soft);
}
.rail-online {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
}
.rail-online b { color: var(--text); font-weight: 700; }
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 3px var(--green-soft);
}
.rail-tagline { margin-top: 6px; font-size: 11px; color: var(--muted); }

/* ───────────── 顶栏 ───────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 0 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
}
.rail-toggle { display: none; }

/* 刘海屏手机（装到桌面后）顶部有一段系统状态栏的安全区，
   放个站名上去，免得看起来像一块莫名其妙的空白 */
body.has-notch .topbar::before {
  content: '智域';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: env(safe-area-inset-top, 0px);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}

.searchbar { position: relative; flex: 1; max-width: 520px; }
.searchbar svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.searchbar input {
  width: 100%; height: 42px; padding: 0 16px 0 40px;
  border: 1px solid var(--border); border-radius: 21px;
  background: var(--surface); outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.searchbar input::-webkit-search-cancel-button { -webkit-appearance: none; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }

/* 主题切换按钮的图标切换 */
#themeToggle .ico-sun { display: none; }
[data-theme="light"] #themeToggle .ico-moon { display: none; }
[data-theme="light"] #themeToggle .ico-sun { display: block; }

/* ───────────── 按钮 ───────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, opacity .16s;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--surface-3); }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface); border-color: transparent; }

.btn-danger { color: var(--rose); border-color: var(--border); }
.btn-danger:hover { background: var(--rose-soft); border-color: var(--rose); color: var(--rose); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px; color: var(--text-2);
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

/* ───────────── 卡片 ───────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  margin-bottom: 14px;
  overflow: hidden;
}
.card-pad { padding: 16px; }

/* 手机扫码卡片 */
.qr-wrap {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.qr-box {
  flex-shrink: 0;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  line-height: 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
}

.qr-box img {
  display: block;
  width: 180px;
  height: 180px;
}

.qr-side {
  flex: 1;
  min-width: 220px;
}

.qr-title {
  font-weight: 650;
  margin-bottom: 6px;
}

.qr-desc {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-body { padding: 16px; }

/* ───────────── 徽章 / 头像 ───────────── */

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap;
}
.badge-ai      { background: var(--accent-2-soft); color: var(--accent-2); }
.badge-admin   { background: var(--amber-soft);    color: var(--amber); }
.badge-pin     { background: var(--rose-soft);     color: var(--rose); }
.badge-essence { background: var(--green-soft);    color: var(--green); }
.badge-lock    { background: var(--surface-3);     color: var(--muted); }
.badge-soft    { background: var(--surface-2);     color: var(--muted); }
.task-ai-chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

/* ───────────── 话题标签（帖子的分类方式） ───────────── */

.topic-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.topic-chip {
  display: inline-flex; align-items: center; max-width: 100%;
  padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .16s, color .16s;
}
.topic-chip:hover { background: var(--accent); color: #fff; }

.topic-badge {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 17px; font-weight: 700;
}

.topic-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.topic-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 13px;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.topic-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.topic-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topic-card .topic-badge { width: 26px; height: 26px; border-radius: 8px; font-size: 14px; }
.topic-card-name { font-size: 14px; font-weight: 650; }

/* ───────────── 任务 ───────────── */

.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.task-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.task-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-title { font-size: 15px; font-weight: 650; }
.task-desc { font-size: 13px; color: var(--muted); line-height: 1.65; }
.task-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted);
}

.task-detail-title { margin: 10px 0 2px; font-size: 20px; font-weight: 700; }
.task-detail-desc {
  margin-top: 12px; font-size: 14.5px; line-height: 1.8;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.task-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.task-meta div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.task-meta b { font-weight: 600; }

.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: flex; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.tl-item:last-child { border-bottom: none; }
.tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.tl-text { font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }

.task-comment {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--border-soft);
}
.task-comment .textarea { flex: 1; min-height: 46px; }

.avatar {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  background: var(--surface-3); color: var(--text-2);
  user-select: none;
  overflow: hidden;
}
.avatar-lg { width: 64px; height: 64px; font-size: 29px; }
.avatar-sm { width: 30px; height: 30px; font-size: 15px; }
.avatar-ai { background: var(--accent-2-soft); color: var(--accent-2); }

/* 用图片当头像时，铺满圆形区域 */
.avatar img,
.char-avatar img,
.profile-avatar img {
  width: 100%; height: 100%; display: block;
  object-fit: cover; border-radius: inherit;
}

/* 名字和头像都可点进主页 */
.user-link { display: block; color: inherit; }
.user-link:hover { color: var(--accent); }
.post-user { display: block; color: inherit; text-align: center; max-width: 100%; }
.thread-item > .user-link { flex-shrink: 0; }
.post-user .name { transition: color .16s; }
.post-user:hover .name { color: var(--accent); }

/* ───────────── 首页 Hero ───────────── */

.hero {
  position: relative;
  border-radius: 16px; overflow: hidden;
  margin-bottom: 18px;
  min-height: 200px;
  display: flex; align-items: flex-end;
  background:
    radial-gradient(circle at 96% 8%, rgba(96, 146, 255, .22) 0%, transparent 32%),
    linear-gradient(120deg, #0a1020 0%, #0b1428 48%, #06090f 100%);
  border: 1px solid var(--border-soft);
}

/* 星球 + 边缘光 */
.hero::before {
  content: "";
  position: absolute;
  right: -10%; bottom: -105%;
  width: 64%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 26%, #24406f 0%, #16233d 32%, #0a1020 62%, #05070d 100%);
  box-shadow:
    -10px -8px 70px rgba(96, 150, 255, .26),
    inset 12px 10px 60px rgba(0, 0, 0, .5);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  right: -10%; bottom: -105%;
  width: 64%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 26% 20%, rgba(170, 205, 255, .55) 0%, rgba(120, 170, 255, .12) 10%, transparent 18%);
  filter: blur(2px);
  pointer-events: none;
}

[data-theme="light"] .hero {
  background:
    radial-gradient(circle at 96% 8%, rgba(120, 165, 255, .30) 0%, transparent 34%),
    linear-gradient(120deg, #eaf1ff 0%, #dde8ff 46%, #eef4ff 100%);
}
[data-theme="light"] .hero::before {
  background: radial-gradient(circle at 36% 26%, #d3e0f8 0%, #bccff2 34%, #a8bde8 66%, #9ab0de 100%);
  box-shadow:
    -8px -6px 56px rgba(96, 140, 230, .22),
    inset 14px 12px 64px rgba(80, 110, 175, .18);
}
[data-theme="light"] .hero::after {
  background: radial-gradient(circle at 26% 20%, rgba(255, 255, 255, .78) 0%, rgba(210, 226, 250, .24) 11%, transparent 19%);
}
.hero-main {
  position: relative; z-index: 1;
  padding: 26px 28px; max-width: 680px;
  display: flex; flex-direction: column; gap: 9px;
}
.hero-main h1 {
  margin: 0; font-size: 26px; font-weight: 700; line-height: 1.25;
  color: #fff;
}
[data-theme="light"] .hero-main h1 { color: var(--text); }
.hero-main p {
  margin: 0; font-size: 13.5px; line-height: 1.7; max-width: 46em;
  color: rgba(226, 234, 255, .78);
}
[data-theme="light"] .hero-main p { color: var(--text-2); }
.hero-actions { display: flex; gap: 9px; margin-top: 5px; flex-wrap: wrap; }
.hero-actions .btn {
  background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff;
  backdrop-filter: blur(6px);
}
.hero-actions .btn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.hero-actions .btn-primary { background: #fff; border-color: #fff; color: #16264d; }
.hero-actions .btn-primary:hover { background: #eef3ff; border-color: #eef3ff; color: #16264d; }
[data-theme="light"] .hero-actions .btn { background: rgba(255,255,255,.72); border-color: rgba(120,150,220,.3); color: var(--text-2); }
[data-theme="light"] .hero-actions .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 介绍横幅右上角的关闭按钮 */
.hero-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: rgba(255, 255, 255, .72);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  transition: background .16s, color .16s;
}
.hero-close:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.hero-close svg { width: 15px; height: 15px; }
[data-theme="light"] .hero-close {
  color: var(--text-2);
  background: rgba(255, 255, 255, .65);
  border-color: rgba(120, 150, 220, .28);
}
[data-theme="light"] .hero-close:hover { background: #fff; color: var(--text); }

/* 数据小卡 */
.hero-side { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-card b { font-size: 21px; font-weight: 700; line-height: 1.25; }
.stat-card span { font-size: 12px; color: var(--muted); }

/* ───────────── 版块卡片 ───────────── */

/* ───────────── 首页发帖框 ───────────── */

.composer { padding: 15px 16px; display: flex; flex-direction: column; gap: 12px; }
.composer-top { display: flex; align-items: center; gap: 11px; }
.composer-input {
  flex: 1; min-width: 0; text-align: left;
  padding: 10px 16px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  color: var(--muted); font-size: 13.5px;
  transition: border-color .16s, color .16s;
}
.composer-input:hover { border-color: var(--border); color: var(--text-2); }
.composer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  color: var(--text-2); font-size: 12.5px;
  transition: background .16s, color .16s, border-color .16s;
}
.composer-chip:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.composer-chip svg { width: 14px; height: 14px; }
.composer-send {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff;
  box-shadow: 0 4px 14px rgba(91, 124, 250, .35);
  transition: transform .16s, opacity .16s;
}
.composer-send:hover { transform: scale(1.05); }
.composer-send svg { width: 19px; height: 19px; stroke-width: 2.3; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 24px 0 12px;
}
.section-title h2 { margin: 0; font-size: 15.5px; font-weight: 650; }
.section-title a { font-size: 12.5px; color: var(--muted); }
.section-title a:hover { color: var(--accent); }

.board-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.board-card {
  display: flex; gap: 13px; padding: 15px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 13px;
  transition: border-color .16s, background .16s, transform .16s;
}
.board-card:hover { border-color: var(--border); background: var(--surface-2); transform: translateY(-1px); }
.board-icon {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 12px; display: grid; place-items: center;
  font-size: 20px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.board-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.board-meta strong { font-size: 14px; font-weight: 600; }
.board-meta p { margin: 0; font-size: 12.5px; color: var(--muted); }
.board-foot { display: flex; gap: 10px; font-size: 11.5px; color: var(--muted); }

/* ───────────── 帖子列表 ───────────── */

.thread-list { display: flex; flex-direction: column; }
.thread-item {
  display: flex; gap: 12px; padding: 15px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .16s;
}
.thread-item:last-child { border-bottom: none; }
.thread-item:hover { background: var(--surface-2); }
.thread-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.thread-title-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.thread-title { font-size: 14.5px; font-weight: 600; }
.thread-title:hover { color: var(--accent); }
.thread-preview { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.thread-foot { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.thread-foot .who { color: var(--accent); font-weight: 500; }

.thread-stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 50px; padding: 5px 8px; border-radius: 9px;
  background: var(--surface-2); flex-shrink: 0;
}
.thread-stat b { font-size: 14px; font-weight: 700; }
.thread-stat span { font-size: 10.5px; color: var(--muted); }

/* ───────────── 帖子详情 ───────────── */

.stack { display: flex; flex-direction: column; gap: 14px; }

.post {
  display: flex; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px;
}
.post-op { border-color: var(--border); }
.post-side { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 58px; flex-shrink: 0; }
.post-side .name { font-size: 11.5px; color: var(--text-2); text-align: center; line-height: 1.3; word-break: break-all; }
.post-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.post-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.post-body { font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.post-body a:hover { opacity: .82; }
.post-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.like-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 15px;
  border: 1px solid var(--border-soft); background: transparent;
  color: var(--muted); font-size: 12.5px;
  transition: all .16s;
}
.like-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.like-btn.on { border-color: var(--rose); color: var(--rose); background: var(--rose-soft); }
.like-btn svg { width: 14px; height: 14px; }
.like-btn.ai:hover { border-color: var(--accent-2); color: var(--accent-2); background: var(--accent-2-soft); }

.floor-tag {
  font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 1px 7px; border-radius: 5px; background: var(--surface-2);
}
.floor-tag.op { background: var(--accent-soft); color: var(--accent); }

.floor-no {
  font-size: 11.5px; color: var(--muted); padding: 1px 7px;
  border-radius: 5px; transition: background .15s, color .15s;
}
.floor-no:hover { background: var(--surface-2); color: var(--accent); }

/* 楼中楼引用 */
.quote-ref {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 6px 11px;
  border: 1px solid var(--border-soft); border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--surface-2);
  font-size: 12.5px; color: var(--text-2); cursor: pointer;
  text-align: left; transition: background .15s, border-color .15s;
  white-space: nowrap; overflow: hidden;
}
.quote-ref:hover { background: var(--accent-soft); border-color: var(--accent); }
.quote-ref svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--accent); }
.quote-name { color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }

/* 楼层内联编辑器 */
.floor-editor {
  margin-top: 11px; padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: 12px;
  animation: fade-in .16s ease-out;
}
.floor-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-2);
  min-width: 0;
}
.floor-editor-head > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floor-editor-head strong { color: var(--accent); }
.floor-editor-head .icon-btn { flex-shrink: 0; width: 28px; height: 28px; }
.floor-editor-head .icon-btn svg { width: 14px; height: 14px; }
.floor-editor .textarea { background: var(--surface); min-height: 74px; }

/* 跳转高亮 */
.post.flash { animation: floor-flash 1.6s ease-out; }
@keyframes floor-flash {
  0%   { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
  70%  { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
  100% { box-shadow: none; border-color: var(--border-soft); }
}

/* ───────────── 编辑器 / 表单 ───────────── */

.editor { display: flex; flex-direction: column; gap: 11px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.input, .textarea, .select {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.textarea { min-height: 100px; resize: vertical; line-height: 1.7; font-family: inherit; }
.textarea-lg { min-height: 150px; }
.input-sm { padding: 7px 11px; font-size: 13px; }
.hint { font-size: 11.5px; color: var(--muted); }
.error-text { font-size: 12.5px; color: var(--rose); }

.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* 密码强度条 */
.pw-meter { display: flex; gap: 4px; margin-top: 2px; }
.pw-meter i { flex: 1; height: 4px; border-radius: 2px; background: var(--border); transition: background .2s; }

/* ───────────── 侧栏列表 ───────────── */

.sidebar { display: flex; flex-direction: column; gap: 14px; }
.side-list { display: flex; flex-direction: column; }
.side-item {
  display: flex; gap: 11px; padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .16s;
}
.side-item:last-child { border-bottom: none; }
.side-item:hover { background: var(--surface-2); }
.side-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.side-title { font-size: 13px; font-weight: 550; }
.side-sub { font-size: 11.5px; color: var(--muted); }

/* ───────────── 空状态 / 分页 ───────────── */

.empty {
  padding: 52px 20px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-icon { font-size: 34px; opacity: .75; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 18px 0 4px; }
.pagination button {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text-2); font-size: 13px;
  transition: all .15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ───────────── 面包屑 / 页头 ───────────── */

.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .5; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 20px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px;
}
.page-head h1 { margin: 0 0 5px; font-size: 19px; font-weight: 700; }
.page-head p { margin: 0; font-size: 13px; color: var(--muted); }

/* ───────────── 标签页 ───────────── */

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
}
.tabs button {
  padding: 10px 6px; margin-right: 18px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; transition: color .16s, border-color .16s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ───────────── 登录页 ───────────── */

.auth-wrap { max-width: 400px; margin: 40px auto; }
.auth-card { padding: 26px; }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.auth-card > p { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.auth-switch { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 10px; margin-bottom: 20px; }
.auth-switch button {
  flex: 1; padding: 9px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: all .15s;
}
.auth-switch button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ───────────── AI 角色卡 ───────────── */

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(266px, 1fr)); gap: 14px; }
.char-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 11px;
  transition: border-color .16s, background .16s, transform .16s;
}
.char-card:hover { border-color: var(--border); background: var(--surface-2); transform: translateY(-2px); }
.char-top { display: flex; align-items: center; gap: 12px; }
.char-avatar {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 24px;
  background: var(--accent-2-soft);
}
.char-name { font-size: 15px; font-weight: 650; }
.char-traits { display: flex; flex-wrap: wrap; gap: 5px; }

/* 发现 AI / 我的 AI 卡片上的按钮行 */
.char-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.char-actions .btn { flex: 1; min-width: 96px; }
.char-card-mine { border-color: var(--accent); }
.trait {
  font-size: 11px; padding: 2px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border-soft);
}
.char-bio { font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.char-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--border-soft);
  font-size: 11.5px; color: var(--muted);
}

/* ───────────── 个人主页 ───────────── */

.profile-head {
  display: flex; align-items: center; gap: 18px; padding: 24px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; margin-bottom: 16px;
}
.profile-info { flex: 1; min-width: 0; }
.profile-info h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-info p { margin: 0; font-size: 13px; color: var(--text-2); }
.profile-stats { display: flex; gap: 24px; }
.profile-stats div { text-align: center; }
.profile-stats b { display: block; font-size: 19px; font-weight: 700; }
.profile-stats span { font-size: 11.5px; color: var(--muted); }

/* ───────────── 头像 ───────────── */

.profile-avatar { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avatar-btn {
  border: 0; padding: 0; cursor: pointer; font: inherit;
  transition: box-shadow .16s, transform .16s;
}
.avatar-btn:hover { box-shadow: 0 0 0 3px var(--accent-soft); transform: translateY(-1px); }
.avatar-xl { width: 104px; height: 104px; font-size: 44px; }
.avatar-view { display: flex; justify-content: center; margin-bottom: 14px; }

/* ───────────── 我的数字代理员 ───────────── */

.agent-facts { display: flex; gap: 22px; }
.agent-facts div { text-align: center; }
.agent-facts b { display: block; font-size: 17px; font-weight: 700; }
.agent-facts span { font-size: 11.5px; color: var(--muted); }

.agent-split {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 14px;
  font-size: 12.5px; font-weight: 650; color: var(--text-2);
}
.agent-split::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border-soft);
}

/* ───────────── 管理后台 ───────────── */

.admin-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 18px; align-items: start; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 76px; }
.admin-nav button {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 9px; text-align: left;
  font-size: 13.5px; color: var(--text-2); font-weight: 500;
  transition: background .16s, color .16s;
}
.admin-nav button:hover { background: var(--surface); color: var(--text); }
.admin-nav button.active { background: var(--accent); color: #fff; font-weight: 600; }
.admin-nav svg { width: 16px; height: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; }
.metric {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 14px 16px;
}
.metric b { display: block; font-size: 22px; font-weight: 700; line-height: 1.25; }
.metric span { font-size: 12px; color: var(--muted); }

.admin-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.admin-row:last-child { border-bottom: none; }
.admin-row .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* ───────────── 提示条 ───────────── */

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 11px;
  font-size: 12.5px; line-height: 1.65;
  border: 1px solid transparent;
}
.banner-warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.banner-info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }
.banner-ok   { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green); }
.banner-icon { font-size: 15px; line-height: 1.4; }

/* ───────────── Toast ───────────── */

.toast-host {
  position: fixed; top: 20px; right: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  min-width: 210px; max-width: 340px; padding: 12px 16px;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 11px; box-shadow: var(--shadow-lg);
  font-size: 13px; line-height: 1.55;
  animation: toast-in .22s ease-out;
}
.toast.ok  { border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.toast.err { border-color: color-mix(in srgb, var(--rose) 45%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ───────────── 弹窗 ───────────── */

.modal-mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4, 8, 18, .62);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 68px 20px 40px; overflow-y: auto;
  animation: fade-in .16s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: modal-in .2s ease-out;
}
.modal-narrow { max-width: 410px; }
.modal-wide { max-width: 660px; }

/* ───────────── 手机整屏发帖页（小红书式） ───────────── */

.compose-page {
  position: fixed; inset: 0; z-index: 85;
  /* 同上：手机浏览器底部工具栏盖住的是 100vh 那一截，用动态高度更稳 */
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  padding-top: env(safe-area-inset-top, 0px);
  animation: compose-in .22s ease-out;
}
@keyframes compose-in {
  from { transform: translateY(14px); opacity: .35; }
  to   { transform: none; opacity: 1; }
}

.compose-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}
.compose-cancel { font-size: 15px; color: var(--text-2); padding: 6px 2px; }

/* 发布页左上角关闭（×） */
.compose-close {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%; color: var(--text-2);
}
.compose-close:hover { background: var(--surface-2); color: var(--text); }
.compose-close svg { width: 20px; height: 20px; }

/* 「#话题 / @用户 / @AI」快捷入口 */
.compose-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.compose-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-2); font-size: 12.5px;
}
.compose-chip b { color: var(--accent); font-weight: 700; }
.compose-chip:hover { border-color: var(--accent); color: var(--accent); }

/* @ 提及面板 */
.mention-panel {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px; padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface);
}
.mention-tabs { display: flex; gap: 6px; }
.mention-tabs button {
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; color: var(--muted);
  background: var(--surface-2);
}
.mention-tabs button.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.mention-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 190px; overflow-y: auto;
}
.mention-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 9px; text-align: left;
}
.mention-row:hover { background: var(--surface-2); }
.mention-name { font-size: 13.5px; font-weight: 500; }
.mention-bio { flex: 1; min-width: 0; font-size: 11.5px; color: var(--muted); }
.compose-send { flex-shrink: 0; }
.compose-head { flex: 1; text-align: center; font-size: 15px; font-weight: 650; }
.compose-publish {
  padding: 8px 18px; border-radius: 999px;
  background: var(--grad); color: #fff;
  font-size: 14px; font-weight: 650;
  box-shadow: 0 4px 14px rgba(108, 99, 255, .28);
}
.compose-publish:disabled { opacity: .55; box-shadow: none; }

/* min-height:0 是必须的：不然中间内容会把底部工具条顶出屏幕 */
.compose-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 24px; }

.compose-board { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.compose-board > .muted { flex-shrink: 0; white-space: nowrap; }
.compose-board .select { height: 38px; padding: 0 12px; }

.pick-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin-top: 14px;
}
.pick-add {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}
.pick-add svg { width: 22px; height: 22px; }
.pick-add em { font-style: normal; }
.pick-add:active { background: var(--surface-3); }

/* 让缩略图直接排进上面的九宫格 */
.compose-page .attach-pending { display: contents; }
.compose-page .attach-thumb {
  width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: 12px;
}

.compose-title-input {
  width: 100%; margin-top: 16px; padding: 8px 0;
  border: none; background: transparent;
  font-size: 17px; font-weight: 650;
}
.compose-title-input:focus { outline: none; box-shadow: none; }
.compose-divider { height: 1px; background: var(--border-soft); margin: 2px 0 10px; }
/* 一行：左边头像，右边大输入框（X 那种） */
.compose-row { display: flex; gap: 10px; align-items: flex-start; }
.compose-avatar {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%; overflow: hidden;
  background: var(--surface-2); font-size: 20px;
}
.compose-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.compose-textarea {
  flex: 1; width: auto; min-height: 150px; padding: 4px 0;
  border: none; background: transparent;
  font-size: 17px; line-height: 1.7; resize: none;
}
.compose-textarea:focus { outline: none; box-shadow: none; }
.compose-count {
  flex-shrink: 0; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.compose-foot {
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 8px);
}
.compose-page .attach-bar { margin-top: 0; }
.compose-page .emoji-panel { margin: 0 0 8px; }

body.compose-open { overflow: hidden; }

/* 整屏弹出层（发帖页 / 聊天页）打开时，把「背后的页面」整体锁死。
   手机上键盘弹出后页面还能被单独上下拖，就是这一层没锁住。 */
html.page-locked, html.page-locked body { overflow: hidden; overscroll-behavior: none; }
html.page-locked body { position: fixed; left: 0; right: 0; width: 100%; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--border-soft); }

/* ───────────── 骨架屏 ───────────── */

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line { height: 12px; margin-bottom: 9px; }
.sk-title { height: 17px; width: 62%; margin-bottom: 12px; }

/* ───────────── 页脚 ───────────── */

.footer { margin-top: auto; }
.footer-inner {
  padding: 24px 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.footer-dot { opacity: .5; }

/* ───────────── 手机底部导航 ───────────── */

.tabbar { display: none; }

.tabbar a {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 2px 6px;
  color: var(--muted); font-size: 10.5px;
  -webkit-tap-highlight-color: transparent;
  transition: color .16s;
}
.tabbar a svg { width: 22px; height: 22px; stroke-width: 1.75; }
.tabbar a em { font-style: normal; line-height: 1.2; }
.tabbar a.active { color: var(--accent); font-weight: 600; }
.tabbar a.active svg { stroke-width: 2.1; }
.tab-dot {
  position: absolute; top: 6px; left: 50%; margin-left: 7px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--rose);
  border: 1.5px solid var(--surface);
}

/* 中间悬浮发帖按钮 */
.tab-compose {
  width: 52px; height: 52px; flex-shrink: 0;
  margin: -18px 6px 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 18px rgba(91, 124, 250, .45);
  transition: transform .16s;
}
.tab-compose:active { transform: scale(.94); }
.tab-compose svg { width: 24px; height: 24px; stroke-width: 2.4; }

/* ───────────── 安装引导条 ───────────── */

.install-bar {
  position: fixed; left: 12px; right: 12px; z-index: 45;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  /* 桌面端不显示，只在手机上和底部导航一起出现 */
  display: none; align-items: center; gap: 10px;
  padding: 11px 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in .24s ease-out;
}
.install-icon { font-size: 20px; line-height: 1; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.install-text strong { font-size: 13px; font-weight: 650; }
.install-text span { font-size: 11.5px; color: var(--muted); }
.install-close { width: 30px; height: 30px; flex-shrink: 0; }
.install-close svg { width: 15px; height: 15px; }

/* 关掉浏览器自带的下拉刷新，用我们自己的 */
body { overscroll-behavior-y: contain; }

/* ───────────── 手机下拉刷新 ───────────── */

.pull-hint {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 0; overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  color: var(--muted); font-size: 13px;
  pointer-events: none;
}
.pull-hint .pull-icon { font-size: 15px; line-height: 1; }
.pull-hint .pull-icon.spin { animation: pull-spin .8s linear infinite; }

@keyframes pull-spin { to { transform: rotate(360deg); } }

/* ───────────── 数字代理员卡片 ───────────── */

.assistant-card { padding: 16px; }
.assistant-head { display: flex; align-items: center; gap: 10px; }
.assistant-head strong { display: block; font-size: 14.5px; font-weight: 650; }
.assistant-orb {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 0 0 4px var(--accent-soft);
  position: relative;
}
.assistant-orb::after {
  content: ""; position: absolute; inset: 9px;
  border-radius: 50%; background: rgba(255, 255, 255, .9);
}
.assistant-body {
  margin: 12px 0 10px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 260px; overflow-y: auto;
}
.assistant-msg {
  padding: 9px 12px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.assistant-msg.bot {
  background: var(--surface-2); color: var(--text-2);
  border-bottom-left-radius: 4px; align-self: flex-start;
}
.assistant-msg.user {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px; align-self: flex-end;
}
.assistant-msg.pending { opacity: .6; }
.assistant-msg.error { background: var(--rose-soft); color: var(--rose); }

.assistant-input {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 4px 4px 4px 12px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 12px;
  transition: border-color .16s, box-shadow .16s;
}
.assistant-input:focus-within {
  border-color: var(--accent); box-shadow: var(--ring);
}
.assistant-input input {
  flex: 1; min-width: 0; height: 32px;
  background: none; border: none; outline: none;
  font-size: 12.5px;
}
.assistant-input input::placeholder { color: var(--muted); }
.assistant-input button {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 9px; background: var(--grad); color: #fff;
  transition: opacity .16s;
}
.assistant-input button:hover { opacity: .88; }
.assistant-input button svg { width: 15px; height: 15px; }
body.assistant-busy .assistant-input button { opacity: .5; }
.assistant-actions { display: flex; flex-direction: column; gap: 2px; }
.assistant-actions a,
.assistant-actions .assistant-ask {
  display: block; padding: 7px 10px; border-radius: 9px;
  width: 100%; text-align: left;
  font-size: 12.5px; color: var(--text-2);
  transition: background .16s, color .16s;
}
.assistant-actions a:hover,
.assistant-actions .assistant-ask:hover {
  background: var(--accent-soft); color: var(--accent);
}

/* 侧栏底部的下载入口 */
.rail-app {
  display: flex; align-items: center; gap: 7px;
  margin-top: 10px; padding: 6px 8px; border-radius: 9px;
  font-size: 12.5px; color: var(--text-2);
  transition: background .16s, color .16s;
}
.rail-app:hover { background: var(--accent-soft); color: var(--accent); }
.rail-app svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ───────────── 私信 ───────────── */

.msg-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .14s;
}
.msg-row:last-child { border-bottom: none; }
.msg-row:hover { background: var(--surface-2); }
.msg-body { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: center; gap: 6px; }
.msg-top strong { font-size: 14px; }
.msg-time { margin-left: auto; font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.msg-preview {
  margin-top: 3px; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-unread {
  flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--rose); color: #fff;
  font-size: 11.5px; display: grid; place-items: center;
}

.chat-card { display: flex; flex-direction: column; max-height: 70vh; }
.chat-back { display: none; }
.chat-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
}
.chat-body {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 240px;
}
.chat-empty { text-align: center; color: var(--muted); font-size: 13px; margin: auto; }
.chat-line { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.chat-line.mine { align-items: flex-end; }
.chat-bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 14px;
  background: var(--surface-2); font-size: 14px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.chat-line.mine .chat-bubble { background: var(--accent); color: #fff; }
.chat-time { font-size: 11px; color: var(--muted); padding: 0 4px; }

/* 私信里的图片 / 视频 / 表情 */
.chat-bubble.with-media { padding: 8px 10px; }
.chat-bubble .post-media {
  margin-top: 6px; max-width: 260px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.chat-bubble .post-media.one { max-width: 240px; grid-template-columns: minmax(0, 1fr); }
.chat-bubble .post-video { margin-top: 6px; max-width: 260px; }
.chat-bubble .post-video video { max-height: 260px; }
.chat-bubble.emoji-only {
  background: transparent; padding: 0 4px;
  font-size: 30px; line-height: 1.25;
}
.chat-line.mine .chat-bubble.emoji-only { background: transparent; color: inherit; }
.chat-attach {
  padding: 0 16px 8px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}
.chat-attach .attach-bar { margin-top: 10px; }
.chat-input {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--border-soft);
}
.chat-input .textarea { flex: 1; min-height: 46px; max-height: 140px; }
.chat-input .btn { flex-shrink: 0; height: 42px; }

/* ───────────── 上传附件（图片 / 视频 / 表情） ───────────── */

.attach-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px;
}
.attach-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 11px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  color: var(--text-2); font-size: 12.5px;
  transition: background .16s, color .16s, border-color .16s;
}
.attach-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.attach-btn svg { width: 15px; height: 15px; }
.attach-count { margin-left: auto; font-size: 11.5px; color: var(--muted); }

/* 拖拽文件进来时给个提示框 */
.dragging { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 12px; }

.attach-pending { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attach-thumb {
  position: relative; width: 84px; height: 84px;
  border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.attach-thumb img, .attach-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.attach-del {
  position: absolute; top: 4px; right: 4px;
  width: 21px; height: 21px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(10, 14, 24, .72); color: #fff;
}
.attach-del svg { width: 12px; height: 12px; }
.attach-busy {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(10, 14, 24, .55); color: #fff; font-size: 11.5px;
}

.emoji-panel {
  display: flex; flex-wrap: wrap; gap: 2px;
  margin-top: 10px; padding: 8px;
  max-height: 150px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.emoji-item {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  transition: background .12s;
}
.emoji-item:hover { background: var(--surface-3); }

/* 帖子里的图片 / 视频 */
.post-media {
  display: grid; gap: 6px; margin-top: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 420px;
}
.post-media.two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 300px; }
.post-media.one { grid-template-columns: minmax(0, 1fr); max-width: 380px; }
.media-cell {
  position: relative; display: block; overflow: hidden;
  border-radius: 10px; background: var(--surface-2);
  aspect-ratio: 1;
}
.post-media.one .media-cell { aspect-ratio: auto; }
.media-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-media.one .media-cell {
  display: grid; place-items: center; background: transparent;
}
.post-media.one .media-cell img {
  width: auto; height: auto;
  max-width: 100%; max-height: 520px;
  object-fit: contain;
}

.post-video { margin-top: 10px; max-width: 560px; }
.post-video video {
  width: 100%; max-height: 460px; display: block;
  border-radius: 12px; background: #000;
}

/* 信息流里的预览小一点 */
.thread-body .post-media { max-width: 260px; margin-top: 8px; }
.thread-body .post-video { max-width: 320px; margin-top: 8px; }

/* 点开看大图 */
.lightbox {
  position: fixed; inset: 0; z-index: 130;
  display: grid; place-items: center; padding: 24px;
  background: rgba(4, 8, 18, .92);
  animation: fade-in .16s ease-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox-close {
  position: absolute; right: 18px;
  top: calc(18px + env(safe-area-inset-top, 0px));
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); color: #fff;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .24); }
.lightbox-close svg { width: 18px; height: 18px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ───────────── 工具类 ───────────── */

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hidden { display: none !important; }

/* ───────────── 长期指令（我的数字代理员） ───────────── */

.dir-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 11px 0; border-top: 1px solid var(--border-soft);
}
.dir-row:first-child { border-top: none; }
.dir-row .btn { flex-shrink: 0; }
.dir-text {
  margin-top: 5px; font-size: 13.5px; line-height: 1.65;
  word-break: break-word; color: var(--text);
}

/* 代理员和别人的私聊记录（只读） */
.msg-row-plain { cursor: default; }

/* 点数字看「谁赞了」 */
.like-count { text-decoration: underline dotted; text-underline-offset: 3px; }
.liker-list { display: flex; flex-direction: column; }
.liker-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border-soft);
}
.liker-row:last-child { border-bottom: none; }

.chat-log {
  display: flex; flex-direction: column; gap: 14px;
  max-height: 62vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
}
.chat-log .chat-bubble { background: var(--surface); box-shadow: var(--shadow-sm); }
.chat-log .chat-line.mine .chat-bubble { background: var(--accent); box-shadow: none; }
.chat-log .chat-line.mine .chat-bubble.emoji-only { background: transparent; }

/* ───────────── 响应式 ───────────── */

/* 中等屏幕：收窄右侧栏 */
@media (max-width: 1320px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr) 268px; gap: 20px; }
}

/* 小笔记本 / 平板横屏：隐藏右侧栏，左侧只留图标 */
@media (max-width: 1160px) {
  .layout { grid-template-columns: 68px minmax(0, 1fr); gap: 18px; padding: 0 18px; }
  .rail-right { display: none; }
  .rail { align-items: center; }
  .brand { justify-content: center; padding: 0; }
  .brand-text { display: none; }
  .rail-nav { width: 100%; align-items: center; }
  .rail-nav a { justify-content: center; padding: 11px 0; width: 44px; }
  .rail-nav a span { display: none; }
  .rail-badge { left: 24px; top: 6px; }
  .rail-section, .rail-foot { display: none; }
  .board-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 手机：底部导航 + 单栏 */
@media (max-width: 880px) {
  .layout { display: block; padding: 0 14px; }
  .rail { display: none; }

  /* 手机上顶栏用实色，别让下面的卡片透过来显得像一块空白 */
  .topbar {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 0 10px;
    gap: 8px;
    background: var(--bg);
    backdrop-filter: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .rail-toggle { display: grid; }
  .searchbar { max-width: none; min-width: 0; }
  .searchbar input { height: 40px; }
  .topbar-actions { gap: 6px; }
  .topbar-user { gap: 6px; }
  .topbar-user .btn { padding: 0 10px; }

  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }

  .tabbar {
    display: flex; align-items: flex-start;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border-soft);
  }

  .footer { display: none; }
  .app { padding: 16px 0 28px; }

  /* iOS 输入框小于 16px 会触发缩放 */
  .searchbar input, .input, .select { font-size: 16px; }
  .textarea { font-size: 16px; }
  .searchbar input { font-size: 15px; }

  /* 手机上触摸目标放大 */
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
  .like-btn { height: 34px; padding: 0 13px; }
  .tabs button { padding: 12px 4px; }
  .pagination button { min-width: 40px; height: 40px; }

  .hero { min-height: 210px; border-radius: 14px; }
  .hero-main { padding: 22px 20px; }
  .hero-main h1 { font-size: 22px; }
  .hero-main p { font-size: 13px; }
  .hero-side { grid-template-columns: repeat(2, 1fr); }
  .stat-card b { font-size: 19px; }

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

  .profile-head { flex-direction: column; align-items: flex-start; }
  .profile-stats { width: 100%; justify-content: space-between; }
  .post { padding: 15px; gap: 11px; border-radius: 12px; }
  .post-side { width: 46px; }
  .thread-item { padding: 14px; gap: 10px; }
  .card { border-radius: 13px; }

  .post-media, .post-media.two, .post-media.one { max-width: 100%; }
  .post-video { max-width: 100%; }
  .thread-body .post-media, .thread-body .post-video { max-width: 100%; }
  .attach-thumb { width: 72px; height: 72px; }
  .emoji-item { width: 36px; height: 36px; font-size: 20px; }
  /* ── 手机端聊天页：整屏，像聊天软件那样 ── */
  body.chat-open { overflow: hidden; }
  body.chat-open .topbar,
  body.chat-open .tabbar,
  body.chat-open .install-bar,
  body.chat-open .rail,
  body.chat-open .rail-right,
  body.chat-open .footer,
  body.chat-open .crumbs { display: none !important; }

  .chat-card {
    position: fixed;
    top: 0; left: 0; right: 0;
    /* 100vh 在手机上是最「高」的可视区，底部工具栏弹出来时会盖住输入框，
       所以第二行用动态可视高度（不支持的浏览器自动用上一行的 100vh） */
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: none; border-radius: 0;
    background: var(--bg);
    padding-top: env(safe-area-inset-top, 0px);
    z-index: 55;
  }
  /* 头和底部不参与压缩：屏幕矮/键盘高的时候只压中间的消息区，
     否则最下面的输入框会被挤掉一截 */
  .chat-head { padding: 10px 12px; background: var(--surface); flex-shrink: 0; }
  .chat-foot { flex-shrink: 0; }
  .chat-back { display: grid; }
  .chat-body {
    min-height: 0; max-height: none;
    padding: 14px 12px;
    background: var(--bg-soft);
  }
  /* 对方的气泡用白底 + 轻阴影，和自己的紫色气泡区分开 */
  .chat-bubble {
    max-width: 84%;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .chat-line.mine .chat-bubble { background: var(--accent); box-shadow: none; }
  .chat-line.mine .chat-bubble.emoji-only { background: transparent; }
  .chat-foot {
    background: var(--surface);
    border-top: 1px solid var(--border-soft);
    /* 键盘弹出时只把输入区垫到键盘上沿，面板本身还是铺满整屏（底下不透光） */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--kb, 0px));
    transition: padding-bottom .18s ease-out;
  }
  .chat-attach { padding: 6px 10px 0; border-top: none; background: transparent; }
  .chat-attach .attach-bar { margin-top: 0; gap: 6px; }
  .chat-attach .attach-btn { height: 30px; padding: 0 10px; font-size: 12px; }
  .chat-attach .attach-label { display: none; }
  .chat-input { padding: 8px 10px 10px; }
  .chat-input .textarea { min-height: 40px; max-height: 96px; }
  .chat-input .btn { height: 40px; }

  .toast-host { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); right: 14px; left: 14px; }
  .toast { max-width: none; }

  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none; border-radius: 18px 18px 0 0;
    /* 用百分比而不是 vh：键盘弹出、可视区域变矮时它也会跟着变矮 */
    max-height: 88%; overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-wide, .modal-narrow { max-width: none; }

  /* 手机上弹窗可能比可视区域还高：标题和底部按钮固定住，
     中间的内容自己滚动，这样键盘弹出来也能点到「发布」 */
  .modal-head {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
  }
  .modal-foot {
    position: sticky; bottom: 0; z-index: 2;
    background: var(--surface);
  }

  /* 发帖框矮一点，键盘弹出来之后还能看到「发布」按钮 */
  .textarea-lg { min-height: 104px; }

  /* 手机端发布页：底部工具条只留图标，右边一个发布 */
  .compose-page .attach-btn { height: 34px; padding: 0 10px; }
  .compose-page .attach-label { display: none; }
  .compose-page .attach-bar { gap: 6px; }
  .compose-page .mention-list { max-height: 150px; }
  /* 正文框别太长：默认 110px，跟着内容长到屏幕 40% 就内部滚动 */
  .compose-page .compose-textarea {
    min-height: 110px; max-height: 40vh; overflow-y: auto;
  }
  .compose-page .compose-title-input { margin-top: 12px; }
  .compose-page .compose-body { padding: 12px 14px 16px; }
  /* 同上：底部工具条跟着键盘走，容器不动，所以不会有透明缝隙和整页滚动 */
  .compose-page .compose-foot {
    padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 6px + var(--kb, 0px));
    transition: padding-bottom .18s ease-out;
  }
  /* 整屏页自己不吃「链式滚动」，中间的内容区照常滚 */
  .compose-page, .chat-card { overscroll-behavior: none; }
  .compose-page .compose-body,
  .chat-card .chat-body,
  .compose-page .emoji-panel,
  .compose-page .mention-list { overscroll-behavior: contain; }

  .install-bar { display: flex; bottom: calc(env(safe-area-inset-bottom, 0px) + 82px); }

  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .admin-nav button { white-space: nowrap; }

  /* 手机端：左侧导航做成抽屉 */
  /* 底部标签栏已经有了，抽屉里不再重复显示这几个入口 */
  .rail-nav a[data-nav="home"],
  .rail-nav a[data-nav="boards"],
  .rail-nav a[data-nav="notifications"],
  .rail-nav a[data-nav="me"] { display: none; }

  body.rail-open .rail {
    display: flex;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 70;
    width: min(280px, 82vw);
    padding: calc(22px + env(safe-area-inset-top, 0px)) 16px 20px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: rail-in .2s ease-out;
    overflow-y: auto;
  }
  /* 抽屉右上角的关闭按钮 */
  body.rail-open .rail-close {
    display: grid; place-items: center;
    position: absolute; top: 16px; right: 12px;
    width: 34px; height: 34px; border-radius: 50%;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: background .16s, color .16s;
  }
  body.rail-open .rail-close:hover { background: var(--surface-3); color: var(--text); }
  body.rail-open .rail-close svg { width: 16px; height: 16px; }
  body.rail-open .brand { justify-content: flex-start; padding: 0 40px 0 8px; }
  body.rail-open .brand-text { display: flex; }
  body.rail-open .rail-nav { align-items: stretch; width: auto; }
  body.rail-open .rail-nav a { justify-content: flex-start; padding: 10px 12px; width: auto; }
  body.rail-open .rail-nav a span { display: inline; }
  body.rail-open .rail-section { display: block; flex: none; }
  body.rail-open .rail-foot { display: block; }
  body.rail-open::after {
    content: ""; position: fixed; inset: 0; z-index: 65;
    background: rgba(4, 8, 18, .5);
  }
}

@keyframes rail-in { from { transform: translateX(-100%); } to { transform: none; } }

@media (max-width: 420px) {
  .hero-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thread-stat { display: none; }
  .page-head { padding: 16px; flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 18px; }
  .page-head .btn { width: 100%; }
}

/* 已安装为 App 时隐藏安装条 */
body.standalone .install-bar { display: none !important; }

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
