html[data-lang="zh"] .lang-en { display: none !important; }
html[data-lang="en"] .lang-zh { display: none !important; }

:root {
  --ink: #05070c;
  --accent: #1f5eff;
  --fg: #ffffff;
  --fg-90: rgba(255, 255, 255, 0.90);
  --fg-80: rgba(255, 255, 255, 0.80);
  --fg-70: rgba(255, 255, 255, 0.70);
  --fg-65: rgba(255, 255, 255, 0.65);
  --fg-60: rgba(255, 255, 255, 0.60);
  --fg-55: rgba(255, 255, 255, 0.55);
  --fg-50: rgba(255, 255, 255, 0.50);
  --fg-45: rgba(255, 255, 255, 0.45);
  --fg-40: rgba(255, 255, 255, 0.40);
  --line: rgba(255, 255, 255, 0.12);
  --line-10: rgba(255, 255, 255, 0.10);
  --line-20: rgba(255, 255, 255, 0.20);
  --line-30: rgba(255, 255, 255, 0.30);
  --stroke: #ffffff;
  --card: #000000;
  --menu: rgba(10, 10, 10, 0.95);
}

html[data-theme="light"] {
  --ink: #f3f0e8;
  --fg: #14161c;
  --fg-90: rgba(20, 22, 28, 0.90);
  --fg-80: rgba(20, 22, 28, 0.80);
  --fg-70: rgba(20, 22, 28, 0.70);
  --fg-65: rgba(20, 22, 28, 0.65);
  --fg-60: rgba(20, 22, 28, 0.60);
  --fg-55: rgba(20, 22, 28, 0.55);
  --fg-50: rgba(20, 22, 28, 0.50);
  --fg-45: rgba(20, 22, 28, 0.45);
  --fg-40: rgba(20, 22, 28, 0.40);
  --line: rgba(20, 22, 28, 0.12);
  --line-10: rgba(20, 22, 28, 0.10);
  --line-20: rgba(20, 22, 28, 0.20);
  --line-30: rgba(20, 22, 28, 0.30);
  --stroke: #14161c;
  --card: #ffffff;
  --menu: rgba(243, 240, 232, 0.96);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  color-scheme: dark;
}

html[data-theme="light"] { color-scheme: light; }

body {
  background: var(--ink);
  color: var(--fg);
  transition: background-color 220ms ease, color 220ms ease;
}

::selection {
  background: #1f5eff;
  color: #fff;
}

:focus-visible {
  outline: 2px solid #7aa2ff;
  outline-offset: 3px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  display: block;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fg) 22%, transparent);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--ink);
  border-bottom: 1px solid var(--line-10);
}

.dash-rule {
  background-image: repeating-linear-gradient(
    90deg,
    var(--line-30) 0,
    var(--line-30) 4px,
    transparent 4px,
    transparent 9px
  );
  height: 1px;
}

.theme-toggle {
  position: relative;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  color: var(--fg);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  flex: 0 0 44px;
  transition: background 180ms ease, color 180ms ease;
}

.theme-toggle:hover {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}

.theme-toggle svg {
  position: absolute;
  width: 20px;
  height: 20px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

html[data-theme="dark"] .theme-icon-sun { opacity: 1; transform: none; }
html[data-theme="dark"] .theme-icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.7); }
html[data-theme="light"] .theme-icon-sun { opacity: 0; transform: rotate(90deg) scale(0.7); }
html[data-theme="light"] .theme-icon-moon { opacity: 1; transform: none; }

.lang-switch {
  position: relative;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.lang-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
  opacity: 0.42;
  transition: opacity 180ms ease, background 180ms ease;
}

.lang-switch button[aria-pressed="true"] {
  opacity: 1;
  background: color-mix(in srgb, var(--fg) 10%, transparent);
}

.lang-switch button:hover { opacity: 1; }

.mobile-menu-panel { background: var(--menu); }

.legal-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--fg-45);
}

.legal-crumbs li {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.legal-crumbs li + li::before {
  content: "›";
  margin: 0 0.55rem;
  color: var(--fg-40);
}

.legal-crumbs a {
  color: inherit;
  text-decoration: none;
}

.legal-crumbs a:hover { color: var(--fg); }

.legal-crumbs [aria-current="page"] { color: var(--fg-80); }

.legal-toc {
  margin-top: 2.5rem;
}

.legal-toc-label {
  margin: 0 0 0.75rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-45);
}

.legal-toc-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.legal-toc-scroll::-webkit-scrollbar {
  display: none;
}

.legal-toc ol {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0 1rem 1rem 0;
  width: max-content;
}

