:root {
  --bg: #f7f7f8; --surface: #ffffff; --text: #1b1d22; --muted: #5d6370; --border: #d9dce1;
  --accent: #5865f2; --accent-text: #ffffff; --danger: #c62828; --ok: #1e7d3a; --warn-bg: #fff4d6;
  --focus: #2f6fed; --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b; --surface: #1f2227; --text: #e8eaee; --muted: #a2a8b3; --border: #343841;
    --accent: #7c86ff; --accent-text: #0e1020; --danger: #ff6b6b; --ok: #5bd17d; --warn-bg: #3a3218;
    --focus: #8ab4ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
a { color: var(--accent); }
img { max-width: 100%; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .25rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }

.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.topbar nav a { text-decoration: none; }
main { max-width: 960px; margin: 0 auto; padding: 1rem; }
form.inline { display: inline; margin: 0; }

.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.button.danger { color: var(--danger); border-color: var(--danger); }
.button.small { min-height: 36px; padding: .25rem .75rem; font-size: .9rem; }
button.link { background: none; border: 0; min-height: 0; padding: 0; color: var(--accent); }
button[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }

.flash { background: var(--surface); border-left: 4px solid var(--ok); padding: .5rem .75rem; border-radius: 4px; }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.note.warn { background: var(--warn-bg); }
.errors { border: 2px solid var(--danger); border-radius: var(--radius); padding: .5rem 1rem; margin-bottom: 1rem; }
.errors p { margin: .25rem 0; color: var(--danger); }
.hero { max-width: 38rem; margin: 2rem auto; }
.hero h1 { font-size: 1.75rem; }
.empty { padding: 2rem 0; }

.page-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.page-head h1 { margin: .5rem 0; }
.page-head .actions { margin: 0; }
.items { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.item { display: flex; gap: .75rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem; min-width: 0; }
.thumb { width: 88px; height: auto; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 4.5% / 3.2%; flex: none; }
.item-body { min-width: 0; flex: 1; }
.qty { color: var(--muted); font-weight: 400; }
.facts { margin: .25rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .1rem .75rem; font-size: .9rem; }
.facts div { display: flex; gap: .35rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.stock { margin: .5rem 0; padding: .4rem .6rem; border-radius: 6px; border-left: 4px solid var(--ok); font-size: .9rem; }
.stock strong { color: var(--ok); }
.stock ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.item-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.confirm { display: flex; gap: 1rem; align-items: flex-start; }

.stack > * + * { margin-top: .75rem; }
label { display: block; font-weight: 600; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; min-height: 44px; padding: .5rem .6rem;
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; resize: vertical; }
input[type=checkbox] { display: inline-block; width: 1.25rem; height: 1.25rem; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
label.check { display: flex; gap: .6rem; align-items: center; font-weight: 400; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0 .25rem; }

.search { position: relative; }
.results { position: absolute; z-index: 10; left: 0; right: 0; list-style: none; margin: .25rem 0 0; padding: .25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18); max-height: 60vh; overflow-y: auto; }
.results button { width: 100%; justify-content: flex-start; gap: .6rem; border: 0; text-align: left; min-height: 48px; }
.results button:hover, .results button[aria-selected=true] { background: var(--bg); }
.results img { width: 40px; height: auto; aspect-ratio: 63 / 88; object-fit: contain; border-radius: 3px; }
.stock-chip { margin-left: auto; font-size: .75rem; font-weight: 700; color: var(--ok); border: 1px solid var(--ok); border-radius: 999px; padding: 0 .45rem; }
.selected { display: flex; gap: .75rem; align-items: center; }
.selected[hidden], fieldset[hidden], .results[hidden] { display: none; }
.printings { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  max-height: 26rem; overflow-y: auto; }
label.printing { display: flex; gap: .5rem; align-items: center; font-weight: 400; padding: .35rem;
  border: 1px solid var(--border); border-radius: 8px; }
label.printing:has(input:checked) { border-color: var(--accent); }
label.printing img { width: 44px; height: auto; aspect-ratio: 63/88; border-radius: 3px; }

.review { list-style: none; padding: 0; margin: 0; }
.line { padding: .5rem; border-bottom: 1px solid var(--border); }
.line .mini { width: 44px; height: auto; aspect-ratio: 63/88; border-radius: 3px; }
.line span small { display: block; color: var(--muted); }
.line.bad { color: var(--danger); }
.line.bad small { display: block; }
.line code { white-space: pre-wrap; }
.tag { font-weight: 700; font-size: .8rem; border: 1px solid var(--danger); border-radius: 4px; padding: 0 .3rem; }
.warn-text { color: var(--danger) !important; }

@media (max-width: 420px) {
  main { padding: .75rem; }
  .thumb { width: 72px; }
  h1 { font-size: 1.3rem; }
}

/* "I bought these" ticks on the wish list */
.bought-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.bought-tick { display: inline-flex; vertical-align: middle; margin-right: .35rem; cursor: pointer; }
.bought-tick input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: currentColor; }
