.mga-page-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 34px auto 48px;
  padding: 38px 48px 48px;
}

.mga-panel {
  border: 1px solid rgba(196, 71, 127, 0.14);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 38px rgba(91, 48, 67, 0.08);
}

.mga-page-header {
  padding: 2px 0 0;
}

.mga-page-header h1 {
  margin: 0;
  color: #8f2248;
  font-size: clamp(1.8rem, 3vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}

.mga-panel-heading p {
  max-width: 780px;
  margin: 0;
  color: #705b64;
  line-height: 1.7;
}

.mga-section-kicker {
  margin: 0;
  color: #a02f61;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.mga-reference-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin: 1rem 0 1.4rem;
}

.mga-reference-nav a {
  padding: .5rem .8rem;
  border: 1px solid #e6d5df;
  border-radius: 7px;
  color: #8f2248;
  font-weight: 600;
}

.mga-reference-nav a[aria-current="page"] {
  border-color: #8f2248;
  background: #8f2248;
  color: #fff;
}

.mga-intro-card {
  margin: 0 0 28px;
  color: #705b64;
  line-height: 1.5;
  text-align: center;
}

.mga-dataset-line {
  display: block;
  margin-top: 4px;
  color: #80717a;
  font-size: 0.88rem;
}

.mga-dataset-name {
  color: #8f2248;
  font-weight: 700;
}

.mga-panel {
  margin-top: 0;
  padding: 28px;
  border-radius: 18px;
}

.mga-table-panel {
  margin-top: 18px;
}

.mga-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.mga-panel-heading h2 {
  margin: 2px 0 7px;
  color: #52283a;
  font-size: 1.42rem;
  font-weight: 800;
}

.mga-figure-launch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 16px;
  border: 1px solid #9b2955;
  border-radius: 10px;
  background: #9b2955;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(143, 34, 72, 0.18);
}

.mga-figure-launch:hover,
.mga-figure-launch:focus-visible {
  border-color: #771a40;
  background: #771a40;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(143, 34, 72, 0.24);
}

.mga-figure-launch:focus-visible {
  outline: 3px solid rgba(196, 71, 127, 0.35);
  outline-offset: 3px;
}

.mga-track-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  color: #6b4a58;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mga-track-control select {
  width: 100%;
  height: 44px;
  padding: 7px 38px 7px 13px;
  border: 1px solid rgba(178, 93, 130, 0.34);
  border-radius: 11px;
  background-color: rgba(255, 255, 255, 0.96);
  color: #3f2932;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: normal;
  outline: 0;
  text-transform: none;
}

.mga-track-control select:focus {
  border-color: #c4477f;
  box-shadow: 0 0 0 3px rgba(196, 71, 127, 0.12);
  outline: 0;
}

.mga-chart-controls {
  display: grid;
  box-sizing: border-box;
  flex: 0 0 336px;
  gap: 13px;
  width: 336px;
  padding: 0;
  background: transparent;
}

.mga-control-label {
  display: block;
  margin: 0;
  color: #6b4a58;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mga-zoom-control {
  display: grid;
  gap: 7px;
}

.mga-zoom-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(178, 93, 130, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 2px rgba(83, 41, 59, 0.035);
}

.mga-zoom-buttons button,
.mga-zoom-buttons output {
  display: flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: #5a3142;
  font: inherit;
  font-weight: 800;
}

