:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d232b;
  --muted: #5f6b78;
  --line: #d9dee4;
  --accent: #2f6fd6;
  --error: #b3261e;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-size: 13px;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
}

.appbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 12px;
  background: #1f3a5f;
  color: #fff;
}

.brand {
  margin-right: 12px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

#menus {
  display: flex;
  gap: 2px;
}

.menu-button {
  font: inherit;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  flex: none;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-button:hover,
.menu-button.active {
  background: rgba(255, 255, 255, 0.16);
}

.menu-button[hidden],
.menu-button.burger {
  display: none;
}

.menu-button::after {
  content: '▾';
  margin-left: 4px;
  opacity: 0.6;
  font-size: 10px;
}

#stats {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#find-form {
  flex: none;
  margin-left: 12px;
}

#find,
#locate {
  width: 160px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font: inherit;
}

#locate-form {
  display: flex;
  flex: none;
  align-items: center;
  margin-left: 8px;
}

#locate {
  width: 230px;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}

#locate-form button {
  height: 28px;
  padding: 0 7px;
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#locate-form button:hover {
  background: rgba(255, 255, 255, 0.28);
}

#locate-back {
  border-radius: 4px 0 0 4px;
}

#locate-forward {
  border-radius: 0 4px 4px 0;
}

#find::placeholder {
  color: rgba(255, 255, 255, 0.72);
}

#find:focus {
  outline: 2px solid #9cc3ff;
  background: #fff;
  color: var(--ink);
}

#find:focus::placeholder {
  color: var(--muted);
}

.menu {
  position: fixed;
  z-index: 20;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 4px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
}

.menu[hidden] {
  display: none;
}

.menu .menu {
  max-height: calc(100vh - 16px);
}

.menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 8px 6px 14px;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.menu button:hover:not(:disabled),
.menu button[aria-expanded='true'] {
  background: #eef3fb;
}

.menu button:disabled {
  color: var(--muted);
  opacity: 0.6;
  cursor: default;
}

.menu .label {
  display: flex;
  flex-direction: column;
}

.menu svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: auto;
  fill: var(--muted);
}

.menu svg.on {
  fill: var(--accent);
}

.menu small {
  max-width: 340px;
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.menu button[hidden] {
  display: none;
}

.menu-search {
  display: block;
  width: calc(100% - 16px);
  height: 28px;
  margin: 4px 8px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.menu-header {
  padding: 8px 14px 2px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.menu hr {
  margin: 4px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 20px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

dialog h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0 0;
  color: var(--muted);
}

dialog input {
  font: inherit;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
}

dialog section[hidden],
dialog label[hidden] {
  display: none;
}

dialog select {
  font: inherit;
  height: 30px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

#genome-results {
  max-height: 220px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

#genome-results:empty {
  display: none;
}

#genome-results .genome {
  display: flex;
  width: 100%;
  height: auto;
  flex-direction: column;
  align-items: flex-start;
  padding: 5px 8px;
  border: 1px solid transparent;
  background: none;
  text-align: left;
}

#genome-results .genome:hover {
  background: #eef3fb;
}

#genome-results .genome[aria-pressed='true'] {
  border-color: var(--accent);
  background: #eef3fb;
}

#genome-results small {
  color: var(--muted);
  font-size: 13px;
}

dialog label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

dialog label.check input {
  height: auto;
}

#reference-contigs label {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}

dialog details {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

dialog summary {
  font-weight: 600;
  cursor: pointer;
}

#hub-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

#hub-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

#hub-list span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hub-list small {
  color: var(--muted);
  font-size: 13px;
}

#hub-list button {
  height: auto;
  padding: 2px 8px;
  border: 0;
  background: none;
  color: var(--muted);
}

#highlight-dialog {
  width: min(520px, calc(100vw - 32px));
  margin: 48px 8px auto auto;
}

#highlight-dialog::backdrop {
  background: none;
}

#highlight-rows {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
}

#highlight-rows .head {
  color: var(--muted);
  font-size: 13px;
}

#highlight-rows strong {
  overflow-wrap: anywhere;
}

#layout-dialog {
  width: min(320px, calc(100vw - 32px));
  margin: 48px 8px auto auto;
}

#layout-dialog::backdrop {
  background: none;
}

