:root {
  --navy-900: #0b1236;
  --navy-800: #121c52;
  --navy-700: #1d2b78;
  --ink: #18203f;
  --ink-soft: #4a5376;
  --muted: #7d86a8;
  --line: #e3e7f3;
  --surface: #ffffff;
  --surface-2: #f6f8fd;
  --cream: #fffaf0;
  --green: #3bb178;
  --green-d: #2a9663;
  --blue: #3e5fae;
  --blue-d: #2f4c92;
  --indigo: #5b6ee1;
  --indigo-d: #4657c9;
  --dom: #2a9663;
  --mid: #d98a1c;
  --rec: #7a55d6;
  --danger: #d6455d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(20, 30, 80, .25), 0 2px 6px rgba(20, 30, 80, .06);
  --font: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, #eef2fb 0%, #e6ecf8 45%, #f3f0fa 100%);
  min-height: 100vh;
  line-height: 1.45;
}
.bg-decor {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(600px 400px at 85% -5%, rgba(91, 110, 225, .18), transparent 70%),
    radial-gradient(500px 360px at -10% 30%, rgba(59, 177, 120, .12), transparent 70%),
    radial-gradient(600px 420px at 110% 90%, rgba(255, 92, 138, .10), transparent 70%);
}

.shell {
  position: relative; z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

/* Hero */
.hero {
  display: flex; align-items: center; gap: 18px;
  padding: 26px 30px;
  border-radius: 26px;
  color: #fff;
  background:
    radial-gradient(420px 200px at 100% 0%, rgba(124, 108, 255, .45), transparent 70%),
    linear-gradient(135deg, var(--navy-900), var(--navy-700));
  box-shadow: 0 24px 50px -24px rgba(13, 22, 64, .8);
}
.hero__icon {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
}
.hero__icon svg { width: 44px; height: 44px; }
.hero__title { margin: 0; font-size: clamp(26px, 4.6vw, 40px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.hero__subtitle { margin: 8px 0 0; color: #c9d1ff; font-weight: 500; font-size: 15px; }
.hero__subtitle span { opacity: .6; margin: 0 4px; }

/* Tabs */
.tabs {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 22px 0 18px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.tab {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: transparent;
  padding: 12px 10px;
  border-radius: 999px;
  font: 600 15px/1 var(--font);
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s;
  white-space: nowrap;
}
.tab svg { width: 18px; height: 18px; flex: 0 0 auto; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: #fff; }
.tab:focus-visible { outline: 3px solid rgba(91, 110, 225, .45); outline-offset: 2px; }
.tabs__indicator {
  position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 6px;
  width: calc((100% - 24px) / 3);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--navy-800), var(--indigo));
  box-shadow: 0 8px 18px -8px rgba(29, 43, 120, .8);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

/* Cards & forms */
.panel { animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(227, 231, 243, .7);
}
.card + .card, .results, .formulas { margin-top: 16px; }
.results .card + .card { margin-top: 16px; }
.card__title { margin: 0 0 14px; font-size: 17px; font-weight: 700; }

.form { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.field { position: relative; display: block; }
.field__label {
  position: absolute; top: -9px; left: 14px;
  padding: 0 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px; font-weight: 600;
  line-height: 18px;
  max-width: calc(100% - 28px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .2s;
}
.field__input {
  width: 100%;
  padding: 16px 16px 14px;
  border: 1.5px solid #cfd5e8;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 500 17px/1.35 var(--font);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  resize: vertical;
}
.field__input.mono { font-family: var(--mono); letter-spacing: .02em; }
.field__input:focus { border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(91, 110, 225, .15); }
.field:focus-within .field__label { color: var(--indigo); }
.field__input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(214, 69, 93, .12); }

.form__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--ink-soft); font-weight: 500; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check__box {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid #b9c1da; background: #fff;
  display: grid; place-items: center;
  transition: all .2s;
}
.check__box::after { content: ""; width: 10px; height: 6px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform .2s; }
.check input:checked + .check__box { background: var(--green); border-color: var(--green); }
.check input:checked + .check__box::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:focus-visible + .check__box { box-shadow: 0 0 0 4px rgba(59, 177, 120, .25); }

.link-btn { border: 0; background: none; color: var(--indigo); font: 600 14px var(--font); cursor: pointer; padding: 4px 0; }
.link-btn:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips__label { color: var(--muted); font-size: 13px; font-weight: 600; margin-right: 2px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 999px; padding: 6px 12px;
  font: 600 13px var(--mono);
  cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--indigo); color: var(--indigo); background: #fff; }

.hint { margin: -6px 2px 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.error {
  margin: 0; padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fdecef; color: #a42a40;
  font-weight: 600; font-size: 14px;
  border: 1px solid #f6c7d0;
}

.btn {
  width: 100%;
  border: 0; border-radius: 16px;
  padding: 17px 20px;
  font: 700 18px/1 var(--font);
  color: #fff;
  cursor: pointer;
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(91, 110, 225, .5); outline-offset: 3px; }
.btn--green { background: linear-gradient(135deg, #48c487, var(--green-d)); box-shadow: 0 12px 24px -12px rgba(42, 150, 99, .8); }
.btn--blue { background: linear-gradient(135deg, #4b6dc0, var(--blue-d)); box-shadow: 0 12px 24px -12px rgba(47, 76, 146, .8); }
.btn--indigo { background: linear-gradient(135deg, #6c7ff0, var(--indigo-d)); box-shadow: 0 12px 24px -12px rgba(70, 87, 201, .8); }

/* Segmented control */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; background: var(--surface-2); border-radius: 14px; border: 1px solid var(--line); }
.segmented label { flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center;
  padding: 9px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.segmented input:checked + span { background: #fff; color: var(--indigo-d); box-shadow: 0 2px 8px rgba(20, 30, 80, .1); }
.segmented input:focus-visible + span { outline: 2px solid var(--indigo); }

/* Summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.summary__item { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.summary__item--wide { grid-column: 1 / -1; }
.summary__label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.summary__value { margin-top: 6px; font: 700 19px/1.25 var(--mono); color: var(--ink); word-break: break-word; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table thead th {
  background: #22337f;
  color: #fff; text-align: left;
  padding: 14px 16px; font-weight: 700; white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: var(--radius-sm); }
.table thead th:last-child { border-top-right-radius: var(--radius-sm); }
.th-ico { margin-right: 6px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table tbody tr:nth-child(even) td { background: #fafbfe; }
.table tbody tr:hover td { background: #f1f4ff; }
.table .gt { font: 700 15px var(--mono); }
.table .num { font-family: var(--mono); color: var(--ink-soft); white-space: nowrap; }

.pheno { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 7px; font: 700 13px/1.5 var(--mono); }
.tag--dom { background: #e3f6ec; color: var(--dom); }
.tag--mid { background: #fdf1de; color: #b06d0f; }
.tag--rec { background: #efe9fc; color: var(--rec); }

/* Phenotype bars */
.bars { display: grid; gap: 12px; }
.bar { display: grid; grid-template-columns: minmax(110px, auto) 1fr auto; align-items: center; gap: 12px; }
.bar__track { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), #5cc8a0); width: 0; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar__value { font: 600 14px var(--mono); color: var(--ink-soft); white-space: nowrap; }

/* Punnett */
.punnett { border-collapse: separate; border-spacing: 4px; margin: 0 auto; }
.punnett th, .punnett td { text-align: center; padding: 8px 10px; border-radius: 9px; font: 600 14px var(--mono); white-space: nowrap; }
.punnett th { background: var(--navy-800); color: #fff; }
.punnett th.corner { background: transparent; color: var(--muted); font-family: var(--font); font-size: 12px; }
.punnett td { background: var(--surface-2); border: 1px solid var(--line); }
.punnett td.k-dom { background: #e9f7f0; }
.punnett td.k-rec { background: #f3eefd; }
.punnett.compact th, .punnett.compact td { padding: 5px 6px; font-size: 12px; }

/* Key-value results (stats, HW) */
.kv { margin: 0; display: grid; }
.kv__row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 13px 4px; border-bottom: 1px dashed var(--line);
}
.kv__row:last-child { border-bottom: 0; }
.kv dt { font-weight: 700; color: var(--ink); }
.kv dt small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kv dd { margin: 0; font: 700 20px var(--mono); color: var(--green-d); white-space: nowrap; }
.kv dd .sub { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 6px; }

.strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.strip span { padding: 4px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font: 600 13px var(--mono); }

/* HW stacked bar */
.stack { display: flex; height: 44px; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.stack div { display: grid; place-items: center; color: #fff; font: 700 13px var(--mono); min-width: 0; overflow: hidden; white-space: nowrap; transition: flex-basis .6s cubic-bezier(.2, .8, .2, 1); }
.s-AA { background: linear-gradient(135deg, #48c487, var(--dom)); }
.s-Aa { background: linear-gradient(135deg, #f0a842, var(--mid)); }
.s-aa { background: linear-gradient(135deg, #9677e6, var(--rec)); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 14px; color: var(--ink-soft); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

/* Formulas */
.formulas summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); list-style: none; display: flex; align-items: center; gap: 8px; }
.formulas summary::-webkit-details-marker { display: none; }
.formulas summary::before { content: "ƒ"; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--surface-2); color: var(--indigo); font-style: italic; }
.formulas ul { margin: 14px 0 0; padding-left: 20px; color: var(--ink-soft); display: grid; gap: 6px; }
.formulas b { color: var(--ink); }

.footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 28px; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .shell { padding: 14px 12px 30px; }
  .hero { padding: 20px; border-radius: 22px; gap: 14px; }
  .hero__icon { width: 52px; height: 52px; border-radius: 14px; }
  .hero__icon svg { width: 36px; height: 36px; }
  .hero__subtitle { font-size: 13px; }
  .tab { font-size: 13.5px; padding: 11px 4px; gap: 5px; }
  .tab svg { width: 15px; height: 15px; }
  .grid-2 { grid-template-columns: 1fr; gap: 20px; }
  .card { padding: 18px 16px; }
  .table { font-size: 14px; }
  .table td, .table thead th { padding: 11px 10px; }
  .hide-sm, .th-ico { display: none; }
  .summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .summary__item { padding: 12px; }
  .summary__value { font-size: 16px; }
  .segmented { display: grid; grid-template-columns: 1fr 1fr; }
  .segmented span { font-size: 12.5px; padding: 8px 6px; }
  .bar { grid-template-columns: 1fr auto; }
  .bar__track { grid-column: 1 / -1; grid-row: 2; }
  .kv dd { font-size: 17px; }
  .segmented span { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