.mga-zoom-buttons button {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(174, 105, 135, 0.25);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 2px 6px rgba(81, 39, 57, 0.07);
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.mga-zoom-buttons .mga-zoom-icon {
  flex: 0 0 36px;
  width: 36px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.mga-zoom-buttons button:hover:not(:disabled),
.mga-zoom-buttons button:focus-visible {
  background: #fff0f6;
  border-color: rgba(196, 71, 127, 0.48);
  color: #a02f61;
  box-shadow: 0 0 0 3px rgba(196, 71, 127, 0.16), 0 2px 6px rgba(81, 39, 57, 0.07);
  outline: 0;
  transform: translateY(-1px);
}

.mga-zoom-buttons button:disabled {
  background: rgba(249, 244, 246, 0.8);
  box-shadow: none;
  color: #c3adb6;
  cursor: not-allowed;
  transform: none;
}

.mga-zoom-buttons output {
  flex: 1 1 70px;
  min-width: 62px;
  border: 0;
  color: #6d5360;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.mga-zoom-buttons .mga-zoom-reset {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 5px;
  padding: 0 11px;
  font-size: 0.76rem;
}

.mga-reset-icon {
  font-size: 1rem;
  line-height: 1;
}

.mga-link-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: #654b57;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}

.mga-link-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.mga-toggle-track {
  position: relative;
  display: inline-block;
  flex: 0 0 36px;
  width: 36px;
  height: 20px;
  border: 1px solid #cfb8c2;
  border-radius: 999px;
  background: #dfd1d7;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.mga-toggle-track > span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(67, 32, 47, 0.2);
  transition: transform 140ms ease;
}

.mga-link-control input:checked + .mga-toggle-track {
  border-color: #b83d73;
  background: #c4477f;
}

.mga-link-control input:checked + .mga-toggle-track > span {
  transform: translateX(16px);
}

.mga-link-control input:focus-visible + .mga-toggle-track {
  box-shadow: 0 0 0 3px rgba(196, 71, 127, 0.17);
}

.mga-link-control input:disabled + .mga-toggle-track {
  opacity: 0.5;
}

.mga-link-control:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.68;
}

.mga-chart-stage {
  position: relative;
  height: 760px;
  overflow: auto;
  border: 1px solid #ead9e0;
  border-radius: 14px;
  background:
    radial-gradient(circle at center, rgba(196, 71, 127, 0.04), transparent 58%),
    linear-gradient(rgba(108, 70, 87, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108, 70, 87, 0.025) 1px, transparent 1px),
    #fdfcfd;
  background-size: auto, 24px 24px, 24px 24px, auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72), inset 0 12px 34px rgba(75, 36, 53, 0.025);
  outline: 0;
  overscroll-behavior: contain;
  scrollbar-color: #d4a9bc #f8eef2;
  scrollbar-width: thin;
}

.mga-chart-stage:focus-visible {
  border-color: #c885a2;
  box-shadow: 0 0 0 3px rgba(196, 71, 127, 0.11), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.mga-chart-surface {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  align-items: center;
  justify-content: center;
}

.mga-circos {
  width: 100%;
  height: 100%;
  flex: 0 0 auto;
  min-width: 1px;
  margin: 0;
  cursor: crosshair;
}

.mga-circos svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mga-svg-item {
  cursor: pointer;
}

.mga-svg-item:hover > path:first-of-type {
  stroke: #2f1d25;
  stroke-width: 1.4;
  filter: drop-shadow(0 0 3px rgba(55, 31, 42, .3));
}

.mga-svg-tooltip {
  position: fixed;
  z-index: 1100;
  max-width: min(390px, calc(100vw - 28px));
  padding: 10px 13px;
  border-radius: 9px;
  background: rgba(52, 34, 43, 0.97);
  box-shadow: 0 12px 30px rgba(40, 20, 30, 0.24);
  color: #fff;
  font-size: 0.86rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  pointer-events: none;
  white-space: pre-line;
}

.mga-svg-tooltip[hidden] {
  display: none;
}

.mga-chart-stage.is-pannable,
.mga-chart-stage.is-pannable .mga-circos {
  cursor: grab;
}

.mga-chart-stage.is-dragging,
.mga-chart-stage.is-dragging .mga-circos {
  cursor: grabbing;
  user-select: none;
}

.mga-chart-loading,
.mga-chart-error {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 30px;
  background: rgba(253, 252, 253, 0.94);
  color: #735462;
  font-weight: 700;
  text-align: center;
}

.mga-chart-error {
  color: #9b294f;
}

.mga-chart-error[hidden] {
  display: none;
}

.mga-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #efd6e1;
  border-top-color: #c4477f;
  border-radius: 50%;
  animation: mga-spin 0.8s linear infinite;
}

