/* =============================================================================
   基础层：重置、排版、纹理背景、滚动条、可访问性
   ========================================================================== */

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

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

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

body {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  /* 两个大范围光晕 + 细噪声：给纯色背景一点「纸/雾」的层次，不用图片请求 */
  background-image:
    radial-gradient(58% 44% at 12% -6%, var(--glow-a), transparent 68%),
    radial-gradient(46% 38% at 92% 8%, var(--glow-b), transparent 70%);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

/* 极细颗粒，避免大面积纯色在 OLED 上「发闷」 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

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

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent);
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
}

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

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

button:disabled {
  cursor: not-allowed;
}

svg {
  flex: none;
}

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

/* --- 键盘焦点：只在键盘导航时出现，鼠标点击不闪一圈 --- */
:focus {
  outline: none;
}

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

/* --- 滚动条：悬停才显形 --- */
.scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.scroll:hover,
.scroll:focus-within {
  scrollbar-color: var(--scroll-thumb) transparent;
}

.scroll::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

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

.scroll::-webkit-scrollbar-thumb {
  background: transparent;
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-pill);
  transition: background-color var(--dur-2) var(--ease-out);
}

.scroll:hover::-webkit-scrollbar-thumb,
.scroll:focus-within::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb);
}

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

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

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

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

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 状态点：在线绿点 / 离开黄月 / 忙碌红减 / 隐身灰点 */
.dot {
  --dot-color: var(--state-offline);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot-color);
  box-shadow: 0 0 0 2px var(--surface);
  flex: none;
}

.dot[data-state="online"] {
  --dot-color: var(--state-online);
}

.dot[data-state="away"] {
  --dot-color: var(--state-away);
}

.dot[data-state="busy"] {
  --dot-color: var(--state-busy);
}

.dot[data-state="dnd"] {
  --dot-color: var(--state-dnd);
}

.dot[data-state="offline"],
.dot[data-state="invisible"] {
  --dot-color: var(--state-offline);
}

.dot[data-state="invisible"] {
  box-shadow: 0 0 0 2px var(--surface), inset 0 0 0 1.5px var(--surface);
}

/* 启动骨架屏 */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: var(--rail-w) var(--sidebar-w) minmax(0, 1fr);
  z-index: 50;
  background: var(--bg);
  transition: opacity var(--dur-4) var(--ease-out), filter var(--dur-4) var(--ease-out);
}

.boot[data-leaving="true"] {
  opacity: 0;
  filter: blur(6px);
  pointer-events: none;
}

.boot__rail,
.boot__sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-right: 1px solid var(--line-soft);
  background: var(--bg-soft);
}

.boot__sidebar {
  background: var(--surface);
}

.boot__main {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-7);
}

.boot__grain {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 50% at 70% 20%, var(--glow-a), transparent 70%),
    radial-gradient(50% 40% at 20% 80%, var(--glow-b), transparent 70%);
}

.boot__hint {
  position: fixed;
  left: 50%;
  bottom: var(--sp-7);
  transform: translateX(-50%);
  color: var(--text-mute);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sk {
  border-radius: var(--r-sm);
  background: linear-gradient(
    100deg,
    var(--surface-2) 20%,
    var(--surface-3) 42%,
    var(--surface-2) 64%
  );
  background-size: 220% 100%;
  animation: sk-slide 1.5s var(--ease-in-out) infinite;
}

.sk--mark {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
}

.sk--circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin: 0 auto;
}

.sk--title {
  width: 45%;
  height: 18px;
  margin-bottom: var(--sp-2);
}

.sk--row {
  height: 52px;
  border-radius: var(--r-md);
}

.sk--short {
  width: 72%;
}

.sk--line {
  height: 14px;
  border-radius: var(--r-xs);
  max-width: 420px;
}

.sk--w40 {
  width: 40%;
}

.sk--w60 {
  width: 60%;
}

.sk--w30 {
  width: 30%;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  gap: var(--sp-3);
  text-align: center;
  padding: var(--sp-7);
  background: var(--bg);
}

.noscript h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
}

@media (max-width: 860px) {
  .boot {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }

  .boot__sidebar {
    display: none;
  }
}

@media (max-width: 640px) {
  .boot {
    grid-template-columns: minmax(0, 1fr);
  }

  .boot__rail,
  .boot__sidebar {
    display: none;
  }

  .boot__main {
    padding: var(--sp-5);
  }
}