:root {
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }

  --bg: light-dark(#f4f6fa, #0b0e14);
  --surface: light-dark(#ffffff, #121620);
  --surface-2: light-dark(#eef2f7, #181d29);
  --surface-hover: light-dark(#e6ecf5, #1e2536);
  --border: light-dark(#d5dde8, #242c3e);
  --border-strong: light-dark(#b7c4d6, #334155);
  --ink: light-dark(#0f172a, #e8edf5);
  --ink-muted: light-dark(#475569, #8b95a8);
  --ink-faint: light-dark(#64748b, #5e6a82);

  --accent: light-dark(#0284c7, #38bdf8);
  --accent-bg: light-dark(rgba(2, 132, 199, 0.12), rgba(56, 189, 248, 0.14));
  --accent-ink: light-dark(#0369a1, #7dd3fc);
  --emerald: light-dark(#059669, #10b981);
  --emerald-bg: light-dark(rgba(5, 150, 105, 0.12), rgba(16, 185, 129, 0.14));
  --amber: light-dark(#d97706, #f59e0b);
  --danger: light-dark(#dc2626, #f87171);
  --danger-bg: light-dark(rgba(220, 38, 38, 0.1), rgba(248, 113, 113, 0.14));

  --scrollbar-thumb: light-dark(#94a3b8, #475569);
  --scrollbar-track: light-dark(#e2e8f0, #131823);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.scroller {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

@supports not (scrollbar-color: auto) {
  .scroller::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  .scroller::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
  }
  .scroller::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  width: 100dvw;
  overflow: hidden;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-inline-size: 0;
  flex-wrap: wrap;
}

/* Top-Level Workspace Tabs (single row, scrolling overflow per tabs guide) */
.top-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.top-tabs::-webkit-scrollbar {
  display: none;
}

.main-tab-btn {
  position: relative;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 5px 5px 0 0;
}

.main-tab-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.main-tab-btn[aria-selected="true"] {
  color: var(--accent-ink);
}

.main-tab-btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 4px 0 4px;
  border-block-end: 3px solid var(--accent);
}

/* Main Tab Panels Grid Cell (zero gap, no padding/border directly on tabpanel for hidden=until-found) */
.main-panels {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  gap: 0;
  min-height: 0;
  min-inline-size: 0;
  overflow: hidden;
}

.main-panel {
  grid-area: 1 / 1;
  min-height: 0;
  min-inline-size: 0;
  overflow: hidden;
  z-index: 1;
}

.main-panel[hidden] {
  pointer-events: none;
  z-index: 0;
}

.explorer-inner {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.explorer-body {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
  min-inline-size: 0;
  overflow: hidden;
}

.explorer-body.has-picker {
  grid-template-columns: 300px 1fr;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-inline-size: 0;
  flex-shrink: 0;
}

.brand-icon {
  display: block;
  border-radius: 5px;
}

.brand-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  min-inline-size: 0;
  flex-wrap: wrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  display: inline-block;
  flex-shrink: 0;
}

.live-dot.is-syncing {
  background: var(--amber);
  animation: pulse 0.9s infinite ease-in-out;
}

.live-dot.is-error {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s;
}

.pill-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.pill-btn.subtle {
  background: transparent;
}

.pill-btn.accent {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pill-btn.is-spin svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.badge-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-muted);
}

.badge-accent {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 600;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 28px;
  width: 210px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box svg {
  color: var(--ink-faint);
  flex-shrink: 0;
}

.search-box input {
  border: 0;
  background: transparent;
  width: 100%;
  min-inline-size: 0;
  font-size: 12px;
  outline: none;
}

.topn-group,
.layout-switch,
.theme-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.group-label {
  font-size: 11px;
  color: var(--ink-muted);
  padding: 0 5px;
  font-weight: 600;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 7px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.seg-btn.is-active {
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 600;
}

.custom-n-input {
  width: 44px;
  height: 22px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-align: center;
  outline: none;
}

/* Formula Studio Bar */
.formula-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.formula-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.fx-name-wrap {
  flex: 0 1 190px;
  min-inline-size: 130px;
  display: flex;
  align-items: center;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 8px;
}

.fx-name-wrap:focus-within {
  border-color: var(--accent);
}

.fx-name-input {
  width: 100%;
  min-inline-size: 0;
  border: 0;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}

.fx-input-wrap {
  position: relative;
  flex: 1 1 380px;
  min-inline-size: 240px;
  display: flex;
  align-items: center;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 0 8px;
  gap: 7px;
}

.fx-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

.fx-input-wrap.has-error {
  border-color: var(--danger);
}

.fx-prefix {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--accent);
  user-select: none;
  flex-shrink: 0;
}

.fx-input {
  flex: 1;
  min-inline-size: 0;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  outline: none;
}

.fx-clear-btn {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
}

.fx-clear-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 50;
  padding: 4px;
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.ac-item:hover,
.ac-item.is-active {
  background: var(--accent-bg);
}

.ac-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
}

.ac-meta {
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.formula-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-inline-size: 0;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-muted);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}

.preset-chip:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

.preset-chip.is-active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.preset-del {
  margin-left: 2px;
  opacity: 0.65;
  font-size: 12px;
}
.preset-del:hover {
  opacity: 1;
  color: var(--danger);
}

.filter-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--ink-muted);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle-chip input {
  margin: 0;
  accent-color: var(--accent);
}

.toggle-chip:has(input:checked) {
  color: var(--ink);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.compact-select {
  height: 24px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 11.5px;
  color: var(--ink);
}

.formula-diag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  min-height: 18px;
  flex-wrap: wrap;
}

.diag-ok {
  color: var(--emerald);
  font-family: var(--font-mono);
  font-weight: 600;
}

.diag-err {
  color: var(--danger);
  font-family: var(--font-mono);
  background: var(--danger-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.diag-var-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  cursor: pointer;
}

.diag-var-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

/* Main Workspace Split */
.workspace {
  display: grid;
  grid-template-columns: minmax(420px, var(--split-left, 56%)) 6px minmax(360px, 1fr);
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.workspace.layout-table {
  grid-template-columns: 1fr 0 0;
}
.workspace.layout-table .split-handle,
.workspace.layout-table .chart-pane {
  display: none;
}

.workspace.layout-chart {
  grid-template-columns: 0 0 1fr;
}
.workspace.layout-chart .table-pane,
.workspace.layout-chart .split-handle {
  display: none;
}

.split-handle {
  background: var(--border);
  cursor: col-resize;
  transition: background-color 0.12s;
}

.split-handle:hover,
.split-handle.is-dragging {
  background: var(--accent);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-inline-size: 0;
  background: var(--surface);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.pane-title-group,
.pane-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mono-muted {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
}

.mini-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-muted);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.mini-btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

.mini-btn.accent {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.mini-btn.accent:hover {
  background: var(--accent);
  color: var(--bg);
}

.export-toast {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--emerald-bg);
  white-space: nowrap;
}

/* Table */
.table-scroll {
  flex: 1;
  overflow: auto;
  contain: layout style;
  position: relative;
}

.models-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

.models-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  text-align: right;
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.models-table thead th:has(> button) {
  padding: 0;
}

.models-table thead th.col-check,
.models-table thead th.col-rank,
.models-table thead th.col-name {
  text-align: left;
}

.models-table thead th > button {
  width: 100%;
  min-inline-size: 0;
  overflow: hidden;
  min-height: 28px;
  border: 0;
  background: transparent;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  cursor: pointer;
  color: inherit;
  font-weight: inherit;
}

.cell-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-inline-size: 0;
}

.sort-indicator {
  font-size: 10px;
  opacity: 0.35;
  flex-shrink: 0;
}

.models-table thead th.col-name > button,
.models-table thead th.col-rank > button {
  justify-content: flex-start;
}

.models-table thead th > button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.models-table thead th[aria-sort] > button {
  color: var(--accent-ink);
}

th[aria-sort="ascending"] .sort-indicator::before {
  content: "▲";
  opacity: 1;
  color: var(--accent);
}

th[aria-sort="descending"] .sort-indicator::before {
  content: "▼";
  opacity: 1;
  color: var(--accent);
}

th:not([aria-sort]) .sort-indicator::before {
  content: "⇅";
}

.models-table tbody tr {
  border-bottom: 1px solid var(--border);
  height: 30px;
  cursor: pointer;
}

.models-table tbody tr:hover {
  background: var(--surface-hover);
}

.models-table tbody tr.is-new-drop {
  background: var(--emerald-bg);
}

.models-table td {
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.models-table td.col-check {
  text-align: center;
  padding: 2px;
}

.models-table td.col-check input {
  accent-color: var(--accent);
  cursor: pointer;
}

.models-table td.col-rank {
  text-align: left;
  color: var(--ink-faint);
  font-size: 11px;
}

.models-table td.col-name {
  text-align: left;
  font-family: var(--font-sans);
  font-size: 12.5px;
}

.model-cell-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-inline-size: 0;
}

.creator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.model-name-text {
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-inline-size: 0;
  flex: 1;
}

.tag-mini {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--ink-muted);
  flex-shrink: 0;
}

.tag-mini.ow {
  color: var(--emerald);
  border-color: var(--emerald);
}

.tag-mini.new {
  background: var(--emerald-bg);
  color: var(--emerald);
  border-color: var(--emerald);
}

.fx-cell {
  position: relative;
  font-weight: 600;
  color: var(--accent-ink);
}

.fx-cell-bar {
  position: absolute;
  left: 2px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.65;
  pointer-events: none;
}

.cell-null {
  color: var(--ink-faint);
}

/* Charts Pane */
.chart-tabs {
  display: inline-flex;
  gap: 4px;
}

.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.tab-btn.is-active {
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
  font-size: 11.5px;
}

.chart-ctrl-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-muted);
}

.chart-ctrl-group .compact-select {
  max-width: 185px;
}

.chart-container {
  flex: 1;
  overflow: auto;
  padding: 8px 10px;
  contain: layout style;
  position: relative;
}

.chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 220px;
  color: var(--ink-muted);
  text-align: center;
  padding: 20px;
}

.aa-svg-chart {
  display: block;
}

.chart-banner-bg {
  fill: var(--surface-2);
}

.chart-banner-divider {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-banner-title {
  fill: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}

.chart-banner-sub {
  fill: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.chart-banner-footer {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-zero {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.chart-plot-frame {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
}

.chart-tick-label {
  fill: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.chart-axis-title {
  fill: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
}

.chart-rank-label {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.chart-model-label {
  fill: var(--ink);
  font-size: 11.5px;
}

.chart-val-label {
  fill: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.chart-row-hit {
  fill: transparent;
}

.chart-bar-row {
  cursor: pointer;
}

.chart-bar-row:hover .chart-row-hit {
  fill: var(--surface-hover);
}

.chart-pareto-line {
  fill: none;
  stroke: var(--emerald);
  stroke-width: 2;
  stroke-dasharray: 5 3;
}

.chart-scatter-dot {
  cursor: pointer;
  transition: r 0.1s;
}

.chart-point-label {
  fill: var(--ink-muted);
  font-size: 10px;
  pointer-events: none;
}

.chart-point-label.is-top {
  fill: var(--ink);
  font-weight: 600;
}

.chart-radar-ring {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
}

/* Tooltip */
.chart-tooltip {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  max-width: 290px;
  font-size: 11.5px;
}

.tt-title {
  font-weight: 700;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tt-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.tt-k {
  color: var(--ink-muted);
}

.tt-v {
  text-align: right;
  font-weight: 600;
}

/* Popovers (CSS Anchor Positioning + fallback) */
.popover-panel {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  width: 320px;
  max-height: 440px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popover-panel:not(:popover-open):not(.\:popover-open) {
  display: none;
}

@supports (position-area: block-end) {
  [popover].anchored-popover {
    inset: auto;
    margin: 4px 0 0 0;
    position-area: block-end span-inline-end;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
  }
}

@supports not (position-area: block-end) {
  [popover].anchored-popover {
    position: fixed;
    inset: 44px 12px auto auto;
    margin: 0;
  }
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.popover-search {
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
}

.cols-checklist,
.drops-list {
  overflow-y: auto;
  max-height: 330px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.col-check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 5px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.col-check-item:hover {
  background: var(--surface-2);
}

.drop-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
}

.drop-item:hover {
  border-color: var(--accent);
}

.drop-item-top {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.settings-popover {
  width: 280px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setting-label {
  font-size: 12px;
  color: var(--ink-muted);
}

/* Modal Dialogs */
.aa-dialog {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  width: min(940px, 92vw);
  max-height: 85vh;
  padding: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.aa-dialog[open] {
  display: flex;
  flex-direction: column;
}

.aa-dialog::backdrop {
  background: rgba(5, 8, 15, 0.65);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 15px;
}

.dialog-header p {
  margin: 2px 0 0;
}

.dialog-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  background: var(--surface-hover);
}

.dialog-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.dialog-search {
  flex: 1;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.dialog-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.var-group-card,
.inspector-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
}

.var-group-card.is-deferred,
.inspector-section.is-deferred {
  content-visibility: auto;
  contain-intrinsic-size: auto 240px;
}

.var-group-title {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.var-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 6px;
}

.var-card-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.var-card-btn:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.var-card-top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}

.var-card-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
}

.var-card-cov {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}

.var-card-sub {
  font-size: 11px;
  color: var(--ink-muted);
}

.inspector-title-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inspector-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px;
}

.kv-tile {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}

.kv-tile:hover {
  border-color: var(--accent);
}

.kv-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.hosts-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.hosts-mini-table th,
.hosts-mini-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.hosts-mini-table th:first-child,
.hosts-mini-table td:first-child {
  text-align: left;
  font-family: var(--font-sans);
}


/* Variable & Benchmark Picker Drawer */
.var-picker-drawer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
  min-inline-size: 0;
  overflow: hidden;
}

.var-picker-drawer[hidden] {
  display: none;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12.5px;
}

.picker-cats {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  flex-shrink: 0;
}

.cat-pill {
  flex: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.cat-pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.cat-pill.is-active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.picker-ops {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.picker-ops-label {
  font-size: 10.5px;
  color: var(--ink-faint);
  font-weight: 600;
  margin-right: 2px;
}

.op-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.op-chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.picker-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.picker-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.picker-item:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.picker-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.picker-item-name {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-ink);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-item-name:hover {
  text-decoration: underline;
}

.picker-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.picker-mini-act {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
}

.picker-mini-act:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.picker-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-muted);
}

.picker-item-desc {
  font-size: 10.5px;
  color: var(--ink-faint);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dir-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--ink-faint);
}

/* Scatter Quick Views Row */
.scatter-quick-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  width: 100%;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}

/* Benchmarks Overview Tab */
.bench-inner {
  display: grid;
  grid-template-columns: minmax(340px, 40%) 1fr;
  gap: 1px;
  background: var(--border);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.bench-directory-pane,
.bench-detail-pane {
  min-height: 0;
  min-inline-size: 0;
  overflow: hidden;
}

.bench-directory-pane .picker-cats {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.bench-card-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}

.bench-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.bench-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.bench-card.is-active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.bench-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.bench-card-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}

.bench-card-var {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-ink);
  flex-shrink: 0;
}

.bench-card-summary {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bench-card-leaders {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bench-leader-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink-muted);
}

.bench-detail-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

.bench-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.bench-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bench-title-row h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.bench-var-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.bench-detail-desc {
  margin: 5px 0 4px;
  font-size: 12.5px;
  color: var(--ink-muted);
  max-width: 78ch;
  line-height: 1.45;
}

.bench-aliases {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bench-detail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bench-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.bench-stat-tile {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.bench-stat-label {
  font-size: 10.5px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bench-stat-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.bench-hist-box {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.bench-hist-container {
  padding: 6px 10px;
}

.compact-table th,
.compact-table td {
  padding: 5px 8px;
}

/* Drops & Hosts Tab */
.drops-inner {
  display: grid;
  grid-template-columns: minmax(320px, 34%) 1fr;
  gap: 1px;
  background: var(--border);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.drops-feed-pane,
.hosts-matrix-pane {
  min-height: 0;
  min-inline-size: 0;
  overflow: hidden;
}

.drops-timeline {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}

.drop-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.drop-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.drop-card.is-new {
  border-color: var(--emerald);
  background: var(--emerald-bg);
}


/* Responsive Adaptation for Narrow Viewports / Tablets / Mobile */
@media (max-width: 1080px) {
  .explorer-body.has-picker {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38dvh) 1fr;
  }
  .var-picker-drawer {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .workspace.layout-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 48%) 0 minmax(320px, 1fr);
  }
  .workspace.layout-split .split-handle {
    display: none;
  }
  .workspace.layout-split .table-pane {
    border-bottom: 1px solid var(--border);
  }
  .bench-inner,
  .drops-inner {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38dvh) 1fr;
  }
}

@media (max-width: 720px) {
  html,
  body,
  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }
  .brand {
    flex-wrap: wrap;
    flex-shrink: 1;
    min-inline-size: 0;
  }
  .main-panels,
  .main-panel,
  .explorer-inner,
  .explorer-body {
    overflow: visible;
    height: auto;
  }
  .workspace.layout-split {
    grid-template-rows: minmax(320px, 55dvh) 0 auto;
  }
  .search-box {
    width: 100%;
    flex: 1 1 160px;
  }
  .bench-inner,
  .drops-inner {
    grid-template-rows: minmax(240px, 42dvh) auto;
    height: auto;
  }
}
