/* ==========================================================================
   UGC 数据中枢 v2 · Base
   Reset + 排版 + 数字对齐 + 焦点 + 滚动条 + 无障碍
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 4;
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  font-weight: var(--weight-regular);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out);
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text);
}

h1 { font-size: var(--text-2xl); letter-spacing: var(--tracking-tighter); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-sm); }

p {
  text-wrap: pretty;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

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

[hidden] {
  display: none !important;
}

/* ---------- 数字：所有数值统一等宽对齐 ---------- */
.tnum,
table,
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv11";
}

.num {
  text-align: right;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---------- 文本工具类 ---------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-subtle { color: var(--text-subtle); }
.text-xs { font-size: var(--text-xs); }
.text-2xs { font-size: var(--text-2xs); }
.text-md { font-size: var(--text-md); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.eyebrow {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- 布局工具类 ---------- */
.row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.col { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.ml-auto { margin-left: auto; }
.gap-1 { gap: var(--space-1); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.wrap { flex-wrap: wrap; }

/* ---------- 焦点：只对键盘用户显示 ---------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- 滚动条 ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-subtle);
}

/* ---------- 无障碍 ---------- */
.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;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-inverse);
  color: var(--text-inverse);
  transform: translateY(-160%);
  transition: transform var(--duration-base) var(--ease-out);
}

.skip-link:focus-visible {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 主题切换瞬间禁用过渡，防止整页颜色"流动" */
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: none !important;
}
