.scanner-scanline {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 2px;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
  animation: scanline 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scanline {
  0%, 100% { transform: translate(-50%, calc(-50% - 60px)); opacity: 0.3; }
  50% { transform: translate(-50%, calc(-50% + 60px)); opacity: 0.7; }
}
/* Reticle pulse: quick accent glow on the corner brackets for every new
   capture, so the acknowledgment reads even with sound off. */
.scanner-reticle.pulse::before,
.scanner-reticle.pulse::after,
.scanner-reticle.pulse .corner-tl,
.scanner-reticle.pulse .corner-br {
  animation: reticlePulse 0.25s ease-out;
}
@keyframes reticlePulse {
  0% {
    border-color: #ffd479;
    box-shadow: 0 0 12px var(--accent), inset 0 0 8px rgba(245, 158, 11, 0.4);
  }
  100% {
    border-color: var(--accent);
    box-shadow: none;
  }
}
.scanner-detected-flash {
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  pointer-events: none;
  opacity: 0;
  border-radius: 2px;
  z-index: 3; /* above a displayed photo */
}
.scanner-detected-flash.flash {
  animation: detectFlash 0.6s ease;
}
@keyframes detectFlash {
  0% { opacity: 0.8; box-shadow: inset 0 0 40px rgba(245, 158, 11, 0.2); }
  100% { opacity: 0; }
}
/* SC-CAPTURE-RESKIN: the list of captured-code lines inside the notepad
   panel (css/cosmos-scanner.css .capture-notepad). One line per code, top to
   bottom; four 48px lines with 4px gaps fit before the list scrolls. */
.scanner-results {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 48px;
  max-height: 204px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* The generic result tag, still used by the mark chips
   (js/scanner-marks.js addFieldChip) and by the probe screen's flavor chips
   (css/cosmos-probe.css). */
.scanner-result-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--font-data);
  font-size: 11px;
  animation: tagAppear 0.2s ease-out;
}
@keyframes tagAppear {
  0% { opacity: 0; transform: scale(0.7); }
  70% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}
.scanner-result-tag .tag-format {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}
/* A mark chip on the paper (js/scanner-marks.js addFieldChip): ink on
   cream, and the same line size as a code line, so every line on the pad
   is at least 48px tall with 16px text and a 44px dismiss control. */
.scanner-results .scanner-result-tag:not(.catch-chip) {
  min-height: 48px;
  gap: 10px;
  padding: 2px 4px 2px 12px;
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(31, 42, 68, 0.35);
  color: #1f2a44;
  font-size: 16px;
}
.scanner-results .scanner-result-tag .tag-format { font-size: 12px; }
/* SC-CAPTURE-RESKIN: a captured code is one torn paper strip. The word rule
   of DESIGN_DECISIONS.md section 16a holds: SIGNAL or TRACE, never a format
   name or a hash. Left to right: the code-kind icon (bars for a
   one-dimensional bar code, a QR-like glyph for a two-dimensional code), the
   word in the handwriting face, a dot, the catch time, and the dismiss
   control. The strip is 48px tall (a 44px dismiss control plus 2px of
   padding above and below, so the line does not shrink when a fourth line
   arrives) with 16px+ text, and both edges are torn with a clip-path
   polygon. A clip-path also clips an outer box-shadow, so every glow on a
   strip is an inset shadow or a background. */
