:root {
  --navy: #05141c;
  --bg: #fbf6ed;
  --card: #ffffff;
  --text: #000000;
  --muted: #413a4d;
  --accent: #1d4ed8;
  --accent-press: #1e40af;
  --error: #a02513;
  --error-bg: #fee2e2;
  --line: #d2d1d4;
  --card-border: #ece9f0;
  --radius-card: 18px;
  --radius-input: 14px;
  --radius-pill: 9999px;
  --btn-height: 48px;
  font-family: Figtree, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

body {
  padding-bottom: calc(11.5rem + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--navy);
  color: #fff;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
}

.wordmark {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}

.wordmark img {
  height: 22px;
  width: auto;
}

.menu {
  margin-left: auto;
}

.menu summary {
  list-style: none;
  cursor: pointer;
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
}

.menu summary::-webkit-details-marker { display: none; }

.menu nav {
  position: absolute;
  right: 1rem;
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(15, 14, 30, 0.18);
  min-width: 12rem;
  padding: 0.5rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.menu nav a,
.menu nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  text-decoration: none;
  padding: 0.6rem 0.5rem;
  font: inherit;
  cursor: pointer;
}

.who {
  margin: 0;
  padding: 0.4rem 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

main {
  padding: 1.25rem 1rem 2rem;
  max-width: 32rem;
  margin: 0 auto;
}

h1 {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.hero-title {
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 0 0 0.65rem;
}

.hero-title .accent {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.progress {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.35rem;
  padding: 0;
  margin: 0 0 0.7rem;
}

.progress li {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  position: relative;
}

.progress li + li::before {
  content: "";
  position: absolute;
  right: calc(100% + 2px);
  top: 50%;
  width: 1.35rem;
  height: 2px;
  background: var(--line);
  transform: translateY(-50%);
}

.progress li.is-done,
.progress li.is-current {
  background: var(--accent);
}

.progress li.is-current {
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.2);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  width: auto;
  min-height: 2.35rem;
  min-width: 0;
  margin: 0 0 0.4rem;
  padding: 0.35rem 0.95rem 0.35rem 0.7rem;
  font-size: 0.95rem;
}

.back-link svg {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.prefill-banner {
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  font-size: 0.9rem;
  line-height: 1.35;
}

.prefill-banner strong {
  display: block;
}

.prefill-hint {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Title top-left under the dots. Sample sits centered above the camera
   card and must not share a row with the title. */
.capture-stage {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.step-head h1 {
  font-size: 1.85rem;
  margin: 0;
  min-width: 0;
}

.sample-panel {
  display: flex;
  justify-content: center;
  margin: 0;
}

.step-sample {
  width: min(78vw, 18rem);
  height: auto;
  max-height: 11rem;
  object-fit: contain;
  object-position: center top;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(5, 20, 28, 0.1);
}

.capture[data-kind="barcode"] .step-sample {
  width: min(82vw, 20rem);
  max-height: 9rem;
}

.step-sample.is-tall {
  width: min(52vw, 11.5rem);
  max-height: 15rem;
}

.capture-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

h2 { font-size: 1rem; margin: 1.5rem 0 0.5rem; font-weight: 600; }

.lede, .hint, .muted, .hint-inline, .kicker {
  color: var(--muted);
}

.lede { margin-top: 0; font-size: 0.95rem; line-height: 1.35; }

.consent {
  background: #eef3fc;
  border-left: 4px solid var(--accent);
  padding: 0.85rem 1rem;
  border-radius: 0 8px 8px 0;
}

.error {
  color: var(--error);
  background: var(--error-bg);
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"] {
  font-size: 16px;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  background: var(--card);
  min-height: var(--btn-height);
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.18);
}

input::placeholder {
  color: #8a8494;
  font-weight: 400;
}

button, .door {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--radius-pill);
  min-height: var(--btn-height);
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:active { background: var(--accent-press); }

.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
}

.text-btn {
  background: none;
  color: var(--muted);
  min-height: 2.75rem;
  min-width: 4.5rem;
  font-weight: 600;
  padding: 0.5rem 0.25rem;
}

.ghost {
  background: var(--card);
  color: var(--navy);
  border: 1.5px solid var(--line);
}

.doors { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.25rem 0; }

.row {
  display: flex;
  gap: 0.75rem;
}

.row > * { flex: 1; }

.hidden, [hidden] { display: none !important; }

.banner {
  margin: 0;
  padding: 0.6rem 1rem;
  background: #ffeedc;
  color: var(--navy);
  text-align: center;
}

.thumbs-strip {
  margin: 0;
  padding: 0;
}

.thumbs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #ddd;
}

#preview,
#kept-photo {
  width: 100%;
  max-height: 42vh;
  object-fit: contain;
  background: #111;
  border-radius: 12px;
}

.kept-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  padding: 0.65rem 0.65rem 0.35rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 6px 18px rgba(5, 20, 28, 0.05);
}

.kept-panel #btn-replace {
  align-self: center;
}

