:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #484f58;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-subtle: rgba(88,166,255,0.15);
  --danger: #f85149;
  --danger-hover: #ff7b72;
  --success: #3fb950;
  --success-subtle: rgba(63,185,80,0.15);
  --warning: #d29922;
  --info: #58a6ff;
  --radius: 8px;
  --radius-lg: 12px;
  /* Kind colors */
  --kind-note: #58a6ff;
  --kind-fact: #3fb950;
  --kind-idea: #d2a8ff;
  --kind-summary: #f0883e;
  --kind-artifact: #79c0ff;
  --kind-task-context: #d29922;
  --kind-constraint: #f85149;
  --kind-question: #db61a2;
  --kind-decision: #7ee787;
  /* Relation colors */
  --rel-supporting: #3fb950;
  --rel-contradicting: #f85149;
  --rel-structural: #58a6ff;
  --app-header-height: 52px;
  --tab-bar-height: 46px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
/* ─── Header ───────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header .logo { font-size: 1.25rem; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.app-header .logo-img { width: 24px; height: 24px; flex-shrink: 0; }
.header-search {
  flex: 1; max-width: 420px; margin: 0 auto;
  position: relative;
}
.header-search input {
  width: 100%; padding: 0.4rem 0.75rem 0.4rem 2rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.8rem;
  cursor: pointer;
}
.header-search input:focus { outline: none; border-color: var(--accent); cursor: text; }
.header-search .search-icon {
  position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.85rem; pointer-events: none;
}
.header-search .search-hint {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 0.65rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.1rem 0.35rem; pointer-events: none;
}
.header-right { display: flex; align-items: center; gap: 0.75rem; white-space: nowrap; }
.user-greeting { color: var(--text-muted); font-size: 0.8rem; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; color: var(--text-muted); overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* ─── Tab bar ──────────────────────────────────────────── */
.tab-bar-spacer {
  display: none;
  width: 100%;
  flex-shrink: 0;
  overflow: hidden;
  transition: height 0.22s ease;
}
.tab-bar {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  --tab-bar-fade: var(--surface);
  position: relative;
  padding: 0;
  margin: 0;
}
.tab-bar-scroll {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}
.tab-bar-overflow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.75rem;
  z-index: 2;
  pointer-events: none;
  display: none;
}
.tab-bar-overflow--start {
  left: 0;
}
.tab-bar-overflow--end {
  right: 0;
}
.tab-bar-overflow--start::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--tab-bar-fade) 38%, transparent);
}
.tab-bar-overflow--end::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, var(--tab-bar-fade) 38%, transparent);
}
.tab-bar-scroll.tab-bar-scroll--overflow:not(.tab-bar-scroll--start) .tab-bar-overflow--start {
  display: block;
}
.tab-bar-scroll.tab-bar-scroll--overflow:not(.tab-bar-scroll--end) .tab-bar-overflow--end {
  display: block;
}
.tab-bar-nudge {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 4;
  width: 2.25rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.tab-bar-nudge:hover {
  color: var(--accent);
}
.tab-bar-nudge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tab-bar-nudge--prev {
  left: 0;
}
.tab-bar-nudge--next {
  right: 0;
}
.tab-bar-nudge[hidden] {
  display: none !important;
  pointer-events: none;
}
.tab-bar-scroll.tab-bar-scroll--overflow .tab-bar-track {
  scroll-padding-inline: 1.75rem;
}
.tab-bar-track {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  gap: 0;
  padding: 0 1.5rem;
}
.tab-bar-track::-webkit-scrollbar {
  display: none;
  height: 0;
  width: 0;
}
.tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.6rem 1.25rem; background: none; border: none;
  color: var(--text-muted); font-size: 0.875rem; cursor: pointer;
  position: relative; transition: color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); font-weight: 600; }