@keyframes mga-spin {
  to { transform: rotate(360deg); }
}

.mga-chart-note {
  margin-top: 12px;
  color: #76616a;
  font-size: 0.82rem;
  line-height: 1.6;
}

.mga-chart-help {
  margin: 3px 0 0;
  color: #9a7d89;
  font-size: 0.75rem;
  line-height: 1.5;
}

.mga-legend-details {
  margin-top: 12px;
  color: #654b57;
}

.mga-legend-details summary {
  width: fit-content;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
}

.mga-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 7px 13px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid #eee1e6;
}

.mga-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #5f4b54;
  font-size: 0.78rem;
  font-weight: 700;
}

.mga-legend-swatch {
  width: 13px;
  height: 13px;
  border: 1px solid rgba(53, 35, 43, 0.14);
  border-radius: 3px;
}

.mga-table-progress {
  margin-bottom: 18px;
}

.mga-table-progress-copy {
  margin-bottom: 6px;
  color: #735462;
  font-size: 0.82rem;
  font-weight: 700;
}

.mga-table-progress .progress {
  height: 8px;
  border-radius: 999px;
  background: #f2e5ea;
}

.mga-table-progress .progress-bar {
  background-color: #c4477f;
}

.mga-table-wrap {
  width: 100%;
  overflow: hidden;
}

.mga-table-panel .dataTables_wrapper {
  width: 100%;
}

.mga-table-panel table.dataTable {
  width: 100% !important;
  border-collapse: collapse !important;
}

.mga-table-panel table.dataTable thead th {
  padding: 10px 12px;
  border-bottom: 2px solid #d69ab4;
  background: #fff8fb;
  color: #6d2947;
  font-size: 0.8rem;
  text-align: left;
}

.mga-table-panel table.dataTable tbody td {
  padding: 9px 12px;
  color: #3f3036;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.mga-table-panel .dataTables_filter input,
.mga-table-panel .dataTables_length select {
  border: 1px solid #d9b8c6;
  border-radius: 7px;
  background: #fff;
}

.mga-table-error {
  margin-top: 16px;
  padding: 12px 15px;
  border: 1px solid #ecc2d0;
  border-radius: 8px;
  background: #fff3f6;
  color: #922847;
  font-size: 0.88rem;
  font-weight: 700;
}

.mga-tooltip-title {
  margin-bottom: 5px;
  color: #ffd8e8;
  font-size: 0.86rem;
  font-weight: 800;
}

.mga-tooltip-examples {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.mga-tooltip-example {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.mga-tooltip-hint {
  margin-top: 6px;
  color: #e8bdcf;
  font-size: 0.7rem;
}

@media (max-width: 900px) {
  .mga-page-shell {
    width: min(100% - 20px, 1540px);
    margin-top: 20px;
    padding: 30px 28px 36px;
  }

  .mga-panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .mga-track-control {
    flex-basis: auto;
    width: 100%;
  }

  .mga-chart-controls {
    flex-basis: auto;
    width: 100%;
  }

  .mga-chart-stage {
    height: 610px;
  }
}

@media (max-width: 560px) {
  .mga-page-shell {
    padding: 25px 16px 30px;
  }

  .mga-panel {
    padding: 21px 17px;
    border-radius: 14px;
  }

  .mga-page-header h1 {
    font-size: 1.7rem;
  }

  .mga-intro-card {
    margin-bottom: 26px;
  }

  .mga-chart-stage {
    height: 500px;
  }

  .mga-zoom-buttons {
    gap: 5px;
  }

  .mga-zoom-buttons .mga-zoom-reset {
    padding: 0 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mga-spinner {
    animation: none;
  }
}
