/* Godly/Apple-dock-inspired: gradient backdrop, rounded card, floating dark dock. */
:root {
  --bg: #0b0b0d;
  --card: #fafafa;
  --card-dark: #0a0a0a;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #ececef;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #0a0a0a;
  --text-dim: #6b6b75;
  --text-faint: #9a9aa3;
  --accent: #0a0a0a;

  --dock-bg: rgba(20, 20, 22, 0.85);
  --dock-border: rgba(255, 255, 255, 0.08);
  --dock-text: #ededf0;
  --dock-text-dim: #a1a1ab;
  --dock-surface: rgba(255, 255, 255, 0.06);
  --dock-active: rgba(255, 255, 255, 0.14);

  --core: #ff7b6b;
  --long: #7eb6ff;
  --visitor: #c89bff;
  --other: #888;
  --green: #30d158;

  --radius: 24px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Geist", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: #fdfdfd;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}

/* (gradient backdrop removed) */

/* ========== Main app surface (full-bleed, no outer chrome) ========== */
.app-card {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  background: #fdfdfd;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#graph {
  position: relative;
  flex: 1;
  min-height: 0; /* allow flex child to shrink so canvas gets real size */
  background: #fdfdfd;
}
#graph > div { width: 100% !important; height: 100% !important; }
#globe {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #0a0a0a;
}
#globe canvas { display: block; }

.globe-marker {
  position: relative;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease;
}
.globe-marker:hover { transform: translate(-50%, -50%) scale(1.18); z-index: 10; }
.globe-marker img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  object-fit: cover;
  background: #1a1a1a;
  display: block;
}
.globe-marker .badge {
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  background: #ff5e3a;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  font-family: "Geist Mono", ui-monospace, monospace;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  border: 1.5px solid #0a0a0a;
}
.vis-tooltip { display: none !important; }

/* ========== Top minimal bar ========== */
.top-bar {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 20;
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.brand-pill .status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}
.brand-pill .logo {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0a0a0a;
  flex-shrink: 0;
}
.brand-pill .name { line-height: 1; }

.search-overlay {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  width: min(520px, calc(100% - 48px));
  color: var(--text-dim);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  z-index: 25;
  overflow: hidden;
}
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 10px 16px;
}
.search-results {
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: 6px;
}
.search-results .sr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s ease;
}
.search-results .sr-item:hover { background: var(--surface-2); }
.search-results .sr-item img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-3);
}
.search-results .sr-item .sr-info { flex: 1; min-width: 0; }
.search-results .sr-item .sr-name { font-weight: 500; font-size: 13px; color: var(--text); }
.search-results .sr-item .sr-meta { font-size: 11px; color: var(--text-dim); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .sr-empty { padding: 14px; color: var(--text-dim); font-size: 12px; text-align: center; }
.search-results .sr-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 8px 12px 4px;
}
.search-results .sr-loading { padding: 8px 12px; color: var(--text-dim); font-size: 12px; }
.search-results .sr-tag {
  display: inline-block;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 5px;
}
.search-overlay input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  padding: 4px 0;
  letter-spacing: -0.005em;
}
.search-overlay input::placeholder { color: var(--text-faint); }
.search-overlay kbd {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  line-height: 1;
}

.search-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.search-btn:hover { background: var(--surface-2); color: var(--text); }

/* ========== Minimal dock (2 icons) ========== */
.dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--dock-bg);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--dock-border);
  border-radius: 14px;
  padding: 6px;
  z-index: 20;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
.tool {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--dock-text-dim);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  position: relative;
}
.tool:hover { background: var(--dock-surface); color: var(--dock-text); }
.tool.active { background: var(--dock-active); color: var(--dock-text); }
.tool:active { transform: scale(0.92); }
.tool[title]:hover::before {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 22, 0.95);
  color: var(--dock-text);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid var(--dock-border);
}

/* tiny stats badge corner */
.stats-badge {
  position: absolute;
  bottom: 30px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-faint);
  z-index: 15;
  pointer-events: none;
  letter-spacing: -0.01em;
}
.stats-badge .dot-sep { color: var(--text-faint); margin: 0 2px; }
.stats-badge .lbl { color: var(--text-faint); margin-left: 2px; }

/* ========== Popover (anchored above dock) ========== */
.popover {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 22, 0.94);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--dock-border);
  border-radius: 14px;
  padding: 16px;
  width: 400px;
  max-width: calc(100vw - 48px);
  z-index: 25;
  color: var(--dock-text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  animation: popIn 0.18s cubic-bezier(0.2, 0, 0, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.popover h4 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dock-text-dim);
  font-weight: 600;
}
.popover .seg {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--dock-border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.popover .seg button {
  flex: 1;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--dock-text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.popover .seg button:hover { color: var(--dock-text); }
.popover .seg button.active { background: rgba(255, 255, 255, 0.12); color: var(--dock-text); }
.filter-text-row { position: relative; }
.suggest-wrap { position: relative; }
.filter-text {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--dock-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--dock-text);
  font: inherit;
  font-size: 13px;
  outline: 0;
  transition: border-color 0.12s ease;
}
.filter-text:focus { border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.06); }
.filter-text::placeholder { color: var(--dock-text-dim); opacity: 0.6; }
.suggest-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(20, 20, 22, 0.96);
  border: 1px solid var(--dock-border);
  border-radius: 8px;
  padding: 4px;
  z-index: 30;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.suggest-item {
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--dock-text-dim);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
}
.suggest-item:hover { background: rgba(255, 255, 255, 0.08); color: var(--dock-text); }

