:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #111827;
  --muted: #5f6b7a;
  --border: #d8dee8;
  --primary: #0f766e;
  --primary-strong: #0d5f59;
  --accent: #b45309;
  --danger: #dc2626;
  --success: #15803d;
  --shadow: 0 18px 42px rgba(17, 24, 39, 0.08);
  --soft-shadow: 0 8px 20px rgba(17, 24, 39, 0.06);
  --radius: 8px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #10151d;
  --text: #f4f7fb;
  --muted: #a8b3c2;
  --border: #2c3644;
  --primary: #2dd4bf;
  --primary-strong: #14b8a6;
  --accent: #f59e0b;
  --danger: #f87171;
  --success: #4ade80;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.26);
  --soft-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-links a,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

.nav-links a:hover,
.theme-toggle:hover {
  border-color: var(--primary);
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.language-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.language-globe {
  position: relative;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 999px;
}

.language-globe::before,
.language-globe::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid currentColor;
  border-top: 0;
  border-bottom: 0;
  border-radius: 999px;
}

.language-globe::after {
  inset: 7px 2px auto;
  height: 0;
  border-right: 0;
  border-left: 0;
  border-top: 1px solid currentColor;
}

.nav-links .language-option {
  min-height: 30px;
  padding: 5px 9px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
}

.nav-links .language-option.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #06221f;
}

.hero {
  display: grid;
  gap: 14px;
  padding: 46px 0 24px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 860px;
  margin: 0;
  font-size: 60px;
  line-height: 1.02;
  letter-spacing: 0;
}

.hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.hero strong {
  color: var(--text);
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.tag,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.tag:hover,
.chip:hover {
  border-color: var(--primary);
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 38px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-card,
.side-card,
.content-card {
  min-width: 0;
  padding: 24px;
}

.tool-card h2,
.side-card h2,
.content-card h2 {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.tool-intro,
.side-card p,
.content-card p,
.content-card li,
.muted,
.caption {
  color: var(--muted);
}

.tool-intro {
  margin: -2px 0 18px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  min-width: 0;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 58px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 19px;
  font-weight: 750;
}

input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);
}

.actions,
.result-actions,
.social-share {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.actions {
  margin-top: 16px;
}

.result-actions,
.social-share {
  margin-top: 12px;
}

.primary-btn,
.secondary-btn {
  min-height: 42px;
  padding: 11px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 850;
}

.primary-btn {
  color: #06221f;
  background: var(--primary);
  box-shadow: var(--soft-shadow);
}

.secondary-btn {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.primary-btn:hover,
.secondary-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.result {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

.result small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.result strong {
  display: block;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: 0;
}

.error {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  font-weight: 750;
}

.side-card {
  min-height: 220px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.history-formula {
  font-weight: 850;
}

.history-mass {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.content {
  display: grid;
  gap: 18px;
  padding: 0 0 56px;
}

.content-card h3 {
  margin: 22px 0 8px;
  font-size: 20px;
  letter-spacing: 0;
}

.content-card p,
.content-card li {
  line-height: 1.72;
}

.toc {
  position: relative;
  overflow: hidden;
  padding: 30px;
  border-color: color-mix(in srgb, var(--primary) 34%, var(--border));
  background:
    radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--primary) 20%, transparent), transparent 32%),
    radial-gradient(circle at 96% 18%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 30%),
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 88%, var(--primary)), var(--surface));
}

.toc::before {
  content: "";
  position: absolute;
  right: -70px;
  top: -84px;
  width: 210px;
  height: 210px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 43%, color-mix(in srgb, var(--primary) 18%, transparent) 44%, transparent 46%),
    radial-gradient(circle at 34% 70%, color-mix(in srgb, var(--accent) 26%, transparent) 0 7px, transparent 8px),
    radial-gradient(circle at 66% 33%, color-mix(in srgb, var(--primary) 30%, transparent) 0 6px, transparent 7px);
  pointer-events: none;
}

