/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #0d0f1a;
  --bg2: #151728;
  --card: #1c1f35;
  --card2: #232644;
  --border: #2e3255;
  --text: #dde1f0;
  --muted: #7b82a8;
  --accent: #8b5cf6;
  --accent2: #ec4899;
  --accent3: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.nav-brand:hover { text-decoration: none; }
.paw { font-size: 1.3rem; }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-link { color: var(--muted); font-size: .92rem; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.btn-nav {
  background: var(--accent);
  color: #fff !important;
  padding: .35rem .9rem;
  border-radius: 6px;
  font-size: .88rem;
  font-weight: 600;
}
.btn-nav:hover { background: #7c4fe6; text-decoration: none; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1.1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: filter .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.15); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; border-radius: 6px; }

.icon-btn {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--card); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.required { color: var(--danger); }
.optional { color: var(--muted); font-weight: 400; font-size: .8rem; text-transform: none; letter-spacing: 0; }
.input-field {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .85rem;
  color: var(--text);
  font-size: .95rem;
  transition: border-color .15s;
}
.input-field:focus { outline: none; border-color: var(--accent); }
.input-error { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: .82rem; margin-top: .3rem; }
.field-hint { color: var(--muted); font-size: .82rem; margin-top: .35rem; }
.input-row { display: flex; gap: .5rem; }

/* ── Discord ID help block ──────────────────────────────────────────────── */
.id-help {
  margin-top: .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .82rem;
}
.id-help summary {
  padding: .45rem .7rem;
  cursor: pointer;
  color: var(--accent);
  user-select: none;
  list-style: none;
}
.id-help summary::-webkit-details-marker { display: none; }
.id-help summary::before { content: "▶ "; font-size: .7rem; }
.id-help[open] summary::before { content: "▼ "; }
.id-help-steps {
  margin: .4rem .7rem .6rem 1.8rem;
  padding: 0;
  color: var(--text);
  line-height: 1.7;
}
.id-help-steps li { margin-bottom: .55rem; }
.id-help-steps strong { color: var(--text); }
.id-help-steps em { color: var(--muted); font-style: normal; background: rgba(255,255,255,.06); padding: .05rem .3rem; border-radius: 4px; }
.id-help-note {
  margin: 0 .7rem .6rem;
  color: var(--muted);
  font-size: .78rem;
}
.input-row .input-field { flex: 1; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: .92rem;
}
.alert-success { background: rgba(16,185,129,.15); border: 1px solid var(--success); color: #6ee7b7; }
.alert-info { background: rgba(59,130,246,.15); border: 1px solid var(--accent3); color: #93c5fd; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.badge-registered { background: rgba(16,185,129,.2); color: #6ee7b7; }
.badge-stub { background: rgba(245,158,11,.2); color: #fcd34d; }
.badge-hidden { background: rgba(107,114,128,.2); color: #9ca3af; }
.badge-merged { background: rgba(239,68,68,.2); color: #fca5a5; }

/* ── Avatars ───────────────────────────────────────────────────────────────── */
.avatar-wrap { flex-shrink: 0; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: .9rem;
  color: rgba(255,255,255,.9);
  width: 44px;
  height: 44px;
}
.avatar-lg.avatar-placeholder { width: 72px; height: 72px; font-size: 1.4rem; }

/* ── Person list / cards ───────────────────────────────────────────────────── */
.person-list { display: flex; flex-direction: column; gap: .5rem; }
.person-card {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .9rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-decoration: none;
  color: var(--text);
}
.person-card:hover { border-color: var(--accent); background: var(--card); text-decoration: none; color: var(--text); }
.person-info { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.person-name { font-weight: 600; }
.person-meta { font-size: .82rem; color: var(--muted); }

/* ── Profile ───────────────────────────────────────────────────────────────── */
.profile-card {}
.profile-header { display: flex; align-items: flex-start; gap: 1.25rem; margin-bottom: 1.5rem; }
.profile-info { flex: 1; }
.profile-name { font-size: 1.5rem; font-weight: 800; display: flex; align-items: center; gap: .5rem; }
.crown { font-size: 1.2rem; }
.profile-section { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.profile-section h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .75rem; }
.rel-row { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.rel-label { color: var(--muted); font-size: .88rem; white-space: nowrap; padding-top: .05rem; }
.rel-person { font-weight: 600; color: var(--accent); }
.rel-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.rel-chip {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .15rem .65rem;
  font-size: .82rem;
  color: var(--text);
}
.rel-chip:hover { border-color: var(--accent); text-decoration: none; }

/* ── Edit page ─────────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.page-title { font-size: 1.6rem; font-weight: 800; }
.current-rel {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem;
  background: var(--bg2);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: .5rem;
}
.selected-person {
  margin-top: .5rem;
  padding: .5rem .75rem;
  background: rgba(139,92,246,.15);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: .88rem;
  color: #c4b5fd;
}

/* ── Search dropdown ───────────────────────────────────────────────────────── */
.search-combo { position: relative; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
  display: none;
  box-shadow: var(--shadow);
}
.search-dropdown.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .9rem;
  cursor: pointer;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--card2); }
.dropdown-item .dn { flex: 1; font-weight: 600; }
.dropdown-item .dm { color: var(--muted); font-size: .82rem; }
.dropdown-stub { color: var(--accent); font-style: italic; }
.hidden { display: none !important; }

/* ── Graph page ────────────────────────────────────────────────────────────── */
.graph-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 53px);
}
.graph-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1.25rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.rel-toggle { display: flex; gap: .4rem; }
.toggle-btn {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .35rem .85rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all .15s;
}
.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.search-wrap { position: relative; flex: 1; max-width: 320px; }
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .35rem .9rem .35rem 2rem;
  color: var(--text);
  font-size: .88rem;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: .55rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .8rem;
  pointer-events: none;
}
.graph-actions { display: flex; gap: .4rem; margin-left: auto; }
.graph-main { flex: 1; position: relative; overflow: hidden; }
.cy-container { width: 100%; height: 100%; background: var(--bg); }

/* ── Detail panel ──────────────────────────────────────────────────────────── */
.detail-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  background: var(--card);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem;
  z-index: 50;
  box-shadow: -4px 0 20px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
.detail-panel.hidden { transform: translateX(100%); display: block !important; }
.panel-close {
  position: absolute;
  top: .75rem; right: .75rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.panel-close:hover { color: var(--text); }
.detail-avatar { margin: .5rem 0 1rem; }
.detail-name { font-size: 1.2rem; font-weight: 800; margin-bottom: .25rem; }
.detail-meta { color: var(--muted); font-size: .85rem; margin-bottom: .75rem; }
.detail-section { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.detail-section h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .5rem; }
.detail-link {
  display: block;
  margin-top: .5rem;
  font-size: .85rem;
  color: var(--accent);
}

/* ── Stats bar ─────────────────────────────────────────────────────────────── */
.stats-bar {
  flex-shrink: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
.stats-toggle {
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  padding: .5rem 1.25rem;
  text-align: left;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
}
.stats-toggle:hover { color: var(--text); }
.stats-content {
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}
.stat-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
}
.stat-block h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .4rem; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.stat-sub { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.stat-list { list-style: none; margin-top: .4rem; }
.stat-list li { font-size: .82rem; padding: .15rem 0; border-bottom: 1px solid var(--border); }
.stat-list li:last-child { border-bottom: none; }

/* ── Container ─────────────────────────────────────────────────────────────── */
.container { padding: 0 1.25rem; }
.text-muted { color: var(--muted); }
.info-box { background: rgba(59,130,246,.1); border-color: var(--accent3); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .detail-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); top: auto; height: 60%; }
  .graph-controls { flex-wrap: wrap; }
  .search-wrap { max-width: 100%; flex-basis: 100%; }
  .stats-content { grid-template-columns: 1fr 1fr; }
}
