:root {
  --teal-950: #0a2f2c;
  --teal-900: #0d3d38;
  --teal-800: #14524b;
  --teal-700: #1a6b62;
  --teal-600: #218075;
  --teal-500: #2a9d8f;
  --coral-500: #e07a5f;
  --coral-600: #c96a52;
  --cream: #f7f3ee;
  --cream-dark: #efe8df;
  --charcoal: #1f2a2e;
  --muted: #5c6b70;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  /* Modest sitewide bump; rem-based Tailwind utilities scale with it */
  font-size: 106.25%; /* 17px when browser default is 16px */
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--charcoal);
  background: var(--cream);
  overflow-x: hidden;
}

.font-display {
  font-family: "Fraunces", Georgia, serif;
}

/* Brand mark — circular logo sizing */
.brand-mark {
  display: block;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  background: transparent;
}
.brand-mark--nav {
  width: 2.75rem;
  height: 2.75rem;
}
@media (min-width: 640px) {
  .brand-mark--nav {
    width: 3.25rem;
    height: 3.25rem;
  }
}
.brand-mark--footer {
  width: 2.5rem;
  height: 2.5rem;
  opacity: 0.95;
}
.brand-mark--hero {
  width: 5.5rem;
  height: 5.5rem;
  box-shadow: 0 8px 24px rgba(13, 61, 56, 0.16);
}
@media (min-width: 640px) {
  .brand-mark--hero {
    width: 7rem;
    height: 7rem;
  }
}
@media (min-width: 768px) {
  .brand-mark--hero {
    width: 8.5rem;
    height: 8.5rem;
  }
}
.brand-lockup--hero {
  min-width: 0;
}

/* Page enter */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-up {
  animation: fade-up 0.55s ease-out both;
}

.animate-delay-1 {
  animation-delay: 0.08s;
}
.animate-delay-2 {
  animation-delay: 0.16s;
}
.animate-delay-3 {
  animation-delay: 0.24s;
}

/* Nav underline */
.nav-link {
  position: relative;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--coral-500);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-link:hover::after,
.nav-link[aria-current="page"]::after {
  transform: scaleX(1);
}

/* Favorite heart pop */
@keyframes heart-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}
.heart-pop {
  animation: heart-pop 0.35s ease;
}

/* Result reveal */
@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.result-reveal {
  animation: result-in 0.3s ease-out;
}

/* Soft hero wash */
.hero-wash {
  background:
    radial-gradient(ellipse 80% 60% at 70% 20%, rgba(42, 157, 143, 0.22), transparent 60%),
    radial-gradient(ellipse 50% 40% at 10% 80%, rgba(224, 122, 95, 0.12), transparent 55%),
    linear-gradient(165deg, #e8f4f2 0%, var(--cream) 45%, #f3ebe3 100%);
}

.btn-primary {
  background: var(--teal-800);
  color: #fff;
  min-height: 44px;
  transition: background 0.2s ease, transform 0.15s ease;
}
.btn-primary:hover {
  background: var(--teal-700);
}
.btn-primary:active {
  transform: scale(0.97);
}

.btn-accent {
  background: var(--coral-500);
  color: #fff;
  transition: background 0.2s ease, transform 0.15s ease;
}
.btn-accent:hover {
  background: var(--coral-600);
}
.btn-accent:active {
  transform: scale(0.97);
}

.btn-ghost {
  border: 1.5px solid var(--teal-800);
  color: var(--teal-800);
  min-height: 44px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.btn-ghost:hover {
  background: var(--teal-800);
  color: #fff;
}
.btn-ghost:active {
  transform: scale(0.97);
}

/* Stopwatch / primary tool controls — comfortable tap targets */
.stopwatch-controls button {
  min-height: 44px;
}

.flash-success {
  background: #e6f5f2;
  border-left: 4px solid var(--teal-500);
  color: var(--teal-900);
}
.flash-error {
  background: #fceceb;
  border-left: 4px solid var(--coral-500);
  color: #7a3024;
}
.flash-info {
  background: #f0ebe4;
  border-left: 4px solid #a89078;
  color: var(--charcoal);
}

.calc-input {
  width: 100%;
  border: 1.5px solid #d4cbc0;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.65rem 0.85rem;
  font-size: 16px;
  color: var(--charcoal);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.formula-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cookie-banner {
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}
.calc-input:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.2);
}

/* Keyboard focus — keep rings visible; do not suppress :focus-visible */
.btn-primary:focus-visible,
.btn-accent:focus-visible,
.btn-ghost:focus-visible,
.category-chip:focus-visible,
.calc-keypad button:focus-visible,
.calc-mode-toggle:focus-visible,
.calc-copy-btn:focus-visible,
.stopwatch-controls button:focus-visible,
.rounded-2xl.border a:focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(42, 157, 143, 0.28);
}