.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 -8px 24px rgba(15, 14, 30, 0.06);
}

.sticky-cluster {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sticky-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.sticky-nav:empty,
.sticky-nav:not(:has(:not([hidden]))) {
  display: none;
}

.worklist, .trip-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.worklist a, .trip-list li {
  display: block;
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--card-border);
}

.trip-card {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.trip-card-media {
  width: 3.25rem;
  height: 3.25rem;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--navy);
}

.trip-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trip-card-body {
  min-width: 0;
  flex: 1;
}

.trip-card-body strong {
  display: block;
  font-size: 1.05rem;
}

.trip-card .status {
  margin-top: 0.15rem;
}

.trip-card a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
}

.worklist a span, .status {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.basket {
  margin-top: 0.5rem;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 22px;
  padding: 1rem 0.85rem 0.85rem;
  box-shadow: 0 12px 28px rgba(5, 20, 28, 0.08);
}

.basket-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.basket-empty {
  margin: 0.4rem 0 0.15rem;
  padding: 1.35rem 0.75rem 1.2rem;
  text-align: center;
  color: var(--muted);
  line-height: 1.4;
}

.basket .trip-list {
  max-height: min(52vh, 24rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.4rem;
}

.basket .trip-list li {
  margin-bottom: 0.45rem;
}

.basket .trip-list li:last-child {
  margin-bottom: 0;
}

.basket-summary {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.4rem 0.1rem;
  margin: 0;
  height: auto;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.basket + .bounty {
  margin-top: 0.85rem;
}

.bounty .basket-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.bounty-progress {
  margin: 0 0 0.35rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.bounty-list {
  max-height: min(52vh, 24rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bounty-list li {
  margin-bottom: 0.5rem;
}

.bounty-list li.found a {
  background: var(--bg);
}

.bounty-check {
  color: var(--accent);
  font-weight: 700;
}

.shutter-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0;
}

.shutter-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0.85rem 0.75rem 0.7rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 6px 18px rgba(5, 20, 28, 0.05);
}

.shutter-pair {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1.75rem;
  width: 100%;
}

.shutter-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 6.5rem;
}

.shutter-wrap {
  position: relative;
}

.shutter-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font-size: 0;
}

.shutter-face,
.library-face {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.shutter-wrap-camera,
.shutter-wrap-library {
  width: 5.5rem;
  height: 5.5rem;
}

.shutter-wrap-camera .shutter-face,
.shutter-wrap-library .library-face {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
}

.shutter-wrap-camera .shutter-face {
  background: var(--accent);
  color: #fff;
}

.shutter-wrap-library .library-face {
  background: var(--bg);
  color: var(--navy);
  border: 1.5px solid var(--line);
}

.shutter-caption {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: center;
}

.barcode-panel {
  gap: 0.45rem;
}

.capture[data-kind="barcode"] #barcode-input {
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.capture[data-kind="barcode"] #barcode-input::placeholder {
  letter-spacing: 0;
  font-variant-numeric: normal;
}

.barcode-detected {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.finish-panel {
  margin: 0.5rem 0 0;
}

.tada {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(29, 78, 216, 0.55), transparent 32%),
    radial-gradient(circle at 88% 8%, rgba(251, 246, 237, 0.35), transparent 28%),
    radial-gradient(circle at 70% 90%, rgba(29, 78, 216, 0.28), transparent 36%),
    radial-gradient(circle at 30% 80%, rgba(251, 246, 237, 0.12), transparent 30%),
    var(--navy);
  color: #fff;
  border-radius: 24px;
  padding: 2.1rem 1.25rem 1.5rem;
  text-align: center;
}

.tada::before,
.tada::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.tada::before {
  width: 9rem;
  height: 9rem;
  right: -2.5rem;
  top: -2.5rem;
  background: rgba(251, 246, 237, 0.1);
}

.tada::after {
  width: 6rem;
  height: 6rem;
  left: -1.5rem;
  bottom: 1rem;
  background: rgba(29, 78, 216, 0.35);
}

.tada-kicker {
  position: relative;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #bfdbfe;
  margin: 0 0 0.4rem;
}

.tada h1 {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.tada .lede,
.tada .hint {
  position: relative;
  z-index: 1;
}

.tada .lede {
  color: #e8eef5;
  font-size: 1.05rem;
}

.tada .hint {
  color: #cbd5e1;
}

.tada .thumbs {
  position: relative;
  z-index: 1;
  margin: 1rem 0 1.25rem;
}

.tada .thumbs img {
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: #102028;
}

.tada .door {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  max-width: 16rem;
}

.finish-spinner {
  position: relative;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  margin: 0 auto 0.75rem;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: finish-spin 0.75s linear infinite;
}

@keyframes finish-spin {
  to {
    transform: rotate(360deg);
  }
}

.finish-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
  gap: 0.55rem;
  list-style: none;
  padding: 0;
}

.finish-thumbs li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.finish-thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  transition: opacity 0.2s ease;
}

.finish-thumb-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #cbd5e1;
  text-align: center;
  line-height: 1.2;
}

