/* 应用外壳：侧边栏 / 顶栏 / 视图容器 */
/* 侧边栏默认是一条 72px 的窄轨（见 tokens 里的 --sidebar-w），
   展开时**浮在内容之上**，所以主区用 padding-left 留出窄轨的位置，
   而不是让 flex 去挤 —— 首页那块银河画布一被挤就要 resize 重排，动画会抖 */
.app {
  display: flex; height: 100%; overflow: hidden;
  padding-left: var(--sidebar-w);
  transition: padding-left 0.34s var(--ease-out);
}

/* ── 侧边栏 ───────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 10px 12px;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--line);
  overflow-x: hidden; overflow-y: auto;
  transition: width 0.34s var(--ease-out), box-shadow 0.34s var(--ease-out), transform var(--dur) var(--ease);
}
/* 展开：鼠标移上去的「探头」，或点了图钉钉住 */
.sidebar.is-wide { width: var(--sidebar-w-open); box-shadow: var(--shadow-pop); }
.sidebar.is-pinned { box-shadow: none; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 6px 14px;
  white-space: nowrap;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: block; object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.34s var(--ease-out);
}
.sidebar.is-wide .brand-logo { transform: scale(1.04); }
/* 品牌文字也只在展开时露出来 —— 否则窄轨里会挤出半个「见」字，像个渲染 bug */
.brand-text {
  min-width: 0; flex: 1;
  opacity: 0; transform: translateX(-6px);
  transition: opacity 0.16s var(--ease), transform 0.24s var(--ease-out);
}
.sidebar.is-wide .brand-text { opacity: 1; transform: none; transition-delay: 0.04s; }
.brand-name { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub {
  font-size: 11px; color: var(--text-3); letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 图钉：折叠时朝右（提示「可以展开」），钉住时转 180° */
.side-pin {
  flex: none; width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-4);
  opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast), background var(--dur-fast), transform 0.34s var(--ease-out);
}
.sidebar:hover .side-pin, .sidebar.is-pinned .side-pin { opacity: 1; }
.side-pin:hover { color: var(--text); background: var(--bg-hover); }
.sidebar.is-pinned .side-pin { color: var(--accent); transform: rotate(180deg); }

.nav-group {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 10px 6px; height: 30px;
  font-size: 11px; font-weight: 600; color: var(--text-4); letter-spacing: 0.06em;
  white-space: nowrap;
}
.nav-group-text { opacity: 0; transform: translateX(-4px); transition: opacity 0.16s var(--ease), transform 0.22s var(--ease-out); }
.nav-group-line { flex: 1; height: 1px; background: var(--line); opacity: 0; transition: opacity 0.16s var(--ease); }
.sidebar.is-wide .nav-group-text { opacity: 1; transform: none; transition-delay: 0.06s; }
.sidebar.is-wide .nav-group-line { opacity: 1; transition-delay: 0.06s; }
/* 折叠时分组只剩一条细线做分隔 */
.sidebar:not(.is-wide) .nav-group { padding: 8px 6px 4px; }
.sidebar:not(.is-wide) .nav-group-line { opacity: 1; background: var(--line-strong); }

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
/* 选中态：左侧一条会「长出来」的竖条 */
.nav-item::before {
  content: ""; position: absolute; left: 2px; top: 50%; width: 3px; height: 0;
  border-radius: 99px; background: var(--accent);
  transform: translateY(-50%);
  transition: height 0.28s var(--ease-out), opacity 0.2s var(--ease);
  opacity: 0;
}
.nav-item.is-active::before { height: 18px; opacity: 1; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item:active { transform: scale(0.985); }
.nav-item.is-active { background: var(--bg-active); color: var(--text); font-weight: 600; }
.nav-item .icon { color: var(--text-3); transition: color var(--dur-fast), transform 0.28s var(--ease-out); }
.nav-item:hover .icon { transform: scale(1.08); }
.nav-item.is-active .icon { color: var(--accent); }
.nav-ico { display: inline-flex; flex: none; width: 22px; justify-content: center; }
/* 文字：折叠时缩起来，展开时逐条错开淡入（--i 是序号） */
.nav-label {
  min-width: 0;
  opacity: 0; transform: translateX(-8px);
  transition: opacity 0.14s var(--ease), transform 0.24s var(--ease-out);
}
.sidebar.is-wide .nav-label { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 16ms); }
.nav-item .nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-3);
  background: var(--bg-input); border-radius: 99px; padding: 1px 7px; min-width: 20px; text-align: center;
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.16s var(--ease), transform 0.24s var(--ease-out);
}
.sidebar.is-wide .nav-item .nav-badge { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 16ms + 40ms); }

.sidebar-spacer { flex: 1; }

/* 用户卡片 */
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast);
}
.user-card:hover { background: var(--bg-hover); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--purple));
  user-select: none;
  transition: transform 0.28s var(--ease-out);
}
.user-card:hover .avatar { transform: scale(1.08); }
.user-meta { min-width: 0; opacity: 0; transform: translateX(-6px); transition: opacity 0.16s var(--ease), transform 0.24s var(--ease-out); }
.sidebar.is-wide .user-meta { opacity: 1; transform: none; transition-delay: 0.08s; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-actions { display: flex; gap: 4px; padding: 6px 4px 0; }
.side-actions .btn-quiet { flex: 1; justify-content: center; min-width: 0; }
.side-actions .btn-quiet .icon { flex: none; }
.sidebar:not(.is-wide) .side-actions .nav-label { display: none; }

/* 动效关掉时：只留状态切换，不做过渡 */
@media (prefers-reduced-motion: reduce) {
  .app, .sidebar, .brand-logo, .brand-text, .nav-item, .nav-item::before, .nav-label, .nav-badge,
  .user-meta, .avatar, .side-pin, .nav-group-text, .nav-group-line { transition: none !important; }
}

/* ── 主区 ───────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  z-index: 30;
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title h2 { font-size: 16px; letter-spacing: -0.015em; }
.topbar-title span { font-size: 11.5px; color: var(--text-3); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.menu-btn { display: none; }

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}
.view-inner { max-width: var(--content-max); margin: 0 auto; padding: 28px 24px 72px; }
.view-inner.wide { max-width: 1280px; }
.view-inner.flush { max-width: none; padding: 0; }

/* 页面切换动画 */
.view-anim { animation: viewIn 0.34s var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 遮罩（移动端抽屉 / 弹窗） */
.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s var(--ease);
}

/* 页面头（栏目页统一） */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .ph-text { flex: 1; min-width: 220px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { color: var(--text-3); font-size: 13px; max-width: 62ch; }
.page-head .ph-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 30px 0 12px;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  letter-spacing: 0.02em; text-transform: uppercase;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

@media (max-width: 900px) {
  /* 手机上侧边栏本来就是抽屉（由「菜单」按钮开关），
     所以窄轨那套 padding / 展开逻辑都要关掉，抽屉打开时直接铺满宽度 */
  .app { padding-left: 0; }
  .sidebar {
    width: var(--sidebar-w-open);
    transform: translateX(-102%);
    box-shadow: var(--shadow-pop);
    padding-top: 18px;
  }
  .sidebar.is-open { transform: none; }
  .sidebar .nav-label, .sidebar .nav-group-text, .sidebar .user-meta, .sidebar .nav-badge,
  .sidebar .brand-text, .sidebar .nav-group-line, .sidebar .side-pin { opacity: 1; transform: none; }
  .sidebar .side-pin { display: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 14px; }
  .view-inner { padding: 20px 16px 80px; }
  .page-head h1 { font-size: 24px; }
}
