:root {
  --bg: #f3efe6;
  --ink: #141414;
  --muted: #3d3d3d;
  --card: #fffdf8;
  --line: #cfc6b4;
  --accent: #1b5e3b;
  --accent-hover: #14472d;
  --accent-text: #ffffff;
  --danger: #8b1e1e;
  --ok-bg: #e5f3ea;
  --err-bg: #f8e4e4;
  --out: #7a4b00;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
}

a { color: var(--accent); }

.wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
}

.site-header a,
.site-header .who,
.site-header summary {
  color: var(--accent-text);
  text-decoration: none;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.who { opacity: 0.95; font-weight: 700; }

.menu { position: relative; }
.menu summary {
  cursor: pointer;
  list-style: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after {
  content: "";
  display: inline-block;
  margin-left: 0.35rem;
  border: 0.28rem solid transparent;
  border-top-color: currentColor;
  transform: translateY(0.12rem);
}
.menu-panel {
  position: absolute;
  right: 0;
  top: 1.6rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 9rem;
  padding: 0.4rem;
  z-index: 5;
}
.menu-panel a {
  display: block;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  text-decoration: none;
}

h1 {
  font-size: 1.7rem;
  line-height: 1.15;
  margin: 0.4rem 0 0.8rem;
}

.scan-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin: 0 0 0.85rem;
}
.scan-heading h1 {
  margin: 0;
  padding: 0;
  font-size: 1.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
}
.scan-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1em;
  font-size: 1.85rem;
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
}
.scan-heading .pill,
.scan-heading .you-have {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  line-height: 1;
  margin: 0;
}
.you-have { font-weight: 800; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 650;
}

.checks-wrap {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.checks-wrap legend {
  font-weight: 650;
  padding: 0;
  margin-bottom: 0.15rem;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  font-weight: 600;
}
label.check input {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  accent-color: var(--accent);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="file"],
select,
textarea {
  font: inherit;
  padding: 0.7rem 0.75rem;
  border: 2px solid #222;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}

.btn-primary,
.btn-secondary,
.btn-danger,
button.btn-primary,
button.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  min-height: 44px;
  background: transparent;
  color: var(--ink);
  border-color: #222;
  font-weight: 700;
  margin-top: 0.5rem;
}

.btn-inline { width: auto; min-width: 8rem; }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.flash {
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 650;
  border: 2px solid #222;
}
.flash-ok { background: var(--ok-bg); }
.flash-error { background: var(--err-bg); }

.hero-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0 0 1rem;
  padding: 0.6rem;
  background: #e6e0d4;
  border: 2px solid var(--line);
  border-radius: 12px;
  box-sizing: border-box;
}
.hero {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(70vh, 24rem);
  object-fit: contain;
  object-position: center;
  background: transparent;
  border: none;
}
.hero-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 10rem;
  color: var(--muted);
  font-weight: 700;
}
.scan-meta {
  margin: 0.9rem 0 0.5rem;
  color: var(--ink);
  font-weight: 800;
}
.scan-identity {
  margin: 0 0 0.2rem;
  font-size: 1.2rem;
}
.scan-edit {
  font-size: 0.95rem;
  font-weight: 700;
  margin-left: 0.35rem;
  white-space: nowrap;
}
.scan-where {
  margin: 0;
  font-size: 0.95rem;
}
.scan-pipe {
  padding: 0 0.2rem;
  font-weight: 800;
}
.scan-rule {
  border: 0;
  border-top: 2px solid #222;
  margin: 0.75rem 0;
}
.scan-desc {
  margin: 0.75rem 0;
  white-space: pre-wrap;
}
.mfr-link { margin: 0.6rem 0 0.85rem; }
.scan .files h2 { margin-top: 0.4rem; }

.tiny, .hint, .muted { color: var(--muted); font-weight: 500; }
.tiny { font-size: 0.95rem; }
.hint { font-size: 0.9rem; margin: -0.4rem 0 0.4rem; }

.btn-quiet {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid var(--accent);
  background: #fff;
  color: var(--accent);
  text-align: center;
}
.add-tool-home {
  width: auto;
  min-height: 44px;
  margin-top: 0.6rem;
}
.file-btn { position: relative; }
.file-btn input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  min-height: 0;
}
.cover-preview {
  display: block;
  width: 100%;
  max-height: 16rem;
  object-fit: contain;
  background: #e6e0d4;
  border-radius: 12px;
  border: 2px solid var(--line);
}
.quiet-label { font-weight: 500; color: var(--muted); }
.lookup-msg { font-weight: 700; margin: 0; }
.add-another { margin: 0.2rem 0 0.8rem; }
.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
  padding: 0.4rem 0;
  text-align: left;
}
.badge-review {
  display: inline-block;
  margin: 0 0.35rem;
  padding: 0.1rem 0.45rem;
  border: 2px solid #222;
  border-radius: 999px;
  background: #f3e2b8;
  color: #141414;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}
[hidden] { display: none !important; }

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tool-list { list-style: none; padding: 0; margin: 1rem 0; }
.tool-list li { margin: 0 0 0.6rem; }
.tool-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem;
  background: var(--card);
  border: 2px solid #222;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  min-height: 88px;
}
.tool-row img,
.thumb-ph {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: #d9d2c4;
  display: block;
}
.tool-meta { display: flex; flex-direction: column; gap: 0.15rem; }
.pill {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  white-space: nowrap;
}
.pill-ok { color: var(--accent); }
.pill-out { color: var(--out); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.2rem 0.7rem;
  border: 2px solid #222;
  border-radius: 999px;
  text-decoration: none;
  color: inherit;
  font-size: 0.9rem;
}
.chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

