:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2563eb;
  --ring: rgba(37, 99, 235, 0.25);
}

:root.dark {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --brand: #ffffff;
  --ring: rgba(59, 130, 246, 0.4);
}

* {
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans";
  color: var(--text);
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 12px;
}

.nav {
  max-width: 1100px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  position: relative;
  justify-content: space-between;
}

.logo {
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: 0.3px;
  color: var(--brand);
  text-decoration: none;
}

.logo span {
  opacity: 0.7;
}

/* Controls */
.themeToggle, .hamburger, .closeBtn {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid #e5e7eb;
  font-size: 1rem;
}

.dark .themeToggle, .dark .hamburger, .dark .closeBtn {
  border-color: #334155;
}

.hamburger {
  display: none;
  font-size: 1.2rem;
}

.dark .hamburger {
  color: #fff;
}

.closeBtn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
}

/* Content and right column */
.content {
  flex: 1;
  background: var(--card);
  padding: 22px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

.dark .content {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Original Sidebar */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  position: relative;
  align-self: flex-start;
  background: var(--card);
  padding: 18px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
}

.dark .sidebar {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.sidebar h3 {
  margin-top: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.sidebar li a {
  color: var(--text);
  text-decoration: none;
}

.sidebar li a:hover {
  color: #2563eb;
  text-decoration: none;
}

/* Main layout */
.wrap {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* Extra Sidebar */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 300px;
  align-self: flex-start; /* ensures sticky works */
  height: auto; /* ya max-content */
}

.extra-sidebar {
  position: sticky;
  top: 80px;
}


@media (min-width: 992px) {
  .extra-sidebar {
    display: block;
    position:sticky;
    top: 80px; /* height of header */
    background: var(--card);
    padding: 18px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    width: 300px;
  }

  .dark .extra-sidebar {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }

  .extra-sidebar h3 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--text);
  }

  .extra-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .extra-sidebar li {
    margin-bottom: 12px;
    font-size: 0.95rem;
  }

  .extra-sidebar li a {
    color: var(--text);
    text-decoration: none;
  }

  .extra-sidebar li a:hover {
    color: #2563eb;
    text-decoration: none;
  }
}

@media (max-width: 991px) {
  .extra-sidebar {
    display: none !important;
  }
}

/* Grid Cards */
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .grid-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Card styling */
.card {
  background: var(--card);
  border: 1px solid #eef0f4;
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 6px 18px rgba(28, 32, 38, 0.06);
  transition: .22s transform, .22s box-shadow;
  min-height: 120px;
}

.dark .card {
  border-color: #334155;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(28, 32, 38, 0.1);
}

.dark .card:hover {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.6);
}

.emoji {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  border-radius: 10px;
}

.title {
  font-weight: 600;
  text-align: center;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  min-height: 28px;
}

.dark .subtitle {
  color: var(--muted);
}

/* Headings and paragraphs */
h1, h2, h3 {
  margin: 16px 0;
}

h1 { font-size: 2rem; line-height: 1.4; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.2rem; line-height: 1.2; }

p, li { line-height: 1.7; margin-bottom: 12px; }
ul { margin-left: 20px; }

/* Alphabetical search */
.alpha-search {
  margin: 20px 0;
  padding: 16px;
  background: var(--card);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  order: -1;
}

.alpha-search h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: var(--text);
}

.name-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
  margin-bottom: 10px;
  background: var(--bg);
  color: var(--text);
}

.search-btn {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 16px;
}

.search-btn:hover {
  opacity: 0.9;
}

/* Results */
.results { margin-top: 10px; }

.result-item {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
}

.result-item strong { color: var(--brand); }

#results.protected {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Pagination */
.pagination {
  display: none;
  justify-content: space-between;
  margin-top: 12px;
}

.pagination button {
  display: inline-block;
  flex: 1;
  margin: 0 4px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.pagination button:hover { opacity: 0.9; }

.dark .pagination button {
  background: var(--brand);
  color: #fff;
  border: none;
}

/* FAQ */
.faq { margin-top: 30px; }

.faq-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.dark .faq-item { border-bottom: 1px solid #334155; }

.faq-item h3 { margin-bottom: 10px; color: var(--brand); }
.faq-item p { margin-bottom: 0; }

/* Mobile/Tablet adjustments */
@media (max-width: 768px) {
  .wrap { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 240px;
    height: 100%;
    z-index: 20;
    padding: 18px;
    display: block;
    border-radius: 0;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.active { left: 0; }

  .nav { display: flex; align-items: center; width: 100%; position: relative; }
  .nav-controls { margin-left: auto; display: flex; align-items: center; gap: 8px; }
  .themeToggle { order: 1; }
  .hamburger { order: 2; display: block; }
  .closeBtn { display: block; color: red; }
  .logo { font-size: 1.5rem; }
}

/* Overlay */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 15;
}

.overlay.active { display: block; }

/* Charts */
.chart-wrapper { width: 100%; max-width: 600px; margin: 0 auto; }

#nameChart { width: 100% !important; height: auto !important; }

/* Dark mode fixes for buttons */
html.dark .search-btn,
html.dark .pagination button {
  background: #2563eb !important;
  color: #ffffff !important;
  border: none !important;
}

html.dark .search-btn:hover,
html.dark .pagination button:hover {
  opacity: 0.9 !important;
}

/* Responsive images */
.responsive-img { max-width: 1280px !important; width: 100% !important; height: auto !important; }

@media (max-width: 1024px) { .responsive-img { max-width: 672px; } }
@media (max-width: 600px) { .responsive-img { max-width: 336px; } }

/* Footer */
footer {
  margin-top: 30px;
  border-top: 1px solid #e9edf3;
  background: var(--card);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.dark footer { border-color: #334155; }

footer a {
  color: var(--text);
  text-decoration: none;
  margin: 0 4px;
}

footer a:hover {
  color: var(--brand);
  text-decoration: none;
}
