/* Shop Math: the stevensbored navy and mint, one calculator per panel. */
:root {
  --bg: #0c1020;
  --panel: #171b2b;
  --field: #0f1426;
  --line: #2a3048;
  --ink: #f4ede6;
  --dim: #a9adc0;
  --mint: #acf8b4;
  --warm: #ffa470;
  --bad: #ff8f8f;
  --focus: #ffffff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: rgba(172, 248, 180, .2); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 17px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.skip { position: absolute; left: 12px; top: -80px; z-index: 5; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 16px; border-bottom: 1px solid var(--line); }
.home { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 700; }
.home b { color: var(--mint); }
.home:hover { text-decoration: underline; text-underline-offset: 4px; }
h1 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--dim); }

main { width: min(100%, 980px); margin: 0 auto; padding: 22px 16px 56px; }
.lead { margin: 0 0 22px; max-width: 64ch; }

/* trade picker: chips that wrap */
.kinds { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.kinds legend { padding: 0; margin-bottom: 8px; font-size: .9rem; font-weight: 600; color: var(--dim); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kinds label { position: relative; flex: none; }
.kinds input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.kinds span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--field); font-weight: 600; cursor: pointer; white-space: nowrap; }
.kinds input:checked + span { background: var(--mint); border-color: var(--mint); color: #0c1020; }
.kinds input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

/* the trade's calculators, one open at a time */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tabs button {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); color: var(--dim); font: inherit; font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--panel); border-color: var(--mint); color: var(--ink); box-shadow: inset 0 -3px 0 var(--mint); }
.tabs button:focus-visible { outline-offset: 2px; }
/* the open tab already names it */
.tabs + .slot .calc h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tabs + .slot .blurb { margin-top: 0; }

.calc { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); min-width: 0; scroll-margin-top: 12px; }
.calc h2 { margin: 0; font-size: 1.25rem; line-height: 1.25; }
.blurb { margin: 2px 0 14px; color: var(--dim); }
.body { display: grid; gap: 16px; }
/* wide screens: the form on the left, the answer beside it and kept in view */
@media (min-width: 760px) {
  .body { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .side { position: sticky; top: 12px; }
  .fields { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
/* phones: smaller chips so the trades fit in a few rows */
@media (max-width: 759px) {
  .chips { gap: 6px; }
  .kinds span { padding: 0 12px; }
  .lead { font-size: .95rem; margin-bottom: 16px; }
  .calc { padding: 14px; }
}

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 12px; align-items: start; }
.field.wide, .check { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; min-width: 0; }
.field .name { font-size: .9rem; font-weight: 600; color: var(--dim); }
.inp { display: flex; align-items: stretch; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
.inp:focus-within { outline: 2px solid var(--mint); outline-offset: 1px; }
.inp input, .inp select {
  flex: 1; width: 100%; min-width: 0; min-height: 46px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); font: inherit; outline: none;
}
.inp select { background: var(--field); }
.unit { display: flex; align-items: center; padding: 0 12px 0 4px; color: var(--dim); font-size: .9rem; white-space: nowrap; }
.unit:empty { display: none; }
.hint, .echo { margin: 0; font-size: .84rem; color: var(--dim); }
.echo { color: var(--mint); }
.echo:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 46px; cursor: pointer; align-self: end; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--mint); flex: none; }

.result { margin-top: 0; padding: 14px; border-radius: 10px; background: var(--field); border: 1px solid var(--line); }
.ask { margin: 0; color: var(--warm); }
.ask:empty { display: none; }
.result dl { margin: 0; display: grid; gap: 2px; }
.result dl:empty { display: none; }
.ask:not(:empty) + dl:not(:empty) { margin-top: 10px; }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 14px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row dt { color: var(--dim); font-size: .92rem; }
.row dd { margin: 0; font-weight: 600; text-align: right; margin-left: auto; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.row.big dd { font-size: 1.25rem; color: var(--mint); }
.row.ok dd { color: var(--mint); }
.row.bad dd { color: var(--bad); }
.extra p { margin: 10px 0 0; font-size: .88rem; color: var(--dim); }
.code { margin: 12px 0 0; padding-left: 12px; border-left: 3px solid var(--warm); font-size: .86rem; color: var(--dim); }

.fine { margin: 28px 0 0; font-size: .88rem; color: var(--dim); max-width: 64ch; }
