:root{
  --ink:#1a1a1a; --muted:#6a6560; --line:#ded9d0; --bg:#faf8f4;
  --panel:#fff; --accent:#1f4e79;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);
  font:18px/1.55 Charter,"PT Serif",Palatino,Georgia,"DejaVu Serif",serif}
/* The page is as wide as two canvases need: the canvas size is set by the window height,
   so the source and sky panels and the controls beneath them fit without scrolling. */
:root{--cv:max(320px, calc(100vh - 372px))}
header,main,footer{max-width:min(1460px, max(1180px, calc(2 * var(--cv) + 104px)));margin:0 auto;padding:0 22px}

#err{position:fixed;inset:0 0 auto 0;z-index:99;background:#7a1420;color:#fff;
  padding:9px 14px;font:12.5px/1.4 ui-monospace,Menlo,monospace;white-space:pre-wrap}
#tip{position:fixed;z-index:50;pointer-events:none;background:rgba(255,255,255,.96);
  border:1px solid var(--line);border-radius:6px;padding:6px 10px;font-size:.86rem;line-height:1.4;
  color:var(--ink);box-shadow:0 2px 8px rgba(0,0,0,.08);white-space:nowrap}
#tip .r{display:flex;justify-content:space-between;gap:14px}
#tip .r span{color:var(--muted)}
#tip .r b{font-weight:500;font-variant-numeric:tabular-nums}

.bar{display:flex;align-items:center;gap:22px;flex-wrap:wrap;padding-top:10px;
  padding-bottom:8px;border-bottom:1px solid var(--line)}
.mark{font-size:1.7rem;letter-spacing:-.025em;line-height:1.05;white-space:nowrap}
.tag{color:var(--muted);font-size:1rem}
.ghost{color:var(--muted);font:inherit;font-size:.9rem;flex:0 0 auto;
  padding:3px 12px;border:1px solid var(--line);border-radius:5px;
  background:transparent;cursor:pointer}
