/* Free calculators and comparison pages. Loaded only on those pages; uses the tokens from style.css. */
.calc { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.calc fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: .85rem; min-width: 0; }
.calc legend { font-weight: 600; margin-bottom: .5rem; padding: 0; }
.calc-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.calc-head p { margin: 0; color: var(--muted); font-size: .92rem; }
.field { display: grid; gap: .3rem; }
.field label, .field .label { font-weight: 500; font-size: .94rem; }
.field small { color: var(--muted); font-size: .82rem; line-height: 1.4; }
.in { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.in:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--glow); }
.in input, .in select { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 500 1rem/1.2 var(--font-body); padding: .7rem .8rem; outline: none; }
.in span { display: grid; place-items: center; padding: 0 .75rem; color: var(--muted); font: 500 .9rem/1 var(--font-mono); background: var(--surface-2); }
.in span:first-child { border-right: 1px solid var(--line); }
.in span:last-child { border-left: 1px solid var(--line); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.cur-pick { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); }
.cur-pick select { font: 500 .92rem/1 var(--font-body); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px; padding: .5rem .8rem; min-height: 2.4rem; }
.check { display: flex; align-items: center; gap: .55rem; font-size: .94rem; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--app); }

.result { display: grid; gap: .8rem; align-content: start; padding: 1.2rem; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); }
.result .big { display: grid; gap: .2rem; }
.result .big b { font: 600 clamp(2rem, 5vw, 2.7rem)/1.05 var(--font-body); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.result .big span { color: var(--muted); font-size: .9rem; }
.result.loss .big b { color: var(--bad); }
.result dl { display: grid; grid-template-columns: 1fr auto; gap: .45rem 1rem; margin: 0; font-size: .93rem; }
.result dt { color: var(--muted); }
.result dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.result .save { padding: .9rem 1rem; border-radius: 14px; background: var(--ok-bg); color: var(--ink); font-size: .95rem; }
.result .save b { color: var(--ok); }
.result .status { font-weight: 500; }

/* Size chart builder */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .7rem; border: 1px solid var(--line-2); border-radius: 999px; font-size: .9rem; cursor: pointer; background: var(--bg); }
.chip:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
.chip input { accent-color: var(--app); }
.seg { display: inline-flex; padding: .2rem; border: 1px solid var(--line-2); border-radius: 999px; gap: .2rem; background: var(--bg); }
.seg label { padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font-size: .92rem; }
.seg label:has(input:checked) { background: var(--ink); color: var(--bg); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--app); outline-offset: 2px; }
.builder { display: grid; gap: 1.1rem; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-table { border-collapse: collapse; min-width: 100%; font-size: .92rem; }
.grid-table th, .grid-table td { border: 1px solid var(--line); padding: .3rem; text-align: left; }
.grid-table th { background: var(--surface-2); font-weight: 500; padding: .5rem .6rem; white-space: nowrap; }
.grid-table input { width: 100%; min-width: 4.5rem; border: 0; background: transparent; color: var(--ink); font: 500 .95rem var(--font-body); padding: .45rem; border-radius: 6px; }
.grid-table input:focus { outline: 2px solid var(--app); }
.code-out { position: relative; }
.code-out pre { margin: 0; max-height: 16rem; overflow: auto; padding: 1rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font: .8rem/1.5 var(--font-mono); white-space: pre; }
.code-out .btn { position: absolute; top: .5rem; right: .5rem; }
.preview-box { padding: 1rem; border: 1px dashed var(--line-2); border-radius: 14px; background: #fff; color: #111; overflow-x: auto; }

/* Comparison tables */
.compare-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 16px; }
.compare { border-collapse: collapse; width: 100%; min-width: 36rem; font-size: .92rem; background: var(--surface); }
.compare th, .compare td { padding: .7rem .85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.compare thead th { background: var(--surface-2); font-weight: 600; }
.compare tbody th { font-weight: 500; color: var(--muted); width: 22%; }
.compare tr:last-child > * { border-bottom: 0; }
.source { font-size: .84rem; color: var(--muted); }
.article .faq { margin-top: .5rem; }

/* Tools hub */
.tool-tile .tile-top .pill { background: var(--surface); }

@media (max-width: 880px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .two { grid-template-columns: minmax(0, 1fr); }
}

/* Keep wide content (code, tables) inside its own scroll box instead of widening the page */
.article { grid-template-columns: minmax(0, 1fr); }
.builder { grid-template-columns: minmax(0, 1fr); }
.builder fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.builder legend { padding: 0; margin-bottom: .3rem; }
.field { grid-template-columns: minmax(0, 1fr); }
