/* ============================================================
   LIMI v2 · 基础层：排版 / 应用骨架 / 侧栏 / 顶栏 / 手机底栏
   ============================================================ */
*,
*::before,
*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--gold); text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
svg { width: 18px; height: 18px; flex: none; }
::selection { background: var(--gold-soft); color: var(--ink); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d8dce3; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 排版工具 ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.label {
  font-size: var(--fs-2xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.hint { font-size: var(--fs-xs); color: var(--muted); }
.gold-rule {
  height: 1px; border: 0; margin: 0;
  background: linear-gradient(90deg, var(--gold), rgba(169, 134, 91, 0));
}
.diamond { color: var(--gold); font-size: 10px; }

/* ---------- 应用骨架 ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

/* ---------- 侧栏（DSH 风格：浅灰白 + 细边） ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  color: var(--muted);
  padding: var(--sp-5) var(--sp-3) var(--sp-4);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-2) var(--sp-6); }
.brand-logo {
  width: 30px; height: 30px;
  display: block;
  flex: none;
}
.brand-word { display: flex; flex-direction: column; gap: 1px; }
.brand-word b {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 650; letter-spacing: 0.06em;
  color: var(--ink);
}
.brand-word span { font-size: 9px; letter-spacing: 0.2em; color: var(--muted-2); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--muted-2);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--muted);
  transition: all var(--dur) var(--ease);
  user-select: none; cursor: pointer;
}
.nav-item svg { width: 16px; height: 16px; opacity: 0.9; }
.nav-item span { font-size: var(--fs-sm); }
.nav-item:hover { background: var(--bg-soft-2); color: var(--ink); }
.nav-item.active { background: #e8f1ff; color: #1d4ed8; font-weight: 600; }
.nav-item.active:hover { background: #dbeafe; color: #1d4ed8; }
.nav-item.active svg { opacity: 1; color: #2563eb; }
.nav-item .nav-tag {
  margin-left: auto;
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--muted-2); padding: 0 5px; line-height: 16px;
  background: var(--surface);
}
.sidebar-foot { margin-top: auto; padding: var(--sp-4) var(--sp-2) 0; }
.sidebar-foot .foot-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; color: var(--muted);
  font-size: var(--fs-xs);
}
.sidebar-foot .foot-link:hover { color: var(--ink); }
.sidebar-meta { margin-top: var(--sp-4); font-size: 10px; line-height: 1.8; color: var(--muted-2); }

/* ---------- 主区 ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title h1 {
  font-family: var(--font-display);
  font-size: var(--fs-md); font-weight: 600; letter-spacing: 0;
}
.topbar-title p { font-size: var(--fs-xs); color: var(--muted-2); margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }

.data-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-2xs); color: var(--muted);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg-soft);
}
.data-chip i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: block; }

.avatar-wrap { position: relative; }
.avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 12px; font-weight: 600; cursor: pointer;
  user-select: none;
}
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 200px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 5px; display: none; z-index: 60;
}
.user-menu.show { display: block; }
.um-head { padding: 9px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.um-head b { display: block; font-size: var(--fs-sm); font-weight: 600; }
.um-head span { font-size: var(--fs-2xs); color: var(--muted-2); }
.user-menu button {
  width: 100%; text-align: left; border: 0; background: none;
  border-radius: var(--r-sm);
  padding: 8px 10px; font-size: var(--fs-sm); color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
}
.user-menu button:hover { background: var(--bg-soft-2); color: var(--ink); }

/* ---------- 页面容器 ---------- */
.page {
  flex: 1; width: 100%; max-width: var(--page-max);
  margin: 0 auto; padding: var(--sp-6) var(--sp-8) var(--sp-10);
}
.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 0; }
.page-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl); font-weight: 600; letter-spacing: 0.08em;
}
.page-head .sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--muted); letter-spacing: 0.03em; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.hide { display: none !important; }

/* ---------- 手机端底栏 ---------- */
.mobile-tabbar { display: none; }
.mobile-topbar { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  :root { --sidebar-w: 216px; }
  .page { padding: var(--sp-5) var(--sp-6) var(--sp-10); }
}

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar { display: none; }
  .topbar { display: none; }
  .page {
    padding: calc(56px + var(--sp-3)) var(--sp-3)
             calc(var(--mobile-tab-h) + var(--sp-4));
  }
  .page.no-tabbar { padding-bottom: var(--sp-6); }

  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; height: 56px;
    padding: 0 var(--sp-4);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    z-index: 40;
  }
  .mobile-topbar .m-brand {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--font-display); font-size: 14px; font-weight: 650;
    letter-spacing: 0.08em; color: var(--ink);
  }
  .mobile-topbar .m-logo { width: 18px; height: 18px; display: block; }
  .mobile-topbar .m-page {
    font-size: var(--fs-xs); color: var(--muted);
    padding-left: 10px; border-left: 1px solid var(--line);
  }
  .mobile-topbar .m-avatar {
    margin-left: auto;
  }

  .mobile-tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--mobile-tab-h);
    background: var(--bg);
    border-top: 1px solid var(--line);
    z-index: 45;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mtab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; color: var(--muted-2);
    position: relative;
  }
  .mtab svg { width: 19px; height: 19px; }
  .mtab span { font-size: 10px; }
  .mtab.active { color: var(--accent); }
  .mtab.active::before {
    content: ""; position: absolute; top: -1px; width: 22px; height: 2px;
    background: var(--accent);
  }
}

@media (max-width: 420px) {
  .page { padding-left: var(--sp-2); padding-right: var(--sp-2); }
}

/* ---------- 预览用：关闭动画 ---------- */
.no-anim *, .no-anim *::before, .no-anim *::after {
  transition: none !important; animation: none !important;
}

/* ============================================================
   正式前端补充：焦点可见 / 工具类 / 移动端安全区修正
   （原型的内联样式全部由这里的工具类与 components/pages 组件类替代）
   ============================================================ */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mt-1 { margin-top: var(--sp-1); }
.ml-auto { margin-left: auto; }
.mr-1 { margin-right: var(--sp-1); }
.mr-2 { margin-right: var(--sp-2); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-3 { display: flex; flex-direction: column; gap: var(--sp-3); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.bold { font-weight: 600; }
.center { text-align: center; }
.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;
}

/* 移动端底栏：safe-area 抬高底栏而不是压缩图标区（修 UI 评审 P1-06） */
@media (max-width: 900px) {
  .mobile-tabbar {
    height: calc(var(--mobile-tab-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .main { min-height: 100dvh; }
}
