/* styles/main.css — DealerScan PWA
   Extension-matched: navy gradient + glass cards + Google-blue accent.
   Tokens lifted from new-source/overlay.css for brand cohesion. */

:root {
  --bg-gradient: linear-gradient(170deg, #1a5296 0%, #163f7a 45%, #112f63 80%, #0d2654 100%);
  --bg-bottom: #0d2654;

  /* Surfaces — opacity-layered white over navy (extension parity) */
  --surface:        rgba(255, 255, 255, 0.05);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --surface-hover:  rgba(255, 255, 255, 0.13);
  --surface-active: rgba(255, 255, 255, 0.18);
  --border:         rgba(255, 255, 255, 0.12);
  --border-strong:  rgba(255, 255, 255, 0.22);

  /* Text */
  --text:        #ffffff;
  --text-muted:  rgba(255, 255, 255, 0.7);
  --text-dim:    rgba(255, 255, 255, 0.5);
  --text-faint:  rgba(255, 255, 255, 0.35);
  --text-ghost:  rgba(255, 255, 255, 0.25);

  /* Accent — blue gradient (navigation, recents, secondary actions) */
  --accent-grad: linear-gradient(135deg, #4285f4, #2b6ed4);
  --accent:      #4285f4;
  --accent-soft: #6ca0f7;
  --accent-deep: #2b6ed4;

  /* Primary destructive — pink gradient (upload, save, irreversible) */
  --primary-grad: linear-gradient(135deg, #e94560, #c73652);
  --primary:      #e94560;
  --primary-deep: #c73652;
  --primary-glow: rgba(233, 69, 96, 0.35);

  --success: #34d399;
  --danger:  #f87171;

  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-gradient);
  background-color: var(--bg-bottom);
  overscroll-behavior-y: none;
}
body {
  margin: 0; padding: 0;
  min-height: 100vh; min-height: 100dvh;
  background: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  display: flex; flex-direction: column;
  position: relative;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-gradient);
  background-color: var(--bg-bottom);
  z-index: -1;
  pointer-events: none;
}
main {
  flex: 1; display: flex; flex-direction: column;
  padding: 1.5rem 1.25rem 1.25rem; min-height: 0;
}

/* ────────────────────────────────────────
   Screen container + transitions
   ──────────────────────────────────────── */
[data-screen] {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0; gap: 1.25rem;
  animation: screenFadeIn 0.22s ease-out;
}
[data-screen][hidden] { display: none; }

/* HTML's `hidden` attribute defaults to `display:none`, but any explicit
   `display: flex` (or similar) rule overrides it. Elements we toggle from
   JS via `.hidden = true/false` need this override or they stay visible.
   Burned by this once with .camera-fallback; codifying the fix project-wide. */
[hidden] { display: none !important; }

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin: 0; color: var(--text); }
h2 { font-size: 12px; font-weight: 600; margin: 0; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; }
.muted { color: var(--text-dim); }
.dim   { color: var(--text-faint); }
.small { font-size: 13px; }

/* ────────────────────────────────────────
   Inputs (16px min font-size — kills iOS zoom)
   ──────────────────────────────────────── */
