/* Stockwise device check. Large controls on purpose: the page is used with gloves. */

:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --text: #1b1f1c;
  --muted: #5b625d;
  --border: #d3d7d1;
  --accent: #1f6f43;
  --accent-text: #ffffff;
  --focus: #1b5fd1;
  --pass: #17663a;   --pass-bg: #dcf1e3;
  --fail: #a32121;   --fail-bg: #fbe0de;
  --warn: #8a5300;   --warn-bg: #fdefd0;
  --info: #1d4f91;   --info-bg: #dfeafb;
  --na: #5b625d;     --na-bg: #e7e9e5;
  --todo: #5b625d;   --todo-bg: transparent;
  --target: #1f9d55;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121513; --surface: #1c201d; --surface-2: #262b27; --text: #eef1ed; --muted: #a6aea8; --border: #3a413c;
    --accent: #3fae6e; --accent-text: #0b1a10; --focus: #7fb0ff;
    --pass: #7fdc9f; --pass-bg: #173822; --fail: #ff9b93; --fail-bg: #4a1c1a; --warn: #f5c56b; --warn-bg: #45320f;
    --info: #9cc3ff; --info-bg: #1b2f4d; --na: #a6aea8; --na-bg: #2a302c; --todo: #a6aea8; --target: #3fae6e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121513; --surface: #1c201d; --surface-2: #262b27; --text: #eef1ed; --muted: #a6aea8; --border: #3a413c;
  --accent: #3fae6e; --accent-text: #0b1a10; --focus: #7fb0ff;
  --pass: #7fdc9f; --pass-bg: #173822; --fail: #ff9b93; --fail-bg: #4a1c1a; --warn: #f5c56b; --warn-bg: #45320f;
  --info: #9cc3ff; --info-bg: #1b2f4d; --na: #a6aea8; --na-bg: #2a302c; --todo: #a6aea8; --target: #3fae6e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
h1 { font-size: 26px; margin: 0; line-height: 1.2; }
h2 { font-size: 21px; margin: 0; line-height: 1.25; }
h3 { font-size: 17px; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--focus); }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px; max-width: 1240px; margin: 0 auto;
}
.sub { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.banner { max-width: 1208px; margin: 0 16px 12px; padding: 14px 16px; border-radius: 10px; font-weight: 600; }
@media (min-width: 1240px) { .banner { margin: 0 auto 12px; } }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.fail { background: var(--fail-bg); color: var(--fail); word-break: break-word; }

.grid {
  display: grid; gap: 16px; padding: 0 16px 40px; max-width: 1240px; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 540px), 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.num {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin-right: 10px;
  border-radius: 50%; background: var(--surface-2); font-size: 17px; vertical-align: 2px;
}
.how { color: var(--muted); margin: 10px 0 12px; }

/* Status pills */
.pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 15px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
[data-status="pass"] { background: var(--pass-bg); color: var(--pass); }
[data-status="fail"] { background: var(--fail-bg); color: var(--fail); }
[data-status="warn"] { background: var(--warn-bg); color: var(--warn); }
[data-status="info"] { background: var(--info-bg); color: var(--info); }
[data-status="na"] { background: var(--na-bg); color: var(--na); }
[data-status="todo"] { background: var(--todo-bg); color: var(--todo); border-color: var(--border); }

/* Buttons: at least 56 px high */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 10px 20px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; touch-action: manipulation; user-select: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--fail); }
.btn[aria-pressed="true"] { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin: 8px 0; flex: 1 1 200px; min-width: 0; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--bg);
  border: 2px solid var(--border); border-radius: 10px; padding: 12px; min-height: 56px; width: 100%;
}
textarea { min-height: 0; resize: vertical; }
.form-row { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: flex-end; }
.form-row.tight .btn { margin: 8px 0; }
.form-row.four .field { flex-basis: 120px; }
.check-inline { display: flex; align-items: center; gap: 10px; margin: 8px 0; min-height: 48px; }
.check-inline input { width: 28px; height: 28px; min-height: 0; }
.notes { margin-top: 16px; }
.capture { margin: 10px 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; }

/* Listening state line */
.listen { min-height: 0; margin: 6px 0; color: var(--muted); }
.listen:empty { display: none; }
.listen[data-on="1"] {
  color: var(--accent); font-weight: 700; padding: 12px 14px; border-radius: 10px; background: var(--pass-bg);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .listen[data-on="1"] { animation: none; } }

