:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --muted: #f5f5f5;
  --text-primary: #0a0a0a;
  --text-body: #262626;
  --text-secondary: #525252;
  --border: #e5e5e5;
  --border-table: #d4d4d4;
  --link: #1a56db;
  --link-underline: rgba(26, 86, 219, .4);
  --legal-header-height: 5.5rem;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* Pages embedded in the app's own navigation chrome have no in-page top bar. */
html.no-topbar { --legal-header-height: 0rem; }

html.no-topbar .legal-main { padding-top: 24px; }

* { box-sizing: border-box; }

html {
  scroll-padding-top: var(--legal-header-height);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

.legal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--legal-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: 0 1rem;
}

.legal-back {
  justify-self: start;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-primary);
  transition: background-color .15s ease;
}

.legal-back:hover { background: var(--muted); }
.legal-back svg { width: 24px; height: 24px; }

.lang-switch {
  position: relative;
}

.lang-button {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color .15s ease;
}

.lang-button:hover,
.lang-switch.is-open .lang-button {
  background: var(--muted);
}

.flag {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

.flag svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lang-button .chevron {
  width: 16px;
  height: 16px;
  transition: transform .18s ease;
}

.lang-switch.is-open .lang-button .chevron {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 172px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .12);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  color: var(--text-body);
  font-size: .9375rem;
  font-weight: 500;
  transition: background-color .15s ease;
}

.lang-option:hover,
.lang-option.active {
  background: var(--muted);
  color: var(--text-primary);
}

.lang-option span {
  flex: 1;
}

.lang-option .check {
  width: 16px;
  height: 16px;
  color: var(--link);
  visibility: hidden;
}

.lang-option.active .check {
  visibility: visible;
}
.legal-layout {
  min-height: calc(100vh - var(--legal-header-height));
  display: block;
}

.legal-nav { display: none; }

.legal-main {
  min-width: 0;
  padding: 8px 16px 64px;
}

.legal-document {
  max-width: 46rem;
  margin: 0 auto;
  color: var(--text-body);
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

html:lang(zh-CN) .legal-document { line-height: 1.8; overflow-wrap: anywhere; }

.legal-document > :first-child { margin-top: 0; }

.legal-document h1 {
  margin: 0 0 .75em;
  color: var(--text-primary);
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -.021em;
  line-height: 1.2;
}

.legal-document h3 {
  margin: 2em 0 .5em;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.011em;
  line-height: 1.3;
  scroll-margin-top: var(--legal-header-height);
}

.legal-document p { margin: 0 0 .875em; }

.legal-document strong {
  color: var(--text-primary);
  font-weight: 600;
}

.legal-document a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  transition: text-decoration-color .15s ease;
}

.legal-document a:hover { text-decoration-color: currentColor; }

.legal-document ul {
  margin: 0 0 .875em;
  padding-left: 1.625em;
  list-style-type: disc;
}

.legal-document li {
  margin: .375em 0;
  padding-left: .25em;
}

.legal-document li::marker { color: var(--text-secondary); }
.legal-document li > :last-child { margin-bottom: 0; }

.table-wrap {
  max-width: 100%;
  margin: 1.25em 0 1.5em;
  overflow-x: auto;
  border: 1px solid var(--border-table);
  border-radius: 8px;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9375rem;
  line-height: 1.55;
}

.table-wrap th,
.table-wrap td {
  min-width: 8rem;
  padding: .625em .875em;
  border: 1px solid var(--border-table);
  text-align: left;
  vertical-align: top;
}

.table-wrap th,
.table-wrap th {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
}

.table-wrap td {
  color: var(--text-body);
  font-weight: 400;
}

.legal-section { margin: 0; }

.page-foot {
  padding: 0 16px 32px;
  color: var(--text-secondary);
  font-size: .875rem;
}

.foot-inner {
  max-width: 46rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.foot-links { display: flex; gap: 20px; }
.foot-links a:hover { color: var(--text-primary); text-decoration: underline; }

@media (min-width: 768px) {
  .legal-topbar { padding: 0 80px; }

  .legal-layout {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
  }

  .legal-nav {
    display: block;
    position: sticky;
    top: var(--legal-header-height);
    grid-column: span 3;
    max-height: calc(100vh - var(--legal-header-height));
    overflow-y: auto;
    align-self: start;
    padding: 16px;
  }

  .legal-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .legal-nav li { text-align: right; }

  .legal-nav a {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .legal-nav a:hover { text-decoration: underline; }
  .legal-nav a[aria-current="page"] { font-weight: 800; }

  .legal-main {
    grid-column: span 6;
    padding: 8px 16px 64px;
  }

  .legal-aside { grid-column: span 3; }

  .table-wrap {
    max-width: none;
    margin-right: -10rem;
  }
}

@media (min-width: 1024px) {
  .legal-topbar { padding: 0 160px; }
}

@media (max-width: 767px) {
  .legal-topbar {
    padding: 0 16px;
  }
}
