:root {
  --lab-primary: #2563eb;
  --lab-success: #22c55e;
  --lab-yellow: #facc15;
  --lab-purple: #8b5cf6;
  --lab-text: #0f172a;
  --lab-muted: #64748b;
  --lab-bg: #f8fafc;
  --lab-white: #ffffff;
  --lab-border: rgba(15, 23, 42, .1);
  --lab-shadow: 0 22px 55px rgba(15, 23, 42, .1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--lab-bg);
  color: var(--lab-text);
  font-family: Tajawal, Cairo, Arial, sans-serif;
  margin: 0;
}

a {
  color: inherit;
}

.lab-container {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 1rem;
  width: 100%;
}

.lab-header {
  align-items: center;
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--lab-border);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: .85rem max(1rem, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-integrated-header {
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
  min-height: 72px;
  padding-block: .65rem;
}

.lab-brand,
.lab-nav {
  align-items: center;
  display: flex;
  gap: .7rem;
}

.lab-brand {
  font-size: .98rem;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
}

.lab-brand-icon {
  align-items: center;
  background: linear-gradient(135deg, var(--lab-primary), var(--lab-success));
  border-radius: 12px;
  color: #fff;
  display: inline-flex;
  font-size: 1rem;
  height: 34px;
  justify-content: center;
  min-width: 34px;
  overflow: hidden;
  padding: 4px;
  width: 34px;
}

.lab-brand-icon img {
  display: block;
  height: 24px;
  max-height: 24px;
  max-width: 24px;
  object-fit: contain;
  width: 24px;
}

.lab-nav a {
  border-radius: 8px;
  color: var(--lab-text);
  font-size: .98rem;
  font-weight: 800;
  padding: .45rem .65rem;
  position: relative;
  text-decoration: none;
  transition: background-color .18s ease, box-shadow .18s ease, color .18s ease, transform .18s ease;
  white-space: nowrap;
}

.lab-nav a::after {
  background: linear-gradient(90deg, var(--lab-primary), var(--lab-success));
  border-radius: 999px;
  bottom: .16rem;
  content: "";
  height: 3px;
  inset-inline: .65rem;
  opacity: 0;
  position: absolute;
  transform: scaleX(.25);
  transform-origin: center;
  transition: opacity .18s ease, transform .18s ease;
}

.lab-nav a:hover,
.lab-nav a:focus,
.lab-nav a.is-active {
  background: rgba(37, 99, 235, .08);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .12);
  color: var(--lab-primary);
  transform: translateY(-2px);
}

.lab-nav a:hover::after,
.lab-nav a:focus::after,
.lab-nav a.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.lab-header-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: .55rem;
}

.lab-header-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-size: .95rem;
  font-weight: 900;
  justify-content: center;
  min-height: 44px;
  padding: .55rem .85rem;
  text-decoration: none;
  transition: box-shadow .18s ease, transform .18s ease, background-color .18s ease;
  white-space: nowrap;
}

