/* ===== LEGAL PAGES (/terms) =====
   Long-form legal text: a single readable column, left-aligned. Deliberately
   does not reuse .install-card — that one is centered and capped at 480px,
   which is right for a short call to action and wrong for a document. */

/* styles.css pins html/body to height:100% for the chat app's fixed shell.
   A document has to grow instead, and the page gradient has to cover the whole
   scroll height: sized to a viewport-tall root box it would otherwise tile,
   banding the page every screenful. Attaching it to the viewport paints it
   once. Loaded after styles.css, so these win. */
html,
body {
  height: auto;
  min-height: 100%;
}

html {
  background: linear-gradient(180deg, #130b18 0%, #0b0810 38%, var(--page-bg) 100%) no-repeat fixed var(--page-bg);
  color: var(--text);
}

body {
  background: none;
}

.legal {
  max-width: 76ch;
  margin: 0 auto;
  /* Nothing is pinned on this page, so at scroll position 0 the title is what
     the dynamic island covers; the column has to start below it. */
  padding: calc(28px + env(safe-area-inset-top)) 20px 64px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-dim);
}

.legal-title {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  color: #fff;
  margin: 8px 0 6px;
}

.legal-meta {
  margin: 0 0 28px;
  font-size: 13px;
  color: var(--text-dim2);
}

.legal p {
  margin: 0 0 14px;
}

.legal a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.legal a:hover {
  color: #fff;
}

.legal strong {
  color: #fff;
  font-weight: 600;
}

/* Table of contents. Anchors only — no JS. */
.legal-toc {
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
  padding: 18px 20px 14px;
  margin: 0 0 36px;
}

.legal-toc-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim2);
}

.legal-toc-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 2px 24px;
  margin: 0;
  padding-left: 22px;
  font-size: 14px;
}

.legal-toc-list li {
  margin-bottom: 4px;
}

.legal-toc-list a,
.legal-toc-extra a {
  color: var(--text-dim);
  text-decoration: none;
}

.legal-toc-list a:hover,
.legal-toc-extra a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.legal-toc-extra {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 14px;
}

/* One rule per section, so the source document's "---" separators survive
   without an <hr> in the markup. */
.legal-section {
  border-top: 1px solid rgba(255, 255, 255, .09);
  padding-top: 26px;
  margin-top: 26px;
  /* The table of contents links to the sections, not the headings, so the jump
     offset has to live here — .gallery-header is sticky (63px) and would
     otherwise cover the heading of whichever section was just jumped to. */
  scroll-margin-top: 76px;
}

.legal-intro {
  margin-bottom: 8px;
}

.legal h2 {
  font-size: 21px;
  line-height: 1.3;
  font-weight: 700;
  color: #fff;
  margin: 0 0 16px;
  /* Keep anchor targets clear of the sticky-ish page header. */
  scroll-margin-top: 76px;
}

.legal h3 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 26px 0 12px;
  scroll-margin-top: 76px;
}

/* The source document numbers its sub-lists "a)", "b)" … — <ol type="a">
   would render "a." instead, so the marker is drawn from a counter. */
.legal-alpha {
  list-style: none;
  margin: 0 0 16px;
  padding-left: 28px;
  counter-reset: legal-alpha;
}

.legal-alpha > li {
  counter-increment: legal-alpha;
  position: relative;
  margin-bottom: 9px;
}

.legal-alpha > li::before {
  content: counter(legal-alpha, lower-alpha) ")";
  position: absolute;
  left: -28px;
  font-weight: 600;
  color: var(--accent);
}

.legal-list {
  margin: 0 0 16px;
  padding-left: 22px;
}

.legal-list li {
  margin-bottom: 9px;
}

.legal-contact {
  font-size: 16px;
  font-weight: 600;
}

.legal-top {
  margin: 32px 0 0;
  font-size: 14px;
}

.legal-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 76ch;
  margin: 0 auto;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, .09);
  font-size: 12px;
  color: var(--text-dim2);
}

@media (max-width: 640px) {
  .legal {
    padding: 20px 16px 48px;
    font-size: 14.5px;
  }

  .legal-title {
    font-size: 25px;
  }

  .legal h2 {
    font-size: 19px;
  }

  .legal-toc-list {
    grid-template-columns: 1fr;
  }

  .legal-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
}
