/* ==========================================================================
   Identification Entry Point + Camera Modal
   Design tokens from design-system.md
   ========================================================================== */

/* --- Entry Point (id-entry__*) --- */

.id-entry {
  padding-top: var(--space-10);
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  position: relative;
}

/* Heading composition: Bebas Neue + Fraunces italic */
.id-entry__heading {
  margin-bottom: var(--space-2);
}

.id-entry__heading-display {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--color-ink);
  margin: 0;
  line-height: 1.1;
}

.id-entry__heading-accent {
  font-family: var(--font-accent);
  font-style: italic;
  font-size: 18px;
  color: var(--color-ink);
  margin: 0;
  line-height: 1.3;
}

.id-entry__heading-accent-period {
  color: var(--color-amber);
}

/* --- Toggle Row --- */

.id-entry__toggles {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  padding: 8px 16px 14px;
}

.id-entry__toggle-divider {
  width: 1px;
  height: 20px;
  background: rgba(26, 13, 8, 0.12);
  flex-shrink: 0;
}

.id-entry__toggle-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.id-entry__toggle-label {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  text-transform: uppercase;
}

.id-entry__toggle-btns {
  display: flex;
  background: var(--color-parch);
  border-radius: 12px;
  padding: 2px;
  gap: 1px;
}

.id-entry__toggle-btn {
  width: 30px;
  height: 26px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  transition: background var(--duration-fast) var(--ease-in-out),
              color var(--duration-fast) var(--ease-in-out);
}

.id-entry__toggle-btn svg {
  stroke: var(--color-ink-muted);
  transition: stroke var(--duration-fast) var(--ease-in-out);
}

.id-entry__toggle-btn--active {
  background: var(--color-ink);
}

.id-entry__toggle-btn--active svg {
  stroke: var(--color-ivory);
}

/* --- Upload Card --- */

.id-entry__card {
  margin: 0 var(--space-4);
  border: var(--border-brand);
  border-radius: var(--radius-card);
  background: var(--color-cream-card);
  overflow: hidden;
}

.id-entry__card--drag-active {
  border-color: var(--color-red);
  background: var(--color-ivory);
}

/* Card Header */
.id-entry__card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(26, 13, 8, 0.08);
}

.id-entry__card-header-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-electric);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
}

.id-entry__card-header-label svg {
  width: 12px;
  height: 12px;
  stroke: var(--color-electric);
  flex-shrink: 0;
}

