/* ============================================================
   PRISM · 应用骨架：侧边栏 / 顶栏 / 多页签 / 页面容器
   ============================================================ */

.app { position: relative; z-index: 1; display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ── 侧边栏 ───────────────────────────────────────────── */
.sidebar {
  position: relative; z-index: var(--z-sidebar); width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column; background: var(--surface);
  border-right: 1px solid var(--border); transition: width var(--dur-3) var(--ease);
}
.sidebar::after {
  content: ''; position: absolute; top: 0; right: -1px; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent, var(--accent-line) 22%, color-mix(in srgb, var(--c2) 45%, transparent) 55%, transparent);
  opacity: .7; pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 11px; height: var(--topbar-h); padding: 0 18px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; position: relative; }
.brand-mark svg { width: 100%; height: 100%; overflow: visible; }
.brand-text { min-width: 0; overflow: hidden; }
.brand-name { font-family: var(--font-display); font-size: 17px; font-weight: 720; letter-spacing: -.03em; line-height: 1.1; white-space: nowrap; }
.brand-tag { font-family: var(--font-mono); font-size: 9px; letter-spacing: .18em; color: var(--text-3); text-transform: uppercase; white-space: nowrap; }

.side-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 20px; }
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  display: flex; align-items: center; gap: 8px; padding: 14px 10px 7px;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; color: var(--text-3); white-space: nowrap;
}
.nav-group-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 520;
  color: var(--text-2); cursor: pointer; transition: background var(--dur-1), color var(--dur-1);
  white-space: nowrap; text-align: left;
}
.nav-item .icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active .icon { opacity: 1; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--c2));
}
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-badge { font-family: var(--font-mono); font-size: 10px; padding: 1px 6px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-3); }
.nav-item.active .nav-badge { background: var(--accent); color: var(--on-accent); }
.nav-item .nav-badge.hot { background: var(--danger); color: #fff; }
.nav-caret { width: 13px; height: 13px; transition: transform var(--dur-2) var(--ease); opacity: .6; }
.nav-sub { overflow: hidden; display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-3) var(--ease); }
.nav-parent.open + .nav-sub { grid-template-rows: 1fr; }
.nav-parent.open .nav-caret { transform: rotate(90deg); }
.nav-sub-inner { min-height: 0; overflow: hidden; padding-left: 14px; margin-left: 9px; border-left: 1px solid var(--border); }
.nav-sub .nav-item { font-size: 12.5px; padding: 6px 10px; }
.nav-sub .nav-item.active::before { display: none; }
.nav-sub .nav-item::after {
  content: ''; position: absolute; left: -15px; top: 50%; width: 9px; height: 1px; background: var(--border);
}
.nav-sub .nav-item.active::after { background: var(--accent); }

.side-foot { flex-shrink: 0; padding: 12px; border-top: 1px solid var(--border); }
.side-card {
  position: relative; overflow: hidden; padding: 13px; border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--accent-soft), color-mix(in srgb, var(--c2) 12%, transparent));
  border: 1px solid var(--accent-line);
}
.side-card-title { font-size: 12.5px; font-weight: 620; display: flex; align-items: center; gap: 7px; }
.side-card-desc { font-size: 11px; color: var(--text-2); margin: 4px 0 9px; line-height: 1.5; }

/* 收起为图标栏 */
[data-sidebar='rail'] .sidebar { width: var(--sidebar-rail); }
[data-sidebar='rail'] .brand { justify-content: center; padding: 0; }
[data-sidebar='rail'] .brand-text,
[data-sidebar='rail'] .nav-label,
[data-sidebar='rail'] .nav-badge,
[data-sidebar='rail'] .nav-caret,
[data-sidebar='rail'] .nav-group-title,
[data-sidebar='rail'] .side-card,
[data-sidebar='rail'] .nav-sub { display: none; }
[data-sidebar='rail'] .side-scroll { padding: 12px 10px; }
[data-sidebar='rail'] .nav-item { justify-content: center; padding: 10px 0; }
[data-sidebar='rail'] .nav-item.active::before { left: -10px; }
[data-sidebar='rail'] .nav-group { padding-top: 8px; border-top: 1px solid var(--border); margin-top: 8px; }
[data-sidebar='rail'] .nav-group:first-child { border-top: none; margin-top: 0; }
[data-sidebar='rail'] .side-foot { display: flex; justify-content: center; }

