/* Shared graph explorer. All styles are scoped to this page. */
:root { --dg-surface: var(--bg-elevated); --dg-grid: #e5e8ed; --dg-axis: #c3cad4; }
[data-theme="dark"] { --dg-grid: #343d48; --dg-axis: #596575; }
.dg-root { height: auto; overflow: auto; }
.dg-body { margin: 0; height: auto; overflow: auto; background: var(--bg); color: var(--fg); }
.dg-page { max-width: 1480px; margin: 0 auto; padding: 26px 32px 40px; box-sizing: border-box; }
.dg-page [hidden] { display: none !important; }
.dg-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 22px; }
.dg-back { color: var(--fg-muted); text-decoration: none; font-size: 12px; letter-spacing: .06em; }
.dg-back:hover { color: var(--brand); }
.dg-title { font-size: 26px; font-weight: 600; letter-spacing: -.025em; margin: 8px 0 5px; }
.dg-sub { margin: 0; color: var(--fg-muted); font-size: 13px; }
.dg-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--fg-muted); }
.dg-field > span { font-weight: 500; }
.dg-field select, .dg-field input[type="search"] { width: 180px; max-width: 100%; min-height: 36px; box-sizing: border-box; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 13px; color: var(--fg); background: var(--bg-input); text-overflow: ellipsis; }
.dg-graph-field { width: min(520px, 48%); }
.dg-field #dg-graph { width: 100%; min-height: 42px; }
.dg-variant select { width: 210px; }
.dg-page :is(button, select, input, a):focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.dg-page button:disabled, .dg-page select:disabled, .dg-check:has(input:disabled) { opacity: .45; cursor: default; }
.dg-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; background: var(--dg-surface); margin-bottom: 16px; }
.dg-stat { padding: 14px 20px; display: flex; align-items: baseline; gap: 9px; }
.dg-stat + .dg-stat { border-left: 1px solid var(--line); }
.dg-stat strong { font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dg-stat span { color: var(--fg-muted); font-size: 12px; }
.dg-banner, .dg-notice { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5; border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); background: color-mix(in srgb, var(--brand) 6%, var(--bg)); }
.dg-banner { border-color: color-mix(in srgb, #c79036 45%, var(--line)); background: color-mix(in srgb, #c79036 8%, var(--bg)); }
.dg-controls { border: 0; padding: 0; margin: 0; min-width: 0; }
.dg-filters { display: flex; flex-wrap: wrap; gap: 14px 12px; align-items: flex-end; margin-bottom: 20px; }
.dg-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 16px; }
.dg-presets > span { font-size: 12px; color: var(--fg-muted); margin-right: 3px; }
.dg-button, .dg-presets button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12px; background: var(--bg-input); color: var(--fg); cursor: pointer; white-space: nowrap; }
.dg-presets button[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--bg)); }
.dg-button:hover, .dg-presets button:hover { background: var(--bg-hover); }
.dg-toggle-row { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.dg-check { display: inline-flex; align-items: center; gap: 4px; color: var(--fg); font-size: 13px; white-space: nowrap; }
.dg-check input { accent-color: var(--brand); }
.dg-view { margin-left: auto; }
.dg-seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.dg-seg button { padding: 8px 14px; min-height: 34px; font: inherit; font-size: 13px; border: 0; background: var(--bg-input); color: var(--fg-muted); cursor: pointer; }
.dg-seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--brand) 10%, var(--dg-surface)); color: var(--brand); font-weight: 600; }
.dg-card { background: var(--dg-surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.dg-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dg-plot-title { margin: 0; font-size: 17px; font-weight: 600; }
.dg-plot-note { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: var(--fg-muted); }
.dg-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 14px 0 4px; max-height: 144px; overflow: auto; }
.dg-legend-item { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12px; background: transparent; color: var(--fg); cursor: pointer; text-align: left; }
.dg-legend-item[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.dg-swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dg-count { color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.dg-encoding, .dg-help { font-size: 11px; color: var(--fg-muted); line-height: 1.6; margin: 10px 0 0; }
.dg-encoding { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.dg-chart { width: 100%; height: 480px; }
.dg-help { text-align: center; }
.dg-empty { min-height: 260px; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; text-align: center; color: var(--fg-muted); font-size: 14px; line-height: 1.6; }
.dg-table-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 16px 0; color: var(--fg-muted); font-size: 12px; }
.dg-field #dg-search { width: 260px; }
.dg-table-scroll { max-height: 500px; overflow: auto; }
.dg-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dg-table th { position: sticky; top: 0; z-index: 1; text-align: left; background: var(--dg-surface); font-weight: 600; color: var(--fg-muted); white-space: nowrap; border-bottom: 1px solid var(--line-strong); padding: 10px; }
.dg-table td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; min-width: 100px; white-space: pre-line; }
.dg-table tr:hover td { background: var(--bg-hover); }
.dg-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dg-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; color: var(--fg-muted); font-size: 12px; }
.dg-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 800px) {
  .dg-page { padding: 18px 16px 28px; }
  .dg-head { align-items: stretch; flex-direction: column; gap: 16px; }
  .dg-graph-field { width: 100%; }
  .dg-stat { padding: 12px; flex-direction: column; gap: 3px; }
  .dg-stat strong { font-size: 20px; }
  .dg-card { padding: 14px; }
  .dg-field select { width: 165px; }
  .dg-chart { height: 420px; }
}
@media (max-width: 480px) {
  .dg-filters > .dg-field { width: calc(50% - 6px); }
  .dg-filters select { width: 100%; }
  .dg-view { margin-left: 0; }
  .dg-card-head { flex-wrap: wrap; }
  .dg-table-tools { align-items: stretch; flex-direction: column; }
}