input[type="text"], input[type="search"] {
  font: inherit; width: 100%;
  border: 0.5px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 16px 16px;
  outline: none;
  font-size: 17px;
  -webkit-appearance: none; appearance: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input::placeholder { color: var(--text-faint); }
input:focus { border-color: var(--border-strong); background: var(--surface-hover); }

/* ────────────────────────────────────────
   Shared header + buttons
   ──────────────────────────────────────── */
.screen-header { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.screen-header h1 { flex: 1; }
.icon-button {
  background: var(--surface-strong);
  border: 0.5px solid var(--border);
  border-radius: 50%;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.icon-button:active { background: var(--surface-active); color: var(--text); transform: scale(0.94); }

/* Two-tone primary buttons */
.primary-button, .accent-button, .secondary-button {
  font: inherit; font-weight: 600; font-size: 16px;
  border-radius: var(--radius-md);
  padding: 17px 18px; width: 100%;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  border: 0.5px solid transparent;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.15s ease, filter 0.2s ease;
}
.primary-button {
  background: var(--primary-grad);
  color: #fff;
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 4px 14px var(--primary-glow);
}
.primary-button:active { transform: translateY(1px) scale(0.99); box-shadow: 0 2px 8px var(--primary-glow); }
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.accent-button {
  background: var(--accent-grad);
  color: #fff;
  border-color: rgba(255,255,255,0.15);
}
.accent-button:active { transform: scale(0.98); }
.accent-button:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-button {
  background: rgba(255,255,255,0.08);
  color: var(--text-dim);
  border-color: var(--border);
}
.secondary-button:hover { color: var(--text-muted); }
.secondary-button:active { background: var(--surface-active); transform: scale(0.98); }

.sticky-action { margin-top: auto; padding-top: 0.5rem; flex-shrink: 0; }

/* ────────────────────────────────────────
   Sign-in screen — picker
   ──────────────────────────────────────── */
.signin-header { padding: 0.5rem 0 0.75rem; flex-shrink: 0; }
.signin-header h1 { margin-bottom: 6px; }
.signin-header p  { margin: 0; font-size: 15px; color: var(--text-dim); }
.picker-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}
.picker-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 8px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  font-family: inherit; color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  animation: tileFadeIn 0.35s ease-out backwards;
  min-height: 96px;
}
.picker-tile:hover  { background: var(--surface-hover); }
.picker-tile:active { transform: scale(0.95); background: var(--surface-active); border-color: var(--border-strong); }

/* Stagger fade-in for the tile grid — feels alive on load */
@keyframes tileFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.picker-tile:nth-child(3n+1) { animation-delay: 0ms; }
.picker-tile:nth-child(3n+2) { animation-delay: 30ms; }
.picker-tile:nth-child(3n+3) { animation-delay: 60ms; }

.picker-tile-initial {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad);
  color: #fff; font-weight: 600; font-size: 18px;
}
.picker-tile-name { font-size: 13px; font-weight: 500; text-align: center; line-height: 1.2; }

/* ────────────────────────────────────────
   Home screen
   ──────────────────────────────────────── */
.home-header { padding: 0.25rem 0 0; flex-shrink: 0; }
.home-header p { margin: 6px 0 0 0; font-size: 15px; }
.home-greeting { font-size: 34px; font-weight: 700; letter-spacing: -0.7px; margin: 0; color: var(--text); }