.popover-h4 {
  margin: 0 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dock-text-dim);
  font-weight: 600;
}

/* Multi-select chip + searchable list */
.multi-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--dock-border);
  border-radius: 8px;
  padding: 6px;
}
.ms-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--dock-border);
}
.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--dock-text);
  font-size: 11px;
  padding: 3px 4px 3px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.ms-chip .ms-x {
  background: transparent;
  border: 0;
  color: var(--dock-text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ms-chip .ms-x:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.ms-search {
  flex: 1;
  min-width: 100px;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--dock-text);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
}
.ms-search::placeholder { color: var(--dock-text-dim); opacity: 0.6; }
.ms-list {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 4px;
}
.ms-row {
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--dock-text-dim);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
}
.ms-row:hover { background: rgba(255, 255, 255, 0.08); color: var(--dock-text); }
.ms-empty { padding: 8px; color: var(--dock-text-dim); font-size: 11px; text-align: center; }

.popover .smart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 8px;
}
.popover .smart-row .label { font-size: 13px; font-weight: 500; flex: 1; }
.popover .smart-row .desc { font-size: 11px; color: var(--dock-text-dim); margin-top: 2px; line-height: 1.45; }
.popover .smart-info { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--dock-border); display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--dock-text-dim); }
.popover .smart-info .info-row { display: flex; align-items: center; gap: 8px; }
.popover .smart-info .info-icon { color: var(--dock-text); font-size: 12px; opacity: 0.6; width: 14px; }
.popover .progress-wrap { margin-top: 10px; }
.popover .progress-bar { height: 3px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden; }
.popover .progress-bar .fill { height: 100%; background: var(--dock-text); transition: width 0.3s ease; }
.popover .progress-text {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--dock-text-dim);
  margin-top: 6px;
}

/* iOS-style toggle */
.ios-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.ios-toggle input { display: none; }
.ios-toggle .track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  transition: background 0.2s ease;
  cursor: pointer;
}
.ios-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.ios-toggle input:checked ~ .track { background: var(--green); }
.ios-toggle input:checked ~ .track .knob { left: 20px; }

/* ========== Custom tooltip ========== */
#tooltip {
  position: fixed;
  background: rgba(20, 20, 22, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  pointer-events: none;
  z-index: 50;
  display: none;
  min-width: 180px;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: #ededf0;
}
#tooltip.show { display: block; }
#tooltip .name { font-weight: 600; font-size: 13px; }
#tooltip .username { color: var(--dock-text-dim); font-size: 11px; margin-top: 1px; }
#tooltip .meta { color: var(--dock-text-dim); font-size: 11px; margin-top: 6px; line-height: 1.5; }
#tooltip .pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  text-transform: capitalize;
  margin-top: 6px;
}

/* The `hidden` attribute must always win over flex/grid display. */
[hidden] { display: none !important; }

/* ========== Stacked profile panels ========== */
.panel-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 30;
  pointer-events: none;
}
.panel-stack > * { pointer-events: auto; }
.panel-card {
  position: relative;
  width: 380px;
  height: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  animation: slideIn 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.panel-card .panel-loading { flex: 1; padding: 28px 24px; overflow-y: auto; }
.panel-card .panel-content { overflow-y: auto; padding: 28px 24px 24px; }
.panel-card .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.panel-card .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.panel-card .close-btn { position: absolute; top: 12px; right: 12px; z-index: 2; }

@media (max-width: 720px) {
  .panel-stack {
    top: 8px; left: 8px; right: 8px; bottom: 8px;
    gap: 0;
  }
  .panel-card { width: 100% !important; }
  /* Mobile: only show topmost (newest) card. Older ones fade behind. */
  .panel-card:not(:last-child) { display: none; }
}

/* legacy single-panel selector (kept for old refs) */
#panel {
  position: fixed;
  top: 32px;
  right: 32px;
  bottom: 32px;
  width: 380px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s cubic-bezier(0.2, 0, 0, 1);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
#panel .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
#panel .icon-btn:hover { background: var(--surface-2); color: var(--text); }
#panel .close-btn { position: absolute; top: 14px; right: 14px; z-index: 2; }
#panel .back-btn { position: absolute; top: 14px; left: 14px; z-index: 2; }
#panelLoading { flex: 1; padding: 28px 24px; overflow-y: auto; }
#panelContent { overflow-y: auto; padding: 28px 24px 24px; }

/* ========== Profile content ========== */
.profile-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  background: var(--surface-2);
  transition: transform 0.12s ease;
}
.profile-img:hover { transform: scale(1.04); }