#layout-dialog label.slider span {
  display: flex;
  justify-content: space-between;
}

#layout-dialog small {
  color: var(--muted);
}

#layout-dialog output {
  color: var(--ink);
}

#layout-dialog input[type='range'] {
  height: auto;
  padding: 0;
  border: 0;
}

dialog .hint {
  margin: 4px 0 0;
  color: var(--muted);
}

dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
}

dialog section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

#recent-list {
  margin: 4px -8px 0;
  padding: 0;
  list-style: none;
}

#recent-list li {
  display: flex;
  align-items: center;
}

#recent-list button {
  height: auto;
  border: 0;
  background: none;
}

#recent-list .reopen {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  padding: 4px 8px;
  text-align: left;
}

#recent-list .reopen:hover {
  background: #eef3fb;
}

#recent-list .reopen span,
#recent-list small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#recent-list small {
  color: var(--muted);
  font-size: 13px;
}

#recent-list .forget {
  padding: 4px 8px;
  color: var(--muted);
}

dialog h3 {
  margin: 0;
  font-size: 15px;
}

dialog .controls {
  display: grid;
  grid-template-columns: 13em 1fr;
  gap: 4px 16px;
  margin: 8px 0 0;
}

dialog .controls dt {
  font-weight: 600;
}

dialog .controls dd {
  margin: 0;
  color: var(--muted);
}

kbd {
  font: inherit;
  font-size: 13px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

dialog section > button {
  margin-top: 8px;
}

dialog .inline {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

dialog .inline input {
  flex: 1;
  min-width: 0;
}

dialog button,
#empty button,
#back {
  font: inherit;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

dialog button.primary,
#empty button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main {
  position: relative;
  touch-action: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: grab;
  touch-action: none;
}

#tube,
#hover,
.facet-hover {
  pointer-events: none;
}

#tube[hidden] {
  display: none;
}

main.busy canvas,
main.busy #overlay-svg,
main.busy #overlay-html {
  opacity: 0.35;
  transition: opacity 0.2s;
}

canvas.dragging {
  cursor: grabbing;
}

#overlay-svg {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: hidden;
  font-family: sans-serif;
}

#overlay-svg .clickable {
  pointer-events: auto;
  cursor: pointer;
}

#overlay-svg .gene .chip {
  pointer-events: auto;
  cursor: help;
}

#overlay-html {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.row-label {
  position: absolute;
  left: 6px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.82);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 16px;
  white-space: nowrap;
}

.size-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.78);
  padding: 0 3px;
  border-radius: 3px;
  font-size: 10px;
  line-height: 13px;
  white-space: nowrap;
}

.size-label.deletion {
  color: #18181c;
  font-weight: 600;
}

#facets {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  background: #fff;
  overflow: hidden;
}

#facets[hidden] {
  display: none;
}

.facet canvas {
  position: static;
}

.facet-title {
  display: block;
  box-sizing: border-box;
  padding: 2px 6px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 11px;
  line-height: 15px;
  text-align: left;
  cursor: pointer;
}

main.faceted #back {
  left: auto;
  right: 8px;
}

#legends {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
}

.legend {
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 15px;
  white-space: nowrap;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.swatch.bar {
  height: 8px;
}

.swatch-exon {
  flex: none;
}

.swatch.gene-box {
  box-sizing: border-box;
  border: 1.5px solid #1c1c22;
  border-radius: 0;
}

.swatch.walk {
  flex: none;
  height: 8px;
}

.swatch.walk.scale {
  width: 48px;
}

.walk-key {
  margin-bottom: 2px;
}

.legend-title {
  font-weight: 600;
}

.legend-note {
  color: #666;
  font-style: italic;
}

.ramp {
  min-width: 90px;
  height: 8px;
  border-radius: 2px;
}

.ramp-ends {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

#back {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(255, 255, 255, 0.92);
}

#walk-strip {
  position: relative;
  border-top: 1px solid var(--line);
  background: #fff;
}

#walk-strip[hidden],
#strip-tip[hidden] {
  display: none;
}

#strip-svg {
  display: block;
  cursor: pointer;
  font-family: sans-serif;
}

#strip-tip {
  position: absolute;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 11px;
  white-space: nowrap;
}

#strip-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  padding: 0 8px 6px;
  font-size: 11px;
  color: #333;
}

