:root {
  --bg: #0c0c0e;
  --panel: #17171b;
  --line: #2a2a31;
  --text: #f2f2f4;
  --muted: #a3a3ad;
  --sale: #3ecf8e;
  --trade: #5aa9ff;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.bar {
  position: sticky; top: 0; z-index: 30; /* above the pager, the + button, and the 3D view */
  background: rgba(12, 12, 14, 0.92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(14px, env(safe-area-inset-left));
  transition: transform 180ms ease;
}
.bar.bar-hidden { transform: translateY(-110%); }
.bar-row { display: flex; align-items: center; gap: 4px; min-height: 48px; }
.bar-title {
  flex: 1; min-width: 0; margin: 0; font-size: 1.05rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.search-box input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px;
}
.icon-btn, .view-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; border: 0;
  background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-btn:active, .view-btn:active { background: var(--panel); }
.icon-btn svg, .view-btn svg, .popover svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.view-btn {
  background: var(--panel); border: 1px solid var(--line); padding: 0 8px 0 12px; font-weight: 600;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.view-btn .chev { width: 16px; height: 16px; opacity: 0.7; }
.badge-dot {
  position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%;
  background: #fbbf24; box-shadow: 0 0 0 2px var(--bg);
}

.popover {
  position: absolute; right: 10px; top: calc(100% + 6px); z-index: 31;
  /* Long menus scroll inside themselves; the page behind never moves. */
  max-height: calc(100vh - 80px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  max-height: calc(100dvh - 80px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); padding: 8px;
}
.view-menu { min-width: 200px; display: grid; }
.view-menu button {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer;
}
.view-menu button[aria-checked="true"] { background: var(--text); color: var(--bg); }
.view-menu button:disabled { opacity: 0.45; cursor: default; }
.view-menu small { margin-left: auto; font-size: 0.72rem; color: var(--muted); }
.menu-panel { width: min(320px, calc(100vw - 20px)); display: grid; gap: 0; padding: 6px 14px; }
.summary { margin: 0; color: var(--muted); font-size: 0.85rem; }
.menu-label { margin: 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.menu-item {
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent;
  text-align: left; padding: 0 12px; cursor: pointer;
}
.chip, .text-btn, .pager button, .insp-nav button {
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
:focus-visible { outline: 3px solid var(--trade); outline-offset: 2px; }

main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: 6px;
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
}
.card .art {
  position: relative; aspect-ratio: 63 / 88; border-radius: 8px; overflow: hidden;
  background: #1f1f24; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 18px rgba(0, 0, 0, 0.45);
}
.card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .name { font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
.card .sub { color: var(--muted); font-size: 0.78rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.for_sale { background: var(--sale); }
.dot.for_trade { background: var(--trade); }

.binder-page {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  background: #121215; border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  max-width: 560px; margin: 0 auto;
}
.binder-page .card .name, .binder-page .card .sub { display: none; }
.binder-page .empty-slot { aspect-ratio: 63 / 88; border-radius: 8px; border: 1px dashed var(--line); }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.pager button { min-width: 56px; }
.pager button:disabled { opacity: 0.35; cursor: default; }

.empty { color: var(--muted); text-align: center; padding: 48px 12px; }
.error { background: #3a1518; border: 1px solid #7a2a31; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; }

dialog {
  width: min(560px, 100vw); max-width: 100vw; max-height: 100dvh; margin: auto; padding: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.75); }
.insp, .sources { position: relative; padding: 16px; }
.close {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px;
  border-radius: 50%; border: 1px solid var(--line); background: rgba(12, 12, 14, 0.8);
  font-size: 1.4rem; cursor: pointer; z-index: 2;
}
#inspImage {
  display: block; width: 100%; max-height: 68dvh; aspect-ratio: 63 / 88;
  object-fit: contain; border-radius: 10px; background: #1f1f24;
}
.source-label { margin: 6px 0 0; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.insp h2, .sources h2 { margin: 4px 0; font-size: 1.15rem; padding-right: 48px; }
.meta { color: var(--muted); margin: 4px 0; font-size: 0.9rem; }
.status-pill { display: inline-block; margin: 8px 0 12px; font-weight: 600; }
.insp-nav { display: flex; justify-content: space-between; gap: 10px; }
.insp-nav button:disabled { opacity: 0.35; }
.source-row { border-top: 1px solid var(--line); padding: 10px 0; font-size: 0.9rem; }
.source-row strong { display: block; margin-bottom: 4px; }
.source-row ul { margin: 0; padding-left: 18px; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .card .art { transition: transform 120ms ease; }
  .card:active .art { transform: scale(0.98); }
}

/* Browsers without aspect-ratio (older iOS and Android): keep the card shape. */
@supports not (aspect-ratio: 1 / 1) {
  .card .art, .binder-page .empty-slot { height: 0; padding-top: 139.68%; }
  .card .art img { position: absolute; inset: 0; top: 0; left: 0; }
  #inspImage { height: auto; }
}

/* Condition tags: color plus initials, so color is never the only signal. */
.cond {
  display: inline-block; min-width: 2.2em; padding: 2px 7px; border-radius: 6px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; text-align: center; color: #fff;
}
.cond-nm { background: #16a34a; }
.cond-lp { background: #2563eb; }
.cond-mp { background: #ea580c; }
.cond-hp { background: #ca8a04; color: #111; }
.cond-dmg { background: #dc2626; }
.cond-graded { background: #e5e7eb; color: #111; }
.cond-sealed { background: #6b7280; }
.cond-unknown { background: #3f3f46; }

.chips-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between;
  align-items: flex-end; gap: 4px; padding: 6px; pointer-events: none;
}
.price {
  padding: 2px 8px; border-radius: 6px; background: rgba(12, 12, 14, 0.88); color: #fff;
  font-weight: 800; font-size: 0.85rem; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.price-ask { font-weight: 600; color: #d4d4d8; }
.binder-page .price { font-size: 0.72rem; padding: 1px 5px; }
.binder-page .cond { font-size: 0.62rem; padding: 1px 4px; }

.insp-price-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.insp-price { margin: 0; font-size: 1.6rem; font-weight: 800; }
.insp-condition { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }

.owner-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.owner-badge {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: #fbbf24; border: 1px solid #fbbf24; border-radius: 999px; padding: 3px 10px;
}
.owner-panel { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; }
.owner-panel h3 { margin: 0 0 8px; font-size: 1rem; display: flex; justify-content: space-between; align-items: baseline; }
.owner-panel .private { font-size: 0.72rem; color: #fbbf24; font-weight: 600; }
.owner-panel dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0 0 12px; }
.owner-panel dt { color: var(--muted); font-size: 0.78rem; }
.owner-panel dd { margin: 0; font-weight: 700; }
.owner-panel .wide { grid-column: 1 / -1; }
.owner-panel .note { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.gain { color: #4ade80; }
.loss { color: #f87171; }
.owner-panel label { display: block; font-size: 0.85rem; margin-bottom: 6px; }
.ask-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ask-row input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.ask-row button {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; flex: 1;
}
.ask-row button.primary { background: var(--text); color: var(--bg); flex: 0 0 auto; }
.ask-row button:disabled { opacity: 0.4; }

/* The close button sits in its own bar above the card, never over the artwork. */
.insp { padding-top: 0; }
.insp-top {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: flex-end;
  margin: 0 -16px 8px; padding: 8px 8px 4px; background: var(--panel);
}
.insp-top .close { position: static; }

/* Owner-only: a small dot marks a manual price that overrides market value. */
.override-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #fbbf24;
  margin-right: 5px; vertical-align: middle; box-shadow: 0 0 0 1.5px rgba(12, 12, 14, 0.9);
}
.price-mode { margin: 0 0 8px; font-size: 0.8rem; color: var(--muted); }
.price-mode.is-override::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #fbbf24; margin-right: 6px; vertical-align: middle;
}

/* Real card corners: 3 mm radius on a 63 x 88 mm card. */
.card .art, .face img, .back-empty, .binder-page .empty-slot { border-radius: 4.76% / 3.41%; }

/* Close-up: tap the card to flip it. */
.flip {
  perspective: 1600px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  width: min(100%, calc(68vh * 63 / 88)); width: min(100%, calc(68dvh * 63 / 88)); margin: 0 auto;
}
.flip-inner { position: relative; aspect-ratio: 63 / 88; transform-style: preserve-3d; transition: transform 450ms ease; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.face-back { transform: rotateY(180deg); }
.face img, #inspImage {
  display: block; width: 100%; height: 100%; max-height: none; aspect-ratio: auto;
  object-fit: contain; background: #1f1f24;
}
.back-empty {
  height: 100%; display: grid; place-items: center; text-align: center; padding: 16px;
  background: repeating-linear-gradient(135deg, #18181c 0 12px, #1d1d22 12px 24px);
  border: 1px dashed var(--line); color: var(--muted);
}
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.side-seg { grid-template-columns: repeat(2, 1fr); width: 170px; }
.side-row .source-label { margin: 0; text-align: right; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-actions button {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; flex: 1 1 auto;
}
.photo-actions button.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.photo-actions button.danger { color: #fca5a5; border-color: #7f1d1d; }
.photo-actions .meta { flex-basis: 100%; margin: 0; }

/* Corner alignment screen */
dialog.aligner {
  width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh;
  margin: 0; border: 0; border-radius: 0; background: #000; color: var(--text);
  display: none; grid-template-rows: auto 1fr auto;
}
dialog.aligner[open] { display: grid; }
.al-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
}
.al-top h2 { margin: 0; font-size: 1rem; }
.al-text { min-height: 44px; padding: 0 12px; border: 0; background: transparent; font-weight: 600; cursor: pointer; }
.al-stage { position: relative; min-height: 0; }
#alCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.loupe {
  position: absolute; top: 10px; width: 132px; height: 132px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); pointer-events: none;
}
.al-bottom {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: #0c0c0e;
}
.al-preview { display: grid; justify-items: center; gap: 4px; font-size: 0.7rem; color: var(--muted); }
.al-preview canvas { width: 63px; height: 88px; border-radius: 3px; background: #1f1f24; }
.al-actions { flex: 1; display: grid; gap: 6px; }
.al-hint, .al-status { margin: 0; font-size: 0.8rem; color: var(--muted); }
.al-status.error { color: #fca5a5; }
.al-actions .primary {
  min-height: 48px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 1rem; cursor: pointer;
}
.al-actions .primary:disabled { opacity: 0.5; }

/* View as: Owner | Customer. The highlighted side is the view on screen. */
.owner-view { display: grid; gap: 6px; }
.view-as { grid-template-columns: repeat(2, 1fr); }
.view-as button[data-view-as="owner"][aria-pressed="true"] { background: #fbbf24; color: #111; }
.view-as-note { margin: 0; font-size: 0.78rem; color: var(--muted); }
/* A slim reminder in the top bar while previewing as a customer. */
body.previewing .bar { box-shadow: inset 0 -2px 0 #3b82f6; }

/* Ledger (owner only) */
dialog.ledger {
  width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh;
  margin: 0; border: 0; border-radius: 0; background: var(--bg); padding: 0;
}
.ledger-top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px 14px; background: rgba(12, 12, 14, 0.95);
  border-bottom: 1px solid var(--line);
}
.ledger-top h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.ledger-top .close { position: static; }
.ledger-body { padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; display: grid; gap: 12px; }
.ledger-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .v { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.ledger-filter { grid-template-columns: repeat(4, 1fr); }
.ledger-tests { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.ledger-rows { display: grid; gap: 8px; }
.tx {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer;
}
.tx .when { font-size: 0.78rem; color: var(--muted); }
.tx .what { font-weight: 700; }
.tx .venue { font-size: 0.8rem; color: var(--muted); grid-column: 1; }
.tx .amt { text-align: right; font-weight: 800; grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.tx .amt small { display: block; font-weight: 600; font-size: 0.75rem; }
.kind { display: inline-block; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 6px; border-radius: 5px; margin-right: 6px; background: #3f3f46; color: #fff; }
.kind-sale { background: #16a34a; } .kind-trade { background: #2563eb; } .kind-purchase { background: #9333ea; }
.kind-reversal, .kind-adjustment { background: #6b7280; }
.test-flag { font-size: 0.68rem; color: #fbbf24; margin-left: 6px; }
.detail-head { display: grid; gap: 4px; }
.detail-head .notes { font-size: 0.85rem; color: var(--muted); white-space: pre-wrap; }
.line-group h3 { margin: 6px 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.line .nm { font-weight: 700; }
.line .sub { font-size: 0.78rem; color: var(--muted); }
.line .num { text-align: right; font-size: 0.85rem; }
.line .num b { display: block; font-size: 1rem; }

/* Recording transactions (owner only) */
.record-btn { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: #fbbf24; color: #111; font-weight: 800; cursor: pointer; }
.pending { background: var(--panel); border: 1px solid #fbbf24; border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.pending h3 { margin: 0; font-size: 0.85rem; }
.pend { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.pend:first-child { border-top: 0; }
.pend .sub { font-size: 0.78rem; color: var(--muted); }
.pend .acts { display: flex; gap: 6px; }
.pend button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.badge { font-size: 0.68rem; font-weight: 800; padding: 2px 6px; border-radius: 5px; margin-right: 6px; }
.badge-draft { background: #3f3f46; } .badge-waiting { background: #ca8a04; color: #111; } .badge-attn { background: #dc2626; }
.rec { gap: 14px; }
.rec-kind { grid-template-columns: repeat(3, 1fr); }
.rec-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.rec label { display: grid; gap: 4px; font-size: 0.78rem; color: var(--muted); }
.rec input, .rec textarea, .pick-find {
  min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px; width: 100%; min-width: 0;
}
.rec textarea { padding: 10px 12px; min-height: 60px; resize: vertical; }
.rec-side { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.rec-side h3 { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.rec-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.rec-line:first-child { border-top: 0; }
.rec-line .nm { font-weight: 700; }
.rec-line .sub { font-size: 0.75rem; color: var(--muted); }
.rec-line .fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; }
.rec-line .fields label { font-size: 0.7rem; }
.rec-line .fields input { min-height: 40px; }
.rec-line .remove { border: 0; background: transparent; color: #fca5a5; font-size: 0.8rem; cursor: pointer; align-self: start; min-height: 32px; }
.rec-add { display: flex; gap: 6px; flex-wrap: wrap; }
.rec-add button { flex: 1; min-height: 40px; border-radius: 999px; border: 1px dashed var(--line); background: transparent; cursor: pointer; }
.rec-split { display: flex !important; align-items: center; gap: 8px; font-size: 0.85rem !important; color: var(--text) !important; }
.rec-split[hidden] { display: none !important; }
.rec-split input { width: 20px; min-height: 20px; }
.rec-problems { margin: 0; color: #fca5a5; font-size: 0.85rem; }
.rec-primary { min-height: 52px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 800; font-size: 1.05rem; cursor: pointer; }
.rec-primary:disabled { opacity: 0.4; }
.pick-rows { display: grid; gap: 6px; }
.pick { display: grid; grid-template-columns: 46px 1fr auto; gap: 2px 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.pick .sub { font-size: 0.75rem; color: var(--muted); }
.pick .st { font-size: 0.7rem; color: var(--muted); text-align: right; }
.rec-discard { justify-self: center; min-height: 40px; border: 0; background: transparent; color: #fca5a5; cursor: pointer; }
.rec-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 50; }
.rec-thumb { display: grid; place-items: center; overflow: hidden; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); aspect-ratio: 5 / 7; }
.rec-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-thumb.none span { font-size: 0.55rem; color: var(--muted); text-align: center; line-height: 1.1; padding: 2px; }
.pick-pic { width: 46px; grid-row: span 2; }
.rec-line.has-thumb { grid-template-columns: 64px 1fr auto; }
.rec-line.has-thumb .fields { grid-column: 1 / -1; }
.rec-thumb.line { width: 64px; cursor: zoom-in; align-self: start; }
.rec-preview { border: 0; padding: 16px; background: rgba(0, 0, 0, 0.92); color: var(--text); width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; }
.rec-preview[open] { display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; }
.rec-preview img { max-width: min(92vw, 520px); max-height: 72dvh; border-radius: 12px; object-fit: contain; }
.rec-preview .nm { font-weight: 800; font-size: 1.1rem; }
.rec-preview .sub { color: var(--muted); font-size: 0.85rem; margin: 0; }
/* Catalog review (owner only) */
.review-body { padding-bottom: 110px; }
.review-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.review-card #reviewMine { width: 96px; }
.review-card .nm { font-weight: 800; font-size: 1.05rem; }
.review-card .sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.review-matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.match { display: grid; gap: 4px; padding: 6px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); text-align: left; cursor: pointer; }
.match[aria-pressed="true"] { border-color: #fbbf24; box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35); }
.match .rec-thumb { width: 100%; }
.match .nm { font-weight: 700; font-size: 0.85rem; }
.match .sub { color: var(--muted); font-size: 0.72rem; }
.match .score { font-size: 0.68rem; color: #86efac; }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.review-actions button { flex: 1; min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 600; }
.review-bar { position: sticky; bottom: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); background: rgba(12, 12, 14, 0.95); border-top: 1px solid var(--line); display: grid; max-width: 720px; margin: 0 auto; }
/* Card gallery: extra photos and videos of this exact copy */
.gallery { display: grid; gap: 8px; margin: 10px 0; }
.gallery-head { display: flex; align-items: baseline; justify-content: space-between; }
.gallery-head h3 { margin: 0; font-size: 0.85rem; }
.gallery-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
.g-item { position: relative; flex: 0 0 76px; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); padding: 0; cursor: pointer; scroll-snap-align: start; }
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-item .g-tag { position: absolute; left: 4px; bottom: 4px; font-size: 0.6rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.7); color: #fff; }
.g-item.is-video::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-40%, -50%); border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent rgba(255, 255, 255, 0.92); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.g-item.is-face { outline: 2px solid #fbbf24; outline-offset: -2px; }
.g-empty { font-size: 0.8rem; color: var(--muted); }
.gallery-owner { display: grid; gap: 6px; }
.gallery-add { display: flex; gap: 6px; flex-wrap: wrap; }
.gallery-add button, .face-row button, .mv-owner button { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 600; }
.gallery-add .primary { background: var(--text); color: var(--bg); border-color: var(--text); flex: 1 1 100%; }
.gallery-add button:not(.primary) { flex: 1; }
.face-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.85rem; flex-wrap: wrap; }
.scan-note { margin: 0; font-size: 0.75rem; color: var(--muted); }
.media-badge { position: absolute; top: 6px; right: 6px; font-size: 0.65rem; font-weight: 800; padding: 2px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.72); color: #fff; }
.media-view { border: 0; padding: 0; margin: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; background: #000; color: #fff; }
.media-view[open] { display: grid; grid-template-rows: auto 1fr auto auto auto; }
.mv-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px 14px; }
.mv-top #mvLabel { font-weight: 700; flex: 1; }
.mv-top .close { position: static; }
/* The picture fills the stage and shrinks to fit it whole: a scan is never cut off. */
.mv-stage { position: relative; min-height: 0; overflow: hidden; touch-action: pan-y; }
.mv-stage img, .mv-stage video { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; }
.mv-scrub { display: flex; align-items: center; gap: 12px; padding: 6px 16px; }
.mv-scrub input { flex: 1; min-width: 0; height: 36px; accent-color: #fbbf24; }
.mv-time { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: #d4d4d8; min-width: 7.5ch; text-align: right; }
#mvPlay { position: relative; flex: none; width: 44px; height: 44px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35); background: transparent; cursor: pointer; }
#mvPlay::before { content: ""; position: absolute; left: 16px; top: 13px; border-style: solid; border-width: 9px 0 9px 14px; border-color: transparent transparent transparent #fff; }
#mvPlay.playing::before { left: 14px; top: 13px; width: 5px; height: 18px; border: 0; background: #fff; box-shadow: 9px 0 0 #fff; }
.mv-nav { display: flex; justify-content: space-between; padding: 6px 12px; }
.mv-nav button { width: 48px; height: 48px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent; color: #fff; font-size: 1.6rem; cursor: pointer; }
.mv-nav button:disabled { opacity: 0.25; }
.mv-owner { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255, 255, 255, 0.15); }
.mv-owner button { color: #fff; border-color: rgba(255, 255, 255, 0.3); flex: 1; }
.mv-owner .danger { color: #fca5a5; }
.mv-owner p { flex-basis: 100%; margin: 0; color: #d4d4d8; }
/* Photos & storage (owner only) */
.storage-rows { display: grid; gap: 8px; }
.st-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: grid; gap: 8px; }
.st-head { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.st-head .rec-thumb { width: 44px; }
.st-head .nm { font-weight: 700; }
.st-head .sub { font-size: 0.75rem; color: var(--muted); }
.st-head .sz { font-weight: 700; font-size: 0.85rem; }
.st-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.st-item { display: grid; gap: 4px; font-size: 0.72rem; color: var(--muted); }
.st-item .g-item { flex: none; width: 100%; }
.st-item button.danger { min-height: 34px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: #fca5a5; cursor: pointer; }
/* Collection and card finder (owner only) */
.col-filter { grid-template-columns: repeat(4, 1fr); }
.pick .st.pill { justify-self: end; font-weight: 700; }
.cs-head { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; }
.cs-head .rec-thumb { width: 110px; }
.cs-head .nm { font-weight: 800; font-size: 1.1rem; }
.cs-head .sub { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }
.cs-new, .cs-manual { display: grid; gap: 10px; }
.cs-new label, .cs-manual label { display: grid; gap: 4px; font-size: 0.78rem; color: var(--muted); }
.cs-new select, .cs-new input { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: 16px; }
.cs-status { grid-template-columns: repeat(3, 1fr); }
.match .lang { font-size: 0.68rem; color: #93c5fd; }
/* Header search: the magnifier swaps the title for the search field (every screen) */
.ledger-top .head-search { flex: 1; min-width: 0; }
.ledger-top .head-search input {
  flex: 1; min-width: 0; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px;
}
.ledger-top.searching h2 { display: none; }
.ledger-top .head-find { position: relative; }
.ledger-top .view-btn { min-height: 40px; }
.col-view-menu { min-width: 160px; }
.col-view-menu button { display: block; width: 100%; text-align: left; }
#colGrid .card, #colBinderPage .card { position: relative; }
.col-status { position: absolute; left: 6px; top: 6px; font-size: 0.62rem; font-weight: 800; padding: 2px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.72); color: #fff; }
.col-status.to_sell { background: #15803d; } .col-status.to_trade { background: #1d4ed8; }
.art-missing { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; font-size: 0.75rem; color: var(--muted); }
.cs-edit { grid-template-columns: 1fr 1fr; align-items: end; }
.cs-edit button { grid-column: 1 / -1; min-height: 44px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 800; cursor: pointer; }
.tailnet-box { display: grid; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line); }
.tailnet-box p { margin: 0; overflow-wrap: anywhere; }
.offline-note { margin: 8px 0; padding: 8px 12px; border-radius: 10px; background: #422006; color: #fde68a; font-size: 0.82rem; }
.ledger-top h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 480px) {
  /* Phone width: the view button shows its icon only, so the search field has room. */
  .ledger-top .view-btn { padding: 0 10px; }
  .ledger-top .view-btn span { display: none; }
  .ledger-top.searching .record-btn { padding: 0 12px; }
}
/* Pages share the one header; menu parts marked data-for show only on their page. */
body:not([data-page]) [data-for]:not([data-for="showcase"]) { display: none !important; }
body[data-page="showcase"] [data-for]:not([data-for="showcase"]) { display: none !important; }
body[data-page="collection"] [data-for]:not([data-for="collection"]) { display: none !important; }
body[data-page="ledger"] [data-for]:not([data-for="ledger"]) { display: none !important; }
body[data-page="review"] [data-for]:not([data-for="review"]) { display: none !important; }
body[data-page="storage"] [data-for]:not([data-for="storage"]) { display: none !important; }
body[data-page="import"] [data-for]:not([data-for="import"]) { display: none !important; }
.page-nav { display: grid; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.page-nav .menu-item[aria-current="page"] { font-weight: 800; background: var(--bg); }
.page-back { margin-bottom: 8px; }
.page-body { display: grid; gap: 12px; }
.page { display: grid; gap: 12px; align-content: start; }
.page[hidden] { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* One primary action per page (Add card, Record) */
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: #fbbf24; color: #111; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); display: grid; place-items: center; }
.fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
/* Binder pager stays on screen at the bottom; tap fast, pick a page, or swipe the page. */
.pager-sticky { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 15; width: fit-content;
  margin: 14px auto 0; padding: 6px; border-radius: 999px; background: rgba(23, 23, 27, 0.94); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); gap: 8px; }
.page-pick select { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font: inherit; font-size: 16px; font-weight: 700; }
.review-bar { position: sticky; bottom: 0; }
/* Menu Show rows stay on one line, even with four choices on a narrow phone. */
.menu-panel .seg button { white-space: nowrap; min-width: 0; padding: 0 6px; font-size: 0.9rem; }
/* Card notes and transaction history (owner only) */
.card-info { display: grid; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.ci-notes label { display: grid; gap: 6px; font-size: 0.85rem; font-weight: 700; }
.ci-notes label .private { font-weight: 500; font-size: 0.72rem; color: #fbbf24; margin-left: 6px; }
.ci-notes textarea { min-height: 70px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font: inherit; font-size: 16px; resize: vertical; }
.ci-save { justify-self: start; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 800; cursor: pointer; }
.ci-status { margin: 0; }
.ci-history h4 { margin: 0 0 6px; font-size: 0.85rem; }
.ci-list { display: grid; gap: 6px; }
.ci-tx { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; text-align: left; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: inherit; cursor: pointer; }
.ci-tx .ci-kind { font-weight: 800; }
.ci-tx .ci-venue { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted); }
.ci-tx .ci-amt { grid-row: 1; grid-column: 3; font-weight: 700; }
.rec-line .fields .rec-note { grid-column: 1 / -1; }

/* ----- Display only (2026-09-26) ----- */
:root { --display: #f5b942; }
.dot.display { background: var(--display); }
.price-display { font-weight: 700; color: var(--display); }

/* View menu: Show (status filter) under the views. */
.view-show { display: grid; gap: 2px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.view-show .menu-label { padding: 0 12px 4px; }
.view-show button {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px;
  background: transparent; text-align: left; cursor: pointer;
}
.view-show button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.view-btn .badge-dot { top: 6px; right: 6px; }

/* ----- 3D table ----- */
/* The page is held still on the root only: overflow on body would clip the menus to the page height. */
html.view-table { overflow: hidden; overscroll-behavior: none; }
/* Pinned over the 3D table, the bar keeps clear of the status bar in the installed app. */
body.view-table .bar { background: rgba(12, 12, 14, 0.72); position: fixed; left: 0; right: 0; top: 0; padding-top: calc(6px + env(safe-area-inset-top)); }
/* Full screen height: the installed app draws under the status bar, and iOS then reports a
   viewport short by the status bar's height, which left a band at the bottom. */
.table3d { position: fixed; inset: 0; height: 100vh; height: 100lvh; z-index: 1; background: #1d1b22; }
.t3-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
body.view-table #empty { position: fixed; left: 16px; right: 16px; top: 40%; z-index: 2; text-align: center; }
.t3-status { position: absolute; inset: 40% 16px auto; margin: 0; text-align: center; color: var(--muted); pointer-events: none; }
.t3-status:empty { display: none; }
.t3-controls {
  position: absolute; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex;
  justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 16px; pointer-events: none;
}
.t3-controls > * { pointer-events: auto; }
.t3-case {
  display: flex; align-items: center; gap: 6px; background: rgba(23, 23, 27, 0.92); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px;
}
.t3-case button { min-width: 40px; min-height: 40px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.t3-case button:disabled { opacity: 0.35; }
.t3-case span { min-width: 90px; text-align: center; font-weight: 600; font-size: 0.9rem; }
.t3-info {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(70px + env(safe-area-inset-top));
  width: min(420px, calc(100% - 32px)); display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: rgba(23, 23, 27, 0.95); border: 1px solid var(--line); border-radius: 14px;
}
.t3-text { flex: 1; min-width: 0; display: grid; }
.t3-text b, .t3-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t3-text span { color: var(--muted); font-size: 0.85rem; }
.t3-text .t3-price { color: var(--text); font-weight: 700; font-size: 0.95rem; }
.t3-info button { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700; }
.t3-hint {
  position: absolute; left: 16px; right: 16px; bottom: calc(130px + env(safe-area-inset-bottom)); margin: 0; text-align: center;
  color: rgba(242, 242, 244, 0.7); font-size: 0.78rem; pointer-events: none;
  animation: t3-hint-out 1s ease 6s forwards;
}
@keyframes t3-hint-out { to { opacity: 0; } }

/* ----- Owner: on show as ----- */
.own-status { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.own-status .seg button { white-space: nowrap; min-width: 0; padding: 0 6px; font-size: 0.9rem; }
.own-now button { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; }

/* ----- Showcase settings ----- */
.settings h3 { margin: 16px 0 6px; font-size: 1rem; }
.set-binders { display: grid; gap: 2px; max-height: 40vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
.set-binder { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.set-binder:last-child { border-bottom: 0; }
.set-binder > label:first-child { font-weight: 600; min-height: 32px; display: flex; align-items: center; gap: 6px; }
.set-binder .meta { grid-column: 1; margin: 0; font-size: 0.8rem; }
.set-display { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 6px; font-size: 0.9rem; white-space: nowrap; }
.set-binder input[type="checkbox"], .set-check input { width: 20px; height: 20px; }
.set-look { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.set-look label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.set-look input[type="color"] { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 2px; }
.set-look select { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 8px; font-size: 16px; }
.set-look .set-check { display: flex; align-items: center; gap: 8px; color: var(--text); grid-column: 1 / -1; }
.set-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.set-swatches button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }

/* ----- Brand ----- */
@font-face {
  font-family: "Bangers";
  src: url("/static/vendor/fonts/Bangers-Regular.ttf") format("truetype");
  font-display: swap;
}
.bb-logo { display: block; width: 100%; height: 100%; overflow: visible; }
.bar-logo { flex: 0 0 auto; width: 118px; height: 42px; margin-right: auto; }
body[data-page]:not([data-page="showcase"]) .bar-logo { display: none; }
body[data-page="showcase"] #title, body:not([data-page]) #title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.bar-row:has(#searchBox:not([hidden])) .bar-logo { display: none; }

/* ----- Share with a QR code ----- */
.share { text-align: center; }
.share-logo { width: min(260px, 70%); aspect-ratio: 312 / 122; margin: 8px auto 4px; }
.share h2 { padding: 0; margin: 8px 0 12px; }
.share-codes { display: grid; gap: 16px; justify-items: center; }
.share-code { display: grid; gap: 6px; justify-items: center; width: 100%; }
.share-code .qr { width: min(78vw, 360px); aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 6px; }
.share-code .qr svg { width: 100%; height: 100%; display: block; }
.share-code .url { font-size: 0.8rem; color: var(--muted); word-break: break-all; }
.share-code .code { font-weight: 800; letter-spacing: 0.12em; font-size: 1.2rem; }

/* ----- Not on show ----- */
.hidden-box { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.hidden-box h3 { margin: 8px 0 4px; font-size: 1rem; }
.hidden-group { margin-top: 12px; }
.hidden-group > p { margin: 0 0 4px; font-weight: 700; font-size: 0.9rem; }
.hidden-row { border-top: 1px solid var(--line); padding: 8px 0; font-size: 0.9rem; display: grid; gap: 4px; }
.hidden-row .where { color: var(--muted); font-size: 0.8rem; }
.hidden-row .cand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hidden-row .cand span { flex: 1; min-width: 160px; }
.hidden-row .cand b.same { color: var(--sale); font-weight: 700; }
.hidden-row button { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; }
.t3-case select { min-height: 40px; max-width: 46vw; border: 0; border-radius: 9px; background: transparent; color: var(--text); font: inherit; font-weight: 600; font-size: 0.9rem; text-align: center; }
.hidden-box input[type="search"] {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 16px; margin: 6px 0;
}

/* ----- 3D: Front, the Overview slider, play ----- */
.t3-rail {
  display: flex; align-items: center; gap: 4px; width: min(560px, 100%); padding: 4px;
  background: rgba(23, 23, 27, 0.92); border: 1px solid var(--line); border-radius: 14px;
}
.t3-rail > #t3Front, .t3-play {
  flex: 0 0 auto; min-width: 44px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); font-weight: 700; cursor: pointer;
}
.t3-rail > #t3Front[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.t3-play { padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.t3-play svg { width: 20px; height: 20px; }
.t3-play[aria-pressed="true"] { background: rgba(245, 185, 66, 0.22); color: #f5b942; }
.t3-track {
  --thumb-half: 52px;
  position: relative; flex: 1; min-width: 0; height: 40px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.04); touch-action: none; -webkit-user-select: none; user-select: none;
  transition: background 200ms ease, box-shadow 200ms ease;
}
.t3-ticks span {
  position: absolute; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  opacity: 0.35; transition: opacity 200ms ease;
}
.t3-thumb {
  position: absolute; left: 0; top: 0; width: calc(2 * var(--thumb-half)); height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, 0.12); color: var(--text); font-weight: 700; cursor: grab;
  touch-action: none; will-change: transform; transition: background 200ms ease, box-shadow 200ms ease;
}
.t3-thumb:active { cursor: grabbing; }
.t3-grip { opacity: 0.6; font-size: 1.15em; line-height: 1; }
/* In Overview the track and the handle light up, and the handle nudges once to say "drag me". */
.t3-rail.active .t3-track {
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 0 0 1px rgba(245, 185, 66, 0.45), 0 0 16px rgba(245, 185, 66, 0.22);
}
.t3-rail.active .t3-ticks span { opacity: 0.95; }
.t3-rail.active .t3-thumb {
  background: var(--text); color: var(--bg); box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.45);
  animation: t3-nudge 900ms ease 1;
}
@keyframes t3-nudge { 0%, 100% { margin-left: 0; } 30% { margin-left: 6px; } 65% { margin-left: -6px; } }
@media (prefers-reduced-motion: reduce) { .t3-rail.active .t3-thumb { animation: none; } }

/* ----- Menu: sections, and the page held still behind an open menu ----- */
.page-nav { display: grid; gap: 6px; padding: 10px 0; border-bottom: 0; margin-bottom: 0; }
.menu-section { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.menu-panel > :first-child:not([hidden]), .page-nav[hidden] + .menu-section { border-top: 0; }
.menu-hint { margin: 0; font-size: 0.8rem; line-height: 1.35; }
.menu-section .seg button { white-space: nowrap; min-width: 0; padding: 0 6px; font-size: 0.9rem; }
.view-as-note { margin: 0; }
/* Only the root is locked: hiding overflow on body would clip the menu to the page height. */
html.menu-open { overflow: hidden; }
body.menu-open::after {
  content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.35);
}

/* ----- Import cards ----- */
.imp { display: grid; gap: 12px; }
.imp-file { display: flex; align-items: center; justify-content: center; min-height: 56px; border: 2px dashed var(--line);
  border-radius: 14px; cursor: pointer; font-weight: 700; }
.imp-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.imp-file:focus-within { outline: 3px solid var(--trade); outline-offset: 2px; }
.imp-toggle { display: flex; gap: 10px; align-items: flex-start; }
.imp-toggle input, .imp-mode input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; }
.imp-summary { grid-template-columns: repeat(3, 1fr); }
.imp-summary .stat { display: grid; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.imp-summary .stat b { font-size: 1.2rem; }
.imp-summary .stat span { color: var(--muted); font-size: 0.8rem; }
#impChoose h3 { margin: 8px 0 4px; font-size: 1rem; }
.imp-choose { border-top: 1px solid var(--line); padding: 10px 0; display: grid; gap: 8px; }
.imp-picks { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.imp-pick, .imp-skip { flex: 0 0 auto; display: grid; gap: 4px; width: 120px; padding: 6px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 0.75rem; text-align: left; cursor: pointer; }
.imp-pick img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: var(--bg); }
.imp-skip { width: 96px; align-content: center; text-align: center; font-weight: 600; }
.imp-pick[aria-pressed="true"], .imp-skip[aria-pressed="true"] { border-color: var(--sale); box-shadow: 0 0 0 2px var(--sale); }
.imp-all summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.imp-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 0;
  border-top: 1px solid var(--line); font-size: 0.85rem; }
.imp-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-status { font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--panel); white-space: nowrap; }
.imp-status.s-owned { color: var(--sale); }
.imp-status.s-matched, .imp-status.s-chosen { color: var(--trade); }
.imp-status.s-choose { color: #fbbf24; }
.imp-status.s-unknown { color: #f87171; }
.imp-name-field { display: grid; gap: 6px; font-weight: 700; }
.imp-name-field input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 16px; }
.imp-mode { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; display: grid; gap: 8px; }
.imp-mode legend { font-weight: 700; padding: 0 4px; }
.imp-mode label { display: flex; gap: 10px; align-items: center; min-height: 36px; }
.imp-done { display: grid; gap: 10px; }

/* ----- One-handed closing: a dock at the bottom of card windows ----- */
.insp-dock {
  position: sticky; bottom: 0; z-index: 3; display: flex; gap: 10px; align-items: center;
  margin: 14px -16px -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(23, 23, 27, 0.96); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.insp-dock button { min-height: 48px; }
.insp-dock #inspPrev, .insp-dock #inspNext { flex: 0 0 64px; font-size: 1.2rem; }
.insp-dock .dock-close {
  flex: 1; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 800; cursor: pointer;
}
.sheet-dock { margin: 12px -14px calc(-24px - env(safe-area-inset-bottom)); }
dialog.swiping { transition: none; }
dialog.swipe-release { transition: transform 180ms ease, opacity 180ms ease; }

/* ----- Select several cards (phone) ----- */
.sel-bar {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 28;
  display: grid; gap: 8px; padding: 10px 12px; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(23, 23, 27, 0.97); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.sel-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sel-top button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--text); color: var(--bg); font-weight: 800; }
.sel-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sel-actions button, .sel-binders button {
  min-height: 44px; padding: 0 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.sel-actions button:disabled { opacity: 0.4; }
.sel-binders { display: flex; flex-wrap: wrap; gap: 6px; max-height: 30vh; overflow-y: auto; }
.sel-binders button { padding: 0 12px; }
.sel-bar .meta { margin: 0; }
.sel-bar .meta:empty { display: none; }
[data-sel-ew] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.is-picked { outline: 3px solid #ffcb05; outline-offset: 2px; border-radius: 12px; }
body.selecting .fab { visibility: hidden; }
body.selecting .pager-sticky { bottom: calc(190px + env(safe-area-inset-bottom)); }
body.selecting main { padding-bottom: 180px; }

/* ----- Binders on show: filter and grid headings ----- */
.view-binders #viewBinderList { display: grid; gap: 2px; max-height: 40vh; overflow-y: auto; }
.view-binders button { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px;
  padding: 0 12px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; width: 100%; }
.view-binders button small { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.view-binders button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.view-binders button[aria-pressed="true"] small { color: var(--bg); opacity: 0.7; }
.binder-head { grid-column: 1 / -1; margin: 18px 0 2px; font-size: 1.05rem; font-weight: 800; }
.binder-head:first-child { margin-top: 0; }
.binder-head small { margin-left: 6px; font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.binder-summary { grid-column: 1 / -1; display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--panel); }
.binder-summary h2 { margin: 0; font-size: 1.15rem; }
.binder-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.binder-figures div { display: grid; gap: 2px; }
.binder-figures b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.binder-figures span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* ----- Catalog review: clear matches, linked together ----- */
.review-sure { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.sure-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sure-head button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 700; }
.review-sure .meta { margin: 0; }
.sure-list { display: grid; gap: 2px; max-height: 55vh; overflow-y: auto; }
.sure-row { display: grid; grid-template-columns: 24px 44px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.sure-row input { width: 20px; height: 20px; }
.sure-text { display: grid; gap: 2px; font-size: 0.85rem; min-width: 0; }
.sure-line { display: flex; gap: 6px; min-width: 0; }
.sure-line span:last-child { overflow-wrap: anywhere; }
/* While the clear-match list is open, the one-card Link bar steps aside. */
.sure-open .review-bar { display: none; }
.sure-k { flex: 0 0 56px; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }

/* Taps answer at once on every phone (no double-tap-to-zoom wait), and a quick second
   tap is never read as a zoom gesture. */
button, .card, .flip, [role="button"], a { touch-action: manipulation; }

/* ----- Phones held sideways: a slim header, see-through over the 3D table, and one
   row of 3D controls, so the cards get the screen. ----- */
@media (orientation: landscape) and (max-height: 520px) {
  .bar { padding-top: max(2px, env(safe-area-inset-top)); padding-bottom: 2px; }
  .bar-row { min-height: 40px; }
  .icon-btn, .view-btn { height: 38px; }
  .bar-logo { width: 92px; height: 32px; }
  body.view-table .bar {
    padding-top: max(2px, env(safe-area-inset-top));
    background: rgba(12, 12, 14, 0.32); border-bottom-color: transparent;
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  }
  body.view-table .view-btn, body.view-table .icon-btn { background: rgba(23, 23, 27, 0.55); }
  .t3-controls {
    flex-wrap: nowrap; gap: 8px; bottom: calc(6px + env(safe-area-inset-bottom));
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }
  .t3-rail { flex: 1 1 auto; width: auto; min-width: 0; }
  .t3-case { flex: 0 1 280px; min-width: 0; }
  .t3-case select { flex: 1; min-width: 0; max-width: none; }
  .t3-hint { display: none; }
  .t3-info { top: calc(48px + env(safe-area-inset-top)); }
  body.selecting .pager-sticky { bottom: calc(120px + env(safe-area-inset-bottom)); }
  .sel-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.t3-thumb.t3-settle { transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), background 200ms ease, box-shadow 200ms ease; }

/* ----- Publish: automatic updates ----- */
.pub-auto { display: grid; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pub-auto h3 { margin: 0; font-size: 1rem; }
.pub-auto .set-check { display: flex; align-items: center; gap: 8px; }
.pub-auto .set-check input { width: 20px; height: 20px; }
.pub-every { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.pub-every select { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 8px; font-size: 16px; }
.pub-auto .meta { margin: 0; }
.set-actions button { flex: 1; min-height: 48px; }
.set-public { margin-top: 18px; }

/* ----- Ask about a card (customers) ----- */
.insp-ask { width: 100%; margin: 0 0 12px; }
.ask-form { display: grid; gap: 8px; }
.ask-card { display: flex; gap: 12px; align-items: center; margin: 4px 0; }
.ask-card img { width: 64px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: #1f1f24; flex: none; }
.ask-card .meta { margin: 2px 0 0; }
.ask-kind { margin: 4px 0; }
.ask-field { font-weight: 600; font-size: 0.9rem; margin-top: 4px; }
.ask-form input, .ask-form textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px; resize: vertical;
}
.ask-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ----- Inbox (owner) ----- */
.count-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 999px; background: #ef4444; color: #fff; font-size: 0.75rem; font-weight: 800; vertical-align: middle;
}
.count-badge.on-icon { position: absolute; top: 2px; right: 0; margin: 0; min-width: 18px; height: 18px; padding: 0 4px;
  font-size: 0.7rem; box-shadow: 0 0 0 2px var(--bg); }
.inbox { display: grid; gap: 10px; padding: 12px 14px 96px; }
.inbox-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.inbox-filter { flex: 1; max-width: 320px; }
.inbox-rows { display: grid; gap: 10px; }
.inbox-item { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--panel); }
.inbox-item.unread { border-color: #fbbf24; }
.inbox-thumb img { width: 64px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; display: block; }
.inbox-body { display: grid; gap: 4px; min-width: 0; }
.inbox-body p { margin: 0; }
.inbox-head-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.inbox-kind { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.inbox-kind.ask-buy { color: var(--sale); }
.inbox-kind.ask-trade { color: var(--trade); }
.inbox-kind.ask-question { color: var(--display); }
.inbox-item.unread .inbox-card::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; background: #fbbf24; vertical-align: middle; }
.inbox-from { overflow-wrap: anywhere; }
.inbox-message { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.inbox-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.inbox-reply { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.inbox-empty { padding: 32px 8px; }

/* ----- First-visit guide (public copy) ----- */
html.guide-open { overflow: hidden; }
.guide { position: fixed; inset: 0; z-index: 60; }
.guide-hole {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 3px #fbbf24, 0 0 0 9999px rgba(0, 0, 0, 0.72);
  transition: left 220ms ease, top 220ms ease, width 220ms ease, height 220ms ease;
}
.guide-hole[hidden] { display: block !important; left: 50%; top: 40%; width: 0; height: 0; }
.guide-arrow { position: fixed; width: 28px; height: 32px; fill: none; stroke: #fbbf24; stroke-width: 3.5;
  stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
.guide-arrow:not(.up) { transform: rotate(180deg); }
.guide-bubble {
  position: fixed; left: 16px; right: 16px; margin: 0 auto; max-width: 420px; padding: 16px 16px 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.guide-bubble h2 { margin: 2px 0 6px; font-size: 1.2rem; }
.guide-bubble p { margin: 0; }
.guide-step { color: #fbbf24; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.guide-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.guide-actions .rec-primary { padding: 0 22px; }
@media (prefers-reduced-motion: no-preference) {
  .guide-arrow { animation: guide-bob 0.9s ease-in-out infinite; }
  .guide-hole { animation: guide-pulse 1.2s ease-in-out infinite; }
}
@keyframes guide-bob { 0%, 100% { translate: 0 0; opacity: 1; } 50% { translate: 0 -7px; opacity: 0.35; } }
@keyframes guide-pulse { 50% { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0.55), 0 0 0 9999px rgba(0, 0, 0, 0.72); } }

.inbox-kind.ask-photos { color: #f472b6; }
.insp-ask-photos { width: 100%; margin: -4px 0 12px; }
.ask-kind button { padding: 0 4px; font-size: 0.9rem; }

/* Import: where the cards go */
.imp-dest label.imp-name-field { display: grid; gap: 6px; align-items: stretch; margin: 0 0 4px 30px; font-weight: 600; }
.imp-dest .imp-name-field input { width: 100%; height: 44px; margin: 0; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.imp-dest select { width: calc(100% - 30px); margin: 0 0 4px 30px; min-height: 44px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.imp-dest .meta { margin: 0 0 4px 30px; }
#impGo, #impOpen { width: 100%; }

/* The logo doubles as the Catalogue | Showcase switch (owner, on this PC): full-size logo,
   then a header-style button beside it. Same place and look in both apps; same tab. */
.bar-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; margin-right: auto; min-width: 0; }
.bar-brand .bar-logo { margin-right: 0; }
.bar-logo.is-link { cursor: pointer; }
.app-swap { text-decoration: none; color: var(--muted); font-size: 0.85rem; gap: 6px; padding: 0 12px 0 10px; }
.app-swap:hover, .app-swap:focus-visible { color: var(--text); }
body[data-page]:not([data-page="showcase"]) .bar-brand { display: none; }
.bar-row:has(#searchBox:not([hidden])) .bar-brand { display: none; }
@media (max-width: 480px) { .app-swap { display: none !important; } }  /* the logo itself still switches */
a.menu-link { display: flex; align-items: center; color: var(--text); text-decoration: none; }
