/* Legal reading layout, adapted from the Seedance terms page structure. */
.legal-hero,
.legal-layout {
  --legal-text: #f4f2e9;
  --legal-muted: #a8afa0;
  --legal-line: #343b2c;
  --legal-accent: #d8ff47;
  color: var(--legal-text);
  font-family: var(--font, system-ui, sans-serif);
}

.legal-hero {
  padding: 54px 0 56px;
  border-bottom: 1px solid var(--legal-line);
  background: radial-gradient(ellipse at 50% 0, #d8ff470b, transparent 62%),
    linear-gradient(180deg, #161c10, #10120f);
}
.legal-hero > .container { max-width: 1160px; text-align: center; }
.legal-hero .breadcrumbs { margin-bottom: 32px; text-align: left; font-size: 11px; line-height: 1.7; }
.legal-hero .eyebrow { justify-content: center; margin-bottom: 16px; color: var(--legal-accent); }
.legal-hero h1 {
  max-width: 900px;
  margin: 0 auto 20px;
  color: var(--legal-text);
  font-size: clamp(36px, 4.6vw, 60px);
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -.035em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.legal-description { max-width: 680px; margin: 0 auto; color: #c4cbbd; font-size: 16px; line-height: 1.9; text-wrap: pretty; }
.legal-updated { margin: 22px 0 0; color: var(--legal-muted); font-size: 13px; line-height: 1.8; }
.legal-updated time { font-variant-numeric: tabular-nums; }

.legal-layout.container {
  display: grid;
  grid-template-columns: 220px minmax(0, 900px);
  align-items: start;
  gap: 40px;
  max-width: 1160px;
  margin-top: 48px;
  margin-bottom: 88px;
}
.legal-index {
  position: sticky;
  top: calc(var(--header-height, 80px) + 24px);
  min-width: 0;
  max-height: calc(100svh - var(--header-height, 80px) - 48px);
  padding: 20px 18px 14px;
  border: 1px solid var(--legal-line);
  border-radius: 10px;
  background: #151a11;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #53613b #151a11;
}
.legal-index > strong { display: block; margin-bottom: 12px; color: var(--legal-text); font-size: 12px; font-weight: 750; letter-spacing: .035em; }
.legal-index ol,
.legal-toc ol { margin: 0; padding-left: 23px; list-style: decimal-leading-zero; }
.legal-index li,
.legal-toc li { padding-left: 2px; color: #7f8e6a; font-size: 11px; }
.legal-index li::marker,
.legal-toc li::marker { font-variant-numeric: tabular-nums; }
.legal-index li a,
.legal-toc li a { display: block; padding: 8px 2px 8px 5px; color: #b5bfa9; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.legal-index li a:hover,
.legal-toc li a:hover,
.legal-index li a[aria-current="location"] { color: var(--legal-accent); text-decoration: underline; text-underline-offset: 4px; }
.legal-toc { display: none; }

.legal-document {
  min-width: 0;
  width: 100%;
  max-width: 900px;
  padding: 36px 40px;
  border: 1px solid var(--legal-line);
  border-radius: 12px;
  background: #161b13;
  box-shadow: 0 20px 70px #00000024;
  overflow-wrap: anywhere;
}
.legal-section { padding: 30px 0 32px; border-bottom: 1px solid var(--legal-line); }
.legal-section[id] { scroll-margin-top: 24px; }
.legal-section:first-child { padding-top: 0; }
.legal-section:last-of-type { border-bottom: 0; }
.legal-number { display: inline-block; margin-bottom: 9px; color: var(--legal-accent); font-size: 11px; font-weight: 750; line-height: 1.5; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.legal-section h2 { margin: 0 0 18px; color: var(--legal-text); font-size: clamp(22px, 2.1vw, 27px); font-weight: 750; line-height: 1.4; letter-spacing: -.025em; text-wrap: pretty; }
.legal-section h3 { margin: 24px 0 12px; color: var(--legal-text); font-size: 18px; font-weight: 700; line-height: 1.5; }
.legal-section p,
.legal-section li { color: #bec6b6; font-size: 16px; line-height: 1.9; }
.legal-section p { margin: 0 0 16px; }
.legal-section ul,
.legal-section ol { margin: 16px 0; padding-left: 23px; }
.legal-section li { margin-bottom: 8px; padding-left: 3px; }
.legal-section li::marker { color: #a4ba76; }
.legal-section strong { color: var(--legal-text); font-weight: 700; }
.legal-section > :last-child { margin-bottom: 0; }
.legal-section a { color: var(--legal-accent); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.legal-section a:hover { color: #e9ffac; }
.legal-section:target h2 { color: var(--legal-accent); }

.legal-related { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; padding: 20px; border: 1px solid #53613a; border-radius: 8px; background: #1c2613; }
.legal-related strong { flex-basis: 100%; margin-bottom: 3px; color: var(--legal-text); font-size: 14px; line-height: 1.6; }
.legal-related a { display: inline-flex; align-items: center; min-height: 40px; color: var(--legal-accent); font-size: 13px; line-height: 1.7; text-decoration: underline; text-underline-offset: 4px; overflow-wrap: anywhere; }
.legal-related a:hover { color: #e9ffac; }
.legal-back-top { display: inline-flex; align-items: center; min-height: 44px; margin-top: 18px; color: #bec6b6; font-size: 13px; line-height: 1.7; text-decoration: underline; text-underline-offset: 4px; }
.legal-back-top:hover { color: var(--legal-accent); }
.legal-hero a:focus-visible,
.legal-layout a:focus-visible,
.legal-toc > summary:focus-visible { outline: 2px solid var(--legal-accent); outline-offset: 4px; border-radius: 3px; }

@media (max-width: 900px) {
  .legal-hero { padding: 42px 0; }
  .legal-layout.container { grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 900px; margin-top: 32px; margin-bottom: 64px; }
  .legal-index { position: static; max-height: none; padding: 12px 20px; overflow: visible; }
  .legal-index > strong,
  .legal-index > ol { display: none; }
  .legal-index:not(:has(.legal-toc)) { display: none; }
  .legal-toc { display: block; min-width: 0; padding: 12px 20px; border: 1px solid var(--legal-line); border-radius: 10px; background: #151a11; }
  .legal-index .legal-toc { padding: 0; border: 0; border-radius: 0; background: transparent; }
  .legal-toc > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; color: var(--legal-text); font-size: 14px; font-weight: 700; line-height: 1.6; list-style: none; cursor: pointer; }
  .legal-toc > summary::-webkit-details-marker { display: none; }
  .legal-toc > summary::after { content: "+"; flex: 0 0 20px; color: var(--legal-accent); font-size: 23px; font-weight: 400; text-align: center; }
  .legal-toc[open] > summary::after { content: "−"; }
  .legal-toc ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 24px; margin-top: 10px; padding-bottom: 8px; }
  .legal-toc li a { min-height: 44px; padding-top: 10px; padding-bottom: 10px; font-size: 13px; }
  .legal-document { padding: 30px; }
}

@media (max-width: 640px) {
  .legal-hero > .container,
  .legal-layout.container { width: calc(100% - 32px); }
  .legal-hero { padding: 32px 0 36px; }
  .legal-hero .breadcrumbs { margin-bottom: 24px; font-size: 10px; }
  .legal-hero h1 { margin-bottom: 16px; font-size: clamp(31px, 8.5vw, 42px); line-height: 1.2; letter-spacing: -.03em; }
  .legal-description { font-size: 14px; line-height: 1.9; }
  .legal-updated { margin-top: 18px; font-size: 12px; }
  .legal-layout.container { gap: 20px; margin-top: 24px; margin-bottom: 48px; }
  .legal-index,
  .legal-toc { padding: 10px 16px; }
  .legal-toc ol { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .legal-document { padding: 24px 20px; border-radius: 10px; }
  .legal-section { padding: 26px 0 28px; }
  .legal-section h2 { margin-bottom: 16px; font-size: 22px; line-height: 1.4; }
  .legal-section h3 { font-size: 17px; }
  .legal-section p,
  .legal-section li { font-size: 15px; line-height: 1.95; }
  .legal-related { padding: 16px; gap: 4px 14px; }
  .legal-related a { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  html:has(.legal-document) { scroll-behavior: auto !important; }
  .legal-hero *,
  .legal-layout * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
