:root {
  --pdb-ink: #14231f;
  --pdb-paper: #eef4f1;
  --pdb-accent: #0f766e;
  --bs-primary: #0f766e;
  --bs-primary-rgb: 15, 118, 110;
  --bs-link-color: #115e59;
  --bs-link-hover-color: #0f766e;
  --bs-body-color: #14231f;
  --bs-body-bg: #eef4f1;
  --bs-modal-bg: #ffffff;
  --bs-border-radius: 0.9rem;
  --bs-font-sans-serif: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  color: var(--pdb-ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 118, 110, 0.14), transparent 55%),
    radial-gradient(900px 480px at 90% 0%, rgba(30, 90, 120, 0.12), transparent 50%),
    linear-gradient(180deg, #f7faf8 0%, var(--pdb-paper) 45%, #d9e6df 100%);
}

.site-footer {
  background: rgba(255, 252, 247, 0.55);
  border-color: rgba(20, 35, 31, 0.12) !important;
}

.site-footer a:hover {
  color: var(--pdb-accent) !important;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--pdb-ink);
  line-height: 1;
}

.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  flex: 0 0 auto;
  display: block;
}

.brand-text {
  line-height: 1.1;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  border-bottom: 1px solid rgba(20, 35, 31, 0.12);
  padding-bottom: 0.65rem;
}

.site-nav-link {
  color: rgba(20, 35, 31, 0.62);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
}

.site-nav-link:hover {
  color: var(--pdb-ink);
}

.site-nav-link.is-active {
  color: var(--pdb-accent);
  border-bottom-color: var(--pdb-accent);
}

.product-list {
  border: 1px solid rgba(20, 35, 31, 0.12);
  border-radius: var(--bs-border-radius);
  background: rgba(255, 252, 247, 0.82);
  overflow: hidden;
}

.product-list-head .product-count-col,
.product-count {
  min-width: 5.5rem;
  text-align: center;
}

a.product-count {
  color: #fff;
  background-color: var(--pdb-accent);
  border: 1px solid var(--pdb-accent);
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

a.product-count:hover {
  color: #fff;
  background-color: #0d9488;
  border-color: #0d9488;
  transform: translateY(-1px);
}

.product-row + .product-row {
  border-top: 1px solid rgba(20, 35, 31, 0.08);
}

.product-row:hover {
  background: rgba(15, 118, 110, 0.06);
}

.hero-brand {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.hero-lead {
  max-width: 36rem;
  font-size: 1.05rem;
}

.search-form .input-group {
  flex-wrap: nowrap;
}

.search-form .input-group > .form-control {
  min-width: 0;
}

.search-form .input-group > :first-child {
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
}

.search-form .input-group > :last-child {
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
}

@media (max-width: 575.98px) {
  .search-form .input-group {
    flex-wrap: wrap;
  }

  .search-form .input-group > .form-control {
    flex: 1 1 100%;
    width: 100%;
    border-radius: 999px !important;
    margin-bottom: 0.5rem;
  }

  .search-form .input-group > .btn {
    flex: 1 1 auto;
  }

  .search-form .input-group > .btn:first-of-type {
    border-top-left-radius: 999px;
    border-bottom-left-radius: 999px;
  }

  .search-form .input-group > :last-child {
    border-top-right-radius: 999px;
    border-bottom-right-radius: 999px;
  }
}

.tag-sidebar-col {
  min-width: 0;
}

.tag-sidebar {
  padding: 1rem;
  border: 1px solid rgba(20, 35, 31, 0.12);
  border-radius: var(--bs-border-radius);
  background: rgba(255, 252, 247, 0.82);
  min-height: 100%;
  min-width: 0;
  overflow: hidden;
}

.tag-sidebar-list {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.tag-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  border-radius: 0.55rem;
  color: inherit;
  text-decoration: none;
  font-size: 0.92rem;
}

.tag-link > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-link > span:last-child {
  flex: 0 0 auto;
}

.tag-link:hover,
.tag-link-active {
  background: rgba(15, 118, 110, 0.12);
  color: #115e59;
}

.tag-link-disabled {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}

.tag-link-disabled:hover {
  background: transparent;
  color: inherit;
}

.booru-card {
  overflow: hidden;
  border-color: rgba(20, 35, 31, 0.12);
  background: rgba(255, 252, 247, 0.88);
  box-shadow: 0 14px 28px rgba(20, 35, 31, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.booru-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(20, 35, 31, 0.1);
}

.structure-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 2;
  min-height: 10rem;
  padding: 0.75rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(20, 35, 31, 0.08);
  text-decoration: none;
}

.structure-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-tag-row {
  z-index: 2;
}

.detail-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.detail-header {
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(20, 35, 31, 0.1);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: 0.55rem;
}

.detail-action {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bs-link-color);
  font-size: 0.9rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
}

.detail-action:hover:not(:disabled) {
  color: var(--bs-link-hover-color);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.detail-action:disabled {
  color: rgba(20, 35, 31, 0.38);
  cursor: not-allowed;
  text-decoration: none;
}

.detail-section-label {
  margin: 0 0 0.55rem;
  color: rgba(20, 35, 31, 0.55);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-similar .similarity-score {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--pdb-accent);
}

.detail-structure {
  overflow: hidden;
  border: 1px solid rgba(20, 35, 31, 0.1);
  border-radius: var(--bs-border-radius);
  background: #ffffff;
  box-shadow: 0 14px 28px rgba(20, 35, 31, 0.05);
}

.detail-structure img {
  display: block;
  width: 100%;
  height: auto;
}

.detail-notes-body {
  color: var(--pdb-ink);
  line-height: 1.55;
  white-space: pre-wrap;
}

.detail-precursor-list {
  padding-left: 1.1rem;
}

.detail-precursor-list li + li {
  margin-top: 0.25rem;
}

.copy-value {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: 100%;
  margin: 0;
  padding: 0.1rem 0.25rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: copy;
  transition: background-color 140ms ease, color 140ms ease;
}

.copy-value-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.copy-value-icon {
  flex: 0 0 auto;
  width: 0.72rem;
  height: 0.76rem;
  margin-top: 0.28em;
  background-color: currentColor;
  opacity: 0.45;
  -webkit-mask: url("../img/copy.svg") center / contain no-repeat;
  mask: url("../img/copy.svg") center / contain no-repeat;
  transition: opacity 140ms ease;
}

.copy-value:hover {
  background: rgba(15, 118, 110, 0.12);
  color: #115e59;
}

.copy-value:hover .copy-value-icon,
.copy-value.is-copied .copy-value-icon {
  opacity: 0.85;
}

.copy-value.is-copied {
  background: rgba(15, 118, 110, 0.18);
  color: #0f766e;
}

.btn-primary {
  --bs-btn-bg: var(--pdb-accent);
  --bs-btn-border-color: var(--pdb-accent);
  --bs-btn-hover-bg: #115e59;
  --bs-btn-hover-border-color: #115e59;
  --bs-btn-active-bg: #115e59;
  --bs-btn-active-border-color: #115e59;
}

/* Ketcher modal: solid panel + iframe that truly fills the body */
#ketcherModal {
  --bs-modal-bg: #ffffff;
}

#ketcherModal .modal-content.ketcher-modal-content {
  height: 90vh;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  background-color: #ffffff !important;
  opacity: 1 !important;
  border: none;
  overflow: hidden;
}