.lab-header-button.primary {
  background: linear-gradient(135deg, var(--lab-primary), #14b8a6);
  box-shadow: 0 12px 24px rgba(37, 99, 235, .2);
  color: #fff;
}

.lab-header-button.ghost {
  background: #fff;
  border: 1px solid rgba(37, 99, 235, .32);
  color: var(--lab-primary);
}

.lab-header-button:hover,
.lab-header-button:focus {
  transform: translateY(-2px);
}

.lab-theme-toggle {
  background: rgba(37, 99, 235, .1);
  border: 1px solid rgba(37, 99, 235, .22);
  border-radius: 8px;
  color: var(--lab-primary);
  cursor: pointer;
  font: inherit;
  font-size: .88rem;
  font-weight: 900;
  line-height: 1;
  min-height: 40px;
  padding: .45rem .8rem;
}

.lab-nav .lab-theme-toggle {
  align-self: center;
  display: inline-flex;
  margin-inline-start: .15rem;
}

.lab-theme-toggle:hover,
.lab-theme-toggle:focus {
  background: rgba(37, 99, 235, .16);
  outline: none;
}

.help-toggle {
  color: #0f766e;
}

.lab-help-modal {
  align-items: center;
  background: rgba(2, 6, 23, .58);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 9999;
}

.lab-help-modal.is-open {
  display: flex;
}

.lab-help-dialog {
  background: #fff;
  border: 1px solid rgba(37, 99, 235, .16);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(2, 6, 23, .24);
  color: var(--lab-text);
  max-width: 440px;
  padding: 1.2rem;
  position: relative;
  text-align: center;
  width: min(100%, 440px);
}

.lab-help-dialog strong {
  color: var(--lab-primary);
  display: block;
  font-size: 1.25rem;
  font-weight: 900;
  margin-bottom: .55rem;
}

.lab-help-dialog p {
  color: var(--lab-muted);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.9;
  margin: 0;
}

.lab-help-close {
  align-items: center;
  background: #ef4444;
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 1.2rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  left: .8rem;
  position: absolute;
  top: .8rem;
  width: 34px;
}

.lab-hero {
  background:
    radial-gradient(circle at 12% 20%, rgba(250, 204, 21, .32), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(34, 197, 94, .2), transparent 30%),
    linear-gradient(135deg, #eff6ff 0%, #ffffff 46%, #ecfdf5 100%);
  overflow: hidden;
  padding: clamp(3rem, 7vw, 5.5rem) 0;
}

.lab-hero-grid {
  align-items: center;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, .72fr);
}

.lab-kicker {
  background: rgba(37, 99, 235, .1);
  border-radius: 999px;
  color: var(--lab-primary);
  display: inline-flex;
  font-weight: 900;
  margin-bottom: .8rem;
  padding: .45rem .8rem;
}

.lab-hero h1,
.lab-section-heading h2,
.experiment-title {
  color: var(--lab-text);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
}

.lab-hero h1 {
  font-size: clamp(2.6rem, 7vw, 5.2rem);
}

.lab-hero p,
.lab-section-heading p {
  color: var(--lab-muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 700;
  line-height: 1.9;
  margin: 1rem 0 0;
  max-width: 760px;
}

.lab-hero-actions,
.experiment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.4rem;
}

.lab-button {
  align-items: center;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font-size: 1rem;
  font-weight: 900;
  gap: .45rem;
  justify-content: center;
  min-height: 48px;
  padding: .75rem 1.1rem;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.lab-button:hover,
.lab-button:focus {
  transform: translateY(-2px);
}

.lab-button.primary {
  background: linear-gradient(135deg, var(--lab-primary), #16a34a);
  box-shadow: 0 16px 28px rgba(37, 99, 235, .22);
  color: #fff;
}

.lab-button.ghost {
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(37, 99, 235, .18);
  color: var(--lab-primary);
}

.lab-hero-card,
.experiment-card,
.lab-panel,
.lab-result {
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--lab-border);
  border-radius: 24px;
  box-shadow: var(--lab-shadow);
}

.lab-hero-card {
  padding: 1.4rem;
  text-align: center;
}

.lab-orbit {
  background: linear-gradient(135deg, rgba(37, 99, 235, .12), rgba(34, 197, 94, .12));
  border-radius: 22px;
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1rem;
  padding: 1rem;
}

.lab-orbit span {
  align-items: center;
  background: #fff;
  border-radius: 18px;
  display: flex;
  font-size: 2.4rem;
  justify-content: center;
  min-height: 100px;
}

.lab-hero-card strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
}

.lab-hero-card small {
  color: var(--lab-muted);
  display: block;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.7;
  margin-top: .35rem;
}

.lab-section,
.experiment-page {
  padding: clamp(2.4rem, 5vw, 4rem) 0;
}

.lab-section-heading {
  margin: 0 auto 1.5rem;
  max-width: 820px;
  text-align: center;
}

.lab-section-heading h2,
.experiment-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.experiment-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.experiment-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1.1rem;
}

.experiment-card.active {
  border-color: rgba(37, 99, 235, .22);
}

.experiment-icon {
  align-items: center;
  background: linear-gradient(135deg, rgba(37, 99, 235, .1), rgba(250, 204, 21, .2));
  border-radius: 18px;
  display: flex;
  font-size: 2.5rem;
  height: 76px;
  justify-content: center;
  width: 76px;
}

.experiment-card h3 {
  font-size: 1.3rem;
  font-weight: 900;
  margin: 0;
}

.experiment-card p,
.experiment-card span {
  color: var(--lab-muted);
  font-weight: 800;
  line-height: 1.75;
  margin: 0;
}

.experiment-card .lab-button {
  margin-top: auto;
  width: 100%;
}

