:root {
  --color-page: #F5F4FA;
  --color-surface: #FFFFFF;
  --color-surface-muted: #ECEAF4;
  --color-border: #DCD9E8;
  --color-accent: #6D00FF;
  --color-accent-deep: #4E00B8;
  --color-accent-soft: #A66BFF;
  --color-companion: #FF4FD8;
  --color-text: #14111F;
  --color-text-muted: #5D5871;
  --color-success: #13A36B;
  --color-warning: #E0A200;
  --color-error: #DB2A48;
  --color-console: #1A1626;
  --color-console-raised: #241E33;
  --color-console-border: #2B2540;
  --color-console-dot: #3D3656;
  --color-console-text: #EDEAF7;
  --color-console-muted: #8F89A6;
  --color-console-dim: #5E5876;
  --color-white: #FFFFFF;
  --color-flag-us-red: #B32234;
  --color-flag-us-blue: #3C3B6E;
  --color-flag-hk: #DE2910;
  --color-flag-sg: #EF3340;
  --color-flag-jp: #BC002D;
  --color-flag-fr-blue: #0055A4;
  --color-flag-fr-red: #EF4135;
  --rgb-accent: 109, 0, 255;
  --rgb-white: 255, 255, 255;
  --rgb-success: 19, 163, 107;
  --rgb-console: 26, 22, 38;
  --font-display: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-body: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  --radius-xs: 4px;
  --radius-small: 6px;
  --radius-card: 10px;
  --radius-board: 20px;
  --radius-pill: 999px;
  --shadow-panel: 0 18px 44px -28px rgba(var(--rgb-accent), .22);
  --shadow-console: 0 22px 44px -14px rgba(var(--rgb-accent), .18);
  --shadow-button: 0 10px 24px -12px rgba(var(--rgb-accent), .58);
  --grid-step: 40px;
  --header-height: 64px;
  --shell: 1384px;
  --reading-width: 820px;
  --gutter: clamp(16px, 3vw, 28px);
  --section-space: clamp(64px, 8vw, 112px);
  --toc-offset: 92px;
  --transition-fast: 180ms ease;
  --transition-main: 280ms ease;
}

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

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
}

html.nav-open {
  overflow: hidden;
}

body {
  min-width: 320px;
  margin: 0;
  background-color: var(--color-page);
  background-image:
    linear-gradient(to right, rgba(var(--rgb-accent), .045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(var(--rgb-accent), .045) 1px, transparent 1px);
  background-size: var(--grid-step) var(--grid-step);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

img {
  height: auto;
}

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

button,
summary {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
}

p,
ul,
ol,
blockquote,
pre,
table {
  margin-top: 0;
}

code,
kbd,
samp {
  font-family: var(--font-mono);
}

:not(pre) > code {
  padding: .14em .38em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface-muted);
  overflow-wrap: anywhere;
}

pre {
  max-width: 100%;
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--color-console-border);
  border-radius: var(--radius-card);
  background: var(--color-console);
  color: var(--color-console-text);
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}

pre code {
  white-space: pre;
  overflow-wrap: normal;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--color-text);
  font-family: var(--font-display);
  text-wrap: balance;
}

h1,
.hero-title {
  font-size: clamp(52px, 5vw, 68px);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.1;
}

h2 {
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 850;
  letter-spacing: -.02em;
  line-height: 1.12;
}

h3 {
  font-size: clamp(22px, 2.5vw, 30px);
  font-weight: 750;
  line-height: 1.25;
}

small {
  font-size: .875em;
}

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

