/* ── Second Brain Panel ─────────────────────────────────────────── */
.sb-panel {
  position:fixed; top:var(--header-h); right:-100%; width:100%; max-width:600px; bottom:0; z-index:150;
  background:var(--bg); border-left:1px solid var(--border);
  display:flex; flex-direction:column; transition:right .3s ease;
}
.sb-panel.open { right:0; }
.sb-panel-backdrop {
  position:fixed; top:var(--header-h); left:0; right:0; bottom:0; z-index:140; background:rgba(0,0,0,.5); display:none;
}
.sb-panel-backdrop.open { display:block; }

/* Header */
.sb-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; border-bottom:1px solid var(--border); flex-shrink:0;
}
.sb-header h2 {
  font-size:15px; font-weight:600; margin:0; display:flex; align-items:center; gap:8px;
}
.sb-header h2 svg { opacity:.7; }
.sb-header-right { display:flex; align-items:center; gap:8px; }
.sb-stats {
  display:flex; gap:12px; font-size:11px; color:var(--text-dim);
}
.sb-stats span { white-space:nowrap; }

/* Tabs */
.sb-tabs { display:flex; border-bottom:1px solid var(--border); flex-shrink:0; }
.sb-tab {
  flex:1; padding:10px 12px; font-size:12px; font-weight:500; color:var(--text-dim);
  cursor:pointer; border:none; background:none; border-bottom:2px solid transparent;
  display:flex; align-items:center; justify-content:center; gap:6px; transition:.15s;
}
.sb-tab:hover { color:var(--text); background:rgba(255,255,255,.03); }
.sb-tab.active { color:var(--accent); border-bottom-color:var(--accent); }

/* Body */
.sb-body { flex:1; overflow-y:auto; overflow-x:hidden; }

/* Toolbar */
.sb-toolbar { padding:10px 12px; border-bottom:1px solid var(--border); flex-shrink:0; }
.sb-search-row { display:flex; gap:6px; margin-bottom:8px; }
.sb-search {
  flex:1; padding:8px 12px; background:var(--surface); border:1px solid var(--border);
  border-radius:8px; color:var(--text); font-size:13px; outline:none;
}
.sb-search:focus { border-color:var(--accent); }
.sb-search-btn {
  padding:8px 12px; background:var(--accent); color:#fff; border:none; border-radius:8px;
  cursor:pointer; display:flex; align-items:center;
}

/* Filters */
.sb-filters { display:flex; flex-wrap:wrap; gap:4px; align-items:center; position:relative; }
.sb-filter-pill {
  padding:4px 10px; font-size:11px; border:1px solid var(--border); border-radius:20px;
  background:rgba(255,255,255,.04); color:var(--text-dim); cursor:pointer; white-space:nowrap;
  transition:.15s;
}
.sb-filter-pill:hover { background:rgba(255,255,255,.08); color:var(--text); }
.sb-filter-pill.active { font-weight:600; }
.sb-filter-sep { color:var(--border); font-size:11px; margin:0 2px; }
.sb-filter-dropdown {
  position:absolute; top:100%; left:0; right:0; z-index:10; margin-top:4px;
  background:var(--surface); border:1px solid var(--border); border-radius:8px;
  max-height:200px; overflow-y:auto; box-shadow:0 8px 24px rgba(0,0,0,.4);
}
.sb-filter-dropdown-item {
  display:flex; align-items:center; gap:8px; padding:8px 12px; font-size:12px;
  color:var(--text-dim); border:none; background:none; width:100%; cursor:pointer; text-align:left;
}
.sb-filter-dropdown-item:hover { background:rgba(255,255,255,.06); }
.sb-filter-dropdown-item.active { color:var(--accent); font-weight:600; }

