:root {
  /* Seaborn deep palette (consistent by model family across all charts) */
  --fam-0: #4C72B0; /* OpenAI */
  --fam-1: #DD8452; /* Anthropic */
  --fam-2: #55A868; /* DeepSeek */
  --fam-3: #C44E52; /* xAI */
  --fam-4: #8172B3; /* Google */
  --fam-5: #937860; /* Alibaba / Qwen */
  --fam-6: #DA8BC3; /* Meta */
  --fam-7: #64B5CD; /* Mistral */

  --div-lo: #2a78d6;
  --div-mid: #f0efec;
  --div-hi: #c44e52;
  --ref-warn: #b45309;
  --sky-gain: #2d8659;
  --sky-loss: #c44e52;
  --sky-ruler: #4C72B0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --div-lo: #4b94eb;
    --div-mid: #272725;
    --div-hi: #df6568;
    --ref-warn: #f59e0b;
    --sky-gain: #55A868;
    --sky-loss: #df6568;
    --sky-ruler: #6fa0e0;
  }
}
:root[data-theme="dark"] {
  --div-lo: #4b94eb;
  --div-mid: #272725;
  --div-hi: #df6568;
  --ref-warn: #f59e0b;
  --sky-gain: #55A868;
  --sky-loss: #df6568;
  --sky-ruler: #6fa0e0;
}

.global-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0;
  margin: 0.85rem 0 0.75rem;
}
.global-bar .legend { margin: 0.45rem 0 0; font-size: 11px; gap: 0.25rem 0.85rem; }

.legend i.dot-swatch,
.dot-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.chart-tooltip {
  background: var(--bg) !important;
  z-index: 60 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
}

.two.two-space {
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
}
@media (max-width: 980px) {
  .two.two-space { grid-template-columns: 1fr; }
}

table.heat.heat-sim th.col-h {
  height: 5.2rem;
  min-width: 32px;
}
table.heat.heat-sim th.row-h {
  font-size: 10px;
  padding-right: 6px;
}
table.heat.heat-sim td.cell {
  min-width: 32px;
  height: 22px;
  padding: 0 2px;
  font-size: 9.5px;
}

/* Section 1: Portrait Value Skyline (nwyin.com cohesive light/dark styling) */
.sky-lens-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0 0.65rem;
  align-items: center;
}
.sky-lens-btn {
  font: inherit;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.24rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.sky-lens-btn:hover {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface);
}
.sky-lens-btn[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 600;
}

.sky-meta-bar {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.sky-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: center;
}
.sky-search {
  font: inherit;
  font-size: 11.5px;
  padding: 0.22rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  width: 11.5rem;
}
.sky-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.sky-cat-btn {
  font: inherit;
  font-size: 10.5px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.45rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.sky-cat-btn:hover { color: var(--text); border-color: var(--text); }
.sky-cat-btn[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 600;
}
.sky-cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.sky-movers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}
.sky-mover-chip {
  font: inherit;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.42rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}
.sky-mover-chip.up { color: var(--sky-gain); border-color: color-mix(in srgb, var(--sky-gain) 45%, var(--border)); }
.sky-mover-chip.down { color: var(--sky-loss); border-color: color-mix(in srgb, var(--sky-loss) 45%, var(--border)); }
.sky-mover-chip:hover { border-color: var(--text); }

.sky-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 0.9rem;
  align-items: start;
}
@media (max-width: 1080px) {
  .sky-grid { grid-template-columns: 1fr; }
}

.sky-stage {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  padding: 0.65rem 0.75rem 0.75rem;
  min-width: 0;
}
.sky-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-bottom: 0.35rem;
}
.sky-stage-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.sky-stage-hint {
  font-size: 10.5px;
  color: var(--muted);
}

.sky-chart {
  position: relative;
  width: 100%;
}
.sky-chart svg {
  aspect-ratio: 980 / 560;
}
.sky-chart.is-companies svg {
  aspect-ratio: 980 / 480;
}
.sky-nodes-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.sky-node {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  margin: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--border);
  background-color: var(--bg);
  background-repeat: no-repeat;
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: clamp(7px, 0.85vw, 10px);
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  user-select: none;
  will-change: transform;
  transition: opacity 140ms ease, box-shadow 120ms ease;
}
.sky-nodes-layer.is-morphing .sky-node {
  transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease, box-shadow 120ms ease;
}
.sky-node:hover,
.sky-node:focus-visible {
  z-index: 4;
  box-shadow: 0 0 0 1.5px var(--node-col, var(--text));
  outline: none;
}
.sky-node.is-selected {
  z-index: 5;
  border-color: var(--text) !important;
  box-shadow: 0 0 0 1.5px var(--text);
}
.sky-node.is-dimmed {
  opacity: 0.16;
}

/* Fog of Silence refusal tray */
.sky-fog {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 4px;
  border: 1px dashed var(--border);
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    var(--surface) 6px,
    var(--surface) 12px
  );
}
.sky-fog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.sky-fog-head b { color: var(--text); }
.sky-fog-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.sky-fog-chip {
  font: inherit;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.14rem 0.45rem 0.14rem 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.sky-fog-chip:hover { border-color: var(--text); }
.sky-fog-pct {
  font-size: 10px;
  font-weight: 600;
  color: var(--ref-warn);
  font-variant-numeric: tabular-nums;
}

/* Sprite-based circular avatar for placard, fog chips, and tooltips */
.atlas-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-color: var(--surface);
  flex: none;
  overflow: hidden;
  font-weight: 700;
  color: var(--bg);
  user-select: none;
}

