:root {
  /* Purple & Modern Palette */
  --primary-color: #a80dcbd6;
  --primary-hover: #a30dc1d6;
  --secondary-color: #b388ff;
  --accent-color: #00e5ff;
  --background-color: #f3f4f6;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --card-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.9);
  --glass-border: 1px solid rgba(0, 0, 0, 0.05);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --border-radius: 12px;
}

[data-theme="dark"] {
  --background-color: #121212;
  --text-color: #e0e0e0;
  --text-muted: #a0a0a0;
  --card-bg: #1e1e1e;
  --header-bg: rgba(30, 30, 30, 0.9);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);

  /* Adjusted for Dark Mode */
  --primary-color: #ce58e8d6;
  /* Brighter purple for dark bg */
  --secondary-color: #d1c4e9;
}

body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* Navbar */
nav.custom-navbar {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  padding: 0.8rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: var(--glass-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

nav.custom-navbar .brand a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

nav.custom-navbar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.5rem;
}

nav.custom-navbar a.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

nav.custom-navbar a.nav-link:hover {
  color: var(--primary-color);
}

/* Layout */
.container {
  max-width: 1400px;
  /* Use more screen space */
  width: 90%;
  margin: 2rem auto;
}

h1,
h2,
h3,
h4 {
  font-family: 'Inter', sans-serif;
  color: #111;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

/* Components */
.btn-primary {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--text-color);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #d1d5db;
}

/* Environment Selector Card (Compact) */
.env-selector-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.env-input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.env-input-group input {
  flex-grow: 1;
  padding: 0.6rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.env-input-group input:focus {
  border-color: var(--primary-color);
}

.env-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.env-tag {
  background: #f3e8ff;
  /* Light purple tag */
  color: var(--primary-color);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.env-tag:hover {
  background: #e9d5ff;
}

.env-tag .remove {
  font-size: 1.1em;
  opacity: 0.6;
}

.env-tag .remove:hover {
  opacity: 1;
}

/* Masonry Layout for Index */
.query-grid {
  column-count: 3;
  column-gap: 1.5rem;
  margin-top: 2rem;
}

@media (max-width: 1024px) {
  .query-grid {
    column-count: 2;
  }
}

@media (max-width: 768px) {
  .query-grid {
    column-count: 1;
  }
}


.query-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s;
  break-inside: avoid;
  /* Prevent split across columns */
  margin-bottom: 1.5rem;
  /* Vertical spacing for masonry */
  /* height: 100%; removed to fit content */
}

.query-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.query-card h4 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  line-height: 1.4;
}

.query-card h4 a {
  text-decoration: none;
  color: var(--text-color);
}

.query-card h4 a:hover {
  color: var(--primary-color);
}

.query-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1rem;
}

/* Tabs */
.custom-tabs {
  margin-top: 2rem;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.tab-headers {
  display: flex;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.tab-header {
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab-header:hover {
  color: var(--primary-color);
  background: #f3f4f6;
}

.tab-header.active {
  color: var(--primary-color);
  background: white;
  border-bottom-color: var(--primary-color);
}

.tab-content {
  display: none;
  padding: 0;
}

.tab-content.active {
  display: block;
}

/* Code Blocks */
.code-container {
  position: relative;
  background: #282c34;
  /* Atom One Dark BG */
}

.code-container pre {
  margin: 0;
  padding: 1.5rem;
  overflow: auto;
  max-height: 800px;
  /* Guard against huge files */
}

.code-container code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.copy-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
  opacity: 0;
  z-index: 10;
}

.code-container:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

/* Footer */
footer {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4rem;
}

footer a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .query-grid {
    grid-template-columns: 1fr;
  }
}