*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f1419;
  color: #e7ecf3;
}

/* ── Desktop layout ─────────────────────────────────────────── */

#mobile-topbar {
  display: none;
}

#app {
  display: flex;
  height: 100vh;
}

#sidebar-backdrop {
  display: none;
}

#sidebar {
  width: 320px;
  min-width: 280px;
  padding: 1.25rem;
  border-right: 1px solid #243041;
  background: #151b23;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 100;
}

#sidebar h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.subtitle {
  margin: 0 0 1.25rem;
  color: #8b98a9;
  font-size: 0.9rem;
}

#sidebar h2 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8b98a9;
}

/* ── Search ─────────────────────────────────────────────────── */

#search-section {
  position: relative;
  margin-bottom: 1.5rem;
}

#search-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: #1e2935;
  border: 1px solid #2e3d4f;
  border-radius: 8px;
  color: #e7ecf3;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

#search-input::placeholder {
  color: #5a6a7a;
}

#search-input:focus {
  border-color: #5b9cf5;
}

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: #1e2935;
  border: 1px solid #2e3d4f;
  border-radius: 8px;
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#search-results.hidden {
  display: none;
}

.search-result {
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: background 0.1s;
}

.search-result:hover,
.search-result:focus {
  background: #263344;
}

/* ── Edge filters ───────────────────────────────────────────── */

#edge-filters {
  margin-bottom: 1.5rem;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  min-height: 32px;
}

.filter-item input {
  accent-color: #5b9cf5;
}

.filter-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Detail panel ───────────────────────────────────────────── */

#detail-panel.hidden {
  display: none;
}

#empty-detail {
  color: #8b98a9;
  font-size: 0.95rem;
}

#empty-detail.hidden {
  display: none;
}

.detail-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.75rem;
  border: 2px solid #243041;
  background: #243041;
  display: block;
}

.detail-initials {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #3d4f63;
  border: 2px solid #243041;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: bold;
  color: #e7ecf3;
  margin-bottom: 0.75rem;
}

.detail-name {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.detail-row {
  margin-bottom: 0.65rem;
}

.detail-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b98a9;
  margin-bottom: 0.15rem;
}

.detail-value {
  font-size: 0.95rem;
}

/* ── Graph container ────────────────────────────────────────── */

#graph-container {
  flex: 1;
  min-width: 0;
  background: #0f1419;
}

#graph-container .loading,
#graph-container .error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #8b98a9;
}

#graph-container .error {
  color: #f87171;
}

/* ── Mobile ─────────────────────────────────────────────────── */

@media (max-width: 768px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  #mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    height: 52px;
    background: #151b23;
    border-bottom: 1px solid #243041;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    flex-shrink: 0;
  }

  #mobile-topbar button {
    background: none;
    border: none;
    color: #e7ecf3;
    font-size: 1.35rem;
    padding: 0.5rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
  }

  #mobile-topbar button:hover {
    background: #1e2935;
  }

  #mobile-title {
    font-weight: 600;
    font-size: 1rem;
  }

  #app {
    height: 100vh;
    padding-top: 52px;
  }

  #sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 150;
  }

  #sidebar-backdrop.hidden {
    display: none;
  }

  #sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 88vw;
    max-width: 320px;
    min-width: unset;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    z-index: 200;
    overflow-y: auto;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-header {
    display: none;
  }

  #graph-container {
    width: 100%;
  }

  .filter-item {
    min-height: 44px;
  }

  .search-result {
    min-height: 44px;
  }
}
