:root {
  color-scheme: light dark;
  --ground: #FBFBFA;
  --well: #F1F1EE;
  --well-hover: #EAEAE6;
  --surface: #FFFFFF;
  --ink: #1B1B1A;
  --muted: #6A6A65;
  --line: #E7E7E3;
  --control-line: #D2D2CD;
  --on-ink: #FFFFFF;
  --danger: #A82E0A;
  --seg-0: #1B1B1A;
  --seg-1: #55554F;
  --seg-2: #85857E;
  --seg-3: #A9A9A3;
  --seg-4: #C6C6C0;
  --seg-5: #DADAD5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #131312;
    --well: #1D1D1B;
    --well-hover: #252523;
    --surface: #1A1A18;
    --ink: #EFEFEB;
    --muted: #A0A099;
    --line: #2A2A27;
    --control-line: #41413D;
    --on-ink: #131312;
    --danger: #FF8A65;
    --seg-0: #EFEFEB;
    --seg-1: #C3C3BD;
    --seg-2: #9A9A94;
    --seg-3: #74746F;
    --seg-4: #55554F;
    --seg-5: #3E3E3A;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { padding: 0 clamp(16px, 3vw, 40px) 72px; max-width: 1480px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 28px; min-height: 60px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.brand { font-size: 14px; font-weight: 500; text-decoration: none; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 0 20px; flex: 1 1 240px; }
.nav a { color: var(--muted); text-decoration: none; padding: 11px 0; transition: color .14s ease; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current] { color: var(--ink); font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 14px;
  background: transparent; border: 1px solid var(--control-line); border-radius: 8px;
  font-size: 14px; font-weight: 450; color: var(--ink); text-decoration: none; cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, opacity .14s ease;
}
.btn:hover { background: var(--well); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink); opacity: .86; }
.btn-quiet { border-color: transparent; color: var(--muted); padding: 0 8px; }
.btn-quiet:hover { background: transparent; color: var(--ink); }
.btn-danger { color: var(--danger); border-color: var(--control-line); }
.btn-large { min-height: 48px; padding: 0 20px; }
.link-button { background: none; border: 0; padding: 8px 0; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.grow { flex: 1 1 220px; }

label { display: block; font-size: 13px; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; min-height: 44px; margin-top: 5px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--control-line); border-radius: 8px; font-size: 15px; color: var(--ink);
  transition: border-color .14s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input[type="file"] { padding: 9px 10px; font-size: 13px; }
.row select { width: auto; margin-top: 0; }
textarea { resize: vertical; }
summary { min-height: 28px; font-size: 14px; font-weight: 450; cursor: pointer; }

/* Summary */
.summary { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 48px; padding: 36px 0 20px; }
.display { font-size: clamp(32px, 3.4vw, 40px); line-height: 1.1; font-weight: 500; letter-spacing: -0.03em; margin-top: 4px; }
.stats { display: flex; flex-wrap: wrap; gap: 14px 36px; margin: 0; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 2px 0 0; font-weight: 500; font-size: 15px; }

.strip { display: flex; gap: 2px; height: 3px; margin-bottom: 28px; border-radius: 2px; overflow: hidden; animation: strip-in .7s cubic-bezier(.2, .7, .2, 1) both; transform-origin: left; }
.strip-seg { flex: 0 0 auto; width: var(--share); min-width: 3px; }
.seg-0 { background: var(--seg-0); } .seg-1 { background: var(--seg-1); } .seg-2 { background: var(--seg-2); }
.seg-3 { background: var(--seg-3); } .seg-4 { background: var(--seg-4); } .seg-5 { background: var(--seg-5); }
@keyframes strip-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; margin-bottom: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--muted); text-decoration: none; box-shadow: inset 0 -1px 0 transparent; transition: color .14s ease; }
.chip:hover { color: var(--ink); }
.chip span { font-size: 12px; opacity: .75; }
.chip[aria-current] { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--ink); }
.search { flex: 0 1 280px; min-width: 200px; }
.search input { margin-top: 0; }