.experiment-header {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.experiment-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.lab-panel {
  min-height: 460px;
  overflow: hidden;
  padding: 1rem;
  position: relative;
}

.lab-side {
  display: grid;
  gap: 1rem;
}

.lab-result {
  padding: 1rem;
}

.lab-result h2 {
  font-size: 1.1rem;
  font-weight: 900;
  margin: 0 0 .6rem;
}

.lab-result-message {
  background: rgba(37, 99, 235, .08);
  border-radius: 16px;
  color: var(--lab-primary);
  font-weight: 900;
  line-height: 1.8;
  min-height: 74px;
  padding: .85rem;
}

.lab-result-message.success {
  background: rgba(34, 197, 94, .12);
  color: #15803d;
}

.lab-rating-placeholder {
  align-items: center;
  background: rgba(250, 204, 21, .13);
  border-radius: 14px;
  color: #a16207;
  display: flex;
  font-weight: 900;
  gap: .45rem;
  justify-content: center;
  margin-top: .75rem;
  padding: .65rem;
}

.lab-toolbox {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
}

.lab-draggable {
  align-items: center;
  background: #fff;
  border: 2px solid rgba(37, 99, 235, .16);
  border-radius: 18px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, .08);
  cursor: grab;
  display: inline-flex;
  font-size: 1.05rem;
  font-weight: 900;
  gap: .45rem;
  min-height: 54px;
  padding: .65rem .85rem;
  touch-action: none;
  user-select: none;
}

.lab-draggable.is-dragging {
  cursor: grabbing;
  opacity: .88;
  position: fixed;
  z-index: 50;
}

.lab-zone {
  align-items: center;
  background: rgba(248, 250, 252, .95);
  border: 2px dashed rgba(37, 99, 235, .24);
  border-radius: 20px;
  color: #64748b;
  display: flex;
  font-weight: 900;
  justify-content: center;
  min-height: 96px;
  padding: .7rem;
  text-align: center;
}

.lab-zone.is-over {
  background: rgba(37, 99, 235, .1);
  border-color: var(--lab-primary);
}

.lab-zone.is-filled {
  background: rgba(34, 197, 94, .12);
  border-color: rgba(34, 197, 94, .45);
  color: #15803d;
}