/* Episode Cards */
.sb-episodes { padding:8px; }
.sb-episode-card {
  background:var(--surface); border:1px solid var(--border); border-radius:10px;
  padding:12px; margin-bottom:8px; transition:border-color .15s;
}
.sb-episode-card:hover { border-color:rgba(255,255,255,.15); }
.sb-ep-header { display:flex; align-items:center; gap:8px; margin-bottom:6px; flex-wrap:wrap; }
.sb-ep-date { font-size:11px; color:var(--text-dim); }
.sb-ep-score {
  font-size:10px; padding:1px 6px; border-radius:10px;
  background:rgba(59,125,216,.15); color:var(--accent); font-weight:600;
}
.sb-scope-badge {
  font-size:10px; padding:2px 8px; border-radius:10px; font-weight:600;
}
.sb-scope-personal { background:rgba(34,197,94,.15); color:#22c55e; }
.sb-scope-business { background:rgba(59,125,216,.15); color:#3b82f6; }
.sb-scope-both { background:rgba(168,85,247,.15); color:#a855f7; }
.sb-ep-content {
  font-size:12px; line-height:1.6; color:var(--text); white-space:pre-wrap; word-break:break-word;
}
.sb-ep-labels { display:flex; flex-wrap:wrap; gap:4px; margin-top:6px; }
.sb-label-badge {
  font-size:10px; padding:2px 7px; border-radius:8px; border:1px solid;
  color:var(--text-dim); background:rgba(255,255,255,.03);
}
.sb-label-dot {
  display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:4px; vertical-align:middle;
}

/* Load more */
.sb-load-more {
  display:block; width:100%; padding:12px; background:rgba(255,255,255,.04);
  border:1px solid var(--border); border-radius:8px; color:var(--text-dim);
  font-size:12px; cursor:pointer; text-align:center; margin-top:4px;
}
.sb-load-more:hover { background:rgba(255,255,255,.08); }

/* Loading / Empty */
.sb-loading { padding:24px; text-align:center; color:var(--text-dim); font-size:13px; }
.sb-empty { padding:24px; text-align:center; color:var(--text-dim); font-size:13px; }

/* ── Knowledge Graph ─────────────────────────────────────────────── */
.sb-graph-types { display:flex; flex-wrap:wrap; gap:4px; }
.sb-type-pill {
  padding:3px 8px; font-size:10px; border:1px solid var(--border); border-radius:14px;
  background:rgba(255,255,255,.04); color:var(--text-dim); cursor:pointer; white-space:nowrap;
  display:flex; align-items:center; gap:4px; transition:.15s;
}
.sb-type-pill:hover { background:rgba(255,255,255,.08); }
.sb-type-pill.active { font-weight:600; }
.sb-type-dot {
  display:inline-block; width:6px; height:6px; border-radius:50%; flex-shrink:0;
}

.sb-graph-container {
  flex:1; position:relative; min-height:300px; background:#0c0c14; overflow:hidden;
}
.sb-graph-container canvas {
  display:block; width:100%; height:100%;
}
.sb-graph-tooltip {
  display:none; position:absolute; padding:6px 10px; background:rgba(20,20,35,.95);
  border:1px solid var(--border); border-radius:6px; font-size:11px; color:var(--text);
  pointer-events:none; z-index:5; white-space:nowrap; max-width:250px;
}
.sb-graph-legend {
  position:absolute; bottom:8px; left:8px; display:flex; flex-wrap:wrap; gap:6px;
  padding:6px 10px; background:rgba(0,0,0,.6); border-radius:6px; font-size:10px;
}
.sb-legend-item { display:flex; align-items:center; gap:3px; color:var(--text-dim); }

/* Graph detail panel */
.sb-graph-detail {
  display:none; max-height:200px; overflow-y:auto; border-top:1px solid var(--border);
  padding:10px 12px; background:var(--surface);
}
.sb-detail-header {
  display:flex; align-items:center; gap:8px; margin-bottom:8px; flex-wrap:wrap;
}
.sb-detail-header strong { font-size:14px; }
.sb-detail-type { font-size:11px; color:var(--text-dim); background:rgba(255,255,255,.06); padding:2px 8px; border-radius:10px; }
.sb-detail-close {
  margin-left:auto; background:none; border:none; color:var(--text-dim);
  font-size:18px; cursor:pointer; padding:0 4px;
}
.sb-rel-item {
  display:flex; align-items:center; gap:6px; padding:3px 0; font-size:12px; color:var(--text-dim);
}
.sb-rel-arrow { color:var(--accent); font-size:14px; }
.sb-rel-pred { color:var(--text-dim); font-style:italic; min-width:80px; }
.sb-rel-entity { color:var(--text); display:flex; align-items:center; gap:4px; }

/* Mobile */
@media(max-width:600px){
  .sb-panel { max-width:100% !important; width:100% !important; z-index:150 !important; }
  .sb-panel-backdrop.open { display:none; }
  .sb-graph-container { min-height:250px; }
  .sb-graph-detail { max-height:150px; }
}
