/* =============================================================================
   v2 stylesheet — compact, graph-first. The map fills the viewport; controls
   (left) and info (right) are collapsible panels toggled from the app bar, so
   the graph can go full-bleed. Controls use accordion sections to stay short.
   No external fonts (CSP: system stack). Legend swatches are classes.
   ============================================================================= */

:root {
  --bg: #0a0d13;
  --panel: #0e131c;
  --panel-2: #141a26;
  --elev: #1a2130;
  --border: #202736;
  --border-strong: #2b3547;

  --text: #e7ebf3;
  --text-dim: #aab2c2;
  --muted: #7b8494;
  --muted-2: #565f6f;

  --accent: #5b8cff;
  --accent-press: #4577f0;
  --danger: #ef4757;
  --danger-press: #e03a4a;
  --green: #34c77b;
  --warn: #e8b84f;

  --radius: 8px;
  --radius-sm: 6px;
  --ctl-h: 30px;
  --appbar-h: 46px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* --- app bar --------------------------------------------------------------- */
#appbar {
  height: var(--appbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3, 12px);
  padding: 0 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { color: var(--accent); font-size: 16px; }
#appbar h1 {
  font-size: 14px; font-weight: 650; margin: 0; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* --- layout ---------------------------------------------------------------- */
main { flex: 1; display: flex; min-height: 0; position: relative; }
#graph { flex: 1; min-width: 0; min-height: 0; background: radial-gradient(circle at 50% 42%, #0e131d, #080b10); }
.select-box {
  position: absolute; border: 1px dashed var(--accent);
  background: rgba(91, 140, 255, .15); pointer-events: none; z-index: 10;
}

#controls {
  width: 296px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Collapse (desktop): toggling the app-bar labels hides the panel to free the map. */
#controlsChk:checked ~ main #controls { display: none; }
#sidebarChk:checked ~ main #sidebar { display: none; }

/* --- accordion control panels ---------------------------------------------- */
.panel { border-bottom: 1px solid var(--border); }
.panel-title {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  font-weight: 700;
  user-select: none;
}
.panel-title::-webkit-details-marker { display: none; }
.panel-title::before {
  content: "▸";
  color: var(--muted);
  font-size: 10px;
  transition: transform .15s ease;
}
.panel[open] > .panel-title::before { transform: rotate(90deg); }
.panel[open] > .panel-title { color: var(--text); }
.panel-body { padding: 2px 12px 14px; display: flex; flex-direction: column; gap: 10px; }

/* --- fields ---------------------------------------------------------------- */
.fields { display: flex; flex-direction: column; gap: 9px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span {
  font-size: 10px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); font-weight: 600;
}
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check > span { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 400; color: var(--text-dim); }

input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], select {
  width: 100%; height: var(--ctl-h);
  background: var(--elev); border: 1px solid var(--border-strong);
  color: var(--text); padding: 0 8px; border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
input::placeholder { color: var(--muted-2); }
select { cursor: pointer; }
input:focus, select:focus { outline: none; border-color: var(--accent); }

.checks { display: flex; flex-direction: column; gap: 8px; }

/* --- buttons --------------------------------------------------------------- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn {
  min-height: var(--ctl-h); padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--elev); color: var(--text);
  font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .12s ease, border-color .12s ease, transform .04s ease;
  white-space: nowrap;
}
.btn.sm { min-height: 28px; padding: 0 9px; font-size: 12px; }
.btn:hover { background: #1f2736; border-color: #384357; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent-press); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.danger:hover { background: var(--danger-press); }
.btn.accent { background: rgba(52, 199, 123, .16); border-color: rgba(52, 199, 123, .5); color: #7ee2ab; }
.btn.accent:hover { background: rgba(52, 199, 123, .26); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text-dim); }
.btn.ghost:hover { background: var(--elev); color: var(--text); }
.btn.icon { padding: 0 9px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

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

.status { font-size: 11.5px; color: var(--muted); min-height: 14px; }
.detect { display: block; font-size: 11px; line-height: 1.4; min-height: 14px; color: var(--muted-2); }
.detect.ok { color: var(--green); }
.detect.warn { color: var(--warn); }
.detect a { color: var(--accent); }
.hint { font-size: 11px; color: var(--muted-2); margin: 0; line-height: 1.5; }

/* --- sampling banner ------------------------------------------------------- */
.banner {
  flex-shrink: 0;
  padding: 8px 12px;
  background: rgba(232, 184, 79, .1);
  border-bottom: 1px solid rgba(232, 184, 79, .35);
  color: #ecd08a; font-size: 12px;
}

/* --- sidebar cards --------------------------------------------------------- */
.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.card.grow { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.card h3 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 7px; font-weight: 700;
}
.legend-row { font-size: 12px; margin-bottom: 5px; display: flex; align-items: center; gap: 8px; color: var(--text-dim); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.line { width: 18px; height: 3px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.dot-root { background: #e63946; }
.dot-discovered { background: #457b9d; }
.line-normal { background: #4f8ef7; }
.line-internal { background: #f7a24f; }
.line-token { background: #4fd67a; }
.line-data { background: repeating-linear-gradient(90deg, #c9d3e3 0 4px, transparent 4px 7px); }
.dot-cycle { background: transparent; border: 2px solid #e8b84f; }
.line-age { background: linear-gradient(90deg, hsl(210, 72%, 45%), hsl(30, 72%, 60%)); }

#detailsContent { font-size: 12px; line-height: 1.5; word-break: break-all; color: var(--text-dim); }
#detailsContent a { color: var(--accent); }
#detailsContent table { width: 100%; border-collapse: collapse; }
#detailsContent td { padding: 2px 0; vertical-align: top; }
#detailsContent td.k { color: var(--muted); width: 78px; padding-right: 8px; }
#detailsContent .btn { margin-top: 8px; }

#privacyBody { font-size: 11px; line-height: 1.5; color: var(--muted); margin: 0 0 7px; }
.indicator { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.indicator::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3a4150; flex-shrink: 0; }
.indicator.active { color: var(--warn); }
.indicator.active::before { background: var(--warn); box-shadow: 0 0 7px var(--warn); }

#logContent {
  flex: 1; font-size: 11px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  color: var(--muted); overflow-y: auto; min-height: 80px; white-space: pre-wrap;
}
#logContent .err { color: #ff6b76; }

/* --- mobile: panels become slide-in overlays; graph stays full-screen ------ */
@media (max-width: 860px) {
  #controls, #sidebar {
    position: fixed;
    top: var(--appbar-h);
    bottom: 0;
    width: min(86%, 320px);
    z-index: 40;
    box-shadow: var(--shadow);
    transition: transform .2s ease;
  }
  #controls { left: 0; transform: translateX(-101%); display: flex; }
  #sidebar { right: 0; transform: translateX(101%); display: flex; }
  #controlsChk:checked ~ main #controls { display: flex; transform: none; }
  #sidebarChk:checked ~ main #sidebar { display: flex; transform: none; }
}
