:root {
  color-scheme: light;
  --bg-gradient-top: #f7f9fd;
  --bg-gradient-bottom: #edf2fb;
  --panel: #ffffff;
  --border: #d6dfef;
  --text: #14213d;
  --muted: #64748b;
  --primary: #166534;
  --primary-hover: #18713a;
  --danger: #b4233a;
  --surface-subtle: rgba(20, 33, 61, 0.04);
  --shadow: 0 18px 42px rgba(8, 15, 30, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-bottom) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.genome-browser-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 24px;
  background: url('../background.png') center center / cover no-repeat;
}

.portal-header {
  width: min(1180px, 100%);
  justify-self: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.portal-hero {
  position: relative;
  text-align: center;
}

.portal-hero-content {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 4px 16px 2px;
  color: #12203b;
}

.portal-hero h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: 0;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(150%);
  scrollbar-width: thin;
}

.portal-nav-item {
  flex: 0 0 auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid rgba(22, 101, 52, 0.18);
  border-radius: 8px;
  color: #17324d;
  background: rgba(255, 255, 255, 0.62);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.portal-nav-item:hover {
  border-color: rgba(22, 101, 52, 0.34);
  background: rgba(255, 255, 255, 0.84);
}

.portal-nav-item.active {
  border-color: rgba(22, 101, 52, 0.58);
  color: #ffffff;
  background: #166534;
  box-shadow: 0 10px 24px rgba(22, 101, 52, 0.28);
}

.portal-nav-item:disabled {
  cursor: default;
  opacity: 0.58;
  color: rgba(23, 50, 77, 0.72);
  background: rgba(255, 255, 255, 0.38);
}

.browser-main {
  width: min(1680px, 100%);
  min-height: 0;
  justify-self: center;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.query-panel {
  min-height: 0;
  border: 1px solid rgba(214, 223, 239, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 36px rgba(8, 15, 30, 0.1);
  backdrop-filter: blur(16px) saturate(140%);
}

.query-panel {
  align-self: start;
  padding: 16px;
  overflow: auto;
}

.viewer-panel {
  min-height: 0;
  align-self: start;
  display: grid;
  grid-template-rows: auto auto;
}

.query-heading {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.parent-page-link {
  display: inline-flex;
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.parent-page-link:hover {
  text-decoration: underline;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 23px;
  line-height: 1.15;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.query-form,
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.query-form {
  gap: 14px;
}

.field span {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(22, 101, 52, 0.55);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.14);
}

.query-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary,
.ghost {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
}

.primary {
  border: 1px solid var(--primary);
  color: #ffffff;
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-hover);
}

.ghost {
  border: 1px solid var(--border);
  color: #17324d;
  background: rgba(255, 255, 255, 0.76);
}

.ghost:hover {
  border-color: rgba(22, 101, 52, 0.34);
  background: rgba(255, 255, 255, 0.96);
}

.primary:disabled,
.ghost:disabled,
select:disabled,
input:disabled {
  cursor: default;
  opacity: 0.58;
}

.status-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(214, 223, 239, 0.92);
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.detail-list dt {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  color: #172033;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.viewer-toolbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 14px;
}

.browser-title {
  font-size: 17px;
  font-weight: 850;
  line-height: 1.2;
}

.browser-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.browser-stage {
  position: relative;
  min-width: 0;
}

#jbrowse-linear-genome-view {
  width: 100%;
}

.browser-empty {
  display: grid;
  place-items: center;
  min-height: 360px;
  height: clamp(380px, 48vh, 460px);
  padding: 24px;
  color: #475569;
  font-size: 14px;
  font-weight: 750;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
}

.browser-empty.is-error {
  color: var(--danger);
}

@media (max-width: 980px) {
  .genome-browser-app {
    padding: 16px;
  }

  .portal-hero h1 {
    font-size: 25px;
  }

  .browser-main {
    grid-template-columns: 1fr;
  }

  .browser-empty {
    height: clamp(360px, 56vh, 440px);
    min-height: 340px;
  }
}

@media (max-width: 640px) {
  .genome-browser-app {
    padding: 12px;
    gap: 12px;
  }

  .portal-hero h1 {
    font-size: 20px;
  }

  .portal-nav {
    min-height: 52px;
  }

  .portal-nav-item {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .query-actions,
  .detail-list div {
    grid-template-columns: 1fr;
  }

  .viewer-toolbar {
    min-height: 62px;
    padding: 12px;
  }

  .browser-empty {
    height: 52vh;
    min-height: 320px;
  }
}
