/* 基础:重置、排版、表单控件、焦点样式。 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-sm); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
code, pre { font-family: var(--font-mono); font-size: var(--fs-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
svg { flex-shrink: 0; }
.num, .tnum, td, th { font-variant-numeric: tabular-nums; }

/* 焦点:键盘可达,始终可见 */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }

/* ── 按钮 ── */
button { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  height: var(--control-h); padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
  cursor: pointer; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { height: var(--control-h-sm); padding: 0 var(--sp-2); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn.icon { width: var(--control-h); padding: 0; }
.btn.sm.icon { width: var(--control-h-sm); }
.btn .spinner { width: 12px; height: 12px; }

.link-btn {
  background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer;
  font-size: inherit; text-align: left;
}
.link-btn:hover { color: var(--accent-strong); text-decoration: underline; }

/* ── 表单控件 ── */
input, select, textarea {
  font: inherit; font-size: var(--fs-sm); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  height: var(--control-h); padding: 0 var(--sp-2);
  transition: border-color var(--dur-fast) var(--ease);
}
textarea { height: auto; padding: var(--sp-2); resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="date"] { font-variant-numeric: tabular-nums; }
input[type="checkbox"] { height: auto; width: 16px; height: 16px; accent-color: var(--accent); }
input.sm, select.sm { height: var(--control-h-sm); font-size: var(--fs-xs); border-radius: var(--r-sm); }
::placeholder { color: var(--text-3); }
label.field { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); color: var(--text-2); }
label.inline { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }

/* ── 通用排版辅助 ── */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-xs); }
.tiny { font-size: var(--fs-2xs); }
.strong { font-weight: var(--fw-semibold); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.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; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tone-good { color: var(--good); }
.tone-warn { color: var(--warn); }
.tone-bad { color: var(--bad); }
.tone-neutral { color: var(--text-2); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
