:root {
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-hover: #1a2332;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #475569;
  --accent: #06b6d4;
  --accent-dim: #0e7490;
  --border: #1e293b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --expected: #3b82f6;
  --observed: #06b6d4;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: transparent;
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 1rem;
  font-size: 13px;
}

.widget {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

/* Header Banner */
.header-banner {
  position: relative;
  height: 80px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  opacity: 0.5;
}
.banner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 1rem;
  background: linear-gradient(90deg, rgba(17,24,39,0.9) 0%, rgba(17,24,39,0.4) 60%, rgba(17,24,39,0.7) 100%);
}
.banner-overlay h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.3px;
}
.banner-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.badge {
  font-size: 0.55rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}
.badge.live { background: var(--success); color: #000; }

/* Manual Controls */
.manual-controls {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.slider-group { margin-bottom: 0.4rem; }
.slider-group:last-of-type { margin-bottom: 0.5rem; }
.slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.slider-group .val { font-family: monospace; color: var(--accent); font-weight: 600; }
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 4px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.formula {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--bg);
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  line-height: 1.5;
  white-space: pre;
}

/* Chart */
.chart-area { padding: 0.4rem 0.8rem; }
#hwe-chart { width: 100%; }

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
}
.stat { text-align: center; padding: 0.2rem; }
.stat .stat-value { font-size: 1rem; font-weight: 700; font-family: monospace; }
.stat .stat-label { font-size: 0.65rem; color: var(--text-dim); margin-top: 0.1rem; }
.stat.deviation .stat-value { color: var(--warning); }
.stat.ok .stat-value { color: var(--success); }

/* Variants Section */
.variants-section {
  padding: 0.5rem 0.8rem;
  border-top: 1px solid var(--border);
}
.section-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.section-label .hint { font-weight: 400; color: var(--text-dim); font-size: 0.7rem; }

.preset-row {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
}
.preset {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.72rem;
  white-space: nowrap;
  transition: all 0.12s;
  font-family: inherit;
}
.preset small { color: var(--text-dim); font-size: 0.65rem; }
.preset:hover { border-color: var(--accent-dim); color: var(--text); }
.preset.active { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
.preset.active small { color: rgba(255,255,255,0.7); }

.search-row { position: relative; margin-top: 0.4rem; }
.search-row input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}
.search-row input:focus { border-color: var(--accent-dim); }
.search-row input::placeholder { color: var(--text-dim); }
.autocomplete {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 5px 5px;
  max-height: 150px;
  overflow-y: auto;
  z-index: 10;
}
.autocomplete.open { display: block; }
.ac-item {
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
}
.ac-item:hover { background: var(--bg-hover); }
.ac-item .gene { font-weight: 600; }
.ac-item .count { color: var(--text-dim); font-size: 0.7rem; }

/* gnomAD Lookup Panel */
.gnomad-panel {
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.gnomad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.gnomad-gene { font-weight: 700; color: var(--accent); font-size: 0.85rem; }
.gnomad-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}
.gnomad-close:hover { color: var(--text); }
.gnomad-search {
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
}
.gnomad-search input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-family: inherit;
  outline: none;
}
.gnomad-search input:focus { border-color: var(--accent-dim); }
.gnomad-search input::placeholder { color: var(--text-dim); }
.gnomad-fetch {
  background: var(--accent-dim);
  border: none;
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  white-space: nowrap;
}
.gnomad-fetch:hover { background: var(--accent); }
.gnomad-fetch:disabled { opacity: 0.5; cursor: wait; }
.gnomad-status {
  padding: 0 0.8rem;
  font-size: 0.73rem;
  color: var(--text-dim);
  min-height: 1.2em;
}
.gnomad-status.error { color: var(--danger); }
.gnomad-status.ok { color: var(--success); }
.gnomad-results {
  padding: 0 0.8rem 0.4rem;
}
.gnomad-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.5rem;
  margin-top: 0.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s;
  font-size: 0.78rem;
}
.gnomad-result-item:hover { border-color: var(--accent-dim); }
.gnomad-result-item .rsid { font-weight: 600; color: var(--accent); }
.gnomad-result-item .consequence { color: var(--text-dim); font-size: 0.7rem; }
.gnomad-result-item .freq { font-family: monospace; font-size: 0.75rem; }
.gnomad-result-item .use-btn {
  background: var(--accent-dim);
  color: #fff;
  border: none;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
}
.gnomad-result-item .use-btn:hover { background: var(--accent); }

