/* Colors come from the approved mockup. Everything is sized for one hand over a box of books. */
:root {
  --surface-1: #f6f5f1; --surface-2: #ffffff; --border: #e3e1da; --border-strong: #cfcdc4; --border-stronger: #9c9a92;
  --text-primary: #1f1e1c; --text-secondary: #6b6a65; --bg-accent: #e6f1fb; --text-accent: #0c447c; --border-accent: #85b7eb;
  --bg-warning: #faeeda; --text-warning: #633806; --border-warning: #ef9f27; --text-success: #3b6d11; --text-danger: #b3261e;
  --primary: #0c447c; --radius: 12px; --tap: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--surface-1); color: var(--text-primary); font: 17px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; }
#app { min-height: 100dvh; max-width: 520px; margin: 0 auto; background: var(--surface-2); display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.header { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; }
.heading { font-size: 20px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.subheading { font-size: 15px; color: var(--text-secondary); margin: 2px 0 0; }
.section-title { font-size: 17px; margin: 18px 0 6px; }
.label { font-size: 14px; color: var(--text-secondary); margin: 0 0 6px; display: block; }
.note { font-size: 14px; color: var(--text-secondary); margin: 0; }
.error { font-size: 15px; color: var(--text-danger); margin: 0; font-weight: 500; }
.grow { flex: 1; }

button { font: inherit; color: inherit; cursor: pointer; }
.button { width: 100%; min-height: var(--tap); padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-2); font-weight: 500; }
.button:active { background: var(--surface-1); }
.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); font-size: 18px; font-weight: 600; }
.button.primary:active { background: #08335e; }
.button:disabled { opacity: .55; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row.bottom { align-items: flex-end; }
.link-button { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text-accent); text-decoration: none; }
.price-source { margin-top: -10px; color: var(--text-success); font-weight: 500; }
.price-source:empty { display: none; }
.link { background: none; border: none; color: var(--text-accent); font-weight: 500; min-height: 44px; padding: 8px 4px; text-align: left; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 46px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-secondary); font-size: 16px; }
.chip.on { background: var(--bg-accent); color: var(--text-accent); border-color: var(--border-accent); font-weight: 600; }
.location { min-height: 44px; flex: none; }