.tab-btn.active::after {
  content: ""; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--accent); border-radius: 1px;
}
.tab-bar.has-indicator .tab-btn.active::after { display: none; }
.tab-indicator {
  position: absolute; bottom: -1px; left: 0; height: 2px;
  background: var(--accent); border-radius: 1px;
  transition: left 0.25s ease, width 0.25s ease;
  pointer-events: none;
}
.tab-btn .tab-attention-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  margin-left: 0.4rem;
  box-shadow: 0 0 0 0 rgba(210,153,34,0.65);
  animation: tabPulse 1.8s infinite;
  vertical-align: middle;
}
.tab-btn.attention .tab-attention-dot { display: inline-block; }
@keyframes tabPulse {
  0% { box-shadow: 0 0 0 0 rgba(210,153,34,0.65); }
  70% { box-shadow: 0 0 0 7px rgba(210,153,34,0); }
  100% { box-shadow: 0 0 0 0 rgba(210,153,34,0); }
}

@media (max-width: 768px) {
  :root {
    --tab-bar-reveal-duration: 0.28s;
    --tab-bar-reveal-ease: cubic-bezier(0.32, 0.72, 0, 1);
  }
  body {
    overflow-x: hidden;
  }
  .tab-bar-spacer {
    display: block;
    height: var(--tab-bar-height, 46px);
    transition: height var(--tab-bar-reveal-duration) var(--tab-bar-reveal-ease);
    overflow: hidden;
  }
  .tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--app-header-height, 52px);
    z-index: 49;
    transform: translateY(0);
    transition: transform var(--tab-bar-reveal-duration) var(--tab-bar-reveal-ease);
  }
  .tab-bar.tab-bar--hidden {
    transform: translateY(-100%);
    pointer-events: none;
  }
  .tab-bar-track {
    padding: 0 0.75rem;
  }
}

