/* ==========================================================================
   双栏外壳：左侧会话列表（固定 320px）+ 右侧聊天面板
   桌面专用；窄于 880px 时侧栏收窄，< 720px 只显示一栏（手机版另有原生应用）
   ========================================================================== */

:root {
  --sidebar-width: 320px;
  /* 和 tokens.css 里那份是同一个值，改要一起改（同一选择器，这份后加载所以它生效）。
     顶栏里除了标题还有一行 meta，再加 32px 的任务头像，整块高 48.6px ——
     52px 时上下只剩 1.7px，看着就像头像贴着浏览器顶边 */
  --nav-height: 68px;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  /* 行高必须钉死成 1fr。只写 height:100% 时这一行是隐式 auto 行，
     会被两栏的内容顶高（grid 项默认 min-height:auto，不会缩），
     于是 .chat/.sidebar 跟着长到内容高，里面的 overflow 滚动条全成了摆设，
     变成整个文档在滚 —— 而且 body 是 overflow:hidden，滚轮还拉不回来。
     minmax(0, 1fr) 里的 0 是关键，写成 1fr 同样会被 min-height:auto 顶破 */
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--c-canvas);
}

/* ---------------- 侧栏 ---------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--c-grouped-bg);
  border-right: 1px solid var(--c-hairline);
}

.nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  height: var(--nav-height);
  padding: 0 var(--sp-sm) 0 var(--sp-md);
  background: var(--c-surface);
}

/* 侧栏与聊天面板的标题栏共用：带毛玻璃，滚动内容从下面穿过 */
.nav--blur {
  background: color-mix(in srgb, var(--c-surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
}

.nav__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.3px;
}

.nav__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav__sub {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-fine);
  font-weight: var(--fw-regular);
  color: var(--c-secondary);
  letter-spacing: 0;
}

/* 会话列表这一整块。和「个人中心」二选一显示，所以两者都是这个位置的一份内容 */
.sidebar__view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 搜索区 + 分段筛选，浅灰底贴在侧栏顶部 */
.sidebar__tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  padding: var(--sp-xs) var(--sp-sm) var(--sp-sm);
}

.sidebar__list {
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: var(--sp-sm);
}

.sidebar__section {
  padding: var(--sp-xs) var(--sp-md) 2px;
  font-size: var(--fs-fine);
  font-weight: var(--fw-semibold);
  color: var(--c-secondary);
  letter-spacing: 0;
}

/* ---------------- 底部导航栏（首页 / 个人中心） ---------------- */

.tabbar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  height: 52px;
  border-top: 1px solid var(--c-hairline);
  background: var(--c-surface);
}

.tabbar__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--c-tertiary);
  font: inherit;
  font-size: var(--fs-fine);
  cursor: pointer;
}

.tabbar__btn:hover {
  color: var(--c-ink);
}

/* 选中态用主色。这里不改字形粗细：中文加粗之后宽度会跳一下 */
.tabbar__btn[aria-selected='true'],
.tabbar__btn[aria-selected='true']:hover {
  color: var(--c-primary);
}

.tabbar__icon {
  width: 20px;
  height: 20px;
}

/* ---------------- 聊天面板 ---------------- */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--c-canvas);
  position: relative;
}

.chat__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  height: var(--nav-height);
  padding: 0 var(--sp-md);
  border-bottom: 1px solid var(--c-hairline);
  background: var(--c-surface);
}

.chat__heading {
  flex: 1;
  min-width: 0;
}

.chat__title {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.2px;
}

.chat__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-top: 1px;
  font-size: var(--fs-fine);
  color: var(--c-secondary);
  letter-spacing: 0;
}

.chat__meta-dot::before {
  content: '·';
  margin-right: var(--sp-xs);
}

/* 在线人数：绿点跟着文字颜色走（深色主题下自动换成更亮的那支绿） */
.meta__online {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--c-status-done);
}

.meta__online::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chat__scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--sp-md) var(--sp-lg) var(--sp-xs);
}

.chat__composer {
  flex: 0 0 auto;
  padding: var(--sp-xs) var(--sp-lg) var(--sp-md);
  background: var(--c-canvas);
}

/* ---------------- 空态占位（未选中会话时） ---------------- */

.chat__placeholder {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  color: var(--c-secondary);
}

.chat__placeholder-icon {
  width: 64px;
  height: 64px;
  color: var(--c-disabled);
}

.chat__placeholder-icon svg {
  width: 100%;
  height: 100%;
}

.chat__placeholder-title {
  font-size: var(--fs-lead);
  font-weight: var(--fw-semibold);
  color: var(--c-ink);
  letter-spacing: -0.4px;
}

/* ---------------- 响应式收缩 ---------------- */

@media (max-width: 880px) {
  :root {
    --sidebar-width: 264px;
  }

  .chat__scroll,
  .chat__composer {
    padding-left: var(--sp-md);
    padding-right: var(--sp-md);
  }
}

@media (max-width: 720px) {
  /* 单栏：默认显示侧栏，选中会话后加 .app--reading 切到聊天 */
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .app:not(.app--reading) .chat {
    display: none;
  }

  .app--reading .sidebar {
    display: none;
  }

  .chat__back {
    display: inline-flex;
  }
}

.chat__back {
  display: none;
}