.btn-primary:focus-visible,
.btn-accent:focus-visible,
.category-chip.is-active:focus-visible {
  outline-color: #fff;
  box-shadow: 0 0 0 3px var(--teal-800), 0 0 0 6px rgba(42, 157, 143, 0.45);
}

/* Crypto / encoding algorithm tier badges */
.crypto-tier-badge {
  border-color: rgba(15, 78, 70, 0.15);
  background: var(--cream, #f7f4ef);
  color: var(--teal-900, #0f4e46);
}
.crypto-tier-badge.tier-secure {
  border-color: rgba(42, 157, 143, 0.45);
  background: rgba(42, 157, 143, 0.12);
  color: #0f4e46;
}
.crypto-tier-badge.tier-legacy {
  border-color: rgba(201, 125, 48, 0.5);
  background: rgba(201, 125, 48, 0.14);
  color: #7a3e0c;
}
.crypto-tier-badge.tier-non-crypto {
  border-color: rgba(100, 116, 139, 0.4);
  background: rgba(100, 116, 139, 0.1);
  color: #334155;
}
.crypto-tier-badge.tier-educational {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.1);
  color: #1e3a8a;
}

/* Scientific calculator keypad */
.scientific-keypad .sci-key--num {
  background: #fff;
  border: 1px solid rgba(19, 78, 74, 0.1);
  color: var(--teal-950);
}
.scientific-keypad .sci-key--num:hover {
  background: rgba(42, 157, 143, 0.08);
}
.scientific-keypad .sci-key--fn {
  background: rgba(19, 78, 74, 0.05);
  color: var(--teal-800);
}
.scientific-keypad .sci-key--fn:hover {
  background: rgba(19, 78, 74, 0.1);
}
.scientific-keypad .sci-key--second {
  background: rgba(231, 111, 81, 0.12);
  color: var(--coral-600);
}
.scientific-keypad .sci-key--second:hover {
  background: rgba(231, 111, 81, 0.2);
}
.scientific-keypad .sci-key--op {
  background: rgba(42, 157, 143, 0.16);
  color: var(--teal-900);
}
.scientific-keypad .sci-key--op:hover {
  background: rgba(42, 157, 143, 0.28);
}
.scientific-keypad .sci-key--mem {
  background: rgba(19, 78, 74, 0.04);
  color: var(--teal-700);
  font-size: 0.7rem;
}
.scientific-keypad .sci-key--mem:hover {
  background: rgba(19, 78, 74, 0.1);
}
.scientific-keypad .sci-key--danger {
  background: rgba(231, 111, 81, 0.1);
  color: var(--coral-600);
}
.scientific-keypad .sci-key--danger:hover {
  background: rgba(231, 111, 81, 0.2);
}
.scientific-keypad .sci-key--eq {
  background: var(--teal-700);
  color: #fff;
}
.scientific-keypad .sci-key--eq:hover {
  background: var(--teal-800);
}
.scientific-history__item:focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(42, 157, 143, 0.28);
}

.formula-block {
  font-family: ui-monospace, "Cascadia Code", monospace;
  background: var(--teal-950);
  color: #d4efe9;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  overflow-x: auto;
}