.id-entry__card-header-add {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  color: var(--color-ink-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.id-entry__card-header-add:hover {
  color: var(--color-ink);
}

.id-entry__card-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.id-entry__card-header-btn {
  background: transparent;
  border: 1px solid rgba(26, 13, 8, 0.15);
  color: var(--color-ink-2);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.id-entry__card-header-btn:hover {
  background: rgba(26, 13, 8, 0.04);
  border-color: rgba(26, 13, 8, 0.30);
}

.id-entry--editing .id-entry__card-header-btn {
  background: var(--color-ink);
  color: var(--color-ivory);
  border-color: var(--color-ink);
}

/* Upload Target */
.id-entry__upload-target {
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
}

.id-entry__upload-target-icon {
  width: 44px;
  height: 44px;
  opacity: 0.25;
  margin: 0 auto var(--space-3);
  display: block;
}

.id-entry__upload-target-text {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  color: var(--color-ink);
  margin: 0;
}

.id-entry__upload-target-subtext {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--color-ink-muted);
  margin: var(--space-1) 0 0;
}

.id-entry__upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Hide drag text on touch devices */
@media (hover: none) and (pointer: coarse) {
  .id-entry__upload-target-subtext {
    display: none;
  }
}

/* Action Row (UPLOAD / CAMERA tabs) */
.id-entry__action-row {
  display: flex;
  border-top: 1px solid rgba(26, 13, 8, 0.08);
}

.id-entry__action-tab {
  flex: 1;
  padding: 11px;
  text-align: center;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--color-ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.id-entry__action-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.id-entry__action-tab--active {
  color: var(--color-ink);
  background: rgba(26, 13, 8, 0.03);
}

/* --- Converged State (Photos Ready) --- */

/* Photo Grid */
.id-entry__photo-grid {
  padding: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Register --p so the conic-gradient transition on the upload pie can
   interpolate smoothly. Without @property, custom-property changes apply
   instantly and the ring would snap rather than fill. */
@property --p {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.id-entry__thumb {
  position: relative;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}

/* Layer 1 — Placeholder: parch background + photo-icon SVG. Visible until
   the wrapper gets .id-entry__thumb--ready, then fades to reveal the img. */
.id-entry__thumb-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 4px;
  background-color: var(--color-parch);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32' fill='none'><rect x='4' y='7' width='24' height='18' rx='2' stroke='%237A5C48' stroke-width='1.5'/><circle cx='11' cy='14' r='2' fill='%237A5C48'/><path d='M5 23l7-7 5 5 4-4 7 6' stroke='%237A5C48' stroke-width='1.5' stroke-linejoin='round' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 32px 32px;
  opacity: 1;
  pointer-events: none;
  transition: opacity 150ms var(--ease-out);
}

.id-entry__thumb--ready .id-entry__thumb-placeholder {
  opacity: 0;
}

/* Layer 2 — Img: stacks above the placeholder via z-index, starts hidden
   and crossfades in when the wrapper gets .id-entry__thumb--ready. */
.id-entry__thumb-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: cover;
  border: 1.5px solid rgba(26, 13, 8, 0.12);
  opacity: 0;
  transition: opacity 150ms var(--ease-out);
}

.id-entry__thumb--ready .id-entry__thumb-img {
  opacity: 1;
}

.id-entry__thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-red);
  color: var(--color-ivory);
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Hidden by default. Surfaced when the entry root is in edit mode
     (mobile + desktop, no hover dependency). Desktop also gets the
     hover-reveal for fast removal without entering edit mode. */
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.id-entry--editing .id-entry__thumb-remove {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .id-entry__thumb:hover .id-entry__thumb-remove {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Layer 3 — Pie: per-thumb upload progress ring. The conic-gradient stop
   is driven by the --p custom property (0..100) that the JS animates as
   bytes upload. Done flips to a solid mint check; failed turns red and
   becomes the retry tap target; scoring pulses while AI runs. */
.id-entry__thumb-pie {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  z-index: 3;
  border-radius: 50%;
  border: 1.5px solid var(--color-ivory);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  background: conic-gradient(var(--color-electric) calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.55) 0);
  /* 250ms (not 80ms) so a single 0→100 progress event on a fast
     connection (small file → S3 PUT in <100ms → one progress event
     with loaded=total) still animates visibly. The browser fires
     progress at its own cadence; the transition only sets a max
     duration per interpolation. */
  transition: --p 250ms linear, background 100ms var(--ease-out);
  pointer-events: none;
}

.id-entry__thumb-pie--done {
  --p: 100;
  background: var(--color-mint);
}

.id-entry__thumb-pie--done::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ivory);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.id-entry__thumb-pie--failed {
  background: conic-gradient(var(--color-red) calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.55) 0);
  cursor: pointer;
  pointer-events: auto;
}

.id-entry__thumb-pie--failed::after {
  content: "↻";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ivory);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.id-entry__thumb-pie--scoring {
  /* Keep the conic-gradient (don't swap to solid background) so the
     --p 0→100 transition kicked off by the last xhr.upload.progress
     event remains visible. At --p:100 the conic-gradient renders as
     a full electric ring, identical to the solid background but
     interpolable from any prior --p value. The pulse halo runs on
     box-shadow, independent of background. */
  --p: 100;
  animation: pie-pulse 1.2s var(--ease-out) infinite;
}

@keyframes pie-pulse {
  0% { box-shadow: 0 0 0 0 rgba(26, 93, 255, 0.45); }
  100% { box-shadow: 0 0 0 6px rgba(26, 93, 255, 0); }
}

/* Reassurance Copy */
.id-entry__reassurance {
  padding: 12px 16px;
  text-align: center;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--color-ink-2);
  line-height: 1.5;
}

/* Action Buttons (NEW / CONTINUE) */
.id-entry__buttons {
  display: flex;
  border-top: 1.5px solid rgba(26, 13, 8, 0.12);
}

.id-entry__btn-new,
.id-entry__btn-continue {
  flex: 1;
  padding: 10px 8px;
  border: none;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.id-entry__btn-new {
  background: var(--color-ink);
  color: var(--color-ivory);
  border-right: 1px solid rgba(250, 246, 238, 0.15);
}

.id-entry__btn-new svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-ivory);
}

.id-entry__btn-continue {
  background: var(--color-red);
  color: var(--color-ivory);
}

.id-entry__btn-continue svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-ivory);
}

.id-entry__btn-subtitle {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.65;
  margin-top: 2px;
}

