:root {
  --bg: #0c0f14;
  --bg-elevated: #141a24;
  --bg-input: #0e131c;
  --border: rgba(94, 234, 212, 0.12);
  --accent: #5eead4;
  --accent-dim: rgba(94, 234, 212, 0.55);
  --text: #e8edf5;
  --text-muted: #8b98ab;
  --danger: #f87171;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(94, 234, 212, 0.08), transparent),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(56, 189, 248, 0.06), transparent),
    var(--bg);
}

main {
  max-width: min(96vw, 1440px);
  margin: 0 auto;
  padding: 2rem 1.1rem 2.8rem;
}

header.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

header.hero h1 {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f0fdfa 0%, var(--accent) 55%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header.hero .hero-guide {
  max-width: 52rem;
  margin: 0.75rem auto 0;
  text-align: left;
}

header.hero .hero-guide p,
header.hero .hero-guide .hero-guide__lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.58;
}

header.hero .hero-guide--collapsible > .hero-guide__lead {
  margin-bottom: 0.65rem;
}

header.hero .hero-guide a:link,
header.hero .hero-guide a:visited {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.45);
  text-underline-offset: 0.15em;
}

header.hero .hero-guide__section {
  margin-top: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(20, 26, 36, 0.55);
}

header.hero .hero-guide__section summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  list-style: none;
}

header.hero .hero-guide__section summary::-webkit-details-marker {
  display: none;
}

header.hero .hero-guide__body {
  padding: 0 1rem 1rem;
}

header.hero .hero-guide__body p,
header.hero .hero-guide__body li {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

header.hero .hero-guide__body ul,
header.hero .hero-guide__body ol {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

header.hero .hero-guide__heading {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  color: var(--text);
}

header.hero .hero-guide__steps li + li {
  margin-top: 0.45rem;
}

header.hero .hero-guide__tip {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-left: 3px solid var(--accent-dim);
  background: rgba(94, 234, 212, 0.06);
  border-radius: 0 8px 8px 0;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.controls--wide {
  grid-template-columns: 1fr auto auto;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.text-input,
.select {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
}

.text-input:focus,
.select:focus {
  outline: 2px solid rgba(94, 234, 212, 0.35);
  outline-offset: 1px;
}

.btn {
  padding: 0.62rem 1rem;
  border: 1px solid rgba(94, 234, 212, 0.45);
  border-radius: 8px;
  background: rgba(94, 234, 212, 0.14);
  color: #f0fdfa;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(94, 234, 212, 0.22);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:disabled:hover {
  background: rgba(94, 234, 212, 0.14);
}

.btn.secondary {
  border-color: var(--border);
  background: rgba(14, 19, 28, 0.85);
  color: var(--text);
}

.btn.secondary:hover {
  border-color: rgba(94, 234, 212, 0.35);
}

.track-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.track-panel h2 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.motif-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.motif-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.motif-hint {
  margin: 0 0 0.65rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.motif-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.55rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.motif-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.motif-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  flex: 0 0 auto;
}

.motif-swatch--sense {
  background: #14b8a6;
}

.motif-swatch--antisense {
  background: #f472b6;
}

.track-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.track-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.motif-panel {
  margin-top: 0.85rem;
}

.motif-hint {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.motif-iupac-table {
  margin-top: 0.5rem;
  font-size: 0.88rem;
}

.motif-find-wrap {
  display: flex;
  align-items: flex-end;
}

.motif-find-wrap .btn {
  width: 100%;
}

.region-panel {
  margin-top: 0.85rem;
}

.region-list {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 19, 28, 0.55);
  max-height: 140px;
  overflow: auto;
}

.region-list-item,
.region-list-empty {
  padding: 0.5rem 0.75rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.region-list-item:first-child,
.region-list-empty:first-child {
  border-top: none;
}

.region-list-item {
  color: var(--text);
  cursor: context-menu;
}

.region-list-item:hover {
  background: rgba(239, 68, 68, 0.08);
}

.region-context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 170px;
  padding: 0.35rem;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 8px;
  background: #141a24;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.region-context-menu__btn {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fecaca;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.region-context-menu__btn:hover {
  background: rgba(239, 68, 68, 0.18);
}

.status {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  background: rgba(14, 19, 28, 0.65);
  border: 1px solid var(--border);
}

.status.error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

#igv-viewer {
  margin-top: 0.85rem;
  width: 100%;
  min-height: min(72vh, 880px);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.hub-about-author {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.hub-about-author a {
  color: var(--accent);
}

.encode-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.encode-modal[hidden] {
  display: none;
}

.encode-modal__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(4, 8, 14, 0.78);
  cursor: pointer;
}

.encode-modal__panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.1rem;
}

.encode-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.encode-modal__header h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.encode-modal__close {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 19, 28, 0.85);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
}

.encode-modal__close:hover {
  border-color: rgba(94, 234, 212, 0.35);
}

.encode-modal__lead {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.encode-modal__lead a {
  color: var(--accent);
}

.encode-modal__assembly {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  background: rgba(14, 19, 28, 0.65);
  border: 1px solid var(--border);
}

.encode-modal__hint {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.encode-modal__assembly--warn {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.encode-modal__filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.encode-modal__search-wrap {
  display: flex;
  align-items: flex-end;
}

.encode-modal__search-wrap .btn {
  width: 100%;
}

.encode-modal__status {
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  background: rgba(14, 19, 28, 0.65);
  border: 1px solid var(--border);
}

.encode-modal__status.error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.encode-results-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: min(46vh, 420px);
  background: rgba(14, 19, 28, 0.55);
}

.encode-results {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.encode-results th,
.encode-results td {
  padding: 0.55rem 0.65rem;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.encode-results thead th {
  border-top: none;
  position: sticky;
  top: 0;
  z-index: 1;
  background: #121822;
  color: var(--text-muted);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.encode-results__empty {
  color: var(--text-muted);
  text-align: center;
}

.encode-results .btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
}

@media (max-width: 720px) {
  .encode-modal__filters {
    grid-template-columns: 1fr;
  }

  .controls--wide {
    grid-template-columns: 1fr;
  }

  #igv-viewer {
    min-height: min(58vh, 560px);
  }
}