/* Variant Detail Panel */
.variant-detail {
  border-top: 1px solid var(--border);
}
.variant-info {
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}
.variant-info .var-name { font-weight: 600; color: var(--accent); }
.variant-info .var-gene { color: var(--text-muted); }
.variant-info .var-note { color: var(--text-dim); font-style: italic; font-size: 0.73rem; margin-top: 0.15rem; }

.pop-tabs {
  display: flex;
  gap: 2px;
  padding: 0.35rem 0.8rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.pop-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  font-size: 0.7rem;
  border-radius: 3px;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.12s;
}
.pop-tab:hover { color: var(--text-muted); background: var(--bg); }
.pop-tab.active { background: var(--accent-dim); color: #fff; }

.obs-vs-exp {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
}
.obs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-family: monospace;
}
.obs-table th {
  color: var(--text-dim);
  font-weight: 400;
  text-align: right;
  padding: 0.15rem 0.5rem 0.15rem 0;
  font-size: 0.7rem;
}
.obs-table th:first-child { text-align: left; }
.obs-table td {
  text-align: right;
  padding: 0.15rem 0.5rem 0.15rem 0;
}
.obs-table td:first-child { text-align: left; color: var(--text-muted); font-weight: 600; }
.obs-table .dev-pos { color: var(--success); }
.obs-table .dev-neg { color: var(--danger); }
.obs-table .chi-row td { border-top: 1px solid var(--border); padding-top: 0.3rem; }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border-top: 1px solid var(--border);
  font-size: 0.65rem;
  color: var(--text-dim);
}
.footer a { color: var(--accent-dim); }
.footer code {
  background: var(--bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.6rem;
}
.embed-hint { opacity: 0.6; }

/* Module Chooser */
.chooser-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 0.7rem 0.8rem;
}
.chooser-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.chooser-card:hover { border-color: var(--accent-dim); background: var(--bg-hover); text-decoration: none; }
.chooser-card.cc-soon { opacity: 0.5; cursor: default; }
.chooser-card.cc-soon:hover { border-color: var(--border); background: var(--bg); }
.cc-icon {
  font-size: 1.1rem;
  font-family: monospace;
  color: var(--accent);
  margin-bottom: 0.2rem;
  font-weight: 700;
}
.cc-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.15rem; }
.cc-desc { font-size: 0.7rem; color: var(--text-dim); line-height: 1.3; }
.chooser-card .badge { margin-top: 0.3rem; display: inline-block; }
.badge.soon { background: var(--border); color: var(--text-dim); }

/* Back link in header */
.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.1rem;
  margin-right: 0.6rem;
  opacity: 0.7;
}
.back-link:hover { opacity: 1; color: var(--accent); }
.hwe-header .banner-overlay { flex-direction: row; align-items: center; }

/* Science disclaimer (shared) */
.science-disclaimer {
  padding: 0.3rem 0.8rem;
  font-size: 0.6rem;
  line-height: 1.35;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  text-align: center;
}
.science-disclaimer a { color: var(--accent-dim); }

/* Embed mode */
body.embed { padding: 0; background: transparent; }
body.embed .widget { border-radius: 0; border: none; max-width: 100%; }
body.embed .footer .embed-hint { display: none; }

@media (max-width: 400px) {
  .preset { font-size: 0.65rem; padding: 0.2rem 0.35rem; }
}