.ghost:hover{background:#f1ede5;color:var(--ink)}
#reset{margin-left:auto}

.seg{display:inline-flex;border:1px solid var(--line);border-radius:6px;overflow:hidden;flex:0 0 auto}
.seg button{font:inherit;font-size:.92rem;padding:2px 11px;border:0;
  background:transparent;color:var(--muted);cursor:pointer;white-space:nowrap}
.seg button+button{border-left:1px solid var(--line)}
.seg button[aria-pressed="true"]{background:var(--accent);color:#fff}
.seg.sm button{font-size:.86rem;padding:1px 9px}
.seg[hidden]{display:none}

.models{display:flex;border:1px solid var(--line);border-radius:6px;overflow:hidden;margin:2px 0 9px}
.models button{flex:1 1 auto;font:inherit;font-size:.92rem;padding:3px 8px;border:0;white-space:nowrap;
  background:transparent;color:var(--muted);cursor:pointer}
.models button+button{border-left:1px solid var(--line)}
.models button:hover{background:#f1ede5;color:var(--ink)}
.models button[aria-pressed="true"]{background:var(--accent);color:#fff}

/* Three panels in a row, the controls in a strip beneath; the canvases shrink with the
   window height so the controls stay on screen without scrolling. */
main{padding-top:10px;padding-bottom:6px}
.panels{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;align-items:start}
.controls{display:grid;grid-template-columns:minmax(360px,1.4fr) minmax(280px,1.05fr) minmax(255px,1fr) minmax(200px,.8fr);
  gap:12px;margin-top:12px;align-items:stretch}
.lensgrid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0 18px}
.controls section,.panel{background:var(--panel);border:1px solid var(--line);
  border-radius:8px;padding:9px 12px 10px}
h2{font-size:.93rem;font-weight:600;letter-spacing:.055em;text-transform:uppercase;
  color:var(--muted);margin:0 0 9px}
.ph{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap}
.ph h2{margin-bottom:7px}
.ph .sub{font-size:.9rem;color:var(--muted);margin-left:auto}
.gh{display:flex;align-items:baseline;justify-content:space-between;gap:8px;flex-wrap:wrap}
.gh .btns{display:flex;gap:6px}
.gh .ghost{font-size:.82rem;padding:2px 8px}
#readSub{margin-top:2px}

.ctl{margin-bottom:5px}
.ctl label{display:flex;justify-content:space-between;align-items:baseline;
  gap:8px;font-size:.95rem;line-height:1.3;color:var(--muted);margin-bottom:1px}
.ctl .val{color:var(--ink);font-variant-numeric:tabular-nums;font-size:1.0rem;white-space:nowrap}
input[type=range]{display:block;width:100%;accent-color:var(--accent);height:16px;margin:0}
sup,sub{line-height:0}
.caserow{display:flex;align-items:center;justify-content:space-between;gap:8px;
  margin:2px 0 8px;font-size:1.0rem;color:var(--muted)}
.chk{display:flex;align-items:center;gap:8px;font-size:.95rem;color:var(--muted);margin:3px 0;cursor:pointer}
.chk input{accent-color:var(--accent);margin:0}

.rd{display:flex;justify-content:space-between;gap:10px;font-size:.92rem;line-height:1.35;
  padding:2px 0;border-bottom:1px dotted var(--line)}
.rd:last-child{border-bottom:none}
.rd span{color:var(--muted)}
.rd b{font-weight:500;font-variant-numeric:tabular-nums;text-align:right}

body.m-point .only-cored, body.m-point .only-ell, body.m-sis .only-cored, body.m-sis .only-ell,
body.m-cored .only-ell:not(.only-cored){display:none}
body.s-pt .only-ext{display:none}

/* The canvases are square: the CSS fixes the height from the width, so fit() can
   size the backing store from the measured box without the canvas growing. */
canvas{display:block;width:100%;max-width:var(--cv);margin:0 auto;
  aspect-ratio:1 / 1;height:auto;touch-action:none}
#cvS{cursor:crosshair}

  border-bottom:1px solid var(--line);padding:3px 6px}

footer{padding:6px 22px 34px;font-size:.93rem;color:var(--muted);line-height:1.55}
footer p{margin:.5em 0;max-width:110ch}
.src{font-size:.86rem}

/* colorbar in the sky panel header: stretch switch, gradient with tick marks and labels, title */
.ph{height:40px;align-items:center;flex-wrap:nowrap}
.ph h2{margin:0}
.cbrow{display:flex;align-items:flex-start;gap:12px;margin-left:auto}
.cbar{position:relative;width:170px;height:27px;margin-top:3px}
#cbGrad{height:9px;border-radius:2px;border:1px solid var(--line)}
#cbTicks{position:relative;height:17px}
#cbTicks .tk{position:absolute;top:0;transform:translateX(-50%);padding-top:5px;white-space:nowrap;
  font-size:.74rem;line-height:1;color:#3b3733;font-variant-numeric:tabular-nums}
#cbTicks .tk::before{content:"";position:absolute;left:50%;top:0;width:1px;height:4px;background:#6a6560}
#cbTicks .tk.lo{transform:none} #cbTicks .tk.lo::before{left:0}
#cbTicks .tk.hi{transform:translateX(-100%)} #cbTicks .tk.hi::before{left:auto;right:0}
.cblab{font-size:.8rem;color:var(--muted);line-height:1;white-space:nowrap;margin-top:3px}

/* the two-handled color-range slider */
.crctl{margin-top:6px}
.crctl label{white-space:nowrap}
.dual{position:relative;height:18px;margin:2px 7px 0;touch-action:none}
.dual .trk{position:absolute;left:0;right:0;top:7px;height:4px;border-radius:2px;background:#e3ded5}
.dual .fill{position:absolute;top:7px;height:4px;border-radius:2px;background:var(--accent);cursor:grab}
.dual .h{position:absolute;top:2px;width:14px;height:14px;margin-left:-7px;border-radius:50%;background:#fff;
  border:2px solid var(--accent);cursor:ew-resize;box-sizing:border-box}

/* the mass-profile pop-up */
.modal{position:fixed;inset:0;z-index:80;background:rgba(20,18,15,.38);display:flex;align-items:center;justify-content:center;padding:16px}
.modal[hidden]{display:none}
.mbox{background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 40px rgba(0,0,0,.25);
  width:min(980px, 100%);padding:12px 16px 12px}
.mhead{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}
.mhead h2{margin:0}
#cvP{width:100%;aspect-ratio:2.25 / 1;max-width:none;height:auto}
.mnote{font-size:.85rem;color:var(--muted);margin:6px 0 0;line-height:1.4}

@media (max-width:1180px){ .controls{grid-template-columns:repeat(2,minmax(0,1fr))} }
@media (max-width:640px){ .models{flex-wrap:wrap} }
@media (max-width:640px){
  .panels,.controls,.lensgrid{grid-template-columns:minmax(0,1fr)}
  .ph{height:auto;flex-wrap:wrap;row-gap:6px}
  .cbrow{margin-left:0;flex-wrap:wrap;row-gap:4px}
  canvas{max-width:none}
}
@media (max-width:860px){
  header,main,footer{padding-left:16px;padding-right:16px}
  .mark{font-size:1.6rem;white-space:normal}
  .tag{display:none}
  #reset{margin-left:0}
}

.legend{display:flex;align-items:center;gap:8px;font-size:.88rem;color:var(--muted);margin-top:6px;flex-wrap:wrap}
.legend .cbar{display:inline-block;width:150px;height:10px;border-radius:2px}
.legend[hidden]{display:none}
.caserow .btns{display:flex;gap:6px}