.scanner-result-tag.catch-chip {
  --strip: #fbf6e8;
  --strip-edge: rgba(60, 50, 30, 0.14);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 2px 4px 2px 12px;
  border: none;
  border-radius: 0;
  background: var(--strip);
  box-shadow: inset 0 0 0 1px var(--strip-edge);
  color: #1f2a44;
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
  clip-path: polygon(0 4px, 5% 1px, 11% 5px, 17% 2px, 23% 5px, 29% 0, 36% 5px, 42% 2px, 48% 5px, 55% 1px, 61% 5px,
    67% 2px, 73% 5px, 79% 0, 86% 5px, 92% 2px, 100% 4px, 100% calc(100% - 4px), 95% calc(100% - 1px),
    89% calc(100% - 5px), 83% calc(100% - 2px), 77% calc(100% - 5px), 71% 100%, 64% calc(100% - 5px),
    58% calc(100% - 2px), 52% calc(100% - 5px), 45% calc(100% - 1px), 39% calc(100% - 5px), 33% calc(100% - 2px),
    27% calc(100% - 5px), 21% 100%, 14% calc(100% - 5px), 8% calc(100% - 2px), 0 calc(100% - 4px));
  animation: tagAppear 0.2s ease-out, captureLineArrive 0.9s ease-out;
}
.catch-chip .capture-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: #1f2a44;
}
.catch-chip .catch-word {
  font-family: var(--font-hand);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
  color: #1f2a44;
}
.catch-chip .capture-time {
  font-family: var(--font-data);
  font-size: 16px;
  color: #5c657a;
  font-variant-numeric: tabular-nums;
}
/* The dot between the word and the time. */
.catch-chip .capture-time::before {
  content: "\00B7";
  margin-right: 10px;
  color: #5c657a;
}
/* The dismiss control on every line of the pad, code or mark: a 44px hit
   area at the right end of the line. */
.scanner-results .chip-dismiss {
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #1f2a44;
  opacity: 0.55;
}
.scanner-results .chip-dismiss:hover { opacity: 1; color: var(--accent-dim); }
/* A new strip starts with an amber background and inset shadow that fade to
   the plain paper colour over 0.9s. */
@keyframes captureLineArrive {
  0% { background: #ffe9b0; box-shadow: inset 0 0 0 2px #f59e0b, inset 0 0 18px rgba(245, 158, 11, 0.45); }
  100% { background: var(--strip); box-shadow: inset 0 0 0 1px var(--strip-edge); }
}
/* The tapped line glows until another line is tapped (js/capture-notepad.js
   lightLine); the tap also flashes that code's own detection box over the
   picture, unchanged. The tapped line glows blue (the owner's mockup); an owned (grey) line glows grey, never blue, so it
   still reads as already yours (section 11). */
.scanner-result-tag.catch-chip.capture-line-lit {
  background: #f2f8ff;
  box-shadow: inset 0 0 0 2px rgba(56, 160, 255, 0.85), inset 0 0 22px rgba(56, 160, 255, 0.4);
}
.scanner-result-tag.catch-chip.chip-owned.capture-line-lit {
  background: #e2e4ea;
  box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.9), inset 0 0 22px rgba(148, 163, 184, 0.45);
}
/* Duplicate catch (section 13): the existing chip jiggles — a short side
   shake plus a brief glow so the chip is easy to spot. Reduced motion keeps
   only the glow. The generic rule glows the border; a paper strip has no
   border, so the strip rule below glows the paper itself. */
