:root {
      --bg: #020c1b;
      --surface: rgb(10 25 47 / 0.6);
      --surface2: rgb(17 34 64 / 0.8);
      --border: rgb(0 200 255 / 0.15);
      --border2: rgb(0 255 136 / 0.2);
      --text: #ccd6f6;
      --muted: #8892b0;
      --dim: #495670;
      --accent: #00c8ff;

      /* cyan */
      --accent2: #ff6b6b;

      /* coral */
      --accent3: #0f8;

      /* green */
      --accent4: #ffd43b;

      /* gold */
      --accent5: #cc5de8;

      /* purple */
      --grad-a: #00c8ff;
      --grad-b: #0f8;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: Lora, Georgia, serif;
      font-size: 17px;
      line-height: 1.85;
      position: relative;
      overflow-x: hidden;
    }

    #bg-canvas {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: -1;
      pointer-events: none;
      opacity: 0.3;
    }

    /* ── HERO ── */
    .hero {
      min-height: 480px;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      margin-top: 50px;
      padding: 80px 56px 56px;
      position: relative;
      overflow: hidden;
      background: linear-gradient(135deg, rgb(2 12 27 / 0.8), rgb(10 25 47 / 0.9));
      border-bottom: 1px solid var(--border);
      backdrop-filter: blur(10px);
    }

    .hero-grid {
      position: absolute;
      inset: 0;
      background-image:
        linear-gradient(rgb(0 200 255 / 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgb(0 200 255 / 0.05) 1px, transparent 1px);
      background-size: 40px 40px;
    }

    .hero-glow {
      position: absolute;
      width: 600px;
      height: 400px;
      background: radial-gradient(circle, rgb(0 200 255 / 0.15) 0%, transparent 60%);
      top: -100px;
      left: -100px;
      pointer-events: none;
    }

    .hero-glow2 {
      position: absolute;
      width: 500px;
      height: 400px;
      background: radial-gradient(circle, rgb(0 255 136 / 0.1) 0%, transparent 60%);
      bottom: -50px;
      right: -50px;
      pointer-events: none;
    }

    .hero-inner {
      max-width: 1200px;
      margin: 0 auto;
      position: relative;
      width: 100%;
      z-index: 2;
    }

    .hero-tag {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: var(--accent3);
      margin-bottom: 20px;
      font-weight: 600;
    }

    .hero h1 {
      font-family: 'DM Serif Display', serif;
      font-size: clamp(3rem, 7vw, 5.5rem);
      font-weight: 400;
      line-height: 1.1;
      letter-spacing: -0.02em;
      margin-bottom: 24px;
      color: #fff;
      text-shadow: 0 0 30px rgb(0 200 255 / 0.3);
    }

    .hero h1 .grad {
      background: linear-gradient(to right, var(--accent), var(--accent3));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .hero-sub {
      font-size: 16px;
      color: var(--muted);
      max-width: 680px;
      font-family: 'JetBrains Mono', monospace;
      line-height: 1.8;
    }

    .hero-pills {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 32px;
    }

    .pill {
      background: rgb(0 200 255 / 0.08);
      border: 1px solid rgb(0 200 255 / 0.3);
      color: var(--accent);
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      padding: 6px 14px;
      border-radius: 20px;
      letter-spacing: 0.08em;
      box-shadow: 0 0 10px rgb(0 200 255 / 0.1);
    }

    /* ── TOC ── */
    .toc-outer {
      max-width: 1200px;
      margin: 60px auto;
      padding: 0 32px;
    }

    .toc-wrap {
      background: var(--surface);
      border: 1px solid var(--border);
      border-left: 4px solid var(--accent);
      padding: 40px;
      border-radius: 12px;
      backdrop-filter: blur(12px);
      box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
    }

    .toc-title {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.25em;
      text-transform: uppercase;
      color: var(--accent);
      margin-bottom: 24px;
    }

    .toc-list {
      list-style: none;
      columns: 2;
      column-gap: 40px;
    }

    .toc-list li {
      margin: 8px 0;
      break-inside: avoid;
    }

    .toc-list a {
      color: var(--text);
      text-decoration: none;
      font-size: 14.5px;
      display: flex;
      align-items: baseline;
      gap: 12px;
      transition: all 0.2s;
    }

    .toc-list a:hover {
      color: var(--accent);
      transform: translateX(5px);
    }

    .toc-num {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      color: var(--accent3);
      min-width: 28px;
      font-weight: 600;
    }

    /* ── CONTENT ── */
    .content {
      max-width: 1200px;
      margin: 0 auto;
      padding: 0 32px 100px;
      position: relative;
      z-index: 2;
    }

    /* ── SECTION ── */
    .section {
      margin-bottom: 100px;
      opacity: 0;
      transform: translateY(30px);
    }

    .section.visible {
      opacity: 1;
      transform: translateY(0);
      transition: all 0.8s ease-out;
    }

    .section-header {
      display: flex;
      align-items: baseline;
      gap: 20px;
      margin-bottom: 40px;
      padding-bottom: 20px;
      border-bottom: 1px solid var(--border);
    }

    .section-num {
      font-family: 'JetBrains Mono', monospace;
      font-size: 14px;
      color: var(--accent3);
      font-weight: 700;
      letter-spacing: 0.15em;
      text-shadow: 0 0 10px rgb(0 255 136 / 0.3);
    }

    .section h2 {
      font-family: 'DM Serif Display', serif;
      font-size: 2.4rem;
      font-weight: 400;
      color: #e6f1ff;
      letter-spacing: -0.01em;
    }

    .subsection {
      margin: 44px 0;
    }

    .subsection h3 {
      font-family: 'JetBrains Mono', monospace;
      font-size: 14px;
      font-weight: 700;
      color: var(--accent);
      margin-bottom: 20px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
    }

    .subsection h3.green {
      color: var(--accent3);
    }

    .subsection h3.coral {
      color: var(--accent2);
    }

    .subsection h3.gold {
      color: var(--accent4);
    }

    .subsection h3.purple {
      color: var(--accent5);
    }

    p {
      margin-bottom: 20px;
      color: #a8b2d1;
    }

    /* ── MATH BLOCKS ── */
    .math-block {
      background: var(--surface);
      border: 1px solid var(--border);
      border-left: 4px solid var(--accent);
      padding: 32px 40px;
      margin: 36px 0;
      border-radius: 12px;
      overflow-x: auto;
      position: relative;
      backdrop-filter: blur(10px);
      box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
      transition: transform 0.3s;
    }

    .math-block:hover {
      transform: translateY(-3px);
      box-shadow: 0 15px 35px rgb(0 0 0 / 0.4);
    }

    .math-block.coral {
      border-left-color: var(--accent2);
    }

    .math-block.green {
      border-left-color: var(--accent3);
    }

    .math-block.gold {
      border-left-color: var(--accent4);
    }

    .math-block.purple {
      border-left-color: var(--accent5);
    }

    .math-block .label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      letter-spacing: 0.25em;
      text-transform: uppercase;
      color: var(--accent);
      position: absolute;
      top: 14px;
      right: 20px;
      opacity: 0.8;
    }

    /* ── DERIVATION ── */
    .derivation {
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
      margin: 36px 0;
      box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
    }

    .derivation-hdr,
    .derivation-header {
      background: var(--surface2);
      padding: 16px 24px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      color: var(--accent);
      border-bottom: 1px solid var(--border);
    }

    .derivation-step {
      padding: 20px 28px;
      border-bottom: 1px solid var(--border);
      display: grid;
      grid-template-columns: 32px 1fr;
      gap: 20px;
      align-items: start;
      background: var(--surface);
      backdrop-filter: blur(5px);
    }

    .derivation-step:last-child {
      border-bottom: none;
    }

    .step-n,
    .step-num {
      font-family: 'JetBrains Mono', monospace;
      font-size: 13px;
      color: var(--accent3);
      font-weight: 700;
      padding-top: 4px;
    }

    .step-note {
      font-size: 13px;
      color: var(--muted);
      font-style: italic;
      margin-top: 10px;
      font-family: 'JetBrains Mono', monospace;
    }

    /* ── CALLOUTS ── */
    .callout {
      padding: 24px 28px;
      border-radius: 12px;
      margin: 32px 0;
      border: 1px solid;
      border-left-width: 4px;
      backdrop-filter: blur(8px);
      box-shadow: 0 8px 25px rgb(0 0 0 / 0.15);
    }

    .callout-insight {
      background: rgb(0 200 255 / 0.05);
      border-color: rgb(0 200 255 / 0.2);
      border-left-color: var(--accent);
    }

    .callout-warning {
      background: rgb(255 107 107 / 0.05);
      border-color: rgb(255 107 107 / 0.2);
      border-left-color: var(--accent2);
    }

    .callout-key {
      background: rgb(0 255 136 / 0.05);
      border-color: rgb(0 255 136 / 0.2);
      border-left-color: var(--accent3);
    }

    .callout-gold {
      background: rgb(255 212 59 / 0.05);
      border-color: rgb(255 212 59 / 0.2);
      border-left-color: var(--accent4);
    }

    .callout-purple {
      background: rgb(204 93 232 / 0.05);
      border-color: rgb(204 93 232 / 0.2);
      border-left-color: var(--accent5);
    }

    .callout-title {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      margin-bottom: 12px;
    }

    .callout-insight .callout-title {
      color: var(--accent);
    }

    .callout-warning .callout-title {
      color: var(--accent2);
    }

    .callout-key .callout-title {
      color: var(--accent3);
    }

    .callout-gold .callout-title {
      color: var(--accent4);
    }

    .callout-purple .callout-title {
      color: var(--accent5);
    }

    .callout p {
      margin-bottom: 0;
      font-size: 16px;
      color: #ccd6f6;
    }

    /* ── TABLES ── */
    table {
      width: 100%;
      border-collapse: collapse;
      margin: 32px 0;
      font-size: 15px;
      background: var(--surface);
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid var(--border);
    }

    thead {
      background: var(--surface2);
    }

    thead th {
      padding: 16px 20px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      color: var(--accent);
      text-align: left;
      border-bottom: 1px solid var(--border);
    }

    tbody tr {
      border-bottom: 1px solid var(--border);
      transition: background 0.2s;
    }

    tbody tr:last-child {
      border-bottom: none;
    }

    tbody tr:hover {
      background: rgb(0 200 255 / 0.05);
    }

    tbody td {
      padding: 16px 20px;
      color: #a8b2d1;
    }

    /* ── RESPONSIVENESS ── */
    @media (width <= 1024px) {
      .hero {
        padding: 60px 32px 40px;
      }

      .toc-list {
        columns: 1;
      }
    }

    @media (width <= 768px) {
      .hero h1 {
        font-size: 3rem;
      }

      .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
      }

      .toc-wrap {
        padding: 24px;
      }

      .content {
        padding: 0 20px 60px;
      }

      table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-collapse: collapse;
      }

      .derivation-step {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 16px 20px;
      }

      .derivation-step div {
        overflow-x: auto;
      }

      .hero-pills {
        gap: 8px;
      }

      .pill {
        padding: 4px 10px;
        font-size: 10px;
      }

      .mjx-container {
        overflow: auto hidden !important;
        max-width: 100% !important;
        padding: 10px 0;
      }
    }

    /* ── FIGURE / SVG ── */
    .figure {
      margin: 40px 0;
      text-align: center;
      background: var(--surface);
      padding: 30px;
      border-radius: 16px;
      border: 1px solid var(--border);
      box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
    }

    .figure svg,
    .figure img {
      max-width: 100%;
      height: auto;
      filter: drop-shadow(0 0 15px rgb(0 200 255 / 0.1));
      border-radius: 8px;
    }

    .figure-cap {
      font-size: 13px;
      color: var(--muted);
      margin-top: 16px;
      font-style: italic;
      font-family: 'JetBrains Mono', monospace;
    }

    /* ── ALGORITHM ── */
    .algo {
      background: #020c1b;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 32px 40px;
      margin: 32px 0;
      font-family: 'JetBrains Mono', monospace;
      font-size: 14px;
      line-height: 2.2;
      overflow-x: auto;
      box-shadow: inset 0 0 20px rgb(0 0 0 / 0.5);
    }

    .algo .kw {
      color: var(--accent5);
      font-weight: 700;
    }

    .algo .fn {
      color: var(--accent);
    }

    .algo .cmt {
      color: var(--muted);
      font-style: italic;
    }

    .algo .num {
      color: var(--accent4);
    }

    .algo .var {
      color: var(--accent3);
    }

    .algo .op {
      color: var(--accent2);
    }

    .algo .hdr {
      color: var(--accent);
      font-size: 11px;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      display: block;
      margin-bottom: 12px;
      border-bottom: 1px solid var(--border);
      padding-bottom: 12px;
    }

    /* ── PROPERTY LIST ── */
    .prop-list {
      list-style: none;
      margin: 16px 0;
    }

    .prop-list li {
      padding: 12px 0 12px 32px;
      border-bottom: 1px solid var(--border);
      position: relative;
      font-size: 16px;
      line-height: 1.8;
      color: #a8b2d1;
    }

    .prop-list li:last-child {
      border-bottom: none;
    }

    .prop-list li::before {
      content: '→';
      position: absolute;
      left: 0;
      color: var(--accent3);
      font-family: 'JetBrains Mono', monospace;
      font-weight: 700;
    }

    /* ── OPTIMIZER CARDS ── */
    .opt-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px;
      margin: 36px 0;
    }

    @media(width <= 680px) {
      .opt-grid {
        grid-template-columns: 1fr;
      }
    }

    .opt-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 30px;
      transition: transform 0.3s, box-shadow 0.3s;
    }

    .opt-card:hover {
      border-color: var(--accent);
      transform: translateY(-5px);
      box-shadow: 0 10px 25px rgb(0 200 255 / 0.15);
    }

    .opt-card-name {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      margin-bottom: 16px;
      color: var(--accent);
    }

    .opt-card p {
      font-size: 15px;
      margin-bottom: 0;
    }

    /* ── INLINE ── */
    code {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.9em;
      background: rgb(0 200 255 / 0.1);
      border: 1px solid rgb(0 200 255 / 0.2);
      padding: 2px 8px;
      border-radius: 4px;
      color: var(--accent);
    }

    .hl {
      color: var(--accent);
      font-weight: 600;
      text-shadow: 0 0 8px rgb(0 200 255 / 0.4);
    }

    .hl2 {
      color: var(--accent2);
      font-weight: 600;
    }

    .hl3 {
      color: var(--accent3);
      font-weight: 600;
    }

    .hl4 {
      color: var(--accent4);
      font-weight: 600;
    }

    .hl5 {
      color: var(--accent5);
      font-weight: 600;
    }

    hr.divider {
      border: none;
      border-top: 1px dashed var(--border);
      margin: 80px 0;
    }

    /* ── COMPARE BLOCK ── */
    .compare {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 1px;
      background: var(--border);
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
      margin: 32px 0;
    }

    @media(width <=680px) {
      .compare {
        grid-template-columns: 1fr;
      }
    }

    .compare-col {
      background: var(--surface);
      padding: 28px;
    }

    .compare-col-title {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      margin-bottom: 16px;
      color: var(--accent);
    }

    .compare-col p {
      font-size: 15px;
      margin-bottom: 12px;
    }

    /* ── LR VISUAL ZONES ── */
    .lr-zones {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 20px;
      margin: 32px 0;
    }

    @media(width <=640px) {
      .lr-zones {
        grid-template-columns: 1fr;
      }
    }

    .lr-zone {
      padding: 28px 20px;
      border-radius: 12px;
      border: 1px solid;
      text-align: center;
      background: var(--surface);
      transition: transform 0.3s;
    }

    .lr-zone:hover {
      transform: translateY(-5px);
    }

    .lr-zone:nth-child(1) {
      border-color: rgb(255 212 59 / 0.3);
    }

    .lr-zone:nth-child(2) {
      border-color: rgb(0 255 136 / 0.3);
    }

    .lr-zone:nth-child(3) {
      border-color: rgb(255 107 107 / 0.3);
    }

    .lr-zone .lr-val {
      font-family: 'JetBrains Mono', monospace;
      font-size: 26px;
      font-weight: 700;
      margin-bottom: 10px;
      color: var(--text);
    }

    .lr-zone p {
      font-size: 14px;
      color: var(--muted);
      margin: 0;
    }

    /* scrollbar */
    ::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    ::-webkit-scrollbar-track {
      background: var(--bg);
    }

    ::-webkit-scrollbar-thumb {
      background: rgb(0 200 255 / 0.3);
      border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb:hover {
      background: rgb(0 200 255 / 0.6);
    }