.primary-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  background: var(--accent-grad);
  border: 0.5px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-xl);
  padding: 30px 26px 32px;
  color: #fff; font: inherit; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  width: 100%; flex-shrink: 0;
  position: relative; overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 24px rgba(66, 133, 244, 0.3);
  min-height: 160px;
}
.primary-card:active { transform: scale(0.985); box-shadow: 0 3px 12px rgba(66, 133, 244, 0.3); }
.primary-card::after {
  content: ''; position: absolute;
  top: -40%; right: -20%; width: 60%; height: 140%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.primary-card-icon {
  display: inline-flex; width: 56px; height: 56px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.18);
  align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.primary-card-icon svg { width: 36px; height: 36px; }
.primary-card-label { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.primary-card-sub   { font-size: 14px; color: rgba(255,255,255,0.85); margin-top: 2px; }

.recent-section { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; }

.recent-list {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.recent-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 16px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  font: inherit; color: var(--text); text-align: left;
  width: 100%;
  transition: background 0.15s ease, transform 0.1s ease;
  animation: rowFadeIn 0.25s ease-out backwards;
}
.recent-item:active { background: var(--surface-active); transform: scale(0.99); }
.recent-item:nth-child(1) { animation-delay: 0ms; }
.recent-item:nth-child(2) { animation-delay: 40ms; }
.recent-item:nth-child(3) { animation-delay: 80ms; }
.recent-item:nth-child(4) { animation-delay: 120ms; }
.recent-item:nth-child(5) { animation-delay: 160ms; }
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.recent-item-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.recent-item-name {
  flex: 1; font-size: 16px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-item-chev { color: var(--text-faint); flex-shrink: 0; }
.recent-item-chev svg { width: 20px; height: 20px; }

.recent-empty {
  padding: 28px 18px; text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
}

/* ────────────────────────────────────────
   Skeleton loaders (pulsing placeholder rows)
   ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.06) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
}
.skeleton-row {
  height: 72px;
}
@keyframes skeletonShimmer {
  0%   { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}

/* ────────────────────────────────────────
   Customer screen — inline "use as new" CTA + bigger recent rows
   ──────────────────────────────────────── */
.search-wrap {
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 10px;
}

/* When on the customer screen, recent items get more breathing room than
   on the home screen — they're the primary content here, not a sidebar. */
[data-screen="customer"] .recent-list { gap: 10px; }
[data-screen="customer"] .recent-item {
  padding: 20px 18px;
  gap: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
}
[data-screen="customer"] .recent-item-icon {
  width: 48px; height: 48px;
  font-size: 18px;
}
[data-screen="customer"] .recent-item-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.1px;
}
[data-screen="customer"] .recent-item-chev svg { width: 22px; height: 22px; }

[data-screen="customer"] .skeleton-row { height: 88px; }

.inline-new-cta {
  display: flex; align-items: center; gap: 14px;
  background: var(--primary-grad);
  color: #fff;
  border: 0.5px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-lg);
  padding: 18px 18px;
  font: inherit; font-weight: 600; font-size: 16px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  text-align: left; width: 100%;
  box-shadow: 0 4px 14px var(--primary-glow);
  animation: ctaSlideIn 0.22s ease-out;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.inline-new-cta:active { transform: scale(0.985); box-shadow: 0 2px 8px var(--primary-glow); }
.inline-new-cta-plus {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; line-height: 1;
  flex-shrink: 0;
}
.inline-new-cta-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-new-cta-chev { display: inline-flex; opacity: 0.7; }
.inline-new-cta-chev svg { width: 20px; height: 20px; }

@keyframes ctaSlideIn {
  from { opacity: 0; transform: translateY(-6px); max-height: 0; padding-top: 0; padding-bottom: 0; }
  to   { opacity: 1; transform: translateY(0); max-height: 60px; }
}

/* ────────────────────────────────────────
   Camera screen — full-bleed viewfinder + chrome overlays
   ──────────────────────────────────────── */

/* The camera screen breaks the normal screen padding because the viewfinder
   is full-bleed. We override main padding when camera is active. */
main:has([data-screen="camera"]:not([hidden])) {
  padding: 0;
}

.camera-stage {
  position: relative;
  flex: 1;
  background: #000;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Flash overlay — pulses white briefly on capture for tactile feedback */
.camera-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.18s ease;
}
.camera-flash.firing {
  opacity: 0.85;
  transition: opacity 0.08s ease;
}

/* Top chrome — sits above the viewfinder */
.camera-top {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 14px 0;
}
.camera-chrome-btn {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}
.camera-customer-chip {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 99px;
  padding: 9px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  margin: 0 auto;
}
.camera-customer-chip:empty { display: none; }

.camera-done-btn {
  background: var(--primary-grad);
  color: #fff;
  border: 0.5px solid rgba(255,255,255,0.2);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 18px;
  border-radius: 99px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform 0.1s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}
.camera-done-btn:active { transform: scale(0.95); }
.camera-done-btn:disabled {
  background: rgba(0, 0, 0, 0.45);
  box-shadow: none;
  opacity: 0.6;
  cursor: not-allowed;
}

/* Bottom chrome — shutter row.
   3 columns of equal width so the shutter stays dead-center regardless
   of whether the thumb peek is visible. Left + right columns are 76px
   wide (same as shutter) so the layout is perfectly symmetric. */
.camera-bottom {
  position: relative;
  z-index: 10;
  margin-top: auto;
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  align-items: center;
  padding: 14px 18px 26px;
  gap: 12px;
}

.camera-thumb-peek {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.4);
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  position: relative;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
  justify-self: start;
}
.camera-thumb-peek:active { transform: scale(0.93); }
.camera-thumb-peek img { width: 100%; height: 100%; object-fit: cover; display: block; }

.camera-thumb-peek-count {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* The classic ring + core shutter */
.camera-shutter {
  width: 76px;
  height: 76px;
  border: none;
  background: transparent;
  padding: 0;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-shutter-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.camera-shutter-core {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.12s ease, background 0.12s ease;
}
.camera-shutter:active .camera-shutter-core {
  transform: scale(0.86);
  background: rgba(255, 255, 255, 0.85);
}
.camera-shutter:disabled .camera-shutter-core { background: rgba(255,255,255,0.45); }
.camera-shutter:disabled { cursor: not-allowed; }

.camera-bottom-right-spacer { /* keeps the shutter centered in the 3-col grid */ }

/* Permission denied / no camera fallback overlay */
.camera-fallback {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(13, 38, 84, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px;
  gap: 10px;
}
.camera-fallback-icon { font-size: 56px; opacity: 0.55; }
.camera-fallback h2 {
  font-size: 20px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
  color: var(--text);
}
.camera-fallback p { margin: 0 0 8px 0; font-size: 14px; max-width: 320px; }
.camera-fallback-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 14px 24px;
  cursor: pointer;
}

/* ────────────────────────────────────────
   Review
   ──────────────────────────────────────── */
.review-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  flex: 1; align-content: start; padding-bottom: 0.5rem;
}
.review-thumb {
  position: relative; aspect-ratio: 3 / 4;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: thumbPop 0.25s ease-out backwards;
}
@keyframes thumbPop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.review-thumb:nth-child(1) { animation-delay: 0ms; }
.review-thumb:nth-child(2) { animation-delay: 40ms; }
.review-thumb:nth-child(3) { animation-delay: 80ms; }
.review-thumb:nth-child(4) { animation-delay: 120ms; }
.review-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-thumb-placeholder { font-size: 28px; opacity: 0.45; }
.review-thumb-index {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 10px;
}
.review-thumb-delete {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.6); border: none; color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
  transition: background 0.15s ease;
}
.review-thumb-delete:active { background: var(--primary); }

/* ────────────────────────────────────────
   Upload — stacked card deck
   One active card on top, queue peeks behind. As cards complete they
   fly off and the stack visibly shrinks. Active card carries a
   "2 of 5" count badge so progress is legible without extra UI chrome.
   ──────────────────────────────────────── */

.card-deck-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  /* Generous padding so the back-stack cards have room to peek */
  padding: 8px 8px 24px;
  perspective: 1000px;
}