@media (min-width: 769px) {
  .tab-bar {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    transform: none !important;
  }
  .tab-bar.tab-bar--hidden {
    transform: none !important;
    pointer-events: auto;
  }
  .tab-bar-spacer {
    display: none !important;
    height: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab-bar,
  .tab-bar-spacer,
  .graph-container {
    transition-duration: 0.01ms !important;
  }
}

/* ─── Tab content ──────────────────────────────────────── */
.tab-content { display: none; padding: 1.5rem; max-width: 1100px; margin: 0 auto; }
.tab-content.active { display: block; }
/* ─── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 0.875rem;
  cursor: pointer; text-decoration: none; transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--bg); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.4rem; border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; }
.btn-icon:hover { color: var(--accent); }
/* ─── Cards ────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
.section { margin-bottom: 2rem; }
.section h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; }
.section h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text-muted); }
/* ─── Stat cards ───────────────────────────────────────── */
.stat-cards {
  display: flex; flex-wrap: wrap;
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-cards > .stat-card {
  flex: 1 1 0; min-width: 0;
}
@media (max-width: 1100px) {
  .stat-cards > .stat-card { flex-basis: 28%; min-width: 28%; }
}
@media (max-width: 768px) {
  .stat-cards > .stat-card { flex-basis: 40%; min-width: 40%; }
}
@media (max-width: 480px) {
  .stat-cards > .stat-card { flex-basis: 100%; }
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  opacity: 0; animation: fadeInUp 0.4s ease forwards;
}
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 100ms; }
.stat-card:nth-child(3) { animation-delay: 200ms; }
.stat-card:nth-child(4) { animation-delay: 300ms; }
.stat-card:nth-child(5) { animation-delay: 400ms; }
.stat-card:nth-child(6) { animation-delay: 500ms; }

.stats-usage-strip {
  margin-bottom: 1rem;
  padding: 0.55rem 0.85rem;
}
.stats-usage-strip-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}
.stats-usage-strip-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.stats-usage-strip-numbers {
  font-size: 0.82rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  max-width: 42%;
}
.stats-usage-strip-bar-wrap {
  flex: 1 1 0;
  min-width: 4rem;
  min-height: 8px;
}
.stats-usage-strip-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.stats-usage-strip-bar-fills {
  display: block;
  height: 100%;
  width: 0%;
  min-width: 0;
  transition: width 0.2s ease;
}
.stats-usage-strip-bar-fills--overflow {
  display: flex;
  flex-direction: row;
  width: 100%;
}
.stats-usage-strip-bar-seg {
  height: 100%;
  min-width: 0;
  transition: flex 0.2s ease, background 0.2s ease;
}
.stats-usage-strip-bar-seg--normal {
  border-radius: 999px 0 0 999px;
}
.stats-usage-strip-bar-seg--normal:only-child {
  border-radius: 999px;
}
.stats-usage-strip-bar-seg--over {
  border-radius: 0 999px 999px 0;
}
.stats-usage-strip-reset {
  font-size: 0.72rem;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-left: 0;
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .stats-usage-strip-inner { flex-wrap: wrap; }
  .stats-usage-strip-numbers { max-width: none; }
  .stats-usage-strip-bar-wrap {
    flex: 1 1 100%;
    order: 4;
    margin-left: 0;
  }
  .stats-usage-strip-reset { width: 100%; text-align: right; order: 5; }
}
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; line-height: 1; margin-bottom: 0.25rem; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ─── Charts grid ──────────────────────────────────────── */
.charts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem;
}
.charts-grid--stats { align-items: start; }
.charts-stack {
  display: flex; flex-direction: column; gap: 1rem; min-width: 0;
}
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; min-width: 0; }
.chart-card > h3 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.chart-card-head h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
  min-width: 8rem;
}
.chart-y-scale {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.chart-y-scale label { margin: 0; cursor: default; }
.chart-y-scale-select {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.chart-card canvas { display: block; width: 100% !important; max-width: 100%; max-height: 220px; }
.chart-card--synapse canvas { max-height: 260px; }
.chart-card.full-width { grid-column: 1 / -1; }
/* ─── Plan accordion ──────────────────────────────────── */
.plan-accordion-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.85rem; cursor: pointer; border-radius: var(--radius-lg);
  border: 1px solid var(--border); margin-bottom: 0.5rem;
  transition: border-color 0.15s, background 0.15s; user-select: none;
}
.plan-accordion-row:hover { border-color: var(--accent); background: var(--surface); }
.plan-accordion-row.open { border-color: var(--accent); background: var(--surface); border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: 0; }
.plan-accordion-row.no-toggle { cursor: default; }
.plan-accordion-row.no-toggle:hover { border-color: var(--border); background: transparent; }
.plan-accordion-chevron { font-size: 0.8rem; color: var(--text-muted); transition: transform 0.2s; width: 1rem; text-align: center; flex-shrink: 0; }
.plan-accordion-row.open .plan-accordion-chevron { transform: rotate(90deg); }
.plan-accordion-name { font-weight: 600; font-size: 0.92rem; }
.plan-accordion-meta { font-size: 0.92rem; font-weight: 600; color: var(--text-muted); margin-left: auto; display: flex; gap: 1rem; }
.plan-accordion-badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--accent-subtle); color: var(--accent); border: 1px solid var(--accent); font-weight: 500; }
.plan-accordion-body {
  border: 1px solid var(--accent); border-top: none; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 1rem; margin-bottom: 0.5rem; background: var(--surface);
}
.plan-accordion-body.hidden { display: none; }

