/* RUI Sphere frontend. Self-hosted IBM Plex (SIL OFL 1.1) in fonts/; system fonts are the fallback. */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: local("IBM Plex Sans"), local("IBMPlexSans"), url("fonts/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: local("IBM Plex Sans SemiBold"), local("IBMPlexSans-SemiBold"), url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap;
  src: local("IBM Plex Mono Medium"), local("IBMPlexMono-Medium"), url("fonts/IBMPlexMono-Medium.woff2") format("woff2"); }

:root {
  --font: "IBM Plex Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --bg: #f4f2ee;
  --surface: #ffffff;
  --line: #e2ddd5;
  --line-strong: #c9c2b7;
  --ink: #1f2421;
  --ink-2: #5c6560;
  --accent: #0f6e66;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ef;
  --field: #fbfaf8;
  --warn: #8a5a00;
  --warn-bg: #fdf4e3;
  --stop: #a3302a;
  --stop-bg: #fbeceb;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121514; --surface: #1a1e1c; --line: #2b312e; --line-strong: #3b433f; --ink: #e7ebe8; --ink-2: #9aa59f;
    --accent: #4fc2b5; --accent-ink: #08201d; --accent-soft: #163330; --field: #151917;
    --warn: #f0c46a; --warn-bg: #2e2716; --stop: #f08a83; --stop-bg: #331c1a;
  }
}
:root[data-theme="dark"] {
  --bg: #121514; --surface: #1a1e1c; --line: #2b312e; --line-strong: #3b433f; --ink: #e7ebe8; --ink-2: #9aa59f;
  --accent: #4fc2b5; --accent-ink: #08201d; --accent-soft: #163330; --field: #151917;
  --warn: #f0c46a; --warn-bg: #2e2716; --stop: #f08a83; --stop-bg: #331c1a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--ink-2); margin: 0 0 14px; }

/* header */
.top { max-width: 1120px; margin: 0 auto; padding: 22px 20px 6px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 3; }
.name { font-weight: 600; font-size: 20px; letter-spacing: -.01em; }
.sub { display: block; font-size: 12px; color: var(--ink-2); margin-top: -2px; }
.proto { margin: 0; font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; }

/* two panes */
.layout { max-width: 1120px; margin: 0 auto; padding: 14px 20px 24px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 20px; margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.lbl { font-size: 13px; font-weight: 600; }
.lbl em { font-style: normal; font-weight: 400; color: var(--ink-2); margin-left: 4px; }

/* inputs with unit suffix */
.in { position: relative; display: flex; align-items: center; }
.in i { position: absolute; right: 10px; font-style: normal; font-size: 13px; color: var(--ink-2); pointer-events: none; }
input[type=number], select {
  width: 100%; height: 40px; padding: 0 34px 0 12px; font: 500 15px var(--mono); color: var(--ink);
  background: var(--field); border: 1px solid var(--line-strong); border-radius: 8px;
}
select { font-family: var(--font); font-weight: 400; padding-right: 12px; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input:focus, select:focus, summary:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input:disabled, select:disabled { opacity: .55; }
input.bad, select.bad { border-color: var(--stop); background: var(--stop-bg); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto 84px; align-items: center; gap: 8px; }
.at { font-size: 13px; color: var(--ink-2); }
.axo { font: 500 15px var(--mono); color: var(--ink-2); padding-left: 4px; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; height: 40px; width: 100%; }
.seg label { flex: 1; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; padding: 0 10px; background: var(--field); }
.seg label + label span { border-left: 1px solid var(--line-strong); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.seg input:disabled + span { opacity: .45; cursor: not-allowed; }

/* special cases */
.opt { border-top: 1px solid var(--line); padding: 2px 0; }
.opt:first-of-type { border-top: 0; }
.opt summary { cursor: pointer; list-style: none; padding: 12px 0; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
.opt summary::-webkit-details-marker { display: none; }
.opt summary::before { content: "+"; font: 500 16px var(--mono); color: var(--accent); width: 14px; }
.opt[open] summary::before { content: "–"; }
.opt .hint { font-weight: 400; font-size: 13px; color: var(--ink-2); }
.opt .fields { padding: 2px 0 6px 24px; }
.help { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 12px 24px; }
.opt.active summary::after { content: "on"; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }

.actions { display: flex; gap: 10px; }
button { font: 600 15px var(--font); height: 44px; padding: 0 22px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); flex: 1; max-width: 260px; }
button:disabled { opacity: .6; cursor: progress; }

/* results */
.results { position: sticky; top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-height: 220px; }
.empty { color: var(--ink-2); }
.empty .small { font-size: 13px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.hero .k { font-size: 12.5px; color: var(--ink-2); }
.hero .big { font: 500 44px/1 var(--mono); letter-spacing: -.02em; margin: 6px 0 4px; }
.hero .big small { font: 400 16px var(--font); color: var(--ink-2); margin-left: 4px; }
.hero .meta { font-size: 13px; color: var(--ink-2); }
.chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; background: var(--accent-soft); color: var(--accent); }
.chip.Moderate, .chip.Uncalibrated { background: var(--warn-bg); color: var(--warn); }
.chip.Low { background: var(--stop-bg); color: var(--stop); }
.results h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 18px 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font-size: 12px; font-weight: 600; color: var(--ink-2); text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { font-family: var(--mono); font-weight: 500; text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
td.txt { font-family: var(--font); font-weight: 400; }
tr.pick td { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
tr.pick td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.msg { border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin: 0 0 8px; }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.stop { background: var(--stop-bg); color: var(--stop); }
.note { font-size: 12.5px; color: var(--ink-2); margin: 8px 0 0; }
.res-actions { margin-top: 16px; display: flex; gap: 8px; }
.res-actions button { height: 36px; font-size: 13px; padding: 0 14px; }
.scroll { overflow-x: auto; }

/* printout scan */
.scan-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn { position: relative; display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; background: var(--surface); }
.btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.scan-status { margin: 0; font-size: 13px; color: var(--ink-2); }
.scan-status.ok { color: var(--accent); }
.scan-status.bad { color: var(--stop); }
.help.flush { margin-left: 0; }
.scan-preview { margin-top: 6px; }
.scan-preview img { max-height: 120px; max-width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; cursor: zoom-in; display: block; }
.scan-preview.big img { max-height: none; cursor: zoom-out; }
.scan-found { margin: 10px 0 0; padding-left: 18px; font-size: 13.5px; }
.scan-found:empty { display: none; }
input.ocr, select.ocr { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn-bg); background: var(--warn-bg); }
input.ocr-flag { border-width: 2px; border-color: var(--stop); }
.scan-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 12px; }
.scan-banner p { margin: 0; flex: 1 1 260px; }
.scan-banner button { height: 34px; font-size: 13px; padding: 0 12px; }
[hidden] { display: none !important; }
.nolog { margin: 10px 0 4px; font-size: 13.5px; padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.method { margin-top: 6px; font-size: 13.5px; }
.method summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0; }
.method ol { margin: 6px 0 4px; padding-left: 20px; }
.method li { margin-bottom: 5px; }
.privacy { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 14px; color: var(--ink); font-size: 13.5px; }
.privacy ul { margin: 0; padding-left: 18px; }
.privacy li { margin-bottom: 5px; }

.foot { max-width: 1120px; margin: 0 auto; padding: 0 20px 28px; font-size: 12px; color: var(--ink-2); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .results { position: static; }
}
@media (max-width: 520px) {
  .top, .layout, .foot { padding-left: 16px; padding-right: 16px; }
  .fields { grid-template-columns: 1fr; }
  .opt .fields, .help { padding-left: 0; margin-left: 0; }
  .card { padding: 16px; }
  .hero .big { font-size: 38px; }
}
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .form, .actions, .res-actions, .proto { display: none; }
  .layout { display: block; padding: 0; }
  .results { position: static; border: 0; padding: 0; }
  tr.pick td { background: #eee; }
}
