/* MendelSim — Simulador de Genética */
/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fira+Mono:wght@400;500&display=swap');

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --primary:       #1a7431;
  --primary-light: #28a745;
  --accent:        #f0a500;
  --affected:      #c0392b;
  --carrier:       #e67e22;
  --bg:            #eef4ee;
  --card:          #ffffff;
  --text:          #2c3e50;
  --border:        #cde0cd;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --radius:        12px;
  --font:          'Inter', system-ui, sans-serif;
  --mono:          'Fira Mono', 'Consolas', monospace;
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Header ──────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, #2ecc71 100%);
  color: #fff;
  padding: 0.9rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
}
.header .logo {
  font-size: 2.4rem;
  display: inline;
  vertical-align: middle;
  margin-right: 0.35rem;
}
.header h1 {
  display: inline;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.5px;
}
.header p {
  font-size: 1rem;
  opacity: 0.88;
  margin-top: 0.3rem;
}
.header .back-btn {
  position: absolute;
  top: 1.2rem; left: 1.2rem;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.header .back-btn:hover { background: rgba(255,255,255,0.3); text-decoration: none; }
.header-content { max-width: 1100px; margin: 0 auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.header-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  z-index: 1;
}
.language-control {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

/* ── Container ───────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 1.2em;
  background: var(--primary-light);
  border-radius: 2px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.3rem;
  border-radius: 8px;
  border: none;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  background: var(--primary-light);
  color: #fff;
}
.btn-primary:hover { background: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(40,167,69,0.35); }
.btn-secondary {
  background: var(--accent);
  color: #fff;
}
.btn-secondary:hover { background: #d4920a; transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-light);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); color: #fff; }
.btn-danger {
  background: var(--affected);
  color: #fff;
}
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.82rem; }
.btn-lg { padding: 0.75rem 1.8rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── Form elements ───────────────────────────────────────── */
label { font-size: 0.9rem; font-weight: 500; color: #4a5568; }
select, input[type="text"], input[type="number"], textarea {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.92rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(40,167,69,0.12);
}
.header .header-controls .language-control #languageSelect {
  width: 4.4rem;
  min-width: 4.4rem;
  height: 2.2rem;
  padding: 0 0.55rem;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  background-color: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}
.header .header-controls .language-control #languageSelect:focus {
  border-color: rgba(255,255,255,0.75);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
}
.header .header-controls .language-control #languageSelect option { color: #1f2937; }
.form-group { margin-bottom: 1rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.radio-group { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: 0.3rem; }
.radio-group label {
  display: flex; align-items: center; gap: 0.4rem;
  cursor: pointer; font-weight: 400; color: var(--text);
}

/* ── Punnett Grid ────────────────────────────────────────── */
.punnett-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}
.punnett-grid {
  display: inline-grid;
  border-collapse: collapse;
  gap: 0;
}
.punnett-grid.mono { grid-template-columns: 60px repeat(2, 80px); }
.punnett-grid.dihybrid { grid-template-columns: 80px repeat(4, 80px); }
.punnett-cell {
  min-width: 60px; min-height: 52px;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  background: #fafafa;
  transition: all 0.25s ease;
  padding: 0.3rem;
  text-align: center;
}
.punnett-cell.header-cell {
  background: var(--primary);
  color: #fff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
}
.punnett-cell.row-header {
  background: #e8f5e9;
  color: var(--primary);
  font-weight: 600;
}
.punnett-cell.corner { background: var(--primary); }
.punnett-cell.result {
  opacity: 0;
  transform: scale(0.7);
  background: #fff;
}
.punnett-cell.result.show {
  opacity: 1;
  transform: scale(1);
}
/* Phenotype coloring for cells */
.punnett-cell.pheno-dom   { background: #d1fae5; color: #065f46; }
.punnett-cell.pheno-rec   { background: #fee2e2; color: #991b1b; }
.punnett-cell.pheno-inter { background: #fef3c7; color: #92400e; }
.punnett-cell.pheno-a     { background: #dbeafe; color: #1e3a8a; }
.punnett-cell.pheno-b     { background: #ede9fe; color: #5b21b6; }
.punnett-cell.pheno-ab    { background: #fce7f3; color: #9d174d; }
.punnett-cell.pheno-xnorm { background: #dcfce7; color: #166534; }
.punnett-cell.pheno-xcarr { background: #ffedd5; color: #9a3412; }
.punnett-cell.pheno-xaff  { background: #fee2e2; color: #991b1b; }

/* ── Ratio Bar ───────────────────────────────────────────── */
.ratio-bar-wrap { margin: 0.6rem 0; }
.ratio-bar-label {
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
  display: flex;
  justify-content: space-between;
}
.ratio-bar {
  height: 22px;
  border-radius: 11px;
  background: #e9ecef;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.ratio-bar-fill {
  height: 100%;
  border-radius: 11px;
  transition: width 0.8s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  min-width: 2rem;
}
.ratio-fill-1 { background: var(--primary-light); }
.ratio-fill-2 { background: var(--accent); }
.ratio-fill-3 { background: #8b5cf6; }
.ratio-fill-4 { background: var(--affected); }

/* ── Module Grid (index page) ────────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.module-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: var(--text);
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
  text-decoration: none;
}
.module-card .module-icon { font-size: 2.2rem; }
.module-card h3 { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.module-card p { font-size: 0.88rem; color: #6b7280; flex: 1; }
.module-card .card-footer { margin-top: 0.5rem; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 0.65rem 1.3rem;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.18s;
  display: flex; align-items: center; gap: 0.35rem;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary-light);
  font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.tabs.student-only-tabs {
  justify-content: flex-start;
}

/* ── Teacher/student exercises ───────────────────────────── */
.exercise-status {
  min-height: 1.25rem;
  margin-top: 0.7rem;
  font-size: 0.84rem;
  color: #64748b;
}
.exercise-status.success { color: #15803d; font-weight: 600; }
.exercise-status.warning { color: #b45309; font-weight: 600; }
.student-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
.student-meta-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  background: #fff;
}
.exercise-answer-section { margin-top: 1rem; }
.exercise-answer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-top: 0.55rem;
}
.exercise-answer-table th {
  background: var(--primary);
  color: #fff;
  padding: 0.45rem 0.65rem;
  text-align: left;
  font-weight: 600;
}
.exercise-answer-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #e5e7eb;
}
.exercise-answer-table tr:nth-child(even) td { background: #f9fafb; }
.student-count-input {
  max-width: 7rem;
}
.exercise-total {
  color: #64748b;
  white-space: nowrap;
}
.student-feedback {
  display: none;
  margin-top: 0.75rem;
}
.student-feedback.visible { display: flex; flex-direction: column; }
.check-ok { color: #15803d; font-weight: 700; }
.check-error { color: #b91c1c; font-weight: 700; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 0.9rem 1.1rem;
  border-radius: 8px;
  font-size: 0.92rem;
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin: 0.75rem 0;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }
.alert-info    { background: #eff6ff; border-left: 4px solid #3b82f6; color: #1e3a8a; }
.alert-success { background: #f0fdf4; border-left: 4px solid #22c55e; color: #14532d; }
.alert-warning { background: #fffbeb; border-left: 4px solid var(--accent); color: #78350f; }
.alert-error   { background: #fef2f2; border-left: 4px solid var(--affected); color: #7f1d1d; }

/* ── Results / Ratios ────────────────────────────────────── */
.ratio-list { list-style: none; padding: 0; }
.ratio-list li {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.92rem;
}
.ratio-list li:last-child { border-bottom: none; }
.ratio-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.genotype-tag {
  font-family: var(--mono);
  background: #f3f4f6;
  padding: 0.1rem 0.5rem;
  border-radius: 5px;
  font-size: 0.88rem;
}

/* ── Pedigree specific ───────────────────────────────────── */
.pedigree-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem;
  background: #f8fdf8;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  align-items: center;
}
.tool-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.82rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 0.3rem;
  white-space: nowrap;
}
.tool-btn:hover { border-color: var(--primary-light); color: var(--primary); background: #f0fdf4; }
.tool-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.builder-sex-toggle {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.sex-option {
  width: 2rem;
  height: 2rem;
  border: none;
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sex-option:last-child { border-right: none; }
.sex-option:hover { background: #f0fdf4; color: var(--primary); }
.sex-option.active { background: var(--primary); color: #fff; }

.pedigree-canvas-wrap {
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: #fafffe;
  position: relative;
}
.pedigree-canvas {
  display: block;
  width: 100%;
  min-height: 380px;
  cursor: crosshair;
}
.pedigree-info {
  font-size: 0.82rem;
  color: #6b7280;
  padding: 0.4rem 0.75rem;
  background: #f8fdf8;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 2rem;
}

/* SVG pedigree styles */
.ped-male rect { fill: #fff; stroke: var(--text); stroke-width: 2; }
.ped-female circle { fill: #fff; stroke: var(--text); stroke-width: 2; }
.ped-affected-m rect { fill: var(--affected); stroke: var(--affected); }
.ped-affected-f circle { fill: var(--affected); stroke: var(--affected); }
.ped-carrier-f circle { fill: #fff; stroke: var(--carrier); stroke-width: 2.5; }
.ped-carrier-m rect  { fill: #fff; stroke: var(--carrier); stroke-width: 2.5; }
.ped-line { stroke: var(--text); stroke-width: 1.8; fill: none; }
.ped-label { font-family: var(--font); font-size: 11px; fill: #555; text-anchor: middle; }
.ped-genotype { font-family: var(--mono); font-size: 10px; fill: #1a7431; text-anchor: middle; font-weight: 600; }
.ped-ind { cursor: grab; touch-action: none; }
.ped-ind:active { cursor: grabbing; }
.ped-ind:hover .ped-hover-rect { opacity: 1; }
.ped-hover-rect { opacity: 0; fill: rgba(40,167,69,0.1); rx: 4; transition: opacity 0.15s; }

/* ── Q&A / Self-test ─────────────────────────────────────── */
.qa-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.75rem; overflow: hidden; }
.qa-question {
  padding: 0.75rem 1rem;
  background: #f8fdf8;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
}
.qa-question:hover { background: #e8f5e9; }
.qa-answer {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  display: none;
  background: #fff;
  color: #374151;
}
.qa-answer.open { display: block; }

/* ── Legend ──────────────────────────────────────────────── */
.legend { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: 0.85rem; margin: 0.75rem 0; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-swatch {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1.5px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

/* ── Score display ───────────────────────────────────────── */
.score-display {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0fdf4;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
}

/* ── Section separators ──────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.2rem 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.step-number {
  width: 26px; height: 26px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Clue list ───────────────────────────────────────────── */
.clue-item {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed #e5e7eb;
  font-size: 0.9rem;
  animation: fadeInDown 0.35s ease;
}
.clue-item:last-child { border-bottom: none; }
.clue-num {
  width: 22px; height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Probability display ─────────────────────────────────── */
.prob-display {
  text-align: center;
  padding: 1.2rem;
  background: linear-gradient(135deg, #f0fdf4, #e8f5e9);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.prob-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.prob-fraction {
  font-size: 1rem;
  color: #6b7280;
  margin-top: 0.2rem;
}

/* ── Footer ──────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.82rem;
  color: #9ca3af;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  line-height: 1.7;
}
footer a {
  color: #6b9e6b;
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* ── Tooltip ─────────────────────────────────────────────── */
.tooltip-box {
  position: absolute;
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  transform: translate(-50%, -130%);
}

/* ── Divider ─────────────────────────────────────────────── */
.divider { border: none; border-top: 1.5px solid var(--border); margin: 1.5rem 0; }

/* ── Pattern label ───────────────────────────────────────── */
.pattern-result {
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius);
  margin: 0.75rem 0;
  font-size: 1.2rem;
  font-weight: 700;
}
.pattern-AR { background: #fef3c7; color: #92400e; border: 2px solid #fcd34d; }
.pattern-AD { background: #dbeafe; color: #1e40af; border: 2px solid #93c5fd; }
.pattern-XR { background: #fce7f3; color: #9d174d; border: 2px solid #f9a8d4; }
.pattern-XD { background: #ede9fe; color: #6d28d9; border: 2px solid #c4b5fd; }

/* ── Dark Mode Toggle Button ─────────────────────────────── */
.dark-toggle {
  position: absolute;
  top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 50%;
  width: 2.2rem; height: 2.2rem;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
  line-height: 1;
  color: inherit;
  padding: 0;
}
.dark-toggle:hover { background: rgba(255,255,255,0.3); }
.header-controls .dark-toggle { position: static; flex: 0 0 auto; }

/* ── Dark Mode Variables & Overrides ─────────────────────── */
[data-theme="dark"] {
  --primary:       #4ec97a;
  --primary-light: #5fdb8b;
  --accent:        #f0a500;
  --affected:      #e05252;
  --carrier:       #f0944d;
  --bg:            #111b11;
  --card:          #192619;
  --text:          #dce8dc;
  --border:        #2a4a2a;
  --shadow:        0 2px 12px rgba(0,0,0,0.5);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] a { color: var(--primary-light); }
[data-theme="dark"] a:hover { color: var(--primary); }
[data-theme="dark"] .header {
  background: linear-gradient(135deg, #1a5e2a 0%, #28a050 100%);
}
[data-theme="dark"] label { color: #a8c4a8; }
[data-theme="dark"] select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea {
  background: #1e301e; color: var(--text); border-color: var(--border);
}
[data-theme="dark"] select:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(95,219,139,0.15);
}
[data-theme="dark"] .card { background: var(--card); border-color: var(--border); }
[data-theme="dark"] .law-box {
  background: linear-gradient(135deg, #0d2e1a, #0a2216);
  border-color: var(--border);
}
[data-theme="dark"] .law-title { color: var(--primary); }
[data-theme="dark"] .law-box p { color: var(--text); }
[data-theme="dark"] .module-card { background: var(--card); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .module-card p { color: #9dba9d; }
[data-theme="dark"] .module-card h3 { color: var(--primary); }
[data-theme="dark"] .feature-list li { background: #1e301e; color: var(--primary); border-color: var(--border); }
[data-theme="dark"] .modules-section p { color: #9dba9d; }
[data-theme="dark"] .tab-btn { color: #9dba9d; }
[data-theme="dark"] .tab-btn:hover { color: var(--primary); }
[data-theme="dark"] .tab-btn.active { color: var(--primary); }
[data-theme="dark"] .student-meta-item { background: #192619; border-color: var(--border); }
[data-theme="dark"] .exercise-answer-table td { border-bottom-color: #1e301e; }
[data-theme="dark"] .exercise-answer-table tr:nth-child(even) td { background: #192619; }
[data-theme="dark"] .punnett-cell { background: #1e2e1e; color: var(--text); }
[data-theme="dark"] .punnett-cell.row-header { background: #1e361e; color: var(--primary); }
[data-theme="dark"] .punnett-cell.result { background: #1a291a; }
[data-theme="dark"] .punnett-cell.pheno-dom   { background: #0d2e1f; color: #6ee7b7; }
[data-theme="dark"] .punnett-cell.pheno-rec   { background: #2e0d0d; color: #fca5a5; }
[data-theme="dark"] .punnett-cell.pheno-inter { background: #2e2000; color: #fde68a; }
[data-theme="dark"] .punnett-cell.pheno-a     { background: #0d1a2e; color: #93c5fd; }
[data-theme="dark"] .punnett-cell.pheno-b     { background: #1a0d2e; color: #c4b5fd; }
[data-theme="dark"] .punnett-cell.pheno-ab    { background: #2e0d1e; color: #f9a8d4; }
[data-theme="dark"] .punnett-cell.pheno-xnorm { background: #0d2e16; color: #86efac; }
[data-theme="dark"] .punnett-cell.pheno-xcarr { background: #2e1a0d; color: #fdba74; }
[data-theme="dark"] .punnett-cell.pheno-xaff  { background: #2e0d0d; color: #fca5a5; }
[data-theme="dark"] .ratio-bar { background: #1e301e; }
[data-theme="dark"] .genotype-tag { background: #1e2e1e; color: var(--text); }
[data-theme="dark"] .ratio-list li { border-bottom-color: #1e301e; }
[data-theme="dark"] .qa-item { border-color: var(--border); }
[data-theme="dark"] .qa-question { background: #1a2a1a; color: var(--text); }
[data-theme="dark"] .qa-question:hover { background: #1e361e; }
[data-theme="dark"] .qa-answer { background: #192619; color: #c4d9c4; border-color: var(--border); }
[data-theme="dark"] .pedigree-toolbar { background: #162016; border-color: var(--border); }
[data-theme="dark"] .tool-btn { background: #1e301e; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .tool-btn:hover { border-color: var(--primary-light); color: var(--primary); background: #1a361a; }
[data-theme="dark"] .tool-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .builder-sex-toggle { background: #1e301e; border-color: var(--border); }
[data-theme="dark"] .sex-option { background: #1e301e; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .sex-option:hover { background: #1a361a; color: var(--primary); }
[data-theme="dark"] .sex-option.active { background: var(--primary); color: #fff; }
[data-theme="dark"] .pedigree-canvas-wrap { background: #141e14; border-color: var(--border); }
[data-theme="dark"] .pedigree-info { background: #162016; color: #9dba9d; border-color: var(--border); }
[data-theme="dark"] .ped-male rect { fill: #2a3e2a; stroke: var(--text); }
[data-theme="dark"] .ped-female circle { fill: #2a3e2a; stroke: var(--text); }
[data-theme="dark"] .ped-carrier-f circle { fill: #2a3e2a; stroke: var(--carrier); }
[data-theme="dark"] .ped-carrier-m rect  { fill: #2a3e2a; stroke: var(--carrier); }
[data-theme="dark"] .ped-label { fill: #a8c4a8; }
[data-theme="dark"] .ped-genotype { fill: var(--primary); }
[data-theme="dark"] .ped-line { stroke: var(--text); }
[data-theme="dark"] .ped-hover-rect { fill: rgba(95,219,139,0.12); }
[data-theme="dark"] .score-display { background: #1a2e1a; border-color: var(--border); }
[data-theme="dark"] .prob-display { background: linear-gradient(135deg, #1a2e1a, #1e361e); border-color: var(--border); }
[data-theme="dark"] .alert-info    { background: #0d1a2e; border-left-color: #3b82f6; color: #93c5fd; }
[data-theme="dark"] .alert-success { background: #0d2016; border-left-color: #22c55e; color: #86efac; }
[data-theme="dark"] .alert-warning { background: #2a1e00; border-left-color: var(--accent); color: #fde68a; }
[data-theme="dark"] .alert-error   { background: #2e0d0d; border-left-color: var(--affected); color: #fca5a5; }
[data-theme="dark"] .clue-item { border-bottom-color: #2a402a; }
[data-theme="dark"] .pattern-AR { background: #2a1a00; color: #fde68a; border-color: #7a5c00; }
[data-theme="dark"] .pattern-AD { background: #0d1a2e; color: #93c5fd; border-color: #1e3a6a; }
[data-theme="dark"] .pattern-XR { background: #2e0d1e; color: #f9a8d4; border-color: #6a1e3a; }
[data-theme="dark"] .pattern-XD { background: #1a0d2e; color: #c4b5fd; border-color: #3a1e6a; }
[data-theme="dark"] footer { color: #5a7a5a; border-top-color: var(--border); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 1rem 0.75rem 2rem; }
  .header { padding: 0.7rem 1rem; }
  .header h1 { font-size: 1.1rem; }
  .module-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .form-row { flex-direction: column; gap: 0.5rem; }
  .punnett-cell { min-width: 48px; min-height: 44px; font-size: 0.82rem; }
  .pedigree-toolbar { gap: 0.3rem; }
  .tool-btn { font-size: 0.75rem; padding: 0.35rem 0.6rem; }
  .tabs { gap: 0; }
  .tab-btn { padding: 0.55rem 0.9rem; font-size: 0.85rem; }
}
@media (max-width: 480px) {
  .module-grid { grid-template-columns: 1fr; }
  .header .back-btn { position: static; margin-bottom: 0.75rem; }
  .header-controls {
    top: 0.7rem;
    right: 0.7rem;
  }
  .btn-group { gap: 0.4rem; }
}