.field { width: 100%; min-height: var(--tap); padding: 12px; font: inherit; font-size: 17px; color: inherit; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); }
textarea.field { resize: vertical; min-height: 84px; }
.field:focus, .button:focus-visible, .chip:focus-visible, .link:focus-visible, .tile:focus-visible, .toggle:focus-visible { outline: 3px solid var(--border-accent); outline-offset: 1px; }
.field:disabled { background: var(--surface-1); color: var(--text-secondary); }
.rebuild { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rebuild .note { flex: 1; }
.whatnot-section { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.whatnot-fields { display: flex; flex-direction: column; gap: 8px; }
.button.danger { color: var(--text-warning); border-color: var(--border-warning); background: transparent; }
.note.warn { color: var(--text-warning); font-weight: 500; }
.count { font-size: 13px; color: var(--text-secondary); text-align: right; margin-top: 4px; }
.count.over { color: var(--text-danger); font-weight: 600; }

.viewfinder { position: relative; flex: 1; min-height: 300px; border-radius: var(--radius); border: 2px dashed var(--border-stronger); overflow: hidden; background: #111; display: flex; align-items: center; justify-content: center; }
.viewfinder.off { background: var(--surface-1); }
.camera { position: absolute; inset: 0; }
.camera video { width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
.scanline { position: absolute; left: 12%; right: 12%; top: 50%; height: 3px; background: #e24b4a; z-index: 2; pointer-events: none; box-shadow: 0 0 6px rgba(226, 75, 74, .8); }
.hint { position: absolute; left: 0; right: 0; bottom: 10px; z-index: 2; text-align: center; margin: 0; color: #fff; font-size: 15px; text-shadow: 0 1px 3px #000; pointer-events: none; }
.viewfinder.off .hint { position: static; color: var(--text-secondary); text-shadow: none; padding: 16px; pointer-events: auto; }
.status { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 3; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-accent); color: var(--text-accent); font-size: 15px; font-weight: 500; }
.status.bad { background: var(--bg-warning); color: var(--text-warning); }

.box { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.box .summary { flex: 1; text-align: left; min-height: 48px; padding: 6px 0; background: none; border: none; color: var(--text-secondary); font-size: 15px; }
.box .summary.has { color: var(--text-accent); font-weight: 500; text-decoration: underline; }

.tiles { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: stretch; }
.match { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius); background: var(--bg-warning); border: 1px solid var(--border-warning); }
.match strong { overflow-wrap: anywhere; }
.match-kind { font-size: 13px; font-weight: 600; color: var(--text-accent); }
.my-books { font-size: 17px; }
.collectible { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.collectible .detail { margin-top: 8px; }
.link-button.ebay { color: #fff; }
.match .note { color: var(--text-warning); }
.match-question { margin: 0; font-weight: 600; color: var(--text-warning); }
.tile-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-wrap .tile { flex: 1; width: 100%; }
.photo-status { position: relative; font-size: 13px; font-weight: 500; background: rgba(255, 255, 255, .92); color: var(--text-accent); border-radius: 8px; padding: 2px 8px; margin-top: 4px; }
.photo-status.bad { color: var(--text-warning); }
.photo-status.required { color: var(--text-warning); font-weight: 600; }
.tiles-heading { grid-column: 1 / -1; margin: 10px 0 0; }
.photo-switch { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 14px; color: var(--text-secondary); min-height: 44px; }
.toggle.small { min-width: 60px; min-height: 40px; font-size: 14px; }
.tile { position: relative; min-height: 130px; border-radius: var(--radius); border: 2px dashed var(--border-strong); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; overflow: hidden; padding: 8px; }
.tile.has { border: 1px solid var(--border); background: #111; justify-content: flex-end; min-height: 230px; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; } /* the whole photo, to judge the edges */
.tile .caption { position: relative; font-size: 15px; font-weight: 500; }
.tile.has .caption { background: rgba(255, 255, 255, .92); border-radius: 8px; padding: 2px 8px; color: var(--text-success); }
.tile .icon { position: relative; font-size: 26px; line-height: 1; color: var(--text-secondary); }
input[type="file"] { display: none; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.toggle { min-width: 84px; min-height: 46px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-secondary); font-weight: 600; }
.toggle.on { background: var(--bg-accent); color: var(--text-accent); border-color: var(--border-accent); }

.warning { padding: 12px; border-radius: var(--radius); background: var(--bg-warning); color: var(--text-warning); border: 1px solid var(--border-warning); display: flex; flex-direction: column; gap: 10px; }
.warning p { margin: 0; font-weight: 500; }
.warning .button { background: #fff; border-color: var(--border-warning); }
.notice { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-accent); color: var(--text-accent); font-size: 15px; margin: 0; }
.review-actions { position: sticky; bottom: 0; background: var(--surface-2); padding: 8px 0 calc(4px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }

.list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.list-item { display: flex; gap: 8px; align-items: stretch; }
.result { flex: 1; min-width: 0; min-height: 64px; padding: 10px 12px; text-align: left; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-2); }
.result:active { background: var(--surface-1); }
.result strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.result span { font-size: 14px; color: var(--text-secondary); overflow-wrap: anywhere; }
.remove { flex: none; width: 86px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-danger); font-size: 15px; }

.done.compact { flex: none; padding-top: 8px; gap: 8px; }
.session-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.session-count { font-size: 18px; margin: 0; }
.session-book { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.session-book.copy { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--surface-1); }
.session-book strong { overflow-wrap: anywhere; }
.copy-tag { font-weight: 600; color: var(--text-success); }
.todo-item { display: flex; flex-direction: column; gap: 6px; padding: 12px; text-align: left; border: 1px solid var(--border-warning); border-radius: var(--radius); background: var(--bg-warning); }
.todo-item.done { background: transparent; border-color: var(--border); opacity: .8; }
.todo-instruction { margin: 0; font-weight: 600; }
.session-thumbs { display: flex; gap: 8px; overflow-x: auto; }
.thumb { flex: none; width: 76px; height: 76px; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: #111; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.session-open { display: flex; flex-direction: column; gap: 2px; text-align: left; background: none; border: none; padding: 4px 0; min-height: 48px; }
.session-open span { font-size: 14px; color: var(--text-secondary); }
.session-open .session-fix { color: var(--text-accent); font-weight: 500; }

.viewer { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: flex; flex-direction: column; padding: calc(8px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom)); }
.viewer-top { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.viewer-count { font-size: 15px; }
.viewer-close { min-width: 52px; min-height: 48px; font-size: 22px; color: #fff; background: rgba(255, 255, 255, .12); border: none; border-radius: 12px; }
.viewer-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; touch-action: pan-y; }
.viewer-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; font-size: 34px; color: #fff; background: rgba(255, 255, 255, .14); border: none; border-radius: 12px; }
.viewer-arrow.left { left: 0; }
.viewer-arrow.right { right: 0; }
.viewer-arrow[hidden] { display: none; }
.viewer-status { margin: 6px 0 0; text-align: center; font-size: 14px; color: #f3d9a4; min-height: 0; }
.viewer-status:empty { display: none; }
.viewer-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; }
.viewer-switch { color: #ddd; flex: 1; }
.viewer-retake { width: auto; flex: none; padding: 10px 18px; background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .3); }
.done { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.done .check { width: 64px; height: 64px; border-radius: 50%; background: #eaf3de; color: var(--text-success); font-size: 34px; line-height: 64px; }
.sku { font: 18px ui-monospace, Consolas, monospace; padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius); }

/* Box list and Publish all */
.box-book { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.box-book.published { background: var(--surface-1); }
.box-top { display: flex; gap: 12px; align-items: flex-start; }
.box-top .session-open { flex: 1; min-width: 0; }
.thumb.empty { color: #ccc; font-size: 13px; }
.box-status { font-weight: 600; }
.box-status.ready, .box-status.published, .box-status.on_whatnot { color: var(--text-success) !important; }
.box-status.not_ready, .box-status.not_listing { color: var(--text-warning) !important; }
.box-error { color: var(--text-danger) !important; }
.box-edit { display: flex; flex-direction: column; gap: 8px; }
.field.small { min-height: 44px; padding: 8px 10px; font-size: 16px; }
.button.small { min-height: 44px; padding: 8px 10px; font-size: 15px; }
.box-price { margin-top: 0; }
.tick-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.tick-row input { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.tick-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.list.skipped { gap: 4px; }
.batch-book { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.batch-book > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.batch-icon { flex: none; width: 24px; font-weight: 700; text-align: center; }
.batch-book.published .batch-icon { color: var(--text-success); }
.batch-book.failed .batch-icon { color: var(--text-danger); }
.box-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--bg-accent); color: var(--text-accent); font-weight: 600; }
.toggle.wide { min-width: 140px; }
.link.danger-link { color: var(--text-danger); }
.box-banner.off { background: var(--surface-1); color: var(--text-secondary); font-weight: 500; }
.torch { position: absolute; right: 10px; bottom: 44px; z-index: 3; min-height: 48px; padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .5); background: rgba(0, 0, 0, .45); color: #fff; font-size: 16px; }
.torch.on { background: #f7d774; color: #1f1e1c; }
.scan-help { position: absolute; left: 10px; right: 10px; bottom: 100px; z-index: 4; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .96); display: flex; flex-direction: column; gap: 8px; }
.scan-help p { margin: 0; font-size: 15px; }
.box-fields { display: flex; flex-direction: column; gap: 8px; }
.box-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.box-field .label { margin: 0; }
.box-edit .row { align-items: flex-end; }
.suggest { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--bg-accent); }
textarea.field.small { min-height: 110px; font-size: 15px; line-height: 1.35; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack .label { margin: 8px 0 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: 16px; }
.check input { width: 22px; height: 22px; }
.button.finish { font-size: 18px; min-height: 56px; }
.row-extra { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
