/* ============================================================
   QB · 基础：reset · 玻璃拟态工作台壳 · 响应式
   背景：淡蓝渐变 + 两团极淡色雾；表面：磨砂白
   注意：本文件及全站禁用位移动画，只做颜色过渡
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { text-rendering: optimizeLegibility; scrollbar-gutter: stable; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.006em;
  color: var(--text-1);
  /* 2026-09-14 滚动性能：body 背景层跟随滚动（scroll），不再用 background-attachment:fixed。
   * fixed 背景是浏览器里最贵的"伪视差"——每次滚动都要整页重绘（chromium 里固定背景
   * 无法进入滚动合成层，逐帧 repaint）。顶部的两团径向渐变本来就钉在页首（gradient 尺寸
   * 定位 y=-6%），scroll 下引用 box 顶部 = 页首，固定层只是"滚出视口"，观感差别≈0。 */
  background:
    radial-gradient(720px 380px at 8% -6%, rgba(37, 99, 235, .09), transparent 65%),
    radial-gradient(760px 420px at 104% 4%, rgba(124, 58, 237, .08), transparent 65%),
    linear-gradient(180deg, #eaf1fe 0%, #eaf1fe 240px, var(--bg) 520px, var(--bg) 100%);
  /* scroll 下渐变速按文档盒子定位：径向渐变是显式像素尺寸、天然免疫长页拉伸；
   * 线性渐变改用固定像素停靠点（240px 内保持页首蓝、520px 处退到底色），
   * 不再用 46% 这类百分比（长页会把渐变纵向拉直、首屏蓝底观感漂移）。 */
  background-color: var(--bg, #f3f6fc);
  background-attachment: scroll;
  background-repeat: no-repeat; /* 显式尺寸渐变 + repeat 默认会贴瓷砖，滚动时瓷砖缝扫过成线 */
  -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] body {
  background:
    radial-gradient(720px 380px at 8% -6%, rgba(79, 140, 255, .12), transparent 65%),
    radial-gradient(760px 420px at 104% 4%, rgba(167, 139, 250, .1), transparent 65%),
    linear-gradient(180deg, #101a33 0%, #101a33 240px, var(--bg) 520px, var(--bg) 100%);
  background-color: var(--bg, #0c1322);
  background-attachment: scroll;
  background-repeat: no-repeat; /* 同上 */
}

::selection { background: var(--brand-100); color: var(--brand-700); }
[data-theme="dark"] ::selection { background: rgba(79,140,255,.35); color: #fff; }
/* 键盘焦点环：box-shadow 会自动贴合元素自身圆角，**不要**在这里写 border-radius，
 * 否则任何被键盘聚焦的元素圆角都被强制改成 8px（btn/chip/opt 的圆角各不相同）→ 边缘跳变。
 * 只在精确指针（鼠标/键盘）设备显示：触屏点按不应闪蓝环（rgba(37,99,235,.13)），
 * 按压反馈交给各组件的 :active 缩放即可。 */
@media (hover: hover) and (pointer: fine) {
  :focus-visible { outline: none; box-shadow: var(--ring); }
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 应用壳 ---------- */
.shell { display: flex; min-height: 100vh; }

/* ---------- 侧栏（磨砂 · 自动隐藏：靠近左缘滑出，图标+文字一起出来） ---------- */
.rail-hot {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 10px; z-index: 65; /* 2026-09-13 用户嫌左热区大：16→10px，近缘预唤出补覆盖 */
}
/* 左缘微光提示条：告知"这里有入口"（纯装饰，不挡点击） */
.rail-hot::after {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 3px; height: 72px; border-radius: 999px;
  background: linear-gradient(180deg, transparent, var(--brand-500), transparent);
  opacity: .45;
  pointer-events: none;
}
.sidebar {
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  height: 100vh; height: 100dvh;   /* dvh：手机地址栏收放不再让抽屉跟着伸缩 */
  z-index: 70;
  transform: translateX(-103%);
  transition: transform .24s cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
  box-shadow: none;
}
/* 悬停热区 / 悬停栏体 / 键盘聚焦 / 移动端 .open / 点击钉住 .pinned → 滑出 */
.rail-hot:hover + .sidebar,
.sidebar:hover,
.sidebar:focus-within,
.sidebar.pinned,
body.sidepeek .sidebar,
body.sidebridge .sidebar,
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-3); }

.brand { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 18px 16px 12px; cursor: pointer; user-select: none; }
/* 品牌 logo：渐变徽章（图标自带底色，此处只定尺寸） */
.brand-logo {
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
}
.brand-logo svg { width: 30px; height: 30px; }
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }

.nav { flex: 1; padding: 8px 12px 12px; overflow-y: auto; }
.nav-group {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .1em;
  margin: 16px 10px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-group::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 7px 12px 7px 8px;
  margin: 2px 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
/* 彩色图标砖 */
.nav-tile {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  background: var(--tile-blue-bg);
  color: var(--tile-blue-fg);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-tile svg { width: 18px; height: 18px; }
.nav-item[data-tone="violet"] .nav-tile { background: var(--tile-violet-bg); color: var(--tile-violet-fg); }
.nav-item[data-tone="amber"] .nav-tile { background: var(--tile-amber-bg); color: var(--tile-amber-fg); }
.nav-item[data-tone="teal"] .nav-tile { background: var(--tile-teal-bg); color: var(--tile-teal-fg); }
.nav-item[data-tone="orange"] .nav-tile { background: var(--tile-orange-bg); color: var(--tile-orange-fg); }
.nav-item[data-tone="pink"] .nav-tile { background: var(--tile-pink-bg); color: var(--tile-pink-fg); }
.nav-item[data-tone="cyan"] .nav-tile { background: var(--tile-cyan-bg); color: var(--tile-cyan-fg); }

.nav-item:hover { background: var(--surface-2); color: var(--text-1); }
.nav-item.active { background: var(--brand-50); color: var(--brand-600); font-weight: 750; }
.nav-item.active .nav-tile { background: var(--brand-500); color: #fff; }
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 750;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-badge { background: #fff; border-color: var(--brand-200); color: var(--brand-600); }
[data-theme="dark"] .nav-item.active .nav-badge { background: var(--surface-3); }
.nav-item .nav-label { flex: 1; }

/* 侧栏底部用户卡 */
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.side-user .user-avatar { width: 32px; height: 32px; font-size: 13px; }
.side-user-meta { flex: 1; min-width: 0; }
.side-user-name { font-size: 13px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-actions { display: flex; gap: 8px; }
.side-actions .btn { flex: 1; }
#themeBtn, #langBtn { flex: 0 0 36px; padding: 0 !important; border-radius: 12px !important; width: 36px; font-weight: 800; }

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

.topbar {
  height: var(--header-h);
  /* 2026-09-15 根因修复（用户："选择数据结构后上面导航栏错位"）：
   * .main 是 flex 列且被 .shell 的整屏高卡住，.topbar 未声明 flex 时默认 `0 1 auto`
   * ⇒ 可被压缩。切换科目后列表变长、.content 的 flex-basis(内容高) 变大，溢出的份额
   * 就按比例从顶栏身上扣：同一页实测顶栏 66px ↔ 44.1px ↔ 41px ↔ 35px 随视口/内容浮动，
   * 于是"顶栏高矮跳变 + 下方内容整体上移 ~16px"= 用户看到的"导航栏错位"。
   * 顶栏是整屏骨架，高度必须恒等于 --header-h（jumpAnchor / sticky 占位 / 各种
   * scroll-margin 都按它算），故禁止收缩。 */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; min-width: 0; }
.crumb-home { color: var(--text-3); cursor: pointer; display: inline-flex; padding: 6px; border-radius: 9px; }
.crumb-home:hover { color: var(--brand-600); background: var(--brand-50); }
.crumb-home svg { width: 17px; height: 17px; }
.crumb-sep { color: var(--line-strong); }
.crumb-now { font-weight: 750; letter-spacing: -0.01em; white-space: nowrap; font-size: 14.5px; }
.topbar-spacer { flex: 1; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 13px 4px 4px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.user-avatar svg { width: 18px; height: 18px; }
.user-name { font-weight: 700; font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 26px 26px 60px; max-width: 1200px; width: 100%; margin: 0 auto; }
/* 路由切换：仅淡入，不位移 */
#outlet > * { animation: page-fade .18s ease; }
@keyframes page-fade { from { opacity: 0; } to { opacity: 1; } }

.page-head { margin-bottom: 20px; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.page-desc { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.page-head-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 登录态：隐藏壳 */
.shell.no-chrome .sidebar,
.shell.no-chrome .rail-hot,
.shell.no-chrome .main > .topbar,
.shell.no-chrome .scrim { display: none; }
.shell.no-chrome .main { display: block; }
.shell.no-chrome .content { padding: 0; max-width: none; }

/* ---------- 响应式 ---------- */
.menu-btn { display: none; }
.topbar-search-wrap { flex: 0 1 360px; }
@media (max-width: 1080px) {
  .topbar-search-wrap { display: none; }
}
@media (max-width: 860px) {
  .rail-hot { display: none; } /* 触屏无悬停，改用菜单按钮抽屉 */
  .sidebar {
    position: fixed; z-index: 60;
    width: 284px; flex-basis: 284px;
    transform: translateX(-102%);
    box-shadow: var(--shadow-3);
    border-radius: 0 20px 20px 0;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .44);
    z-index: 50; opacity: 0; pointer-events: none;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding: 0 16px; }
  .user-name { display: none; }
}