/* ─── Plan term boxes ──────────────────────────────────── */
.plan-term-boxes { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.plan-term-box {
  flex: 1; min-width: 160px; display: flex; flex-direction: column; align-items: center;
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg);
  text-decoration: none; color: var(--text); text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.plan-term-box:hover { border-color: var(--accent); background: rgba(88,166,255,0.06); transform: translateY(-1px); }
.plan-term-box.annual {
  border-color: var(--accent); background: linear-gradient(180deg, rgba(88,166,255,0.14), rgba(88,166,255,0.04));
  box-shadow: 0 0 0 1px rgba(88,166,255,0.15);
}
.plan-term-box.annual:hover { background: linear-gradient(180deg, rgba(88,166,255,0.22), rgba(88,166,255,0.08)); }
.plan-term-box.current {
  border-color: var(--success); background: rgba(63,185,80,0.06);
  pointer-events: none; cursor: default;
}
.plan-term-box .term-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.3rem; }
.plan-term-box .term-price { font-size: 1.15rem; font-weight: 700; }
.plan-term-box .term-sub { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.1rem; }
.plan-term-box .term-cta { font-size: 0.82rem; font-weight: 600; margin-top: 0.5rem; color: var(--accent); }
.plan-term-box .term-cta.cta-lg { font-size: 1rem; margin-top: 0.7rem; }
.plan-term-box.current .term-cta { color: var(--success); }
.plan-savings-note { font-size: 0.78rem; color: var(--success); margin-top: 0.6rem; text-align: center; }
.plan-manage-row { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

/* ─── Billing gate ─────────────────────────────────────── */
.billing-gate {
  position: fixed; inset: 0; z-index: 500; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.billing-gate-inner { max-width: 520px; width: 100%; padding: 2rem; }
.billing-gate-inner h1 { font-size: 1.5rem; margin: 0 0 0.5rem 0; }
.billing-gate-inner .gate-sub { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem; }
/* ─── Activity feed ────────────────────────────────────── */
.activity-feed { max-height: 320px; overflow-y: auto; }
.activity-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
  overflow: hidden;
}
.activity-item:hover { background: var(--surface-hover); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.activity-dot.created { background: var(--success); }
.activity-dot.updated { background: var(--accent); }
.activity-headline {
  display: block;
  width: 100%;
  min-width: 0;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-time {
  justify-self: end;
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}
/* ─── Kind badge ───────────────────────────────────────── */
.kind-badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 4px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
}
/* ─── Session insights ─────────────────────────────────── */
.insights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.insight-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.insight-row:last-child { border-bottom: none; }
.insight-name { font-weight: 500; }
.insight-stat { color: var(--text-muted); font-size: 0.8rem; }
/* ─── Heatmap ─────────────────────────────────────────── */
.heatmap-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1.5rem;
}
.heatmap-card h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.75rem 0; color: var(--text-muted); }
.heatmap-wrap { position: relative; width: 100%; height: 140px; }
.heatmap-meta {
  display: flex; align-items: center; gap: 1rem; margin-top: 0.5rem; font-size: 0.7rem; color: var(--text-muted);
  flex-wrap: wrap;
}
.heatmap-legend {
  display: flex; align-items: center; gap: 3px; margin-left: auto;
}
.heatmap-legend-cell {
  width: 10px; height: 10px; border-radius: 2px;
}
/* ─── Knowledge Insights (collapsible) ────────────────── */
.knowledge-insights { margin-top: 1.5rem; }
.knowledge-insights-toggle {
  display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
  padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); user-select: none; transition: background 150ms ease;
}
.knowledge-insights-toggle:hover { background: var(--bg); }
.knowledge-insights-toggle h3 { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.knowledge-insights-chevron {
  transition: transform 200ms ease; color: var(--text-muted);
}
.knowledge-insights.open .knowledge-insights-chevron { transform: rotate(90deg); }
.knowledge-insights-body {
  display: none; margin-top: 0.75rem;
}
.knowledge-insights.open .knowledge-insights-body { display: grid; }
.knowledge-insights-body {
  grid-template-columns: 1fr 1fr 1fr; gap: 1rem;
}
.insight-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
}
.insight-card h4 { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin: 0 0 0.75rem 0; }
.insight-card-body { position: relative; height: 240px; overflow: hidden; }
#distTabs {
  display: flex; width: 100%; padding: 2px; gap: 2px;
  border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border);
}
.dist-tab {
  flex: 1 1 0; text-align: center; padding: 0.25rem 0.55rem; font-size: 0.68rem; font-weight: 500;
  border: none; border-radius: calc(var(--radius) - 2px);
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.dist-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.dist-tab.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
/* ─── Empty state ──────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; max-width: 480px; margin-left: auto; margin-right: auto; }
.empty-state .btn { margin: 0 0.5rem; }
/* ─── Explore tab ──────────────────────────────────────── */
.explore-controls {
  display: flex; gap: 0.5rem 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.explore-controls .flex-break { flex-basis: 100%; height: 0; }
.explore-controls select, .explore-controls input {
  padding: 0.4rem 0.75rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.8rem;
}
.explore-controls select:focus, .explore-controls input:focus { outline: none; border-color: var(--accent); }
.layout-btns { display: flex; gap: 2px; }
.layout-btns button {
  padding: 0.35rem 0.6rem; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.75rem; cursor: pointer; transition: all 0.15s;
}
.layout-btns button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.layout-btns button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.layout-btns button.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }
.kind-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.kind-chip {
  padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.7rem;
  cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); transition: all 0.15s;
}
.kind-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }
.graph-container {
  position: relative; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  height: calc(100vh - 260px); min-height: 400px;
}
#cy { width: 100%; height: 100%; }
.truncation-banner {
  display: none; position: absolute; top: 0.5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.4rem 1rem; font-size: 0.8rem; color: var(--text-muted); z-index: 10;
}
.truncation-banner.visible { display: block; }
.node-hover-card {
  display: none; position: fixed; z-index: 30; pointer-events: none;
  max-width: 320px; background: rgba(22, 27, 34, 0.96); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.55rem 0.65rem; box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  font-size: 0.75rem; color: var(--text-muted);
}
.node-hover-card .headline { color: var(--text); font-weight: 600; margin-bottom: 0.2rem; }
.node-hover-card .meta { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.node-hover-card .pill { border: 1px solid var(--border); background: var(--bg); border-radius: 999px; padding: 0.05rem 0.4rem; }
/* ─── Node detail panel ────────────────────────────────── */
.detail-panel {
  position: fixed; top: 0; right: -380px; width: 380px; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 60; transition: right 0.25s ease; overflow-y: auto;
  padding: 1.25rem;
}
.detail-panel.open { right: 0; }
.detail-panel .panel-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1rem;
}
.detail-panel .panel-close {
  background: var(--surface-hover); border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; font-size: 0.82rem; padding: 0.45rem 1rem; border-radius: var(--radius);
  min-height: 44px; min-width: 70px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.detail-panel .panel-close:hover { background: var(--border); color: var(--text); }

/* ─── Gear dropdown ──────────────────────────────────── */
.gear-wrapper { position: relative; }
.gear-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 160px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  padding: 4px 0;
}
.gear-menu.open { display: block; }
.gear-menu-item {
  display: block; width: 100%; padding: 9px 14px; background: none; border: none;
  color: var(--text); font-size: 0.85rem; text-align: left; cursor: pointer;
  transition: background 0.12s;
}
.gear-menu-item:hover { background: var(--surface-hover); }
.gear-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.detail-headline { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.detail-body { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.6; }
.detail-meta { margin-bottom: 1rem; }
.detail-meta-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; font-size: 0.8rem; }
.detail-meta-label { color: var(--text-dim); min-width: 80px; }
.detail-collections { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 0.75rem; }
.detail-collection {
  padding: 0.2rem 0.55rem; background: rgba(88,166,255,0.1); color: #58a6ff;
  border: 1px solid rgba(88,166,255,0.2); border-radius: 6px; font-size: 0.75rem;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.detail-collection:hover { background: rgba(88,166,255,0.2); border-color: rgba(88,166,255,0.4); }
.detail-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 0.75rem; }
.detail-tag {
  padding: 0.15rem 0.5rem; background: var(--accent-subtle); color: var(--accent);
  border-radius: 4px; font-size: 0.75rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.detail-tag:hover { background: var(--accent); color: var(--bg); }
.detail-links { font-size: 0.85rem; }
.detail-link-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: color 0.15s;
}
.detail-link-item:hover { color: var(--accent); }
.detail-link-item:last-child { border-bottom: none; }
.detail-link-rel { font-size: 0.7rem; color: var(--text-dim); min-width: 90px; }
.confidence-bar {
  width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.confidence-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
/* ─── Settings ─────────────────────────────────────────── */
#tab-settings { column-count: 2; column-gap: 1.5rem; }
.settings-section { break-inside: avoid; margin-bottom: 1.5rem; }
.settings-section h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.form-group input {
  width: 100%; padding: 0.5rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.875rem;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-group input[readonly] { color: var(--text-muted); cursor: not-allowed; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.key-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border);
}
.key-row:last-child { border-bottom: none; }
.key-meta { display: flex; flex-direction: column; gap: 0.25rem; }
.key-name { font-weight: 500; }
.key-prefix { font-family: monospace; color: var(--text-muted); font-size: 0.8rem; }
.key-date { color: var(--text-muted); font-size: 0.75rem; }
.badge-inactive {
  font-size: 0.7rem; padding: 0.15rem 0.5rem;
  background: var(--danger); color: #fff; border-radius: 4px; margin-left: 0.5rem;
}
.create-form { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.create-form input {
  flex: 1; padding: 0.5rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.875rem;
}
.create-form input:focus { outline: none; border-color: var(--accent); }
.danger-zone {
  border-top: 1px solid var(--danger); padding-top: 1.5rem; margin-top: 2rem;
}
.danger-zone h3 { color: var(--danger); font-size: 0.95rem; margin-bottom: 0.75rem; }
/* ─── Modal ────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 100; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  max-width: 520px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { margin-bottom: 1rem; }
.modal .key-display {
  font-family: monospace; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem; word-break: break-all;
  margin-bottom: 1rem; font-size: 0.85rem;
}
.modal .warning { color: var(--danger); font-size: 0.8rem; margin-bottom: 1rem; }
#lockKeyModal {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 110px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
}
#lockKeyModal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#lockKeyModal .modal {
  animation: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: transform 0.22s ease, opacity 0.22s ease;
  border-color: rgba(212,167,44,0.45);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
#lockKeyModal.active .modal {
  opacity: 1;
  transform: translateY(0);
}
#unlockReauthModal {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 110px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
}
#unlockReauthModal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#unlockReauthModal .modal {
  animation: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: transform 0.22s ease, opacity 0.22s ease;
  border-color: rgba(255,85,85,0.35);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
#unlockReauthModal.active .modal {
  opacity: 1;
  transform: translateY(0);
}

/* Lock tab: verify-identity overlay (match unlock modal backdrop; no red border on card) */
#lockReauthOverlay {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 110px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  z-index: 105;
}
#lockReauthOverlay .modal {
  animation: none;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
#lockReauthOverlay .reauth-modal__title {
  margin: 0;
  font-size: 1.05rem;
}