:where(a, button, summary, input, select, textarea, [role="tab"]):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.wrap {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.reading-wrap {
  width: 100%;
  max-width: calc(var(--reading-width) + var(--gutter) + var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-top: var(--section-space);
  padding-bottom: var(--section-space);
}

.section-tight {
  padding-top: clamp(40px, 6vw, 72px);
  padding-bottom: clamp(40px, 6vw, 72px);
}

.panel {
  min-width: 0;
  padding: clamp(22px, 3vw, 40px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-board);
  background: var(--color-surface);
  box-shadow: inset 0 1px 0 var(--color-white), var(--shadow-panel);
}

.card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: inset 0 1px 0 var(--color-white), var(--shadow-panel);
}

.eyebrow,
.badge {
  display: inline-flex;
  min-height: 28px;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: 500 12px/1.35 var(--font-mono);
}

.eyebrow-dot,
.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--rgb-accent), .15);
}

.badge-accent {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-white);
}

.badge-success {
  border-color: var(--color-success);
  color: var(--color-success);
}

.gradient-text {
  background: linear-gradient(92deg, var(--color-accent), var(--color-companion));
  color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
}

.no-break {
  white-space: nowrap;
}

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

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

.button,
.btn-primary,
.btn-secondary,
.btn-login {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-weight: 650;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  transition: transform var(--transition-fast), background var(--transition-main), border-color var(--transition-fast);
}

.btn-primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-white);
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  background: linear-gradient(90deg, var(--color-accent), var(--color-companion));
  transform: translateY(-1px);
}

.btn-secondary {
  border-color: var(--color-text);
  background: transparent;
  color: var(--color-text);
}

.btn-secondary:hover {
  background: var(--color-surface);
}

.btn-login {
  min-height: 38px;
  padding-inline: 18px;
  border-color: var(--color-console-border);
  background: var(--color-console);
  color: var(--color-white);
  box-shadow: var(--shadow-button);
}

.btn-login:hover {
  background: var(--color-console-raised);
}

.button-row {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

#site-header,
.preview-header {
  position: relative;
  z-index: 50;
}

.site-topbar {
  position: relative;
  display: flex;
  width: 100%;
  max-width: var(--shell);
  height: var(--header-height);
  margin-inline: auto;
  padding-inline: var(--gutter);
  align-items: center;
  gap: 22px;
}

.site-brand {
  display: inline-flex;
  min-width: max-content;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
  text-decoration: none;
}

.site-brand img {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.site-brand-name {
  font: 800 18px/1 var(--font-display);
  letter-spacing: -.02em;
}

.site-brand-local {
  color: var(--color-text-muted);
  font-weight: 550;
}

.desktop-nav {
  display: flex;
  margin-left: auto;
  align-items: center;
}

.desktop-nav ul {
  display: flex;
  margin: 0;
  padding: 0;
  align-items: center;
  list-style: none;
}

.desktop-nav li {
  display: flex;
  align-items: center;
}

.desktop-nav li + li::before {
  margin-inline: 12px;
  color: var(--color-text-muted);
  content: "·";
  font-weight: 750;
}

.desktop-nav a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
}

.desktop-nav a:hover,
.desktop-nav a[aria-current="page"] {
  color: var(--color-accent);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-picker {
  position: relative;
}

.language-trigger,
.menu-toggle {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
}

.language-trigger {
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.language-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  width: 156px;
  margin: 0;
  padding: 7px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
  list-style: none;
}

.language-picker.is-open .language-menu {
  display: block;
}

.language-menu a {
  display: flex;
  min-height: 38px;
  align-items: center;
  padding-inline: 10px;
  border-radius: var(--radius-small);
  font-size: 13px;
  text-decoration: none;
}

.language-menu a:hover,
.language-menu a[aria-current="true"] {
  background: var(--color-surface-muted);
  color: var(--color-accent);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface);
}

.menu-toggle span {
  width: 18px;
  height: 2px;
  background: var(--color-text);
}

.mobile-drawer {
  position: fixed;
  z-index: 60;
  top: var(--header-height);
  right: 0;
  left: 0;
  display: none;
  max-height: calc(100dvh - var(--header-height));
  padding: 10px var(--gutter) calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
}

.mobile-drawer.is-open {
  display: block;
}

.mobile-drawer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-drawer a {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
}

.mobile-drawer a[aria-current="page"] {
  color: var(--color-accent);
  font-weight: 700;
}

.drawer-languages {
  padding-top: 10px;
}

.drawer-languages strong {
  display: block;
  padding: 8px;
  color: var(--color-text-muted);
  font: 500 11px/1 var(--font-mono);
  text-transform: uppercase;
}

.nav-veil {
  position: fixed;
  z-index: 40;
  inset: var(--header-height) 0 0;
  display: none;
  background: rgba(var(--rgb-console), .28);
}

.nav-veil.is-open {
  display: block;
}

.site-footer,
.preview-footer {
  overflow-x: clip;
  background: var(--color-console);
  color: var(--color-console-text);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(3, minmax(150px, 1fr));
  gap: 34px;
  padding-top: 58px;
  padding-bottom: 44px;
}

.footer-brand {
  min-width: 0;
}

.footer-brand .site-brand {
  color: var(--color-white);
}

.footer-brand p {
  max-width: 440px;
  margin-top: 18px;
  color: var(--color-console-muted);
}

.footer-column h2 {
  margin-bottom: 14px;
  color: var(--color-white);
  font: 650 13px/1.2 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.footer-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links li + li {
  margin-top: 7px;
}

.footer-links a {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  color: var(--color-console-muted);
  font-size: 14px;
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--color-white);
}

.footer-bottom {
  display: flex;
  padding-top: 20px;
  padding-bottom: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--color-console-border);
  color: var(--color-console-muted);
  font-size: 13px;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-legal a {
  min-height: 24px;
}

.reveal {
  transition: opacity .65s ease, transform .65s ease;
}

.reveal.pending {
  opacity: 0;
  transform: translateY(16px);
}

.reveal.shown {
  opacity: 1;
  transform: none;
}

#server-status {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 32px;
  overflow: hidden;
}

