/* Barbell Math styles. Dark first; light follows the phone's appearance setting. */

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
}

/* Layout: one column with a fixed bottom tab bar. Load keeps a sticky scale readout over the
   loading floor; the other tabs are a page head, an input panel, then result cards or rows. */
:root {
  --bg: #111315;
  --surface: #1a1d20;
  --surface-2: #24282c;
  --raise: #363b41;
  --line: #2d3236;
  --fg: #edebe7;
  --muted: #8e959b;
  --osu: #fe5c00;            /* OSU orange, official brand hex. Selection only. */
  --osu-ink: #ff7b33;        /* orange used as text */
  --osu-soft: rgba(254, 92, 0, 0.13);
  --on-osu: #170a02;
  --good: #4cc08e;
  --good-soft: rgba(76, 192, 142, 0.14);
  --warn: #e9a83c;
  --warn-soft: rgba(233, 168, 60, 0.14);
  --steel: #a3a9af;
  --steel-2: #727980;
  --iron: #3a3e43;
  --iron-rim: #60666c;
  --iron-ink: #efede9;
  --knob: #ffffff;
  --tabbar: rgba(17, 19, 21, 0.9);
  --shade: rgba(0, 0, 0, 0.24);
  --plate-edge: rgba(0, 0, 0, 0.38);
  /* IWF plate colors. Same in light and dark; ink is the numeral on the disc. */
  --iwf-red: #d3302f;
  --iwf-blue: #2459c4;
  --iwf-yellow: #efc232;
  --iwf-green: #2e9a57;
  --iwf-white: #f2f0eb;
  --iwf-chrome: #b7bcc2;
  --iwf-ink: #16181a;
  --iwf-ink-on: #ffffff;

  --font-num: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef0f1;
    --surface: #ffffff;
    --surface-2: #e3e7ea;
    --raise: #ffffff;
    --line: #d3d9dd;
    --fg: #15181b;
    --muted: #5d656c;
    --osu: #fe5c00;
    --osu-ink: #bf4300;
    --osu-soft: rgba(254, 92, 0, 0.1);
    --on-osu: #170a02;
    --good: #157a4c;
    --good-soft: rgba(21, 122, 76, 0.1);
    --warn: #985a00;
    --warn-soft: rgba(152, 90, 0, 0.1);
    --steel: #8b9298;
    --steel-2: #5f666d;
    --iron: #2e3236;
    --iron-rim: #16181a;
    --iron-ink: #f1efeb;
    --knob: #ffffff;
    --tabbar: rgba(238, 240, 241, 0.92);
    --shade: rgba(0, 0, 0, 0.2);
    --plate-edge: rgba(0, 0, 0, 0.4);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #eef0f1;
  --surface: #ffffff;
  --surface-2: #e3e7ea;
  --raise: #ffffff;
  --line: #d3d9dd;
  --fg: #15181b;
  --muted: #5d656c;
  --osu: #fe5c00;
  --osu-ink: #bf4300;
  --osu-soft: rgba(254, 92, 0, 0.1);
  --on-osu: #170a02;
  --good: #157a4c;
  --good-soft: rgba(21, 122, 76, 0.1);
  --warn: #985a00;
  --warn-soft: rgba(152, 90, 0, 0.1);
  --steel: #8b9298;
  --steel-2: #5f666d;
  --iron: #2e3236;
  --iron-rim: #16181a;
  --iron-ink: #f1efeb;
  --knob: #ffffff;
  --tabbar: rgba(238, 240, 241, 0.92);
  --shade: rgba(0, 0, 0, 0.2);
  --plate-edge: rgba(0, 0, 0, 0.4);
  color-scheme: light;
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button:disabled {
  cursor: default;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--osu);
  outline-offset: 2px;
}
h1,
h2,
h3 {
  margin: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}

.app {
  max-width: 540px;
  margin: 0 auto;
  padding-inline: var(--gut-l) var(--gut-r);
  padding-block: 0 92px; /* room for the tab bar */
}