#strip-key .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  padding: 0;
  background: none;
}

#back[hidden],
#info[hidden],
#loading[hidden],
#toast[hidden],
#caption[hidden],
#hint[hidden],
#empty[hidden] {
  display: none;
}

#info {
  position: absolute;
  bottom: 8px;
  right: 8px;
  max-width: min(420px, calc(100% - 16px));
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 17px;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#info.interactive {
  pointer-events: auto;
}

#details[hidden] {
  display: none;
}

#pane {
  --details-width: min(300px, calc(100% - 16px));
}

#details {
  position: absolute;
  top: 8px;
  right: 8px;
  width: var(--details-width);
  max-height: calc(100% - 16px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 8px 12px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  line-height: 18px;
}

#pane.details-open #legends {
  right: calc(var(--details-width) + 16px);
}

#details header {
  display: flex;
  align-items: center;
  gap: 8px;
}

#details h2 {
  flex: 1;
  margin: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

#details h3 {
  margin: 10px 0 2px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#details h3 small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
}

#details p {
  margin: 4px 0;
}

#details small,
#details .none,
#details .hint {
  color: var(--muted);
}

#details .hint {
  font-size: 12px;
}

#details ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#details li {
  padding: 2px 0;
}

#details .walks li,
#details li:has(code) {
  display: flex;
  flex-direction: column;
}

#details li:has(code) {
  flex-direction: row;
  flex-wrap: wrap;
  column-gap: 6px;
  align-items: baseline;
}

#details code {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 11px;
}

#details .walk-actions {
  display: flex;
  gap: 12px;
}

#details button {
  font: inherit;
  cursor: pointer;
}

#details [data-close] {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
}

.details-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 2px;
}

.details-actions button {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
}

.details-actions a,
#details .node-link {
  color: var(--accent);
}

#details .node-link {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.info-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.info-actions a {
  color: #9cc3ff;
}

.info-actions button,
#toast button,
#hint button {
  margin-left: auto;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

#toast-actions {
  display: flex;
  flex: none;
  gap: 4px;
}

#toast #toast-actions button {
  margin: 0;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-weight: 600;
}

#toast #toast-actions button:hover {
  background: #eef3fb;
}

.corner {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: min(460px, calc(100% - 16px));
  pointer-events: none;
}

.zoom {
  display: flex;
  pointer-events: auto;
}

.zoom button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.zoom button:first-child {
  border-radius: 6px 0 0 6px;
}

.zoom button:last-child {
  border-radius: 0 6px 6px 0;
}

.zoom button + button {
  border-left: 0;
}

#caption,
#hint {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 16px;
}

#caption {
  display: flex;
  flex-direction: column;
}

#caption span {
  color: var(--muted);
}

#hint {
  display: flex;
  gap: 8px;
  color: var(--muted);
  pointer-events: auto;
}

#hint.dismissed {
  display: none;
}

#hint .for-touch {
  display: none;
}

#hint.no-bubbles .for-bubbles {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  #hint .for-mouse {
    display: none;
  }

  #hint .for-touch {
    display: inline;
  }
}

#loading,
#toast {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px 6px 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 5;
}

#loading-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#loading button {
  font: inherit;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  cursor: pointer;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#toast.error {
  color: var(--error);
  border-color: var(--error);
}

#empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  pointer-events: none;
}

#empty button {
  pointer-events: auto;
}

body.dropping main {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
}

body.dropping main::after {
  content: 'Drop to open';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
}

@media (max-width: 720px) {
  .appbar {
    padding: 0 4px;
  }
  .menu-button {
    display: none;
  }
  .menu-button.burger {
    display: block;
    font-size: 18px;
  }
  .menu-button.burger::after {
    content: none;
  }
  .brand {
    display: none;
  }
  #stats {
    display: none;
  }
  #find-form {
    margin-left: auto;
  }
  #find {
    width: 104px;
  }
  #locate-form {
    display: none;
  }
  #details {
    top: auto;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 55%;
  }
  #pane.details-open #legends {
    right: 6px;
  }
  #pane.details-open .corner {
    display: none;
  }
}

.facet-canvas {
  position: relative;
  line-height: 0;
}

.facet .facet-hover {
  position: absolute;
  left: 0;
  top: 0;
}
