:root {
  --bg: #f3f2ee; --panel: #ffffff; --fg: #1d1f22; --muted: #6b6f76; --line: #dcdad3; --grid: #e7e5df;
  --accent: #8a4b14; --accent-fg: #fff; --bad: #c0392b;
  --c-p: #c0392b; --c-v: #1f6fb2; --c-e: #2e8b57; --c-1: #d98a1c; --c-2: #b0392b; --c-3: #5a4bb0;
  --ad: repeating-linear-gradient(45deg, #ebe9e3 0 10px, #e4e2db 10px 20px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --panel: #1e2125; --fg: #e7e6e2; --muted: #9aa0a8; --line: #33373d; --grid: #2a2e33;
    --accent: #e0a060; --accent-fg: #1a1a1a; --bad: #ff6b5b; --c-p: #ff7a6b; --c-v: #6fb3ff; --c-e: #6fd39a;
    --c-1: #f0b050; --c-2: #ff7a6b; --c-3: #a99bff; --ad: repeating-linear-gradient(45deg, #1b1e22 0 10px, #202328 10px 20px);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --panel: #1e2125; --fg: #e7e6e2; --muted: #9aa0a8; --line: #33373d; --grid: #2a2e33;
  --accent: #e0a060; --accent-fg: #1a1a1a; --bad: #ff6b5b; --c-p: #ff7a6b; --c-v: #6fb3ff; --c-e: #6fd39a;
  --c-1: #f0b050; --c-2: #ff7a6b; --c-3: #a99bff; --ad: repeating-linear-gradient(45deg, #1b1e22 0 10px, #202328 10px 20px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; }
body.tryanyway { overflow: auto; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; width: 100%; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 0; overflow: hidden; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 86px 46px; align-items: center; gap: 6px; padding: 1px 0; }
.row .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row input { width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; background: var(--bg); text-align: right; }
.row .unit { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; }
.row.adv { display: none; }
body.showadv .row.adv { display: grid; }
.muted { color: var(--muted); }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--accent); }
.ad { background: var(--ad); border: 1px dashed var(--line); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; overflow: hidden; }
#summary .t { font-weight: 700; font-size: 14px; }
#summary div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--grid); }
.kv b { font-variant-numeric: tabular-nums; }
.kv.p b { color: var(--c-p); } .kv.v b { color: var(--c-v); } .kv.e b { color: var(--c-e); } .kv.bad b { color: var(--bad); }
.warn { color: var(--bad); font-weight: 600; margin-top: 4px; }
#ladder { display: flex; gap: 4px; overflow: hidden; flex-wrap: nowrap; }
.lstep { flex: 1 1 0; min-width: 0; padding: 2px 2px; font-size: 12px; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.lstep small { color: var(--muted); font-size: 10px; } .lstep.on small { color: inherit; }
.lstep.over { border-color: var(--bad); }
canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.chk { display: flex; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); white-space: nowrap; }
.disclaimer { font-size: 10.5px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(80px); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px; transition: transform .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); } .toast.bad { background: var(--bad); color: #fff; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal[hidden] { display: none; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; max-width: 560px; width: 100%; max-height: 100%; overflow: auto; }
.modal h3 { margin: 0 0 8px; }
.modal p, .modal li { margin: 6px 0; }
#gate .box { text-align: center; max-width: 420px; }
#gate .box button { margin-top: 10px; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); padding: 6px 16px; }
body.gated #app { visibility: hidden; }

/* calibration library */
.modal .cbox { max-width: 980px; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.chead { display: flex; gap: 8px; align-items: center; }
.chead h3 { margin: 0; white-space: nowrap; } .chead select { flex: 1; }
.cbody { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; min-height: 0; }
.ccol { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 8px; }
.cf { display: flex; flex-direction: column; gap: 1px; font-size: 11px; color: var(--muted); min-width: 0; }
.cf i { font-style: normal; }
.cf input, .cf textarea { font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; width: 100%; resize: none; }
.cf textarea#cShots { font-family: ui-monospace, Menlo, monospace; }
.cload { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
#cOut table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; }
#cOut th, #cOut td { text-align: right; padding: 1px 4px; border-bottom: 1px solid var(--grid); }
#cOut th { color: var(--muted); font-weight: 600; }
.cbtns { display: flex; gap: 6px; flex-wrap: wrap; } .cbtns .sp { flex: 1; }
.ctabs { display: none; }

/* community */
.modal .mbox { max-width: 900px; height: min(620px, 100%); display: flex; flex-direction: column; gap: 8px; }
.mfilter { display: flex; gap: 8px; align-items: center; }
.mfilter input[type=search], .mfilter input[type=text] { flex: 1; min-width: 0; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
#mList { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.mrow { display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--grid); padding: 3px 0; height: 42px; }
.mtxt { flex: 1; min-width: 0; } .mtxt, .mtxt div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .mtxt .muted { font-size: 11.5px; }
.mfoot { display: flex; gap: 6px; align-items: center; } .mfoot .sp { flex: 1; } #mStatus { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#shPreview { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 11px; height: 220px; overflow: hidden; margin: 8px 0; white-space: pre-wrap; }
#mPage { white-space: nowrap; }
