/* ==========================================================================
   虚拟生命 · 基础样式（reset / 排版 / 滚动条 / 焦点 / 安全区）
   依赖 tokens.css；本文件不出现具体色值（除极少数半透明遮罩）。
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  overscroll-behavior-y: contain;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: var(--fs-24);
  line-height: var(--lh-tight);
  font-weight: 650;
  letter-spacing: 0.01em;
}

h2 {
  font-size: var(--fs-20);
  line-height: var(--lh-tight);
  font-weight: 650;
}

h3 {
  font-size: var(--fs-16);
  line-height: var(--lh-tight);
  font-weight: 600;
}

h4 {
  font-size: var(--fs-14);
  font-weight: 600;
}

p {
  font-size: var(--fs-14);
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

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

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

button:disabled {
  cursor: not-allowed;
}

input,
textarea,
select {
  background: transparent;
}

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

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

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

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 鼠标用户不显示焦点环；键盘 Tab 仍有 2px 焦点环（UI_DESIGN_SPEC §7） */
@media (pointer: fine) {
  :focus:not(:focus-visible) {
    outline: none;
  }
}

::selection {
  background: var(--primary-weak);
  color: var(--text);
}

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

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

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

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

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

/* 安全区（Android WebView / iPhone 刘海 / Windows 任务栏） */
.safe-top {
  padding-top: env(safe-area-inset-top);
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

/* 工具类 */
.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;
}

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

.muted {
  color: var(--text-2);
}

.dim {
  color: var(--text-3);
}

.small {
  font-size: var(--fs-12);
}

.nowrap {
  white-space: nowrap;
}

.break {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.row-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.spacer {
  flex: 1 1 auto;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.desktop-only {
  display: initial;
}

.mobile-only {
  display: none;
}

@media (max-width: 719.98px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: initial;
  }
}

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