/* =========================================================================
   shell.css — 应用外壳：左侧导航轨 · 玻璃顶栏 · 内容区 · 抽屉 · 命令面板
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: var(--rail-w, 252px) 1fr;
  height: 100vh;
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(84, 214, 92, .05), transparent 60%),
    var(--bg);
  transition: grid-template-columns var(--t) var(--ease);
}
.app.rail-collapsed { --rail-w: 68px; }

/* =========================================================================
   左侧导航轨
   ========================================================================= */
.app-rail {
  grid-row: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--rail);
  border-right: 1px solid var(--line);
  position: relative; z-index: var(--z-rail);
}

.rail-brand {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 14px; flex: none;
  border-bottom: 1px solid var(--line);
}
.rail-brand .logo-full { height: 22px; width: auto; }
.rail-brand .logo-mark { height: 26px; width: 26px; display: none; }
.app.rail-collapsed .rail-brand { justify-content: center; padding: 0; }
.app.rail-collapsed .rail-brand .logo-full { display: none; }
.app.rail-collapsed .rail-brand .logo-mark { display: block; }
.rail-brand .env {
  margin-left: auto; font-size: var(--fs-11); font-weight: 600;
  color: var(--brand-lime); padding: 2px 7px; border-radius: var(--r-full);
  background: rgba(180, 244, 106, .1); border: 1px solid rgba(180, 244, 106, .2);
}
.app.rail-collapsed .rail-brand .env { display: none; }

.rail-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 8px 10px 20px; }
.app.rail-collapsed .rail-scroll { padding: 8px 8px 20px; }

.nav-group { margin-top: 10px; }
.nav-group > .nav-group-label {
  padding: 8px 10px 4px; color: var(--text-faint);
  font-size: var(--fs-11); font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
}
.app.rail-collapsed .nav-group-label { opacity: 0; height: 10px; padding: 0; overflow: hidden; }

.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-dim); font-size: var(--fs-13); font-weight: 450;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item .ic { flex: none; width: 18px; height: 18px; color: currentColor; opacity: .85; }
.nav-item .lbl { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.nav-item .chev {
  width: 15px; height: 15px; color: var(--text-faint);
  transition: transform var(--t) var(--ease); flex: none;
}
.nav-item.open > .chev { transform: rotate(90deg); }
.nav-item .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--danger); color: #fff; font-size: var(--fs-11); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.app.rail-collapsed .nav-item .lbl,
.app.rail-collapsed .nav-item .chev,
.app.rail-collapsed .nav-item .count { display: none; }
.app.rail-collapsed .nav-top > .nav-item { justify-content: center; padding: 10px; }

/* 顶层带子选单 */
.nav-top { position: relative; }
.nav-sub {
  overflow: hidden; display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows var(--t) var(--ease);
}
.nav-top.open > .nav-sub { grid-template-rows: 1fr; }
.nav-sub-inner { min-height: 0; padding: 2px 0 2px 0; }
.nav-sub .nav-item { padding-left: 40px; font-size: var(--fs-13); }
.nav-sub .nav-item .lbl { color: inherit; }

/* 当前页 */
.nav-item.active { color: var(--text); background: var(--accent-weak); font-weight: 500; }
.nav-item.active .ic { color: var(--brand); opacity: 1; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--brand-grad);
}
.app.rail-collapsed .nav-item.active::before { left: -8px; }

/* 折叠态 flyout 子选单 */
.app.rail-collapsed .nav-top:hover > .nav-sub {
  position: absolute; left: calc(100% + 8px); top: 0; z-index: 60;
  grid-template-rows: 1fr; min-width: 210px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px;
}
.app.rail-collapsed .nav-top:hover > .nav-sub .nav-item { padding-left: 12px; }
.app.rail-collapsed .nav-top:hover > .nav-sub .lbl,
.app.rail-collapsed .nav-top:hover .nav-sub-inner { display: block; }

.rail-foot { flex: none; padding: 10px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.rail-foot .who { display: flex; align-items: center; gap: 9px; flex: 1 1 auto; min-width: 0; }
.rail-foot .avatar {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-sm);
  background: var(--brand-grad); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: var(--fs-13);
}
.rail-foot .who .meta { min-width: 0; line-height: 1.25; }
.rail-foot .who .meta b { font-size: var(--fs-13); font-weight: 550; }
.rail-foot .who .meta span { font-size: var(--fs-11); color: var(--text-faint); }
.app.rail-collapsed .rail-foot { flex-direction: column; }
.app.rail-collapsed .rail-foot .who .meta, .app.rail-collapsed .rail-foot .icon-btn.theme { display: none; }

/* =========================================================================
   内容主区
   ========================================================================= */
