/* Media — structure only. Every color, font, radius, border weight and shadow below is a
   custom property; the values live in the theme packs under css/themes/ (one file per pack,
   listed in apps/inventory/themes.py). css/themes/classic-light.css is the full token
   contract and the fallback for every pack. See "Theme packs" in README.md. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background-color: var(--bg); background-image: var(--bg-image); background-size: var(--bg-size); color: var(--ink);
  font: 16px/1.5 var(--font-body); }
a { color: var(--link); }
input[type=checkbox], input[type=radio] { accent-color: var(--check); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: 2px; }
h1, h2, .brand, legend, .stat b, .titlecard, .g-total { font-family: var(--font-display); font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking); text-transform: var(--display-case); }
h1 { font-size: var(--h1-size); margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: var(--h2-size); margin: 1.5rem 0 .5rem; line-height: 1.25; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); color: var(--ink); padding: 8px; z-index: 30; }

.top { background-color: var(--header-bg); background-image: var(--header-image); color: var(--header-ink);
  border-bottom: var(--header-border-w) solid var(--header-line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-block: 10px; }
.brand { font-size: var(--brand-size); line-height: 1.2; color: var(--header-ink); text-shadow: var(--brand-shadow);
  text-decoration: none; margin-right: auto; }
.top nav { display: flex; flex-wrap: wrap; gap: 2px 14px; font-family: var(--font-ui); font-weight: var(--nav-weight); }
.top nav a { color: var(--header-ink); text-decoration: none; padding: 4px 0; }
.top nav a[aria-current] { border-bottom: 2px solid var(--header-mark); }
.top form { margin: 0; }
.top :focus-visible { outline-color: var(--header-focus); }
.top-tools { display: flex; align-items: center; gap: 8px; }
@media (max-width: 700px) { .top nav { order: 3; flex-basis: 100%; } }

.btn, button { font: inherit; font-family: var(--font-ui); font-weight: var(--btn-weight); cursor: pointer;
  border: var(--control-border-w) solid var(--control-line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius); box-shadow: var(--shadow-control); text-decoration: none; display: inline-block; }
.btn:active, button:active { transform: translate(var(--press), var(--press)); }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-line); font-weight: var(--btn-primary-weight); }
.btn.small, button.small { padding: 3px 9px; font-size: .875rem; }
button.link { border: 0; background: none; box-shadow: none; transform: none; color: var(--link); padding: 0;
  text-decoration: underline; font-family: inherit; font-weight: inherit; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }

.msgs { list-style: none; padding: 0; margin: 0 0 12px; }
.msgs li { padding: 10px 12px; border-radius: var(--radius); background: var(--soft); border-left: var(--bar-w) solid var(--muted); margin-bottom: 6px; }
.msgs .success { border-color: var(--ok); } .msgs .error { border-color: var(--danger); } .msgs .warning { border-color: var(--warn); }

.card { background: var(--surface); border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; text-decoration: none; color: var(--ink); display: block; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .875rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .right { text-align: right; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: var(--radius-pill); border: var(--hairline) solid var(--tag-line); background: var(--soft); white-space: nowrap; }
.tag.public { border-color: var(--ok); color: var(--ok); } .tag.warn { border-color: var(--warn); color: var(--warn); }

form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 14px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-family: var(--font-ui); font-weight: 600; font-size: .875rem; margin-bottom: 3px; }
.field .help { color: var(--muted); font-size: .8rem; }
.field .errorlist, .errorlist { color: var(--danger); list-style: none; padding: 0; margin: 3px 0 0; font-size: .875rem; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], input[type=file], select, textarea, input:not([type]) {
  font: inherit; width: 100%; padding: 8px 10px; border: var(--control-border-w) solid var(--control-line); border-radius: var(--radius-sm); background: var(--field-bg); color: var(--ink); }
.field.check label { display: inline; font-family: inherit; font-weight: 400; }
fieldset { border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 14px; padding: 10px 14px; background: var(--surface); }
legend { padding: 0 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters > * { flex: 1 1 140px; } .filters .grow { flex: 3 1 240px; } .filters button { flex: 0 0 auto; }
.filters label { display: block; font-size: .75rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px; list-style: none; padding: 0; margin: 0; }
.tile { background: var(--surface); border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; position: relative; }
.tile a { color: var(--ink); text-decoration: none; display: block; }
.tile .art { aspect-ratio: 2 / 3; background: var(--soft); display: flex; align-items: center; justify-content: center; }
.tile .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.titlecard { padding: 10px; text-align: center; line-height: 1.25; overflow-wrap: anywhere; }
.titlecard small { display: block; font-family: var(--font-body); font-weight: 400; letter-spacing: normal; text-transform: none; color: var(--muted); margin-top: 6px; }
.tile .meta { padding: 8px 10px; font-size: .875rem; }
.tile .meta b { display: block; line-height: 1.25; overflow-wrap: anywhere; }
.tile input[type=checkbox] { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; }

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: 7px 9px; border-bottom: var(--hairline) solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-family: var(--font-ui); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 18px 0; }

.detail { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .detail { grid-template-columns: minmax(220px, 340px) 1fr; } }
.detail .art img { width: 100%; border-radius: var(--radius); border: var(--border-w) solid var(--panel-line); box-shadow: var(--shadow); display: block; }
.detail .art .titlecard { aspect-ratio: 2 / 3; display: flex; flex-direction: column; justify-content: center; background: var(--soft); border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 1.3rem; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.photos { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; }
.photos li { width: 150px; font-size: .8rem; } .photos img { width: 100%; border-radius: var(--radius-sm); border: var(--hairline) solid var(--panel-line); }
.bulkbar { position: sticky; bottom: 0; background: var(--surface); border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.bulkbar select, .bulkbar input[type=text] { width: auto; flex: 1 1 140px; }
.hero { padding: 28px 0 8px; } .hero p { max-width: 62ch; }
footer.site { color: var(--muted); font-size: .8rem; padding: 24px 16px; text-align: center; }

/* ---- Inventory grid (portal grid standard) ---- */
.wrap.wide { max-width: 1680px; }
.g-root .card { margin-bottom: 10px; }
.g-grow { flex: 1 1 auto; }
.g-searchbox { position: relative; margin: 4px 0 8px; }
.g-searchbox kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 12px var(--font-mono); color: var(--muted); border: var(--hairline) solid var(--control-line); border-radius: var(--radius-thumb); padding: 0 6px; }
.g-quickrow { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
#g-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.g-pill, .g-chip { font-size: .8rem; padding: 3px 11px; border-radius: var(--radius-pill); }
.g-pill[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-line); }
.g-chip { background: var(--soft); }
.g-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 10px; align-items: start; }
.g-nofilters .g-layout { grid-template-columns: minmax(0, 1fr); }
.g-nofilters .g-facets { display: none; }
@media (max-width: 820px) { .g-layout { grid-template-columns: minmax(0, 1fr); } }
.g-facets { padding: 10px 12px; font-size: .875rem; }
.g-facets-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.g-facet { border-top: var(--hairline) solid var(--line); padding: 6px 0; }
.g-facet h3 { margin: 0; font-size: .875rem; }
.g-facet h3 button { all: unset; cursor: pointer; display: flex; width: 100%; align-items: center; gap: 6px; font-weight: 700; padding: 3px 0; }
.g-facet h3 button:focus-visible { outline: var(--focus-w) solid var(--focus); }
.g-chev { margin-left: auto; color: var(--muted); }
.g-facet ul, .g-columns ul { list-style: none; margin: 4px 0 0; padding: 0; max-height: 240px; overflow: auto; }
.g-facet label, .g-columns label { display: flex; align-items: center; gap: 8px; padding: 3px 2px; cursor: pointer; }
.g-facet label span:first-of-type, .g-columns label span:first-of-type { flex: 1; overflow-wrap: anywhere; }
.g-count { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.g-count.on { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-pill); padding: 0 7px; }
.g-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; }
.g-total { font-size: 1.15rem; }
.g-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.g-panel { padding: 0; overflow: hidden; }
.g-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: var(--hairline) solid var(--line); }
.g-toolbar button, .g-head button { padding: 5px 11px; font-size: .875rem; }
.g-inline { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; color: var(--muted); }
.g-inline select, .g-status select { width: auto; padding: 4px 8px; }
.g-seg { display: inline-flex; border: var(--control-border-w) solid var(--control-line); border-radius: var(--radius); box-shadow: var(--shadow-control); overflow: hidden; }
.g-seg button { border: 0; border-radius: 0; box-shadow: none; transform: none; border-left: var(--control-border-w) solid var(--control-line); }
.g-seg button:first-child { border-left: 0; }
.g-seg button[aria-pressed=true] { background: var(--seg-on-bg); color: var(--seg-on-ink); font-weight: 700; }
.g-split { display: flex; align-items: stretch; }
.g-body { flex: 1 1 auto; min-width: 0; }
.g-body .grid { padding: 12px; }
.g-columns { flex: 0 0 220px; border-left: var(--hairline) solid var(--line); background: var(--soft); padding: 10px 12px; font-size: .875rem; }
.g-columns ul { max-height: 60vh; }
.g-empty { padding: 36px 12px; text-align: center; }
.g-scroll { overflow: auto; max-height: 72vh; }
.g-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .875rem; }
.g-table th, .g-table td { border-bottom: var(--hairline) solid var(--line); padding: 8px 10px; white-space: nowrap; vertical-align: middle; background: var(--surface); }
.g-table.g-compact td { padding-block: 3px; } .g-table.g-roomy td { padding-block: 14px; }
.g-table thead th { position: sticky; top: 0; z-index: 2; background: var(--thead-bg); color: var(--thead-ink); border-right: var(--hairline) solid var(--thead-line); }
.g-table th button { all: unset; cursor: pointer; font-weight: 600; color: var(--thead-ink); }
.g-table th button:focus-visible { outline: var(--focus-w) solid var(--focus); }
.g-table .g-pin { position: sticky; left: 0; z-index: 1; min-width: 280px; max-width: 420px; white-space: normal; box-shadow: var(--hairline) 0 0 var(--line); }
.g-table thead .g-pin { z-index: 3; }
.g-pinwrap { display: flex; align-items: center; gap: 10px; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.g-links { display: inline-flex; gap: 2px; }
.g-links a { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius-pill); }
.g-links a:hover, .g-links a:focus-visible { background: var(--soft); }
.rlinks { list-style: none; padding: 0; display: grid; gap: 6px; }
.rlinks a { display: inline-flex; align-items: center; gap: 8px; }
.g-table tbody tr:hover td { background: var(--row-hover); }
.g-table tr.g-sel td { background: var(--row-selected); }
.g-table .g-group td { background: var(--soft); padding: 5px 10px; }
.g-group button { all: unset; cursor: pointer; }
.g-group button:focus-visible { outline: var(--focus-w) solid var(--focus); }
.g-art { flex: 0 0 auto; width: 30px; height: 44px; border-radius: var(--radius-thumb); overflow: hidden; background: var(--soft); border: var(--hairline) solid var(--line); }
.g-compact .g-art { width: 18px; height: 26px; } .g-roomy .g-art { width: 40px; height: 60px; }
.g-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-book { min-width: 0; } .g-book a { color: var(--ink); text-decoration: none; } .g-book a:hover { text-decoration: underline; }
.g-book small { display: block; color: var(--muted); }
.g-status { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 8px 12px; border-top: var(--hairline) solid var(--line); background: var(--soft); font-size: .8rem; color: var(--muted); }
.g-status b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- Theme picker (both shells) ---- */
.theme-picker { position: relative; }
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; }
.theme-btn svg { width: 20px; height: 20px; display: block; }
.theme-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: max-content; min-width: 220px;
  max-width: calc(100vw - 32px); padding: 6px; background: var(--surface); color: var(--ink);
  border: var(--border-w) solid var(--panel-line); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.theme-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none;
  box-shadow: none; text-align: left; border-radius: var(--radius-sm); font-family: var(--font-body); font-weight: 400; }
