:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #152033;
  --muted: #5b6b80;
  --line: #e3e8ef;
  --brand: #1d4f91;
  --brand-soft: #e8f0fa;
  --teal: #0f766e;
  --teal-soft: #e6f4f2;
  --amber: #b45309;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.06);
  --radius: 16px;
  --radius-sm: 12px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

nav { display: flex; gap: 1rem; }
nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.page.narrow { width: min(800px, calc(100% - 2rem)); }

.hero { margin-bottom: 1.2rem; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--brand);
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.hero h1, .card h2 { margin: 0 0 0.35rem; }
.lede, .muted { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.8rem; }

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

.card { padding: 1.15rem 1.25rem 1.25rem; }
.card-inset { padding: 0.95rem 1rem; background: #fbfcfe; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
label span { color: var(--muted); font-weight: 500; }
label.check {
  flex-direction: row;
  align-items: center;
  margin-top: 1.4rem;
}

input[type="text"], input[type="number"], input[type="date"], select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

input[type="range"] { width: 100%; accent-color: var(--brand); }

.hint-box {
  grid-column: span 3;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  color: var(--ink);
  font-size: 0.88rem;
}

.fineprint, .footer { color: var(--muted); font-size: 0.84rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.62rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 1.1rem;
}

.status { color: var(--teal); font-size: 0.9rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.stat {
  background: var(--bg);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}

.stat span { display: block; color: var(--muted); font-size: 0.78rem; }
.stat strong { font-family: var(--mono); font-size: 1.05rem; }

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

.convert-result {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.convert-result strong { font-family: var(--mono); font-size: 1.15rem; }

.footer {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto 2rem;
}

.prose h2 { margin-top: 1.4rem; }
.prose code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.compound-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
}

@media (max-width: 900px) {
  .grid-4, .stats { grid-template-columns: 1fr 1fr; }
  .hint-box { grid-column: span 2; }
}

@media (max-width: 640px) {
  .grid-4, .stats { grid-template-columns: 1fr; }
  .hint-box { grid-column: auto; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .chart-wrap { height: 280px; }
}