.finish-thumbs li.is-pending img {
  opacity: 0.45;
}

.finish-thumbs li.is-sending img {
  opacity: 0.85;
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.finish-thumbs li.is-sent img {
  opacity: 1;
}

.finish-thumbs li.is-failed img {
  opacity: 0.55;
  outline: 2px solid #fca5a5;
  outline-offset: 1px;
}

.finish-thumbs li.is-sent::after,
.finish-thumbs li.is-failed::after {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.1rem;
  text-align: center;
}

.finish-thumbs li.is-sent::after {
  content: "✓";
  background: #22c55e;
  color: #052e16;
}

.finish-thumbs li.is-failed::after {
  content: "!";
  background: #f87171;
  color: #450a0a;
}

.tada.is-processing .door {
  display: none;
}

.capture.is-finished .step-head,
.capture.is-finished .progress,
.capture.is-finished .thumbs-panel,
.capture.is-finished .kept-panel,
.capture.is-finished .sample-panel,
.capture.is-finished .back-link {
  display: none !important;
}

body.guide-open {
  overflow: hidden;
}

.guide {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 20, 28, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
}

.guide-card {
  background: var(--bg);
  width: 100%;
  max-width: 32rem;
  max-height: 94vh;
  overflow: auto;
  border-radius: 24px;
  padding: 1rem 1rem 0.85rem;
}

.guide-kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.25rem;
}

.guide-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
}

.guide-img {
  display: block;
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 16px;
}

.guide-card .lede {
  margin: 0.75rem 0 0.85rem;
}

.guide-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.guide-actions .text-btn {
  margin-right: auto;
  padding-left: 0;
}

.guide-actions .secondary,
.guide-actions .primary {
  flex: 0 0 auto;
  min-width: 5.5rem;
}

.guide.welcome-layer {
  align-items: center;
  background: rgba(5, 20, 28, 0.46);
}

.welcome-card {
  text-align: center;
  padding: 1.7rem 1.2rem 1.2rem;
}

.welcome-mark {
  width: 4.25rem;
  height: 4.25rem;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-mark img {
  height: 1.35rem;
  width: auto;
}

.welcome-card h2 {
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.welcome-card .lede {
  margin: 0.6rem 0 1.1rem;
}

.welcome-card .guide-actions {
  justify-content: space-between;
}

.welcome-card .guide-actions .primary {
  min-width: 9.5rem;
}
