:root {
  --bg: #f4f5f2; --card: #ffffff; --text: #17201a; --muted: #5f6b63; --line: #d9ded8;
  --accent: #166534; --accent-text: #ffffff; --danger: #b42318;
  --wait: #8a5a00; --wait-bg: #fdf0d0; --got: #1d4f91; --got-bg: #dfeafb; --done: #166534; --done-bg: #dcf3e2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101411; --card: #1a201c; --text: #e8ede9; --muted: #9aa69e; --line: #2c352f;
    --accent: #2f9e58; --accent-text: #06120a; --danger: #f97066;
    --wait: #f5c869; --wait-bg: #3a2e10; --got: #9cc2f5; --got-bg: #16283f; --done: #7fd99b; --done-bg: #12301c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
main { padding: 0 16px calc(32px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.pc { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--wait-bg); color: var(--wait); white-space: nowrap; }
.pc.on { background: var(--done-bg); color: var(--done); }

button, .btn, .big, input[type=text] {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-height: 48px;
}
button, .btn, .big { cursor: pointer; text-align: center; text-decoration: none; font-weight: 600; }
button:disabled { opacity: .5; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.danger { color: var(--danger); }
input[type=text] { width: 100%; margin-bottom: 8px; }

.capture { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big { display: flex; align-items: center; justify-content: center; min-height: 88px; font-size: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }

#pending { margin-top: 16px; }
.pendingList { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pendingItem { position: relative; flex: 0 0 auto; }
.pendingItem img { display: block; height: 180px; max-width: 70vw; border-radius: 10px; border: 1px solid var(--line); object-fit: contain; background: var(--card); }
.pendingItem button {
  position: absolute; top: 6px; right: 6px; min-height: 0; width: 32px; height: 32px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; border: 0; font-size: 18px; line-height: 1;
}
.pendingItem.busy img { opacity: .45; }

.list { display: grid; gap: 10px; }
.card {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  width: 100%; text-align: left; font-weight: 400; min-height: 0;
}
.card img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--line); display: block; }
.card .when { font-size: 14px; color: var(--muted); }
.card .note { font-size: 14px; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chip { display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.chip.uploaded { background: var(--wait-bg); color: var(--wait); }
.chip.picked_up { background: var(--got-bg); color: var(--got); }
.chip.result { background: var(--done-bg); color: var(--done); }

.viewer { position: fixed; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column; z-index: 10; }
.viewerBar {
  display: flex; gap: 8px; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  background: #111;
}
.viewerBar button, .viewerBar .btn { background: #222; color: #fff; border-color: #444; min-height: 40px; padding: 8px 12px; }
.viewerBar .danger { color: #f97066; }
.tabs { display: flex; gap: 6px; flex: 1; }
.tabs button.sel { background: #fff; color: #000; }
.stage { flex: 1; overflow: auto; display: flex; -webkit-overflow-scrolling: touch; }
.stage img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.stage.zoom img { max-width: none; max-height: none; }
.viewNote { margin: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #111; white-space: pre-wrap; max-height: 30vh; overflow: auto; }

.nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.nav button { min-height: 44px; padding: 8px 12px; }
.nav button.sel { background: var(--text); color: var(--bg); border-color: var(--text); }
#tabRecheck .big { min-height: 72px; }
.summary { font-weight: 600; margin: 16px 0 8px; }
.rc { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.rc img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--line); display: block; }
.rc .name { font-weight: 600; overflow-wrap: anywhere; }
.rc .detail { font-size: 14px; color: var(--muted); margin-top: 2px; }
.rc .chip { margin-top: 4px; }
.rc button.res { padding: 0; min-height: 0; border: 0; background: none; }
.chip.failed { background: var(--wait-bg); color: var(--danger); }
.chip.checking { background: var(--line); color: var(--muted); }
.card .tag { font-size: 12px; color: var(--muted); }
