function LegalShell() {
  const sections = [
    { id: 'terms',         num: '01', title: 'Terms of Service' },
    { id: 'privacy',       num: '02', title: 'Privacy Policy' },
    { id: 'cookies',       num: '03', title: 'Cookie Notice' },
    { id: 'accessibility', num: '04', title: 'Accessibility' },
    { id: 'regulatory',    num: '05', title: 'Regulatory & Trademark' },
    { id: 'contact',       num: '06', title: 'Contact & Disclosures' },
  ];
  const [active, setActive] = React.useState('terms');
  React.useEffect(() => {
    const onScroll = () => {
      for (let i = sections.length - 1; i >= 0; i--) {
        const el = document.getElementById(sections[i].id);
        if (el && el.getBoundingClientRect().top < 120) { setActive(sections[i].id); break; }
      }
    };
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  const PH = ({children}) => <span className="placeholder">[{children}]</span>;
  return (
    <main className="legal-page">
      <div className="container">
        <aside>
          <span className="label">// Contents</span>
          <ul>
            {sections.map(s => (
              <li key={s.id}>
                <a href={'#' + s.id} className={active === s.id ? 'active' : ''}>{s.num} · {s.title}</a>
              </li>
            ))}
          </ul>
          <div style={{marginTop: 32, fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.04em', color: 'var(--fg-subtle)', lineHeight: 1.7}}>
            // TS-LEGAL-001<br/>
            // Effective: 2026-04-29<br/>
            // Jurisdiction: <span className="placeholder" style={{display:'inline-block'}}>[state / country]</span>
          </div>
        </aside>

        <article>
          <h1>Legal &amp; Disclosures</h1>
          <div className="doc-meta">// Effective 2026-04-29 · TS-LEGAL-001 · v0.1 working draft</div>

          <section id="terms">
            <span className="num">01 · Terms</span>
            <h2>Terms of Service</h2>
            <p>These Terms of Service ("Terms") govern your access to and use of the products, APIs, dashboards, and documentation provided by <PH>Tetrahedron Systems Legal Entity</PH> ("Tetrahedron Systems," "we," "us"). By accessing the service you agree to these Terms.</p>
            <p>Eligibility. The service is offered to businesses, not consumers. You represent that you have the authority to bind your organization to these Terms and that your use complies with all laws applicable in <PH>jurisdiction</PH> and the jurisdictions in which you transact.</p>
            <p>Accounts &amp; security. You are responsible for safeguarding API keys, signing keys, and access credentials. Notify <a href="mailto:security@tetrahedron-systems.com" style={{color: 'var(--ths-signal)', borderBottom: '1px solid currentColor'}}>security@tetrahedron-systems.com</a> within 24 hours of any suspected compromise.</p>
            <p>Acceptable use. No use of the service to facilitate sanctioned transactions, fraud, money laundering, terrorism financing, or activities prohibited under <PH>applicable AML / sanctions regime</PH>. We reserve the right to suspend access for violations.</p>
            <p>Service levels &amp; settlement. Settlement targets and uptime commitments are described in the Master Service Agreement signed at onboarding. The website is informational; no SLA is created by content on this page.</p>
            <p>Disclaimer of warranties. To the maximum extent permitted by law, the service is provided "as is" without warranty of merchantability, fitness for a particular purpose, or non-infringement. Limitation of liability and indemnification provisions are set forth in the Master Service Agreement.</p>
            <p>Termination. Either party may terminate per the MSA. Upon termination, we will provide a final reconciliation report and assist with data export for 30 days.</p>
            <p>Governing law. These Terms are governed by the laws of <PH>state, USA</PH>, without regard to conflict-of-law principles. Disputes are resolved by binding arbitration in <PH>city, state</PH>, except where prohibited by law.</p>
          </section>

          <section id="privacy">
            <span className="num">02 · Privacy</span>
            <h2>Privacy Policy</h2>
            <p>This policy explains what information we collect, how we use it, and the rights you have under U.S. state privacy laws (including the California Consumer Privacy Act / CPRA, and equivalents in <PH>other states</PH>) and, where applicable, the GDPR.</p>
            <p>What we collect. (i) Account information you provide — name, business email, organization. (ii) Settlement data necessary to operate the service — transaction hashes, amounts, timestamps, jurisdictions, counterparties. (iii) Server logs — IP address, request metadata, user agent. (iv) Cookies and similar technologies — see the Cookie Notice below.</p>
            <p>Why we collect it. To operate, secure, and improve the service; to satisfy our legal and regulatory obligations (including KYC, AML, sanctions screening, and tax reporting); and to communicate with you about your account.</p>
            <p>Sharing. We do not sell personal information. We share data with: (a) sub-processors under contract — <PH>list of named sub-processors</PH>; (b) regulators and law enforcement when required by law; (c) successors in interest in the event of a merger or acquisition.</p>
            <p>Your rights. Subject to verification, you may request access to, correction of, or deletion of personal information about you, and opt out of certain uses. Contact <a href="mailto:privacy@tetrahedron-systems.com" style={{color: 'var(--ths-signal)', borderBottom: '1px solid currentColor'}}>privacy@tetrahedron-systems.com</a>. We do not discriminate against you for exercising these rights.</p>
            <p>Retention. We retain transaction records for the period required by financial-services regulation in <PH>jurisdiction</PH> — generally a minimum of five years.</p>
            <p>Children. The service is not directed to children under 13. We do not knowingly collect personal information from children.</p>
            <p>Changes. We will post material changes here and notify customers by email at least 30 days before they take effect.</p>
          </section>

          <section id="cookies">
            <span className="num">03 · Cookies</span>
            <h2>Cookie Notice</h2>
            <p>This site uses a small set of cookies. Essential cookies are required to operate the service and cannot be disabled. Analytics cookies are off by default and require your consent.</p>
            <ul className="bare">
              <li><b>ths_session</b> — essential. Authenticates your session in the dashboard.</li>
              <li><b>ths_csrf</b> — essential. Mitigates cross-site request forgery on state-changing endpoints.</li>
              <li><b>ths_consent</b> — essential. Records your cookie consent choices.</li>
              <li><b>ths_analytics</b> — optional. First-party page-view counts only. No third-party trackers.</li>
            </ul>
            <p>To withdraw consent, clear the <b>ths_consent</b> cookie and reload. Do-Not-Track headers are honored.</p>
          </section>

          <section id="accessibility">
            <span className="num">04 · Accessibility</span>
            <h2>Accessibility statement</h2>
            <p>We design to <b>WCAG 2.2 AA</b>. Body-text contrast on Bone reaches AAA. Signal Blue is restricted to large text and UI components on light surfaces, never as paragraph text. Keyboard focus is visible on all interactive elements; tab order matches reading order.</p>
            <p>Known issues and accommodations are tracked publicly. Report a barrier to <a href="mailto:accessibility@tetrahedron-systems.com" style={{color: 'var(--ths-signal)', borderBottom: '1px solid currentColor'}}>accessibility@tetrahedron-systems.com</a> — we respond within five business days.</p>
            <p>This statement is provided in compliance with the Americans with Disabilities Act (ADA) and Section 508 of the Rehabilitation Act, as applicable.</p>
          </section>

          <section id="regulatory">
            <span className="num">05 · Regulatory</span>
            <h2>Regulatory &amp; Trademark</h2>
            <p>Where we are licensed, we name the regulator. Where we are not, we say so. No mythology.</p>
            <ul className="bare">
              <li><b>Money services.</b> Registered with FinCEN as a Money Services Business (MSB). Registration number: <PH>MSB number</PH>.</li>
              <li><b>State licensing.</b> Money Transmitter Licenses pending or held in: <PH>list of US states</PH>. Activity in non-licensed states is restricted to <PH>permitted activities</PH>.</li>
              <li><b>International.</b> Activities outside the United States are conducted by <PH>Tetrahedron Systems EU Entity</PH>, registered in <PH>jurisdiction</PH>. Licensed by <PH>regulator</PH> under file <PH>file no.</PH>.</li>
              <li><b>Bank Secrecy Act / AML.</b> We maintain a BSA/AML compliance program, including KYB, sanctions screening (OFAC, EU, UN), Suspicious Activity Reporting, and Currency Transaction Reporting where applicable.</li>
              <li><b>Not a deposit institution.</b> Tetrahedron Systems is not a bank. Funds held on behalf of customers are segregated <PH>pursuant to specific structure</PH>. We do not pay interest.</li>
            </ul>
            <p>Trademarks. "TETRAHEDRON SYSTEMS" and the wireframe mark are claimed marks of the owner. Federal registration in classes 36 (financial services) and 42 (software) is <PH>pending / registered no.</PH>. Use outside this document requires written permission. Geist and Geist Mono are licensed under the SIL Open Font License.</p>
          </section>

          <section id="contact">
            <span className="num">06 · Contact</span>
            <h2>Contact &amp; mandatory disclosures</h2>
            <p>Tetrahedron Systems<br/>
              <PH>Legal entity · Inc. / LLC / Ltd.</PH><br/>
              <PH>Address line 1</PH><br/>
              <PH>City, State, ZIP, USA</PH>
            </p>
            <p>General · <a href="mailto:hello@tetrahedron-systems.com" style={{color: 'var(--ths-signal)', borderBottom: '1px solid currentColor'}}>hello@tetrahedron-systems.com</a><br/>
              Privacy · privacy@tetrahedron-systems.com<br/>
              Security · security@tetrahedron-systems.com · PGP <span style={{fontFamily: 'var(--font-mono)'}}>0x4f2a · keys.openpgp.org</span><br/>
              Legal &amp; subpoenas · <PH>legal@tetrahedron-systems.com</PH>
            </p>
            <p style={{color: 'var(--fg-muted)', fontSize: 13, marginTop: 24}}>
              This page is informational. It does not constitute legal advice or create a contractual relationship. Customers should rely on the executed Master Service Agreement and applicable order forms. © 2026 Tetrahedron Systems. All rights reserved.
            </p>
          </section>
        </article>
      </div>
    </main>
  );
}

window.LegalShell = LegalShell;
