/* Trade-cost calculator (issue #2, 14.11.2026; widget port 14.11.2026) —
   separate stylesheet on purpose: only the .tcalc block on market pages, built
   from existing theme tokens so light/dark and focus-visible work like the
   rest of the site. Compact card layout ported from the chatcn "Calculator
   Widget" by aadixc0de — source https://chatcn.dev/r/calculator-widget.json,
   preview https://21st.dev/@aadixc0de/components/calculator-widget: paired
   slider + exact-field rows on the left, a neutral inset result pane with a
   segmented cost bar on the right, small outline footer action. */
.tcalc-jump{margin:14px 0 0}
.tcalc-jump a{font-weight:700;color:var(--accent-ink)}
.tcalc{max-width:760px;margin:12px auto 18px}
.tcalc [hidden]{display:none}
.tcalc>summary{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:8px 0;cursor:pointer;font-weight:550;font-size:12px;color:var(--muted);list-style:none}
.tcalc>summary::-webkit-details-marker{display:none}
.tcalc>summary::before{content:"";flex:none;align-self:center;width:0;height:0;border:5px solid transparent;border-left:6px solid var(--muted);transition:transform .16s;margin-right:2px}
.tcalc[open]>summary::before{transform:rotate(90deg)}
.tcalc-sum{flex:1;min-width:0}
.tcalc-sum-sub{font-size:12px;font-weight:550;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tcalc-body{padding:0}

/* the ported card: centered ~760px, thin border, 12px radius */
.tcalc-card{max-width:760px;margin:12px auto 0;border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:var(--shadow);font-size:14px}
.tcalc-head{display:flex;flex-direction:column;gap:2px;padding:16px 16px 0}
.tcalc-title{margin:0;font-size:14px;font-weight:600}
.tcalc-sub,.tcalc-ctx{margin:0;font-size:13px;color:var(--muted);line-height:1.55}
.tcalc-dim{color:var(--muted)}

/* main grid: controls 1fr, inset result pane .9fr, 16px gap and padding */
.tcalc-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,.9fr);gap:16px;padding:16px}
.tcalc-inputs{display:flex;flex-direction:column;gap:14px;min-width:0}
.tcalc-selrow{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.tcalc-f{margin:0;display:flex;flex-direction:column;gap:4px;min-width:0}
.tcalc-f label{font-size:13px;font-weight:600}
.tcalc-f input,.tcalc-f select{font:inherit;font-size:13px;padding:6px 8px;border:1px solid var(--line);border-radius:7px;background:var(--surface);color:var(--ink);width:100%;min-width:0}
.tcalc-f input[aria-invalid]{border-color:var(--down)}
.tcalc-radios{display:flex;flex-wrap:wrap;gap:6px 16px}
.tcalc-radios label,.tcalc-check label{display:flex;align-items:center;gap:7px;font-size:13px;cursor:pointer}
.tcalc-radios input,.tcalc-check input{width:auto;flex:none}
.tcalc-check{margin:0}
/* size-mode radio group rendered as a native fieldset/legend: reset only this
   widget's box so the generic _field rows elsewhere keep their own semantics */
.tcalc-size{padding:0;border:0;min-width:0}
.tcalc-size legend{padding:0;font-size:13px;font-weight:600}
.tcalc-hint{display:block;font-size:12px;color:var(--muted);line-height:1.5}
.tcalc-role-hint{margin:-4px 0 0}
.tcalc-err{font-size:12px;font-weight:600;color:var(--down);line-height:1.5;overflow-wrap:anywhere}

/* slider-paired numeric block: label + compact exact field on one line, then
   a thin neutral rail with a round thumb, then min/max captions */
.tcalc-num{display:flex;flex-direction:column;gap:4px;min-width:0}
.tcalc-num-top{display:flex;align-items:center;justify-content:space-between;gap:12px}
.tcalc-num-top label{font-size:13px;font-weight:600;min-width:0}
.tcalc-num-top input{flex:none;width:96px;height:28px;padding:0 8px;font:inherit;font-size:13px;font-weight:600;text-align:right;font-variant-numeric:tabular-nums;border:1px solid var(--line);border-radius:7px;background:var(--surface);color:var(--ink)}
.tcalc-num-top input[aria-invalid]{border-color:var(--down)}
/* drawn rail under a transparent native range input — keyboard, touch and the
   slider role stay native while the track/thumb match the component */
.tcalc-range{position:relative;height:24px;display:flex;align-items:center}
.tcalc-rail{position:absolute;left:0;right:0;top:50%;height:4px;margin-top:-2px;border-radius:999px;background:var(--line)}
.tcalc-fill{position:absolute;left:0;top:50%;height:4px;margin-top:-2px;border-radius:999px;background:var(--ink)}
.tcalc-thumb{position:absolute;top:50%;left:0;width:16px;height:16px;margin-top:-8px;border-radius:50%;background:var(--surface);border:1px solid var(--line);box-shadow:0 1px 3px rgba(0,0,0,.18);transition:transform .15s ease}
.tcalc-range input[type=range]{position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;opacity:0;cursor:pointer;-webkit-appearance:none;appearance:none}
.tcalc-range input[type=range]:disabled{cursor:default}
.tcalc-range:active .tcalc-thumb{transform:scale(1.1)}
.tcalc-range:has(input[type=range]:focus-visible) .tcalc-thumb{outline:2px solid var(--accent);outline-offset:2px}
/* an empty exact field means a quiet rail: no fill, no implied default thumb */
.tcalc-num.tcalc-empty .tcalc-fill{width:0}
.tcalc-num.tcalc-empty .tcalc-thumb{opacity:0}
/* but keyboard focus must stay visible on the quiet rail: the transparent
   thumb cannot paint its ring, so the range wrapper carries the outline */
.tcalc-num.tcalc-empty .tcalc-range:has(input[type=range]:focus-visible){outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
.tcalc-minmax{display:flex;justify-content:space-between;gap:8px;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}

/* fee settings and repeated rounds: subordinate native disclosures */
.tcalc-fees,.tcalc-rounds{margin:0;border:1px solid var(--line);border-radius:var(--radius)}
.tcalc-fees>summary,.tcalc-rounds>summary{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:9px 12px;cursor:pointer;font-size:13px;font-weight:650;list-style:none}
.tcalc-fees>summary{flex-wrap:wrap}
.tcalc-fees>summary::-webkit-details-marker,.tcalc-rounds>summary::-webkit-details-marker,.tcalc-ct>summary::-webkit-details-marker,.tcalc-src>summary::-webkit-details-marker,.tcalc-break>summary::-webkit-details-marker{display:none}
.tcalc-fees>summary::before,.tcalc-rounds>summary::before,.tcalc-ct>summary::before,.tcalc-src>summary::before,.tcalc-break>summary::before{content:"";flex:none;align-self:center;width:0;height:0;border:4px solid transparent;border-left:5px solid var(--muted);transition:transform .16s;margin-right:2px}
.tcalc-fees[open]>summary::before,.tcalc-rounds[open]>summary::before,.tcalc-ct[open]>summary::before,.tcalc-src[open]>summary::before,.tcalc-break[open]>summary::before{transform:rotate(90deg)}
.tcalc-fees-k{flex:1;min-width:0}
.tcalc-fees>summary>.tcalc-fees-k{min-width:auto}
/* status block keeps its one-line look while it fits; below that it wraps as a
   whole under the title and its own text wraps inside — never clipped, never
   overlapping, the configure control stays put. Long unbroken profile ids
   (quadratic_with_maker_fees) break anywhere instead of forcing overflow */
.tcalc-fees-v{display:flex;flex:none;min-width:0;max-width:100%;gap:8px;font-size:12px;font-weight:550;color:var(--muted)}
.tcalc-fees-v [data-tc="feestat"]{min-width:0;overflow-wrap:anywhere}
.tcalc-fees-go{color:var(--accent-ink);font-weight:650;flex:none}
.tcalc-fees-b{display:flex;flex-direction:column;gap:12px;padding:12px;border-top:1px solid var(--line)}
.tcalc-note-us{margin:0}

/* footer across the whole card: top border, right-aligned outline action */
.tcalc-foot{display:flex;justify-content:flex-end;border-top:1px solid var(--line);padding:12px 16px}
.tcalc-foot button{font:inherit;font-size:13px;font-weight:600;padding:7px 14px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--ink);cursor:pointer;transition:border-color .16s,background .16s}
.tcalc-foot button:hover{border-color:var(--muted);background:var(--chip)}
.tcalc select:focus-visible,.tcalc details:focus-visible{outline:2px solid var(--accent);outline-offset:3px}

/* the inset result pane: neutral fill, 32px headline, compact rows, flex so
   the cost bar sinks to the bottom like the source component */
.tcalc-res{display:flex;flex-direction:column;gap:14px;min-width:0;margin:0;padding:16px;border-radius:12px;background:var(--bg)}
.tcalc-res-k{margin:0;font-size:13px;color:var(--muted)}
.tcalc-res-big{margin:0;font-size:32px;font-weight:750;letter-spacing:-.02em;line-height:1.15;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.tcalc-res-sub{margin:0;font-size:12px;color:var(--muted);line-height:1.5}
.tcalc-res-inv{margin:0;font-size:13px;color:var(--muted);line-height:1.55}
.tcalc-dl{margin:0;display:grid;grid-template-columns:minmax(0,1fr) fit-content(56%);gap:5px 14px;font-size:13px}
.tcalc-dl dt{color:var(--muted);min-width:0}
.tcalc-dl dd{margin:0;min-width:0;text-align:right;font-variant-numeric:tabular-nums;font-weight:600;overflow-wrap:anywhere}
.tcalc-key{padding-top:10px;border-top:1px solid var(--line)}
.tcalc-net.up{color:var(--up)}
.tcalc-net.down{color:var(--down)}
.tcalc-metal{margin:0;font-size:12px;color:var(--muted);line-height:1.5}

/* segmented cost bar + legend: real expense parts, colors from the site chart
   palette; the bar is aria-hidden, the legend carries label/percent/money */
.tcalc-cost{display:flex;flex-direction:column;gap:8px;margin-top:auto;padding-top:6px}
.tcalc-cost-h{margin:0;font-size:12px;font-weight:650;color:var(--muted)}
.tcalc-bar{display:flex;height:8px;border-radius:999px;overflow:hidden;background:var(--line)}
.tcalc-seg{display:block;height:100%}
.tcalc-legend{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:4px;font-size:13px}
.tcalc-legend li{display:flex;align-items:baseline;gap:8px;min-width:0}
.tcalc-dot{align-self:center;width:9px;height:9px;border-radius:2px;flex:none}
.tcalc-lab{color:var(--muted);flex:1;min-width:0;overflow-wrap:anywhere}
.tcalc-lv{font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
.tcalc-c0{background:var(--c0)}
.tcalc-c1{background:var(--c1)}
.tcalc-c2{background:var(--c2)}

/* expandable full breakdown inside the pane; provenance below it */
.tcalc-break{margin:0;border-top:1px solid var(--line);padding-top:8px}
.tcalc-break>summary{display:flex;align-items:baseline;gap:8px;cursor:pointer;font-size:13px;font-weight:650;list-style:none}
.tcalc-break-b{padding-top:10px}
.tcalc-cum-h,.tcalc-meta-h{margin:12px 0 6px;font-size:12px;font-weight:650;color:var(--muted);border-top:1px dashed var(--line);padding-top:10px}
.tcalc-meta{margin:0;display:grid;grid-template-columns:1fr auto;gap:4px 14px;font-size:13px}
.tcalc-meta dt{color:var(--muted)}
.tcalc-meta dd{margin:0;text-align:right;font-variant-numeric:tabular-nums;max-width:34em;overflow-wrap:anywhere}
.tcalc-meta-src a{color:var(--accent-ink)}

/* contract rules and source disclosures stay small below the card */
.tcalc-ct,.tcalc-src{margin:12px 0 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--bg)}
.tcalc-ct>summary,.tcalc-src>summary{display:flex;align-items:baseline;gap:10px;padding:10px 12px;cursor:pointer;font-size:13px;font-weight:650;list-style:none}
.tcalc-ct-name{flex:none;max-width:60%;font-size:12px;font-weight:550;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tcalc-ct-body{padding:2px 12px 12px;border-top:1px solid var(--line)}
.tcalc-ct-body>*:first-child{margin-top:10px}
.tcalc-cq{margin:0 0 6px;font-size:14px;font-weight:600}
.tcalc-cmeta{margin:0 0 8px;font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.tcalc-rules-t{margin:0 0 8px;font:inherit;font-size:13px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
.tcalc-warn{margin:0 0 8px;font-size:13px;color:var(--muted)}
.tcalc-clinks-h{margin:8px 0 4px;font-size:12px;font-weight:650;color:var(--muted)}
.tcalc-clinks{margin:0;padding-left:18px;font-size:13px}
.tcalc-note{margin:10px 12px 0;font-size:12px;color:var(--muted);line-height:1.6}
.tcalc-break .tcalc-note{margin:10px 0 0}
.tcalc-refs{margin:4px 12px 12px;padding-left:18px;font-size:12px;color:var(--muted)}

/* debounced aria-live headline: visually hidden, still announced */
.tcalc-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

@media (max-width:720px){
 .tcalc-grid{grid-template-columns:1fr}
 .tcalc-meta{grid-template-columns:1fr}
 .tcalc-meta dd{text-align:left}
}
@media (max-width:560px){
 .tcalc-selrow{grid-template-columns:1fr}
 .tcalc>summary{flex-wrap:wrap}
 .tcalc-grid{padding:12px}
 .tcalc-head{padding:12px 12px 0}
 .tcalc-foot{padding:10px 12px}
 .tcalc-sum-sub{white-space:normal}
 .tcalc-res-big{font-size:26px}
}
/* coarse pointers get the source's 44px slider target and taller field */
@media (pointer:coarse){
 .tcalc-range{height:44px}
 .tcalc-num-top input{height:44px}
}
@media (prefers-reduced-motion:reduce){
 .tcalc summary::before{transition:none}
 .tcalc-thumb{transition:none}
}