/* Checks list */
.checks { list-style: none; padding: 0; margin: 12px 0 0; }
.checks li {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.checks li:first-child { border-top: 0; }
.checks .pill { font-size: 14px; padding: 3px 10px; min-width: 64px; text-align: center; }
.checks .label { font-weight: 600; }
.checks .value.plain { font-family: inherit; word-break: normal; }
.checks .value {
  grid-column: 2; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; color: var(--muted);
  word-break: break-all;
}
.checks .yesno { grid-column: 2; display: flex; gap: 10px; flex-wrap: wrap; }
.checks .yesno .btn { min-height: 48px; padding: 6px 18px; }

/* Readings */
.feed { margin-top: 10px; }
.feed:empty { display: none; }
.reading {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--bg);
}
.reading .text { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 19px; word-break: break-all; }
.reading .meta { color: var(--muted); font-size: 15px; margin-top: 2px; }
.big-number {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 30px; font-weight: 700; letter-spacing: .04em;
  padding: 12px 14px; margin: 10px 0; border-radius: 10px; background: var(--surface-2); word-break: break-all;
}
.more { margin-top: 12px; }
.more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); font-weight: 600; }
.raw {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; white-space: pre-wrap; word-break: break-all;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 320px; overflow: auto;
}
.raw table { border-collapse: collapse; width: 100%; }
.raw td, .raw th { padding: 2px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }

/* Facts table */
.facts { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 16px; }
.facts th, .facts td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--border); vertical-align: top; }
.facts th { color: var(--muted); font-weight: 600; width: 38%; }
.facts td { word-break: break-word; }

/* Camera */
.video-box { position: relative; margin: 10px 0; background: #000; border-radius: 12px; overflow: hidden; }
.video-box video { display: block; width: 100%; max-height: 55vh; object-fit: contain; }
.aim { position: absolute; left: 12%; right: 12%; top: 35%; bottom: 35%; border: 3px solid rgba(255,255,255,.8); border-radius: 8px; pointer-events: none; }

/* Theme sample */
.sample { margin: 12px 0 4px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.sample-weight { font-size: 44px; font-weight: 800; line-height: 1; }
.sample-weight small { font-size: 22px; color: var(--muted); }
.sample-line { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 20px; }
.sample-line.muted { color: var(--muted); font-size: 16px; }
.tag { background: var(--pass-bg); color: var(--pass); border-radius: 999px; padding: 0 10px; font-weight: 700; }

/* Tap test */
.tap-area {
  position: relative; height: 340px; margin: 10px 0; border-radius: 12px; border: 2px dashed var(--border);
  background: var(--bg); touch-action: none; overflow: hidden;
}
.tap-target {
  position: absolute; border: 0; border-radius: 10px; background: var(--target); padding: 0; min-height: 0; cursor: pointer;
}
.tap-progress { position: absolute; top: 8px; left: 12px; color: var(--muted); font-weight: 700; pointer-events: none; }
.tap-table { border-collapse: collapse; margin-top: 6px; }
.tap-table td, .tap-table th { padding: 4px 12px 4px 0; text-align: left; }

/* Summary chips */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.summary a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 14px; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: 16px;
}

/* Report */
.report { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; margin-top: 10px; }

/* Test sheet */
.sheet-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 16px;
}
.sheet-backdrop[hidden] { display: none; }
.sheet { background: var(--surface); color: var(--text); border-radius: 14px; padding: 18px; width: 100%; max-width: 860px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.sheet-head .actions { margin: 0; }
.codes { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.code { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #fff; color: #000; }
.code h4 { margin: 0 0 8px; font-size: 17px; }
.code svg { display: block; max-width: 100%; height: auto; }
.code .hrt { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; margin-top: 6px; word-break: break-all; }
.code p { margin: 6px 0 0; font-size: 15px; color: #444; }

@media print {
  body.print-sheet > *:not(#sheet) { display: none !important; }
  body.print-sheet .sheet-backdrop { position: static; background: none; padding: 0; overflow: visible; }
  body.print-sheet .sheet { max-width: none; padding: 0; }
  body.print-sheet .sheet-head .actions, body.print-sheet .sheet > .how { display: none; }
  .code { break-inside: avoid; border-color: #999; }
}

@media (max-width: 520px) {
  body { font-size: 17px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; }
  .actions .btn { flex: 1 1 auto; }
  .big-number { font-size: 24px; }
}
