    :root {
      color-scheme: dark;
      --bg: #0b1014;
      --ink: #edf3f6;
      --muted: #92a0aa;
      --line: #26323b;
      --line-soft: #1c2730;
      --panel: #131a20;
      --panel-raised: #172129;
      --panel-soft: #1a242c;
      --control: #1c2831;
      --control-hover: #24323d;
      --accent: #77c8c1;
      --accent-soft: rgba(119, 200, 193, 0.14);
      --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--ink);
      background:
        radial-gradient(circle at 18% 0%, rgba(59, 89, 104, 0.22), transparent 34rem),
        linear-gradient(180deg, #0d1419 0%, var(--bg) 42rem);
    }
    main {
      min-height: 100vh;
      display: grid;
      grid-template-columns: minmax(680px, 1fr) minmax(500px, 33vw);
      gap: 12px;
      padding: 12px;
    }
    .plot-wrap, aside {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 10px;
      box-shadow: var(--shadow);
    }
    .plot-wrap {
      position: relative;
      min-height: calc(100vh - 24px);
      overflow: hidden;
    }
    header {
      min-height: 76px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px 10px;
      border-bottom: 1px solid var(--line-soft);
      background: rgba(19, 26, 32, 0.86);
    }
    h1 {
      margin: 0;
      font-size: 20px;
      font-weight: 680;
      letter-spacing: 0;
    }
    .count {
      color: var(--muted);
      font-size: 13px;
      white-space: nowrap;
    }
    svg {
      display: block;
      width: 100%;
      height: calc(100vh - 110px);
      min-height: 560px;
    }
    aside {
      height: calc(100vh - 24px);
      min-height: 0;
      padding: 12px;
      overflow: auto;
      scrollbar-color: #33414b transparent;
    }
    .section {
      border: 1px solid var(--line-soft);
      border-radius: 8px;
      padding: 9px;
      margin-top: 10px;
      background: rgba(17, 25, 31, 0.72);
    }
    .section:first-child {
      margin-top: 0;
    }
    h2 {
      margin: 0 0 6px;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--muted);
    }
    label {
      display: grid;
      gap: 5px;
      margin: 9px 0;
      font-size: 13px;
      color: #cfd7dc;
    }
    input, select, button {
      font: inherit;
      border: 1px solid #2e3c46;
      border-radius: 6px;
      background: var(--control);
      color: var(--ink);
    }
    input:focus-visible,
    select:focus-visible,
    button:focus-visible {
      outline: 2px solid rgba(119, 200, 193, 0.42);
      outline-offset: 1px;
      border-color: var(--accent);
    }
    input, select {
      width: 100%;
      padding: 7px 8px;
    }
    .row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    button {
      width: 100%;
      padding: 8px 10px;
      cursor: pointer;
      background: var(--control);
      transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
    }
    button:hover { background: var(--control-hover); }
    .filters-section {
      padding-top: 6px;
      margin-top: 6px;
    }
    .filters-section h2 {
      margin-bottom: 4px;
    }
    .perspective-section[hidden] {
      display: none;
    }
    .segmented-control {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }
    .segmented-control label {
      margin: 0;
      display: block;
      cursor: pointer;
    }
    .segmented-control input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    .segmented-control span {
      display: block;
      min-height: 30px;
      padding: 7px 8px;
      border: 1px solid #2e3c46;
      border-radius: 6px;
      background: var(--control);
      color: #cfd7dc;
      text-align: center;
      font-size: 12px;
    }
    .segmented-control input:checked + span {
      border-color: var(--accent);
      background: var(--accent-soft);
      color: #ecfffb;
    }
    .active-perspective {
      border-color: rgba(119, 200, 193, 0.34);
      background: rgba(20, 34, 39, 0.64);
    }
    .active-perspective .range-head h2::after {
      content: " active";
      margin-left: 6px;
      color: #80cbc4;
      font-size: 10px;
      text-transform: none;
      letter-spacing: 0;
    }
    .filters-section label {
      gap: 2px;
      margin: 4px 0;
      font-size: 10px;
    }
    .filters-section input,
    .filters-section select {
      min-height: 24px;
      padding: 3px 6px;
      font-size: 10px;
      border-radius: 4px;
    }
    .filters-section .row {
      gap: 4px;
      margin-top: 4px;
    }
    .filters-section button {
      min-height: 24px;
      padding: 3px 6px;
      font-size: 10px;
      border-radius: 4px;
    }
    .filters-section > button {
      margin-top: 4px;
    }
    .range-paint-panel {
      display: grid;
      gap: 5px;
      margin: 5px 0 7px;
      padding: 7px;
      border: 1px solid var(--line-soft);
      border-radius: 6px;
      background: rgba(12, 18, 24, 0.55);
    }
    .range-paint-panel[hidden] {
      display: none;
    }
    .range-paint-panel label {
      gap: 2px;
      font-size: 10px;
    }
    .range-paint-panel textarea {
      width: 100%;
      padding: 4px 6px;
      font-size: 10px;
      border-radius: 4px;
      min-height: 58px;
      resize: vertical;
      font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
      line-height: 1.3;
    }
    .range-paint-toggle {
      min-height: 24px;
      padding: 3px 6px;
      font-size: 10px;
      border-radius: 4px;
      margin: 0 0 3px;
    }
    .range-paint-toggle[aria-expanded="true"] {
      background: #2b4a52;
      color: #fff;
      border-color: rgba(119, 200, 193, 0.45);
    }
    .range-paint-panel .row {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 4px;
    }
    .range-paint-panel .row button {
      min-height: 24px;
      padding: 3px 6px;
      font-size: 10px;
      border-radius: 4px;
    }
    .paint-range-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      margin: 5px 0 3px;
      color: #d8e0e5;
      font-size: 10px;
      font-weight: 650;
    }
    .paint-range-head output {
      color: var(--muted);
      font-size: 10px;
      font-weight: 500;
    }
    .range-paint-grid {
      display: grid;
      grid-template-columns: repeat(13, minmax(0, 1fr));
      gap: 2px;
      margin-bottom: 5px;
    }
    .range-paint-cell {
      aspect-ratio: 1;
      min-width: 0;
      width: 100%;
      padding: 0;
      border-radius: 3px;
      background: #202a32;
      color: #8795a0;
      font-size: 8px;
      line-height: 1;
      font-weight: 600;
    }
    .range-paint-cell:hover {
      background: #26323b;
    }
    .range-paint-cell.selected {
      color: #fff;
      border-color: #4d7183;
      background: #375464;
    }
    .range-paint-cell.pair {
      background: #302b23;
    }
    .range-paint-cell.pair.selected {
      background: #6b5740;
      border-color: #6b5740;
    }
    .range-paint-cell.suited.selected {
      background: #2e7d6f;
      border-color: #2e7d6f;
    }
    .range-paint-cell.offsuit.selected {
      background: #7a5a95;
      border-color: #7a5a95;
    }
    .range-paint-grid.disabled .range-paint-cell {
      opacity: 0.45;
      cursor: default;
    }
    .plot-tabs {
      display: flex;
      gap: 5px;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: wrap;
      padding: 3px;
      border: 1px solid var(--line-soft);
      border-radius: 999px;
      background: rgba(11, 16, 20, 0.42);
    }
    .plot-tab {
      width: auto;
      padding: 5px 9px;
      font-size: 12px;
      border-radius: 999px;
      border-color: transparent;
      white-space: nowrap;
    }
    .plot-tab.active {
      background: #2b4a52;
      color: #fff;
      border-color: rgba(119, 200, 193, 0.36);
    }
    #pcaTransform.active {
      background: #2b4a52;
      color: #fff;
      border-color: rgba(119, 200, 193, 0.36);
    }
    .legend {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px 10px;
      font-size: 12px;
    }
    .legend-item {
      display: flex;
      gap: 6px;
      align-items: center;
      min-width: 0;
    }
    .swatch {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex: 0 0 auto;
    }
    .range-head {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      align-items: baseline;
      margin: 0 0 6px;
    }
    .range-head output {
      color: var(--ink);
      font-size: 12px;
      font-weight: 650;
    }
    .range-preset-label {
      gap: 2px;
      margin: 2px 0 4px;
      font-size: 9px;
    }
    .range-preset-label select {
      min-height: 22px;
      padding: 2px 5px;
      font-size: 10px;
      border-radius: 4px;
    }
    input[type="range"] {
      padding: 0;
    }
    .range-detail-layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 260px;
      gap: 8px;
      align-items: start;
      margin-top: 6px;
    }
    .range-grid-column {
      display: grid;
      gap: 4px;
      width: 260px;
      padding: 6px;
      border: 1px solid var(--line-soft);
      border-radius: 7px;
      background: rgba(10, 15, 19, 0.28);
    }
    .range-grid-column input[type="range"] {
      width: 100%;
      height: 14px;
    }
    .frequency-panel {
      min-width: 0;
      white-space: normal;
      font-size: 8px;
      line-height: 1.08;
      padding: 6px;
      border: 1px solid var(--line-soft);
      border-radius: 7px;
      background: rgba(10, 15, 19, 0.28);
    }
    .section > .count {
      margin-bottom: 2px;
      font-size: 9px;
      line-height: 1.15;
      white-space: normal;
    }
    .combo-compression {
      margin-top: 1px;
      color: #b8c3ca;
      font-size: 8px;
      font-variant-numeric: tabular-nums;
    }
    .frequency-title {
      margin: 0 0 3px;
      color: var(--ink);
      font-size: 10px;
      font-weight: 750;
    }
    .frequency-columns {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 4px;
      margin-top: 3px;
    }
    .frequency-block {
      min-width: 0;
    }
    .frequency-subtitle {
      margin-top: 3px;
      color: var(--ink);
      font-size: 8px;
      font-weight: 750;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .frequency-empty {
      line-height: 1.4;
      white-space: normal;
    }
    .frequency-pie-card {
      display: grid;
      grid-template-columns: 48px minmax(0, 1fr);
      align-items: center;
      gap: 6px;
      min-height: 54px;
      margin: 4px 0 5px;
      padding: 5px;
      border: 1px solid rgba(65, 81, 94, 0.55);
      border-radius: 7px;
      background: rgba(4, 9, 12, 0.24);
    }
    .frequency-pie {
      width: 48px;
      aspect-ratio: 1;
      display: grid;
      place-items: center;
      border-radius: 50%;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    }
    .frequency-pie-center {
      width: 31px;
      aspect-ratio: 1;
      display: grid;
      place-items: center;
      align-content: center;
      border-radius: 50%;
      background: #101820;
      box-shadow: 0 0 0 1px rgba(9, 13, 17, 0.85);
      text-align: center;
      overflow: hidden;
    }
    .frequency-pie-center b {
      display: block;
      max-width: 27px;
      color: var(--ink);
      font-size: 7px;
      line-height: 1;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
    }
    .frequency-pie-center span {
      display: block;
      max-width: 27px;
      margin-top: 1px;
      color: var(--muted);
      font-size: 5px;
      line-height: 1;
      text-transform: capitalize;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .frequency-pie-meta {
      min-width: 0;
      display: grid;
      gap: 2px;
    }
    .frequency-pie-title {
      color: var(--ink);
      font-size: 8px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .frequency-pie-total {
      color: var(--muted);
      font-size: 7px;
      font-variant-numeric: tabular-nums;
    }
    .frequency-chip-row {
      display: flex;
      flex-wrap: wrap;
      gap: 2px;
      min-width: 0;
    }
    .frequency-chip {
      display: inline-flex;
      align-items: center;
      gap: 2px;
      max-width: 100%;
      padding: 1px 4px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.08);
      color: #cbd5dc;
      font-size: 7px;
      line-height: 1.15;
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .frequency-chip span {
      flex: 0 0 auto;
      width: 5px;
      height: 5px;
      border-radius: 50%;
    }
    .frequency-chip.muted {
      color: var(--muted);
    }
    .range-matrix {
      display: grid;
      grid-template-columns: repeat(13, minmax(0, 1fr));
      gap: 2px;
      width: 100%;
    }
    .range-cell {
      aspect-ratio: 1;
      position: relative;
      display: grid;
      place-items: center;
      border: 1px solid #34414b;
      border-radius: 3px;
      background: #202a32;
      color: #8f9ca6;
      font-size: 9px;
      line-height: 1;
      user-select: none;
      overflow: hidden;
    }
    .range-cell-label {
      position: relative;
      z-index: 1;
    }
    .draw-out-badge {
      position: absolute;
      right: -1px;
      bottom: -1px;
      min-width: 11px;
      height: 10px;
      padding: 0 2px;
      border-radius: 4px 0 2px 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: rgba(245, 158, 11, 0.95);
      color: #111827;
      font-size: 7px;
      font-weight: 800;
      line-height: 1;
      box-shadow: 0 0 0 1px rgba(12, 18, 24, 0.7);
      z-index: 2;
    }
    .draw-out-badge.fd {
      background: rgba(14, 165, 233, 0.95);
      color: #ffffff;
    }
    .draw-out-badge.combo {
      background: rgba(236, 72, 153, 0.95);
      color: #ffffff;
    }
    .range-cell.selected {
      background: #375464;
      border-color: #26343d;
      color: #fff;
      font-weight: 700;
    }
    .range-cell.pair {
      background: #302b23;
    }
    .range-cell.pair.selected {
      background: #6b5740;
      border-color: #3f372c;
    }
    .range-cell.suited.selected {
      background: #2e7d6f;
      border-color: #1f4f48;
    }
    .range-cell.offsuit.selected {
      background: #7a5a95;
      border-color: #49365a;
    }
    .tooltip {
      position: fixed;
      pointer-events: none;
      display: none;
      min-width: 0;
      max-width: 220px;
      padding: 10px 11px;
      background: rgba(20, 25, 29, 0.94);
      color: #fff;
      border-radius: 7px;
      font-size: 12px;
      line-height: 1.2;
      box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
      z-index: 10;
    }
    .tooltip b {
      display: block;
      font-size: 12px;
      margin-bottom: 4px;
    }
    .spectrum {
      display: grid;
      gap: 2px;
      margin-top: 3px;
    }
    .spectrum-head {
      display: flex;
      justify-content: space-between;
      gap: 6px;
      align-items: baseline;
      margin-top: 4px;
      font-size: 8px;
      font-weight: 700;
    }
    .spectrum-total {
      color: inherit;
      opacity: 0.72;
      font-weight: 500;
      white-space: nowrap;
    }
    .spectrum-row {
      display: grid;
      grid-template-columns: 86px minmax(70px, 1fr) 44px;
      gap: 4px;
      align-items: center;
      font-size: 8px;
      line-height: 1.05;
    }
    .spectrum-label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-transform: capitalize;
    }
    .spectrum-track {
      height: 5px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.16);
    }
    .spectrum-fill {
      display: flex;
      height: 100%;
      min-width: 1px;
      border-radius: inherit;
      overflow: hidden;
    }
    .spectrum-row.zero .spectrum-fill {
      min-width: 0;
    }
    .spectrum-segment {
      position: relative;
      height: 100%;
      min-width: 0;
    }
    .spectrum-segment::after {
      content: "";
      position: absolute;
      inset: -5px -3px;
    }
    .spectrum-segment.hero {
      background: rgba(37, 99, 235, 0.72);
    }
    .spectrum-segment.tie {
      background: rgba(255, 255, 255, 0.42);
    }
    .spectrum-segment.villain {
      background: rgba(220, 38, 38, 0.70);
    }
    .spectrum-value {
      text-align: right;
      opacity: 0.82;
      font-variant-numeric: tabular-nums;
    }
    .spectrum-note {
      margin-top: 5px;
      color: inherit;
      opacity: 0.72;
      font-size: 11px;
    }
    .spectrum-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      align-items: center;
      margin-top: 3px;
      font-size: 8px;
    }
    .spectrum-legend.compact {
      gap: 5px;
      margin-top: 2px;
      margin-bottom: 0;
    }
    .spectrum-legend-item {
      display: inline-flex;
      gap: 4px;
      align-items: center;
      white-space: nowrap;
    }
    .spectrum-legend-swatch {
      width: 11px;
      height: 6px;
      border-radius: 999px;
      background: #9aa4aa;
    }
    .spectrum-legend-swatch.hero {
      background: rgba(37, 99, 235, 0.72);
    }
    .spectrum-legend-swatch.tie {
      background: rgba(160, 166, 170, 0.70);
    }
    .spectrum-legend-swatch.villain {
      background: rgba(220, 38, 38, 0.70);
    }
    .draw-block {
      margin-top: 8px;
    }
    .draw-list {
      display: flex;
      flex-wrap: wrap;
      gap: 4px 6px;
      margin-top: 6px;
      font-size: 11px;
      line-height: 1.35;
    }
    .draw-hand {
      display: inline-flex;
      gap: 4px;
      align-items: baseline;
      padding: 2px 5px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.12);
      white-space: nowrap;
    }
    .draw-hand b {
      display: inline;
      margin: 0;
      font-size: inherit;
    }
    .frequency-panel .spectrum-track {
      background: #2a343d;
    }
    .frequency-panel .spectrum-row {
      grid-template-columns: 42px minmax(18px, 1fr) 23px;
      gap: 2px;
    }
    .frequency-panel .spectrum-total {
      display: none;
    }
    .frequency-panel .spectrum-value {
      color: var(--muted);
      opacity: 1;
    }
    .frequency-panel hr {
      border: 0;
      border-top: 1px solid var(--line);
      margin: 5px 0;
    }
    .axis-label {
      fill: var(--ink);
      font-size: 13px;
      font-weight: 600;
    }
    .tick,
    .tick text {
      fill: var(--muted);
      font-size: 11px;
    }
    .grid {
      stroke: #29333b;
      stroke-width: 1;
    }
    .median {
      stroke: #a7b4bd;
      stroke-width: 1.2;
      stroke-dasharray: 6 5;
      opacity: 0.48;
    }
    .point {
      stroke: rgba(10, 16, 20, 0.34);
      stroke-width: 1;
      opacity: 0.78;
      cursor: crosshair;
    }
    .point:hover {
      opacity: 1;
      stroke: rgba(237, 243, 246, 0.74);
      stroke-width: 1.8;
    }
    .empty {
      fill: var(--muted);
      font-size: 15px;
      text-anchor: middle;
    }
    @media (max-width: 1220px) {
      main {
        grid-template-columns: 1fr;
      }
      .plot-wrap, aside {
        min-height: auto;
      }
      svg {
        height: 620px;
      }
      .range-detail-layout {
        grid-template-columns: 1fr;
      }
      aside {
        height: auto;
        overflow: visible;
      }
      .range-grid-column,
      .range-grid-column input[type="range"],
      .range-matrix {
        width: 260px;
      }
    }
    .loading-overlay {
      position: absolute;
      inset: 76px 0 0;
      display: grid;
      place-items: center;
      padding: 24px;
      background: rgba(14, 18, 22, 0.94);
      z-index: 20;
      transition: opacity 180ms ease, visibility 180ms ease;
    }
    .loading-overlay.hidden {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }
    .loading-card {
      width: min(420px, 100%);
      padding: 18px;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.36);
    }
    .loading-title {
      margin: 0 0 6px;
      font-size: 15px;
      font-weight: 700;
    }
    .loading-status {
      min-height: 18px;
      margin: 0 0 12px;
      color: var(--muted);
      font-size: 13px;
    }
    .loading-track {
      height: 8px;
      overflow: hidden;
      border-radius: 999px;
      background: #2a343d;
    }
    .loading-bar {
      width: 8%;
      height: 100%;
      border-radius: inherit;
      background: #2e7d6f;
      transition: width 180ms ease;
    }

