:root {
  --bg: #0b0b0c;
  --bg-2: #101013;
  --panel: #141418;
  --panel-2: #17171c;
  --ink: #f2f2f2;
  --muted: #8d8d92;
  --faint: #6a6a70;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --teal: #2f9e8f;
  --teal-ink: #4fd1bf;
  --teal-soft: rgba(47, 158, 143, 0.14);
  --radius: 16px;
  --maxline: 72ch;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --header-h: 116px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.legal {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--teal-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--teal-ink);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-160%);
  background: var(--teal);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  transition: transform 0.18s ease;
}

.skip-link:focus {
  transform: translateY(0);
  text-decoration: none;
}

/* ---- Header ---- */
.legal-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 11, 12, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.legal-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
}

.legal-brand:hover {
  text-decoration: none;
}

.legal-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.legal-brand-text {
  display: flex;
  flex-direction: column;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.legal-brand-text small {
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.legal-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.seg button.active {
  background: var(--teal);
  color: #fff;
}

.legal-backlink {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.legal-backlink:hover {
  color: var(--ink);
}

.doc-switch {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 20px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.doc-switch::-webkit-scrollbar {
  display: none;
}

.doc-switch a {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
}

.doc-switch a:hover {
  color: var(--ink);
  background: var(--panel);
  text-decoration: none;
}

.doc-switch a.active {
  color: var(--ink);
  background: var(--panel-2);
  border-color: var(--line-strong);
  box-shadow: inset 0 -2px 0 var(--teal);
}

/* ---- Main / document ---- */
.legal-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.doc-head {
  max-width: var(--maxline);
}

.doc-eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-ink);
  font-weight: 700;
  margin-bottom: 14px;
}

.doc-title {
  font-size: clamp(2rem, 4.4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.doc-tagline {
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 60ch;
}

.doc-meta {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
  gap: 10px 30px;
}

.doc-meta dt {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 3px;
}

.doc-meta dd {
  font-size: 0.92rem;
  color: var(--ink);
  font-weight: 600;
}

.doc-summary {
  margin-top: 28px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--teal-soft), rgba(47, 158, 143, 0.03));
}

.doc-summary-title {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-ink);
  font-weight: 700;
  margin-bottom: 12px;
}

.doc-summary ul {
  list-style: none;
  display: grid;
  gap: 9px;
}

.doc-summary li {
  position: relative;
  padding-left: 24px;
  color: #dcdce0;
  font-size: 0.96rem;
}

.doc-summary li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
}

/* ---- Layout: ToC + body ---- */
.doc-layout {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.doc-toc {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow: auto;
  scrollbar-width: thin;
}

.doc-toc-toggle {
  display: none;
}

.doc-toc-title {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
  margin-bottom: 12px;
  padding-left: 13px;
}

.doc-toc-list {
  list-style: none;
  counter-reset: toc;
  border-left: 1px solid var(--line);
}

.doc-toc-list li {
  counter-increment: toc;
}

.doc-toc-list a {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
  padding: 7px 12px 7px 13px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.doc-toc-list a::before {
  content: counter(toc) ". ";
  color: var(--faint);
}

.doc-toc-list a:hover {
  color: var(--ink);
  text-decoration: none;
}

.doc-toc-list a.active {
  color: var(--teal-ink);
  border-left-color: var(--teal);
  font-weight: 600;
}

.doc-toc-list a.active::before {
  color: var(--teal-ink);
}

/* ---- Body sections ---- */
.doc-body {
  max-width: var(--maxline);
}

.doc-section {
  padding-top: 8px;
  margin-bottom: 36px;
}

.doc-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin-bottom: 14px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.doc-section-title:focus {
  outline: none;
}

.doc-section-num {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.doc-section-label {
  flex: 1;
}

.doc-anchor {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: var(--faint);
  opacity: 0;
  transition: opacity 0.16s ease, color 0.16s ease, background 0.16s ease;
  align-self: center;
}

.doc-anchor svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc-section-title:hover .doc-anchor,
.doc-anchor:focus {
  opacity: 1;
}

.doc-anchor:hover {
  color: var(--teal-ink);
  background: var(--panel);
  text-decoration: none;
}

.doc-anchor.copied {
  color: var(--teal-ink);
  opacity: 1;
}

.doc-section-body p {
  margin-bottom: 14px;
  color: #d6d6da;
}

.doc-section-body ul {
  margin: 0 0 16px;
  padding-left: 20px;
}

.doc-section-body li {
  margin-bottom: 8px;
  color: #d6d6da;
}

.doc-section-body li::marker {
  color: var(--teal);
}

.doc-section-body strong {
  color: var(--ink);
  font-weight: 600;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 18px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.doc-table th,
.doc-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.doc-table thead th {
  background: var(--panel-2);
  color: var(--ink);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.doc-table td {
  color: #cdcdd2;
}

.doc-table tr:last-child td {
  border-bottom: 0;
}

.doc-table td:first-child {
  color: var(--ink);
  font-weight: 500;
}

/* ---- Footer ---- */
.legal-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}

.legal-footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
  padding: 40px 24px calc(40px + env(safe-area-inset-bottom, 0px));
}

.legal-footer-brand .legal-brand {
  margin-bottom: 14px;
}

.legal-footer-rights {
  color: var(--faint);
  font-size: 0.82rem;
}

.legal-footer-col h2 {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
  margin-bottom: 14px;
}

.legal-footer-col ul {
  list-style: none;
  display: grid;
  gap: 9px;
}

.legal-footer-col li {
  color: var(--muted);
  font-size: 0.9rem;
}

.legal-footer-col a {
  color: var(--muted);
}

.legal-footer-col a:hover {
  color: var(--ink);
}

/* ---- Responsive ---- */
@media (max-width: 920px) {
  :root {
    --header-h: 108px;
  }

  .doc-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .doc-toc {
    position: static;
    max-height: none;
    margin-bottom: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    overflow: visible;
  }

  .doc-toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 14px 16px;
    cursor: pointer;
  }

  .doc-toc-toggle::after {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
  }

  .doc-toc.open .doc-toc-toggle::after {
    transform: rotate(-135deg);
  }

  .doc-toc-inner {
    display: none;
    padding: 0 16px 14px;
  }

  .doc-toc.open .doc-toc-inner {
    display: block;
  }

  .doc-toc-title {
    display: none;
  }
}

@media (max-width: 680px) {
  .legal-header-inner {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .legal-brand-text small {
    display: none;
  }

  .legal-main {
    padding: 28px 16px 56px;
  }

  .legal-footer-inner {
    grid-template-columns: 1fr;
    gap: 26px;
    padding: 32px 16px;
  }

  .doc-switch {
    padding: 0 14px 10px;
  }
}

@media (max-width: 380px) {
  .seg button {
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .legal-header-actions {
    gap: 10px;
  }

  .doc-section-title {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

/* ---- Print ---- */
@media print {
  :root {
    --ink: #000;
    --muted: #333;
  }

  body.legal {
    background: #fff;
    color: #000;
  }

  .legal-header,
  .legal-footer,
  .doc-toc,
  .skip-link,
  .doc-anchor {
    display: none !important;
  }

  .legal-main {
    max-width: none;
    padding: 0;
  }

  .doc-layout {
    display: block;
  }

  .doc-body,
  .doc-head {
    max-width: none;
  }

  .doc-summary {
    background: none;
    border: 1px solid #999;
  }

  .doc-section-title,
  .doc-section-body p,
  .doc-section-body li,
  .doc-table td {
    color: #000;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .doc-table th {
    background: #eee;
  }
}