/* Shared reauth UI: method choice + fields (used by verify + remove-lock modals) */
.reauth-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.reauth-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.reauth-modal__close:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface);
}

.reauth-method-segment {
  display: flex;
  width: 100%;
  padding: 3px;
  margin-bottom: 0.75rem;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}
.reauth-method-segment__btn {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.reauth-method-segment__btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.reauth-method-segment__btn.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.reauth-field-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.reauth-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  box-sizing: border-box;
}
.reauth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.25);
}
.reauth-input--totp {
  letter-spacing: 0.25em;
  text-align: center;
}

.reauth-primary-btn {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}
.reauth-primary-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}
.reauth-primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
/* ─── Delete data modal ───────────────────────────────── */
.delete-data-modal { max-width: 480px; }
.delete-data-modal h3 { margin-bottom: 0.5rem; }
.delete-modal-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; line-height: 1.5; }
.delete-export-status {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted); font-size: 0.85rem;
}
.delete-spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: delete-spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes delete-spin { to { transform: rotate(360deg); } }
.delete-export-ready {}
.delete-export-counts {
  padding: 0.75rem 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.82rem;
  color: var(--text-muted); line-height: 1.6;
}
.delete-export-counts strong { color: var(--text); }
.delete-export-error p { color: var(--danger); font-size: 0.85rem; margin-bottom: 0.75rem; }
.delete-confirm-field { margin-top: 0.75rem; }
.delete-confirm-field label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.delete-confirm-field input {
  width: 100%; padding: 0.55rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.9rem; font-family: monospace;
}
.delete-confirm-field input:focus { outline: none; border-color: var(--danger); }
#deleteFinalBtn:disabled { opacity: 0.4; cursor: not-allowed; }
.delete-download-done {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.85rem; background: var(--success-subtle);
  border: 1px solid var(--success); border-radius: var(--radius);
  color: var(--success); font-size: 0.82rem; margin-bottom: 0.75rem;
}
/* ─── Welcome modal ────────────────────────────────────── */
.welcome-modal { max-width: 480px; }
.welcome-modal h2 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.welcome-modal .beta-badge {
  display: inline-block; padding: 0.1rem 0.5rem; background: var(--accent-subtle);
  color: var(--accent); border-radius: 4px; font-size: 0.7rem; font-weight: 600;
  margin-bottom: 0.5rem;
}
.welcome-modal > p { color: var(--text-muted); margin-bottom: 0.75rem; font-size: 0.85rem; }
.welcome-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.welcome-feature {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 0.6rem 0.4rem; background: var(--bg); border-radius: var(--radius);
}
.welcome-feature-icon { font-size: 1.3rem; margin-bottom: 0.25rem; }
.welcome-feature h4 { font-size: 0.8rem; margin-bottom: 0.15rem; }
.welcome-feature p { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0; line-height: 1.3; }
.mcp-url-row {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.6rem 0.75rem; font-family: monospace; font-size: 0.82rem;
  word-break: break-all;
}
.mcp-url-row span { flex: 1; color: var(--accent); }
.mcp-url-row button {
  flex-shrink: 0; background: var(--accent-subtle); color: var(--accent);
  border: none; border-radius: 4px; padding: 0.3rem 0.6rem; font-size: 0.75rem;
  cursor: pointer; font-weight: 600;
}
.mcp-url-row button:hover { background: var(--accent); color: var(--bg); }
.settings-mcp-card { transition: filter 0.2s ease; }
.settings-mcp-card:hover { filter: brightness(1.5); }
.welcome-mcp-url { margin-bottom: 0.5rem; }
.welcome-help-link {
  display: block; text-align: center; font-size: 0.78rem; color: var(--accent);
  margin-bottom: 0.75rem;
}
.show-again-label {
  display: flex; align-items: center; gap: 0.4rem; justify-content: center;
  margin-top: 0.5rem; font-size: 0.72rem; color: var(--text-dim); cursor: pointer;
}
.show-again-label input { accent-color: var(--accent); cursor: pointer; }
@media (max-width: 480px) {
  .welcome-modal { padding: 0.75rem; }
  .welcome-modal h2 { font-size: 1.1rem; }
  .welcome-features { grid-template-columns: 1fr; }
  .welcome-feature { flex-direction: row; text-align: left; padding: 0.4rem 0.5rem; gap: 0.4rem; }
  .welcome-feature-icon { font-size: 1.1rem; margin-bottom: 0; }
}
/* ─── Search overlay ───────────────────────────────────── */
.search-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 200; padding-top: 15vh; align-items: flex-start; justify-content: center;
}
.search-overlay.active { display: flex; }
.search-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 90%; max-width: 600px;
  overflow: hidden; animation: modalSlideIn 0.2s ease;
}
.search-panel input {
  width: 100%; padding: 1rem 1.25rem; background: transparent;
  border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 1.1rem;
}
.search-panel input:focus { outline: none; }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result-item {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.75rem 1.25rem; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result-item:hover { background: var(--surface-hover); }
.search-result-item:last-child { border-bottom: none; }
.search-result-headline { font-size: 0.9rem; font-weight: 500; }
.search-result-snippet { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-meta { display: flex; gap: 0.5rem; align-items: center; }
.search-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.search-hint-text { padding: 0.75rem 1.25rem; font-size: 0.75rem; color: var(--text-dim); }
/* ─── Toast ────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; left: auto; z-index: 300;
  display: flex; flex-direction: column; gap: 0.5rem;
  align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.85rem; min-width: 280px; max-width: 400px;
  animation: toastSlideIn 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast .toast-msg { flex: 1; }
.toast .toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; }
.toast.removing { animation: toastFadeOut 0.2s ease forwards; }
@keyframes toastSlideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastFadeOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }
/* ─── Info tips ─────────────────────────────────────────── */
.info-tip {
  position: relative; display: inline-flex; align-items: center;
  cursor: help; vertical-align: middle;
}
.info-tip-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--text-dim); color: var(--text-dim);
  font-size: 10px; font-weight: 700; font-style: normal;
  line-height: 1; transition: border-color 0.15s, color 0.15s;
  user-select: none;
}
.info-tip:hover .info-tip-icon,
.info-tip:focus-within .info-tip-icon {
  border-color: var(--accent); color: var(--accent);
}
.info-tip-body {
  display: none; position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); z-index: 50;
  width: 280px; padding: 0.65rem 0.8rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  font-size: 0.78rem; line-height: 1.5; color: var(--text-muted);
  font-weight: 400; text-align: left;
}
.info-tip:hover .info-tip-body,
.info-tip:focus-within .info-tip-body { display: block; }
.info-tip-body strong { color: var(--text); font-weight: 600; }
.info-tip-up .info-tip-body {
  top: auto; bottom: calc(100% + 6px);
}
/* ─── Keyboard shortcut help ───────────────────────────── */
.shortcut-help {
  display: none; position: fixed; bottom: 3.5rem; right: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  z-index: 90; font-size: 0.8rem; min-width: 240px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.shortcut-help.visible { display: block; }
.shortcut-help h4 { margin-bottom: 0.5rem; font-size: 0.85rem; }
.shortcut-row { display: flex; justify-content: space-between; padding: 0.2rem 0; }
.shortcut-key { font-family: monospace; background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.75rem; }
/* ─── Loading ──────────────────────────────────────────── */
#loading {
  display: flex; align-items: center; justify-content: center;
  height: 60vh; color: var(--text-muted);
}
/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0.5rem 1rem; }
  .header-search {
    flex: 1;
    min-width: 0;
    max-width: none;
    margin: 0 auto;
  }
  .header-search .search-hint { display: none; }
  .user-greeting { display: none; }
  .tab-content { padding: 1rem; }
  .charts-grid { grid-template-columns: 1fr; }
  .insights-grid { grid-template-columns: 1fr; }
  .knowledge-insights-body { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  #tab-settings { column-count: 1; }
  .detail-panel { width: 100%; right: -100%; }
  .explore-controls { flex-direction: column; align-items: stretch; }
  .graph-container {
    height: calc(100vh - var(--app-header-height, 52px) - var(--tab-bar-height, 46px) - 5.5rem);
    min-height: 280px;
    transition: height var(--tab-bar-reveal-duration) var(--tab-bar-reveal-ease);
  }
  html.dash-tabbar-collapsed .graph-container {
    height: calc(100vh - var(--app-header-height, 52px) - 5.5rem);
  }
  .create-form {
    flex-direction: column;
    align-items: stretch;
  }
  .create-form .btn,
  .create-form .btn-primary {
    width: 100%;
    justify-content: center;
  }
  .mcp-url-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .mcp-url-row button {
    align-self: stretch;
    width: 100%;
    padding: 0.45rem 0.75rem;
  }
  .key-row {
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: flex-start;
  }
  .key-row .btn {
    width: 100%;
    justify-content: center;
  }
  .toast {
    min-width: 0;
    max-width: min(400px, calc(100vw - 2rem));
  }
  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    align-items: stretch;
  }
  .plan-accordion-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .plan-accordion-meta {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }
  .locks-section-head {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
  .locks-section-head #lockCount {
    align-self: flex-start;
  }
  .lock-add-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .lock-add-row button {
    width: 100%;
  }
  .lock-card-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
  .lock-card-head > div:last-child {
    margin-left: 0 !important;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .lock-card-head > div:last-child button {
    flex: 1;
    min-width: 120px;
  }
  .mfa-enroll-layout {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }
  .mfa-enroll-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .mfa-enroll-actions .btn {
    margin-left: 0 !important;
    width: 100%;
  }
  .settings-profile-head {
    flex-direction: column;
    align-items: flex-start !important;
  }
  .data-portability-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .data-portability-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .mfa-factor-row {
    flex-direction: column;
    align-items: stretch;
  }
  .mfa-factor-row .btn {
    width: 100%;
    justify-content: center;
  }
  .mfa-inline-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .mfa-inline-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .data-portability-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .activity-item {
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto;
    align-items: start;
  }
  .activity-dot { grid-column: 1; grid-row: 1; }
  .activity-item .kind-badge { grid-column: 2; grid-row: 1; align-self: center; }
  .activity-time { grid-column: 3; grid-row: 1; justify-self: end; align-self: center; }
  .activity-headline {
    grid-column: 1 / -1;
    grid-row: 2;
    white-space: normal;
  }
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin-top: 0.25rem;
}

.mfa-factor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.mfa-factor-row:last-child { border-bottom: none; }
.mfa-inline-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.method-btn {
  flex: 1;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}
.method-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle, rgba(88,166,255,0.08));
}

/* ── Toggle switch ──────────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border, #333);
  border-radius: 22px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent, #58a6ff);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}