#server-status > * {
  min-width: 0;
}

.prose {
  min-width: 0;
}

.prose h2 {
  margin-top: 2.2em;
  margin-bottom: .7em;
}

.prose h3 {
  margin-top: 1.7em;
  margin-bottom: .55em;
}

.prose p,
.prose li {
  color: var(--color-text-muted);
}

.prose strong {
  color: var(--color-text);
}

.prose img {
  border-radius: var(--radius-card);
}

body:has(.toc-tabs) section[id] {
  scroll-margin-top: var(--toc-offset);
}

.tilt-card {
  transform-style: preserve-3d;
  will-change: transform;
}

@media (max-width: 1080px) {
  .desktop-nav li + li::before {
    margin-inline: 7px;
  }

  .desktop-nav a {
    font-size: 13px;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  :root {
    --header-height: 56px;
  }

  .site-topbar {
    height: var(--header-height);
  }

  .desktop-nav {
    display: none;
  }

  .header-tools {
    margin-left: auto;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .language-picker {
    display: none;
  }

  .btn-login {
    min-height: 38px;
    padding-inline: 15px;
  }

  h1,
  .hero-title {
    font-size: clamp(28px, 9vw, 40px);
  }
}

@media (max-width: 640px) {
  .no-break {
    white-space: normal;
  }

  .section {
    padding-top: 64px;
    padding-bottom: 64px;
  }

  .panel,
  .card {
    padding: 20px;
  }

  .button-row > * {
    width: 100%;
  }

  .tilt-card,
  [class*="tilt"] {
    transform: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }

  .decorative-halo,
  .stripe-halo,
  .absolute-decoration {
    max-width: 100%;
    transform: none;
  }
}

@media (max-width: 390px) {
  .site-brand-name {
    font-size: 16px;
  }

  .site-brand img {
    width: 27px;
    height: 27px;
  }

  .header-tools {
    gap: 5px;
  }

  .btn-login {
    padding-inline: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-duration: 0s;
  }

  .reveal,
  .reveal.pending,
  .reveal.shown {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .btn-primary,
  .btn-secondary,
  .tilt-card {
    transition: none;
  }
}