:root {
  --bg: #f5f0e8;
  --paper: #fffaf2;
  --ink: #1f2a21;
  --muted: #5f665f;
  --line: #d8cdbb;
  --accent: #b5542f;
  --accent-dark: #8f3f20;
  --ok: #2c7a4b;
  --warn: #a66a13;
  --bad: #a53434;
  --shadow: 0 18px 60px rgba(44, 30, 12, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(181, 84, 47, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f3ec 0%, var(--bg) 100%);
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.page {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.top-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.72);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
}

.top-nav a:hover {
  background: white;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(24, 19, 14, 0.55);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.modal-card {
  width: min(680px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.compact {
  margin-bottom: 20px;
}

.hero {
  padding: 24px 0 12px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
}

h2 {
  font-size: clamp(1.6rem, 2vw, 2.2rem);
}

h3 {
  font-size: 1.1rem;
}

.lede {
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-top: 20px;
}

.info-band {
  background:
    linear-gradient(135deg, rgba(181, 84, 47, 0.08), rgba(255, 250, 242, 0.95)),
    var(--paper);
}

.info-grid,
.explainers {
  display: grid;
  gap: 14px;
}

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

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

.info-card,
.explain-card,
.contact-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
}

.info-card p,
.explain-card p,
.contact-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.prs-animation-panel {
  overflow: hidden;
}

.prs-animation-shell {
  margin-top: 16px;
}

.prs-stage {
  border-radius: 18px;
  padding: 30px 28px 24px;
  border: 1px solid rgba(216, 205, 187, 0.32);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(181, 84, 47, 0.22), transparent 32%),
    radial-gradient(circle at bottom right, rgba(152, 124, 72, 0.18), transparent 28%),
    linear-gradient(180deg, #221712 0%, #2b1e17 100%);
  box-shadow: 0 12px 36px rgba(35, 20, 9, 0.26);
}

.prs-stage-heading {
  margin: 0 0 20px;
  text-align: center;
  color: #fff6ea;
  font-size: 1.12rem;
  font-weight: 600;
}

.prs-svg {
  width: 100%;
  height: auto;
  overflow: visible;
  display: block;
}

.prs-step-group {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.prs-item {
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.prs-variants circle {
  fill: none;
  stroke: #d8b16a;
  stroke-width: 2;
  filter: url(#prs-glow);
}

.prs-variants text {
  fill: #f0d5a4;
  font-size: 14px;
  font-family: Georgia, "Times New Roman", serif;
}

.prs-item-1 {
  transition-delay: 0s;
}

.prs-item-2 {
  transition-delay: 0.15s;
}

.prs-item-3 {
  transition-delay: 0.3s;
}

.prs-ellipsis {
  fill: rgba(255, 246, 234, 0.62);
  font-size: 24px;
}

.prs-beta {
  fill: #d98f4b;
  font-size: 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  transform: scale(0);
  transform-origin: center;
  transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.prs-multiply {
  fill: #fff6ea;
  font-size: 14px;
}

.prs-genotype {
  fill: #97b88d;
  font-size: 14px;
  font-family: Georgia, "Times New Roman", serif;
}

.prs-sigma {
  fill: #fff6ea;
  font-size: 60px;
  font-family: Georgia, "Times New Roman", serif;
  transform: scale(0);
  transform-origin: 380px 80px;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
}

.prs-sigma-caption {
  fill: rgba(255, 246, 234, 0.7);
  font-size: 12px;
  font-family: Georgia, "Times New Roman", serif;
}

.prs-formula-beta,
.prs-formula-sub,
.prs-formula-times,
.prs-formula-genotype {
  fill: #fff6ea;
  font-family: Georgia, "Times New Roman", serif;
}

.prs-formula-beta {
  fill: #d98f4b;
  font-size: 18px;
  font-style: italic;
}

.prs-formula-sub {
  font-size: 12px;
}

.prs-formula-times {
  font-size: 18px;
}

.prs-formula-genotype {
  fill: #97b88d;
  font-size: 18px;
}

.prs-fraction-line {
  stroke: #fff6ea;
  stroke-width: 2;
}

.prs-ancestry-label {
  fill: #d8b16a;
  font-size: 14px;
  font-family: Georgia, "Times New Roman", serif;
}

.prs-arrow-path {
  fill: none;
  stroke: #b5542f;
  stroke-width: 2;
  marker-end: url(#prs-arrow);
}

.prs-result-box {
  fill: #b5542f;
  filter: url(#prs-glow-strong);
  transform: scale(0);
  transform-origin: 55px 177px;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
}

.prs-result-text {
  fill: #fff6ea;
  font-size: 18px;
  font-weight: 700;
}

.prs-stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.prs-animation-copy {
  text-align: center;
  margin-top: 24px;
  min-height: 24px;
}

.prs-step-label {
  margin: 0;
  color: rgba(255, 246, 234, 0.8);
  font-size: 0.92rem;
}

.prs-dots {
  display: inline-flex;
  gap: 10px;
}

.prs-dot {
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d3c7b7;
  cursor: pointer;
  transform: none;
}

.prs-dot.active {
  background: var(--accent);
}

.prs-replay-button {
  padding: 8px 16px;
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid rgba(255, 246, 234, 0.34);
  color: rgba(255, 246, 234, 0.82);
}

.prs-replay-button:hover {
  border-color: #d8b16a;
  color: #d8b16a;
  background: transparent;
  transform: none;
}

.prs-stage[data-step="1"] .prs-variants,
.prs-stage[data-step="2"] .prs-variants,
.prs-stage[data-step="3"] .prs-variants,
.prs-stage[data-step="4"] .prs-variants,
.prs-stage[data-step="5"] .prs-variants,
.prs-stage[data-step="6"] .prs-variants {
  opacity: 1;
}

.prs-stage[data-step="1"] .prs-variants .prs-item,
.prs-stage[data-step="2"] .prs-variants .prs-item,
.prs-stage[data-step="3"] .prs-variants .prs-item,
.prs-stage[data-step="4"] .prs-variants .prs-item,
.prs-stage[data-step="5"] .prs-variants .prs-item,
.prs-stage[data-step="6"] .prs-variants .prs-item {
  opacity: 1;
  transform: translateY(0);
}

.prs-stage[data-step="0"] .prs-variants .prs-item {
  transform: translateY(20px);
}

.prs-stage[data-step="2"] .prs-betas,
.prs-stage[data-step="3"] .prs-betas,
.prs-stage[data-step="4"] .prs-betas,
.prs-stage[data-step="5"] .prs-betas,
.prs-stage[data-step="6"] .prs-betas {
  opacity: 1;
}

.prs-stage[data-step="2"] .prs-betas .prs-item,
.prs-stage[data-step="3"] .prs-betas .prs-item,
.prs-stage[data-step="4"] .prs-betas .prs-item,
.prs-stage[data-step="5"] .prs-betas .prs-item,
.prs-stage[data-step="6"] .prs-betas .prs-item {
  opacity: 1;
  transform: scale(1);
}

.prs-stage[data-step="3"] .prs-genotypes,
.prs-stage[data-step="4"] .prs-genotypes,
.prs-stage[data-step="5"] .prs-genotypes,
.prs-stage[data-step="6"] .prs-genotypes {
  opacity: 1;
}

.prs-stage[data-step="3"] .prs-genotypes .prs-item,
.prs-stage[data-step="4"] .prs-genotypes .prs-item,
.prs-stage[data-step="5"] .prs-genotypes .prs-item,
.prs-stage[data-step="6"] .prs-genotypes .prs-item {
  opacity: 1;
  transform: translateY(0);
}

.prs-stage[data-step="0"] .prs-genotypes .prs-item,
.prs-stage[data-step="1"] .prs-genotypes .prs-item,
.prs-stage[data-step="2"] .prs-genotypes .prs-item {
  transform: translateY(10px);
}

.prs-stage[data-step="4"] .prs-summation,
.prs-stage[data-step="5"] .prs-summation,
.prs-stage[data-step="6"] .prs-summation {
  opacity: 1;
}

.prs-stage[data-step="4"] .prs-sigma,
.prs-stage[data-step="5"] .prs-sigma,
.prs-stage[data-step="6"] .prs-sigma {
  transform: scale(1);
}

.prs-stage[data-step="5"] .prs-normalization,
.prs-stage[data-step="6"] .prs-normalization {
  opacity: 1;
}

.prs-stage[data-step="6"] .prs-result {
  opacity: 1;
}

.prs-stage[data-step="6"] .prs-result-box {
  transform: scale(1);
}

.method-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.7;
}

.method-list li + li {
  margin-top: 10px;
}

.bibliography-panel .references-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  align-items: start;
}

.contact-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

.subtle-panel {
  padding-top: 18px;
  padding-bottom: 18px;
}

.upload-form {
  display: grid;
  gap: 16px;
}

.resource-callout {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(181, 84, 47, 0.08), rgba(255, 255, 255, 0.82));
}

.resource-callout-copy {
  display: grid;
  gap: 6px;
}

.resource-callout-copy h2,
.resource-callout-copy p {
  margin: 0;
}

.resource-callout-copy p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.field-stack {
  display: grid;
  gap: 8px;
}

.field-stack input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font: inherit;
}

.dropzone {
  display: block;
  padding: 28px;
  border: 2px dashed var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(181, 84, 47, 0.06), rgba(255, 255, 255, 0.65));
  cursor: pointer;
}

.dropzone input {
  display: block;
  width: 100%;
  margin-bottom: 16px;
}

.dropzone-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
}

.dropzone-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

button {
  width: fit-content;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 13px 18px;
  background: var(--ink);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  background: #111811;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button:disabled {
  background: #baa999;
  cursor: wait;
  transform: none;
}

.job-card {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.job-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.job-label,
.summary-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.job-message {
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #ece3d6;
}

.pill.running,
.pill.queued,
.pill.uploaded {
  color: var(--warn);
}

.pill.finished,
.pill.ok {
  color: var(--ok);
}

.pill.error,
.pill.no_matches {
  color: var(--bad);
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.results-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
}

.summary-box,
.insight-card,
.study-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.summary-box strong,
.insight-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.15rem;
}

.insight-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 12px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.interpretation-body {
  display: grid;
  gap: 10px;
}

.interpretation-body p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}

.references-list {
  display: grid;
  gap: 12px;
}

.reference-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.reference-citation {
  font-weight: 700;
  line-height: 1.5;
}

.reference-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.reference-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.reference-link:hover {
  text-decoration: underline;
}

.study-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.study-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.study-name {
  font-weight: 700;
  word-break: break-word;
}

.study-percentile {
  font-size: 1.45rem;
  font-weight: 700;
}

.study-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.meter {
  width: 100%;
  height: 10px;
  background: #efe5d7;
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #98c7d3 0%, #d8b16a 52%, #b5542f 100%);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover {
  background: rgba(181, 84, 47, 0.05);
}

.error-box {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(165, 52, 52, 0.28);
  border-radius: 14px;
  background: rgba(165, 52, 52, 0.08);
  color: var(--bad);
}

.hidden {
  display: none;
}

@media (max-width: 760px) {
  .page {
    width: min(100vw - 20px, 1080px);
    padding-top: 22px;
  }

  .top-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
  }

  .top-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .top-nav::-webkit-scrollbar {
    display: none;
  }

  .top-nav a {
    flex: 0 0 auto;
    padding: 9px 13px;
    font-size: 0.88rem;
  }

  .panel {
    padding: 18px;
    border-radius: 18px;
  }

  .hero {
    padding: 10px 0 4px;
  }

  h1 {
    max-width: 10ch;
    font-size: clamp(2.35rem, 11vw, 3.5rem);
    line-height: 0.96;
  }

  .lede {
    max-width: 34ch;
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .section-head p {
    max-width: 36ch;
  }

  .results-header {
    flex-direction: column;
    align-items: start;
  }

  .results-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .resource-callout {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid {
    width: 100%;
  }

  .insights-grid,
  .study-cards,
  .info-grid,
  .explainers,
  .prs-stage,
  .contact-grid,
  .bibliography-panel .references-list {
    grid-template-columns: 1fr;
  }

  .prs-stage-visual,
  .prs-stage {
    padding: 24px 18px 20px;
  }
}

@media (max-width: 560px) {
  .page {
    width: calc(100vw - 16px);
    padding-top: 16px;
  }

  .top-bar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .top-nav {
    gap: 8px;
  }

  .top-nav a {
    padding: 8px 12px;
    font-size: 0.84rem;
  }

  h1 {
    max-width: 9ch;
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .lede {
    max-width: 30ch;
    font-size: 0.95rem;
  }

  .panel {
    margin-top: 16px;
    padding: 16px;
  }

  .info-card,
  .explain-card,
  .contact-card,
  .reference-card {
    padding: 16px;
  }

  .prs-stage {
    padding: 20px 14px 18px;
  }

  .prs-stage-heading {
    font-size: 1rem;
  }

  .prs-stage-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}
