.lbm {
  --lbm-paper: hsl(174deg, 45%, 97%);
  --lbm-panel: hsl(0deg, 0%, 100%);
  --lbm-ink: hsl(205deg, 32%, 15%);
  --lbm-figure-line: hsl(188deg, 28%, 32%);
  --lbm-muted: hsl(202deg, 11%, 43%);
  --lbm-line: hsl(184deg, 22%, 84%);
  --lbm-emerald: hsl(158deg, 72%, 40%);
  --lbm-teal: hsl(181deg, 76%, 38%);
  --lbm-fat: hsl(36deg, 77%, 66%);
  --lbm-shadow: hsl(200deg, 45%, 18%, 0.1);

  width: 100%;
}

.theme-dark .lbm {
  --lbm-paper: hsl(204deg, 28%, 10%);
  --lbm-panel: hsl(204deg, 25%, 14%);
  --lbm-ink: hsl(174deg, 35%, 94%);
  --lbm-figure-line: hsl(174deg, 35%, 88%);
  --lbm-muted: hsl(190deg, 13%, 70%);
  --lbm-line: hsl(196deg, 22%, 27%);
  --lbm-emerald: hsl(156deg, 67%, 52%);
  --lbm-teal: hsl(181deg, 72%, 48%);
  --lbm-fat: hsl(38deg, 72%, 58%);
  --lbm-shadow: hsl(0deg, 0%, 0%, 0.28);
}

.lbm__shell {
  overflow: hidden;
  border: 1px solid var(--lbm-line);
  border-radius: 8px;
  background: var(--lbm-paper);
  color: var(--lbm-ink);
  box-shadow: 0 18px 44px var(--lbm-shadow);
}

.lbm__stage {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.6rem);
  background:
    linear-gradient(135deg, hsl(158deg, 72%, 40%, 0.12), transparent 42%),
    radial-gradient(circle at 88% 15%, hsl(181deg, 76%, 38%, 0.16), transparent 34%),
    var(--lbm-panel);
}

.lbm__figure-wrap {
  display: grid;
  gap: 0.75rem;
  place-items: center;
}

.lbm__figure {
  width: min(13rem, 56vw);
  height: auto;
  filter: drop-shadow(0 16px 18px var(--lbm-shadow));
}

.lbm__figure-base {
  fill: hsl(0deg, 0%, 100%, 0.58);
}

.lbm__fat-fill {
  fill: var(--lbm-fat);
  opacity: 0.72;
}

.lbm__lean-fill {
  fill: var(--lbm-emerald);
  transition: y 180ms ease, height 180ms ease;
}

.lbm__figure-outline {
  fill: none;
  stroke: var(--lbm-figure-line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.25;
}

.lbm__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 0.9rem;
  color: var(--lbm-muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.lbm__legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lbm__key {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
}

.lbm__key--lean { background: var(--lbm-emerald); }
.lbm__key--fat { background: var(--lbm-fat); }

.lbm__donut {
  --lean: 74;

  position: relative;
  display: grid;
  place-items: center;
  width: min(15rem, 64vw);
  aspect-ratio: 1;
  justify-self: center;
}

.lbm__ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: conic-gradient(var(--lbm-emerald) calc(var(--lean) * 1%), var(--lbm-fat) 0);
  box-shadow: inset 0 0 0 1px var(--lbm-line), 0 18px 34px var(--lbm-shadow);
}

.lbm__ring::after {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: inherit;
  background: var(--lbm-panel);
  box-shadow: inset 0 0 0 1px var(--lbm-line);
}

.lbm__ring-core {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.25rem;
  text-align: center;
}

.lbm__ring-core span,
.lbm__metrics span {
  color: var(--lbm-muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lbm__ring-core strong {
  font-size: clamp(2.4rem, 10vw, 3.9rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

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

.lbm__metrics div {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--lbm-line);
  border-radius: 8px;
  background: hsl(0deg, 0%, 100%, 0.62);
}

.theme-dark .lbm__metrics div {
  background: hsl(204deg, 25%, 18%, 0.68);
}

.lbm__metrics strong {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.05rem, 4vw, 1.55rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.lbm__controls {
  display: grid;
  gap: 0.8rem;
  padding: clamp(1rem, 4vw, 1.6rem);
}

.lbm__switches {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: center;
}

.lbm__seg,
.lbm__formula {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--lbm-line);
  border-radius: 8px;
  background: var(--lbm-panel);
}

.lbm__seg:first-child,
.lbm__formula {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.lbm__seg-btn,
.lbm__icon-btn,
.lbm__formula-btn {
  min-height: 2.4rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--lbm-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.lbm__icon-btn {
  width: 2.45rem;
  display: inline-grid;
  place-items: center;
}

.lbm__icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.lbm__seg-btn--active,
.lbm__icon-btn--active,
.lbm__formula-btn--active {
  background: linear-gradient(135deg, var(--lbm-emerald), var(--lbm-teal));
  color: white;
  box-shadow: 0 8px 18px hsl(170deg, 70%, 35%, 0.24);
}

.lbm__field {
  display: grid;
  grid-template-columns: 1fr minmax(4.8rem, 6.5rem);
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid var(--lbm-line);
  border-radius: 8px;
  background: var(--lbm-panel);
}

.lbm__field span {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.lbm__field b {
  font-size: 0.86rem;
}

.lbm__field output {
  color: var(--lbm-muted);
  font-weight: 900;
}

.lbm__range {
  width: 100%;
  margin: 0;
  accent-color: var(--lbm-emerald);
}

.lbm__number {
  min-width: 0;
  height: 2.45rem;
  border: 1px solid var(--lbm-line);
  border-radius: 6px;
  background: var(--lbm-paper);
  color: var(--lbm-ink);
  font: inherit;
  font-weight: 850;
  text-align: center;
}

.lbm__equation {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem;
  border: 1px solid var(--lbm-line);
  border-radius: 8px;
  background: var(--lbm-panel);
}

.lbm__equation span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--lbm-muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lbm__equation svg {
  width: 1rem;
  height: 1rem;
}

.lbm__equation code {
  overflow-wrap: anywhere;
  color: var(--lbm-ink);
  font-size: 0.95rem;
  font-weight: 850;
}

.lbm__notes {
  display: grid;
  border-top: 1px solid var(--lbm-line);
}

.lbm__notes div {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--lbm-line);
  background: var(--lbm-panel);
}

.lbm__notes div:last-child {
  border-bottom: 0;
}

.lbm__notes strong {
  display: block;
  margin-bottom: 0.25rem;
}

.lbm__notes p {
  margin: 0;
  color: var(--lbm-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 480px) {
  .lbm__metrics,
  .lbm__switches,
  .lbm__field {
    grid-template-columns: 1fr;
  }

  .lbm__seg {
    width: 100%;
  }
}

@media (min-width: 860px) {
  .lbm__shell {
    display: grid;
    grid-template-columns: minmax(380px, 1.1fr) minmax(360px, 0.9fr);
  }

  .lbm__stage {
    grid-template-columns: minmax(160px, 0.8fr) minmax(190px, 1fr);
    align-items: center;
  }

  .lbm__metrics {
    grid-column: 1 / -1;
  }

  .lbm__controls {
    border-left: 1px solid var(--lbm-line);
  }

  .lbm__notes {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, 1fr);
  }

  .lbm__notes div:first-child {
    border-right: 1px solid var(--lbm-line);
  }
}