.circuit-board {
  background:
    linear-gradient(90deg, rgba(37, 99, 235, .08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(37, 99, 235, .08) 1px, transparent 1px),
    #f8fafc;
  background-size: 32px 32px;
  border-radius: 22px;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 1rem;
}

.wire-line {
  background: linear-gradient(90deg, var(--lab-primary), var(--lab-success));
  border-radius: 999px;
  grid-column: 1 / -1;
  height: 8px;
  opacity: .35;
}

.bulb-display,
.plant-stage {
  align-items: center;
  background: linear-gradient(135deg, rgba(250, 204, 21, .14), rgba(34, 197, 94, .12));
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  font-size: 4rem;
  font-weight: 900;
  justify-content: center;
  margin-top: 1rem;
  min-height: 150px;
}

.bulb-display.is-on {
  background: radial-gradient(circle, rgba(250, 204, 21, .62), rgba(250, 204, 21, .16) 45%, rgba(34, 197, 94, .08));
  color: #a16207;
}

.switch-toggle {
  margin-top: 1rem;
  width: 100%;
}

.plant-garden {
  align-items: end;
  background: linear-gradient(180deg, #dbeafe, #ecfdf5 58%, #bbf7d0 59%, #86efac);
  border-radius: 22px;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  min-height: 320px;
  padding: 1rem;
}

.plant-pot {
  align-items: center;
  background: rgba(255, 255, 255, .7);
  border: 2px dashed rgba(34, 197, 94, .45);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  font-size: 4.5rem;
  font-weight: 900;
  justify-content: center;
  min-height: 210px;
}

.plant-needs {
  display: grid;
  gap: .65rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.placeholder-panel {
  align-items: center;
  background: linear-gradient(135deg, rgba(37, 99, 235, .08), rgba(139, 92, 246, .1));
  border: 2px dashed rgba(37, 99, 235, .22);
  border-radius: 22px;
  color: var(--lab-muted);
  display: flex;
  flex-direction: column;
  font-weight: 900;
  justify-content: center;
  min-height: 320px;
  padding: 1rem;
  text-align: center;
}

.placeholder-panel span {
  font-size: 4rem;
  margin-bottom: .75rem;
}

.lab-footer {
  background: #0f172a;
  color: #dbeafe;
  font-weight: 800;
  padding: 2.5rem 1rem 1.25rem;
}

.site-integrated-footer {
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.lab-footer-grid {
  align-items: start;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(260px, 1fr) auto;
}

.lab-footer strong {
  color: #fff;
  display: block;
  font-size: 1.35rem;
  margin-bottom: .4rem;
}

.lab-footer p {
  color: #cbd5e1;
  line-height: 1.9;
  margin: 0;
  max-width: 560px;
}

.lab-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .9rem;
  justify-content: flex-end;
}

.lab-footer a {
  color: #dbeafe;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.lab-footer a:hover,
.lab-footer a:focus {
  color: #93c5fd;
}

.lab-footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, .15);
  color: #94a3b8;
  margin: 2rem auto 0;
  max-width: 1180px;
  padding-top: 1rem;
  text-align: center;
}

.lab-theme-dark {
  --lab-text: #f8fafc;
  --lab-muted: #a8bdd6;
  --lab-bg: #08111f;
  --lab-white: #111827;
  --lab-border: rgba(148, 163, 184, .22);
  --lab-shadow: 0 22px 55px rgba(0, 0, 0, .28);
  background: #08111f;
  color: var(--lab-text);
}

.lab-theme-dark .lab-header {
  background: rgba(8, 17, 31, .9);
  border-bottom-color: rgba(148, 163, 184, .18);
  color: #f8fafc;
}

.lab-theme-dark .lab-nav a,
.lab-theme-dark .lab-header-button.ghost {
  color: #cbd5e1;
}

.lab-theme-dark .lab-header-button.ghost {
  background: rgba(15, 23, 42, .82);
  border-color: rgba(96, 165, 250, .28);
}

.lab-theme-dark .lab-theme-toggle {
  background: rgba(96, 165, 250, .14);
  border-color: rgba(96, 165, 250, .24);
  color: #bfdbfe;
}

.lab-theme-dark .lab-hero {
  background:
    radial-gradient(circle at 12% 20%, rgba(250, 204, 21, .16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(34, 197, 94, .14), transparent 30%),
    linear-gradient(135deg, #08111f 0%, #0f172a 58%, #111827 100%);
}

.lab-theme-dark .lab-kicker {
  background: rgba(96, 165, 250, .14);
  color: #bfdbfe;
}

.lab-theme-dark .lab-hero-card,
.lab-theme-dark .experiment-card,
.lab-theme-dark .lab-panel,
.lab-theme-dark .lab-result,
.lab-theme-dark .placeholder-panel {
  background: rgba(17, 24, 39, .94);
  border-color: rgba(148, 163, 184, .18);
  color: #f8fafc;
}

.lab-theme-dark .lab-orbit {
  background: linear-gradient(135deg, rgba(37, 99, 235, .18), rgba(34, 197, 94, .12));
}

.lab-theme-dark .lab-orbit span {
  background: #0f172a;
}

.lab-theme-dark .lab-button.ghost {
  background: rgba(15, 23, 42, .82);
  border-color: rgba(96, 165, 250, .28);
  color: #bfdbfe;
}

.lab-theme-dark .lab-result-message {
  background: rgba(96, 165, 250, .14);
  color: #bfdbfe;
}

.lab-theme-dark .lab-help-dialog {
  background: #0f172a;
  border-color: rgba(148, 163, 184, .22);
}

.lab-theme-dark .lab-help-dialog strong {
  color: #bfdbfe;
}

.lab-theme-dark .circuit-board {
  background:
    linear-gradient(90deg, rgba(96, 165, 250, .1) 1px, transparent 1px),
    linear-gradient(180deg, rgba(96, 165, 250, .1) 1px, transparent 1px),
    #0f172a;
}

.lab-theme-dark .plant-garden {
  background: linear-gradient(180deg, #0f2547, #12382d 58%, #14532d 59%, #166534);
}

.lab-theme-dark .plant-pot {
  background: rgba(15, 23, 42, .72);
  border-color: rgba(74, 222, 128, .36);
}

.lab-theme-dark .bulb-display,
.lab-theme-dark .plant-stage {
  background: linear-gradient(135deg, rgba(250, 204, 21, .12), rgba(34, 197, 94, .1));
}

.lab-theme-dark .lab-footer {
  background: #020617;
}

@media (max-width: 980px) {
  .site-integrated-header {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .lab-brand {
    flex: 1 1 auto;
  }

  .lab-nav {
    flex: 1 1 100%;
    order: 3;
    overflow-x: auto;
    padding-bottom: .15rem;
  }

  .lab-header-actions {
    justify-content: flex-end;
  }

  .lab-hero-grid,
  .experiment-layout {
    grid-template-columns: 1fr;
  }

  .experiment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .lab-header {
    align-items: stretch;
    flex-direction: row;
  }

  .lab-header-actions {
    display: grid;
    gap: .5rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .lab-header-button,
  .lab-theme-toggle {
    font-size: .82rem;
    min-width: 0;
    padding-inline: .45rem;
  }

  .lab-footer-grid {
    grid-template-columns: 1fr;
  }

  .lab-footer nav {
    justify-content: flex-start;
  }

  .experiment-grid,
  .circuit-board,
  .plant-needs {
    grid-template-columns: 1fr;
  }

  .lab-hero-actions,
  .experiment-actions {
    flex-direction: column;
  }

  .lab-button {
    width: 100%;
  }
}
