:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #16212b;
  --muted: #5b6770;
  --line: #d9dee3;
  --brand: #0b5fa5;
  --brand-ink: #ffffff;
  --ok: #1d7f3f;
  --warn: #b7791f;
  --bad: #b3261e;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 20px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--brand);
  color: var(--brand-ink);
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; font-weight: 700; }
.brand img { display: block; width: 36px; height: 36px; }
.who { min-width: 0; margin-left: 12px; font-size: 16px; opacity: 0.9; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.screen {
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1 { font-size: 24px; margin: 4px 0; }
h2 { font-size: 20px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { filter: brightness(0.9); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.big { min-height: 120px; font-size: 28px; }
.btn.secondary { background: var(--card); color: var(--brand); border: 2px solid var(--brand); }
.btn.ok { background: var(--ok); color: var(--brand-ink); border-color: var(--ok); }
.btn.quiet { background: transparent; color: var(--muted); min-height: 48px; font-weight: 500; }

.status { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper button {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--brand); background: var(--card); color: var(--brand);
  font: inherit; font-size: 32px; font-weight: 700; cursor: pointer;
}
.stepper output { font-size: 32px; font-weight: 700; min-width: 2ch; text-align: center; }

.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 30;
}
.toast.show { opacity: 1; transform: none; }

input[type="file"] { display: none; }
.btn.danger { background: var(--bad); color: #fff; }

body.viewing { overflow: hidden; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
}
.viewer-bar, .viewer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; }
.viewer-bar { padding-top: calc(8px + env(safe-area-inset-top)); }
.viewer-foot { min-height: 64px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.viewer-bar .btn, .viewer-foot .btn { width: auto; min-height: 48px; padding: 8px 18px; font-size: 18px; }
.viewer-back { background: rgba(255, 255, 255, 0.18); }
.viewer-count, .viewer-caption { font-size: 18px; font-weight: 600; }
.viewer-caption.waiting { color: #f6c26b; }
.viewer-track {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-slide { flex: 0 0 100%; min-width: 0; display: flex; scroll-snap-align: center; scroll-snap-stop: always; }
.viewer-slide img { width: 100%; height: 100%; object-fit: contain; }
.confirm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.confirm-box { width: 100%; max-width: 420px; padding: 20px; display: flex; flex-direction: column; gap: 16px; background: var(--card); color: var(--ink); border-radius: var(--radius); }
.confirm-box p { font-weight: 600; }
.confirm-actions { display: flex; gap: 12px; }
.confirm-actions .btn { min-height: 56px; font-size: 20px; }