/* Specimen Placard (Right panel) */
.sky-placard {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  padding: 0.8rem 0.85rem;
  position: sticky;
  top: 4.5rem;
}
@media (max-width: 1080px) {
  .sky-placard { position: static; }
}
.placard-head {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.65rem;
}
.placard-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.placard-bio {
  font-size: 11px;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}
.placard-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
  padding: 0.08rem 0.38rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 10px;
  color: var(--muted);
}
.placard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  padding: 0.5rem 0;
  margin: 0.5rem 0 0.6rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.placard-stats .pv {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.placard-stats .pk {
  font-size: 9.5px;
  color: var(--muted);
  margin-top: 0.1rem;
}
.placard-sec {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.65rem 0 0.35rem;
}
.placard-fr-list {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}
.placard-fr-row {
  display: grid;
  grid-template-columns: 4.8rem 1fr 2.8rem;
  gap: 0.45rem;
  align-items: center;
  font-size: 10.5px;
}
.placard-fr-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.placard-fr-track {
  height: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.placard-fr-fill {
  height: 100%;
  background: var(--sky-ruler);
}
.placard-fr-row:hover .placard-fr-track {
  border-color: var(--text);
}
.placard-fr-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.placard-models {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pm-row {
  display: grid;
  grid-template-columns: 7.2rem 1fr 3.3rem;
  gap: 0.4rem;
  align-items: center;
  font-size: 10.5px;
  padding: 0.14rem 0.28rem;
  border-radius: 3px;
  cursor: pointer;
}
.pm-row:hover { background: var(--surface); }
.pm-row.active {
  background: var(--surface);
  outline: 1px solid var(--text);
  outline-offset: -1px;
  font-weight: 600;
}
.pm-name {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pm-track {
  height: 5px;
  background: var(--surface);
  border-radius: 2px;
  position: relative;
}
.pm-zero {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 1px;
  background: var(--border);
}
.pm-dot {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.pm-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

.placard-ruler-note {
  margin-top: 0.65rem;
  padding: 0.45rem 0.55rem;
  border-radius: 3px;
  border-left: 2px solid var(--sky-ruler);
  background: var(--surface);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--muted);
}
.placard-ruler-note b { color: var(--text); }
.placard-table-btn {
  margin-top: 0.55rem;
  width: 100%;
  font: inherit;
  font-size: 11px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.placard-table-btn:hover { border-color: var(--text); }

.tip-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}
.tip-odds {
  margin-top: 0.35rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--border);
  color: var(--sky-ruler);
  font-size: 11px;
}

.entity-drawer {
  margin-top: 0.75rem;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--text);
  border-radius: 4px;
  background: var(--bg);
}
.entity-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.entity-drawer-head h3 { margin: 0; font-size: 0.95rem; }
.entity-drawer-close {
  font: inherit;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
}

/* Charts & SVG typography */
.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; max-width: 100%; overflow: visible; font-family: inherit; }
.axis-lbl { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.ref-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.pt-lbl { fill: var(--text); font-size: 10px; pointer-events: none; }

/* Section 2 presets & stats */
.preset-group { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.preset-group button {
  font: inherit;
  font-size: 11px;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.preset-group button:hover { color: var(--text); border-color: var(--text); }
.cmp-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 12px;
  margin: 0.35rem 0 0.75rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: fit-content;
}
.cmp-stats b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-stats .m { color: var(--muted); }

/* Heatmaps (outline on hover, full opacity preserved) */
table.heat { border-collapse: separate; border-spacing: 2px; font-size: 10.5px; }
table.heat th { font-weight: 400; color: var(--muted); padding: 2px 4px; white-space: nowrap; }
table.heat th.row-h {
  text-align: right;
  position: sticky;
  left: 0;
  background: var(--bg);
  z-index: 1;
  padding-right: 8px;
}
table.heat th.col-h {
  height: 6.2rem;
  vertical-align: bottom;
  padding: 0;
  position: relative;
  min-width: 38px;
}
table.heat th.col-h span {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: rotate(-42deg);
  transform-origin: bottom left;
  font-size: 10px;
}
table.heat td.cell {
  min-width: 38px;
  height: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border-radius: 2px;
  padding: 0 3px;
  font-size: 10px;
  cursor: pointer;
}
table.heat td.cell:hover {
  outline: 1.5px solid var(--text);
  outline-offset: -1.5px;
}

/* Spotlight head-to-head reasoning cards */
.spotlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.65rem;
  margin-top: 0.65rem;
}
.spot-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.spot-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 11.5px;
}
.spot-card-model {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}
.spot-pick {
  font-size: 10.5px;
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
}
.spot-pick.a { background: color-mix(in srgb, var(--s1) 18%, var(--bg)); color: var(--text); border: 1px solid var(--s1); }
.spot-pick.b { background: color-mix(in srgb, var(--s2) 18%, var(--bg)); color: var(--text); border: 1px solid var(--s2); }
.spot-pick.tie { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.spot-pick.refusal { background: color-mix(in srgb, var(--s4) 15%, var(--bg)); color: var(--s4); border: 1px solid var(--s4); }
.spot-expl {
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

/* Bar hover rule compliance: keep full opacity on all bars & labels, highlight via outline */
.bar-group:hover rect.bar-rect,
.bar-group:focus-within rect.bar-rect {
  stroke: var(--text);
  stroke-width: 1.5px;
}
.bar-group:hover .row-bg { fill: var(--surface); }
