:root {
  color-scheme: light;
  --bg: #f5f9ff;
  --surface: #ffffff;
  --surface-soft: #eaf3ff;
  --text: #102033;
  --muted: #5d7088;
  --primary: #0b6eea;
  --primary-strong: #0758bc;
  --primary-soft: #dcecff;
  --border: #cfe0f5;
  --danger: #c93333;
  --success: #0a7f62;
  --shadow: 0 22px 60px rgba(14, 77, 146, 0.14);
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0f1f35;
  --surface-soft: #142941;
  --text: #edf6ff;
  --muted: #a9bbd2;
  --primary: #57a6ff;
  --primary-strong: #86bdff;
  --primary-soft: #14345a;
  --border: #25425f;
  --danger: #ff8a8a;
  --success: #7ce2c3;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 154px;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(46, 138, 255, 0.14), transparent 34rem),
    linear-gradient(180deg, var(--bg) 0%, var(--surface-soft) 100%);
  transition: background-color 220ms ease, color 220ms ease;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary), white 20%);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid color-mix(in srgb, var(--border), transparent 35%);
  background: color-mix(in srgb, var(--bg), transparent 8%);
  backdrop-filter: blur(16px);
}

.nav {
  width: min(1120px, calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(11, 110, 234, 0.22);
}

.nav-actions,
.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links a,
.footer-links a {
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  transition: color 160ms ease;
}

.nav-links a:hover,
.footer-links a:hover {
  color: var(--primary-strong);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(14, 77, 146, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, background-color 220ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.toggle-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: inset -5px -4px 0 color-mix(in srgb, var(--surface), transparent 25%);
}

.calculator-nav {
  text-align: center;
  border-top: 1px solid color-mix(in srgb, var(--border), transparent 35%);
  background: color-mix(in srgb, var(--bg), transparent 10%);
}

.calculator-nav-inner {
  position: relative;
  max-width: 100%;
  display: inline-flex;
  vertical-align: middle;
  text-align: left;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.calculator-nav-inner::-webkit-scrollbar {
  display: none;
}

/* Safely enforce trailing space at the end of the scroll on mobile devices */
.calculator-nav-inner::after {
  content: "";
  padding-right: 4px;
}

.calc-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(14, 77, 146, 0.04);
  transition: all 180ms ease;
}

.calc-tab svg {
  fill: none;
}

.calc-tab:hover {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary), var(--border) 40%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(11, 110, 234, 0.08);
}

.calc-tab.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary), transparent 60%);
  box-shadow: 0 4px 12px rgba(11, 110, 234, 0.12);
}

[data-theme="dark"] .calc-tab.active {
  color: var(--primary);
  border-color: var(--primary);
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  align-items: center;
  gap: 36px;
  padding: 64px 0 42px;
}

.hero-content {
  animation: riseIn 560ms ease both;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 18px;
  font-size: 4rem;
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

/* Lightweight CSS illustration keeps the page visual without adding image downloads. */
.chem-visual {
  position: relative;
  min-height: 330px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface), transparent 2%), var(--primary-soft)),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(11, 110, 234, 0.07) 35px 36px);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: floatIn 680ms ease both;
}

.chem-visual::before {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px dashed color-mix(in srgb, var(--primary), transparent 54%);
  border-radius: 8px;
}

.orbital {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 250px;
  height: 92px;
  border: 2px solid color-mix(in srgb, var(--primary), transparent 32%);
  border-radius: 50%;
  transform-origin: center;
}

.orbital-one {
  transform: translate(-50%, -50%) rotate(28deg);
}

.orbital-two {
  transform: translate(-50%, -50%) rotate(-28deg);
}

.molecule-node {
  position: absolute;
  width: 68px;
  height: 68px;
  border: 10px solid color-mix(in srgb, var(--primary), white 72%);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 16px 36px rgba(11, 110, 234, 0.28);
}

.node-a {
  left: 26%;
  top: 34%;
}

.node-b {
  left: 54%;
  top: 26%;
  width: 86px;
  height: 86px;
}

.node-c {
  left: 48%;
  top: 58%;
  width: 58px;
  height: 58px;
}

.bond {
  position: absolute;
  height: 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary), white 36%);
  transform-origin: left center;
}

.bond-one {
  left: 38%;
  top: 44%;
  width: 118px;
  transform: rotate(-15deg);
}

.bond-two {
  left: 55%;
  top: 56%;
  width: 92px;
  transform: rotate(90deg);
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
  margin-bottom: 64px;
}

.molarity-suite {
  margin-bottom: 64px;
}

.peptide-suite {
  margin-bottom: 64px;
  display: none !important;
}

.molarity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.calculator-card,
.formula-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, background-color 220ms ease;
}

.calculator-card {
  padding: 28px;
}

.calculator-card:hover,
.formula-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--primary), var(--border) 35%);
}

.card-heading h2,
.section-heading h2 {
  margin-bottom: 0;
  font-size: 2rem;
}

.calculator-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.field {
  display: grid;
  gap: 8px;
}

label {
  color: var(--text);
  font-weight: 700;
}

label span {
  color: var(--muted);
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 220ms ease;
}

select {
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
}

.input-with-select {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 10px;
}

.unit-field input {
  min-width: 0;
}

