:root {
  --bg: #0a0a0c;
  --bg-elevated: #141418;
  --bg-card: #1c1c22;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #818cf8;
  --accent-strong: #6366f1;
  --danger: #f87171;
  --danger-bg: #3f1515;
  --radius: 16px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --top-bar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.hidden { display: none !important; }

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--top-bar-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.top-bar-actions {
  display: flex;
  gap: 10px;
}

.unlock-links {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.unlock-links a {
  color: var(--text-muted, #9a9aa8);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-icon:active { transform: scale(0.94); background: #222228; }

.btn-text {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 8px;
}
.btn-text.accent { color: var(--accent); }
.btn-text.danger { color: var(--danger); }
.btn-text:active { opacity: 0.7; }

.btn-primary {
  border: none;
  background: var(--accent-strong);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 560;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.btn-secondary:active { background: #222228; }
.btn-secondary.danger-outline { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }

.btn-danger {
  border: none;
  background: var(--danger);
  color: #1a0505;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
}

.file-btn { display: inline-flex; align-items: center; }

/* Paste: never show iOS text callout / selection on the control itself */
.btn-paste,
#btn-paste,
#btn-attach-paste {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Stack / Apple Wallet-style deck */
.stack-view {
  padding: 8px 16px calc(24px + var(--safe-bottom));
  min-height: calc(100dvh - var(--top-bar-h) - var(--safe-top));
  display: flex;
  flex-direction: column;
}

.empty-state {
  text-align: center;
  padding: 64px 20px 40px;
  color: var(--text-muted);
}
.empty-state .empty-icon { color: #52525b; margin-bottom: 20px; }
.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1.35rem;
}
.empty-state p {
  margin: 0 0 28px;
  line-height: 1.45;
  font-size: 0.95rem;
}

.deck-hint {
  margin: 0 0 10px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-stack {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  flex: 1;
  min-height: 480px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: visible;
}

.pass-card {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 18px;
  background: #1a1a22;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow:
    0 12px 28px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.05) inset;
  cursor: grab;
  transform-origin: center top;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
              height 0.38s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.38s;
  will-change: transform, height;
  /* collapsed = title strip; expanded/under = full pass */
  height: 64px;
}
.pass-card.is-dragging { transition: none !important; cursor: grabbing; }
.pass-card.is-lifting {
  transition: none !important;
  cursor: grabbing;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--coin-accent, #818cf8) 70%, transparent),
    0 28px 56px rgba(0,0,0,0.65);
  touch-action: none;
}

.pass-card.is-front,
.pass-card.is-under {
  height: auto;
  min-height: 420px;
}
.pass-card.is-front {
  box-shadow:
    0 0 0 1.5px color-mix(in srgb, var(--coin-accent, #818cf8) 60%, transparent),
    0 20px 44px rgba(0,0,0,0.6);
}

.pass-card-peek {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 64px;
  height: 64px;
  box-sizing: border-box;
  background: linear-gradient(145deg, #2c2c38 0%, #17171e 100%);
  border-top: 4px solid var(--coin-accent, #6366f1);
}
.pass-card-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #0e0e12;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
/* Thumbnail with optional "stack" look + count badge for multi-image coins */
.pass-card-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  isolation: isolate;
}
.pass-card-thumb-wrap .pass-card-thumb {
  position: relative;
  z-index: 1;
}
.pass-card-thumb-wrap.is-stack::before,
.pass-card-thumb-wrap.is-stack::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #2b2b36;
  z-index: -1;
}
.pass-card-thumb-wrap.is-stack::before { transform: translate(3px, -3px); }
.pass-card-thumb-wrap.is-stack::after { transform: translate(6px, -6px); opacity: 0.6; z-index: -2; }
.pass-card-count {
  position: absolute;
  right: -9px;
  top: -8px; /* top corner stays visible when the next coin overlaps this row */
  z-index: 2;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: var(--coin-accent, #6366f1);
  border: 2px solid #1d1d26;
  font-variant-numeric: tabular-nums;
}
.pass-card-thumb.placeholder {
  display: grid;
  place-items: center;
  color: #52525b;
}
.pass-card-meta { flex: 1; min-width: 0; }
.pass-card-trash {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-right: -6px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
.pass-card-trash:hover { color: var(--danger); }
.pass-card-trash:active {
  color: var(--danger);
  background: var(--danger-bg);
  transform: scale(0.94);
}
.pass-card-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pass-card-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pass-card-body {
  display: none;
  padding: 0 14px 16px;
  background: #121218;
}
.pass-card.is-front .pass-card-body,
.pass-card.is-under .pass-card-body {
  display: block;
}
.pass-card-body img {
  width: 100%;
  max-height: 48vh;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
  display: block;
}
.pass-card-open-hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

/* Front-card preview: stacked edges peek out under the picture */
.pass-card-frame {
  position: relative;
  isolation: isolate;
}
.pass-card-frame.is-stack { margin-bottom: 9px; }
.pass-card-frame.is-stack-deep { margin-bottom: 17px; }
.pass-card-frame.is-stack::before,
.pass-card-frame.is-stack-deep::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  bottom: -9px;
  border-radius: 12px;
  background: #3a3a48;
  border: 1px solid rgba(255, 255, 255, 0.18);
  z-index: -1;
}
.pass-card-frame.is-stack-deep::after {
  left: 26px;
  right: 26px;
  bottom: -17px;
  background: #2c2c38;
  z-index: -2;
}
.pass-card-dots {
  display: inline-flex;
  gap: 4px;
  margin-right: 7px;
  vertical-align: middle;
}
.pass-card-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}
.pass-card-dot.is-active { background: var(--coin-accent, var(--accent)); }
.pass-card-count-label { color: var(--text); }


/* Viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: #000;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  left: 0;
  right: 0;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 8px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
}

.viewer-actions { display: flex; align-items: center; gap: 4px; }

/* Share sits in the top bar, never over the picture; see-through like Edit/Delete */
.btn-share {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}
.btn-share:active { background: rgba(255, 255, 255, 0.18); }
.btn-share.hidden { display: none; }

.viewer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(56px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  overflow: auto;
}

.viewer-image-wrap {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  position: relative;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.viewer-image-wrap.is-panning { cursor: grabbing; }

#viewer-image,
.viewer-image-peer {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: #111;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}
.viewer-image-peer {
  /* same box as main — no intrinsic-size snap while sliding */
}
.viewer-image-peer.hidden {
  display: none;
}
.viewer-image-wrap.is-sliding #viewer-image,
.viewer-image-wrap.is-sliding .viewer-image-peer {
  /* GPU slide; zoom transforms paused while sliding */
}
.viewer-zoom-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 2;
}
.viewer-zoom-hint.hidden { opacity: 0; }

.viewer-no-image {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 40px;
  margin: 0;
}
.viewer-no-image.hidden { display: none; }

.viewer-meta {
  width: 100%;
  flex: 0 0 auto;
  max-height: 28vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 8px;
  pointer-events: none;
}
.viewer-title {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
}
.viewer-notes {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  white-space: pre-wrap;
  max-width: none;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
}

/* Editor sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  max-width: 480px;
  margin: 0 auto;
  left: 0;
  right: 0;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: relative;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  max-height: min(92dvh, 900px);
  overflow: auto;
  padding-bottom: var(--safe-bottom);
  border: 1px solid var(--border);
  border-bottom: none;
  animation: slideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
.sheet-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.editor-form {
  padding: 16px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field > span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field > span em { color: var(--danger); font-style: normal; }

.field input[type="text"],
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.accent-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.accent-swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.accent-swatch.is-selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--swatch), 0 0 0 4px rgba(255,255,255,0.2);
  transform: scale(1.08);
}
.accent-swatch:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.image-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-preview-wrap {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.image-preview-stage {
  position: relative;
  width: 100%;
  height: 220px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.image-preview-stage.is-sliding {
  cursor: grabbing;
}
#image-preview,
.image-preview-peer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
  background: #0a0a0c;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}
.image-preview-peer.hidden {
  display: none;
}

/* Editor multi-image strip (primary + attachments) */
.editor-thumbs {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  padding: 4px 0 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.editor-thumbs::-webkit-scrollbar { display: none; }
.editor-thumbs.hidden { display: none; }
.editor-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  cursor: pointer;
}
.editor-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.editor-thumb.is-primary {
  /* Main badge marks primary; selection uses is-active */
}
.editor-thumb.is-active {
  border-color: var(--accent, #6c8cff);
  box-shadow: 0 0 0 1px var(--accent, #6c8cff);
}
.editor-thumb-badge {
  position: absolute;
  left: 3px;
  bottom: 3px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0,0,0,0.65);
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: none;
}
.editor-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.editor-thumb-x:active { transform: scale(0.92); background: #b91c1c; }
.editor-thumb-plus {
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated, #1a1a1f);
  border-style: dashed;
}
.editor-thumb-plus:disabled,
.editor-thumb-plus.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint {
  margin: 0;
  font-size: 0.78rem;
  color: #71717a;
  line-height: 1.4;
}

/* Confirm */
.confirm {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  padding: 24px;
  max-width: 480px;
  margin: 0 auto;
  left: 0;
  right: 0;
}
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.confirm-panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 20px;
  width: min(100%, 340px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.confirm-panel h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}
.confirm-panel p {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 700;
  background: #27272a;
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 560;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 481px) {
  #app, .viewer, .sheet, .confirm {
    box-shadow: 0 0 0 1px var(--border);
  }
}






/* Viewer multi-image thumbs — bottom overlay (portrait + landscape) */
.viewer-thumbs {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  position: absolute;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  transform: translateX(-50%);
  width: auto;
  max-width: min(92vw, 520px);
  padding: 6px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 14px;
  z-index: 3;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.viewer-thumbs::-webkit-scrollbar { display: none; }
.viewer-thumbs.hidden { display: none; }

.viewer-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #111;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.viewer-thumb.is-active {
  border-color: #818cf8;
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.45);
}
.viewer-thumb-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a20;
  border-style: dashed;
  border-color: rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.7);
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1;
}
.viewer-thumb-plus:disabled,
.viewer-thumb-plus.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.viewer-attach-bar {
  display: flex;
  justify-content: center;
  position: absolute;
  left: 50%;
  bottom: calc(72px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 3;
  padding: 2px 10px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.4);
  border-radius: 999px;
}
.viewer-attach-bar.hidden { display: none; }

.attach-panel .attach-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attach-panel .attach-actions .btn-secondary,
.attach-panel .attach-actions .btn-danger,
.attach-panel .attach-actions .file-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}
.attach-panel .attach-actions .btn-text {
  margin-top: 4px;
  align-self: center;
}

/* Landscape: open coin fills screen height; width stays proportional */
@media (orientation: landscape) {
  .viewer {
    max-width: none;
    width: 100%;
    height: 100dvh;
  }

  .viewer-body {
    position: relative;
    flex: 1;
    min-height: 0;
    height: 100%;
    padding: 0;
    overflow: hidden;
  }

  .viewer-image-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: none;
  }

  #viewer-image,
  .viewer-image-peer {
    width: 100%;
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
  }

  /* Keep chrome out of the way so the photo can use the full height */
  .viewer-title,
  .viewer-notes,
  .viewer-zoom-hint {
    display: none;
  }

  .viewer-bar {
    background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
  }
  .viewer-thumbs {
    position: absolute;
    left: 50%;
    bottom: calc(10px + var(--safe-bottom));
    transform: translateX(-50%);
    width: auto;
    max-width: min(92vw, 520px);
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 14px;
    z-index: 3;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .viewer-thumbs.hidden { display: none; }
  .viewer-attach-bar {
    position: absolute;
    left: 50%;
    bottom: calc(72px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 3;
    padding: 2px 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 999px;
  }
  .viewer-thumb {
    width: 44px;
    height: 44px;
  }

}

/* Image preview + crop */
.image-preview-wrap {
  margin-top: 10px;
}
.image-preview-stage {
  border-radius: 12px;
  height: 220px;
}
#image-preview,
.image-preview-peer {
  border-radius: 12px;
}
.image-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cropper-tools {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px 0;
}
.cropper-tools .btn-secondary {
  min-width: 88px;
  background: #1c1c22;
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}

.cropper {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #000;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}
.cropper.hidden { display: none; }
.cropper-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}
.cropper-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  background: #000;
}
.cropper-stage img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.cropper-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  /* hole punched via clip-path in JS */
  background: rgba(0, 0, 0, 0.55);
}
.cropper-box {
  position: absolute;
  z-index: 3;
  box-sizing: border-box;
  border: 2px solid rgba(165, 180, 252, 0.95);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  touch-action: none;
  cursor: move;
}
.cropper-edge {
  position: absolute;
  z-index: 4;
  background: transparent;
}
.cropper-edge.edge-n,
.cropper-edge.edge-s {
  left: 12px;
  right: 12px;
  height: 28px;
  cursor: ns-resize;
}
.cropper-edge.edge-n { top: -14px; }
.cropper-edge.edge-s { bottom: -14px; }
.cropper-edge.edge-e,
.cropper-edge.edge-w {
  top: 12px;
  bottom: 12px;
  width: 28px;
  cursor: ew-resize;
}
.cropper-edge.edge-e { right: -14px; }
.cropper-edge.edge-w { left: -14px; }
.cropper-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: #a5b4fc;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  z-index: 5;
  touch-action: none;
}
.cropper-handle.handle-nw { left: 0; top: 0; cursor: nwse-resize; }
.cropper-handle.handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
.cropper-handle.handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
.cropper-handle.handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
.cropper-tools {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px 0;
}
.cropper-tools .btn-secondary {
  min-width: 88px;
  background: #1c1c22;
  color: #fff;
  border-color: rgba(255,255,255,0.18);
}
.cropper-hint {
  margin: 0;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  text-align: center;
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
}

/* Wallet stack polish — match Apple-like peeks above front */
.pass-card {
  box-shadow:
    0 0 0 1px rgba(129, 140, 248, 0.18),
    0 12px 28px rgba(0,0,0,0.55) !important;
}
.pass-card.is-peek {
  height: 64px !important;
  min-height: 64px !important;
}
.pass-card.is-peek .pass-card-body {
  display: none !important;
}


/* While viewer/editor is open, keep the wallet deck out of the paint path */
body.mode-overlay #stack-view,
body.mode-overlay #home-header {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}


/* One-time device unlock */
.unlock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0a0a0c;
}
.unlock-screen.hidden { display: none; }
.unlock-card {
  width: min(100%, 360px);
  background: #16161c;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 28px 22px 24px;
  text-align: center;
}
.unlock-card h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}
.unlock-card > p {
  margin: 0 0 20px;
  color: #a1a1aa;
  font-size: 0.95rem;
  line-height: 1.4;
}
#unlock-form {
  display: grid;
  gap: 12px;
}
#unlock-pin {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0e0e12;
  color: #fff;
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 14px 12px;
}
#unlock-pin:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.7);
}
.unlock-error {
  margin: 12px 0 0;
  color: #fb7185;
  font-size: 0.9rem;
}
.unlock-error.hidden { display: none; }

body.is-locked #home-header,
body.is-locked #stack-view,
body.is-locked #viewer,
body.is-locked #editor,
body.is-locked #confirm {
  visibility: hidden;
  pointer-events: none;
}

#unlock-email {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0e0e12;
  color: #fff;
  font-size: 1.05rem;
  text-align: center;
  padding: 14px 12px;
}
#unlock-code {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0e0e12;
  color: #fff;
  font-size: 1.25rem;
  letter-spacing: 0.25em;
  text-align: center;
  padding: 14px 12px;
}
#unlock-email:focus,
#unlock-code:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.7);
}
#email-form, #code-form, #pin-form { display: grid; gap: 12px; }
#email-form.hidden, #code-form.hidden, #pin-form.hidden { display: none; }

/* iPhone Safari zooms into any text box under 16px and leaves the page
   zoomed (wider than the screen). Keep every input at 16px or more. */
input, textarea, select {
  font-size: max(16px, 1em);
}
.unlock-status {
  margin: 14px 0 0;
  color: #a1a1aa;
  font-size: 0.95rem;
  line-height: 1.4;
}
.unlock-status.hidden { display: none; }
#btn-auth-reset {
  margin-top: 16px;
}


