/* HypGraph Atlas — the research graph explorer.
   Theme with --hg-* on any ancestor (a host's own tokens), or leave the defaults. Dark by default; data-theme="light". */

.atlas {
  --a-bg: var(--hg-bg, #0a0d14); --a-bg1: var(--hg-bg1, #0e131d); --a-bg2: var(--hg-bg2, #141b28);
  --a-panel: var(--hg-panel, #111826);
  --a-ink: var(--hg-ink, #e6ecf5); --a-ink2: var(--hg-ink2, #9aa8bd); --a-ink3: var(--hg-ink3, #5d6b80);
  --a-line: var(--hg-line, #1e2838); --a-line2: var(--hg-line2, #2b3850); --a-accent: var(--hg-accent, #7cf3ff);
  --a-good: var(--hg-good, #4ee08a); --a-warn: var(--hg-warn, #ffb547); --a-bad: var(--hg-bad, #ff4d5e);
  --a-info: var(--hg-info, #6cb6ff);
  --a-mono: var(--hg-mono, ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace);
  --a-body: var(--hg-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --a-display: var(--hg-display, var(--a-mono));
  position: relative; overflow: hidden; background: var(--a-bg); color: var(--a-ink);
  font-family: var(--a-body); font-size: 13px;
  display: flex; flex-direction: column; height: 100%; min-height: 480px;
  color-scheme: dark;
}
.atlas[data-theme="light"] {
  --a-bg: var(--hg-light-bg, #f7f8fb); --a-bg1: var(--hg-light-bg1, #eef1f6); --a-bg2: var(--hg-light-bg2, #e3e8f0);
  --a-panel: var(--hg-light-panel, #ffffff);
  --a-ink: var(--hg-light-ink, #0d1321); --a-ink2: var(--hg-light-ink2, #4a5568); --a-ink3: var(--hg-light-ink3, #8a96a8);
  --a-line: var(--hg-light-line, #d8dee8); --a-line2: var(--hg-light-line2, #bfc8d6);
  --a-accent: var(--hg-light-accent, #0b6bcb);
  --a-good: #0a7a3c; --a-warn: #a35f00; --a-bad: #c4182a; --a-info: #0063a8;
  color-scheme: light;
}
.atlas *, .atlas *::before, .atlas *::after { box-sizing: border-box; }

/* ── top bar ── */
.at-bar {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px; flex-shrink: 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--a-line2); background: linear-gradient(180deg, var(--a-bg2), var(--a-bg1));
}
.at-brand { font-family: var(--a-display); letter-spacing: .14em; color: var(--a-accent); font-size: 14px; }
.at-brand span { color: var(--a-ink2); font-family: var(--a-mono); letter-spacing: 0; font-size: 11px; }
.at-k { font-family: var(--a-mono); font-size: 10px; letter-spacing: .08em; color: var(--a-ink2); text-transform: uppercase; }
.at-inv-wrap { display: flex; flex-direction: column; gap: 2px; }
.at-inv-wrap select, .at-hud select {
  background: var(--a-bg); color: var(--a-ink); border: 1px solid var(--a-line2); padding: 4px 6px;
  font-family: var(--a-mono); font-size: 12px; max-width: 320px;
}
.at-tabs { display: flex; gap: 2px; }
.at-tabs button {
  background: transparent; color: var(--a-ink2); border: 1px solid transparent; padding: 6px 11px;
  font-family: var(--a-mono); font-size: 12px; cursor: pointer; letter-spacing: .04em;
}
.at-tabs button:hover { color: var(--a-ink); border-color: var(--a-line2); }
.at-tabs button.on { color: var(--a-accent); border-color: var(--a-accent); background: var(--a-bg); }
.at-search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.at-search input, .at-table-bar input {
  width: 100%; background: var(--a-bg); color: var(--a-ink); border: 1px solid var(--a-line2);
  padding: 6px 9px; font-family: var(--a-mono); font-size: 12px;
}
.at-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30; max-height: 360px; overflow: auto;
  background: var(--a-panel); border: 1px solid var(--a-line2); box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.at-results button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--a-line);
  color: var(--a-ink); padding: 6px 9px; cursor: pointer; font-size: 12px;
}
.at-results button:hover, .at-results button:focus { background: var(--a-bg2); outline: none; }
.at-bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.at-chip {
  font-family: var(--a-mono); font-size: 10px; padding: 3px 7px; border: 1px solid var(--a-line2); color: var(--a-ink2);
  letter-spacing: .06em; white-space: nowrap;
}
.at-chip.ok { color: var(--a-good); border-color: var(--a-good); }
.at-chip.bad { color: var(--a-bad); border-color: var(--a-bad); }
.at-live::before { content: "●"; margin-right: 5px; color: var(--a-good); }
.at-live.off::before { color: var(--a-ink3); }
.at-btn {
  background: var(--a-bg); color: var(--a-ink); border: 1px solid var(--a-line2); padding: 5px 9px; cursor: pointer;
  font-family: var(--a-mono); font-size: 12px;
}
.at-btn:hover:not(:disabled) { border-color: var(--a-accent); color: var(--a-accent); }
.at-btn:disabled { opacity: .4; cursor: default; }
.at-btn:focus-visible, .at-tabs button:focus-visible { outline: 2px solid var(--a-accent); outline-offset: 1px; }

/* ── layout ── */
.at-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 1fr 380px; }
.at-rail { border-right: 1px solid var(--a-line); overflow: auto; padding: 10px 12px; background: var(--a-bg1); }
.at-main { position: relative; min-width: 0; min-height: 0; }
.at-insp { border-left: 1px solid var(--a-line); overflow: auto; background: var(--a-bg1); padding: 12px 14px; }
.at-sec { margin-bottom: 16px; }
.at-sec h3 { font-family: var(--a-mono); font-size: 10px; letter-spacing: .12em; color: var(--a-ink2); text-transform: uppercase;
  margin: 0 0 7px; font-weight: normal; }
.at-types label, .at-checks label, .at-toggle {
  display: flex; align-items: center; gap: 7px; padding: 2px 0; cursor: pointer; font-size: 12px; color: var(--a-ink);
}
.at-types .sw { width: 11px; height: 11px; display: inline-block; flex-shrink: 0; border-radius: 2px; }
.at-types .n, .at-checks .n { margin-left: auto; font-family: var(--a-mono); font-size: 11px; color: var(--a-ink2); }
.at-legend div { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--a-ink2); padding: 2px 0; }
.at-legend .ln { width: 22px; height: 0; border-top: 2px solid; display: inline-block; }
.at-legend .ln.dot { border-top-style: dotted; } .at-legend .ln.dash { border-top-style: dashed; }
.ring { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid; }
.ring.checked { border-color: var(--a-good); } .ring.unchecked { border-color: var(--a-ink3); border-style: dashed; }
.ring.needs_revalidation { border-color: var(--a-warn); border-style: dashed; }
.ring.contested { border-color: var(--a-bad); border-width: 3px; }
.ring.at-risk { border-color: transparent; box-shadow: 0 0 0 3px rgba(255,51,68,.45); }
.at-stats { font-family: var(--a-mono); font-size: 11px; color: var(--a-ink2); line-height: 1.6; }

.at-view { display: none; position: absolute; inset: 0; flex-direction: column; }
.at-view.on { display: flex; }
.at-cy { flex: 1; min-height: 0; }
.at-hud {
  position: absolute; left: 10px; bottom: 10px; right: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--a-panel) 88%, transparent); border: 1px solid var(--a-line2); padding: 6px 9px;
}
.at-hint { margin-left: auto; font-size: 11px; color: var(--a-ink3); }
.at-tip {
  position: absolute; z-index: 20; pointer-events: none; max-width: 380px; background: var(--a-panel); color: var(--a-ink);
  border: 1px solid var(--a-line2); padding: 7px 9px; font-size: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.at-tip b { color: var(--a-accent); font-family: var(--a-mono); }
.at-tip .st { color: var(--a-ink2); font-size: 11px; margin-top: 4px; }
.at-scroll { flex: 1; overflow: auto; padding: 14px 16px; }

/* ── inspector ── */
.at-empty { color: var(--a-ink3); font-size: 12px; line-height: 1.5; padding-top: 30px; }
.at-i-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.at-i-code { font-family: var(--a-mono); font-size: 16px; color: var(--a-accent); }
.at-badge { font-family: var(--a-mono); font-size: 10px; padding: 2px 6px; border: 1px solid; letter-spacing: .05em; }
.at-i-title { margin: 6px 0 8px; font-size: 14px; line-height: 1.45; }
.at-sentence { font-size: 12px; line-height: 1.5; color: var(--a-ink2); border-left: 2px solid var(--a-accent); padding: 4px 8px;
  background: var(--a-bg); margin-bottom: 10px; }
.at-dims { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; margin-bottom: 10px; }
.at-dims dt { font-family: var(--a-mono); font-size: 10px; color: var(--a-ink2); text-transform: uppercase; padding-top: 2px; }
.at-dims dd { margin: 0; }
.st-good { color: var(--a-good); } .st-warn { color: var(--a-warn); } .st-bad { color: var(--a-bad); } .st-dim { color: var(--a-ink3); }
.at-i-sec { margin-top: 14px; }
.at-i-sec h4 { font-family: var(--a-mono); font-size: 10px; letter-spacing: .1em; color: var(--a-ink2); margin: 0 0 6px;
  text-transform: uppercase; font-weight: normal; border-bottom: 1px solid var(--a-line); padding-bottom: 3px; }
.at-field { font-size: 12px; margin-bottom: 6px; line-height: 1.45; word-break: break-word; }
.at-field .k { font-family: var(--a-mono); font-size: 10px; color: var(--a-ink2); display: block; }
.at-field pre { margin: 2px 0 0; white-space: pre-wrap; font-family: var(--a-mono); font-size: 11px; color: var(--a-ink);
  background: var(--a-bg); padding: 5px 7px; max-height: 180px; overflow: auto; }
.at-edge { display: flex; gap: 6px; align-items: baseline; font-size: 12px; padding: 2px 0; }
.at-edge .rel { font-family: var(--a-mono); font-size: 10px; color: var(--a-ink2); min-width: 86px; }
.at-link { background: none; border: 0; padding: 0; color: var(--a-info); cursor: pointer; font-family: var(--a-mono); font-size: 12px; text-align: left; }
.at-link:hover { text-decoration: underline; }
.at-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 4px; }
.at-ver { font-size: 11px; padding: 4px 0; border-bottom: 1px dashed var(--a-line); }
.at-ver .ch { color: var(--a-warn); font-family: var(--a-mono); }

/* ── tables, cards ── */
.at-table-bar { display: flex; gap: 10px; align-items: center; padding: 10px 16px 0; }
.at-table-bar input { max-width: 360px; }
.at-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.at-table th { position: sticky; top: 0; background: var(--a-bg1); text-align: left; font-family: var(--a-mono); font-size: 10px;
  letter-spacing: .06em; color: var(--a-ink2); padding: 7px 8px; border-bottom: 1px solid var(--a-line2); cursor: pointer;
  user-select: none; white-space: nowrap; text-transform: uppercase; font-weight: normal; }
.at-table th.sorted::after { content: " ▾"; } .at-table th.sorted.asc::after { content: " ▴"; }
.at-table td { padding: 6px 8px; border-bottom: 1px solid var(--a-line); vertical-align: top; }
.at-table tr { cursor: pointer; } .at-table tbody tr:hover { background: var(--a-bg2); }
.at-table td.code { font-family: var(--a-mono); color: var(--a-accent); white-space: nowrap; }
.at-table td.num { font-family: var(--a-mono); text-align: right; }
.at-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.at-card { background: var(--a-panel); border: 1px solid var(--a-line2); padding: 10px 12px; }
.at-card h5 { margin: 0 0 6px; font-size: 13px; line-height: 1.4; }
.at-card .meta { font-size: 11px; color: var(--a-ink2); }
.at-card ul { margin: 6px 0 0 16px; padding: 0; font-size: 12px; }
.at-h2 { font-family: var(--a-mono); font-size: 11px; letter-spacing: .12em; color: var(--a-ink2); text-transform: uppercase;
  margin: 18px 0 8px; }
.at-h2:first-child { margin-top: 0; }
.at-matrix td.cell { font-size: 11px; }
.at-matrix .exp { color: var(--a-ink2); } .at-matrix .act { display: block; font-family: var(--a-mono); }

/* provenance */
.at-chain { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 14px; overflow-x: auto;
  padding-bottom: 8px; }
.at-col h6 { font-family: var(--a-mono); font-size: 10px; letter-spacing: .1em; color: var(--a-ink2); margin: 0 0 6px;
  text-transform: uppercase; font-weight: normal; }
.at-hash { font-family: var(--a-mono); font-size: 10px; color: var(--a-ink3); word-break: break-all; }
.at-group { border-left: 3px solid; padding-left: 8px; margin-bottom: 8px; }

/* work */
.at-work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.at-bar-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; }
.at-bar-row .bar { height: 8px; background: var(--a-accent); border-radius: 0 2px 2px 0; }

/* timeline */
.at-tl-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--a-line); }
.at-tl-top input[type=range] { flex: 1; accent-color: var(--a-accent); }
.at-tl-chart { width: 100%; height: 150px; flex-shrink: 0; display: block; }
.at-feed .ev { display: grid; grid-template-columns: 150px 90px 90px 1fr; gap: 8px; font-size: 12px; padding: 3px 0;
  border-bottom: 1px solid var(--a-line); }
.at-feed .ev .t { font-family: var(--a-mono); color: var(--a-ink3); font-size: 11px; }

.at-toast { position: absolute; right: 400px; bottom: 16px; z-index: 40; background: var(--a-panel); border: 1px solid var(--a-accent);
  color: var(--a-ink); padding: 8px 12px; font-size: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }

/* narrower screens: the rail goes (a display:none grid item gives up its column, so the template drops it too) */
@media (max-width: 1280px) {
  .at-body { grid-template-columns: 1fr 320px; }
  .at-rail { display: none; }
  .at-toast { right: 340px; }
}
@media (max-width: 900px) {
  .at-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 42%; }
  .at-insp { border-left: 0; border-top: 1px solid var(--a-line); }
  .at-toast { right: 16px; }
  .at-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .at-live::before { animation: none; } }

.at-spark { display: flex; align-items: flex-end; gap: 2px; height: 36px; margin-top: 6px; }
.at-spark span { flex: 1; min-width: 3px; background: var(--a-accent); opacity: .8; border-radius: 2px 2px 0 0; }

.at-table-wrap { overflow-x: auto; }
.atlas button, .atlas select, .atlas input { font: inherit; }
@media (max-width: 640px) {
  .at-bar { gap: 8px; padding: 8px 10px; }
  .at-tabs { overflow-x: auto; max-width: 100%; }
  .at-tabs button { padding: 6px 8px; }
  .at-search { max-width: none; flex-basis: 100%; }
  .at-bar-right { margin-left: 0; }
}