/* How it works — KaTeX */
.how-it-works .how-formula {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0.5rem;
  padding: 0.85rem 0.75rem;
}
/* Cream / SEO formula blocks: dark readable color (inherits into KaTeX) */
.calc-formula,
.calc-formula .katex,
.calc-formula .katex-display {
  color: var(--teal-900);
}
/* Pale mint ONLY inside dark-panel how-formula boxes — not all .how-it-works */
.how-it-works .how-formula .katex,
.how-it-works .how-formula .katex-display {
  color: #d4efe9;
}
.how-it-works .katex-display {
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.how-step + .how-step {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.15rem;
}

/* Function grapher plot area */
.grapher-plot {
  width: 100%;
  min-height: 280px;
  overflow: hidden;
}
.grapher-plot .function-plot {
  margin: 0 auto;
}
.grapher-plot text.x.axis-label,
.grapher-plot text.y.axis-label {
  font-size: 17px;
  font-weight: 600;
  fill: var(--teal-900);
}
.grapher-plot text.y.axis-label {
  /* Backup: do not keep library sideways rotation via CSS */
  writing-mode: horizontal-tb;
}

/* Shared supplemental mathematical figures */
.calc-figure {
  overflow: hidden;
  border: 1.5px solid rgba(13, 61, 56, 0.18);
  border-radius: 0.875rem;
  background: #fff;
}

.calc-figure__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  background:
    linear-gradient(rgba(42, 157, 143, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 157, 143, 0.035) 1px, transparent 1px),
    #fdfcf9;
  background-size: 24px 24px;
}

.calc-figure__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.calc-figure__status {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(90%, 28rem);
  margin: 0;
  padding: 0.75rem 1rem;
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(13, 61, 56, 0.35);
  border-radius: 0.5rem;
  background: rgba(247, 243, 238, 0.94);
  color: var(--teal-900);
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
}

.calc-figure__status[hidden] {
  display: none;
}