.app-main { grid-row: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.app-topbar {
  flex: none; height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; position: sticky; top: 0; z-index: var(--z-topbar);
  background: var(--chrome); backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.topbar-toggle { flex: none; }

/* 面包屑 */
.crumbs { display: flex; align-items: center; gap: 7px; min-width: 0; }
.crumbs .c { color: var(--text-faint); font-size: var(--fs-13); white-space: nowrap; }
.crumbs .c.cur { color: var(--text); font-weight: 550; }
.crumbs .sep { color: var(--text-faint); opacity: .5; }

/* 命令/搜寻 */
.cmd-trigger {
  display: flex; align-items: center; gap: 9px; height: 36px; width: 320px; max-width: 34vw;
  padding: 0 11px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-faint); font-size: var(--fs-13); transition: border-color var(--t-fast);
}
.cmd-trigger:hover { border-color: var(--line-2); }
.cmd-trigger .ic { width: 16px; height: 16px; }
.cmd-trigger .kbd { margin-left: auto; }

.kbd {
  font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-dim);
  background: var(--surface-3); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: var(--r-xs); padding: 1px 6px; line-height: 1.4;
}

/* 顶栏图标按钮 */
.icon-btn {
  position: relative; flex: none; width: 36px; height: 36px; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--text-dim);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--chrome);
}

/* 模式小标（SYSTEM / FIGHTING） */
.mode-chips { display: flex; gap: 7px; }
.mode-chip {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--fs-12); color: var(--text-dim);
}
.mode-chip b { color: var(--text); font-weight: 550; }
.mode-chip .k { color: var(--text-faint); font-size: var(--fs-11); }

.clock { font-variant-numeric: tabular-nums; font-size: var(--fs-12); color: var(--text-dim); white-space: nowrap; }
.clock b { color: var(--text); font-weight: 550; }

/* 内容卷动区 */
.app-view {
  flex: 1 1 auto; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth; position: relative;
}
.view-pad { padding: 20px 24px 64px; max-width: 1640px; margin: 0 auto; }

/* 页首 */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .ttl { font-size: var(--fs-28); font-weight: 650; letter-spacing: -0.025em; }
.page-head .sub { color: var(--text-dim); font-size: var(--fs-13); margin-top: 3px; }
.page-head .actions { display: flex; gap: 10px; align-items: center; }

/* =========================================================================
   右侧抽屉（检视器）
   ========================================================================= */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px);
  opacity: 0; animation: fade-in var(--t) var(--ease) forwards;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-drawer) + 1);
  width: min(560px, 94vw); background: var(--surface); border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  transform: translateX(100%); animation: drawer-in var(--t-slow) var(--ease-out) forwards;
}
@keyframes drawer-in { to { transform: none; } }
.drawer.wide { width: min(880px, 96vw); }
.drawer-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head .ttl { font-size: var(--fs-18); font-weight: 600; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 20px; }
.drawer-foot { flex: none; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* =========================================================================
   命令面板 ⌘K
   ========================================================================= */
.cmdk-scrim {
  position: fixed; inset: 0; z-index: var(--z-palette);
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh;
  opacity: 0; animation: fade-in var(--t-fast) forwards;
}
.cmdk {
  width: min(680px, 92vw); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop-in var(--t) var(--ease-out);
}
.cmdk-input { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.cmdk-input .ic { width: 19px; height: 19px; color: var(--text-faint); }
.cmdk-input input { flex: 1; background: none; border: none; outline: none; font-size: var(--fs-16); }
.cmdk-input input::placeholder { color: var(--text-faint); }
.cmdk-list { overflow-y: auto; padding: 8px; }
.cmdk-group-label { padding: 10px 10px 4px; }
.cmdk-opt {
  display: flex; align-items: center; gap: 12px; padding: 9px 11px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text-dim);
}
.cmdk-opt .ic { width: 17px; height: 17px; flex: none; }
.cmdk-opt .lbl { flex: 1; color: var(--text); font-size: var(--fs-14); }
.cmdk-opt .path { color: var(--text-faint); font-size: var(--fs-12); }
.cmdk-opt.on { background: var(--accent-weak); color: var(--text); }
.cmdk-opt.on .ic { color: var(--brand); }
.cmdk-empty { padding: 32px; text-align: center; color: var(--text-faint); }

/* =========================================================================
   回到顶部
   ========================================================================= */
.to-top {
  position: fixed; right: 26px; bottom: 26px; z-index: 60;
  width: 42px; height: 42px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  display: grid; place-items: center; color: var(--text-dim);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: all var(--t) var(--ease);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { color: var(--text); border-color: var(--accent-line); }

/* =========================================================================
   响应式
   ========================================================================= */
@media (max-width: 1100px) {
  .cmd-trigger { width: 200px; }
  .mode-chips, .clock { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 0 1fr; }
  .app-rail { position: fixed; left: 0; top: 0; bottom: 0; width: 252px; transform: translateX(-100%); transition: transform var(--t) var(--ease); }
  .app.rail-open .app-rail { transform: none; box-shadow: var(--shadow-lg); }
  .view-pad { padding: 16px 14px 56px; }
  .page-head .ttl { font-size: var(--fs-22); }
}

/* nav accordion open-state chevron（app.js 用 .nav-top.open） */
.nav-top.open > .nav-item > .chev { transform: rotate(90deg); }
.nav-group-icon { width:18px; height:18px; flex:none; opacity:.85; }