.theme-opt:active { transform: none; }
.theme-opt:hover, .theme-opt:focus-visible { background: var(--soft); }
.theme-menu .theme-opt:focus-visible { outline-color: var(--focus); outline-offset: -3px; }
.theme-opt[aria-checked=true] { font-weight: 700; }
.theme-swatch { flex: 0 0 auto; width: 40px; height: 20px; display: block; border: var(--hairline) solid var(--control-line);
  border-radius: var(--radius-thumb); }
.theme-name { flex: 1 1 auto; }
.theme-check { flex: 0 0 auto; width: 16px; height: 16px; visibility: hidden; }
.theme-opt[aria-checked=true] .theme-check { visibility: visible; }
[hidden] { display: none !important; }

/* ==== Scan intake (templates/inventory/scan.html, static/js/scan.js) — begin ==== */
.scan-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.scan h2 { margin: 0 0 8px; }
.scan button, .scan .btn { min-height: 48px; padding: 10px 16px; }
.scan input[type=text], .scan select { min-height: 48px; font-size: 1rem; }
.scan kbd { font: .75rem ui-monospace, monospace; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 6px; opacity: .85; }
@media (pointer: coarse) { .scan kbd { display: none; } }
.scan-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 0; }
.scan-big { flex: 1 1 180px; font-weight: 600; font-size: 1.05rem; min-height: 56px; }
.scan-session { position: sticky; top: 0; z-index: 5; padding: 10px 14px; }
.scan-where, .scan-counts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; }
.scan-counts { margin-top: 4px; font-size: .9rem; }
.scan-counts b { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.scan-counts a { color: var(--ink); display: inline-block; padding: 10px 0; margin: -10px 0; }
.scan-session summary { cursor: pointer; padding: 10px 0 4px; color: var(--accent); min-height: 44px; }
.scan-setup-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; align-items: end; }
.scan-setup-form .scan-row, .scan-setup-form > p { grid-column: 1 / -1; }
.scan-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .scan-cols { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.scan-cols > .card { margin-bottom: 0; }
.scan-cols + .card { margin-top: 14px; }
.scan-stage { position: relative; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  min-height: 180px; max-height: 62vh; display: flex; align-items: center; justify-content: center; }
.scan-stage video, .scan-stage img { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: var(--soft); }
.scan-stage[data-state=off] video, .scan-stage[data-state=shot] video { display: none; }
.scan-stage[data-state=live] video { cursor: pointer; }
.scan-stage[data-state=live] { border: 3px solid var(--ok); }
.scan-stage p { padding: 16px; text-align: center; margin: 0; }
.scan-camstate { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-weight: 600; }
.scan-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); }
.scan-camstate[data-on="1"] { color: var(--ok); }
.scan-camstate[data-on="1"] .scan-dot { background: var(--ok); border-color: var(--ok); }
.scan-note, .scan-alert, .scan-error, .scan-warn { border: 1px solid var(--line); border-left: 6px solid var(--warn); background: var(--soft);
  border-radius: var(--radius); padding: 10px 12px; margin: 0 0 10px; }