/* Library grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 36px 20px; }
.card { display: block; min-width: 0; text-decoration: none; animation: card-in .4s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i) * 24ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card h2 { margin-top: 12px; font-size: 14px; line-height: 1.35; font-weight: 500; }
.card-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; }
.card-line strong { font-weight: 500; }
.card-line .muted { text-align: right; }

.well { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--well); border-radius: 10px; color: var(--muted); transition: background-color .18s ease; }
.well img { width: 100%; height: 100%; object-fit: contain; padding: 10%; mix-blend-mode: multiply; transition: transform .35s cubic-bezier(.2, .7, .2, 1); }
.card:hover .well { background: var(--well-hover); }
.card:hover .well img { transform: scale(1.03); }
.qty { position: absolute; left: 10px; top: 8px; font-size: 12px; color: var(--muted); }
.no-photo { font-size: 12px; }
/* Product photos have white backgrounds, so they need a light surface to blend into, even in dark mode. */
.well:has(img) { background: #F1F1EE; }
.card:hover .well:has(img) { background: #EAEAE6; }
.well:has(img) .qty { color: #5C5C57; }

.empty { padding: 56px 0; display: grid; gap: 10px; justify-items: start; }
.empty h2 { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }

/* Item */
.detail { display: flex; flex-wrap: wrap; gap: 32px 48px; padding-top: 32px; }
.well-large { flex: 1 1 320px; max-width: 560px; align-self: flex-start; }
.detail-body { flex: 999 1 400px; min-width: 0; max-width: 640px; display: grid; gap: 16px; align-content: start; }
.detail-body h1, .panel-page h1, .page-title { font-size: clamp(22px, 2.4vw, 28px); line-height: 1.2; font-weight: 500; letter-spacing: -0.02em; }
.facts { margin: 0; border-top: 1px solid var(--line); }
.facts > div { display: flex; justify-content: space-between; gap: 24px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }
.notes { white-space: pre-wrap; }
.panel { display: grid; gap: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; }
.panel h2 { font-size: 15px; font-weight: 500; }
.panel-page { max-width: 720px; margin: 24px 0 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.errors { color: var(--danger); font-size: 14px; }

/* Add flow */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; max-width: 980px; }
.add-note { max-width: 720px; margin: 16px 0; }
.add-scan { margin-top: 20px; }
.more-details > summary { color: var(--muted); }
.more-details[open] > summary { margin-bottom: 14px; }
.more-details > label { margin-top: 14px; }
details.panel[open] > summary { margin-bottom: 14px; }
.catalog-form { display: grid; gap: 16px; }
.catalog-results { display: grid; border-top: 1px solid var(--line); }
.catalog-result { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; transition: background-color .14s ease; }
.catalog-result:hover { background: var(--well); }
.catalog-result img, .catalog-noimage { flex: 0 0 48px; width: 48px; height: 48px; object-fit: contain; background: #FFFFFF; border-radius: 6px; }
.catalog-text { flex: 1 1 auto; min-width: 0; display: grid; }
.catalog-text strong { font-weight: 500; }
.catalog-price { flex: 0 0 auto; font-weight: 500; }
.preset-photo { display: flex; align-items: center; gap: 14px; color: var(--ink); font-size: 14px; }
.preset-photo img { width: 88px; height: 88px; object-fit: contain; padding: 6px; background: #FFFFFF; border-radius: 8px; }
.preset-photo span { display: flex; align-items: center; gap: 8px; }
.preset-photo input { width: 18px; height: 18px; min-height: 0; margin: 0; }

/* Tables and lists */
.table-box { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
th { text-align: left; font-weight: 400; color: var(--muted); font-size: 13px; }
th, td { padding: 11px 16px 11px 0; border-bottom: 1px solid var(--line); }
.num { text-align: right; }
.page-title { padding-top: 36px; margin-bottom: 20px; }
.location-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.location { display: grid; gap: 4px; padding: 16px; background: var(--well); border-radius: 10px; text-decoration: none; transition: background-color .14s ease; }
.location:hover { background: var(--well-hover); }
.location h2 { font-size: 14px; font-weight: 500; }
.location strong { font-weight: 500; }
.people { list-style: none; margin: 20px 0; padding: 0; border-top: 1px solid var(--line); }
.people li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.people strong { font-weight: 500; }
.notice { display: grid; gap: 10px; padding-top: 72px; justify-items: start; }
.notice h1 { font-size: 24px; font-weight: 500; letter-spacing: -0.02em; }

/* Scan: the viewfinder stays dark in both themes, so it reads as the camera rather than the page. */
.scanner { max-width: 520px; margin: 20px auto 0; display: grid; gap: 20px; }
.scanner-view { position: relative; aspect-ratio: 4 / 5; max-height: 62vh; width: 100%; overflow: hidden; background: #0C0C0B; border-radius: 14px; }
#reader { position: absolute; inset: 0; width: 100% !important; height: 100%; border: 0 !important; }
#reader video { display: block; width: 100% !important; height: 100% !important; object-fit: cover; }
#reader #qr-shaded-region { display: none !important; }
#reader img, #reader br { display: none; }
.scanner-target { position: absolute; left: 4%; right: 4%; top: 50%; aspect-ratio: 2 / 1; transform: translateY(-50%); border-radius: 8px; box-shadow: 0 0 0 100vmax rgba(12, 12, 11, .5); pointer-events: none; }
.corner { position: absolute; width: 24px; height: 24px; border: 0 solid #FFFFFF; transition: border-color .15s ease; }
.corner-tl { top: 0; left: 0; border-width: 2px 0 0 2px; border-top-left-radius: 8px; }
.corner-tr { top: 0; right: 0; border-width: 2px 2px 0 0; border-top-right-radius: 8px; }
.corner-bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; border-bottom-left-radius: 8px; }
.corner-br { bottom: 0; right: 0; border-width: 0 2px 2px 0; border-bottom-right-radius: 8px; }
.scanner-line { position: absolute; left: 14px; right: 14px; top: 8%; height: 1px; background: #FFFFFF; opacity: .8; animation: scanner-sweep 2.2s ease-in-out infinite alternate; }
@keyframes scanner-sweep { from { top: 8%; } to { top: 92%; } }
.scanner-status { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 8px 12px; background: rgba(12, 12, 11, .72); color: #FFFFFF; border-radius: 8px; font-size: 13px; line-height: 1.35; text-align: center; }
.scanner-view.is-found .corner { border-color: #7FE3A0; }
.scanner-view.is-found .scanner-line { display: none; }
.scanner-body { display: grid; gap: 12px; }
.scanner-body h1 { font-size: 22px; line-height: 1.2; font-weight: 500; letter-spacing: -0.02em; }
.scanner-photo { width: 100%; color: var(--on-ink); font-size: 14px; }
.scanner-type summary { color: var(--muted); padding: 8px 0; }
.scanner-type .row { margin-top: 10px; }

/* Sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin > .brand { display: none; }
.signin-main { width: 100%; max-width: 360px; display: grid; justify-items: start; gap: 10px; }
.signin-main .display { font-size: 24px; letter-spacing: -0.02em; margin: 0; }
.signin .lede { color: var(--muted); margin-bottom: 14px; }
.signin .btn { width: 100%; }
code { font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
