:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #1d2320;
  --muted: #64706a;
  --panel: #ffffff;
  --line: #d7ded7;
  --soft: #edf2ef;
  --active: #234f68;
  --active-ink: #ffffff;
  --v1: #547aa5;
  --v2: #6f9f7a;
  --v3: #b9894b;
  --v4: #8a72a9;
  --v5: #c06d65;
  --v6: #4f9d9a;
  --d: #9b7b42;
  --j: #5a8a65;
  --c: #6d7783;
  --selected: #d94f30;
  --shadow: 0 14px 36px rgba(35, 45, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 8%, rgba(84, 122, 165, 0.10), transparent 26rem),
    linear-gradient(135deg, #f7f8f5 0%, #eef3f1 52%, #f8f2ec 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

button {
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover,
select:hover,
input:hover {
  border-color: #aebbae;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(35, 79, 104, 0.25);
  outline-offset: 2px;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.toolbar,
.browser-panel,
.info-panel,
.sequence-panel,
.notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 2.5vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1rem;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.toggle-group,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.toggle-group.small button {
  min-height: 32px;
}

.segmented.active,
button.active {
  background: var(--active);
  border-color: var(--active);
  color: var(--active-ink);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr) auto minmax(220px, 320px);
  gap: 14px;
  align-items: end;
  margin-top: 16px;
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

select,
input[type="search"] {
  min-height: 38px;
  padding: 0 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--active);
}

.browser-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  margin-top: 16px;
}

.browser-panel,
.info-panel,
.sequence-panel,
.notes {
  padding: 16px;
}

.browser-head,
.sequence-head,
.mode-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.view-label {
  margin: 0;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  white-space: nowrap;
}

.minimap {
  position: relative;
  height: 48px;
  margin: 8px 0 12px;
  border-block: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(237, 242, 239, 0.75), rgba(255, 255, 255, 0.55));
  overflow: hidden;
}

.mini-segment,
.mini-window {
  position: absolute;
  top: 13px;
  height: 18px;
  border-radius: 3px;
}

.mini-window {
  top: 4px;
  height: 38px;
  border: 2px solid var(--selected);
  background: rgba(217, 79, 48, 0.10);
  pointer-events: none;
}

.track-wrap {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: stretch;
}

.pan-button {
  min-height: 260px;
  padding: 0;
  font-size: 1.5rem;
}

.track {
  position: relative;
  min-height: 360px;
  border-block: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(100, 112, 106, 0.12) 1px, transparent 1px) 0 0 / 10% 100%,
    linear-gradient(180deg, rgba(237, 242, 239, 0.45), rgba(255, 255, 255, 0.55));
  overflow: hidden;
}

.axis,
.lane-label,
.tick,
.gene,
.zoom-gene,
.codon-mark {
  position: absolute;
}

.axis {
  left: 0;
  right: 0;
  top: 42px;
  height: 2px;
  background: var(--line);
}

.tick {
  top: 31px;
  width: 1px;
  height: 18px;
  background: #a9b4ad;
}

.tick span {
  position: absolute;
  top: -23px;
  left: -28px;
  width: 56px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  text-align: center;
}

.lane-label {
  left: 8px;
  width: 74px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.gene {
  border: 1px solid rgba(29, 35, 32, 0.16);
  border-radius: 5px;
  color: #17201c;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 4px;
  overflow: hidden;
  padding: 0 5px;
  text-align: center;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.gene button {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gene:hover,
.gene.selected {
  z-index: 4;
  border-color: var(--selected);
  box-shadow: 0 0 0 3px rgba(217, 79, 48, 0.16);
  transform: translateY(-1px);
}

.gene.too-small button {
  color: transparent;
}

.family-1 { background: color-mix(in srgb, var(--v1) 58%, white); }
.family-2 { background: color-mix(in srgb, var(--v2) 58%, white); }
.family-3 { background: color-mix(in srgb, var(--v3) 58%, white); }
.family-4 { background: color-mix(in srgb, var(--v4) 58%, white); }
.family-5 { background: color-mix(in srgb, var(--v5) 58%, white); }
.family-6 { background: color-mix(in srgb, var(--v6) 58%, white); }
.kind-D { background: color-mix(in srgb, var(--d) 62%, white); }
.kind-J { background: color-mix(in srgb, var(--j) 62%, white); }
.kind-C { background: color-mix(in srgb, var(--c) 50%, white); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend-item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(29, 35, 32, 0.16);
  border-radius: 4px;
}

.summary {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.summary-box,
.mode-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.summary-box strong {
  display: block;
  margin-bottom: 3px;
}

.pill-row,
.choice-grid,
.assembly-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.switch {
  display: inline-flex;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.guided-step {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.choice-grid button {
  min-height: 34px;
}

.junction-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.junction-controls input {
  width: 100%;
  min-height: 36px;
  padding: 0 9px;
  text-transform: uppercase;
}

.assembly {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.assembly-piece {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 4px 8px;
  background: var(--panel);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
}

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

.sequence-viewer {
  min-height: 150px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow-x: auto;
  padding: 12px;
}

.nt-line,
.codon-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.nt,
.codon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
}

.codon {
  display: grid;
  min-width: 60px;
  padding: 4px;
  text-align: center;
}

.aa {
  color: var(--active);
  font-weight: 700;
}

.region-tag {
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.zoom-gene {
  height: 44px;
  border: 1px solid rgba(29, 35, 32, 0.16);
  border-radius: 5px;
  overflow: hidden;
}

.codon-mark {
  top: 0;
  bottom: 0;
  border-right: 1px solid rgba(29, 35, 32, 0.16);
}

.codon-mark span {
  position: absolute;
  top: 10px;
  left: 2px;
  right: 2px;
  overflow: hidden;
  color: #17201c;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.68rem;
  text-align: center;
}

.notes {
  margin-top: 16px;
  color: var(--muted);
}

.notes p {
  max-width: 1100px;
  margin-bottom: 8px;
}

@media (max-width: 980px) {
  .toolbar,
  .browser-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .browser-head,
  .sequence-head {
    align-items: stretch;
    flex-direction: column;
  }

  .track-wrap {
    grid-template-columns: 1fr;
  }

  .pan-button {
    min-height: 36px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .toolbar,
  .browser-panel,
  .info-panel,
  .sequence-panel,
  .notes,
  .topbar {
    padding: 12px;
  }

  .junction-controls {
    grid-template-columns: 1fr;
  }

  .track {
    min-height: 410px;
  }
}