.scan-alert, .scan-error { border-left-color: var(--accent); }
.scan-alert p { margin: 0; }
.scan-filebtn { display: inline-flex; align-items: center; }
#scan-file:focus-visible + .scan-filebtn { outline: 3px solid var(--accent); outline-offset: 2px; }
.scan-find label, .scan-supp label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: 3px; }
.scan-findrow { display: flex; gap: 8px; }
.scan-findrow input { flex: 1 1 auto; min-width: 0; }
.scan-panel { margin-top: 12px; }
.scan-panel > p:first-child { margin-top: 0; }
.scan-supp { margin: 0 0 12px; }
.scan-book { container-type: inline-size; }
.scan-cands { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.scan-cand { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; gap: 10px; background: var(--surface); min-width: 0; }
/* Side by side when the column has room; stacked rows on a phone. */
@container (min-width: 360px) {
  .scan-cands[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-cands[data-n="2"] .scan-cand { flex-direction: column; }
}
@container (min-width: 460px) {
  .scan-cands[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scan-cands[data-n="3"] .scan-cand { flex-direction: column; }
}
.scan-cand-art { flex: 0 0 84px; }
.scan-cand-art img, .scan-cand-art .titlecard { width: 84px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line);
  background: var(--soft); display: flex; flex-direction: column; justify-content: center; font-size: .75rem; padding: 4px; }
.scan-cand-art img { padding: 0; }
.scan-cand-body { flex: 1 1 auto; min-width: 0; }
.scan-cand h3 { margin: 0; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.scan-cand p { margin: 4px 0; }
.scan-cand dl.facts { margin: 6px 0; }
.scan-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.scan-identity { margin-top: 4px; }
.scan-secondary { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; }
.scan-done { border: 2px solid var(--ok); border-radius: var(--radius); padding: 10px 12px; }
.scan-done p { margin: 0 0 4px; }
.scan-done-head { font-size: 1.1rem; }
.scan-recent { margin: 0; padding-left: 2.2em; }
.scan-recent li { overflow-wrap: anywhere; }
.scan-recent li a { display: inline-block; padding: 11px 0; }
@media (max-width: 480px) { .scan .card { padding: 10px; } .scan-big { flex-basis: 100%; } }
/* ==== Scan intake — end ==== */
