/* 重置、排版、无障碍基础。 */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, p, figure { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; text-wrap: balance; }

ul, ol { margin: 0; padding: 0; list-style: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

code, pre, .mono { font-family: var(--font-mono); }

/* 数字列必须等宽，否则每次刷新数字都在跳，扫一眼看不出哪个变了 */
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }

/* ── 焦点 ────────────────────────────────────────────────────────
 * 键盘焦点必须看得见。用 :focus-visible 而不是 :focus —— 后者会让
 * 鼠标点击也画一圈框，看着像坏了，然后就有人把它整个关掉，
 * 键盘用户跟着遭殃。 */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ── 滚动条 ─────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-full);
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--fg-3); background-clip: content-box; }

/* ── 屏幕阅读器专用 ─────────────────────────────────────────────── */
.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;
}

/* 键盘用户的跳转链接：Tab 第一下就能跳过整个侧栏 */
.skip-link {
  position: absolute;
  top: var(--sp-2); left: var(--sp-2);
  z-index: var(--z-toast);
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent); color: var(--on-accent);
  border-radius: var(--r);
  transform: translateY(-200%);
  transition: transform var(--t-fast) var(--ease);
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

/* ── 排版工具 ───────────────────────────────────────────────────── */
.t-2 { color: var(--fg-2); }
.t-3 { color: var(--fg-3); }
.t-sm { font-size: var(--fs-sm); }
.t-xs { font-size: var(--fs-xs); }
.t-ok { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-err { color: var(--err); }
.t-info { color: var(--info); }
.t-accent { color: var(--accent); }
.bold { font-weight: 600; }

/* 长文本省略：表格里很常见，但必须给宽度约束才生效 */
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 布局工具 ───────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.hidden { display: none !important; }

/* ── 图标 ───────────────────────────────────────────────────────── */
/* 用 currentColor 描边，图标自动跟着文字色走，不用为每种状态单独配色 */
.icon {
  width: 20px; height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ── 动画 ───────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: none; }
}
@keyframes shimmer {
  0%, 100% { opacity: .45; }
  50%      { opacity: .85; }
}

/* 有人对动画敏感，也有人在远程桌面上用 —— 一律关掉，别只是"减少" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
