:root {
  --bg: #000;
  --panel: #0a0a0a;
  --border: #2a2a2a;
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --label-size: 12px;
  --grid: #1a1a1a;
  --axis: #444;
  --inactive-bg: #141414;
  --inactive-text: #666;
  --dim-brightness: 0.7;
  --context-brightness: 0.4;
  --fade-brightness: 0.1;
}
* { box-sizing: border-box; }
body { margin: 0; font: 13px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--text); background: var(--bg); }
#app { display: flex; height: 100vh; overflow: hidden; }
/* Keep the shell invisible until the first full render has populated every
   widget, so reloads don't flash empty controls and shift the layout. */
#app:not(.ready) { visibility: hidden; }

* { scrollbar-color: #444 #111; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #111; }
*::-webkit-scrollbar-thumb { background: #444; border-radius: 6px; border: 2px solid #111; }
*::-webkit-scrollbar-thumb:hover { background: #555; }
*::-webkit-scrollbar-corner { background: #111; }

#search { width: 100%; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: var(--label-size); outline: none; background: #111; color: var(--text); }
#search:focus { border-color: #555; }

.toggle { padding: 3px 7px; border: 1px solid var(--border); border-radius: 999px; background: #111; color: var(--text); cursor: pointer; font: inherit; font-size: var(--label-size); user-select: none; }
.toggle.inactive { background: var(--inactive-bg); color: var(--inactive-text); border-color: transparent; }
.toggle:hover { border-color: #555; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 10px 16px 8px; gap: 8px; }
#chart-header { position: relative; display: flex; justify-content: flex-end; align-items: flex-start; gap: 16px; }
#reset-view { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: #111; color: var(--muted); cursor: pointer; }
#reset-view:hover { color: var(--text); border-color: #555; }
#reset-view:active { background: #1a1a1a; }
#header-toggles { position: absolute; left: 0; top: 42px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: var(--label-size); color: var(--muted); white-space: nowrap; }
#title-block { position: absolute; left: 50%; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 2px; }
#title { color: #f0f0f0; font-size: 18px; font-weight: 600; text-decoration: none; letter-spacing: 0.01em; }
#source-caption { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--label-size); white-space: nowrap; }
#source-link { color: var(--muted); text-decoration: none; border-bottom: 1px dotted #555; }
#source-link:hover { color: var(--text); border-bottom-color: #888; }

#chart-controls { position: relative; display: flex; align-items: center; justify-content: center; gap: 16px; flex: 0 0 auto; margin-top: 6px; margin-bottom: 4px; padding-right: 230px; color: var(--muted); font-size: var(--label-size); flex-wrap: wrap; pointer-events: none; }
#chart-controls > * { pointer-events: auto; }
/* Once the dropdowns fit beside the search/toggle column, lift them into that
   band so the stacked checkboxes no longer push the diagram down. */
@media (min-width: 1120px) {
  #chart-controls { margin-top: -22px; }
}
#chart-controls select { font: inherit; padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; background: #111; color: var(--text); }
/* Fit the longest option in each dropdown so switching sources/views (which
   changes the available options) never resizes or shifts the controls. */
#chart-controls #source { width: 123px; }
#chart-controls #view { width: 105px; }
#chart-controls #metric { width: 109px; }
#chart-controls #scale { width: 66px; }
#refresh-date { color: var(--muted); font-size: var(--label-size); cursor: pointer; user-select: none; }
#refresh-date:hover { color: var(--text); }

@media (max-width: 860px) {
  #chart-header { justify-content: center; flex-wrap: wrap; }
  #title-block { position: static; transform: none; flex: 1 1 auto; min-width: 200px; }
}

#plot-controls { flex: 0 0 auto; width: 230px; max-width: 100%; display: flex; flex-direction: column; gap: 6px; }
/* Keep both toggle rows in flow even when one is unavailable, so switching
   sources/views never shifts the chart or the dropdown controls. */
.models-row { display: flex; flex-direction: column; align-items: flex-start; width: 100%; gap: 6px; min-height: 40px; padding: 4px 0 2px; font-size: var(--label-size); color: var(--muted); }
.check-inline { display: inline-flex; align-items: center; gap: 5px; width: auto; height: 17px; cursor: pointer; font-size: var(--label-size); color: var(--muted); white-space: nowrap; }
.check-inline[hidden] { display: inline-flex; visibility: hidden; pointer-events: none; }
.check-inline input { margin: 0; }
/* Mirrors the y-axis label in the strip above the model-label pane. */
#highlight-count { position: absolute; left: calc(100% - 230px + 18px); top: 2px; z-index: 3; text-align: left; white-space: nowrap; pointer-events: none; }

#content-row { flex: 1; min-height: 0; display: flex; gap: 12px; }
#chart-wrap { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: stretch; }
#plot-area { flex: 1; min-width: 0; min-height: 0; position: relative; user-select: none; }
.selection-box { position: absolute; border: 1px solid #7aa2f7; background: rgba(122,162,247,0.12); pointer-events: none; z-index: 4; }
#plot { width: 100%; height: 100%; display: block; overflow: visible; }

.label-panel { position: absolute; right: 0; width: 230px; display: flex; flex-direction: column; justify-content: safe center; overflow-y: auto; overflow-x: hidden; padding: 0 6px 0 18px; box-sizing: border-box; z-index: 2; }
.label-panel .label-item { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; white-space: nowrap; line-height: 1; font-family: "DM Sans", system-ui, sans-serif; font-weight: 550; cursor: pointer; user-select: none; }
.label-panel .label-item .label-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.label-panel .label-item img.label-logo { object-fit: contain; display: block; flex: 0 0 auto; }
.label-panel .label-item span.label-dot { border-radius: 50%; flex: 0 0 auto; }
.label-panel .label-item.faded { filter: brightness(var(--fade-brightness)); }
.label-panel .label-item.context { filter: brightness(var(--context-brightness)); }
.label-panel .label-item.dimmed { filter: brightness(var(--dim-brightness)); }

.provider-toggles { flex: 0 0 auto; align-self: flex-start; width: 168px; display: flex; flex-direction: column; justify-content: safe center; gap: 5px; padding: 2px 8px 2px 0; overflow-y: auto; }
.provider-toggle { flex: 0 0 auto; min-height: 25px; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; background: #111; cursor: pointer; font-size: var(--label-size); user-select: none; color: var(--text); width: 100%; overflow: hidden; }
.provider-toggle span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.provider-toggle .swatch { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.provider-toggle .provider-logo { width: 14px; height: 14px; object-fit: contain; flex: 0 0 auto; display: block; }
.provider-toggle.inactive { background: var(--inactive-bg); color: var(--inactive-text); border-color: transparent; }
.provider-toggle.inactive .swatch { filter: grayscale(1); opacity: 0.5; }
.provider-toggle.inactive .provider-logo { filter: grayscale(1); opacity: 0.5; }
.provider-toggle.dimmed { filter: brightness(var(--dim-brightness)); }
.provider-toggle.context { filter: brightness(var(--context-brightness)); }
.provider-toggle.faded { filter: brightness(var(--fade-brightness)); }
.provider-toggle.hovered { filter: none; }

#chart-footer { display: flex; flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 16px; margin-left: 235px; margin-right: 230px; padding-top: 14px; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 4px; }
#size-filters { justify-content: flex-start; }
#reasoning-filters { justify-content: flex-end; }

.tooltip { position: absolute; pointer-events: none; background: rgba(20,22,26,0.97); color: #fff; padding: 9px 11px; border-radius: 5px; font-size: 12px; line-height: 1.5; z-index: 10; max-width: 380px; border: 1px solid #3a3f45; box-shadow: 0 6px 20px rgba(0,0,0,0.5); font-variant-numeric: tabular-nums; }
.tooltip .t-title { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 13px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid #383d43; }
.tooltip .t-title img { width: 16px; height: 16px; object-fit: contain; flex: 0 0 auto; }
.tooltip .t-grid { display: grid; grid-template-columns: max-content minmax(max-content, 1fr); column-gap: 10px; row-gap: 2px; align-items: baseline; width: 100%; }
.tooltip .t-key { color: #aeb6c0; white-space: nowrap; }
.tooltip .t-val { color: #aeb6c0; white-space: nowrap; text-align: right; }
.tooltip .t-key.t-active, .tooltip .t-val.t-active { color: #fff; font-weight: 650; }
.tooltip .t-old { margin-top: 6px; padding-top: 5px; border-top: 1px solid #383d43; color: #9aa0a6; font-size: 11px; }

svg .grid line { stroke: var(--grid); }
svg .axis line, svg .axis path { stroke: var(--axis); }
svg .axis text { fill: var(--muted); font-size: 11px; }
svg .model-line { fill: none; stroke-width: 1.5; }
svg .model-line.older { stroke-dasharray: 3 2; }
svg .model-point { stroke: #000; stroke-width: 0.75; }
svg .pareto { fill: none; stroke: #666; stroke-width: 1.5; stroke-dasharray: 4 3; }
svg .pareto.selected,
svg .pareto.hovered { stroke: #fff; }
svg .hit { fill: transparent; stroke: transparent; cursor: pointer; }
svg .faded { filter: brightness(var(--fade-brightness)); }
svg .context { filter: brightness(var(--context-brightness)); }
svg .dimmed { filter: brightness(var(--dim-brightness)); }
svg .leader-line { stroke-width: 2; stroke-dasharray: 0 6; stroke-linecap: round; fill: none; pointer-events: none; }
svg .label-text { cursor: pointer; font-family: "DM Sans", system-ui, sans-serif; font-weight: 550; }
svg .label-text:hover { text-decoration: none; }
svg .axis text.axis-label,
#highlight-count { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 12px; font-weight: 400; line-height: 15px; letter-spacing: normal; color: #b0b0b0; fill: #b0b0b0; }
.empty-msg { fill: var(--muted); font-size: 13px; }
