/* ============================================
   基础重置 + 排版规则
   ============================================ */

/* === 重置 === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-width: 320px;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

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

/* === 滚动条定制 === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-inset);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

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

/* === 文字排版 === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: var(--lh-tight);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p {
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

strong, b {
  font-weight: 600;
  color: var(--text-primary);
}

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

code {
  background: var(--bg-inset);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--accent-hover);
}

pre {
  background: var(--bg-inset);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  line-height: var(--lh-normal);
}

pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

/* === 列表 === */
ul, ol {
  padding-left: var(--space-md);
  line-height: var(--lh-relaxed);
}

li {
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

/* === 引用块 === */
blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* === 分割线 === */
hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-lg) 0;
}

/* === 表格 === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th, td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  color: var(--text-primary);
  font-weight: 600;
}

td {
  color: var(--text-secondary);
}

/* === 选中文本 === */
::selection {
  background: var(--accent-bg-strong);
  color: var(--text-primary);
}

/* === 焦点可见性 === */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === 通用工具类 === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.font-mono { font-family: var(--font-mono); }
.font-serif { font-family: var(--font-serif); }

.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;
}

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.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;
}