.files h2 { font-size: 1.1rem; margin-top: 1.5rem; }
.files ul { list-style: none; padding: 0; }
.files li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.kind {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0 0 1rem;
  font-weight: 750;
}

.row, .row-between {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.row-between { justify-content: space-between; }
.row .btn-secondary, .row .btn-primary, .row-between .btn-primary { width: auto; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
}
th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.mono { font-family: var(--mono); letter-spacing: 0.04em; }
.actions a { margin-right: 0.6rem; }
.linkish {
  background: none;
  border: none;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.edit-cover { width: 8rem; border-radius: 8px; }
.file-admin form { display: inline; }
.danger-zone { margin-top: 2rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.label-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  border: 1px dashed #888;
  padding: 0.08in 0.06in 0.07in;
  page-break-inside: avoid;
  break-inside: avoid;
  background: #fff;
  color: #000;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.label-name {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 1.15;
  max-height: 2.3em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0 0 0.05in;
  max-width: 100%;
}
.label-qr-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
}
.label-qr {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  background: #fff;
}
.label-home {
  flex: 0 0 auto;
  margin: 0.05in 0 0;
  font-size: 0.62rem;
  line-height: 1.2;
  font-weight: 700;
  max-width: 100%;
}

.sheet-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.sheet {
  display: grid;
  justify-content: start;
  justify-items: stretch;
  align-items: stretch;
  gap: 0.12in;
  width: max-content;
  max-width: 100%;
  margin: 1rem auto;
  background: #fff;
  padding: 0.4rem;
  box-sizing: border-box;
}
.sheet.size-small {
  grid-template-columns: repeat(4, 2.0in);
  grid-auto-rows: 2.5in;
}
.sheet.size-small .label-qr { width: 1.85in; height: 1.85in; max-width: 100%; max-height: 100%; }
.sheet.size-standard {
  grid-template-columns: repeat(3, 2.5in);
  grid-auto-rows: 3.2in;
}
.sheet.size-standard .label-qr { width: 2.5in; height: 2.5in; max-width: 100%; max-height: 100%; }
.sheet.size-large {
  grid-template-columns: repeat(2, 3.5in);
  grid-auto-rows: 4.8in;
}
.sheet.size-large .label-qr { width: 4.0in; height: 4.0in; max-width: 100%; max-height: 100%; }
.sheet.sheet-single.size-small {
  grid-template-columns: 2.0in;
  grid-auto-rows: 2.5in;
}
.sheet.sheet-single.size-standard {
  grid-template-columns: 2.5in;
  grid-auto-rows: 3.2in;
}
.sheet.sheet-single.size-large {
  grid-template-columns: 3.5in;
  grid-auto-rows: 4.8in;
}
.sheet.size-small .label-cell:nth-child(16n) { break-after: page; page-break-after: always; }
.sheet.size-standard .label-cell:nth-child(9n) { break-after: page; page-break-after: always; }
.sheet.size-large .label-cell:nth-child(4n) { break-after: page; page-break-after: always; }

.queue-list { list-style: none; padding: 0; }
.queue-list li { display: flex; gap: 0.8rem; align-items: center; }

@media (min-width: 720px) {
  .search-form { flex-direction: row; }
  .search-form .btn-primary { width: auto; min-width: 8rem; }
}

@media print {
  .no-print, .site-header, .flash, .admin-nav { display: none !important; }
  body, .wrap { background: #fff; color: #000; max-width: none; padding: 0; margin: 0; }
  a { color: inherit; text-decoration: none; }
  .sheet-wrap { overflow: visible; }
  .sheet {
    gap: 0;
    padding: 0;
    margin: 0;
    max-width: none;
  }
  .label-cell { border: 1px solid #ddd; }
  .sheet.size-small { grid-template-columns: repeat(4, 2.0in); }
  .sheet.size-standard { grid-template-columns: repeat(3, 2.5in); }
  .sheet.size-large { grid-template-columns: repeat(2, 3.5in); }
  .sheet.sheet-single.size-small { grid-template-columns: 2.0in; }
  .sheet.sheet-single.size-standard { grid-template-columns: 2.5in; }
  .sheet.sheet-single.size-large { grid-template-columns: 3.5in; }
}

@page {
  size: letter;
  margin: 0.5in;
}