/* Disabled state while uploads in progress */
.id-entry__btn-new[disabled],
.id-entry__btn-continue[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.id-entry__btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(250, 246, 238, 0.3);
  border-top-color: var(--color-ivory);
  border-radius: 50%;
  animation: id-btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* Cancel Link */
.id-entry__cancel {
  display: inline-block;
  margin-top: var(--space-4);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--color-ink-muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(122, 92, 72, 0.3);
  text-underline-offset: 2px;
  background: none;
  border: none;
  padding: 0;
}

.id-entry__cancel:hover {
  color: var(--color-ink);
  text-decoration-color: var(--color-ink);
}

/* Credits Indicator */
.id-entry__credits {
  text-align: center;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-mint);
  margin-top: var(--space-3);
  padding-bottom: var(--space-6);
}

.id-entry__credits--empty {
  color: var(--color-red);
}

/* ==========================================================================
   Camera Modal (camera-modal__*)
   Full-screen overlay — z-index 500, above everything
   ========================================================================== */

.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #0a0a0a;
  display: none;
  flex-direction: column;
}

.camera-modal--open {
  display: flex;
}

/* Viewfinder */
.camera-modal__viewfinder {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-modal__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-modal__canvas {
  display: none;
}

/* Scan brackets — decorative amber corners */
.camera-modal__brackets {
  position: absolute;
  inset: 15%;
  border: none;
  pointer-events: none;
  opacity: 0.7;
}

.camera-modal__brackets::before,
.camera-modal__brackets::after,
.camera-modal__brackets-bottom::before,
.camera-modal__brackets-bottom::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--color-amber);
  border-style: solid;
  border-width: 0;
}

.camera-modal__brackets::before {
  top: 0;
  left: 0;
  border-top-width: 2px;
  border-left-width: 2px;
}

.camera-modal__brackets::after {
  top: 0;
  right: 0;
  border-top-width: 2px;
  border-right-width: 2px;
}

.camera-modal__brackets-bottom {
  position: absolute;
  inset: 15%;
  pointer-events: none;
}

.camera-modal__brackets-bottom::before {
  bottom: 0;
  left: 0;
  border-bottom-width: 2px;
  border-left-width: 2px;
}

.camera-modal__brackets-bottom::after {
  bottom: 0;
  right: 0;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

/* Close button */
.camera-modal__close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(26, 13, 8, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  min-height: 44px;
  min-width: 44px;
}

.camera-modal__close svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-ivory);
}

/* Photo count pill */
.camera-modal__count {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(26, 13, 8, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.camera-modal__count svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-ivory);
}

.camera-modal__count-number {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ivory);
}

/* Permission granted dot */
.camera-modal__count-granted-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-mint);
  flex-shrink: 0;
}

/* Last capture thumbnail */
.camera-modal__thumb {
  position: absolute;
  bottom: 16px;
  left: 16px;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 2px solid rgba(250, 246, 238, 0.4);
  object-fit: cover;
  z-index: 10;
}

/* Controls strip — bottom (portrait) */
.camera-modal__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-4);
  background: #0a0a0a;
  flex-shrink: 0;
}

/* Shutter button */
.camera-modal__shutter {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid rgba(250, 246, 238, 0.6);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.camera-modal__shutter:active {
  transform: scale(0.92);
}

.camera-modal__shutter-inner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--color-ivory);
}

/* Flip camera button */
.camera-modal__flip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(250, 246, 238, 0.1);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.camera-modal__flip svg {
  width: 22px;
  height: 22px;
  stroke: var(--color-ivory);
}

/* --- Permission States --- */

.camera-modal__permission {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  z-index: 5;
  text-align: center;
  padding: var(--space-6);
}

.camera-modal__permission-icon {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

.camera-modal__permission-icon svg {
  width: 48px;
  height: 48px;
  stroke: var(--color-ivory);
}

.camera-modal__permission-text {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-ivory);
  opacity: 0.8;
  margin: 0;
}

.camera-modal__permission-subtext {
  font-family: var(--font-body);
  font-size: 12px;
  color: rgba(250, 246, 238, 0.6);
  margin: 0;
}

.camera-modal__permission-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 12px 24px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  min-height: 44px;
}

.camera-modal__permission-btn--allow {
  background: var(--color-electric);
  color: var(--color-ivory);
}

.camera-modal__permission-btn--retry {
  background: var(--color-red);
  color: var(--color-ivory);
}

.camera-modal__permission-fallback {
  font-family: var(--font-body);
  font-size: 12px;
  color: rgba(250, 246, 238, 0.5);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
}

/* Denied state — red tint overlay */
.camera-modal__permission--denied {
  background: rgba(192, 48, 26, 0.08);
}

