:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #5f6c7b;
  --border: #d8dee6;
  --primary: #234e54;
  --primary-hover: #1a3d42;
  --accent: #6c9364;
  --accent-soft: #e8f2e4;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --layout-max: 1100px;
  --layout-width: min(var(--layout-max), calc(100% - 2rem));
  --nav-bg: #ffffff;
  --nav-text: var(--text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

a {
  color: var(--primary);
}

.site-header {
  position: relative;
  z-index: 50;
  margin-bottom: 1.5rem;
}

.banner {
  height: 260px;
  background: url("/static/images/proteinBanner.png") center bottom / cover no-repeat;
}

.site-nav {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0.75rem 0;
  background: var(--nav-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  z-index: 30;
}

.site-nav-inner {
  width: var(--layout-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  line-height: 1;
  background: var(--nav-bg);
  text-decoration: none;
  padding: 0.35rem 0;
}

.nav-brand-text {
  font: inherit;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--nav-text);
  letter-spacing: normal;
}

.nav-brand-vienna,
.nav-brand-ptm {
  color: inherit;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.nav-links a {
  text-decoration: none;
  font-weight: 600;
  color: var(--nav-text);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--nav-text);
  cursor: pointer;
  padding: 0;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 10rem;
  padding-top: 0.35rem;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 60;
}

.nav-dropdown-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 0.85rem;
  white-space: nowrap;
  color: var(--nav-text);
  font-weight: 600;
  text-decoration: none;
}

.nav-dropdown-menu a:hover {
  background: #eef6f9;
}

.nav-dropdown.is-open .nav-dropdown-menu,
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.site-main {
  position: relative;
  z-index: 1;
  width: var(--layout-width);
  margin: 0 auto 3rem;
  display: grid;
  gap: 1.25rem;
}

.site-footer {
  margin-top: 2.5rem;
}

.footer-main {
  background: var(--primary);
  color: #fff;
  padding: 3.5rem 0 0.75rem;
}

.footer-main-inner {
  width: var(--layout-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem 2.5rem;
}

.footer-col h2 {
  margin: 0 0 1.1rem;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.3;
}

.footer-col p {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.92);
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li + li {
  margin-top: 0.15rem;
}

.footer-link {
  display: inline-block;
  padding: 0.2rem 0;
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.5;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-meta {
  margin-top: 3rem;
  padding-top: 0.25rem;
}

.footer-meta ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-meta .footer-link {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  --card-pad-x: 1.5rem;
  padding: 1.25rem var(--card-pad-x);
}

.hero h1,
.page-heading h1 {
  margin-top: 0;
  line-height: 1.2;
}

.lead {
  color: var(--muted);
}

.card .lead,
.card > p,
.card > h2 {
  max-width: none;
}

.hero.card > p {
  color: var(--text);
}

.hero .lead {
  max-width: none;
}

.stack-form,
.options-grid {
  display: grid;
  gap: 1rem;
}

.options-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field span {
  font-weight: 600;
  font-size: 0.95rem;
}

.field.is-inactive {
  opacity: 0.55;
}

.field.is-inactive input {
  cursor: not-allowed;
  background: #f3f4f6;
}

input[type="text"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--border);
}

.form-actions,
.download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border-color: var(--border);
}

.btn-icon {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.page-heading {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  align-items: stretch;
}

.viewer-shell {
  min-width: 0;
  display: flex;
}

.viewer_3Dmoljs,
.structure-viewer,
.result-viewer {
  position: relative;
  width: 100%;
  height: 320px;
  min-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f8fafb;
}

.result-viewer {
  height: 480px;
  min-height: 480px;
}

.viewer_3Dmoljs canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.bead-chains {
  display: grid;
  gap: 1.25rem;
}

.chain-row {
  display: grid;
  gap: 0.5rem;
}

.chain-label {
  font-weight: 700;
  color: var(--primary);
}

.bead-track {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: #f8fafb;
  border: 1px dashed var(--border);
}

.bead {
  min-width: 3rem;
  padding: 0.45rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: default;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.bead.interactive {
  cursor: pointer;
}

.bead.interactive:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 94, 114, 0.15);
}

.bead.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #23401d;
}

.bead.inert {
  opacity: 0.45;
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.error-card {
  border-color: #f3c0bb;
  background: var(--danger-bg);
}

.success-card {
  border-color: #b9ddb0;
  background: #f3faf1;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  overscroll-behavior: contain;
}

html.overlay-open,
body.overlay-open {
  overflow: hidden;
}

body.overlay-open {
  position: fixed;
  width: 100%;
}

.overlay[hidden] {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.overlay-panel {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100% - 2rem));
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem 1.25rem;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.overlay-header h3 {
  margin: 0;
}

.overlay-options {
  display: grid;
  gap: 0.5rem;
  max-height: 320px;
  overflow: auto;
}

.overlay-body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.9fr);
  gap: 1rem;
  align-items: stretch;
}

