@layer views {
  /* ── scanner: a full-viewport dialog, always dark regardless of site theme, so
     colors here are hardcoded rather than pulled from tokens.css ── */
  dialog.scanner {
    position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none;
    margin: 0; padding: 0; border: 0; overflow: hidden; background: #000; color: #fff;
  }
  dialog.scanner::backdrop { background: #000; }

  dialog.scanner .scanner-video {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000;
  }
  dialog.scanner .scanner-error {
    position: absolute; inset: 0; z-index: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; text-align: center; padding: 32px;
  }
  dialog.scanner .scanner-error-msg { font-size: 15px; line-height: 1.5; max-width: 40ch; color: rgb(255 255 255 / .92); margin: 0 0 14px; }
  dialog.scanner .scanner-error .pill { background: #fff; color: #000; }

  dialog.scanner .scanner-flash {
    position: absolute; inset: 0; z-index: 3; background: #fff; opacity: 0; pointer-events: none;
  }
  dialog.scanner .scanner-flash.active { animation: scanner-flash-pop 160ms ease-out; }
  @keyframes scanner-flash-pop { from { opacity: .85; } to { opacity: 0; } }
  @media (prefers-reduced-motion: reduce) {
    dialog.scanner .scanner-flash.active { animation: none; }
  }

  dialog.scanner .scanner-top {
    position: absolute; inset: 0 0 auto 0; z-index: 2; display: flex; align-items: center; gap: 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 28px calc(12px + env(safe-area-inset-left, 0px));
    background: linear-gradient(to bottom, rgb(0 0 0 / .55), transparent);
  }
  dialog.scanner .scanner-title { flex: 1; text-align: center; font-size: 13.5px; font-weight: 700; color: rgb(255 255 255 / .82); }
  dialog.scanner .scanner-close,
  dialog.scanner .scanner-flip {
    flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0;
    display: grid; place-items: center; background: rgb(255 255 255 / .14); color: #fff;
    font-size: 21px; line-height: 1; transition: background 180ms;
  }
  dialog.scanner .scanner-close:hover,
  dialog.scanner .scanner-flip:hover { background: rgb(255 255 255 / .24); }
  dialog.scanner .scanner-flip svg { width: 18px; height: 18px; }

  dialog.scanner .scanner-bar {
    position: absolute; inset: auto 0 0 0; z-index: 2;
    display: grid; gap: 10px; justify-items: center;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgb(0 0 0 / .7), transparent);
  }

  dialog.scanner .scanner-strip {
    display: flex; gap: 8px; width: 100%; max-width: 640px; min-height: 68px;
    overflow-x: auto; padding: 2px;
  }
  dialog.scanner .scanner-thumb {
    position: relative; flex: none; width: 52px; height: 68px; border-radius: 8px; overflow: hidden;
    border: 1.5px solid rgb(255 255 255 / .35);
  }
  dialog.scanner .scanner-thumb img { width: 100%; height: 100%; object-fit: cover; }
  dialog.scanner .thumb-num {
    position: absolute; left: 3px; bottom: 3px; font-size: 10px; font-weight: 700; line-height: 1.4;
    color: #fff; background: rgb(0 0 0 / .6); border-radius: 5px; padding: 0 5px;
  }
  dialog.scanner .thumb-remove {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0;
    display: grid; place-items: center; background: rgb(0 0 0 / .6); color: #fff; font-size: 13px; line-height: 1;
  }
  dialog.scanner .thumb-remove:hover { background: rgb(0 0 0 / .82); }

  dialog.scanner .scanner-controls {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
    width: 100%; max-width: 640px;
  }
  dialog.scanner .scanner-shutter {
    justify-self: center; position: relative; flex: none; width: 68px; height: 68px;
    border-radius: 50%; border: 3px solid #fff; background: rgb(255 255 255 / .16);
    transition: background 180ms;
  }
  dialog.scanner .scanner-shutter::before {
    content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff;
    transition: inset 120ms;
  }
  dialog.scanner .scanner-shutter:hover { background: rgb(255 255 255 / .28); }
  dialog.scanner .scanner-shutter:active::before { inset: 11px; }
  dialog.scanner .scanner-done { justify-self: end; background: #fff; color: #000; }
  dialog.scanner .scanner-done:hover:not(:disabled) { background: rgb(255 255 255 / .85); }

  /* ── generic drop-target highlight: set by dropZone() in core/upload.js ── */
  [data-drag="1"] {
    outline: 1.5px dashed var(--grad-b);
    outline-offset: -1.5px;
    background: color-mix(in oklch, var(--grad-b) 8%, transparent);
    transition: background var(--t-fast), outline-color var(--t-fast);
  }

  /* ── upload progress: same shape as .meter, just thinner and faster to react ── */
  .upload-progress { position: relative; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
  .upload-progress > i {
    position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--known);
    width: var(--v, 0%); transition: width var(--t-fast) var(--ease-liquid);
  }
}