.toc::after {
  content: "";
  position: absolute;
  inset: auto 22px 18px auto;
  width: 170px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 58%, transparent));
  pointer-events: none;
}

.toc > * {
  position: relative;
  z-index: 1;
}

.toc h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.toc h2::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 58%, transparent), transparent);
}

.toc ol {
  counter-reset: toc;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li {
  counter-increment: toc;
  min-width: 0;
  line-height: 1.3;
}

.toc a {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: calc(var(--radius) + 4px);
  background: color-mix(in srgb, var(--surface) 78%, var(--primary));
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--bg) 56%, transparent);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.toc a:hover,
.toc a:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 18%, transparent);
  transform: translateY(-2px);
}

.toc a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
  outline-offset: 3px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.figure {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.figure img {
  width: auto;
  max-height: 210px;
  object-fit: contain;
  margin: 0 auto;
  border-radius: var(--radius);
  background: #0b1220;
}

.split .figure img {
  max-height: 170px;
}

.caption {
  padding-top: 10px;
  font-size: 13px;
  line-height: 1.55;
}

.note {
  display: flex;
  gap: 10px;
  margin: 18px 0 0;
  padding: 14px;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--muted);
}

.warning {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.formula-card {
  margin: 18px 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  overflow-x: auto;
}

.formula-card small {
  display: block;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.step-list,
.mistake-list {
  display: grid;
  gap: 12px;
}

.step,
.mistake {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.step b:first-child {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #06221f;
  background: var(--primary);
}

.example {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.example-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.pill {
  display: inline-flex;
  margin-right: 8px;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: #06221f;
  background: var(--primary);
  font-size: 12px;
  font-weight: 850;
}

.example-body {
  padding: 16px;
}

.answer {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--success) 34%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
  color: var(--success);
  font-weight: 850;
}

.bad {
  color: var(--danger);
  font-weight: 900;
}

.faq details {
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.faq summary {
  cursor: pointer;
  font-weight: 850;
}

.takeaways {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.takeaways li::marker {
  color: var(--primary);
}

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

.listing-card {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
}

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

.social-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

.social-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.page-jump {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.page-jump a {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--soft-shadow);
}

footer {
  padding: 26px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0;
}

.footer-socials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.footer-social {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  box-shadow: var(--soft-shadow);
}

.footer-social:hover,
.footer-social:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.footer-social:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
  outline-offset: 3px;
}

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

  .nav-links {
    justify-content: flex-start;
  }

  .calculator-grid,
  .field-row,
  .split {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .container {
    width: calc(100% - 24px);
    max-width: 1120px;
  }

  header {
    position: static;
  }

  .nav {
    gap: 12px;
  }

  .brand {
    max-width: 100%;
    white-space: normal;
  }

  .nav-links {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .nav-links a,
  .theme-toggle,
  .language-switcher {
    width: 100%;
    padding-right: 8px;
    padding-left: 8px;
    white-space: normal;
    text-align: center;
  }

  .language-switcher {
    justify-content: center;
    grid-column: 1 / -1;
  }

  .nav-links .language-option {
    width: auto;
  }

  .hero {
    padding: 30px 0 18px;
    text-align: left;
  }

  h1 {
    font-size: 38px;
  }

  .hero p {
    font-size: 16px;
  }

  .calculator-grid {
    padding-bottom: 28px;
  }

  .tool-card,
  .side-card,
  .content-card {
    padding: 16px;
  }

  .toc {
    padding: 18px;
  }

  .toc::before {
    right: -112px;
    top: -120px;
  }

  .toc h2 {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .toc h2::after {
    display: none;
  }

  .toc ol {
    grid-template-columns: 1fr;
  }

  .toc a {
    min-height: 54px;
  }

  .tool-card h2,
  .side-card h2,
  .content-card h2 {
    font-size: 25px;
  }

  input {
    min-height: 54px;
    font-size: 18px;
  }

  .primary-btn {
    width: 100%;
  }

  .result strong {
    font-size: 32px;
  }

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

  .page-jump {
    display: none;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}