.deck-card {
  position: absolute;
  width: min(78%, 320px);
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  border: 0.5px solid var(--border);
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.5s cubic-bezier(0.32, 0.72, 0.0, 1),
    opacity 0.5s ease,
    filter 0.4s ease,
    box-shadow 0.4s ease;
  transform-origin: center 70%;
  will-change: transform, opacity;
}

.deck-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Stack positions (data-pos attribute) ────────
   pos=0 = active (front, full size, sharp)
   pos=1 = behind by one (slightly smaller, dimmed)
   pos=2 = behind by two (smaller still, more dimmed)
   pos=3+ = hidden (behind the stack) */
.deck-card[data-pos="0"] {
  transform: translate(-50%, -50%) translateY(0) scale(1);
  opacity: 1;
  z-index: 30;
  filter: none;
}
.deck-card[data-pos="1"] {
  transform: translate(-50%, -50%) translateY(14px) scale(0.94);
  opacity: 0.65;
  z-index: 20;
  filter: saturate(0.8) brightness(0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.deck-card[data-pos="2"] {
  transform: translate(-50%, -50%) translateY(28px) scale(0.88);
  opacity: 0.35;
  z-index: 10;
  filter: saturate(0.6) brightness(0.78);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
.deck-card[data-pos="3"], .deck-card[data-hidden] {
  transform: translate(-50%, -50%) translateY(42px) scale(0.82);
  opacity: 0;
  z-index: 5;
  pointer-events: none;
}

.deck-card { left: 50%; top: 50%; }

/* ── Completed card flies off to the left ─────── */
.deck-card.flying-off {
  transform: translate(-50%, -50%) translateX(-120vw) scale(0.92) rotate(-8deg);
  opacity: 0;
  z-index: 40;
  transition:
    transform 0.55s cubic-bezier(0.5, 0.0, 0.75, 0.0),
    opacity 0.4s ease 0.1s;
}

/* ── Status overlay (only meaningful on the active card) ─── */
.deck-card-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.15) 35%,
    rgba(0, 0, 0, 0.20) 65%,
    rgba(0, 0, 0, 0.65) 100%
  );
}

