/* ============================================================
   布局骨架：顶栏 / 主区 / 移动端底栏 / 通用排版
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, var(--panel-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

/* ---------- 顶栏 ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 54px;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  background: var(--topbar-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: .02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark { width: 20px; height: 20px; fill: var(--accent); filter: drop-shadow(var(--glow)); }

#mainnav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
#mainnav::-webkit-scrollbar { display: none; }

#mainnav a {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#mainnav a:hover { color: var(--text); background: var(--panel-2); }
#mainnav a:active { transform: scale(var(--press-scale)); }
#mainnav a.active {
  color: var(--accent);
  background: var(--nav-pill);
  font-weight: 600;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- 主区 ---------- */

#page {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px max(16px, env(safe-area-inset-left)) 40px max(16px, env(safe-area-inset-right));
  outline: none;
}

h1.page-title {
  font-size: 21px;
  font-weight: 700;
  margin: 2px 0 4px;
  letter-spacing: .01em;
}
.page-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 18px; }

/* ---------- 移动端底栏 ---------- */

#tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  justify-content: space-around;
  align-items: stretch;
  padding: 6px env(safe-area-inset-right) calc(6px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  background: var(--topbar-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-top: 1px solid var(--border);
}
#tabbar a, #tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
  padding: 5px 10px;
  border: 0;
  background: none;
  color: var(--text-faint);
  font-size: 10.5px;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--r-m);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#tabbar a.active { color: var(--accent); }
#tabbar a:active, #tabbar button:active { transform: scale(var(--press-scale)); }

.nav-mobile-only { display: none; }

/* ---------- 响应式 ---------- */

@media (max-width: 760px) {
  #mainnav { display: none; }
  .nav-mobile-only { display: inline-flex; }
  #tabbar { display: flex; }
  #page { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  h1.page-title { font-size: 19px; }
}

/* ---------- 工具类 ---------- */

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.clickable { cursor: pointer; user-select: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 滚动条（桌面端细致化） */
@media (hover: hover) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
  ::-webkit-scrollbar-track { background: transparent; }
}
