/* =====================================================================
   base.css — 设计系统（前台与后台共用）
   风格：霓虹 HUD；Inter 正文，Chakra Petch 标题，Share Tech Mono 元信息
   前台固定深色；后台支持浅色 / 深色
   ===================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Chakra Petch';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/chakra-petch-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Chakra Petch';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/chakra-petch-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Chakra Petch';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/chakra-petch-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Chakra Petch';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/chakra-petch-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Share Tech Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/share-tech-mono-latin-400-normal.woff2') format('woff2');
}

/* ------------------------------------------------------------------ tokens：浅色（仅后台使用） */

:root {
  --bg: #fafafa;
  --bg-soft: #f1f1f1;
  --surface: #ffffff;
  --surface-2: #f6f6f6;
  --glass: rgb(255 255 255 / 0.72);
  --text: #0a0a0a;
  --text-2: #4a4a4a;
  --text-3: #878787;
  --border: #e9e9e9;
  --border-strong: #d4d4d4;
  --accent: #3f73ab;
  --accent-2: #087d87;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent-2) 10%, transparent);
  --accent-gradient: linear-gradient(90deg, #087d87 0%, #b42155 100%);
  --ring-gradient: linear-gradient(90deg, #087d87, #b42155, #087d87);
  --heart: #e5484d;
  --warn: #b7791f;
  --ok: #22c55e;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 12px 32px -12px rgb(0 0 0 / 0.14);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.05), 0 30px 60px -18px rgb(0 0 0 / 0.25);

  --code-bg: #f6f6f6;
  --hl-keyword: #b4366b;
  --hl-string: #2f6f4f;
  --hl-number: #a15c12;
  --hl-comment: #8a8a8a;
  --hl-title: #3f63b4;
  --hl-attr: #3f73ab;
  --hl-built: #8a5a12;
  --hl-meta: #8a8a8a;

  --radius: 4px;
  --radius-sm: 3px;
  --radius-lg: 6px;
  --cut: 14px;
  --accent-3: #ff2a6d;
  --glow-accent: 0 0 14px rgb(252 238 10 / 0.45);
  --glow-cyan: 0 0 14px rgb(0 240 255 / 0.45);
  --glow-pink: 0 0 14px rgb(255 42 109 / 0.45);
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-display: 'Chakra Petch', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-hud: 'Share Tech Mono', 'JetBrains Mono', 'Cascadia Code', ui-monospace, monospace;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  color-scheme: light;
}

/* ------------------------------------------------------------------ tokens：深色（前台固定使用） */

:root[data-theme='dark'] {
  --bg: #07080c;
  --bg-soft: #0b0d13;
  --surface: #10131b;
  --surface-2: #161a24;
  --glass: rgb(12 14 20 / 0.72);
  --text: #e8f1f5;
  --text-2: #a7b4bf;
  --text-3: #808c99;
  --border: #1d2330;
  --border-strong: #2a3344;
  --accent: #fcee0a;
  --accent-2: #00f0ff;
  --accent-gradient: linear-gradient(90deg, #00f0ff, #ff2a6d);
  --ring-gradient: linear-gradient(90deg, #00f0ff, #ff2a6d, #fcee0a, #00f0ff);
  --accent-ink: #07080c;
  --accent-soft: rgb(252 238 10 / 0.10);
  --heart: #ff2a6d;
  --ok: #39ff88;
  --warn: #fcee0a;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.5);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 36px -14px rgb(0 0 0 / 0.8);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.4), 0 34px 70px -18px rgb(0 0 0 / 0.9);
  --code-bg: #0b0e14;
  --hl-keyword: #ff80a7;
  --hl-string: #8effc0;
  --hl-number: #fcee68;
  --hl-comment: #8795a7;
  --hl-title: #75e8ff;
  --hl-attr: #a4c9ff;
  --hl-built: #ffd18c;
  --hl-meta: #a7b4bf;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #07080c;
    --bg-soft: #0b0d13;
    --surface: #10131b;
    --surface-2: #161a24;
    --glass: rgb(12 14 20 / 0.72);
    --text: #e8f1f5;
    --text-2: #a7b4bf;
    --text-3: #808c99;
    --border: #1d2330;
    --border-strong: #2a3344;
    --accent: #fcee0a;
    --accent-2: #00f0ff;
    --accent-gradient: linear-gradient(90deg, #00f0ff, #ff2a6d);
    --ring-gradient: linear-gradient(90deg, #00f0ff, #ff2a6d, #fcee0a, #00f0ff);
    --accent-ink: #07080c;
    --accent-soft: rgb(252 238 10 / 0.10);
    --heart: #ff2a6d;
    --ok: #39ff88;
    --warn: #fcee0a;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.5);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 36px -14px rgb(0 0 0 / 0.8);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.4), 0 34px 70px -18px rgb(0 0 0 / 0.9);
    --code-bg: #0b0e14;
    --hl-keyword: #ff80a7;
    --hl-string: #8effc0;
    --hl-number: #fcee68;
    --hl-comment: #8795a7;
    --hl-title: #75e8ff;
    --hl-attr: #a4c9ff;
    --hl-built: #ffd18c;
    --hl-meta: #a7b4bf;
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 100px;
}
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--font-sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  text-autospace: normal;
}
img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
h1,
h2,
h3,
h4 {
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}
::selection {
  background: color-mix(in srgb, var(--accent-2) 35%, transparent);
}
:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
}
.icon {
  flex: none;
}

/* 主题图标（后台用） */
.i-moon {
  display: none;
}
:root[data-theme='dark'] .i-sun {
  display: none;
}
:root[data-theme='dark'] .i-moon {
  display: block;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .i-sun {
    display: none;
  }
  :root:not([data-theme='light']) .i-moon {
    display: block;
  }
}

/* ------------------------------------------------------------------ 通用 */

.container {
  width: min(100% - 48px, 1200px);
  margin-inline: auto;
}
.container-wide {
  width: min(100% - 32px, 1400px);
  margin-inline: auto;
}
@media (max-width: 640px) {
  .container {
    width: calc(100% - 40px);
  }
}
.muted {
  color: var(--text-3);
}
.display {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.accent-gradient {
  background: var(--accent-gradient);
}
.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 10001;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 16px;
}

/* 小标题：短横线 + 大写字距 */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--border-strong);
}
.eyebrow.no-line::before {
  display: none;
}

@keyframes gradient-shift {
  0% {
    background-position:
      0 0,
      0% 50%;
  }
  50% {
    background-position:
      0 0,
      100% 50%;
  }
  100% {
    background-position:
      0 0,
      0% 50%;
  }
}

/* ------------------------------------------------------------------ 按钮：悬停出现流动的渐变描边 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 28px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 0.35s var(--ease-out),
    background-color 0.3s,
    color 0.3s,
    border-color 0.3s;
}
.btn:hover {
  transform: scale(1.05);
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
  cursor: progress;
  transform: none;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-ghost {
  border-color: var(--border-strong);
  background: var(--bg);
  color: var(--text);
}
.btn-primary:hover,
.btn-ghost:hover,
.ring-hover:hover {
  border-color: transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    var(--ring-gradient) border-box;
  background-size:
    100% 100%,
    200% 100%;
  color: var(--text);
  animation: gradient-shift 3s ease infinite;
}
.btn-danger {
  border-color: color-mix(in oklab, var(--heart) 35%, transparent);
  background: transparent;
  color: var(--heart);
}
.btn-danger:hover {
  border-color: var(--heart);
  background: var(--heart);
  color: #fff;
}
.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  gap: 6px;
}
.btn-sm:hover {
  transform: scale(1.03);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition:
    background-color 0.25s,
    color 0.25s,
    transform 0.25s var(--ease-out);
}
.icon-btn:hover {
  background: color-mix(in oklab, var(--text) 8%, transparent);
  color: var(--text);
}
.icon-btn:active {
  transform: scale(0.92);
}

.kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--text-3);
  font: 500 10.5px/1 var(--font-mono);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 标签、元信息 */

.tag {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  transition:
    color 0.25s,
    border-color 0.25s,
    background-color 0.25s;
}
.tag-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}
.tag-chip sup {
  margin-left: 4px;
  color: var(--text-3);
  font-size: 10px;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12.5px;
}
.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}
mark {
  padding: 0 2px;
  border-radius: 3px;
  background: rgb(252 238 10 / 0.2);
  color: var(--text);
}

