/* ============================================================
   layout: 三栏骨架 / 侧栏 / 底部标签栏 / 响应式
   ============================================================ */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, var(--main-w)) var(--aside-w);
  max-width: calc(var(--rail-w) + var(--main-w) + var(--aside-w));
  margin: 0 auto;
  min-height: 100dvh;
  align-items: start;
}
.shell[hidden] { display: none; }

/* 没有右栏的页面也保留同样的栏宽：
   否则从「广场」切到「消息」时整页会横向收缩、左栏右移，看起来像页面在变大变小。
   aside 元素隐藏后该列自然留白，但主栏的 x 坐标与宽度完全一致。 */
.shell.no-aside {
  grid-template-columns: var(--rail-w) minmax(0, var(--main-w)) var(--aside-w);
  max-width: calc(var(--rail-w) + var(--main-w) + var(--aside-w));
}
/* 详情类页面（会话、帖子、长帖、主页、话题、法务）走更宽的两栏 */
.shell.is-wide {
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  max-width: calc(var(--rail-w) + 760px);
}
.shell.is-wide .main { border-right: none; }

@media (max-width: 1120px) {
  .shell.no-aside .main { border-right: 1px solid var(--line); }
}

/* ---------- 左侧导航 ---------- */
.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 16px 20px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 4px;
}
.brand__mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  box-shadow: 0 8px 22px -12px rgba(91, 124, 255, .85);
  flex: none;
}
.brand__mark .logo-svg { display: block; width: 100%; height: 100%; }
.brand__text { display: grid; line-height: 1.05; }
.brand__text b { font-size: 16px; letter-spacing: .12em; }
.brand__text i {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .34em;
  color: var(--faint);
  margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: 13px;
  color: var(--text-2);
  font-size: 14.5px;
  transition: background .2s var(--ease), color .2s;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--spectrum);
}
.nav__icon { width: 20px; text-align: center; font-size: 16.5px; opacity: .78; transition: opacity .2s, color .2s; }
.nav__item.is-active .nav__icon { opacity: 1; color: var(--accent); }
.nav__label { flex: 1; }
.nav__badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
}
.nav__badge--dot { width: 8px; min-width: 8px; height: 8px; padding: 0; background: var(--accent); }

.rail__foot { margin-top: auto; display: grid; gap: 10px; }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--dim);
  font-size: 12.5px;
  transition: background .2s, color .2s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle__icon { font-size: 15px; }

.me-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .2s, background .2s;
}
.me-mini:hover { border-color: var(--line-2); background: var(--surface-2); }
.me-mini__body { min-width: 0; flex: 1; }
.me-mini__name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-mini__meta { font-size: 11px; color: var(--faint); }

/* ---------- 主栏 ---------- */
.main {
  min-height: 100dvh;
  border-right: 1px solid var(--line);
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
}
.main > * { flex: none; }

.view-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px 22px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.view-head__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .01em;
}
.view-head__sub { font-size: 11.5px; color: var(--faint); letter-spacing: .04em; }
.view-head__tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.page { padding: 18px 22px 40px; }
.page--flush { padding: 0 0 40px; }

/* ---------- 右栏 ---------- */
.aside {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  padding: 22px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.aside__block { display: grid; gap: 12px; }
.aside__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--faint);
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* ---------- 底部标签栏（移动端） ---------- */
.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
}
.tabbar__item {
  flex: 1;
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--faint);
  font-size: 10px;
  position: relative;
  padding-top: 7px;
}
.tabbar__item span:first-child { font-size: 19px; line-height: 1; }
.tabbar__item.is-active { color: var(--text); }
.tabbar__item.is-active span:first-child {
  background: var(--spectrum);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tabbar__item .nav__badge { position: absolute; top: 3px; right: 50%; margin-right: -22px; }
.tabbar__item--center span:first-child {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--spectrum);
  color: #fff !important;
  font-size: 17px;
  margin-top: -14px;
  box-shadow: 0 10px 26px -10px rgba(139, 92, 255, .95);
}

/* ---------- 断点 ---------- */
@media (max-width: 1280px) {
  :root { --rail-w: 228px; --aside-w: 286px; --main-w: 620px; }
}

@media (max-width: 1120px) {
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); max-width: calc(var(--rail-w) + 760px); }
  .aside { display: none; }
  .main { border-right: none; }
}

@media (max-width: 860px) {
  .shell,
  .shell.no-aside {
    grid-template-columns: minmax(0, 1fr);
    max-width: 100%;
    min-height: 100dvh;
  }
  .rail { display: none; }
  .tabbar { display: flex; }
  .main {
    min-height: 100dvh;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    border-right: none;
  }
  .view-head { padding: 11px 16px; min-height: 56px; }
  .view-head__title { font-size: 18px; }
  .page { padding: 14px 14px calc(30px + env(safe-area-inset-bottom)); }
  .page--flush { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

@media (min-width: 861px) {
  .tabbar { display: none; }
  .mobile-only { display: none !important; }
}
@media (max-width: 860px) {
  .desktop-only { display: none !important; }
}
