/* ===== Design tokens ===== */
:root {
  --bg: #060814;
  --bg-2: #0a0e22;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eaf0ff;
  --text-dim: #9aa6c9;
  --text-faint: #6c7799;
  --indigo: #6d7bff;
  --cyan: #29e7ff;
  --magenta: #c44bff;
  --accent-grad: linear-gradient(135deg, #7c83ff 0%, #29e7ff 100%);
  --accent-grad-2: linear-gradient(135deg, #c44bff 0%, #6d7bff 100%);
  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 60px rgba(124, 131, 255, 0.25);
  --radius: 18px;
  --radius-lg: 28px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Layered backdrop gradient */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1100px 700px at 80% -10%, rgba(124, 131, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 10% 10%, rgba(41, 231, 255, 0.12), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(196, 75, 255, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  z-index: -2;
}

/* ===== Ambient orbs ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite;
}

.orb--indigo {
  width: 420px;
  height: 420px;
  background: #5b63ff;
  top: -120px;
  left: -80px;
}

.orb--cyan {
  width: 360px;
  height: 360px;
  background: #1fd6f5;
  bottom: -100px;
  right: -60px;
  animation-delay: -6s;
}

.orb--magenta {
  width: 300px;
  height: 300px;
  background: #b33dff;
  top: 45%;
  left: 55%;
  animation-delay: -11s;
  opacity: 0.35;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
}

/* ===== Nav ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 56px);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(6, 8, 20, 0.45);
  border-bottom: 1px solid var(--border);
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav__logo {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 10px rgba(41, 231, 255, 0.6));
}

.nav__links {
  display: flex;
  gap: 28px;
}

.nav__links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav__links a:hover {
  color: var(--text);
}

/* ===== Layout ===== */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: clamp(60px, 12vw, 130px) 0 clamp(40px, 7vw, 70px);
}

.hero__eyebrow {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 0.78rem;
  color: var(--cyan);
  font-weight: 600;
  margin-bottom: 18px;
}

.hero__title {
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 22px;
}

.hero__subtitle {
  color: var(--text-dim);
  font-size: clamp(1rem, 2vw, 1.2rem);
  max-width: 560px;
  margin: 0 auto 48px;
}

.hero__formula {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 700;
  padding: 28px 44px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero__formula:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 80px rgba(41, 231, 255, 0.35);
}

.var {
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.var--v { background-image: var(--accent-grad); }
.var--i { background-image: linear-gradient(135deg, #29e7ff, #6d7bff); }
.var--r { background-image: var(--accent-grad-2); }

.eq, .op {
  color: var(--text-faint);
  font-weight: 500;
}

.hero__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 28px;
  margin-top: 36px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.hero__legend b {
  color: var(--text);
  font-family: var(--mono);
  margin-right: 6px;
}

/* ===== Sections ===== */
.section {
  padding: clamp(40px, 7vw, 70px) 0;
}

.section__head {
  text-align: center;
  margin-bottom: 44px;
}

.section__head h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}

.section__head p {
  color: var(--text-dim);
  max-width: 600px;
  margin: 0 auto;
}

/* ===== Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
}

.card {
  padding: 30px 26px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.card:hover {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  background: var(--panel-strong);
}

.card__tag {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--cyan);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(41, 231, 255, 0.08);
  border: 1px solid rgba(41, 231, 255, 0.22);
  margin-bottom: 18px;
}

.card__formula {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card p {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ===== Calculator ===== */
.calc {
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(26px, 4vw, 40px);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft), var(--shadow-glow);
}

.calc__fields {
  display: grid;
  gap: 18px;
  margin-bottom: 26px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.4px;
}

.field__input {
  position: relative;
  display: flex;
  align-items: center;
}

.field__input input {
  width: 100%;
  font-family: var(--mono);
  font-size: 1.15rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 52px 14px 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field__input input::placeholder {
  color: var(--text-faint);
}

.field__input input:focus {
  border-color: rgba(41, 231, 255, 0.6);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(41, 231, 255, 0.15);
}

.field__unit {
  position: absolute;
  right: 16px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--cyan);
  pointer-events: none;
}

.calc__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 18px;
}

.btn {
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 600;
  padding: 13px 30px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--accent-grad);
  color: #05070f;
  box-shadow: 0 8px 24px rgba(41, 231, 255, 0.3);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(41, 231, 255, 0.45);
}

.btn--ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--cyan);
}

.calc__message {
  text-align: center;
  font-size: 0.9rem;
  min-height: 1.2em;
  color: #ff8aa0;
  margin-bottom: 6px;
}

.calc__message.is-valid {
  color: #57e3a0;
}

/* ===== Result ===== */
.result {
  margin-top: 8px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  text-align: center;
  transition: opacity 0.3s ease;
}

.result.is-empty {
  opacity: 0.55;
}

.result__label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.result__value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-family: var(--mono);
}

.result__value > span:first-child {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cyan);
}

.result__equals {
  color: var(--text-faint);
  font-size: 1.3rem;
}

.result__number {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result__unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dim);
}

.result__formula {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text-faint);
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.table th,
.table td {
  padding: 15px 22px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table thead th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--cyan);
  background: rgba(255, 255, 255, 0.03);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table td {
  color: var(--text-dim);
  font-size: 0.95rem;
}

.table td:nth-child(4) {
  font-family: var(--mono);
  color: var(--text);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 50px 20px 40px;
  color: var(--text-faint);
  font-size: 0.88rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ===== Reveal animation ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .nav__links {
    gap: 18px;
  }
  .nav__links a {
    font-size: 0.85rem;
  }
  .hero__formula {
    padding: 22px 26px;
    gap: 12px;
  }
  .calc__actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