.deck-card-top-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px;
}

/* "2 of 5" badge — top-left of the active card */
.deck-card-count {
  display: inline-flex; align-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.3px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 0.5px solid rgba(255,255,255,0.18);
}

/* Status icon — top-right corner of the active card */
.deck-card-status-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-grad);
  border: 0.5px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(66, 133, 244, 0.45);
  transition: background 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.deck-card.pending .deck-card-status-icon {
  background: rgba(255,255,255,0.15);
  box-shadow: none;
}
.deck-card.success .deck-card-status-icon {
  background: var(--success);
  color: #06381f;
  box-shadow: 0 4px 14px rgba(52, 211, 153, 0.5);
  animation: checkPopBig 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.deck-card.failed .deck-card-status-icon {
  background: var(--danger);
  color: #3a0e0e;
  box-shadow: 0 4px 14px rgba(248, 113, 113, 0.45);
}

.deck-card-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes checkPopBig {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.18); }
  100% { transform: scale(1); opacity: 1; }
}

/* Filename at the bottom of the active card */
.deck-card-filename {
  color: rgba(255,255,255,0.95);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,0.45);
}

/* Behind-the-stack cards: dim their overlays so they don't visually compete */
.deck-card:not([data-pos="0"]) .deck-card-overlay {
  background: rgba(0, 0, 0, 0.25);
}
.deck-card:not([data-pos="0"]) .deck-card-count,
.deck-card:not([data-pos="0"]) .deck-card-filename {
  opacity: 0;
}
.deck-card:not([data-pos="0"]) .deck-card-status-icon {
  opacity: 0.4;
}

/* Activity hint on the active spinner card — subtle outer glow that pulses */
.deck-card.active[data-pos="0"] {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(66, 133, 244, 0.5),
    0 0 36px rgba(66, 133, 244, 0.25);
  animation: deckActivePulse 2.2s ease-in-out infinite;
}
@keyframes deckActivePulse {
  0%, 100% {
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.35),
      0 0 0 1px rgba(66, 133, 244, 0.5),
      0 0 36px rgba(66, 133, 244, 0.25);
  }
  50% {
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.35),
      0 0 0 1px rgba(66, 133, 244, 0.7),
      0 0 52px rgba(66, 133, 244, 0.45);
  }
}

/* ────────────────────────────────────────
   Done
   ──────────────────────────────────────── */
.done-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; flex: 1; text-align: center;
}
.done-check {
  width: 108px; height: 108px; border-radius: 50%;
  background: var(--success);
  display: flex; align-items: center; justify-content: center;
  color: #06381f; margin-bottom: 12px;
  box-shadow: 0 8px 32px rgba(52, 211, 153, 0.4);
  animation: doneCheckPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.done-check svg { width: 64px; height: 64px; }
@keyframes doneCheckPop {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.done-actions {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; margin-top: 16px;
}

/* ────────────────────────────────────────
   Version footer (visible on home screen)
   ──────────────────────────────────────── */
.version-footer {
  text-align: center;
  font-size: 10px;
  color: var(--text-ghost);
  padding: 4px 0 0;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ────────────────────────────────────────
   DEV-only Sign out
   ──────────────────────────────────────── */
.dev-footer {
  padding: 0.5rem 0 0;
  display: flex; justify-content: center; flex-shrink: 0;
}
.text-link {
  background: transparent; border: none;
  color: var(--text-faint); font: inherit; font-size: 12px;
  padding: 8px 12px; cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--text-ghost);
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
}
.text-link:active { color: var(--text-dim); }
