/* The page scanner overlay (scanner.js). Dark, like a camera app; the page outline turns green as you hold still. */
.scan { position: fixed; inset: 0; z-index: 2147483000; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #0b1620; color: #fff; font-family: var(--tp-font, Inter, system-ui, sans-serif); --steady: 0; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.scan-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 14px; font-size: 14px; }
.scan-top strong { font-weight: 600; text-align: center; }
.scan-top > :first-child { justify-self: start; }
.scan-top > :last-child { justify-self: end; }
.scan-count { color: rgba(255, 255, 255, .7); font-variant-numeric: tabular-nums; }
.scan-btn { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .1); color: #fff; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background .15s ease; }
.scan-btn:hover { background: rgba(255, 255, 255, .18); }
.scan-btn.is-danger:hover { background: #a3322b; }
.scan :focus-visible { outline: 2px solid #7fe3b4; outline-offset: 2px; }

.scan-stage { position: relative; min-height: 0; display: grid; place-items: center; padding: 4px 14px; }
.scan-view { position: relative; width: 100%; height: 100%; min-height: 0; }
.scan-view.is-mirror { transform: scaleX(-1); }
.scan-view video, .scan-view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
.scan-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.scan-quad { fill: rgba(127, 227, 180, calc(.1 + .22 * var(--steady))); stroke: color-mix(in srgb, #fff calc(100% - 100% * var(--steady)), #3ddc97); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: fill .12s linear, stroke .12s linear; }
.scan-overlay.is-edit { pointer-events: auto; touch-action: none; }
.scan-overlay.is-edit .scan-quad { fill: rgba(127, 227, 180, .14); stroke: #3ddc97; }
.scan-handle { fill: #fff; stroke: #3ddc97; stroke-width: 3; vector-effect: non-scaling-stroke; cursor: grab; touch-action: none; }
.scan-handle:active { cursor: grabbing; fill: #3ddc97; }
.scan-hint { position: absolute; left: 50%; bottom: 14px; margin: 0; padding: 9px 16px; max-width: calc(100% - 40px); border-radius: 999px; background: rgba(11, 22, 32, .78); backdrop-filter: blur(8px); font-size: 14px; font-weight: 500; text-align: center; transform: translateX(-50%); }
.scan-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.scan.is-flash .scan-flash { animation: scan-flash .26s ease-out; }
@keyframes scan-flash { 0% { opacity: .85; } 100% { opacity: 0; } }
.scan.is-nocam .scan-view, .scan.is-nocam .scan-shutter, .scan.is-nocam .scan-auto { display: none; }
.scan.is-nocam .scan-hint { position: static; transform: none; max-width: 420px; border-radius: 16px; line-height: 1.5; }

.scan-bar { display: grid; gap: 10px; padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
.scan-tray { display: flex; gap: 8px; min-height: 0; margin: 0; padding: 0; overflow-x: auto; list-style: none; scrollbar-width: none; }
.scan-tray:empty { display: none; }
.scan-tray button { position: relative; display: block; width: 46px; height: 60px; padding: 0; overflow: hidden; border: 2px solid rgba(255, 255, 255, .35); border-radius: 8px; background: #fff; cursor: pointer; }
.scan-tray img { width: 100%; height: 100%; object-fit: cover; }
.scan-tray b { position: absolute; right: 2px; bottom: 2px; min-width: 16px; padding: 0 3px; border-radius: 5px; background: #102b3e; color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; }
.scan-tray li.is-new { animation: scan-drop .42s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes scan-drop { from { opacity: 0; transform: translateY(-34px) scale(1.5); } }
.scan-controls { display: grid; grid-template-columns: 1fr auto auto 1fr; align-items: center; gap: 14px; }
.scan-controls > :first-child { justify-self: start; }
.scan-controls > :last-child { justify-self: end; }
.scan-review .scan-controls { grid-template-columns: repeat(3, auto); justify-content: center; }
.scan-pick { position: relative; overflow: hidden; }
.scan-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.scan-auto { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border: 1.5px solid rgba(255, 255, 255, .3); border-radius: 999px; background: transparent; color: rgba(255, 255, 255, .75); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.scan-auto i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .4); }
.scan-auto.is-on { border-color: #3ddc97; color: #fff; }
.scan-auto.is-on i { background: #3ddc97; box-shadow: 0 0 0 4px rgba(61, 220, 151, .22); }
.scan-shutter { display: grid; place-items: center; width: 64px; height: 64px; padding: 0; border: 3px solid #fff; border-radius: 50%; background: transparent; cursor: pointer; }
.scan-shutter i { width: 50px; height: 50px; border-radius: 50%; background: #fff; transition: transform .12s ease; }
.scan-shutter:active i { transform: scale(.86); }
.scan-done { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 18px; border: 0; border-radius: 13px; background: #3ddc97; color: #06281b; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; transition: opacity .15s ease, transform .12s ease; }
.scan-done:disabled { opacity: .35; cursor: default; }
.scan-done:not(:disabled):active { transform: scale(.97); }

.scan-review { position: absolute; inset: 0; z-index: 2; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #0b1620; }
.scan-review[hidden] { display: none; }
.scan-review.is-busy .scan-view { opacity: .5; }
.scan-review .scan-view img { background: #16242f; }
.scan-modes { display: flex; justify-content: center; gap: 6px; }
.scan-modes button { height: 36px; padding: 0 14px; border: 1.5px solid rgba(255, 255, 255, .25); border-radius: 999px; background: transparent; color: rgba(255, 255, 255, .8); font: inherit; font-size: 13px; cursor: pointer; }
.scan-modes button[aria-checked="true"] { border-color: #fff; background: #fff; color: #0b1620; font-weight: 600; }

@media (max-width: 560px) {
  .scan-top { grid-template-columns: auto 1fr auto; padding: 8px 10px; }
  .scan-top strong { font-size: 13.5px; }
  .scan-btn span { display: none; }
  .scan-review .scan-btn span, .scan-pick span { display: inline; }
  .scan-stage { padding: 2px 8px; }
  .scan-controls { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { .scan *, .scan *::before { animation: none !important; transition: none !important; } }

/* "Scan with your phone" window on the laptop (phone-link.js). */
.plink { position: fixed; inset: 0; z-index: 2147483000; display: grid; place-items: center; padding: 16px; background: rgba(11, 22, 32, .55); backdrop-filter: blur(3px); font-family: var(--tp-font, Inter, system-ui, sans-serif); animation: plink-fade .18s ease-out; }
@keyframes plink-fade { from { opacity: 0; } }
.plink-card { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 22px 24px 20px; border-radius: 22px; background: #fff; color: #111; box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .5); animation: plink-rise .28s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes plink-rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.plink-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plink-card h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.plink-x { width: 34px; height: 34px; border: 0; border-radius: 10px; background: #f2f2f2; font-size: 20px; line-height: 1; cursor: pointer; }
.plink-body { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: 22px; align-items: center; margin-top: 16px; }
.plink-qr { display: grid; place-items: center; aspect-ratio: 1; padding: 6px; border: 2px solid #eee; border-radius: 16px; background: #fff; }
.plink-qr svg { display: block; width: 100%; height: 100%; }
.plink-spin { width: 26px; height: 26px; border: 3px solid #e3e3e3; border-top-color: #102b3e; border-radius: 50%; animation: plink-spin .8s linear infinite; }
@keyframes plink-spin { to { transform: rotate(360deg); } }
.plink-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; font-size: 14.5px; line-height: 1.45; }
.plink-steps li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; counter-increment: step; }
.plink-steps li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #102b3e; color: #fff; font-size: 12.5px; font-weight: 600; }
.plink-status { display: flex; align-items: center; gap: 9px; margin: 18px 0 0; padding: 10px 14px; border-radius: 12px; background: #f5f6f6; font-size: 13.5px; }
.plink-status i { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #c9a227; animation: plink-pulse 1.2s ease-in-out infinite; }
.plink-status[data-s="linked"] { background: #e9f8f0; }
.plink-status[data-s="linked"] i { background: #1c9c63; animation: none; }
.plink-status[data-s="error"] i, .plink-status[data-s="lost"] i { background: #c0392b; animation: none; }
@keyframes plink-pulse { 50% { opacity: .3; } }
.plink-pages { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.plink-pages:empty { display: none; }
.plink-pages li { position: relative; width: 56px; height: 74px; overflow: hidden; border: 2px solid #e6e6e6; border-radius: 8px; animation: scan-drop .42s cubic-bezier(.2, 1.4, .4, 1); }
.plink-pages img { width: 100%; height: 100%; object-fit: cover; }
.plink-pages b { position: absolute; right: 3px; bottom: 3px; min-width: 16px; padding: 0 3px; border-radius: 5px; background: #102b3e; color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.plink-card footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; font-size: 12.5px; line-height: 1.45; color: #737373; }
.plink-done { flex: none; height: 42px; padding: 0 20px; border: 0; border-radius: 12px; background: #111; color: #fff; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; }
@media (max-width: 520px) { .plink-body { grid-template-columns: 1fr; justify-items: center; } .plink-qr { width: 200px; } .plink-card footer { flex-direction: column; align-items: stretch; } }

/* The guide (where to hold the page), the hold ring round the button, and pages whose edges are still being found. */
.scan-guide { fill: none; stroke: color-mix(in srgb, rgba(255, 255, 255, .6) calc(100% - 100% * var(--steady)), #3ddc97); stroke-width: 2; stroke-dasharray: 10 9; vector-effect: non-scaling-stroke; transition: opacity .2s ease; }
.scan.has-page .scan-guide { opacity: 0; }
.scan.has-page .scan-quad { fill: rgba(61, 220, 151, .16); stroke: #3ddc97; }
.scan.is-holding .scan-guide { stroke-dasharray: none; stroke-width: 3; }
.scan-shutter { position: relative; }
.scan-shutter::before { content: ''; position: absolute; inset: -10px; border-radius: 50%; background: conic-gradient(#3ddc97 calc(var(--steady) * 1turn), transparent 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); pointer-events: none; }
.scan.is-manual .scan-auto { visibility: hidden; }
.scan.is-working .scan-controls { opacity: .5; pointer-events: none; }
.scan-tray li.is-pending button::after { content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border: 2.5px solid rgba(16, 43, 62, .25); border-top-color: #102b3e; border-radius: 50%; animation: scan-spin .7s linear infinite; }
.scan-tray li.is-pending img { opacity: .45; }
@keyframes scan-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .scan-tray li.is-pending button::after { animation-duration: 2.4s; } }
