/* ===========================================================
   PTMMI — HPM Calculator page
   Loads after styles.css; reuses its tokens and components.
   =========================================================== */


/* semantic status palette. Muted rather than vivid: on a results card where
   every deduction is negative and every total positive, saturated red/green
   on each row reads as a consumer app. These still pass contrast; they just
   stop shouting. */
:root{--ok:#4caf7d;--err:#d9685e;--warnc:#d9a441}
:root[data-theme="light"]{--ok:#1d7a4a;--err:#b3382e;--warnc:#8a6410}

/* ---------- native cursor + reveal-trap safety ---------- */
.calc-page .split,.calc-page .reveal,.calc-page .reveal-up{opacity:1}

/* ---------- calculator typography: all sans ---------- */
/* the data-dense calculator sets everything in the sans face; the serif
   stays a marketing-site face only */
.calc-page{--serif:var(--sans)}

/* ---------- commodity-terminal shape & type ----------
   The page was built on the marketing template: 22px card radii, 40px pill
   buttons, a 46px serif headline price and glowing accents. A pricing desk
   reads figures, not display type, so the shapes square off, the numerals go
   tabular throughout, and colour is kept for meaning (ok / warn / error)
   rather than decoration. Tokens so monitoring.css can match. */
.calc-page{
  /* the Ops Monitor already runs on a single --r:4px; the calculator's larger
     surfaces take one step up from it so the two read as one system */
  --r-card:6px;       /* cards and sheets — was 14-22px */
  --r-ctl:4px;        /* inputs, buttons, segmented options — was 8-40px */
  --r-field:3px;      /* small chips and badges */
  --bar-fill:rgba(174,174,178,.78);   /* component bars — neutral, not status green */
  --bar-track:rgba(120,120,128,.26);
  --label-track:.14em;                /* uppercase labels — was .22em */
  font-variant-numeric:tabular-nums;
}
:root[data-theme="light"] .calc-page{
  --bar-fill:rgba(60,60,67,.55);
  --bar-track:rgba(60,60,67,.14);
}
.calc-page :is(.sheet,.fcard,.logcard){border-radius:var(--r-card)}
.calc-page :is(.sheet-inset,.basis,.review){border-radius:var(--r-ctl)}
.calc-page :is(input:not([type=range]),select,textarea,.btn,.mini-btn,.toggle){border-radius:var(--r-ctl)}
.calc-page .btn{text-transform:none;letter-spacing:.02em;font-size:0.8125rem}
.calc-page .btn:hover{transform:none}
.calc-page .sheet{box-shadow:none}
.calc-page .split{letter-spacing:-.01em;font-weight:600}
.calc-page .foot{margin-top:60px;padding:32px 0 28px;gap:12px}
.calc-page .foot img{height:36px}

/* ---------- contrast: cards & sliders ---------- */
.calc-page .sheet{background:rgba(24,27,31,.86);border-color:rgba(230,220,213,.22)}
.calc-page .sheet-inset{background:rgba(15,17,20,.55);border-color:rgba(230,220,213,.18)}
.calc-page .fcard{background:rgba(24,27,31,.86);border-color:rgba(230,220,213,.22)}
.calc-page input[type=range]{height:5px;background:transparent}
.calc-page input[type=range]::-webkit-slider-runnable-track{height:5px;border-radius:2px;
  background:var(--bar-track)}
.calc-page input[type=range]::-moz-range-track{height:5px;border-radius:2px;
  background:var(--bar-track)}
/* a fader handle rather than a glowing bead — reads as an instrument */
.calc-page input[type=range]::-webkit-slider-thumb{width:12px;height:20px;
  border-radius:3px;background:var(--brown-glow);border:1px solid var(--bone);
  box-shadow:none}
.calc-page input[type=range]::-moz-range-thumb{width:12px;height:20px;
  border-radius:3px;background:var(--brown-glow);border:1px solid var(--bone);
  box-shadow:none}
.calc-page .cbar .track{height:7px;background:var(--bar-track)}
:root[data-theme="light"] .calc-page .sheet,
:root[data-theme="light"] .calc-page .fcard{background:rgba(255,255,255,.88);border-color:rgba(42,42,46,.22)}
:root[data-theme="light"] .calc-page .sheet-inset{background:rgba(42,42,46,.07);border-color:rgba(42,42,46,.18)}

:root[data-theme="light"] .calc-page input[type=range]::-webkit-slider-thumb{border-color:#fff}

.calc-page button,.calc-page .btn,.calc-page select,.calc-page summary,
.calc-page label,.calc-page .tab{cursor:pointer}
.calc-page input,.calc-page textarea{cursor:text}
.calc-page input[type=range]{cursor:pointer}

/* ---------- dark theme: Apple-grouped palette, shared with site/pjb.css ----------
   The exact PJB Builder palette: a flat #000 ground with raised #1c1c1e cards
   and #2c2c2e cells, rather than the marketing site's translucent charcoal.
   Scoped to the calculator so index.html and monitoring.html keep their own
   look — including the #bg glow, which only this page flattens. */
:root:not([data-theme="light"]) .calc-page{
  --ink:#000;
  --ink-2:#000;
  --bone:#fff;
  --bone-dim:#aeaeb2;
  --line:rgba(84,84,88,.65);
  --brown-glow:#c9b19d;
  --glass:#1c1c1e;
  --ok:#52b98a;--err:#dd7a72;--warnc:#d9a441;
}
:root:not([data-theme="light"]) .calc-page .sheet,
:root:not([data-theme="light"]) .calc-page .fcard{
  background:#1c1c1e;border-color:rgba(84,84,88,.65);backdrop-filter:none}
:root:not([data-theme="light"]) .calc-page .sheet-inset,
:root:not([data-theme="light"]) .calc-page .fcard pre{
  background:#2c2c2e;border-color:rgba(84,84,88,.65)}
:root:not([data-theme="light"]) .calc-page :is(input:not([type=range]),select,textarea){
  background:#2c2c2e;border-color:rgba(84,84,88,.65)}


:root:not([data-theme="light"]) .calc-page .bottomnav{
  background:rgba(22,22,23,.78);border-color:rgba(84,84,88,.65)}
:root:not([data-theme="light"]) .calc-page .bottomnav button.active{color:#fff}
:root:not([data-theme="light"]) .calc-page .bottomnav button.active i{
  background:rgba(120,120,128,.32)}
/* the marketing ground is a #2c3036 glow with a vignette and a grain overlay;
   PJB's is flat black, and that lift — not the card colour — is what kept this
   page off true black. The layers stay in the markup for light mode. */
:root:not([data-theme="light"]) .calc-page #bg{background:#000}
:root:not([data-theme="light"]) .calc-page :is(.vignette,.grain){display:none}
:root:not([data-theme="light"]) .calc-page .nav{
  background:linear-gradient(180deg,rgba(0,0,0,.7),transparent)}
:root:not([data-theme="light"]) .calc-page .nav.solid{background:rgba(0,0,0,.82)}

/* ---------- light theme: remap the existing tokens ---------- */
:root[data-theme="light"]{
  --ink:#f2eee9;
  --ink-2:#e7e1da;
  --brown:#6d5b50;
  --brown-deep:#d9cfc6;
  --brown-glow:#755c4c;   /* was #8a6f5c: 4.03:1 on the page ground, under AA for 11px text */
  --bone:#2a2a2e;
  --bone-dim:#6f675f;
  --white:#111;
  --line:rgba(42,42,46,.14);
  --glass:rgba(255,255,255,.66);
}
:root[data-theme="light"] #bg{
  background:radial-gradient(120% 80% at 50% -10%, #fbf8f4 0%, var(--ink) 45%, var(--ink-2) 100%);
}
:root[data-theme="light"] .vignette{
  background:radial-gradient(120% 100% at 50% 45%,transparent 60%,rgba(150,140,130,.25) 100%)}
:root[data-theme="light"] .grain{opacity:.035}
:root[data-theme="light"] .nav.solid{background:rgba(242,238,233,.88)}
:root[data-theme="light"] .brand .logo-mark,
:root[data-theme="light"] .foot img{filter:brightness(0) opacity(.85)}
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea{background:rgba(255,255,255,.7);color:var(--bone)}
:root[data-theme="light"] input:focus,
:root[data-theme="light"] textarea:focus{background:#fff}
:root[data-theme="light"] .sheet-inset{background:rgba(42,42,46,.05)}

/* ---------- layout ---------- */
.calc{padding-top:152px;justify-content:flex-start;min-height:auto}
.calc-head{margin:0 auto 32px;width:100%}
.calc-head h1{font-size:clamp(1.625rem,3vw,2.5rem);margin:8px 0 12px;font-weight:600;letter-spacing:-.015em}
.reg-badge{display:flex;align-items:center;gap:8px;font-size:0.8125rem;color:var(--bone-dim)}
.reg-badge i{color:var(--brown-glow);font-size:1.0625rem}

.nav-tools{display:flex;gap:12px;align-items:center;margin-left:16px}
.toggle{background:transparent;border:1px solid var(--line);color:var(--bone-dim);
  border-radius:20px;padding:8px 12px;font-size:0.6875rem;font-weight:600;letter-spacing:.08em;
  font-family:var(--sans);transition:.3s}
.toggle:hover{border-color:var(--brown-glow);color:var(--bone)}

/* ---------- tabs (pointer widths) ----------
   The same three signals as the phone bar, in the shape a wider window wants:
   tab-bars.md — "in regular views, the icons and labels appear side by side".
   The tracking is Apple's, not the web's: San Francisco adds about +0.006em at
   this size, where this row carried +0.04em and read as a marketing label
   rather than a system control. */
.tabbar{display:flex;gap:4px;margin:0 auto 28px;width:100%;
  border-bottom:1px solid var(--line)}
.tab{display:inline-flex;align-items:center;gap:8px;background:none;border:none;
  color:var(--bone-dim);font-family:var(--sans);font-size:0.9375rem;font-weight:600;
  letter-spacing:.008em;padding:12px 16px;min-height:44px;position:relative;
  transition:color .3s}
.tab i{font-size:1.0625rem}
.tab::after{content:'';position:absolute;left:16px;right:16px;bottom:-1px;height:2px;
  background:var(--brown-glow);transform:scaleX(0);transition:transform .3s}
.tab:hover{color:var(--bone)}
.tab[aria-selected="true"]{color:var(--brown-glow)}
.tab[aria-selected="true"]::after{transform:scaleX(1)}

/* ---------- formula cards ---------- */
.formula-row{display:grid;grid-template-columns:1fr;gap:20px;
  margin:0 auto 28px;width:100%}
.fcard{border:1px solid var(--line);border-left:3px solid var(--bone-dim);
  border-radius:14px;padding:20px 24px;background:var(--glass);
  min-width:0}
.fcard.kepmen{border-left-color:var(--brown-glow)}
.fcard-title{display:block;font-size:0.6875rem;letter-spacing:var(--label-track);text-transform:uppercase;
  color:var(--brown-glow);font-weight:700;margin-bottom:12px}
.fcard pre{font-size:0.8125rem;line-height:1.7;color:var(--bone);overflow-x:auto;
  background:rgba(20,23,26,.35);border:1px solid var(--line);border-radius:9px;padding:12px 16px;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
:root[data-theme="light"] .fcard pre{background:rgba(42,42,46,.06)}
.fcard-note{display:block;margin-top:12px;font-size:0.8125rem;color:var(--bone-dim)}

/* ---------- panel scaffolding ---------- */
/* One column by default; the two-column row and the form's own inner split
   are opted into at >=1360px, where the input card is wide enough for them.
   The old `.9fr 1.05fr 1.05fr` described the three-card layout that existed
   before Formula Lama was removed — the third track was still being reserved
   and sat empty, 34% of the row at 1920. */
.calc-wrap{display:grid;grid-template-columns:1fr;gap:20px;
  margin:0 auto;width:100%;align-items:start}
.calc-wrap .results{display:contents}
.cpanel{padding:clamp(20px,2.4vw,30px)}
/* title + saved badge + Reset on one row; it has to wrap once the reader's
   text size grows, or Reset is pushed past the card */
.cpanel-head{display:flex;align-items:center;gap:12px;margin-bottom:20px;flex-wrap:wrap}
.panel-title{display:inline-flex;align-items:center;gap:8px;font-size:0.8125rem;
  letter-spacing:var(--label-track);text-transform:uppercase;font-weight:700;color:var(--bone)}
.panel-title.sm{font-size:0.6875rem;letter-spacing:.16em}
.dot-mark{width:7px;height:7px;border-radius:50%;background:var(--brown-glow);display:inline-block}
.dot-mark.ok{background:var(--ok)}
.dot-mark.accent{background:#e8d4c4}
.saved-badge{margin-left:auto;display:inline-flex;align-items:center;gap:8px;
  font-size:0.6875rem;letter-spacing:.16em;text-transform:uppercase;color:var(--ok);font-weight:600}
.mini-btn{background:transparent;border:1px solid var(--line);color:var(--bone-dim);
  font-family:var(--sans);font-size:0.6875rem;font-weight:600;letter-spacing:.06em;
  border-radius:8px;padding:8px 12px;transition:.3s}
.mini-btn:hover{border-color:var(--brown-glow);color:var(--bone)}
.mini-btn.danger{color:var(--err)}
.mini-btn.danger:hover{border-color:var(--err)}
.sheet-inset{background:rgba(20,23,26,.4);border:1px solid var(--line);
  border-radius:12px;padding:16px 20px}

/* ---------- ore-type segmented control ----------
   Saprolit / Limonit price under different Kepmen coefficients, so the choice
   sits above the grades rather than inside them. Built as the PJB segmented
   control: a recessed track with a raised thumb on the selected option. */
.oreblock{margin-bottom:24px}
:is(.oreseg,.sideseg){display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;
  background:rgba(230,220,213,.09);border:1px solid var(--line);border-radius:var(--r-ctl)}
:is(.oreopt,.sideopt){appearance:none;border:1px solid transparent;background:none;border-radius:var(--r-field);
  padding:8px 12px;font-family:var(--sans);font-size:0.8125rem;font-weight:600;
  color:var(--bone-dim);transition:background .25s,color .25s,border-color .25s}
:is(.oreopt,.sideopt):hover{color:var(--bone)}
:is(.oreopt,.sideopt)[aria-checked="true"]{background:var(--glass);color:var(--bone);
  border-color:var(--line);box-shadow:0 1px 3px rgba(0,0,0,.28)}
:is(.oreopt,.sideopt):focus-visible{outline:2px solid var(--brown-glow);outline-offset:2px}
:root[data-theme="light"] :is(.oreseg,.sideseg){background:rgba(42,42,46,.07)}
:root:not([data-theme="light"]) .calc-page :is(.oreseg,.sideseg){background:rgba(120,120,128,.32)}
:root:not([data-theme="light"]) .calc-page :is(.oreopt,.sideopt)[aria-checked="true"]{
  background:#2c2c2e;border-color:rgba(84,84,88,.65)}

/* ---------- form fields ---------- */
.fgroup{border:0;padding:0;margin:24px 0 0}
.group-label{display:flex;align-items:center;gap:12px;font-size:0.6875rem;letter-spacing:var(--label-track);
  text-transform:uppercase;color:var(--brown-glow);font-weight:700;margin-bottom:16px;width:100%}
.group-label::before,.group-label::after{content:'';height:1px;flex:1;
  background:repeating-linear-gradient(90deg,var(--line) 0 4px,transparent 4px 8px)}
.field{margin-bottom:28px}
.field label{display:block;font-size:0.8125rem;font-weight:600;color:var(--bone);margin-bottom:4px}
.field label [lang=id]{font-weight:600}
.label-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
.label-row output{font-size:0.8125rem;color:var(--bone-dim);font-variant-numeric:tabular-nums}
.side-note{font-size:0.6875rem;color:var(--bone-dim)}
/* Each grade field is one grid: label, slider and hint stack tightly in
   column 1, while the number box moves to column 2 and spans them. The box no
   longer sets the slider row's height, so the slider can sit close to both its
   own title and its own hint instead of floating midway between two fields.
   display:contents hoists the range + number box out of .slider-pair and into
   this grid, so the markup and the JS wiring stay untouched. */
.slider-field{display:grid;grid-template-columns:1fr 96px;column-gap:12px;
  margin-bottom:32px}
.slider-field .label-row{grid-column:1;grid-row:1}
.slider-field label{margin-bottom:0}
.slider-field .slider-pair{display:contents}
/* the thumb overflows the 5px track by ~6.5px each way, so the margin — not a
   row-gap, which would survive a hidden hint — carries the clearance */
.slider-field input[type=range]{grid-column:1;grid-row:2;margin:8px 0}
.slider-field .hint{grid-column:1;grid-row:3;margin-top:0}
.slider-field input[type=number]{grid-column:2;grid-row:1/4;align-self:center;
  padding:8px 12px}
.slider-pair{display:grid;grid-template-columns:1fr 96px;gap:12px;align-items:center}
input[type=range]{-webkit-appearance:none;appearance:none;height:3px;border:0;padding:0;
  background:var(--line);border-radius:2px}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:20px;
  border-radius:3px;background:var(--brown-glow);border:none}
input[type=range]::-moz-range-thumb{width:12px;height:20px;border-radius:3px;
  background:var(--brown-glow);border:none}
.field input[type=number],.field input[type=text]{font-variant-numeric:tabular-nums}
.field input[readonly]{color:var(--bone-dim);font-size:0.8125rem}
.hint{font-size:0.6875rem;color:var(--bone-dim);margin-top:8px;line-height:1.55;min-height:0}
.hint:empty{display:none}
.hint.ok{color:var(--ok)}
.hint.warnc{color:var(--warnc)}
.warn{font-size:0.8125rem;color:var(--err);margin-top:8px;line-height:1.55}
.warn::before{content:"⚠ "}
input[aria-invalid="true"]{border-color:var(--err)}
.check{display:flex;align-items:flex-start;gap:8px;font-size:0.8125rem;color:var(--bone);
  margin:8px 0;line-height:1.5}
.check input{width:auto;margin-top:4px}

.import-btn{margin-bottom:4px}
.import-status{font-size:0.8125rem;color:var(--bone-dim);min-height:16px;margin:8px 0}
.import-status.ok{color:var(--ok)}
.import-status.err{color:var(--err)}

/* review panel */
.review{margin:12px 0 8px}
.review-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.review-rows{display:flex;flex-direction:column;gap:8px}
.review-row{display:grid;grid-template-columns:auto 44px 1fr 34px;gap:12px;align-items:center}
.review-row input[type=checkbox]{width:auto}
.review-row .rname{font-size:0.8125rem;font-weight:600;color:var(--bone)}
.review-row input[type=text]{padding:8px 12px;font-size:0.8125rem;font-variant-numeric:tabular-nums}
.review-row input[type=text].missing{border-color:var(--err);color:var(--err)}
.review-row .runit{font-size:0.6875rem;color:var(--bone-dim)}
.raw-text summary{font-size:0.6875rem;color:var(--bone-dim);padding:12px 0;list-style:none}
.raw-text textarea{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:0.6875rem}
.review-actions{display:flex;gap:12px;margin-top:12px}
.review-actions .apply-btn{margin-top:0;width:auto;flex:1}

/* basis / staleness */
.basis{margin-top:12px}
.basis p{font-size:0.6875rem;color:var(--bone-dim);line-height:1.6}
.basis p b{color:var(--bone)}

/* ---------- result cards ---------- */
.rcard{padding:clamp(18px,2.2vw,26px)}
.fsub{font-size:0.6875rem;color:var(--bone-dim);margin:-8px 0 16px}
/* the price reads left-aligned under its own label, at a size you compare
   against the figures beside it rather than a centred display numeral */
.hpm-hero{text-align:left;padding:16px 16px;margin-bottom:12px}
.hpm-cap{display:block;font-size:0.6875rem;letter-spacing:var(--label-track);text-transform:uppercase;
  color:var(--bone-dim);margin-bottom:8px}
.hpm-big{font-family:var(--sans);font-size:clamp(1.6875rem,2.5vw,2.125rem);line-height:1.05;
  font-weight:600;letter-spacing:-.01em;color:var(--bone);font-variant-numeric:tabular-nums}
.hpm-big.accent{color:var(--brown-glow)}
.hpm-per{display:inline-block;font-size:0.6875rem;color:var(--bone-dim);margin:8px 0 0}
/* the secondary figures are hairline-separated fields, not floating chips */
.stat-tiles{display:grid;grid-template-columns:repeat(2,1fr);gap:0;margin-bottom:16px;
  border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
.tile{background:none;border:0;border-radius:0;padding:12px 16px;text-align:left}
.tile + .tile{border-left:1px solid var(--line)}
.tile span{display:block;font-size:0.6875rem;letter-spacing:var(--label-track);text-transform:uppercase;
  color:var(--bone-dim);margin-bottom:4px}
.tile b{font-size:0.9375rem;font-weight:600;color:var(--bone);
  font-variant-numeric:tabular-nums;white-space:nowrap}

/* component bars */
.comp-bars{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
.cbar{display:grid;grid-template-columns:26px 1fr auto;gap:12px;align-items:center}
.cbar .cname{font-size:0.8125rem;font-weight:600;color:var(--bone)}
.cbar .track{height:7px;border-radius:1px;background:var(--bar-track);overflow:hidden}
.cbar .fill{display:block;height:100%;border-radius:0;background:var(--bar-fill);
  transition:width .35s ease}
.cbar .cval{font-size:0.8125rem;color:var(--bone);font-variant-numeric:tabular-nums;white-space:nowrap}
.cbar.off .cname,.cbar.off .cval{color:var(--bone-dim);opacity:.6}
.cbar.off .cval{font-size:0.8125rem}

/* revenue / deduction rows */
.rev-box{margin-bottom:12px}
.ded-box{margin-bottom:16px}
.row-line{display:flex;align-items:baseline;justify-content:space-between;gap:12px;
  padding:8px 0;font-size:0.8125rem;color:var(--bone)}
.row-line b{font-variant-numeric:tabular-nums;white-space:nowrap;font-weight:600}
.row-line.big{font-size:0.9375rem;font-weight:600}
.row-line.big b{font-size:0.9375rem}
.row-line.total{border-top:1px solid var(--line);margin-top:8px;padding-top:12px;
  font-weight:700;letter-spacing:.04em}
.row-line.total span{text-transform:uppercase;font-size:0.8125rem;letter-spacing:.12em}
.row-sub{display:flex;justify-content:space-between;font-size:0.6875rem;color:var(--bone-dim);
  font-variant-numeric:tabular-nums}
.row-sub.right{justify-content:flex-end}
.neg{color:var(--err)}
.pos{color:var(--ok)}
.row-line .muted{color:var(--bone-dim)}


/* ---------- data tables (COA log) ---------- */
.tscroll{overflow-x:auto;margin-top:16px}
.ctable{width:100%;border-collapse:collapse;font-size:0.8125rem}
.ctable th{font-size:0.6875rem;letter-spacing:.16em;text-transform:uppercase;color:var(--bone-dim);
  font-weight:700;text-align:right;padding:12px 12px;border-bottom:1px solid var(--line)}
.ctable th:first-child{text-align:left}
.ctable td{padding:12px 12px;border-bottom:1px solid var(--line);text-align:right;
  font-variant-numeric:tabular-nums;color:var(--bone);white-space:nowrap}
.ctable td:first-child{text-align:left;font-weight:600}
.ctable td.accent{color:var(--brown-glow)}
.ctable td.up{color:var(--ok)}
.ctable td.down{color:var(--err)}
.save-btn{margin:20px auto 0;display:flex}
.sideseg{margin:6px 0 8px}
/* WhatsApp copy beside Save: two equal buttons, stacked on a narrow phone */
.act-row{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:20px}
.act-row .btn{margin:0;width:100%;justify-content:center;min-height:44px}
/* white on the taupe in both themes (6.4:1); the light theme turns --bone dark */
.calc-page .wa-btn,.calc-page .wa-btn:hover{background:var(--brown);color:#fff}
.calc-page .wa-btn:hover{background:#5c4b41}
@media (max-width:599px){.act-row{grid-template-columns:1fr}}
.wa-status{margin:8px 0 0;min-height:1.25rem;font-size:0.8125rem;color:var(--bone-dim);text-align:center}
.wa-fallback{width:100%;margin-top:8px;padding:12px;border-radius:12px;border:1px solid var(--line);
  background:var(--bar-track);color:var(--bone);font:0.8125rem/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;resize:vertical}

.srcnote{margin:24px auto 0;width:100%;font-size:0.6875rem;
  color:var(--bone-dim);line-height:1.6}

/* ---------- assumptions ---------- */
.assumptions{margin-top:24px;border-top:1px solid var(--line)}
.assumptions summary{display:flex;align-items:center;gap:8px;font-size:0.6875rem;
  letter-spacing:.18em;text-transform:uppercase;color:var(--brown-glow);font-weight:700;
  padding:16px 0 12px;list-style:none}
.assumptions summary::-webkit-details-marker{display:none}
.assumptions[open] summary i{transform:rotate(180deg)}
.assumptions summary i{transition:.3s;font-size:0.9375rem}
.assume-body{padding-bottom:8px}

/* ---------- COA log ---------- */
.logcard{margin:0 auto 24px;width:100%;padding:clamp(20px,2.4vw,30px)}
.logtable{font-size:0.8125rem}
.logtable th,.logtable td{padding:8px 8px}
.logtable .del{background:none;border:none;color:var(--err);font-size:0.9375rem;padding:4px 8px}
#logEmpty{margin-top:16px}
.chart-legend{display:flex;flex-wrap:wrap;gap:20px;justify-content:center;margin:8px 0 16px}
.chart-legend span{display:inline-flex;align-items:center;gap:8px;font-size:0.6875rem;color:var(--bone-dim)}
.chart-legend i{width:9px;height:9px;border-radius:50%;display:inline-block}
#trendChart{width:100%;min-width:640px;height:auto}
#trendChart text{font-family:var(--sans);font-size:0.6875rem;fill:var(--bone-dim)}
#trendChart .grid{stroke:var(--line);stroke-width:1}
#trendChart .axis-label{font-size:0.6875rem;letter-spacing:.08em;text-transform:uppercase}

/* flex/grid min-width traps: wide tables must scroll inside .tscroll,
   never stretch their flex parent past the viewport. The panels are
   nested (#panel-calc > .logcard > .tscroll), so constrain every level. */
/* This selector carries ID specificity, so it is what actually sets the
   width of every block on this page — the calculator runs full-bleed inside
   the .act padding, and per-block max-widths here would be dead letters. */
.calc > *,#panel-calc,#panel-log,#panel-calc > *,#panel-log > *{min-width:0;max-width:100%}
/* the grid items inside .calc-wrap need it too, or at large text sizes their
   min-content width pushes the card past the viewport */
.calc-wrap > *,.calc-wrap .cpanel,.calc-wrap .rcard{min-width:0}
#panel-calc,#panel-log{width:100%}
.tscroll{max-width:100%;min-width:0}

/* ---------- a11y ---------- */
.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;
  clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}

/* ---------- responsive ---------- */
/* Two panels side by side, and the form itself flowing into two balanced
   inner columns — its four fieldsets stack 2279px tall against the results
   card's 1062px, so a single tower leaves the right-hand card beside a wall
   of blank. Multi-column balances the two halves itself; placing the blocks
   by hand would only move the void inside the card. 1440px is the first width
   where each inner column clears the ~330px a slider row needs — measured, not
   derived: at 1360 the columns came out 309px. */
/* side by side as soon as the results card clears ~410px; the form only
   splits in two once it is wide enough for that as well */
@media(min-width:1200px){
  .calc-wrap{grid-template-columns:1.5fr 1fr}
}
@media(min-width:1440px){
  .cpanel{columns:2;column-gap:28px}
  /* column-span only applies to block-level boxes, and .btn is inline-flex —
     without the display switch the Import button would sit in column 1 at
     half width while the header above it spans */
  .cpanel > .import-btn{display:flex}
  .cpanel > :is(.cpanel-head,.import-btn,.import-status,.review,
    .paste-toggle,.paste-panel){column-span:all}
  .cpanel > :is(.oreblock,.fgroup,.assumptions){break-inside:avoid}
  /* the reference card is one short line of formula; left as a stacked block
     it became a 1700px-wide box holding 450px of text. On one row it fills
     the band and gives back ~85px of vertical space. */
  .formula-row .fcard{display:grid;grid-template-columns:auto 1fr auto;
    align-items:center;column-gap:28px;padding:16px 24px}
  .formula-row .fcard-title{margin-bottom:0}
  .formula-row .fcard pre{margin:0}
  .formula-row .fcard-note{margin-top:0;text-align:right}
}
@media(max-width:900px){
  .calc{padding-top:112px}
  .formula-row{grid-template-columns:1fr}
  .nav-tools{margin-left:auto;margin-right:16px}
  .nav.open .links{display:flex;position:absolute;top:100%;left:0;right:0;flex-direction:column;
    gap:20px;padding:24px;background:rgba(20,23,26,.96);backdrop-filter:blur(14px)}
  :root[data-theme="light"] .nav.open .links{background:rgba(242,238,233,.97)}
}

/* ---------- phone tab bar — a floating glass capsule ----------
   iOS's shape: the icon over its label, in a bar that floats clear of the
   content. The sizes are the HIG's, not guesses.

   · tab-bars.md asks for a visible label — "A tab label appears beneath or
     beside a tab bar icon … Use single words whenever possible". All four are
     single words, in both languages.
   · the label is 11px. typography.md gives iOS a 17pt default and an 11pt
     minimum, and sets Caption 2 at 11. A system tab bar's own label is 10pt,
     but that is SF drawing itself at its own optical sizes; Montserrat at 11
     is the honest equivalent.
   · the target is 48pt tall, over accessibility.md's 44pt floor.
   · selection is marked three ways at once — the pill, the icon's stroke
     weight and the label's weight — so it never rests on colour alone
     (color.md: "Avoid relying solely on color to differentiate between
     objects"). */
.bottomnav{display:none}
@media(max-width:900px){
  .tabbar{display:none}
  /* clearance for the capsule and the result dock above it; in rem, so it
     grows with the reader's text size instead of trapping the last field */
  .calc{padding-bottom:7.5rem}
  .foot{margin-bottom:5.5rem}

  .bottomnav{position:fixed;left:50%;transform:translateX(-50%);
    bottom:calc(10px + env(safe-area-inset-bottom));
    z-index:60;display:grid;grid-auto-flow:column;grid-auto-columns:1fr;
    /* four equal columns at a stated width, so the labels are not left to a
       shrink-to-fit guess; it narrows rather than running off a 320px screen,
       and the gutter clears a phone's side inset too */
    width:316px;max-width:calc(100vw - 2*max(16px,env(safe-area-inset-left,0px)));
    background:rgba(28,31,35,.55);
    -webkit-backdrop-filter:blur(24px) saturate(1.4);backdrop-filter:blur(24px) saturate(1.4);
    border:1px solid rgba(230,220,213,.14);border-radius:27px;padding:4px;
    box-shadow:0 10px 28px -10px rgba(0,0,0,.55)}
  :root[data-theme="light"] .bottomnav{background:rgba(255,255,255,.55);
    border-color:rgba(42,42,46,.14);box-shadow:0 18px 44px -18px rgba(60,50,40,.45)}

  .bottomnav button{min-width:0;
    display:flex;flex-direction:column;align-items:center;justify-content:center;
    gap:4px;min-height:48px;padding:4px 4px 4px;border-radius:22px;
    background:none;border:none;color:var(--bone-dim);transition:color .3s}
  .bottomnav button i{font-size:1.0625rem;display:inline-flex;align-items:center;
    justify-content:center;width:42px;height:24px;border-radius:999px;
    transition:background .3s}
  .bottomnav button span{max-width:100%;font-family:var(--sans);font-size:0.6875rem;
    font-weight:500;letter-spacing:.012em;line-height:1.1;
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .bottomnav button.active{color:var(--bone)}
  .bottomnav button.active span{font-weight:600}
  .bottomnav button.active i{background:rgba(230,220,213,.16)}
  :root[data-theme="light"] .bottomnav button.active i{background:rgba(42,42,46,.12)}
  /* the ring follows the button now that the button has a label to enclose */
  .bottomnav button:focus-visible{outline:2px solid var(--brown-glow);
    outline-offset:-2px}
  /* one section per view */
  :root[data-mview="input"] :is(#cardKepmen,.formula-row,.srcnote){display:none}
  :root[data-mview="kepmen"] .cpanel{display:none}
  /* tighter header in single-view mode */
  :root[data-mview] .calc-head{margin-bottom:16px}
  :root[data-mview] .calc-head h1{font-size:clamp(1.625rem,7vw,2.125rem)}
}

/* ---------- touch targets ----------
   Apple's floor is 44x44 pt on touch (accessibility.md › Mobility; desktop is
   28x28, which these already clear). The painted sizes stay as designed — the
   hit area is extended underneath, since the box a finger can land on is what
   the guideline measures, not the box that is drawn. */
@media (pointer:coarse){
  .calc-page :is(.toggle,.mini-btn,.oreopt,.sideopt,.brand,.tab,.bottomnav button,
    input[type=checkbox]){position:relative}
  /* .burger is NOT in this list: its ::after is already one of the two bars
     (styles.css), and overwriting it painted a solid 44x44 block of --bone
     in the phone header. It gets its hit area from its own box instead. */
  .calc-page .burger{width:44px;height:44px}
  .calc-page .burger::before,.calc-page .burger::after{left:13px;right:13px}
  .calc-page .burger::before{top:17px}
  .calc-page .burger::after{bottom:17px}
  .calc-page :is(.toggle,.mini-btn,.oreopt,.sideopt,.brand,.tab,.bottomnav button,
    input[type=checkbox])::after{
    content:'';position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
    width:max(100%,44px);height:max(100%,44px)}
  .calc-page :is(input[type=number],input[type=text],input[type=date],select){min-height:44px}
  .calc-page summary{min-height:44px;display:flex;align-items:center}
  /* the slider's grabbable band grows to 44px while the painted track stays
     5px — the element goes transparent and the track draws itself, because a
     padded element paints its background across the whole box */
  .calc-page input[type=range]{height:44px;padding:0}
  /* once the band is 44px the thumb has to be re-centred on the 5px track */
  .calc-page input[type=range]::-webkit-slider-thumb{margin-top:-7.5px}
}


/* ---------- press feedback ----------
   apple-motion §1: respond on pointer-down, not on release. These are
   background/colour changes rather than transitions, so they still land when
   prefers-reduced-motion kills every transition on the page. */
.calc-page :is(.btn,.mini-btn,.toggle,.tab,.oreopt,.sideopt,.bottomnav button,summary):active{
  opacity:.72}
.calc-page :is(.oreopt,.sideopt):active{background:var(--glass)}

/* ---------- reduced transparency ----------
   apple-motion §14 / materials.md: make the material frostier and solid, and
   drop the blur, rather than leaving a translucent surface no one asked for. */
@media (prefers-reduced-transparency:reduce){
  .calc-page :is(.sheet,.fcard,.logcard,.sheet-inset){backdrop-filter:none}
  .calc-page .nav.solid,.calc-page .bottomnav{backdrop-filter:none}
  :root:not([data-theme="light"]) .calc-page .bottomnav{background:#161617}
  :root[data-theme="light"] .calc-page .bottomnav{background:#fff}
  :root:not([data-theme="light"]) .calc-page .nav.solid{background:#000}
  :root[data-theme="light"] .calc-page .nav.solid{background:#f2eee9}
}

/* ---------- increased contrast ----------
   near-solid grounds with a defined border, per apple-motion §14. */
@media (prefers-contrast:more){
  .calc-page{--line:currentColor}
  .calc-page :is(.sheet,.fcard,.logcard,.sheet-inset,input,select,textarea,.btn,.oreseg,.sideseg){
    border-width:1px;border-style:solid}
  .calc-page .hint{color:var(--bone)}
  :root:not([data-theme="light"]) .calc-page{--bone-dim:#d8d8dc}
  :root[data-theme="light"] .calc-page{--bone-dim:#3a352f}
}

/* ---------- text scaling ----------
   typography.md › Supporting Dynamic Type: the layout has to adapt to the
   reader's text size. kalkulator.css is in rem throughout; these are the
   shared components from styles.css, re-declared in rem but only inside
   .calc-page — styles.css itself stays in px so index.html, which is not in
   scope and whose hero cannot take a doubled headline, is untouched. */
.calc-page :is(.btn,.links a){font-size:0.8125rem}
.calc-page .btn i{font-size:1.0625rem}
.calc-page :is(input:not([type=range]),select,textarea){font-size:0.9375rem}
.calc-page .kicker{font-size:0.6875rem}
.calc-page .foot small{font-size:0.8125rem}
/* the number box was a fixed 96px column; minmax(0,auto) lets it grow with the
   text but still shrink rather than push the card open */
.slider-field{grid-template-columns:minmax(0,1fr) minmax(0,auto)}

/* em in a media query resolves against the root, so this is a text-size query:
   on a 390px phone the viewport is 24em at the default size but 12em at 200%.
   typography.md › Supporting Dynamic Type: "consider using a stacked layout
   where text appears above secondary items ... Reduce the number of columns
   when the font size increases." */
@media (max-width:20em){
  .slider-field{grid-template-columns:1fr}
  .slider-field :is(.label-row,input[type=range],.hint,input[type=number]){grid-column:1}
  .slider-field input[type=number]{grid-row:auto;width:100%;align-self:stretch}
  .calc-page .stat-tiles{grid-template-columns:1fr}
  .calc-page .tile + .tile{border-left:0;border-top:1px solid var(--line)}
}

/* =====================================================================
   Blending panel
   Built from the existing tokens (--line, --bone, --bone-dim, --ok,
   --err, --r-card/--r-ctl) so it inherits the Apple restyle rather than
   introducing a second visual language. Reserved colours are untouched.
   ===================================================================== */
.blend-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.blend-rule{display:flex;align-items:center;gap:8px;font-size:0.6875rem;
  letter-spacing:var(--label-track);text-transform:uppercase;color:var(--bone-dim)}
.blend-rule input[type=date]{background:transparent;border:1px solid var(--line);
  border-radius:var(--r-ctl);color:var(--bone);padding:4px 8px;font:inherit;
  font-size:0.8125rem;letter-spacing:normal;text-transform:none;min-height:32px}
.blend-rule input[type=date]:focus-visible{outline:2px solid var(--brown-glow);outline-offset:1px}

.blendtable td{vertical-align:middle}
.blin{width:72px;background:transparent;border:1px solid var(--line);
  border-radius:var(--r-ctl);color:var(--bone);padding:4px 8px;font:inherit;
  font-size:0.8125rem;text-align:right;min-height:32px}
.blin:focus-visible{outline:2px solid var(--brown-glow);outline-offset:1px;border-color:var(--brown-glow)}

.ore-chip{display:inline-block;padding:4px 8px;border-radius:var(--r-field);
  border:1px solid var(--line);font-size:0.6875rem;letter-spacing:.04em;
  text-transform:capitalize;color:var(--bone-dim)}
.ore-chip.saprolit{border-color:var(--ore-sap);color:var(--ore-sap)}
.ore-chip.limonit{border-color:var(--ore-lim);color:var(--ore-lim)}

.blend-grid{display:grid;gap:8px;margin-top:4px;
  grid-template-columns:repeat(auto-fit,minmax(168px,1fr))}
.btile{border:1px solid var(--line);border-radius:var(--r-card);padding:12px 12px;
  display:flex;flex-direction:column;gap:4px;min-height:60px;justify-content:center}
.btile-k{font-size:0.6875rem;letter-spacing:var(--label-track);text-transform:uppercase;
  color:var(--bone-dim)}
.btile-v{font-size:0.9375rem;color:var(--bone);font-variant-numeric:tabular-nums}
.btile.ok .btile-v{color:var(--ok)}
.btile.bad .btile-v{color:var(--err)}

@media (max-width:640px){
  .blin{width:62px}
  .blend-grid{grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}
}

/* ============================================================
   Review pass — apple-motion §1 / §14, accessibility.md, typography.md
   ============================================================ */

/* --- the phone result dock -------------------------------------------
   The result rail stacks below every input at phone width, so dragging a
   slider used to change a figure roughly 650px off screen. This keeps the
   two headline numbers in view while the inputs are being worked.
   (apple-motion §1: feedback continuous during the interaction.) */
.hpmdock{display:none}
@media(max-width:900px){
  .hpmdock{position:fixed;left:50%;transform:translateX(-50%);
    bottom:calc(78px + env(safe-area-inset-bottom));
    z-index:59;display:flex;align-items:baseline;gap:.5rem;
    max-width:calc(100vw - 24px);padding:8px 12px;
    background:rgba(28,31,35,.62);
    -webkit-backdrop-filter:blur(24px) saturate(1.4);backdrop-filter:blur(24px) saturate(1.4);
    border:1px solid rgba(230,220,213,.14);border-radius:999px;
    box-shadow:0 10px 28px -12px rgba(0,0,0,.55);
    font-variant-numeric:tabular-nums;white-space:nowrap;
    transition:opacity .25s}
  :root[data-theme="light"] .hpmdock{background:rgba(255,255,255,.72);
    border-color:rgba(42,42,46,.14);box-shadow:0 14px 34px -16px rgba(60,50,40,.4)}
  .hpmdock__k{font-size:0.6875rem;letter-spacing:.14em;text-transform:uppercase;color:var(--bone-dim)}
  .hpmdock__v{font-size:1.0625rem;font-weight:600;color:var(--brown-hi,#c8a27a)}
  .hpmdock__n{font-size:0.8125rem;font-weight:600}
  .hpmdock__sep{width:1px;height:14px;background:currentColor;opacity:.18}
  /* the dock sits above the nav, so clearance grows by its height */
  .calc{padding-bottom:9rem}
}
@media(prefers-reduced-transparency:reduce){
  .hpmdock{backdrop-filter:none;background:#14171a}
  :root[data-theme="light"] .hpmdock{background:#fff}
}

/* --- press feedback ---------------------------------------------------
   apple-motion §1: "Respond on pointer-down, not on release." The page had
   two :active rules in 628 lines, on a screen that is almost all controls. */
.calc-page :is(.toggle,.mini-btn,.oreopt,.sideopt,.tab,.bottomnav button,.burger,
  button[data-mview],.btn,.chipbtn){transition:transform .1s ease-out,
  background .25s,color .25s,border-color .25s}
.calc-page :is(.toggle,.mini-btn,.oreopt,.sideopt,.tab,.bottomnav button,.burger,
  button[data-mview],.btn,.chipbtn):active{transform:scale(.97)}
.calc-page :is(.oreopt,.sideopt):active,.calc-page .tab:active{transform:scale(.985)}
@media(prefers-reduced-motion:reduce){
  .calc-page :is(.toggle,.mini-btn,.oreopt,.sideopt,.tab,.bottomnav button,.burger,
    button[data-mview],.btn,.chipbtn):active{transform:none}
}

/* --- phone type scale -------------------------------------------------
   typography.md › Ensuring legibility: iOS default 17pt, minimum 11pt.
   120 of ~170 text runs sat under 13px and the scale did not change for
   touch, so a phone had essentially nothing at reading size. Labels and
   values come up; true micro-labels stay where they are. */
@media(max-width:560px){
  .calc-page .ctrl > label,
  .calc-page .field > label,
  .calc-page label:not(.fld__l){font-size:0.9375rem}
  .calc-page input[type=number],
  .calc-page input[type=text],
  .calc-page select{font-size:1.0625rem}
  .calc-page .hint,.calc-page .fsub{font-size:0.8125rem;line-height:1.45}
  .calc-page .row-line{font-size:0.9375rem}
  .calc-page .row-sub{font-size:0.8125rem}
  .calc-page .tile b{font-size:1.0625rem}
  .calc-page .tile span{font-size:0.6875rem}
}

/* --- desktop control minimums ----------------------------------------
   accessibility.md › Mobility: desktop default 28x28, minimum 20x20. The
   coarse-pointer block above covers touch; with a mouse the range track was
   5px and the checkboxes 13px, both under the floor. The painted hairline
   is unchanged — only the box the pointer can land on grows. */
@media(pointer:fine){
  .calc-page input[type=range]{height:20px;background:transparent;cursor:pointer}
  .calc-page input[type=checkbox]{width:20px;height:20px}
}

/* ---------- navigation icons: SF-Symbols-style strokes ----------
   Drawn here, not borrowed: SF Symbols are licensed for Apple platforms, so
   this is Apple's *drawing grammar* on a 24-unit grid — one stroke weight
   across the whole set, round caps and joins, no fill.
   icons.md: "all interface icons in your app need to use a consistent size,
   level of detail, stroke thickness (or weight), and perspective" and "match
   the weights of interface icons and adjacent text". The selected tab gets a
   heavier stroke, the way an SF Symbol steps up a weight — so selection is
   carried by weight AND the pill AND the colour, never colour alone
   (color.md: "Avoid relying solely on color to differentiate between
   objects"). */
.calc-page :is(.tab,.bottomnav button,.toggle,.reg-badge) [data-ico] svg{stroke-width:1.8}
/* the badge wraps to three lines on a phone: as a flex item the icon was
   being squeezed from 17px to 6.3px (its circle to 4.6px) and parked against
   the middle line. It keeps its size and sits on the first line, which is
   where the eye starts reading (layout.md > Visual hierarchy). */
.calc-page .reg-badge{align-items:flex-start}
.calc-page .reg-badge i{flex:none}
.calc-page .tab[aria-selected="true"] [data-ico] svg,
.calc-page .bottomnav button.active [data-ico] svg{stroke-width:2.3}
@media (prefers-reduced-motion:no-preference){
  .calc-page :is(.tab,.bottomnav button) [data-ico] svg{
    transition:stroke-width .28s cubic-bezier(.22,1,.36,1)}
}
/* the appearance toggle shows the mode it switches TO; the pill keeps the
   language pill's 30px height so the pair still sits on one optical line */
.calc-page .toggle.ico{display:inline-flex;align-items:center;justify-content:center;
  padding:8px 12px}
.calc-page .toggle.ico i{font-size:0.9375rem}
.calc-page .toggle.ico [data-ico] svg{stroke-width:2.2}
.calc-page .toggle .ico-moon{display:none}
:root[data-theme="light"] .calc-page .toggle .ico-sun{display:none}
:root[data-theme="light"] .calc-page .toggle .ico-moon{display:inline-flex}
/* two bars, 18px wide, rounded caps — the 30px square-ended pair read as a
   web hamburger rather than a system control */
.calc-page .burger::before,.calc-page .burger::after{border-radius:1.5px;height:1.8px}
@media (pointer:fine){
  /* on touch the same bars sit inside a 44x44 box, set in the touch-target
     block above; this is only the narrow-window-on-a-mouse case */
  .calc-page .burger{width:18px;height:11px}
  .calc-page .burger::before{top:0}
  .calc-page .burger::after{bottom:0}
}

/* ---------- slider tick marks ----------
   The Fe <= 35% and Co >= 0,05% gates and the saprolit/limonit boundary at
   1,2% Ni are the three values that change the arithmetic. sliders.md: "Use
   tick marks to increase clarity and accuracy." A gate you can see coming
   beats a warning you read after tripping it.
   The thumb is 12px, so the track's travel is (100% - 12px) and the mark sits
   6px in; --p and --top are written by syncTicks(). */
.calc-page .slider-field{position:relative}
.calc-page .tickmark{position:absolute;z-index:1;pointer-events:none;
  top:var(--top,0);left:var(--left,0);
  transform:translateX(-50%);display:flex;flex-direction:column;
  align-items:center;gap:1px}
.calc-page .tickmark i{display:block;width:1px;height:8px;background:var(--bone-dim);
  opacity:.75}
.calc-page .tickmark b{font-size:0.6875rem;font-weight:600;color:var(--bone-dim);
  line-height:1;white-space:nowrap;font-variant-numeric:tabular-nums}

/* a comfortable band under the pointer too: 20px was Apple's bare minimum,
   28px is the desktop control size (accessibility.md > Mobility) */
@media (pointer:fine){
  .calc-page input[type=range]{height:28px;padding:0}
  .calc-page input[type=range]::-webkit-slider-thumb{margin-top:-7.5px}
}

/* ---------- ore type ----------
   Saprolit and limonit each have a colour of their own, reserved in DESIGN.md
   3.3. Saprolit is the teal of saprolite and its garnierite, pushed off the
   reserved grade green; limonit is ochre, because ochre pigment is limonite.
   Every reserved colour is at least CIEDE2000 12 away, so neither can be read
   as a grade class, an SI state, a contractor or a status; both pass 4.5:1 as
   text on every ground here. The ore's name always sits beside its colour
   (color.md: never colour alone). Set from renderOre() as body[data-ore]. */
.calc-page{--ore-sap:#0e7469;--ore-lim:#5e4f1f}
:root:not([data-theme="light"]) .calc-page{--ore-sap:#62d8cf;--ore-lim:#f5d596}

/* the chosen segment wears its ore — colour and edge, on top of the fill and
   weight it already had, so selection still never rests on colour alone */
:root .calc-page .oreopt[data-ore="saprolit"][aria-checked="true"]{
  color:var(--ore-sap);border-color:color-mix(in srgb,var(--ore-sap) 60%,transparent)}
:root .calc-page .oreopt[data-ore="limonit"][aria-checked="true"]{
  color:var(--ore-lim);border-color:color-mix(in srgb,var(--ore-lim) 60%,transparent)}

/* the decree badge's check, which names the ore in the line beside it */
body[data-ore="saprolit"] .calc-page .reg-badge i,
body[data-ore="saprolit"].calc-page .reg-badge i{color:var(--ore-sap)}
body[data-ore="limonit"] .calc-page .reg-badge i,
body[data-ore="limonit"].calc-page .reg-badge i{color:var(--ore-lim)}

/* ---------- sliders: the HPM Kalkulator's solid dot (owner, 17 Nov 2026) ----------
   A 16px dot filled with the ore's colour — saprolit teal, limonit ochre —
   inside a white rim, and the track filled up to it in the same colour, so
   every slider says which ladder is pricing the ore. Held, it grows and a
   halo opens round it. It keeps its 16px layout width while held on purpose:
   a slider's travel is the track minus the knob, so a knob that widened
   while dragged would shift the 1,2 / 35 / 0,05 ticks under the pointer.
   The grabbable band (44px touch, 28px pointer) is unchanged; syncTicks()
   measures with the same 16px. Declared on body.calc-page so it outranks the
   fader rules above in every theme and media block. */
body.calc-page input[type=range]{--fill:var(--brown-glow)}
body[data-ore="saprolit"].calc-page input[type=range]{--fill:var(--ore-sap)}
body[data-ore="limonit"].calc-page input[type=range]{--fill:var(--ore-lim)}
body.calc-page input[type=range]::-webkit-slider-runnable-track{height:4px;border-radius:2px;
  background:var(--track,var(--bar-track))}
body.calc-page input[type=range]::-moz-range-track{height:4px;border-radius:2px;
  background:var(--bar-track)}
body.calc-page input[type=range]::-moz-range-progress{height:4px;border-radius:2px;background:var(--fill)}
body.calc-page input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;
  box-sizing:border-box;width:16px;height:16px;margin-top:-6px;border-radius:50%;
  background:var(--fill);border:2.5px solid #fff;
  box-shadow:0 .5px 1px rgba(0,0,0,.28),0 2px 6px rgba(0,0,0,.22);
  transition:transform .3s cubic-bezier(.34,1.56,.64,1),box-shadow .2s}
body.calc-page input[type=range]::-moz-range-thumb{box-sizing:border-box;width:16px;height:16px;
  border-radius:50%;background:var(--fill);border:2.5px solid #fff;
  box-shadow:0 .5px 1px rgba(0,0,0,.28),0 2px 6px rgba(0,0,0,.22)}
@media (hover:hover){
  body.calc-page input[type=range]:hover::-webkit-slider-thumb{transform:scale(1.12)}
}
body.calc-page input[type=range]:active::-webkit-slider-thumb{transform:scale(1.3);
  box-shadow:0 1px 2px rgba(0,0,0,.25),0 3px 10px rgba(0,0,0,.22),
    0 0 0 5px color-mix(in srgb,var(--fill) 22%,transparent)}
body.calc-page input[type=range]:active::-moz-range-thumb{
  box-shadow:0 0 0 5px color-mix(in srgb,var(--fill) 22%,transparent)}
body.calc-page input[type=range]:focus-visible{outline:none}
body.calc-page input[type=range]:focus-visible::-webkit-slider-thumb{
  box-shadow:0 .5px 1px rgba(0,0,0,.28),0 0 0 3px var(--brown-glow)}
@media (prefers-reduced-motion:reduce){
  body.calc-page input[type=range]::-webkit-slider-thumb{transition:box-shadow .2s}
  body.calc-page input[type=range]:hover::-webkit-slider-thumb,
  body.calc-page input[type=range]:active::-webkit-slider-thumb{transform:none}
}

/* ---------- glass (owner, 17 Nov 2026) ----------
   Every card is frosted glass, as in the HPM Kalkulator: translucent, a 24px
   backdrop blur, a hairline highlight along the top edge. Glass needs
   something behind it, so the page ground gets the same warm MMI-brown glow
   the artifact uses — static here, no drift. Text contrast is checked
   against the real composited pixels, not the declared colours. Declared on
   body.calc-page so it outranks the opaque-card rules above in both themes;
   reduced transparency falls back to a near-solid fill (block below). */
:root:not([data-theme="light"]) body.calc-page #bg{
  background:
    radial-gradient(42% 38% at 8% 4%,rgba(107,60,26,.42),transparent 70%),
    radial-gradient(36% 34% at 96% 40%,rgba(138,90,44,.30),transparent 70%),
    radial-gradient(48% 40% at 40% 104%,rgba(53,37,23,.46),transparent 72%),
    #060505}
:root[data-theme="light"] body.calc-page #bg{
  background:
    radial-gradient(42% 38% at 8% 4%,rgba(224,173,120,.44),transparent 70%),
    radial-gradient(36% 34% at 96% 40%,rgba(234,202,159,.34),transparent 70%),
    radial-gradient(48% 40% at 40% 104%,rgba(208,158,104,.48),transparent 72%),
    #efe9e0}
body.calc-page :is(.sheet,.fcard,.logcard){position:relative;
  -webkit-backdrop-filter:blur(24px) saturate(1.6);backdrop-filter:blur(24px) saturate(1.6);
  box-shadow:0 8px 24px -12px rgba(0,0,0,.35)}
body.calc-page :is(.sheet,.logcard)::before{content:'';position:absolute;top:0;left:18px;right:18px;
  height:1px;pointer-events:none;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.22),transparent)}
:root:not([data-theme="light"]) body.calc-page :is(.sheet,.fcard,.logcard){background:rgba(30,25,21,.5)}
:root:not([data-theme="light"]) body.calc-page :is(.sheet,.logcard){border-color:rgba(255,255,255,.1)}
/* the formula card's thick left edge carries meaning; only the other sides change */
:root:not([data-theme="light"]) body.calc-page .fcard{
  border-top-color:rgba(255,255,255,.1);border-right-color:rgba(255,255,255,.1);border-bottom-color:rgba(255,255,255,.1)}
:root:not([data-theme="light"]) body.calc-page .sheet-inset{
  background:rgba(0,0,0,.22);border-color:rgba(255,255,255,.08)}
:root[data-theme="light"] body.calc-page :is(.sheet,.fcard,.logcard){background:rgba(255,255,255,.52)}
:root[data-theme="light"] body.calc-page :is(.sheet,.logcard){border-color:rgba(255,255,255,.7)}
:root[data-theme="light"] body.calc-page .fcard{
  border-top-color:rgba(255,255,255,.7);border-right-color:rgba(255,255,255,.7);border-bottom-color:rgba(255,255,255,.7)}
:root[data-theme="light"] body.calc-page .sheet-inset{
  background:rgba(255,255,255,.4);border-color:rgba(60,42,28,.1)}
@media (prefers-reduced-transparency:reduce){
  body.calc-page :is(.sheet,.fcard,.logcard){-webkit-backdrop-filter:none;backdrop-filter:none}
  :root:not([data-theme="light"]) body.calc-page :is(.sheet,.fcard,.logcard){background:rgba(30,25,21,.94)}
  :root[data-theme="light"] body.calc-page :is(.sheet,.fcard,.logcard){background:rgba(255,255,255,.95)}
}
/* the source note sits on the warm ground itself, not a card: one step darker
   in light mode so it clears 4.5:1 on the brightest part of the glow */
:root[data-theme="light"] body.calc-page .srcnote{color:#5a524a}
/* component bars take the ore's colour, as in the HPM Kalkulator; a mineral
   that does not count keeps the grey .off treatment */
body[data-ore="saprolit"].calc-page .cbar:not(.off) .fill{background:var(--ore-sap)}
body[data-ore="limonit"].calc-page .cbar:not(.off) .fill{background:var(--ore-lim)}