#ketcherModal .modal-header,
#ketcherModal .modal-footer {
  flex: 0 0 auto;
  background-color: #ffffff;
}

#ketcherModal .modal-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: calc(90vh - 8rem);
  padding: 0 !important;
  background-color: #ffffff !important;
  overflow: hidden;
}

#ketcherModal .ketcher-frame {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.manage-form {
  max-width: 36rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid rgba(20, 35, 31, 0.12);
  border-radius: var(--bs-border-radius);
  background: rgba(255, 252, 247, 0.82);
}

.entity-autocomplete {
  position: relative;
}

.entity-autocomplete-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  max-height: 16rem;
  overflow: auto;
  border: 1px solid rgba(20, 35, 31, 0.14);
  border-radius: 0.65rem;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(20, 35, 31, 0.12);
}

.entity-autocomplete-option {
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.entity-autocomplete-option:hover,
.entity-autocomplete-option.is-active {
  background: rgba(15, 118, 110, 0.12);
  color: #115e59;
}

.external-link-icon {
  margin-left: 0.15em;
  font-size: 0.8em;
  opacity: 0.6;
}

.detail-xref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
}

.detail-xref {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.detail-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.detail-name-list li {
  padding: 0.1rem 0.5rem;
  border: 1px solid rgba(20, 35, 31, 0.12);
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.6);
  overflow-wrap: anywhere;
}

.detail-names-more {
  margin-top: 0.4rem;
}

.detail-names-more summary {
  width: fit-content;
  color: var(--bs-link-color);
  font-size: 0.85rem;
  cursor: pointer;
}

.detail-names-more[open] summary {
  margin-bottom: 0.3rem;
}

.card-search-match {
  overflow: hidden;
  font-style: italic;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Nav links on the left, language switcher on the right, one shared divider */
.site-nav-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  border-bottom: 1px solid rgba(20, 35, 31, 0.12);
  padding-bottom: 0.65rem;
}

.site-nav-row .site-nav {
  border-bottom: 0;
  padding-bottom: 0;
}

.language-switch {
  display: inline-flex;
  margin: 0;
  padding: 0.15rem;
  border: 1px solid rgba(20, 35, 31, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

.language-switch-option {
  min-width: 2.4rem;
  padding: 0.15rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(20, 35, 31, 0.62);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.language-switch-option:hover {
  color: var(--pdb-ink);
}

.language-switch-option:focus-visible {
  outline: 2px solid var(--pdb-accent);
  outline-offset: 1px;
}

.language-switch-option.is-active {
  background: var(--pdb-accent);
  color: #ffffff;
  cursor: default;
}
