/* ── Story cards ── */
.story-card { display:flex; align-items:center; gap:10px; padding:10px 12px;
  background:var(--bg-2); border:1px solid var(--border-subtle); border-radius:8px;
  cursor:pointer; transition:all .15s; }
.story-card:hover { border-color:var(--text-3); background:var(--bg-1); }
.story-card.active { border-color:var(--accent); background:color-mix(in srgb, var(--accent) 8%, var(--bg-1)); box-shadow:0 0 0 1px var(--accent); }
.story-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.story-body { min-width:0; }
.story-title { font-size:12px; font-weight:700; color:var(--text-0); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.story-sub { font-size:10px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* ── Subgraph strip ── */
#subgraph-bar { display:none; padding:4px 0; }
#subgraph-bar.visible { display:block; }
.sg-strip { display:flex; gap:4px; flex-wrap:wrap; }
.sg-chip { display:inline-flex; align-items:center; gap:4px; padding:4px 9px;
  background:var(--bg-2); border:1.5px solid var(--border-subtle); border-radius:16px;
  cursor:pointer; transition:all .12s; font-size:10.5px; white-space:nowrap; }
.sg-chip:hover { background:var(--bg-1); border-color:var(--text-3); }
.sg-chip.active { background:color-mix(in srgb, currentColor 12%, var(--bg-1)); border-color:currentColor; font-weight:700; }
.sg-chip .sg-i { font-size:12px; line-height:1; }
.sg-chip .sg-n { color:var(--text-0); }
.sg-chip .sg-c { font-size:8px; color:var(--text-3); opacity:.7; }

.graph-page { display:flex; flex-direction:column; height:calc(100vh - 160px); min-height:500px; }

/* ── Toolbar ── */
.graph-toolbar { display:flex; gap:5px; align-items:center; padding:6px 10px;
  background:var(--bg-1); border:1px solid var(--border-subtle); border-radius:10px 10px 0 0; border-bottom:none; flex-wrap:wrap; }
.graph-toolbar select, .graph-toolbar input { font-size:11px; padding:4px 7px; background:var(--bg-2);
  border:1px solid var(--border); border-radius:5px; color:var(--text-0); }
.graph-toolbar input[type=search] { width:180px; }
.tb-sep { width:1px; height:18px; background:var(--border-subtle); margin:0 1px; flex-shrink:0; }
.tb-stat { font-size:10px; color:var(--text-3); margin-left:auto; white-space:nowrap; }
.tb-preset { font-size:10px; padding:3px 8px; border-radius:5px; border:1px solid var(--border);
  background:var(--bg-2); color:var(--text-2); cursor:pointer; transition:all .12s; white-space:nowrap; }
.tb-preset:hover { border-color:var(--text-3); color:var(--text-0); }
.tb-preset.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.tb-btn { font-size:10px; padding:3px 7px; border-radius:5px; border:1px solid var(--border);
  background:var(--bg-2); color:var(--text-2); cursor:pointer; white-space:nowrap; }
.tb-btn:hover { border-color:var(--text-3); color:var(--text-0); }

/* ── Autocomplete ── */
.search-wrap { position:relative; }
.search-results { position:absolute; top:100%; left:0; right:0; z-index:100; margin-top:2px;
  background:var(--bg-1); border:1px solid var(--border); border-radius:6px; box-shadow:0 4px 12px rgba(0,0,0,.15);
  max-height:260px; overflow-y:auto; display:none; }
.search-results.open { display:block; }
.sr-item { padding:6px 10px; font-size:11px; cursor:pointer; display:flex; align-items:center; gap:6px;
  border-bottom:1px solid var(--border-subtle); }
.sr-item:last-child { border-bottom:none; }
.sr-item:hover, .sr-item.active { background:var(--bg-2); }
.sr-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.sr-name { font-weight:600; color:var(--text-0); }
.sr-meta { font-size:9px; color:var(--text-3); margin-left:auto; }

/* ── Tip bar ── */
.graph-tip { display:flex; align-items:center; gap:10px; padding:6px 12px; font-size:11px; color:var(--text-2);
  background:color-mix(in srgb, var(--accent) 6%, var(--bg-1)); border-left:1px solid var(--border-subtle);
  border-right:1px solid var(--border-subtle); line-height:1.4; }
.graph-tip.hidden { display:none; }
.graph-tip kbd { font-size:10px; padding:1px 5px; background:var(--bg-2); border:1px solid var(--border);
  border-radius:3px; font-family:inherit; }
.graph-tip button { background:none; border:none; color:var(--text-3); cursor:pointer; font-size:13px;
  margin-left:auto; flex-shrink:0; padding:0 4px; }

/* ── Body ── */
.graph-body { display:flex; flex:1; border:1px solid var(--border-subtle); border-radius:0 0 10px 10px;
  overflow:hidden; background:var(--bg-1); min-height:0; position:relative; }
#cy { flex:1; min-width:0; background:var(--bg-2); }

/* ── Sidebar ── */
.graph-sidebar { width:0; overflow:hidden; border-left:none; transition:width .2s ease;
  background:var(--bg-1); display:flex; flex-direction:column; flex-shrink:0; }
.graph-sidebar.open { width:320px; border-left:1px solid var(--border-subtle); }
.gs-header { display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px 8px; border-bottom:1px solid var(--border-subtle); flex-shrink:0; }
.gs-header h3 { font-size:12px; font-weight:700; color:var(--text-0); margin:0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gs-close { background:none; border:none; color:var(--text-3); cursor:pointer;
  font-size:14px; padding:2px 5px; border-radius:4px; flex-shrink:0; }
.gs-close:hover { background:var(--bg-2); color:var(--text-0); }
.gs-body { flex:1; overflow-y:auto; padding:10px 12px; }
.gs-label { font-size:9px; text-transform:uppercase; letter-spacing:.5px;
  color:var(--text-3); font-weight:600; margin:12px 0 4px; }
.gs-label:first-child { margin-top:0; }
.gs-row { display:flex; justify-content:space-between; align-items:baseline;
  padding:3px 0; border-bottom:1px solid var(--border-subtle); font-size:11px; }
.gs-row:last-child { border-bottom:none; }
.gs-tag { display:inline-block; font-size:9px; font-weight:600; padding:2px 7px; border-radius:8px; }
.gs-section { margin-bottom:12px; }
.gs-conns { list-style:none; padding:0; margin:0; }
.gs-conns li { font-size:11px; padding:4px 0; border-bottom:1px solid var(--border-subtle);
  display:flex; align-items:baseline; gap:5px; }
.gs-conns li:last-child { border-bottom:none; }

/* ── Help legend ── */
.help-legend { display:flex; flex-wrap:wrap; gap:6px; margin:4px 0 8px; }
.help-legend span { font-size:10px; display:flex; align-items:center; gap:3px; }
.help-dot { width:8px; height:8px; border-radius:50%; display:inline-block; }
.help-sc { display:flex; align-items:center; gap:6px; font-size:10px; color:var(--text-2); padding:2px 0; }
.help-sc kbd { font-size:9px; padding:1px 5px; min-width:20px; text-align:center;
  background:var(--bg-2); border:1px solid var(--border); border-radius:3px; font-family:inherit; }

/* ── Floating graph legend ── */
.graph-legend {
  position:absolute; bottom:16px; left:16px; z-index:20;
  background:var(--bg-card); border:1px solid var(--border);
  border-radius:10px; padding:10px 14px;
  box-shadow:0 4px 20px rgba(0,0,0,.25);
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
  font-size:11px; line-height:1; user-select:none;
  transition:opacity .2s;
}
.graph-legend.collapsed .gl-items { display:none; }
.graph-legend.collapsed { padding:6px 10px; }
.gl-header {
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; cursor:pointer; margin-bottom:8px;
}
.graph-legend.collapsed .gl-header { margin-bottom:0; }
.gl-header span { font-weight:700; font-size:10px; text-transform:uppercase;
  letter-spacing:.5px; color:var(--text-2); }
.gl-toggle { background:none; border:none; color:var(--text-3); cursor:pointer;
  font-size:13px; padding:0; line-height:1; }
.gl-items { display:flex; flex-direction:column; gap:7px; }
.gl-row { display:flex; align-items:center; gap:8px; }
.gl-shape {
  width:22px; height:22px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  border-radius:4px; position:relative;
}
.gl-shape svg { width:14px; height:14px; }
.gl-shape.s-vessel { background:#1e3a5f; border:1.5px solid #3b82f6;
  border-radius:2px; transform:rotate(45deg); width:18px; height:18px; }
.gl-shape.s-vessel svg { transform:rotate(-45deg); }
.gl-shape.s-person { background:#2e1065; border:1.5px solid #8b5cf6; border-radius:50%; }
.gl-shape.s-company { background:#422006; border:1.5px solid #f59e0b; border-radius:5px; }
.gl-shape.s-infra { background:#064e3b; border:1.5px solid #10b981;
  clip-path:polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%); width:24px; height:24px; }
.gl-label { color:var(--text-1); font-weight:500; }
.gl-count { color:var(--text-3); font-size:10px; margin-left:auto; font-variant-numeric:tabular-nums; }

.gl-divider { height:1px; background:var(--border-subtle); margin:4px 0; }
.gl-ev-row { display:flex; align-items:center; gap:6px; }
.gl-ev-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.gl-ev-label { color:var(--text-2); font-size:10px; }

@media (max-width:640px) {
  .graph-legend { bottom:8px; left:8px; right:8px; }
}
.help-step { font-size:11px; color:var(--text-2); line-height:1.5; padding:3px 0; }
.help-step strong { color:var(--text-0); }

/* ── Mobile list view ── */
.mobile-list { display:none; }
.ml-card { background:var(--bg-1); border:1px solid var(--border-subtle); border-radius:8px;
  padding:10px 12px; margin-bottom:8px; cursor:pointer; transition:border-color .15s; }
.ml-card:hover { border-color:var(--text-3); }
.ml-card-header { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.ml-card-name { font-size:13px; font-weight:700; color:var(--text-0); }
.ml-card-meta { font-size:10px; color:var(--text-3); }
.ml-card-conns { font-size:11px; color:var(--text-2); }
.ml-search { width:100%; padding:8px 12px; font-size:13px; background:var(--bg-1);
  border:1px solid var(--border); border-radius:8px; color:var(--text-0); margin-bottom:10px; }
.ml-filters { display:flex; gap:5px; flex-wrap:wrap; margin-bottom:10px; }
.ml-filter { font-size:10px; padding:4px 10px; border-radius:5px; border:1px solid var(--border);
  background:var(--bg-2); color:var(--text-2); cursor:pointer; }
.ml-filter.active { background:var(--accent); color:#fff; border-color:var(--accent); }

@media(max-width:768px) {
  .graph-page { height:auto; min-height:auto; }
  .graph-toolbar { display:none; }
  .graph-tip { display:none; }
  .graph-body { display:flex; flex-direction:column; height:50vh; min-height:300px; border-radius:10px; }
  #cy { flex:1; min-height:280px; border-radius:10px; }
  .graph-sidebar.open { width:100%; border-left:none; border-top:1px solid var(--border-subtle); max-height:220px; }
  .mobile-list { display:block; padding:0 4px; }
  .story-card { padding:8px 10px; }
}