.calc-figure__symbol-key {
  margin: 0;
  padding: 0.45rem 1rem 0.15rem;
  border-top: 1px solid rgba(13, 61, 56, 0.12);
  background: var(--cream);
  color: var(--teal-900);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.calc-figure__symbol-key[hidden] {
  display: none;
}

.calc-figure__caption {
  min-height: 2.75rem;
  padding: 0.55rem 1rem 0.75rem;
  border-top: 1px solid rgba(13, 61, 56, 0.08);
  background: var(--cream);
  color: var(--charcoal);
  font-size: 0.875rem;
  line-height: 1.45;
}

.calc-figure-axis,
.calc-figure-segment,
.calc-figure-vector,
.calc-figure-dimension,
.calc-figure-right-angle,
.calc-figure-angle,
.calc-figure-curve,
.calc-figure-hidden-edge {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.calc-figure-axis,
.calc-figure-segment {
  stroke: var(--teal-900);
  stroke-width: 2;
}

.calc-figure-grid {
  stroke: rgba(20, 82, 75, 0.22);
  stroke-width: 1;
  stroke-dasharray: 3 5;
  vector-effect: non-scaling-stroke;
}

.calc-figure-curve {
  stroke: var(--coral-600);
  stroke-width: 3;
}

.calc-figure-point {
  fill: var(--coral-600);
  stroke: #fff;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.calc-figure-vector {
  stroke: var(--coral-600);
  stroke-width: 3;
}

.calc-figure-vector--secondary {
  stroke: var(--teal-700);
  stroke-width: 3;
  stroke-dasharray: none;
}

.calc-figure-dimension {
  stroke: var(--teal-700);
  stroke-width: 1.75;
}

.calc-figure-right-angle,
.calc-figure-angle {
  stroke: var(--coral-600);
  stroke-width: 2;
}

.calc-figure-angle {
  stroke-dasharray: 5 3;
}

.calc-figure-hidden-edge {
  stroke: var(--teal-700);
  stroke-width: 1.5;
  stroke-dasharray: 7 5;
}

.calc-figure-region {
  fill: rgba(42, 157, 143, 0.2);
  stroke: var(--teal-900);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.calc-figure-region--secondary {
  fill: rgba(42, 157, 143, 0.1);
  stroke-dasharray: 7 3;
}

.calc-figure-region--accent {
  fill: rgba(224, 122, 95, 0.18);
  stroke: var(--coral-600);
}

.calc-figure-label,
.calc-figure-tick-label {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
  fill: var(--teal-950);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
}

.calc-figure-tick-label {
  fill: var(--charcoal);
  font-size: 13px;
  font-weight: 500;
}

.calc-figure-dimension-label {
  fill: var(--teal-900);
}

.calc-figure-arrowhead {
  fill: var(--teal-800);
  stroke: none;
}

.calc-figure-hatch-line {
  stroke: var(--teal-700);
  stroke-width: 2;
}

.calc-figure-pattern-dot {
  fill: var(--coral-600);
}

.calc-figure__viewport--tutorial {
  aspect-ratio: 2 / 1;
}

.calc-figure__viewport--scale {
  aspect-ratio: 16 / 6;
}

.bmi-band-underweight {
  fill: rgba(42, 157, 143, 0.12);
  stroke: var(--teal-900);
  stroke-width: 1.5;
}

.bmi-band-normal {
  fill: rgba(42, 157, 143, 0.34);
  stroke: var(--teal-900);
  stroke-width: 1.5;
}

.bmi-band-overweight {
  fill: rgba(224, 122, 95, 0.28);
  stroke: var(--coral-600);
  stroke-width: 1.5;
}

.bmi-band-obese {
  fill: rgba(224, 122, 95, 0.5);
  stroke: var(--coral-600);
  stroke-width: 1.5;
}

.bmi-slider,
.bmr-slider {
  accent-color: var(--teal-600);
  height: 0.4rem;
}

.bmi-marker,
.bmr-marker {
  fill: var(--coral-600);
  stroke: #fff;
  stroke-width: 2;
}

.bmr-bar-track {
  fill: rgba(42, 157, 143, 0.1);
  stroke: var(--teal-900);
  stroke-width: 1.5;
}

.bmr-seg-weight {
  fill: rgba(42, 157, 143, 0.5);
}

.bmr-seg-height {
  fill: rgba(42, 157, 143, 0.28);
}

@media (max-width: 639px) {
  .calc-figure__viewport {
    aspect-ratio: 4 / 3;
  }

  .calc-figure-label {
    font-size: 16px;
  }

  .calc-figure-tick-label {
    font-size: 14px;
  }
}

.category-chip {
  border: 1.5px solid #d4cbc0;
  background: transparent;
  color: var(--muted);
  transition: all 0.2s ease;
}
.category-chip:hover,
.category-chip.is-active {
  border-color: var(--teal-700);
  background: var(--teal-800);
  color: #fff;
}

.formula-inline {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85rem;
  color: var(--teal-900);
  background: var(--cream-dark);
  border-radius: 0.35rem;
  padding: 0.2rem 0.45rem;
  word-break: break-word;
}

/* Formula sheet — browser print */
@media print {
  nav,
  footer,
  .cookie-banner,
  .formula-sheet-toolbar,
  .formula-sheet-actions,
  .flash-success,
  .flash-error,
  .flash-info {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  main {
    display: block;
  }

  .formula-sheet {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .formula-sheet .formula-table,
  .formula-sheet .rounded-2xl {
    border: 1px solid #ccc !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .formula-inline {
    background: transparent;
    color: #000;
    padding: 0;
  }

  .calc-figure {
    break-inside: avoid;
    border: 1px solid #777;
    background: #fff;
  }

  .calc-figure__viewport {
    aspect-ratio: 2 / 1;
    background: #fff;
  }

  .calc-figure__svg,
  .calc-figure__symbol-key,
  .calc-figure__caption {
    display: block !important;
  }

  .calc-figure__symbol-key,
  .calc-figure__caption {
    color: #000;
    background: #fff;
  }

  .formula-table th:nth-child(3),
  .formula-table td:nth-child(3) {
    display: table-cell !important;
  }
}