.camera-modal__permission--denied .camera-modal__permission-icon {
  opacity: 1;
}

.camera-modal__permission--denied .camera-modal__permission-icon svg {
  stroke: var(--color-red);
}

.camera-modal__permission--denied .camera-modal__permission-text {
  font-weight: 500;
  opacity: 1;
}

/* Granted state — just the dot in the count pill, no overlay */
.camera-modal__permission--granted {
  display: none;
}

/* Flash effect — reused from existing camera pattern */
.camera-modal--flash .camera-modal__viewfinder::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-ivory);
  animation: camera-flash 0.2s var(--ease-out) forwards;
  z-index: 20;
}

/* --- Landscape Layout --- */

@media (orientation: landscape) {
  .camera-modal__controls {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-4);
  }

  .camera-modal__controls--landscape {
    flex-direction: column;
  }
}

/* ==========================================================================
   Preserved Animations
   ========================================================================== */

@keyframes camera-flash {
  from { opacity: 0.8; }
  to { opacity: 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ==========================================================================
   Identification Result (P9) — Preserved
   ========================================================================== */

.identification-result {
  padding-top: var(--space-8);
  max-width: 480px;
  margin: 0 auto;
}

.identification-result__card {
  background: var(--color-cream-card);
  border: var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  text-align: center;
}

.identification-result__image {
  margin-bottom: var(--space-6);
}

.identification-result__image img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius-card);
}

.identification-result__name {
  font-family: var(--font-accent);
  font-style: italic;
  font-size: 24px;
  color: var(--color-ink);
  margin: 0 0 var(--space-3) 0;
}

.identification-result__grade {
  display: inline-block;
  background: var(--color-amber-light);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  padding: var(--space-1) var(--space-3);
  border-radius: 3px;
  margin-bottom: var(--space-4);
}

.identification-result__value {
  font-family: var(--font-accent);
  font-style: italic;
  font-size: 20px;
  color: var(--color-ink);
  margin-bottom: var(--space-4);
}

/* Confidence Bar */
.identification-result__confidence {
  margin-bottom: var(--space-6);
}

.confidence-bar {
  background: var(--color-parch-2);
  border: 2px solid var(--color-ink);
  border-radius: 3px;
  height: 10px;
  width: 100%;
  overflow: hidden;
}

.confidence-bar__fill {
  height: 100%;
  border-radius: 1px;
  transition: width var(--duration-normal) var(--ease-brand);
}

.confidence-bar__fill--high {
  background: linear-gradient(90deg, var(--color-mint) 0%, var(--color-mint) 100%);
}

.confidence-bar__fill--mid {
  background: linear-gradient(90deg, var(--color-amber) 0%, var(--color-amber-2) 100%);
}

.confidence-bar__fill--low {
  background: linear-gradient(90deg, var(--color-red) 0%, var(--color-red-2) 100%);
}

.confidence-bar__label {
  display: block;
  text-align: right;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  color: var(--color-ink-muted);
  margin-top: var(--space-1);
}

/* Counterfeit Alert */
.counterfeit-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--color-red-light);
  border: 2.5px solid var(--color-red);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  animation: counterfeit-shake 0.4s var(--ease-brand);
}

.counterfeit-alert__icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.counterfeit-alert__content {
  flex: 1;
}

.counterfeit-alert__title {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-red);
  margin-bottom: var(--space-1);
}

.counterfeit-alert__message {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 13px;
  color: var(--color-ink);
  margin: 0;
}

@keyframes counterfeit-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-3px); }
  60% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
}

/* Result Actions */
.identification-result__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* Error State */
.identification-error {
  text-align: center;
  padding: var(--space-16) 0;
}

.identification-error__message {
  font-family: var(--font-body);
  font-size: var(--text-app-body);
  color: var(--color-ink-muted);
  margin-bottom: var(--space-6);
}

.identification-error__actions {
  display: flex;
  justify-content: center;
}

/* Full-width button modifier */
.btn--full-width {
  width: 100%;
  justify-content: center;
}

/* ==========================================================================
   Preserved Utility
   ========================================================================== */

.hidden {
  display: none !important;
}

/* ==========================================================================
   Search Clear Button (used across identification pages)
   ========================================================================== */

.search-box__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-ink);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.5;
  line-height: 1;
}

.search-box__clear:hover { opacity: 1; }

/* ==========================================================================
   Bulk Action Bar (preserved — used by collection gallery)
   ========================================================================== */