input:hover {
  border-color: color-mix(in srgb, var(--primary), var(--border) 48%);
}

input.valid {
  border-color: color-mix(in srgb, var(--success), var(--border) 40%);
}

input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger), transparent 84%);
}

.error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 600;
}

.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 2px;
}

.primary-button,
.secondary-button,
.copy-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.primary-button {
  border: 0;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), #1397ff);
  box-shadow: 0 14px 28px rgba(11, 110, 234, 0.24);
}

.primary-button:hover,
.secondary-button:hover,
.copy-button:hover {
  transform: translateY(-1px);
}

.secondary-button,
.copy-button {
  border: 1px solid var(--border);
  color: var(--primary-strong);
  background: var(--surface);
}

.ghost-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background-color 160ms ease, color 160ms ease;
}

.ghost-button:hover {
  background: var(--surface-soft);
  color: var(--danger);
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--border), var(--primary) 20%);
  color: var(--surface);
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
  cursor: help;
  position: relative;
  vertical-align: middle;
}

@media (hover: hover) {
  .tooltip-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 220px;
    background: var(--text);
    color: var(--surface);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
  }
  
  .tooltip-icon:hover::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text);
  }
}

.result-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  margin-top: 24px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--primary), var(--border) 58%);
  border-radius: 18px;
  background: var(--primary-soft);
}

.result-panel span {
  color: var(--muted);
  font-weight: 800;
}

.result-panel strong {
  grid-column: 1;
  color: var(--text);
  font-size: 2.2rem;
  line-height: 1;
}

.copy-button {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 116px;
  padding: 0 14px;
}

.copy-button.copied {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success), var(--border) 35%);
}

.formula-section,
.seo-section,
.faq-section {
  margin-bottom: 64px;
}

.section-heading {
  margin-bottom: 22px;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.formula-card {
  padding: 24px;
}

.formula-card h3 {
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.formula-card p {
  color: var(--muted);
  line-height: 1.7;
}

code {
  display: block;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  white-space: normal;
  line-height: 1.5;
}

.seo-content {
  max-width: 920px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.85;
}

.seo-content p {
  margin-bottom: 18px;
}

.seo-content p:last-child {
  margin-bottom: 0;
}

.faq-list {
  display: grid;
  gap: 12px;
}

.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: 0 12px 32px rgba(14, 77, 146, 0.08);
  overflow: hidden;
}

.faq-list summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 20px;
  color: var(--text);
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--primary);
  font-weight: 800;
}

.faq-list details[open] summary::after {
  content: "-";
}

.faq-list p {
  margin: 0;
  padding: 0 20px 20px;
  color: var(--muted);
  line-height: 1.75;
}

.page-hero {
  padding: 70px 0 34px;
}

.page-hero h1 {
  max-width: 820px;
}

.page-hero p {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.content-section {
  max-width: 920px;
  margin-bottom: 64px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: var(--shadow);
}

.content-section h2 {
  margin: 30px 0 10px;
  font-size: 1.35rem;
}

.content-section h2:first-child {
  margin-top: 0;
}

.content-section p,
.content-section li {
  color: var(--muted);
  line-height: 1.8;
}

.content-section ul {
  padding-left: 22px;
}

.contact-grid,
.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.text-link {
  color: var(--primary-strong);
  font-weight: 800;
}

.primary-button.text-link {
  color: #ffffff;
}

.secondary-button.text-link {
  color: var(--primary-strong);
}

.error-code {
  margin: 0 0 12px;
  color: var(--primary);
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
}

.site-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 38px;
  color: var(--muted);
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 18px;
  margin-top: 14px;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media print {
  .theme-toggle, .nav, .site-footer, .calculator-nav, .button-row, .copy-button {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 900px) {
  .hero,
  .formula-grid,
  .molarity-grid {
    grid-template-columns: 1fr;
  }

  .calculator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    padding-top: 48px;
  }

  h1 {
    font-size: 3.1rem;
  }

  .chem-visual {
    min-height: 280px;
  }
}

@media (max-width: 620px) {
  .nav {
    width: min(100% - 24px, 1120px);
    min-height: 68px;
  }

  #themeToggleText {
    display: none;
  }

  html {
    /* Account for the taller stacked mobile header */
    scroll-padding-top: 210px;
  }

  .nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }

  .nav-links {
    gap: 12px;
    font-size: 0.9rem;
  }

  main,
  .site-footer {
    width: min(100% - 24px, 1120px);
  }

  .hero {
    min-height: auto;
    padding: 38px 0 28px;
  }

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

  h1 {
    font-size: 2.35rem;
  }

  .card-heading h2,
  .section-heading h2 {
    font-size: 1.45rem;
  }

  .result-panel strong {
    font-size: 1.7rem;
  }

  .calculator-card,
  .formula-card,
  .content-section {
    padding: 20px;
  }

  .button-row,
  .result-panel,
  .input-with-select {
    grid-template-columns: 1fr;
  }

  .copy-button,
  .result-panel strong {
    grid-column: auto;
    grid-row: auto;
  }

  .secondary-button {
    width: 100%;
  }

  .chem-visual {
    min-height: 220px;
  }

  .orbital {
    width: 200px;
  }

  .molecule-node {
    transform: scale(0.82);
  }
}
