:root {
  --bg: #111315; --panel: #1b1e21; --panel2: #24282c; --line: #32373c;
  --text: #f1f2f3; --dim: #9aa1a8; --accent: #e8b23a; --accent-ink: #1a1405;
  --good: #49c486; --bad: #ef6a5e; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 560px; margin: 0 auto; }
#view { flex: 1; overflow-y: auto; padding: calc(var(--safe-t) + 14px) 14px 20px; -webkit-overflow-scrolling: touch; }
#tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
#tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; color: var(--dim); font-size: 12px; }
#tabs button.on { color: var(--accent); }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: .02em; }
.sub { color: var(--dim); font-size: 13px; margin: 0 0 12px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.who { color: var(--dim); font-size: 12px; padding: 6px 0 6px 10px; white-space: nowrap; }

.cam { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .aim { position: absolute; left: 8%; right: 8%; top: 30%; bottom: 30%; border: 2px solid rgba(255,255,255,.85); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.32); pointer-events: none; }
.cam .aim.hit { border-color: var(--good); }
.cam .msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; text-align: center; color: var(--dim); font-size: 14px; background: var(--panel); }
.cam .torch { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 8px 14px; font-size: 13px; }

.row { display: flex; gap: 8px; margin-top: 10px; }
.row > * { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 56px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .45; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 13px; flex: 0 0 auto; }
input[type=text], input[type=search], input[type=number], input[type=password], select {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; }
input:focus, select:focus { border-color: var(--accent); }
label.f { display: block; font-size: 13px; color: var(--dim); margin: 12px 0 4px; }

.item { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 8px; text-align: left; width: 100%; }
.item img, .item .noimg { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--panel2); flex: 0 0 auto; }
.item .t { flex: 1; min-width: 0; }
.item .n { font-weight: 600; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .m { color: var(--dim); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .q { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; flex: 0 0 auto; text-align: right; }
.item .q small { display: block; font-size: 11px; font-weight: 400; color: var(--dim); }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel2); color: var(--dim); margin-left: 4px; vertical-align: 1px; }
.badge.new { background: #3a2f10; color: var(--accent); } .badge.ok { background: #143525; color: var(--good); } .badge.warn { background: #40201c; color: var(--bad); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 6px; }
.stepper button { width: 60px; height: 60px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); font-size: 28px; line-height: 1; }
.stepper input { width: 110px; text-align: center; font-size: 34px; font-weight: 700; min-height: 64px; padding: 0; font-variant-numeric: tabular-nums; }
.mini { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.mini button { width: 38px; height: 38px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); font-size: 20px; line-height: 1; }
.mini input { width: 58px; min-height: 40px; padding: 0; text-align: center; font-size: 18px; font-weight: 700; }

#sheet { position: fixed; inset: 0; z-index: 20; }
#sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
#sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px 14px calc(var(--safe-b) + 18px); }
#sheet-body h2 { font-size: 18px; margin: 0 0 4px; }
.note { color: var(--dim); font-size: 13px; margin: 6px 0; }
.err { color: var(--bad); font-size: 14px; margin: 8px 0; }
.empty { color: var(--dim); text-align: center; padding: 28px 10px; font-size: 14px; }
.sec { font-size: 13px; color: var(--dim); margin: 20px 0 2px; font-weight: 600; letter-spacing: .04em; }
.bar { position: sticky; bottom: -20px; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 4px; margin-top: 10px; }

#toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 78px); max-width: 536px; margin: 0 auto; z-index: 30; background: #f1f2f3; color: #111; border-radius: 12px; padding: 12px 14px; font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
#toast.bad { background: var(--bad); color: #fff; }
#toast button { color: #0a58ca; font-weight: 700; flex: 0 0 auto; }
#busy { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

#login { max-width: 400px; margin: 0 auto; padding: calc(var(--safe-t) + 60px) 20px 20px; }
#login h1 { margin-bottom: 4px; }
.inv { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 8px; }
.inv.skip { opacity: .45; }
.inv .n { font-weight: 600; font-size: 14px; }
.inv .m { color: var(--dim); font-size: 12px; }
.inv .ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inv label { font-size: 13px; color: var(--dim); display: inline-flex; align-items: center; gap: 6px; }
.inv input[type=number] { width: 120px; min-height: 40px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

/* 確認シートを開いている間は、お知らせを上に出してボタンに重ならないようにする */
#sheet:not([hidden]) ~ #toast { bottom: auto; top: calc(var(--safe-t) + 12px); }
