:root {
  --bg: #f6f7f9;
  --fg: #14181f;
  --muted: #5a6472;
  --accent: #0b5fd6;
  --warn: #a15c00;
  --danger: #b3261e;
  --ok: #1b7a3a;
  --field: #ffffff;
  --line: #c4cad3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --fg: #e8ebf0;
    --muted: #9aa4b2;
    --accent: #6ea8ff;
    --warn: #f0b34a;
    --danger: #ff8a80;
    --ok: #6fd18b;
    --field: #1a1f27;
    --line: #3a424e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 18px/1.4 system-ui, sans-serif;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
}
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 24px 0 8px; }
main { padding: 0 16px 24px; max-width: 640px; margin: 0 auto; }
[hidden] { display: none !important; }
label { display: block; margin: 12px 0 4px; color: var(--muted); }
input {
  width: 100%; min-height: 48px; font: inherit; color: var(--fg);
  background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.btn {
  display: block; width: 100%; min-height: 56px; font: inherit; font-size: 20px; font-weight: 600;
  border: 2px solid var(--accent); border-radius: 12px; background: var(--accent); color: var(--bg);
  margin: 16px 0 8px; cursor: pointer;
}
.btn-secondary { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 56px; min-height: 56px; background: transparent;
  color: var(--fg); border: 0; cursor: pointer;
}
.link-btn, #start-over {
  background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline;
  min-height: 48px; padding: 0; cursor: pointer;
}
#start-over { display: inline-block; line-height: 48px; }
.muted { color: var(--muted); margin: 8px 0; }
.readout { font-size: 36px; font-weight: 700; }
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 12px; z-index: 10;
}
.camera { position: relative; width: 100%; flex: 1 1 auto; min-height: 30vh; background: #000; border-radius: 12px; overflow: hidden; }
select {
  width: 100%; min-height: 48px; font: inherit; color: var(--fg);
  background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.pill { display: inline-block; margin: 8px 0; padding: 4px 12px; border-radius: 999px; border: 2px solid var(--line); font-size: 16px; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.danger { color: var(--danger); border-color: var(--danger); }
section[data-screen="calibrate"]:not([hidden]) { display: flex; flex-direction: column; min-height: calc(100dvh - 72px); }
.bar { position: sticky; bottom: 0; background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.bar .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.bar .btn { margin: 8px 0 0; }
.bar .muted { margin: 4px 0; }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }

section[data-screen="capture"]:not([hidden]) { display: flex; flex-direction: column; min-height: calc(100dvh - 72px); }
.cap-readout { position: absolute; z-index: 1; top: 8px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 16px); text-align: center; pointer-events: none; }
.cap-line { display: inline-block; background: rgba(0, 0, 0, .65); color: #fff; font-size: 32px; font-weight: 700; padding: 4px 12px; border-radius: 10px; white-space: nowrap; }
.cap-readout .pill { background: rgba(0, 0, 0, .65); margin: 4px 0 0; }
.cap-hint { background: rgba(0, 0, 0, .65); color: #fff; font-size: 16px; padding: 4px 12px; border-radius: 10px; margin-top: 4px; }
.strip { display: block; width: 100%; height: 72px; color: var(--fg); background: var(--field); border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; touch-action: manipulation; }
.cap-controls { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.cap-controls .btn { margin: 0; width: auto; flex: 1 1 0; padding: 0 8px; font-size: 18px; }
.cap-controls .muted { margin: 0; flex: 1 1 0; text-align: center; font-size: 16px; }
.tapzone { display: block; width: 100%; min-height: 30vh; margin-top: 8px; font: inherit; font-size: 28px; font-weight: 700; color: var(--bg); background: var(--accent); border: 0; border-radius: 12px; cursor: pointer; transition: background .15s; }
.tapzone.flash { background: var(--ok); }

/* Finish (Task 11) */
.plain, #inst-notes { padding-left: 20px; margin: 8px 0; }
.plain { list-style: none; padding: 0; }
.warn { color: var(--warn); }
.fin-strip { height: 140px; }
details { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 0 12px; }
summary { min-height: 56px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
details ol { padding-left: 20px; margin: 0 0 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }

/* Settings and diagnostics (Task 12) */
dialog { width: calc(100% - 32px); max-width: 480px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
label.check { display: flex; align-items: center; gap: 12px; min-height: 48px; color: var(--fg); }
label.check input { width: 28px; min-height: 28px; }
pre.diag { position: absolute; z-index: 1; left: 8px; right: 8px; bottom: 8px; margin: 0; padding: 6px 8px; font: 12px/1.3 ui-monospace, monospace; color: #fff; background: rgba(0, 0, 0, .7); border-radius: 8px; pointer-events: none; white-space: pre-wrap; }
