:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --line: #d6e1df;
  --line-strong: #b8c9c4;
  --text: #172522;
  --muted: #61706c;
  --accent: #0f766e;
  --accent-strong: #0a5c55;
  --accent-soft: #e7f5f1;
  --amber: #b7791f;
  --rose: #9f1239;
  --warn: #9a5b00;
  --code: #111827;
  --shadow: 0 14px 32px rgba(21, 38, 35, 0.1);
  --shadow-soft: 0 8px 18px rgba(21, 38, 35, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(231, 245, 241, 0.85) 0, rgba(244, 247, 246, 0) 300px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

button.primary:hover {
  background: var(--accent-strong);
  color: #ffffff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, #082421 0%, #0e5149 55%, #1d5f73 100%);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 12px 28px rgba(8, 36, 33, 0.2);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.title-block {
  min-width: 0;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.repo-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.repo-link:hover {
  border-color: rgba(216, 255, 245, 0.5);
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

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

h1 {
  max-width: 980px;
  font-size: 25px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 15px;
}

h3 {
  font-size: 18px;
}

.meta-line,
.result-summary,
.footer,
.muted {
  color: var(--muted);
}

.meta-line {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.11);
  color: #f1fbf8;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
}

.ec-coverage {
  margin-top: 8px;
  color: #d6eee8;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.rdkit-status {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #eef9f6;
  white-space: nowrap;
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.rdkit-status.ready {
  color: #d8fff5;
  border-color: rgba(216, 255, 245, 0.45);
}

.rdkit-status.error {
  color: #ffe4ec;
  border-color: rgba(159, 18, 57, 0.35);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.sidebar,
.content {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-height, 140px) + 20px);
  align-self: start;
  max-height: calc(100vh - var(--header-height, 140px) - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
  box-shadow: var(--shadow);
  padding: 16px;
}

.search-label {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
  font-size: 13px;
  color: #273a36;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input[type="search"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(21, 38, 35, 0.04);
}

input[type="search"]:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.12);
}

.browse-head,
.panel-title-row,
.template-title-row,
.load-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.browse-head {
  margin-top: 20px;
  margin-bottom: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.breadcrumbs button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  background: var(--panel-soft);
}

.browse-list {
  display: grid;
  gap: 9px;
}

.browse-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 10px 11px;
  text-align: left;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
}

.browse-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.browse-code,
.ec-code,
.template-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.browse-code {
  font-weight: 800;
  font-size: 13px;
}

.browse-name {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}

.count-stack {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.content {
  display: grid;
  gap: 14px;
}

.panel-head {
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-title-row {
  align-items: flex-start;
}

.panel-kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.panel-name {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.warn {
  border-color: rgba(154, 91, 0, 0.35);
  color: var(--warn);
  background: #fff7e6;
}

.result-summary {
  padding: 0 2px;
  font-size: 13px;
}

.ec-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.ec-result {
  min-height: 74px;
  padding: 11px 12px;
  text-align: left;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.ec-code {
  font-weight: 800;
}

.template-list {
  display: grid;
  gap: 14px;
}

.template-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.template-card:hover {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 18px 42px rgba(21, 38, 35, 0.14);
  transform: translateY(-2px);
}

.template-header {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.template-id {
  font-weight: 800;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.template-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.reaction-art {
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 10px;
  overflow-x: auto;
}

.full-reaction-art {
  min-height: 190px;
  background: #fbfefd;
}

.reaction-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.mol-cell {
  width: 230px;
  min-height: 160px;
  display: grid;
  align-items: center;
  justify-items: center;
}

.mol-cell svg {
  max-width: 230px;
  height: auto;
}

.operator {
  font-weight: 900;
  color: var(--muted);
}

.fallback-mol {
  width: 210px;
  min-height: 80px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 8px;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.smarts-block {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.smarts-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

pre {
  margin: 0;
  padding: 10px;
  color: var(--code);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-grid strong {
  color: var(--text);
  font-weight: 850;
}

.examples-block {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.examples-head,
.example-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.examples-head {
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.examples-head span:last-child {
  color: var(--muted);
  font-weight: 650;
}

.examples-list {
  display: grid;
  gap: 10px;
}

.example-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.example-protein {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

.example-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.uniprot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.uniprot-link {
  color: #046c72;
  font-weight: 800;
  text-decoration: none;
}

.uniprot-link:hover {
  color: #03484c;
  text-decoration: underline;
}

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

.example-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 10px;
  align-items: stretch;
}

.sequence-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.sequence-block pre {
  max-height: 150px;
  overflow: auto;
}

.example-facts {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.example-facts span {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.example-facts span::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--accent);
  vertical-align: 1px;
}

.example-substrate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.compact-value {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #ffffff;
}

.compact-value pre {
  max-height: 96px;
  overflow: auto;
}

.show-more-examples {
  justify-self: start;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  min-width: 54px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(15, 118, 110, 0.24);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-strong);
  color: #ffffff;
}

.load-row {
  justify-content: center;
  display: none;
  padding: 6px 0 20px;
}

.load-row.visible {
  display: flex;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--muted);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 24px 24px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .reaction-row {
    align-items: stretch;
  }

  .mol-cell {
    width: 190px;
  }

  .mol-cell svg {
    max-width: 190px;
  }

  .example-grid {
    grid-template-columns: 1fr;
  }
}
