/* ============================================================
   基础层：设计令牌 / 重置 / 排版 / 通用工具
   ============================================================ */

:root {
  color-scheme: light;

  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f1f3f6;
  --line: #e6e9ef;
  --line-strong: #d5dae3;

  --text: #191c23;
  --text-2: #4a515e;
  --muted: #616a78;
  --faint: #8b93a1;

  --accent: #4263eb;
  --accent-hover: #3550d4;
  --accent-soft: #edf1ff;
  --accent-line: #ccd7ff;
  --accent-text: #2f47b8;
  --on-accent: #ffffff;

  --ok: #237a35;
  --ok-soft: #ebfbee;
  --warn: #b54a06;
  --warn-soft: #fff4e6;
  --danger: #c2255c;
  --danger-2: #b02020;
  --danger-soft: #fff0f3;
  --info: #0b7285;
  --info-soft: #e3fafc;

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.16), 0 4px 12px rgba(16, 24, 40, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --nav-w: 228px;
  --content-max: 1120px;
  --tabbar-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1015;
    --bg-elevated: #14171d;
    --surface: #16191f;
    --surface-2: #1a1e25;
    --surface-3: #21262f;
    --line: #242a34;
    --line-strong: #333b48;

    --text: #e8ebf0;
    --text-2: #b9c1cd;
    --muted: #8a94a3;
    --faint: #6b7484;

    --accent: #7b8fff;
    --accent-hover: #8f9fff;
    --accent-soft: #1c2440;
    --accent-line: #2e3a66;
    --accent-text: #a5b4ff;
    --on-accent: #0b0d12;

    --ok: #51cf66;
    --ok-soft: #16281a;
    --warn: #ffa94d;
    --warn-soft: #2a1f14;
    --danger: #ff6b9d;
    --danger-2: #ff8787;
    --danger-soft: #2b1720;
    --info: #3bc9db;
    --info-soft: #11282c;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1015;
  --bg-elevated: #14171d;
  --surface: #16191f;
  --surface-2: #1a1e25;
  --surface-3: #21262f;
  --line: #242a34;
  --line-strong: #333b48;
  --text: #e8ebf0;
  --text-2: #b9c1cd;
  --muted: #8a94a3;
  --faint: #6b7484;
  --accent: #7b8fff;
  --accent-hover: #8f9fff;
  --accent-soft: #1c2440;
  --accent-line: #2e3a66;
  --accent-text: #a5b4ff;
    --on-accent: #0b0d12;
  --ok: #51cf66;
  --ok-soft: #16281a;
  --warn: #ffa94d;
  --warn-soft: #2a1f14;
  --danger: #ff6b9d;
  --danger-2: #ff8787;
  --danger-soft: #2b1720;
  --info: #3bc9db;
  --info-soft: #11282c;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

#root {
  min-height: 100%;
}

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

h1 {
  font-size: 22px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 17px;
  line-height: 1.4;
  font-weight: 620;
}

h3 {
  font-size: 15px;
  line-height: 1.45;
  font-weight: 600;
}

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

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

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

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

::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------- 工具类 ---------------- */
.row {
  display: flex;
  align-items: center;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.row-gap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.col {
  display: flex;
  flex-direction: column;
}
.grow {
  flex: 1;
  min-width: 0;
}
.wrap {
  flex-wrap: wrap;
}
.center {
  align-items: center;
  justify-content: center;
}
.muted {
  color: var(--muted);
}
.faint {
  color: var(--faint);
}
.small {
  font-size: 12.5px;
}
.tiny {
  font-size: 11.5px;
}
.strong {
  font-weight: 600;
}
.mono {
  font-variant-numeric: tabular-nums;
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pre-wrap {
  white-space: pre-wrap;
  word-break: break-word;
}
.break {
  word-break: break-word;
  overflow-wrap: anywhere;
}
.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;
}

.stack-2 > * + * {
  margin-top: 8px;
}
.stack-3 > * + * {
  margin-top: 12px;
}
.stack-4 > * + * {
  margin-top: 16px;
}

.gap-4 {
  gap: 4px;
}
.gap-6 {
  gap: 6px;
}
.gap-8 {
  gap: 8px;
}
.gap-12 {
  gap: 12px;
}
.gap-16 {
  gap: 16px;
}

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