.overlay-main {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.overlay-context {
  color: var(--muted);
  margin: 0;
}

.overlay-option {
  display: grid;
  gap: 0.15rem;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.overlay-option-code {
  font-weight: 700;
  color: var(--primary);
}

.overlay-option-name {
  color: var(--text);
  line-height: 1.35;
}

.overlay-option-type {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: capitalize;
}

.overlay-option:hover,
.overlay-option.active {
  border-color: var(--primary);
  background: #eef6f9;
}

.overlay-panel-wide {
  width: min(860px, calc(100% - 2rem));
}

.overlay-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overlay-structure-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overlay-structure-panel:has(.overlay-structure-placeholder:not([hidden])) {
  justify-content: center;
}

.overlay-structure-block {
  display: grid;
  gap: 0.25rem;
}

.overlay-ptm-code {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.overlay-structure-block:not(.is-ready) .overlay-ptm-code {
  display: none;
}

.overlay-residue-arrow {
  font-weight: 400;
  color: var(--muted);
}

.overlay-structure-placeholder {
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.45;
}

.overlay-structure-placeholder:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1rem;
}

.overlay-structure-image {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.overlay-structure-block.is-ready .overlay-structure-image {
  display: block;
  min-height: 220px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.overlay-structure-block .overlay-links {
  margin-top: -0.15rem;
}

.overlay-links {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}

.overlay-links a {
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}

.overlay-links a:hover {
  text-decoration: underline;
}

.overlay-links-empty {
  margin: 0;
  width: 100%;
  padding: 0.25rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.overlay-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

.overlay-footer-actions {
  display: flex;
  gap: 0.5rem;
}

.citations ul {
  padding-left: 1.2rem;
}

.paper-list {
  list-style: none;
  padding: 0;
  margin: 0 calc(-1 * var(--card-pad-x)) 1.5rem;
  display: grid;
  gap: 0;
  border-block: 1px solid var(--border);
}

.paper-item {
  padding: 1rem var(--card-pad-x);
  margin-inline: 0;
  border-inline: none;
  border-radius: 0;
  background: #f8fafb;
}

.paper-item + .paper-item {
  border-top: 1px solid var(--border);
}

.paper-item:first-child {
  border-top: none;
}

.paper-authors {
  color: var(--muted);
  font-size: 0.95rem;
}

.paper-title {
  font-weight: 600;
  line-height: 1.4;
}

.paper-journal {
  color: var(--text);
}

.paper-meta {
  color: var(--primary);
  font-size: 0.92rem;
  font-weight: 600;
}

.paper-links a {
  font-weight: 600;
  text-decoration: none;
}

.paper-links a:hover {
  text-decoration: underline;
}

.paper-item p {
  margin: 0 0 0.35rem;
}

.resource-links {
  list-style: none;
  padding: 0;
  margin: 0 calc(-1 * var(--card-pad-x)) 1.5rem;
  display: grid;
  gap: 0;
  border-block: 1px solid var(--border);
}

.resource-link-item {
  padding: 1rem var(--card-pad-x);
  margin-inline: 0;
  border-inline: none;
  border-radius: 0;
  background: #f8fafb;
}

.resource-link-item + .resource-link-item {
  border-top: 1px solid var(--border);
}

.resource-link-item h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.resource-link-item p {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.resource-link-item code {
  font-size: 0.9em;
  background: #eef2f6;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.tutorial-steps {
  padding-left: 1.25rem;
  display: grid;
  gap: 0.85rem;
}

.tutorial-steps li {
  line-height: 1.5;
}

.tutorial-step h3 {
  margin: 1.5rem 0 0.65rem;
  font-size: 1.05rem;
}

.tutorial-step ul {
  margin: 0.5rem 0 1rem;
  padding-left: 1.35rem;
  display: grid;
  gap: 0.45rem;
}

.tutorial-step ul li {
  line-height: 1.55;
}

.tutorial-figure {
  margin: 1.25rem 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f8fafc;
}

.tutorial-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.tutorial-figure figcaption {
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  line-height: 1.45;
}

.breadcrumb {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

@media (max-width: 820px) {
  .banner {
    height: 160px;
    background-image: none;
    background: linear-gradient(135deg, #d9edf4, #eef6f1);
  }

  .page-heading {
    grid-template-columns: 1fr;
  }

  .site-nav {
    position: static;
  }

  .site-nav-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .overlay-body {
    grid-template-columns: 1fr;
  }

  .overlay-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .overlay-footer-actions {
    justify-content: stretch;
  }

  .overlay-footer-actions .btn {
    flex: 1;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.admin-login-card {
  max-width: 420px;
}

.admin-error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin: 0 0 1rem;
}

.admin-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.admin-section-header h2 {
  margin: 0;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.admin-stat {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.admin-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--primary);
}

.admin-stat-label {
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: capitalize;
}

.admin-mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.admin-mod-grid h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.admin-chart-wrap {
  position: relative;
  height: 320px;
}

.admin-map {
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  font-weight: 600;
  background: #f8fafc;
}

.admin-table code {
  font-size: 0.88em;
}