/* ── 主区 ─────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  position: relative; z-index: var(--z-topbar); height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  position: relative; width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--text-2); transition: background var(--dur-1), color var(--dur-1); flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn .count-badge { position: absolute; top: 1px; right: 1px; transform: scale(.85); }

.search-trigger {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 10px 0 11px;
  min-width: 230px; border-radius: var(--r-sm); background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-3); font-size: 12.5px;
  transition: all var(--dur-1); cursor: pointer;
}
.search-trigger:hover { border-color: var(--border-2); background: var(--surface-3); }
.search-trigger .icon { width: 15px; height: 15px; }
.search-trigger .ico { display: inline-flex; color: var(--text-3); }
.search-trigger:hover .ico { color: var(--accent); }
.search-trigger .kbd { margin-left: auto; }

.topbar-user { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: var(--r-sm); transition: background var(--dur-1); cursor: pointer; }
.topbar-user:hover { background: var(--hover); }
.topbar-user-meta { line-height: 1.25; text-align: left; }
.topbar-user-name { font-size: 12.5px; font-weight: 600; }
.topbar-user-role { font-size: 10.5px; color: var(--text-3); }

/* 多页签 */
.tabbar {
  display: flex; align-items: center; gap: 6px; height: var(--tabbar-h); flex-shrink: 0;
  padding: 0 12px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 45%, transparent);
}
.tabbar-scroll { display: flex; align-items: center; gap: 5px; overflow-x: auto; flex: 1; scrollbar-width: none; height: 100%; padding: 6px 0; }
.tabbar-scroll::-webkit-scrollbar { display: none; }
.page-tab {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px 0 11px;
  border-radius: var(--r-sm); font-size: 12px; color: var(--text-3); white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; transition: all var(--dur-1); flex-shrink: 0;
}
.page-tab:hover { background: var(--hover); color: var(--text-2); }
.page-tab.active { background: var(--surface); border-color: var(--border-2); color: var(--text); font-weight: 560; box-shadow: var(--shadow-1); }
.page-tab .dot { width: 5px; height: 5px; }
.page-tab.active .dot { background: var(--accent); }
.page-tab-close { width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center; opacity: .5; }
.page-tab-close:hover { background: var(--danger-soft); color: var(--danger); opacity: 1; }
.page-tab-close .icon { width: 10px; height: 10px; }

/* 页面滚动区 */
.viewport { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; position: relative; }
.page { padding: 22px 24px 40px; max-width: 1680px; margin: 0 auto; animation: fadeUp var(--dur-4) var(--ease-out); }
.page-wide { max-width: none; }
.page-full { padding: 0; max-width: none; height: 100%; }
.page-full-height { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 22px; }
.page-full-height > .page-head { flex-shrink: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head-l { min-width: 0; }
.page-title { font-family: var(--font-display); font-size: 27px; font-weight: 680; letter-spacing: -.032em; line-height: 1.15; display: flex; align-items: center; gap: 11px; }
.page-desc { font-size: 13px; color: var(--text-2); margin-top: 5px; max-width: 680px; line-height: 1.6; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.page-head .eyebrow { margin-bottom: 7px; display: block; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 30px 0 14px; flex-wrap: wrap; }
.section-head:first-child { margin-top: 0; }
.section-title { font-family: var(--font-display); font-size: 18px; font-weight: 650; letter-spacing: -.022em; display: flex; align-items: center; gap: 10px; }
.section-title .bar { width: 3px; height: 16px; border-radius: 2px; background: linear-gradient(180deg, var(--accent), var(--c2)); }
.section-desc { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

.footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }

/* 移动端遮罩 */
.side-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: calc(var(--z-sidebar) - 1); backdrop-filter: blur(3px); animation: fadeIn var(--dur-2); }

@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform var(--dur-3) var(--ease); box-shadow: var(--shadow-3); width: var(--sidebar-w) !important; }
  body.side-open .sidebar { transform: none; }
  [data-sidebar='rail'] .brand-text, [data-sidebar='rail'] .nav-label, [data-sidebar='rail'] .nav-badge,
  [data-sidebar='rail'] .nav-caret, [data-sidebar='rail'] .nav-group-title, [data-sidebar='rail'] .side-card,
  [data-sidebar='rail'] .nav-sub { display: revert; }
  [data-sidebar='rail'] .nav-item { justify-content: flex-start; padding: 8px 10px; }
  [data-sidebar='rail'] .brand { justify-content: flex-start; padding: 0 18px; }
  [data-sidebar='rail'] .nav-group { border-top: none; margin-top: 0; padding-top: 0; }
  .search-trigger { min-width: 0; width: 34px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger .kbd { display: none; }
  .page { padding: 16px 14px 32px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-user-meta { display: none; }
}
@media (max-width: 640px) {
  .page-title { font-size: 22px; }
  .tabbar { display: none; }
  .page-head { align-items: flex-start; }
}

/* 返回顶部 */
.backtop {
  position: fixed; right: 22px; bottom: 22px; width: 38px; height: 38px; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border-2);
  color: var(--text-2); box-shadow: var(--shadow-2); z-index: var(--z-sticky);
  opacity: 0; pointer-events: none; transform: translateY(10px); transition: all var(--dur-3) var(--ease);
}
.backtop.show { opacity: 1; pointer-events: auto; transform: none; }
.backtop:hover { color: var(--accent); border-color: var(--accent); }

/* 主题快捷面板 */
.theme-panel { width: 296px; padding: 14px; }
.theme-panel-section + .theme-panel-section { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border); }
.theme-panel-label { font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-family: var(--font-mono); margin-bottom: 9px; }
.theme-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-card { border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 7px; cursor: pointer; transition: all var(--dur-1); background: var(--surface-2); }
.theme-card:hover { border-color: var(--border-2); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-preview { height: 40px; border-radius: var(--r-xs); overflow: hidden; display: flex; margin-bottom: 6px; }
.theme-preview i { display: block; height: 100%; }
.theme-card span { font-size: 11.5px; font-weight: 550; display: flex; align-items: center; gap: 5px; justify-content: center; }
.theme-card span .icon { width: 12px; height: 12px; }
.accent-row { display: flex; gap: 8px; }
.accent-dot { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform var(--dur-1) var(--ease-spring); position: relative; }
.accent-dot:hover { transform: scale(1.14); }
.accent-dot.active { border-color: var(--text); }
.accent-dot.active::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.85); }