.legal-toc a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0 0.9rem;
  border: 1px solid var(--line-20);
  border-radius: 999px;
  color: var(--fg-65);
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.875rem;
  line-height: 1.3;
}

.legal-toc a:hover { color: var(--fg); border-color: var(--fg-40); }

.legal-toc .idx {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--fg-45);
}

.legal-toc a[aria-current="true"] {
  color: var(--fg);
  border-color: var(--fg);
}

.legal-toc a[aria-current="true"] .idx { color: var(--accent); }

@media (min-width: 1024px) {
  .legal-toc {
    position: sticky;
    top: 6rem;
    align-self: start;
    max-height: calc(100vh - 7.5rem);
    margin-top: 0;
    overflow: auto;
  }

  .legal-toc-scroll { overflow: visible; }

  .legal-toc ol {
    flex-direction: column;
    gap: 0;
    width: auto;
    padding: 0;
  }

  .legal-toc a {
    min-height: 40px;
    padding: 0.35rem 0 0.35rem 0.8rem;
    border: none;
    border-radius: 0;
    white-space: normal;
  }

  .legal-toc a[aria-current="true"] {
    box-shadow: inset 2px 0 0 var(--accent);
  }
}

.legal-prose section {
  scroll-margin-top: 6rem;
}

.legal-prose section + section {
  margin-top: 3.25rem;
  padding-top: 3.25rem;
  border-top: 1px solid var(--line);
}

.legal-prose h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.legal-prose h2 .idx {
  display: block;
  margin-bottom: 0.7rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--fg-45);
}

.legal-prose h3 {
  margin: 1.75rem 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.legal-prose p,
.legal-prose li {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--fg-80);
}

.legal-prose p { margin: 1rem 0 0; }

.legal-prose .lang-zh > p:first-child,
.legal-prose .lang-en > p:first-child,
.legal-prose h3 + p { margin-top: 0.85rem; }

.legal-prose strong {
  font-weight: 600;
  color: var(--fg);
}

.legal-prose a {
  color: var(--fg);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.legal-prose a:hover { text-decoration-color: var(--fg); }

.legal-list,
.legal-steps {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.legal-list li {
  position: relative;
  margin-top: 0.75rem;
  padding-left: 1.15rem;
}

.legal-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.78em;
  width: 8px;
  height: 1px;
  background: var(--accent);
}

.legal-steps { counter-reset: step; }

.legal-steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.75rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--line);
}

.legal-steps li::before {
  content: counter(step, decimal-leading-zero);
  padding-top: 0.28rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--fg-45);
}

.legal-table-wrap {
  margin-top: 1.25rem;
  overflow-x: auto;
  max-width: 100%;
  border-top: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.legal-table-wrap table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.legal-table-wrap th,
.legal-table-wrap td {
  padding: 0.95rem 1.25rem 0.95rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.legal-table-wrap th {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-45);
}

.legal-table-wrap td {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--fg-80);
}

footer a[aria-current="page"] { color: var(--fg); }

html[data-theme="light"] .text-white:not(.bg-accent) { color: var(--fg); }
html[data-theme="light"] .text-white\/90 { color: var(--fg-90); }
html[data-theme="light"] .text-white\/80 { color: var(--fg-80); }
html[data-theme="light"] .text-white\/70 { color: var(--fg-70); }
html[data-theme="light"] .text-white\/65 { color: var(--fg-65); }
html[data-theme="light"] .text-white\/60 { color: var(--fg-60); }
html[data-theme="light"] .text-white\/55 { color: var(--fg-55); }
html[data-theme="light"] .text-white\/50 { color: var(--fg-50); }
html[data-theme="light"] .text-white\/45 { color: var(--fg-45); }
html[data-theme="light"] .text-white\/40 { color: var(--fg-40); }
html[data-theme="light"] .hover\:text-white:hover { color: var(--fg); }
html[data-theme="light"] .hover\:text-white\/70:hover { color: var(--fg-70); }
html[data-theme="light"] .hover\:text-white\/80:hover { color: var(--fg-80); }
html[data-theme="light"] .border-white { border-color: var(--stroke); }
html[data-theme="light"] .border-white\/10 { border-color: var(--line-10); }
html[data-theme="light"] .border-white\/20 { border-color: var(--line-20); }
html[data-theme="light"] .bg-ink { background-color: var(--ink); }
html[data-theme="light"] .bg-black { background-color: var(--card); }
html[data-theme="light"] .bg-accent { color: #fff; }
html[data-theme="light"] footer a[aria-current="page"] { color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body { transition: none; }
  .theme-toggle svg,
  .lang-switch button { transition: none; }
}