/* HD lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: zoom-out;
  animation: fadeIn 0.18s ease;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.lightbox .lb-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.lightbox .lb-close:hover { background: rgba(255, 255, 255, 0.2); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.profile-name {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}
.profile-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.profile-sub .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}
.profile-bio {
  margin-top: 14px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.profile-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.profile-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.profile-links a:hover { background: var(--text); color: #fff; border-color: var(--text); transform: translateY(-1px); }
.profile-links a:active { transform: translateY(0); }

.section { margin-top: 24px; }
.section h3 {
  margin: 0 0 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
}

.meta-grid { display: grid; grid-template-columns: 80px 1fr; gap: 6px 14px; font-size: 12.5px; }
.meta-grid b { color: var(--text-dim); font-weight: 400; font-size: 12px; }

.exp-item {
  border-left: 1px solid var(--border);
  padding: 0 0 16px 14px;
  position: relative;
  font-size: 12.5px;
}
.exp-item::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text);
}
.exp-item .title { font-weight: 600; }
.exp-item .co { color: var(--text-dim); }
.exp-item .when { color: var(--text-faint); font-size: 11px; font-family: "Geist Mono", ui-monospace, monospace; margin: 2px 0 6px; }
.exp-item .desc { white-space: pre-wrap; color: var(--text-dim); font-size: 12px; line-height: 1.55; }

.match-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
}
.match-item:hover { background: var(--surface-2); }
.match-item img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-3); }
.match-item .info { flex: 1; min-width: 0; }
.match-item .info .name { font-weight: 500; font-size: 13px; line-height: 1.2; }
.match-item .info .reasons {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 3px;
  line-height: 1.4;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-item .score {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-3);
  padding: 4px 8px;
  border-radius: 999px;
  letter-spacing: -0.02em;
}

/* ========== Graph loading overlay (shimmer) ========== */
#graphLoading {
  position: absolute;
  inset: 0;
  background: #fdfdfd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: opacity 0.4s ease;
  overflow: hidden;
}
#graphLoading.hidden { opacity: 0; pointer-events: none; }

.loader-status {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.loader-text {
  transition: opacity 0.25s ease, transform 0.25s ease;
  will-change: opacity, transform;
}
.loader-text.fading {
  opacity: 0;
  transform: translateY(-4px);
}
.loader-text {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.loader-hint { color: var(--text-faint); font-size: 11px; }
.loader-hint kbd {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin: 0 2px;
  color: var(--text-dim);
}

/* ========== Shimmer ========== */
@keyframes shimmer {
  0% { background-position: -240px 0; }
  100% { background-position: calc(240px + 100%) 0; }
}
.sk {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 240px 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
.sk-avatar { width: 80px; height: 80px; border-radius: 50%; margin-bottom: 16px; }
.sk-line { height: 11px; margin-bottom: 10px; }
.sk-line.w-30 { width: 30%; }
.sk-line.w-40 { width: 40%; }
.sk-line.w-50 { width: 50%; }
.sk-line.w-60 { width: 60%; }
.sk-line.w-70 { width: 70%; }
.sk-line.w-80 { width: 80%; }
.sk-line.w-90 { width: 90%; }
.sk-section { margin-top: 24px; }

/* ========== Responsive (mobile-first patterns) ========== */
@media (max-width: 720px) {
  body { font-size: 13px; }
  .app-card {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .top-bar { padding: 0 12px; top: 12px; }
  .brand-pill { font-size: 12px; padding: 5px 10px 5px 6px; }
  .search-overlay { width: calc(100vw - 24px); }
  .search-btn { width: 30px; height: 30px; }

  /* Popover becomes a bottom sheet on mobile. */
  .popover {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding: 24px 16px max(20px, env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow-y: auto;
    box-sizing: border-box;
    animation: sheetUp 0.22s cubic-bezier(0.2, 0, 0, 1);
  }
  .popover::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 2px;
  }
  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .popover .seg button { padding: 11px 8px; font-size: 12.5px; }
  .popover .seg { flex-wrap: wrap; }
  .multi-select { box-sizing: border-box; max-width: 100%; }
  .ms-list { max-height: 140px; }
  .search-overlay {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
  }
  .search-results { max-height: 50vh; }

  /* Profile panel = full-screen sheet on mobile. */
  #panel {
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    border-radius: 0;
    animation: slideUpFull 0.22s cubic-bezier(0.2, 0, 0, 1);
  }
  @keyframes slideUpFull {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .dock {
    bottom: max(16px, env(safe-area-inset-bottom));
    padding: 5px;
  }
  .tool { width: 42px; height: 42px; }

  .stats-badge { display: none; }

  /* Boot loader spans the screen now. */
  #graphLoading { background: #fdfdfd; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
