/* =====================================================================
 * Layout：外壳 / 侧栏（完整 · 图标栏 · 抽屉）/ 顶栏 / 底部 Tab 栏 / 边缘羽化
 * 断点：xs<480 · sm 480–767 · md 768–1023 · lg 1024–1439 · xl ≥1440
 * ===================================================================== */
#app { height: 100vh; height: 100dvh; }
.app { display: flex; height: 100%; position: relative; overflow: hidden; background: var(--bg-page); }

/* ---- 侧栏 ---- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; height: 100%;
  display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) 12px calc(14px + var(--safe-b)) calc(12px + var(--safe-l));
  transition: width var(--dur) var(--ease-out);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; min-height: 58px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 24px -10px rgba(var(--accent-rgb), 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brand-mark .ico { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.side-search { margin: 0 4px 12px; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 2px; margin: 0 -2px; }
.nav-section { font-size: 11px; color: var(--text-3); letter-spacing: 0.08em; padding: 16px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-ctl); color: var(--text-2); font-weight: 560; text-decoration: none;
  transition: background-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-1); text-decoration: none; }
.nav-item:active { transform: scale(0.974); }
.nav-item[aria-current="page"] { background: var(--bg-card); color: var(--accent); box-shadow: var(--specular); }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.quota-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-radius: var(--r-sub); background: var(--bg-card); box-shadow: var(--specular);
}
.quota-chip .label { font-size: var(--fs-xs); color: var(--text-2); }
.quota-chip .value { font-family: var(--font-mono); font-weight: 650; color: var(--ok); font-size: 15px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 8px; border-radius: var(--r-sub); }
.avatar {
  width: 34px; height: 34px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.user-meta b { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: var(--fs-xs); color: var(--text-3); }

/* 收起为图标栏（桌面手动 / 平板默认） */
.app.rail .sidebar { width: var(--rail-w); padding-left: 10px; padding-right: 10px; }
.app.rail .brand { justify-content: center; padding: 6px 0 18px; }
.app.rail .brand-name, .app.rail .nav-item .label, .app.rail .nav-section, .app.rail .quota-chip, .app.rail .user-meta, .app.rail .side-collapse-label { display: none; }
.app.rail .nav-item { justify-content: center; padding: 0; }
.app.rail .user-chip { flex-direction: column; padding: 8px 0; }
.app.rail .side-foot .btn { padding: 0; width: 44px; align-self: center; }

/* ---- 主区域 ---- */
.main {
  flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; position: relative;
  background: var(--bg-page);
  transition: transform var(--dur-slow) var(--ease-spring), border-radius var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow);
}
.topbar {
  height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) var(--sp-5) 0 var(--sp-5);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; position: relative; z-index: 5;
}
.topbar h1 { font-size: var(--fs-lg); font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu-btn { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.view {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
/* 滚动边缘羽化：滑入顶栏 / 底栏的内容柔和消隐 */
.feather {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
}
.view.fill { overflow: hidden; display: flex; flex-direction: column; }
.page {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--sp-2) var(--sp-5) calc(var(--sp-6) + 8px);
  animation: pageIn var(--dur-slow) var(--ease-out);
}
.page.wide { max-width: 1320px; }
.page.narrow { max-width: 760px; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 顶部标签导航（管理后台等） */
.tabs { display: flex; gap: 6px; margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  color: var(--text-2); font-weight: 560; white-space: nowrap; flex-shrink: 0;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.tabs > button:hover { background: var(--bg-hover); color: var(--text-1); }
.tabs > button[aria-selected="true"] { background: var(--bg-card); color: var(--accent); box-shadow: var(--specular); }

/* ---- 底部玻璃 Tab 栏（移动端）---- */
.tabbar { display: none; }
.scrim {
  position: absolute; inset: 0; z-index: 30; background: transparent; pointer-events: none;
}

/* ---- 宽屏 ---- */
@media (min-width: 1440px) {
  :root { --content-max: 1200px; --sidebar-w: 264px; }
}

/* 平板（768–1023）默认图标栏：由 shell.js 根据宽度与用户偏好切换 .rail */

/* ---- 手机：推移视差抽屉 + 底部 Tab 栏 ---- */
@media (max-width: 767px) {
  :root { --topbar-h: 56px; }
  .sidebar {
    position: absolute; top: 0; bottom: 0; left: 0; width: 276px;
    transform: translateX(-24px); opacity: 0; pointer-events: none;
    transition: transform var(--dur-slow) var(--ease-spring), opacity var(--dur) var(--ease-out);
  }
  .app.rail .sidebar { width: 276px; padding-left: calc(12px + var(--safe-l)); padding-right: 12px; }
  .app.rail .brand-name, .app.rail .nav-item .label, .app.rail .nav-section, .app.rail .quota-chip, .app.rail .user-meta { display: revert; }
  .app.rail .nav-item { justify-content: flex-start; padding: 0 12px; }
  .app.rail .user-chip { flex-direction: row; padding: 8px 6px 8px 8px; }
  .app.rail .brand { justify-content: flex-start; padding: 6px 8px 18px; }
  .side-collapse { display: none !important; }
  .main { z-index: 25; }
  .app.drawer-open .sidebar { transform: none; opacity: 1; pointer-events: auto; }
  .app.drawer-open .main {
    transform: translateX(262px) scale(0.93);
    border-radius: 34px; overflow: hidden;
    box-shadow: var(--float-shadow);
  }
  .app.drawer-open .scrim { pointer-events: auto; z-index: 40; left: 262px; }
  .topbar { padding-left: 8px; padding-right: 8px; }
  .topbar .menu-btn { display: inline-grid; }
  .page { padding: var(--sp-2) 14px calc(var(--tabbar-h) + var(--safe-b) + 24px); }
  .view.fill { padding-bottom: 0; }

  .tabbar {
    display: flex; position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
    height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 8px calc(6px + var(--safe-b));
    background: var(--bg-card); box-shadow: inset 0 1px 0 var(--hairline);
  }
  @supports (backdrop-filter: blur(10px)) {
    .tabbar { background: var(--bg-glass); backdrop-filter: blur(28px) saturate(190%); -webkit-backdrop-filter: blur(28px) saturate(190%); }
  }
  .tabbar a, .tabbar button {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: var(--r-sub); color: var(--text-3); font-size: 11px; font-weight: 560; text-decoration: none;
    transition: color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
  }
  .tabbar a:active, .tabbar button:active { transform: scale(0.92); }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .tabbar .ico { width: 22px; height: 22px; }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .app.drawer-open .main { transform: translateX(262px); }
}
