:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --border: #d7dbe0;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --ok: #1d7a3a;
  --bad: #b3261e;
  --warn-bg: #fff6e0;
  --warn-border: #e2b84a;
  --err-bg: #fdecea;
  --err-border: #e39a94;
  --input-bg: #ffffff;
  --drop-bg: #f0f4fa;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1c1f24;
    --text: #e6e8eb;
    --muted: #a1a9b3;
    --border: #353a42;
    --accent: #6ea2ff;
    --accent-text: #0b1220;
    --ok: #6fd18f;
    --bad: #ff8a80;
    --warn-bg: #2e2715;
    --warn-border: #8a6d1f;
    --err-bg: #331b1a;
    --err-border: #8a3a34;
    --input-bg: #15181c;
    --drop-bg: #1a212c;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  overflow-wrap: anywhere;
}

.top, main, .foot { max-width: 820px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 20px; }

h1 { font-size: 1.5rem; margin: 0 0 8px; }
h1 .sub { display: block; font-size: 1rem; font-weight: 500; color: var(--muted); }
h2 { font-size: 1.15rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.num {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 0.85rem; flex: none;
}

.notes { margin: 0 0 8px; padding-left: 1.2em; color: var(--muted); font-size: 0.95rem; }
.notes strong { color: var(--text); }
.engine { margin: 4px 0; font-size: 0.95rem; color: var(--muted); }
.engine.ok { color: var(--ok); }
.engine.bad { color: var(--bad); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin: 16px 0;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 0 16px; }
.row { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; min-width: 0; }
label { font-size: 0.95rem; }
input[type="text"], select {
  width: 100%; min-width: 0; font: inherit; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.req { font-size: 0.75rem; color: var(--bad); margin-left: 4px; }
.opt { font-size: 0.8rem; color: var(--muted); margin-left: 4px; }
.hint { color: var(--muted); font-size: 0.875rem; margin: -4px 0 12px; }

fieldset.choice { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
fieldset.choice legend { padding: 0; margin-bottom: 4px; font-size: 0.95rem; width: 100%; }
fieldset.choice label { display: inline-flex; align-items: center; gap: 6px; }

.drop {
  border: 2px dashed var(--border); border-radius: 8px; background: var(--drop-bg);
  padding: 12px; margin: 0 0 12px;
}
.drop.over { border-color: var(--accent); }
.drop p { margin: 2px 0; }
.drop-title { font-weight: 600; }
.drop-hint { color: var(--muted); font-size: 0.9rem; }
.filename { font-size: 0.9rem; }
.pick {
  display: inline-block; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 0.9rem;
}
.pick input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

button, .button {
  font: inherit; border-radius: 6px; padding: 10px 18px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  display: inline-block; text-decoration: none;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.link { padding: 0 4px; border: 0; background: none; color: var(--accent); text-decoration: underline; font-size: 0.9rem; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }

details.more { margin: 0 0 8px; }
details summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }

.theta { margin: 4px 0 0; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.theta.ok { color: var(--ok); border-color: var(--ok); }
.theta.bad { color: var(--bad); border-color: var(--bad); font-weight: 600; }

.problems { margin: 0 0 8px; padding-left: 1.2em; color: var(--muted); font-size: 0.9rem; }

progress { width: 100%; height: 14px; accent-color: var(--accent); }
.stage { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.msg { border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; }
.msg p { margin: 4px 0; }
.msg ul { margin: 4px 0; padding-left: 1.2em; }
.msg.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }
.msg.error { background: var(--err-bg); border: 1px solid var(--err-border); }
.msg pre {
  white-space: pre-wrap; word-break: break-word; font-size: 0.8rem; max-height: 320px; overflow: auto;
  margin: 0; padding: 8px; background: var(--input-bg); border-radius: 4px;
}

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px; margin: 0 0 12px; }
.facts div { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.facts dt { font-size: 0.85rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

figure { margin: 16px 0 0; }
figcaption { font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-row { margin-top: 8px; }

.foot { color: var(--muted); font-size: 0.85rem; padding-bottom: 24px; }

.hidden { display: none !important; }

/* optical setup schematic */
figure.setup { margin: 0; }
figure.setup svg { width: 100%; height: auto; display: block; }
.s-axis { stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; }
.s-box { fill: var(--drop-bg); stroke: var(--text); stroke-width: 1.5; }
.s-lens { fill: var(--drop-bg); stroke: var(--accent); stroke-width: 1.5; }
.s-diff { fill: var(--muted); opacity: .55; }
.s-light { stroke: #d4a017; stroke-width: 2; fill: none; }
.s-fill-light { fill: #d4a017; }
.s-spray { fill: var(--accent); opacity: .12; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; }
.s-drop circle { fill: var(--accent); opacity: .75; }
.s-scat { stroke: var(--bad); stroke-width: 1.8; stroke-dasharray: 6 4; fill: none; }
.s-fill-scat { fill: var(--bad); }
.s-scat-txt { fill: var(--bad); }
.s-cone { stroke: var(--ok); stroke-width: 1.5; fill: none; }
.s-stop { stroke: var(--text); stroke-width: 4; }
.s-dim { stroke: var(--text); stroke-width: 1.2; fill: none; }
.s-arc { stroke: var(--text); stroke-width: 1.4; fill: none; }
.s-tick { stroke: var(--muted); stroke-width: 1; }
.s-fill-text { fill: var(--text); }
.s-lab { fill: var(--muted); font-size: 15px; }
.s-key { fill: var(--text); font-size: 20px; font-weight: 700; font-style: italic; }
.s-sym { fill: var(--muted); font-size: 15px; }
.s-key-txt { fill: var(--text); font-size: 13px; font-weight: 600; }
.s-small { fill: var(--muted); font-size: 12px; }
table.legend { width: 100%; border-collapse: collapse; margin-top: .75rem; font-size: .9rem; }
table.legend th, table.legend td { border-top: 1px solid var(--border); padding: .35rem .5rem; text-align: left; vertical-align: top; }
table.legend th { white-space: nowrap; }
table.legend td:first-child { font-weight: 700; font-style: italic; white-space: nowrap; }
table.legend td:last-child { color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) { table.legend td:last-child { white-space: normal; } }
