:root {
  --ref-card-bg: rgba(255, 255, 255, 0.9);
  --ref-card-border: rgba(124, 58, 237, 0.15);
  --ref-gradient: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(59, 130, 246, 0.1));
}

.ref-labs-hero {
  background: var(--ref-gradient);
  border-radius: var(--radius-lg, 18px);
  padding: 2.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ref-labs-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin: 0;
}

.ref-labs-hero p {
  color: var(--text-secondary);
  max-width: 720px;
}

.ref-labs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.ref-meta-chip {
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #4c1d95;
  box-shadow: 0 5px 18px rgba(79, 70, 229, 0.15);
}

.ref-labs-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.ref-filter-btn {
  border: 1px solid var(--ref-card-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b21a8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ref-filter-btn.active,
.ref-filter-btn:hover {
  background: #6d28d9;
  color: #fff;
  border-color: #6d28d9;
}

.ref-labs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.ref-lab-card {
  background: var(--ref-card-bg);
  border-radius: 20px;
  border: 1px solid var(--ref-card-border);
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(79, 70, 229, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.ref-lab-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(124, 58, 237, 0.15), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ref-lab-card:hover::after {
  opacity: 1;
}

.ref-lab-icon {
  font-size: 2rem;
  width: 3.5rem;
  height: 3.5rem;
  background: rgba(124, 58, 237, 0.12);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-lab-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.ref-lab-description {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.95rem;
}

.ref-lab-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.ref-tag {
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  background: rgba(79, 70, 229, 0.08);
  color: #4338ca;
  text-transform: capitalize;
}

.ref-difficulty[data-level="beginner"] {
  background: rgba(74, 222, 128, 0.15);
  color: #15803d;
}

.ref-difficulty[data-level="intermediate"] {
  background: rgba(251, 191, 36, 0.2);
  color: #b45309;
}

.ref-difficulty[data-level="advanced"] {
  background: rgba(248, 113, 113, 0.2);
  color: #b91c1c;
}

.ref-card-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

.ref-card-actions button,
.ref-card-actions a {
  flex: 1;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  pointer-events: auto !important;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 1;
  text-align: center;
}

.ref-card-actions a.primary {
  background: #6d28d9;
  color: #fff;
  box-shadow: 0 10px 30px rgba(109, 40, 217, 0.2);
}

.ref-card-actions button.primary,
.ref-card-actions a.primary {
  background: #6d28d9;
  color: #fff;
  box-shadow: 0 10px 30px rgba(109, 40, 217, 0.2);
}

.ref-card-actions a.secondary {
  background: rgba(99, 102, 241, 0.12);
  color: #312e81;
}

.ref-card-actions button.secondary,
.ref-card-actions a.secondary {
  background: rgba(99, 102, 241, 0.12);
  color: #312e81;
}

.ref-card-actions button:hover,
.ref-card-actions a:hover {
  transform: translateY(-2px);
}

.ref-lab-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ref-lab-modal.show {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.ref-modal-content {
  background: #0f172a;
  color: #fff;
  border-radius: 24px;
  width: min(1100px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(15, 23, 42, 0.6);
}

.ref-modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.ref-modal-title {
  font-size: 1.3rem;
  margin: 0;
}

.ref-modal-tabs {
  display: flex;
  gap: 0.75rem;
}

.ref-tab-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.ref-tab-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.4);
  color: #6d28d9;
}

.ref-tab-btn.active {
  background: #8b5cf6;
  color: #fff;
  border-color: #8b5cf6;
}

.ref-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 2rem 2rem;
  flex: 1;
  overflow: hidden;
}

.ref-tab-panel {
  display: none;
  height: 100%;
}

.ref-tab-panel.active {
  display: block;
}

#refLabPreview {
  width: 100%;
  height: 65vh;
  border: none;
  border-radius: 16px;
  background: #fff;
}

.ref-code-tabs {
  display: inline-flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.ref-code-tab-btn {
  padding: 0.35rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  color: #cbd5f5;
  cursor: pointer;
  font-size: 0.85rem;
}

.ref-code-tab-btn.active {
  background: rgba(139, 92, 246, 0.25);
  border-color: #a78bfa;
  color: #fff;
}

.ref-code-block {
  background: #0b1120;
  border-radius: 16px;
  padding: 1.25rem;
  height: 58vh;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
}

.ref-code-block pre {
  white-space: pre-wrap;
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: #e2e8f0;
  margin: 0;
}

.ref-code-block code {
  color: #e2e8f0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.ref-readme {
  background: #0b1120;
  border-radius: 16px;
  padding: 1.5rem;
  height: 60vh;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
}

.ref-readme h1,
.ref-readme h2,
.ref-readme h3,
.ref-readme h4,
.ref-readme h5,
.ref-readme h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #f1f5f9;
  font-weight: 600;
}

.ref-readme h1 {
  font-size: 2rem;
  color: #fff;
}

.ref-readme h2 {
  font-size: 1.5rem;
}

.ref-readme h3 {
  font-size: 1.25rem;
}

.ref-readme p {
  color: #cbd5f5;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.ref-readme ul,
.ref-readme ol {
  color: #cbd5f5;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.ref-readme li {
  color: #cbd5f5;
  margin-bottom: 0.5rem;
}

.ref-readme code {
  background: rgba(139, 92, 246, 0.2);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
  color: #fbbf24;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.ref-readme pre {
  background: rgba(15, 23, 42, 0.8);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
}

.ref-readme pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}

.ref-readme a {
  color: #a78bfa;
  text-decoration: none;
}

.ref-readme a:hover {
  color: #c4b5fd;
  text-decoration: underline;
}

.ref-readme strong {
  color: #f1f5f9;
  font-weight: 600;
}

.ref-readme blockquote {
  border-left: 4px solid #8b5cf6;
  padding-left: 1rem;
  margin: 1rem 0;
  color: #cbd5f5;
  font-style: italic;
}

.ref-modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
}

@media (max-width: 768px) {
  .ref-labs-hero {
    padding: 1.5rem;
  }

  .ref-modal-header,
  .ref-modal-body {
    padding: 1.25rem;
  }

  #refLabPreview,
  .ref-code-block,
  .ref-readme {
    height: 55vh;
  }

  .ref-modal-content {
    border-radius: 16px;
  }
}