.view {
  display: grid;
  gap: 18px;
}
.view-load {
  gap: 0;
}

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  background: var(--tabbar);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.tab {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 5px 0 3px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab svg .dots {
  stroke-width: 2.6;
}
.tab.is-on {
  color: var(--osu-ink);
}
.tab.is-on svg {
  color: var(--osu);
}

/* ---------- page heads and panels ---------- */

.page-head {
  padding-top: 14px;
}
.page-head h1 {
  font: 700 30px/1 var(--font-num);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.page-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.opts {
  display: grid;
  gap: 12px;
}
.results {
  display: grid;
  gap: 12px;
}
.count-rows {
  display: grid;
  gap: 10px;
}
.tool {
  display: grid;
  gap: 12px;
}
.range-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.range-to {
  font-size: 13px;
  color: var(--muted);
}
.plan-sum {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 15px;
  line-height: 1.45;
}
.plan-sum b {
  font-family: var(--font-num);
  font-size: 17px;
  font-weight: 700;
}
.wide-btn {
  width: 100%;
  height: 42px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.big-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 8px;
}
.step {
  height: 60px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font: 700 28px/1 var(--font-num);
}
.step:active {
  background: var(--raise);
}
.big-input {
  width: 100%;
  min-width: 0;
  height: 60px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
  font: 700 40px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
}
.big-input:focus,
.text-in:focus {
  outline: none;
  border-color: var(--osu);
  box-shadow: 0 0 0 3px var(--osu-soft);
}
.opt-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.opt-label {
  min-width: 46px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

/* segmented control */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  max-width: 100%;
}
.seg button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.seg button[aria-pressed="true"] {
  background: var(--raise);
  color: var(--osu-ink);
  box-shadow: 0 1px 2px var(--shade);
}

/* bar chips (Target, Tools) */
.bchip {
  height: 34px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.bchip.is-on {
  border-color: var(--osu);
  background: var(--osu-soft);
  color: var(--osu-ink);
}

.primary {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: var(--radius);
  background: var(--osu);
  color: var(--on-osu);
  font-size: 15px;
  font-weight: 700;
}
.primary:active {
  filter: brightness(0.92);
}
.mini-btn {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
}
.mini-btn:active {
  background: var(--raise);
}
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--osu-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}
.mini-title {
  font: 700 14px/1 var(--font-num);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.empty-state {
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ---------- Load: readout (sticky) ---------- */

.readout {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  margin-inline: calc(-1 * var(--gut-l)) calc(-1 * var(--gut-r));
  padding: 10px var(--gut-r) 6px var(--gut-l);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  /* paints the strip under the iPhone status bar when content scrolls */
  box-shadow: 0 calc(-1 * env(safe-area-inset-top, 0px)) 0 0 var(--bg);
}
.readout-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 700 15px/1 var(--font-num);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.brand-mark {
  width: 7px;
  height: 16px;
  border-radius: 2px;
  background: var(--osu);
}
.readout-label {
  font-size: 12px;
  color: var(--muted);
}
.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}
.total {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}
.total + .total {
  border-left: 1px solid var(--line);
  padding-left: 14px;
}
.total-num {
  font: 700 clamp(38px, 12vw, 58px) / 0.95 var(--font-num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.total-num.long {
  font-size: clamp(30px, 9.5vw, 46px);
}
.total-unit {
  font: 600 18px/1 var(--font-num);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 8px 0 0;
}
.stats div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.stats dt {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stats dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stats .eq {
  color: var(--muted);
  font-weight: 500;
}

/* ---------- barbell drawing ---------- */

.barbell {
  display: block;
  width: 100%;
  height: auto;
  max-height: 104px;
  margin-top: 4px;
}
.barbell.mini {
  max-height: 86px;
  margin-top: 0;
}
.bb-sleeve,
.bb-collar {
  fill: var(--steel);
}
.bb-shaft {
  fill: var(--steel-2);
}
.bb-knurl {
  stroke: var(--shade);
  stroke-width: 5;
  stroke-dasharray: 1 1.6;
}
.bb-label {
  font: 700 9px var(--font-num);
  letter-spacing: 0.14em;
  fill: var(--muted);
}
.bb-bar:not(.is-off) .bb-label {
  fill: var(--osu-ink);
}
.bb-bar.is-off {
  opacity: 0.35;
}
.bb-plate {
  stroke-width: 0.8;
}
.bb-plate.enter {
  transform-box: fill-box;
  transform-origin: center;
  animation: plateIn 0.22s ease-out both;
}

/* ---------- Load: sections ---------- */

.content {
  display: grid;
  gap: 22px;
  padding-top: 16px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 32px;
  margin-bottom: 10px;
}
.section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 700 17px/1 var(--font-num);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.tag {
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font: 600 11px/1 var(--font-ui);
  letter-spacing: 0.04em;
}
.actions {
  display: flex;
  gap: 8px;
}
.act {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}
.act:disabled {
  opacity: 0.4;
}
.act:not(:disabled):active {
  background: var(--surface-2);
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px 0 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip-dot {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1.5px var(--shade), 0 0 0 1px var(--ring, transparent);
}
.chip-x {
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.chip.enter {
  animation: chipIn 0.2s ease-out both;
}
.empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
}
.bars > .note {
  grid-column: 1 / -1;
}
.bar {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 12px 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.bar-icon {
  width: 100%;
  max-width: 96px;
  height: 24px;
  opacity: 0.45;
}
.bar-icon rect {
  fill: currentColor;
}
.bar-w {
  font: 700 24px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
}
.bar-w small {
  margin-left: 2px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bar-kg {
  max-width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: center;
}
.bar.is-on {
  border-color: var(--osu);
  background: var(--osu-soft);
  color: var(--osu-ink);
}
.bar.is-on .bar-icon {
  opacity: 1;
  color: var(--osu);
}

.plates {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.plate {
  position: relative;
  display: grid;
  grid-template-rows: 50px auto;
  justify-items: center;
  align-items: center;
  align-content: center;
  gap: 4px;
  height: 80px;
  padding: 6px 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.18s;
}
.plate.flash {
  border-color: var(--osu);
}
.plate.maxed {
  border-style: dashed;
  background: transparent;
}
.plate.maxed .disc {
  filter: grayscale(1);
  opacity: 0.3;
}
.plate.maxed .plate-unit {
  color: var(--fg);
}
.disc {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: var(--c);
  color: var(--ink);
  font: 700 var(--fs) / 1 var(--font-num);
  font-variant-numeric: tabular-nums;
  box-shadow:
    0 0 0 1px var(--ring, transparent),
    inset 0 0 0 2px var(--shade),
    inset 0 0 0 calc(var(--d) * 0.12) var(--c),
    inset 0 0 0 calc(var(--d) * 0.12 + 1.5px) var(--shade);
  transition: transform 0.08s ease-out;
}
.plate:not(:disabled):active .disc {
  transform: scale(0.9);
}
.plate-unit {
  font: 600 11px/1 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 20px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--osu);
  color: var(--on-osu);
  font: 700 12px/16px var(--font-num);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.foot {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Target: result cards ---------- */

.result {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.pill {
  padding: 6px 8px;
  border-radius: 6px;
  font: 700 12px/1 var(--font-ui);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.pill-good {
  background: var(--good-soft);
  color: var(--good);
}
.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.gap {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.gap-warn {
  margin-left: 6px;
  font: 600 13px var(--font-ui);
  color: var(--warn);
}
.result-total {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.rt-main {
  font: 700 42px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
}
.rt-sub {
  font: 600 20px/1 var(--font-num);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.ptag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px 0 6px;
  border-radius: 15px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.alt-list {
  display: grid;
  padding: 12px 14px 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.alt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.mini-title + .alt {
  border-top: 0;
}
.alt-main {
  flex: 1;
  min-width: 0;
}
.alt-label {
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.alt-total {
  font: 700 20px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
}
.alt-gap {
  margin-left: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Tools: rows ---------- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.row:first-child {
  border-top: 0;
}
.row-lead b {
  display: block;
  font: 700 20px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
}
.row-lead small {
  color: var(--muted);
  font-size: 12px;
}
.row-total {
  font: 700 20px/1.15 var(--font-num);
  font-variant-numeric: tabular-nums;
}
.row-total small {
  margin-left: 6px;
  font: 600 14px var(--font-num);
  color: var(--muted);
}
.row-sub,
.row-change,
.row-meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}
.row-change {
  color: var(--osu-ink);
}
.row.is-work .row-lead b {
  color: var(--osu-ink);
}
.row.is-off {
  opacity: 0.55;
}

/* ---------- Convert: calculator ---------- */

.calc {
  display: grid;
  gap: 12px;
}
.calc-screen {
  display: grid;
  align-content: end;
  gap: 4px;
  min-height: 172px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: right;
}
.calc-tape {
  min-height: 20px;
  font-size: 15px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.calc-tape .u {
  margin-left: 2px;
  font-size: 0.85em;
}
.calc-main {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
#calcMain {
  min-width: 0;
  font: 700 54px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
#calcMain.long {
  font-size: 40px;
}
#calcMain.is-empty {
  color: var(--muted);
}
.calc-unit {
  min-width: 1ch;
  font: 600 22px/1 var(--font-num);
  color: var(--osu-ink);
  text-transform: uppercase;
}
.calc-conv {
  min-height: 22px;
  font: 600 19px/1.2 var(--font-num);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.calc-preview {
  min-height: 18px;
  font-size: 13.5px;
  color: var(--muted);
}
.calc-error {
  font-size: 13px;
  color: var(--warn);
}
.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.key {
  display: grid;
  place-items: center;
  height: clamp(48px, 7vh, 60px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font: 700 26px/1 var(--font-num);
}
.key:active {
  background: var(--surface-2);
}
.key-op {
  background: var(--surface-2);
  color: var(--osu-ink);
}
.key-fn {
  color: var(--muted);
  font-size: 22px;
}
.key-eq {
  border-color: var(--osu);
  background: var(--osu);
  color: var(--on-osu);
}
.key-eq:active {
  background: var(--osu);
  filter: brightness(0.92);
}
.key-unit {
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.key-unit[aria-pressed="true"] {
  border-color: var(--osu);
  background: var(--osu-soft);
  color: var(--osu-ink);
}

/* ---------- Gear ---------- */

.gear {
  display: grid;
  gap: 26px;
}
.sec {
  display: grid;
  gap: 12px;
}
.sec > .section-head {
  margin-bottom: 0;
}
.list {
  list-style: none;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.list-row:first-child {
  border-top: 0;
}
.lr-main {
  display: grid;
  flex: 1;
  min-width: 0;
}
.lr-main b {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lr-main small {
  font-size: 12.5px;
  color: var(--muted);
}
.bar-mini {
  flex: none;
  width: 54px;
  color: var(--muted);
}
.bar-mini .bar-icon {
  opacity: 1;
}
.text-btn {
  flex: none;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--warn);
  font-size: 13px;
  font-weight: 600;
}

.switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
}
.switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  transition: background-color 0.15s, border-color 0.15s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 3px var(--shade);
  transition: transform 0.15s;
}
.switch input:checked + span {
  border-color: var(--osu);
  background: var(--osu);
}
.switch input:checked + span::after {
  transform: translateX(20px);
}
.switch input:focus-visible + span {
  outline: 2px solid var(--osu);
  outline-offset: 2px;
}

.stepper {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
}
.stepper button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font: 700 20px/1 var(--font-num);
}
.stepper button:disabled {
  opacity: 0.35;
}
.stepper output {
  min-width: 30px;
  text-align: center;
  font: 700 20px/1 var(--font-num);
  font-variant-numeric: tabular-nums;
}

.form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.text-in {
  flex: 1 1 140px;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px; /* 16px stops iOS from zooming on focus */
}
.text-in.w-in {
  flex: 0 1 110px;
}
.chip-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
}
.form-error {
  margin: 0;
  font-size: 13px;
  color: var(--warn);
}
.danger {
  width: 100%;
  height: 46px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: transparent;
  color: var(--warn);
  font-weight: 600;
}
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mode-card {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: left;
}
.mode-card b {
  font-size: 15px;
}
.mode-card span {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}
.mode-card.is-on {
  border-color: var(--osu);
  background: var(--osu-soft);
}
.mode-card.is-on b {
  color: var(--osu-ink);
}
.count-sum b {
  color: var(--fg);
}
.pair-note {
  font-weight: 600;
}
.pair-note.has-spare {
  color: var(--fg);
}
.list-row.is-none .disc {
  opacity: 0.45;
}
.file-btn {
  position: relative;
  display: grid;
  place-items: center;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.file-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.file-btn:focus-within {
  outline: 2px solid var(--osu);
  outline-offset: 2px;
}
.confirm {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--osu);
  border-radius: var(--radius);
  background: var(--osu-soft);
}
.confirm p {
  margin: 0;
  font-size: 14px;
}
.confirm-yes {
  flex: 1;
  width: auto;
}
.confirm .mini-btn {
  height: 46px;
  padding: 0 18px;
}
.danger.armed {
  background: var(--warn);
  color: var(--on-osu);
}

@keyframes chipIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
@keyframes plateIn {
  from {
    opacity: 0;
    transform: scaleY(0.5);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
