    :root {
      --bg: #f5f1e8;
      --paper: #fffdf8;
      --ink: #1d2430;
      --muted: #5d6b7d;
      --line: #c8bfae;
      --accent: #045d5d;
      --accent-soft: rgba(4, 93, 93, 0.1);
      --river: rgba(25, 118, 210, 0.12);
      --river-stroke: rgba(25, 118, 210, 0.35);
      --warn: #8a4a1f;
      --shadow: 0 18px 50px rgba(58, 48, 28, 0.12);
      --radius: 18px;
      --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
      --sans: "Segoe UI", system-ui, sans-serif;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background:
        radial-gradient(circle at top left, rgba(4, 93, 93, 0.14), transparent 35%),
        linear-gradient(180deg, #f0eadf 0%, var(--bg) 30%, #eee7d7 100%);
      color: var(--ink);
      font-family: var(--sans);
    }

    .page {
      max-width: 1500px;
      margin: 0 auto;
      padding: 28px;
      display: grid;
      gap: 20px;
    }

    .hero,
    .controls,
    .results {
      background: rgba(255, 253, 248, 0.9);
      border: 1px solid rgba(90, 82, 62, 0.12);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
    }

    .hero {
      padding: 24px;
      display: grid;
      gap: 10px;
    }

    .hero h1 {
      margin: 0;
      font-size: clamp(1.8rem, 3vw, 3rem);
      letter-spacing: -0.04em;
    }

    .hero p {
      margin: 0;
      max-width: 75ch;
      color: var(--muted);
      line-height: 1.55;
    }

    .legend {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      font-size: 0.9rem;
      color: var(--muted);
    }

    .legend span {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 6px 10px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.035);
    }

    .legend i {
      width: 14px;
      height: 14px;
      border-radius: 4px;
      display: inline-block;
    }

    .controls {
      padding: 20px;
      display: grid;
      grid-template-columns: minmax(300px, 1.1fr) minmax(340px, 1fr);
      gap: 20px;
    }

    .panel-title {
      margin: 0 0 10px;
      font-size: 0.9rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .editor-column,
    .settings-column {
      display: grid;
      gap: 16px;
    }

    textarea {
      width: 100%;
      min-height: 270px;
      resize: vertical;
      padding: 16px;
      border-radius: 14px;
      border: 1px solid rgba(90, 82, 62, 0.15);
      background: rgba(255, 255, 255, 0.9);
      color: var(--ink);
      font: 0.95rem/1.5 var(--sans);
    }

    .sample-row,
    .preset-row,
    .mode-row,
    .toggle-row,
    .button-row {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
    }

    button,
    select,
    input,
    label.radio,
    label.check {
      font: inherit;
    }

    button,
    .pill {
      border: 1px solid rgba(90, 82, 62, 0.14);
      background: white;
      color: var(--ink);
      border-radius: 999px;
      padding: 10px 14px;
    }

    button {
      cursor: pointer;
      transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
    }

    button:hover {
      transform: translateY(-1px);
      border-color: rgba(4, 93, 93, 0.35);
      background: var(--accent-soft);
    }

    button.primary {
      background: var(--accent);
      color: white;
      border-color: transparent;
    }

    .sample-chip.active,
    label.radio.active,
    label.check.active {
      background: var(--accent-soft);
      border-color: rgba(4, 93, 93, 0.32);
      color: var(--accent);
    }

    .control-grid {
      display: grid;
      gap: 12px;
      grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }

    .control {
      display: grid;
      gap: 6px;
      padding: 12px;
      border-radius: 14px;
      background: rgba(0, 0, 0, 0.028);
      border: 1px solid rgba(90, 82, 62, 0.08);
    }

    .control label {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      font-size: 0.92rem;
      color: var(--muted);
    }

    .control input[type="range"] {
      width: 100%;
    }

    .control .inline {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    .control input[type="number"] {
      width: 96px;
      padding: 8px 10px;
      border-radius: 10px;
      border: 1px solid rgba(90, 82, 62, 0.16);
      background: white;
    }

    label.radio,
    label.check {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
    }

    label.radio input,
    label.check input {
      accent-color: var(--accent);
    }

    .results {
      padding: 20px;
      display: grid;
      gap: 16px;
    }

    .summary-strip {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
      gap: 12px;
    }

    .summary-card {
      background: rgba(0, 0, 0, 0.028);
      border: 1px solid rgba(90, 82, 62, 0.08);
      border-radius: 14px;
      padding: 12px 14px;
    }

    .summary-card strong {
      display: block;
      font-size: 1.2rem;
      margin-top: 6px;
    }

    .summary-card span {
      color: var(--muted);
      font-size: 0.88rem;
    }

    .compare-strip {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 12px;
    }

    .compare-card {
      border-radius: 14px;
      padding: 14px;
      background: linear-gradient(180deg, rgba(4, 93, 93, 0.08), rgba(0, 0, 0, 0.02));
      border: 1px solid rgba(4, 93, 93, 0.14);
    }

    .compare-card strong {
      display: block;
      margin-top: 6px;
      font-size: 1.15rem;
    }

    .compare-card span {
      color: var(--muted);
      font-size: 0.88rem;
    }

    .result-grid {
      display: grid;
      gap: 16px;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result-grid.single {
      grid-template-columns: minmax(0, 1fr);
    }

    .result-card {
      display: grid;
      gap: 14px;
      border-radius: 18px;
      border: 1px solid rgba(90, 82, 62, 0.12);
      background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(250,247,239,0.95));
      padding: 16px;
      overflow: hidden;
    }

    .result-head {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      align-items: flex-start;
      flex-wrap: wrap;
    }

    .result-head h2 {
      margin: 0;
      font-size: 1.05rem;
    }

    .result-head p {
      margin: 4px 0 0;
      color: var(--muted);
      font-size: 0.9rem;
    }

    .metric-list {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      justify-content: flex-end;
    }

    .metric {
      padding: 8px 10px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.04);
      font-size: 0.84rem;
      color: var(--muted);
    }

    .tech-grid {
      display: grid;
      gap: 10px;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .tech-card {
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid rgba(90, 82, 62, 0.09);
      background: rgba(0, 0, 0, 0.025);
    }

    .tech-card strong {
      display: block;
      font-size: 1rem;
      margin-top: 4px;
    }

    .tech-card span {
      color: var(--muted);
      font-size: 0.82rem;
    }

    .viz-grid {
      display: grid;
      gap: 12px;
      grid-template-columns: 1.25fr 1fr;
    }

    .viz-card {
      padding: 12px;
      border-radius: 14px;
      background: rgba(0, 0, 0, 0.028);
      border: 1px solid rgba(90, 82, 62, 0.08);
    }

    .viz-card h3 {
      margin: 0 0 10px;
      font-size: 0.84rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .mini-map {
      display: grid;
      gap: 5px;
    }

    .mini-line {
      display: grid;
      grid-template-columns: 24px minmax(0, 1fr);
      gap: 8px;
      align-items: center;
    }

    .mini-line strong {
      font: 0.75rem var(--mono);
      color: var(--muted);
      text-align: right;
    }

    .mini-track {
      position: relative;
      height: 12px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.05);
      overflow: hidden;
      display: flex;
    }

    .mini-gap {
      height: 100%;
      background: linear-gradient(180deg, rgba(4, 93, 93, 0.12), rgba(4, 93, 93, 0.34));
      border-right: 1px solid rgba(255,255,255,0.5);
    }

    .mini-gap.hot {
      background: linear-gradient(180deg, rgba(25, 118, 210, 0.18), rgba(25, 118, 210, 0.5));
    }

    .score-strip {
      display: grid;
      gap: 6px;
    }

    .score-row {
      display: grid;
      grid-template-columns: 32px minmax(0, 1fr) 54px;
      gap: 8px;
      align-items: center;
      font: 0.75rem var(--mono);
      color: var(--muted);
    }

    .score-bar {
      height: 10px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.05);
      overflow: hidden;
      position: relative;
    }

    .score-fill {
      height: 100%;
      border-radius: 999px;
      background: linear-gradient(90deg, rgba(4,93,93,0.35), rgba(4,93,93,0.78));
    }

    .score-fill.river {
      background: linear-gradient(90deg, rgba(25,118,210,0.28), rgba(25,118,210,0.86));
    }

    .river-list {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .river-tag {
      padding: 7px 10px;
      border-radius: 999px;
      background: rgba(25, 118, 210, 0.09);
      color: #24588f;
      font: 0.78rem var(--mono);
    }

    .typeset-shell {
      position: relative;
      border-radius: 16px;
      background: var(--paper);
      border: 1px solid rgba(90, 82, 62, 0.11);
      overflow: auto;
      padding: 16px;
    }

    .typeset-view {
      position: relative;
      font-family: var(--mono);
      font-size: 1rem;
      line-height: 1.65;
      color: var(--ink);
      min-height: 120px;
      width: fit-content;
    }

    .typeset-lines {
      position: relative;
      z-index: 1;
      white-space: pre;
    }

    .typeset-line {
      display: block;
      height: 1.65em;
      white-space: nowrap;
    }

    .word,
    .gap {
      display: inline-block;
      vertical-align: top;
      height: 1.65em;
    }

    .gap {
      white-space: pre;
    }

    .river-overlay {
      position: absolute;
      inset: 0;
      width: 100%;
      z-index: 2;
      pointer-events: none;
      overflow: visible;
    }

    .river-fill {
      stroke: none;
    }

    .debug-gap {
      fill: rgba(4, 93, 93, 0.08);
      stroke: rgba(4, 93, 93, 0.22);
      stroke-width: 0.04;
    }

    .debug-corridor {
      fill: rgba(25, 118, 210, 0.08);
      stroke: rgba(25, 118, 210, 0.28);
      stroke-width: 0.05;
    }

    .debug-link-accepted {
      stroke: rgba(25, 118, 210, 0.45);
      stroke-width: 0.045;
      fill: none;
    }

    .debug-link-rejected {
      stroke: rgba(170, 64, 64, 0.32);
      stroke-width: 0.035;
      stroke-dasharray: 0.18 0.12;
      fill: none;
    }

    .debug-label {
      font: 0.34px var(--mono);
      fill: rgba(29, 36, 48, 0.78);
    }

    .river-rect {
      fill: var(--river);
      rx: 0.2;
    }

    .breakdown {
      display: none;
      border-top: 1px dashed rgba(90, 82, 62, 0.16);
      padding-top: 12px;
    }

    .breakdown.show {
      display: block;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.86rem;
      font-family: var(--mono);
    }

    th,
    td {
      text-align: left;
      padding: 8px 8px;
      border-bottom: 1px solid rgba(90, 82, 62, 0.09);
    }

    th {
      color: var(--muted);
      font-weight: 600;
    }

    .footer-note {
      color: var(--warn);
      font-size: 0.88rem;
    }

    .subtle-note {
      color: var(--muted);
      font-size: 0.84rem;
      line-height: 1.45;
    }

    @media (max-width: 980px) {
      .controls,
      .result-grid,
      .viz-grid {
        grid-template-columns: 1fr;
      }
    }

    .neural-overlay {
      background: rgba(255, 253, 248, 0.9);
      border: 1px solid rgba(90, 82, 62, 0.12);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
      padding: 24px;
      display: grid;
      gap: 18px;
    }

    .neural-header h2 {
      margin: 0 0 6px 0;
    }

    .neural-subtitle {
      margin: 0;
      color: var(--muted);
      font-size: 0.95rem;
      line-height: 1.5;
    }

    .neural-controls {
      display: grid;
      gap: 14px;
      padding: 14px 16px;
      border: 1px solid rgba(90, 82, 62, 0.1);
      border-radius: 12px;
      background: rgba(255, 253, 248, 0.6);
    }

    .neural-row {
      display: flex;
      align-items: center;
      gap: 14px;
      flex-wrap: wrap;
    }

    .neural-row > label {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      font-size: 0.88rem;
      color: var(--muted);
      min-width: 180px;
    }

    .neural-row > label strong {
      font-family: var(--mono);
      color: var(--ink);
    }

    .neural-row select {
      font-family: var(--mono);
      font-size: 0.9rem;
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: var(--paper);
      color: var(--ink);
    }

    .neural-row input[type="range"] {
      flex: 1 1 240px;
      min-width: 220px;
    }

    .neural-label {
      font-size: 0.88rem;
      color: var(--muted);
      min-width: 60px;
    }

    .neural-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
      font-size: 0.85rem;
      color: var(--muted);
    }

    .neural-legend span {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .neural-legend i {
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.08);
    }

    .neural-canvas-wrap {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      background: #0f1419;
      border-radius: 12px;
      padding: 16px;
      min-height: 260px;
      overflow: auto;
    }

    #neuralCanvas {
      max-width: 100%;
      max-height: 720px;
      height: auto;
      image-rendering: crisp-edges;
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
      background: #fff;
      border-radius: 4px;
    }

    .neural-empty {
      color: #f5f1e8;
      font-family: var(--mono);
      font-size: 0.88rem;
      text-align: center;
      padding: 20px;
    }

    .neural-empty code {
      background: rgba(255, 255, 255, 0.1);
      padding: 2px 6px;
      border-radius: 4px;
    }

    .neural-metrics {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 10px;
      padding: 12px 16px;
      border-radius: 12px;
      background: rgba(4, 93, 93, 0.06);
      border: 1px solid rgba(4, 93, 93, 0.15);
      font-family: var(--mono);
      font-size: 0.88rem;
    }

    .neural-metric {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .neural-metric span:first-child {
      color: var(--muted);
      font-family: var(--sans);
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .neural-metric span:last-child {
      color: var(--ink);
      font-weight: 600;
    }

    .rerank {
      background: rgba(255, 253, 248, 0.9);
      border: 1px solid rgba(90, 82, 62, 0.12);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
      padding: 24px;
      display: grid;
      gap: 18px;
    }

    .rerank-header h2 {
      margin: 0 0 6px 0;
    }

    .rerank-subtitle {
      margin: 0;
      color: var(--muted);
      font-size: 0.95rem;
      line-height: 1.55;
    }

    .rerank-subtitle code {
      background: rgba(4, 93, 93, 0.08);
      padding: 1px 5px;
      border-radius: 4px;
      font-family: var(--mono);
      font-size: 0.88rem;
    }

    .rerank-subtitle em {
      color: var(--warn);
      font-style: normal;
      font-weight: 600;
    }

    .rerank-controls {
      display: grid;
      gap: 14px;
      padding: 14px 16px;
      border: 1px solid rgba(90, 82, 62, 0.1);
      border-radius: 12px;
      background: rgba(255, 253, 248, 0.6);
    }

    .rerank-row {
      display: flex;
      align-items: center;
      gap: 14px;
      flex-wrap: wrap;
    }

    .rerank-row > label {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      font-size: 0.88rem;
      color: var(--muted);
      min-width: 200px;
    }

    .rerank-row > label strong {
      font-family: var(--mono);
      color: var(--ink);
    }

    .rerank-row input[type="range"] {
      flex: 1 1 240px;
      min-width: 220px;
    }

    .rerank-metrics {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      gap: 10px;
      padding: 14px 16px;
      border-radius: 12px;
      background: rgba(4, 93, 93, 0.06);
      border: 1px solid rgba(4, 93, 93, 0.15);
      font-family: var(--mono);
      font-size: 0.9rem;
    }

    .rerank-metric {
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .rerank-metric .label {
      color: var(--muted);
      font-family: var(--sans);
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .rerank-metric .value {
      color: var(--ink);
      font-weight: 600;
    }

    .rerank-metric .delta-positive {
      color: #2f8a4f;
      font-size: 0.78rem;
    }

    .rerank-metric .delta-negative {
      color: #b34a4a;
      font-size: 0.78rem;
    }

    .rerank-metric .delta-neutral {
      color: var(--muted);
      font-size: 0.78rem;
    }

    .rerank-compare {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
    }

    .rerank-column {
      display: grid;
      gap: 10px;
      padding: 14px;
      border: 1px solid rgba(90, 82, 62, 0.12);
      border-radius: 12px;
      background: var(--paper);
    }

    .rerank-column-header h3 {
      margin: 0 0 6px 0;
      font-size: 1.05rem;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .rerank-variant-tag {
      font-family: var(--mono);
      font-size: 0.78rem;
      color: var(--accent);
      background: var(--accent-soft);
      padding: 2px 8px;
      border-radius: 999px;
      font-weight: 500;
    }

    .rerank-column-metrics {
      font-family: var(--mono);
      font-size: 0.82rem;
      color: var(--muted);
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
    }

    .rerank-column-metrics strong {
      color: var(--ink);
    }

    .rerank-layout {
      margin: 0;
      padding: 12px;
      border-radius: 8px;
      background: rgba(245, 241, 232, 0.5);
      font-family: var(--mono);
      font-size: 0.78rem;
      line-height: 1.7;
      white-space: pre;
      overflow-x: auto;
      color: var(--ink);
    }

    .rerank-layout .rerank-line {
      display: block;
      padding: 1px 4px;
      border-radius: 3px;
    }

    .rerank-layout .rerank-line.changed {
      background: rgba(4, 93, 93, 0.14);
      border-left: 3px solid var(--accent);
      padding-left: 6px;
    }

    .rerank-candidates {
      font-family: var(--mono);
      font-size: 0.82rem;
      padding: 12px 14px;
      border-radius: 10px;
      background: rgba(245, 241, 232, 0.4);
      border: 1px dashed rgba(90, 82, 62, 0.2);
      color: var(--muted);
    }

    .rerank-candidates table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 4px;
    }

    .rerank-candidates th,
    .rerank-candidates td {
      font-family: var(--mono);
      font-size: 0.8rem;
      padding: 4px 8px;
      text-align: right;
      border-bottom: 1px solid rgba(90, 82, 62, 0.08);
    }

    .rerank-candidates th:first-child,
    .rerank-candidates td:first-child {
      text-align: left;
    }

    .rerank-candidates tr.winner td {
      background: rgba(4, 93, 93, 0.08);
      font-weight: 600;
      color: var(--ink);
    }

    @media (max-width: 980px) {
      .rerank-compare {
        grid-template-columns: 1fr;
      }
    }

    .live-neural-status {
      font-family: var(--mono);
      font-size: 0.74rem;
      color: var(--warn);
      margin-left: 6px;
      font-weight: 500;
    }

    .typeset-view {
      position: relative;
    }

    .live-neural-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      mix-blend-mode: multiply;
      opacity: 0.75;
      image-rendering: auto;
      z-index: 5;
    }