.bulk-action-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-cream-card);
  border-top: 2.5px solid var(--color-ink);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.bulk-action-bar__count {
  font-family: var(--font-body);
  font-weight: 600;
  flex: 1;
}

.btn--danger {
  background: var(--color-red);
  color: var(--color-cream);
  border-color: var(--color-red);
}

/* ==========================================================================
   Gallery Card Checkbox (preserved — used by collection gallery)
   ========================================================================== */

.gallery-card__checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
}

.gallery-card__checkbox input {
  width: 20px;
  height: 20px;
  accent-color: var(--color-red);
}

/* ==========================================================================
   Card Flip Animation (preserved — used by result page)
   ========================================================================== */

.card-flip {
  perspective: 1000px;
}

.card-flip__inner {
  position: relative;
  transition: transform 0.8s var(--ease-spring);
  transform-style: preserve-3d;
}

.card-flip__inner--flipped {
  transform: rotateY(180deg);
}

.card-flip__front,
.card-flip__back {
  backface-visibility: hidden;
}

.card-flip__front {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transform: rotateY(180deg);
}

.card-flip__back {
  position: relative;
}

.card-flip__inner--no-animation {
  transition: none !important;
  transform: rotateY(180deg) !important;
}

/* ==========================================================================
   Staged Progress (preserved — used by identification show page)
   ========================================================================== */

.identification-progress-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  padding: var(--space-6);
}

.identification-stages__list {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  padding: 0;
  margin: 0;
}

.identification-stages__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

.identification-stages__item--active {
  opacity: 1;
  font-weight: 600;
}

.identification-stages__item--completed {
  opacity: 0.7;
}

.identification-stages__marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid var(--color-parch-2);
  font-size: var(--text-app-label);
}

.identification-stages__item--active .identification-stages__marker {
  border-color: var(--color-red);
  color: var(--color-red);
}

.identification-stages__item--completed .identification-stages__marker {
  border-color: var(--color-mint);
  color: var(--color-mint);
  background: var(--color-mint-light);
}

.identification-stages__pulse {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-red);
  animation: identification-stage-pulse 1.2s ease-in-out infinite;
}

@keyframes identification-stage-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.5; }
}

.identification-stages__label {
  font-size: var(--text-app-label);
  white-space: nowrap;
}

/* Celebration */
.identification-celebration {
  text-align: center;
  animation: identification-celebrate 0.5s ease-out;
}

.identification-celebration__emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: var(--space-2);
}

.identification-celebration__title {
  font-family: var(--font-display);
  font-size: var(--text-app-title);
  margin-bottom: var(--space-1);
}

.identification-celebration__subtitle {
  color: var(--color-ink-muted);
}

@keyframes identification-celebrate {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* Failure */
.identification-failure {
  text-align: center;
}

.identification-failure__icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: var(--space-2);
}

.identification-failure__title {
  font-family: var(--font-display);
  margin-bottom: var(--space-1);
}

.identification-failure__message {
  color: var(--color-ink-muted);
  margin-bottom: var(--space-4);
}

/* Re-identification edit */
.identification-edit__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.identification-edit__photo {
  position: relative;
}

.identification-edit__photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-card);
}

.identification-edit__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-red);
  color: var(--color-ivory);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: var(--text-app-label);
  line-height: 1;
}

/* Failed feedback section */
.identification-failed__feedback {
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-parch-2);
  padding-top: var(--space-3);
}

.identification-failed__feedback-toggle {
  cursor: pointer;
  color: var(--color-electric);
  font-weight: 500;
  font-size: 0.875rem;
}

.identification-failed__feedback-form {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.identification-failed__feedback-input {
  resize: vertical;
  min-height: 60px;
}

/* Mobile: vertical layout for stages */
@media (max-width: 640px) {
  .identification-stages__list {
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .camera-modal--flash .camera-modal__viewfinder::after {
    animation: none;
    display: none;
  }

  .counterfeit-alert {
    animation: none;
  }

  .id-entry__thumb-pie--scoring {
    animation: none;
    box-shadow: 0 0 0 3px rgba(26, 93, 255, 0.25);
  }

  .identification-celebration {
    animation: none;
  }

  .identification-stages__pulse {
    animation: none;
  }

  .card-flip__inner {
    transition: none;
  }
}

/* ==========================================================================
   Touch Device Adjustments
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
  /* Ensure 44px minimum tap targets */
  .id-entry__toggle-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .camera-modal__close {
    min-width: 44px;
    min-height: 44px;
  }

  .camera-modal__flip {
    min-width: 48px;
    min-height: 48px;
  }
}