/* ------------------------------------------------------------------ 提示条 */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 10000;
  display: grid;
  justify-items: center;
  gap: 8px;
  translate: -50% 0;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: toast-in 0.45s var(--ease-out) both;
}
.toast.is-error {
  border-color: color-mix(in oklab, var(--heart) 50%, transparent);
  color: var(--heart);
}
.toast.is-out {
  animation: toast-out 0.25s ease-in forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(6px);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes blur-in {
  from {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(10px);
  }
}

/* ------------------------------------------------------------------ 正文排版 */

.prose {
  color: var(--text-2);
  font-size: 16.5px;
  line-height: 1.9;
  overflow-wrap: break-word;
}
.prose > * {
  margin-block: 0;
}
.prose > * + * {
  margin-top: 1.15em;
}
.prose figure {
  margin-inline: 0;
}
.prose > :first-child {
  margin-top: 0;
}
.prose h2,
.prose h3,
.prose h4 {
  position: relative;
  margin: 2.2em 0 0.7em;
  color: var(--text);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
  scroll-margin-top: 110px;
}
.prose h2 {
  font-size: 1.5em;
}
.prose h3 {
  font-size: 1.22em;
}
.prose h4 {
  font-size: 1.06em;
}
.prose .anchor {
  position: absolute;
  left: -1.1em;
  padding-right: 0.3em;
  color: var(--text-3);
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.2s;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose h4:hover .anchor {
  opacity: 1;
}
.prose strong {
  color: var(--text);
  font-weight: 600;
}
.prose a:not(.anchor) {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 60%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition:
    color 0.2s,
    text-decoration-color 0.2s;
}
.prose a:not(.anchor):hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.prose ul,
.prose ol {
  padding-left: 1.4em;
}
.prose li + li {
  margin-top: 0.4em;
}
.prose li::marker {
  color: var(--text-3);
}
.prose li > ul,
.prose li > ol {
  margin-top: 0.4em;
}
.prose blockquote {
  position: relative;
  margin-inline: 0;
  padding: 1em 1.4em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
}
.prose blockquote::before {
  content: '';
  position: absolute;
  inset: 14px auto 14px 0;
  width: 2px;
  border-radius: 2px;
  background: var(--accent-gradient);
}
.prose blockquote > * + * {
  margin-top: 0.7em;
}
.prose blockquote p {
  margin: 0;
}
.prose hr {
  margin: 3em 0;
  border: 0;
  text-align: center;
}
.prose hr::before {
  content: '∗ ∗ ∗';
  color: var(--text-3);
  font-family: var(--font-display);
  letter-spacing: 0.8em;
}
.prose :not(pre) > code {
  padding: 0.15em 0.45em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.prose img {
  border-radius: var(--radius-sm);
  cursor: zoom-in;
}
.prose p img {
  display: inline-block;
  vertical-align: middle;
}
.prose .md-figure {
  margin-block: 2em;
  text-align: center;
}
.prose .md-figure img {
  margin-inline: auto;
  border: 1px solid var(--border);
}
.prose figcaption {
  margin-top: 0.8em;
  color: var(--text-3);
  font-size: 13px;
}
.prose .table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.prose th,
.prose td {
  padding: 0.7em 1em;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.prose th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.prose tr:last-child td {
  border-bottom: 0;
}
.prose input[type='checkbox'] {
  margin-right: 0.4em;
  accent-color: var(--accent);
}

/* 代码块 */
.prose .code-block {
  margin-block: 1.8em;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
}
.code-block figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font: 500 11.5px/1.6 var(--font-mono);
  letter-spacing: 0.04em;
  text-align: left;
}
.code-copy {
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
}
.code-copy:hover {
  background: var(--surface-2);
  color: var(--text);
}
.code-copy.is-copied {
  color: var(--accent);
}
.code-block pre {
  margin: 0;
  padding: 16px 20px;
  overflow-x: auto;
  color: var(--text);
  font: 13px/1.75 var(--font-mono);
  tab-size: 4;
}
.code-block code {
  font-family: inherit;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-tag,
.hljs-deletion {
  color: var(--hl-keyword);
}
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-selector-attr,
.hljs-template-tag {
  color: var(--hl-string);
}
.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
  color: var(--hl-number);
}
.hljs-comment,
.hljs-quote {
  color: var(--hl-comment);
  font-style: italic;
}
.hljs-title,
.hljs-section,
.hljs-title.function_,
.hljs-selector-id,
.hljs-selector-class {
  color: var(--hl-title);
}
.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-property,
.hljs-name,
.hljs-link {
  color: var(--hl-attr);
}
.hljs-built_in,
.hljs-type,
.hljs-title.class_,
.hljs-params {
  color: var(--hl-built);
}
.hljs-meta,
.hljs-meta .hljs-keyword {
  color: var(--hl-meta);
}
.hljs-emphasis {
  font-style: italic;
}
.hljs-strong {
  font-weight: 700;
}