.scanner-result-tag.chip-jiggle {
  animation: chipJiggle 0.45s ease-in-out, chipDupGlow 0.7s ease-out;
}
@keyframes chipJiggle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes chipDupGlow {
  0% { border-color: #ffe9b8; box-shadow: 0 0 14px rgba(245, 158, 11, 0.5); }
  100% { border-color: var(--accent-dim); box-shadow: none; }
}
.scanner-result-tag.catch-chip.chip-jiggle {
  animation: chipJiggle 0.45s ease-in-out, captureLineGlow 0.7s ease-out;
}
@keyframes captureLineGlow {
  0% { background: #ffe9b0; box-shadow: inset 0 0 0 2px #f59e0b, inset 0 0 16px rgba(245, 158, 11, 0.45); }
  100% { background: var(--strip); box-shadow: inset 0 0 0 1px var(--strip-edge); }
}
@media (prefers-reduced-motion: reduce) {
  .scanner-result-tag.chip-jiggle { animation: chipDupGlow 0.7s ease-out; }
  .scanner-result-tag.catch-chip.chip-jiggle { animation: captureLineGlow 0.7s ease-out; }
}
/* Owned catch (DESIGN_DECISIONS.md section 11): grey means the system was
   already in the atlas before this session. An owned line is drawn in grey:
   same wording, grey ink, no amber arrival flash. */
.scanner-result-tag.catch-chip.chip-owned {
  --strip: #ebe7dc;
  color: #6b7280;
  animation: tagAppear 0.2s ease-out;
}
.catch-chip.chip-owned .capture-icon,
.catch-chip.chip-owned .catch-word { color: #6b7280; }
/* The grey strip's jiggle glows grey, not amber. */
.scanner-result-tag.catch-chip.chip-owned.chip-jiggle {
  animation: chipJiggle 0.45s ease-in-out, captureLineGlowGrey 0.7s ease-out;
}
@keyframes captureLineGlowGrey {
  0% { background: #e2e4ea; box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.9), inset 0 0 14px rgba(148, 163, 184, 0.45); }
  100% { background: var(--strip); box-shadow: inset 0 0 0 1px var(--strip-edge); }
}
@media (prefers-reduced-motion: reduce) {
  .scanner-result-tag.catch-chip.chip-owned.chip-jiggle { animation: captureLineGlowGrey 0.7s ease-out; }
}
/* Picture tap (direction two, DCOSMOS-HATCHCEREMONY): tapping a code's box
   in the picture jiggles the matching chip (reuses chip-jiggle above) plus
   this bright one-shot flash layered on top, so a tap from either side of
   the link reads the same way. JS removes the class once it finishes. */
.scanner-result-tag.chip-code-tap-flash {
  animation: chipCodeTapFlash 0.6s ease-out;
}
/* The animation shorthand does not merge across classes -- whichever rule
   wins takes the whole property. A chip carrying both classes plays the
   shake and the flash as one comma-joined animation list. */
.scanner-result-tag.chip-jiggle.chip-code-tap-flash,
.scanner-result-tag.chip-owned.chip-jiggle.chip-code-tap-flash {
  animation: chipJiggle 0.45s ease-in-out, chipCodeTapFlash 0.6s ease-out;
}
@keyframes chipCodeTapFlash {
  0% {
    border-color: #fff5da;
    box-shadow: 0 0 22px rgba(255, 245, 218, 0.9), inset 0 0 14px rgba(255, 245, 218, 0.5);
    background: rgba(255, 212, 121, 0.35);
  }
  100% { border-color: var(--accent-dim); box-shadow: none; }
}
/* On a paper strip the same tap plays the shake with the paper glow (grey
   on an owned strip), and the strip stays lit afterwards (capture-line-lit,
   set by the same tap). */
.scanner-result-tag.catch-chip.chip-code-tap-flash,
.scanner-result-tag.catch-chip.chip-jiggle.chip-code-tap-flash {
  animation: chipJiggle 0.45s ease-in-out, captureLineGlow 0.6s ease-out;
}
.scanner-result-tag.catch-chip.chip-owned.chip-jiggle.chip-code-tap-flash {
  animation: chipJiggle 0.45s ease-in-out, captureLineGlowGrey 0.6s ease-out;
}
/* Reduced motion: no shake on a picture tap. Each selector here repeats the
   class count of the normal rule it overrides, because a rule with more
   classes wins whatever order the rules come in. */
@media (prefers-reduced-motion: reduce) {
  .scanner-result-tag.chip-code-tap-flash,
  .scanner-result-tag.chip-jiggle.chip-code-tap-flash,
  .scanner-result-tag.chip-owned.chip-jiggle.chip-code-tap-flash {
    animation: none;
    box-shadow: 0 0 14px rgba(255, 245, 218, 0.6);
  }
  .scanner-result-tag.catch-chip.chip-code-tap-flash,
  .scanner-result-tag.catch-chip.chip-jiggle.chip-code-tap-flash { animation: captureLineGlow 0.6s ease-out; }
  .scanner-result-tag.catch-chip.chip-owned.chip-jiggle.chip-code-tap-flash { animation: captureLineGlowGrey 0.6s ease-out; }
}
.chip-dismiss {
  all: unset;
  cursor: pointer;
  margin-left: 2px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-dim);
  opacity: 0.6;
  padding: 0 2px;
}
.chip-dismiss:hover { opacity: 1; color: var(--accent); }
/* Done sits on the notepad: css/cosmos-scanner.css .capture-notepad-foot. */
.scanner-fallback {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
}
.scanner-fallback p {
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 400px;
  line-height: 1.6;
}
.scanner-fallback .fallback-upload { position: relative; }
.scanner-fallback .fallback-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.scanner-fallback .fallback-upload .btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 12px 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: none;
}
