:root {
  color-scheme: light;
  --ink: #292a25;
  --muted: #73746b;
  --paper: #f7f5ef;
  --surface: #fffefa;
  --line: #e7e2d7;
  --olive: #47543d;
  --olive-dark: #35402e;
  --clay: #9a5c3f;
  --danger: #a64535;
  --shadow: 0 12px 32px rgb(42 38 29 / 7%);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 12% 0%, rgb(214 200 163 / 20%), transparent 31rem),
    var(--paper);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--clay); }

.site-header {
  background: rgb(255 254 250 / 90%);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  width: min(1120px, calc(100% - 40px));
  min-height: 72px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.brand, .header-actions, .detail-actions, .form-actions, .pagination {
  display: flex;
  align-items: center;
}

.brand { gap: 11px; font-size: 15px; letter-spacing: -.02em; }
.brand strong { font-weight: 700; }

.brand-mark, .empty-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--olive);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 12px;
  letter-spacing: .04em;
}

.header-actions { gap: 22px; }
.header-actions form { margin: 0; }
.nav-link { font-size: 13px; font-weight: 600; color: var(--muted); }
.nav-button, .text-button { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.nav-button:hover { color: var(--clay); }

.page-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: calc(42px + env(safe-area-inset-top)) 0 calc(72px + env(safe-area-inset-bottom)); }
.page-heading, .detail-heading, .section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.page-heading { margin-bottom: 28px; }
.page-heading h1, .detail-heading h1, .form-heading h1, .login-card h1, .confirm-card h1 { margin: 4px 0 8px; font-size: clamp(30px, 4vw, 42px); line-height: 1.1; letter-spacing: -.045em; }
.eyebrow { margin: 0; color: var(--clay); font-size: 10px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.subheading { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.button {
  display: inline-flex;
  min-height: 44px;
  justify-content: center;
  align-items: center;
  padding: 0 18px;
  border: 1px solid var(--olive);
  border-radius: 7px;
  background: var(--olive);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}

.button:hover { color: white; background: var(--olive-dark); transform: translateY(-1px); }
.button-small { min-height: 36px; padding: 0 14px; font-size: 12px; }
.button-dark { background: #353832; border-color: #353832; }
.button-outline { background: transparent; color: var(--olive); }
.button-outline:hover { background: #eef0e9; color: var(--olive-dark); }
.button-danger { background: var(--danger); border-color: var(--danger); }
.button-danger-outline { min-height: 40px; padding: 0 14px; background: transparent; border-color: #e4cfc8; color: var(--danger); font-size: 12px; }
.button-danger-outline:hover { background: #fbefec; color: var(--danger); }
.button-block { width: 100%; }

.search-bar { display: flex; gap: 10px; margin-bottom: 24px; }
.search-bar .form-input { max-width: 470px; }
.clear-link { align-self: center; color: var(--muted); font-size: 13px; }
.form-input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #dcd7ca;
  border-radius: 6px;
  outline: none;
  background: #fffefa;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.form-input:focus { border-color: var(--olive); box-shadow: 0 0 0 3px rgb(71 84 61 / 12%); }
textarea.form-input { min-height: 96px; resize: vertical; }

.inventory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.item-card { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 3px 12px rgb(42 38 29 / 3%); transition: transform .18s ease, box-shadow .18s ease; }
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-image { display: grid; place-items: center; height: 190px; overflow: hidden; background: #eeeae0; }
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.image-placeholder { color: #8d8a7e; font: 28px Georgia, serif; }
.card-content { padding: 16px 17px 18px; }
.card-title-row { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.card-title-row h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.status-tag { display: inline-block; flex: 0 0 auto; padding: 5px 8px; border-radius: 20px; background: #edf0e8; color: var(--olive); font-size: 10px; font-weight: 700; }
.item-meta { min-height: 20px; margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.item-price { margin: 13px 0 0; font-size: 14px; font-weight: 750; }
.empty-state { padding: 64px 20px; text-align: center; border: 1px dashed #d7d1c3; border-radius: 10px; background: rgb(255 254 250 / 62%); }
.empty-mark { width: 50px; height: 50px; margin-bottom: 16px; font-size: 15px; }
.empty-state h2 { margin: 0 0 8px; font-size: 21px; }
.empty-state p { margin: 0 auto 20px; max-width: 420px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.pagination { justify-content: center; gap: 18px; margin-top: 30px; color: var(--muted); font-size: 12px; }
.pagination .button { min-height: 36px; font-size: 12px; }

.back-link { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.detail-heading { align-items: center; margin-bottom: 36px; }
.detail-actions { justify-content: end; flex-wrap: wrap; gap: 9px; }
.detail-section { margin: 0 0 30px; padding: 24px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.section-heading { align-items: center; margin-bottom: 22px; }
.section-heading h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.03em; }
.count { display: inline-grid; place-items: center; width: 25px; height: 25px; margin-left: 5px; border-radius: 50%; background: #f1eee5; color: var(--muted); font-size: 11px; vertical-align: 2px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 34px; margin: 0; }
.detail-grid div { min-width: 0; }
.detail-grid dt { margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.detail-grid dd { margin: 0; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.detail-wide { grid-column: 1 / -1; }
.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.photo-card { overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 7px; background: white; }
.photo-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #eeeae0; }
.photo-card figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 10px; font-size: 11px; }
.photo-card figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-button { color: var(--muted); font-size: 11px; }
.text-danger { color: var(--danger); }
.muted-copy { color: var(--muted); font-size: 13px; }
.photo-upload-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); }
.photo-upload-form .form-input { font-size: 12px; }

.form-page { max-width: 820px; margin: 0 auto; }
.form-heading { margin-bottom: 22px; }
.panel, .confirm-card { padding: 26px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px 16px; }
.form-field { min-width: 0; }
.form-field-wide { grid-column: 1 / -1; }
.form-field label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 700; }
.optional, .help-text { color: var(--muted); font-size: 11px; font-weight: 400; }
.required-mark { color: var(--clay); }
.help-text { margin: 6px 0 0; }
.field-error { margin: 6px 0 0; color: var(--danger); font-size: 12px; }
.form-errors { padding: 11px 13px; border-radius: 5px; background: #fbefec; color: var(--danger); font-size: 13px; }
.form-actions { justify-content: end; gap: 10px; margin-top: 24px; }
.confirm-card { max-width: 560px; margin: 60px auto; }
.confirm-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }

.login-wrap { display: grid; place-items: center; min-height: min(68vh, 680px); }
.login-card { width: min(420px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.brand-mark-large { width: 44px; height: 44px; margin-bottom: 24px; font-size: 14px; }
.login-card h1 { font-size: 32px; }
.login-form { display: grid; gap: 18px; margin-top: 25px; }
.login-form input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #dcd7ca; border-radius: 6px; background: #fffefa; color: var(--ink); font: inherit; }
.login-form input:focus { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px rgb(71 84 61 / 12%); }
.messages { margin-bottom: 18px; }
.message { margin: 0; padding: 12px 15px; border: 1px solid #dbe2d3; border-radius: 6px; background: #f0f3eb; color: var(--olive-dark); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .inventory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-heading { align-items: start; flex-direction: column; }
  .detail-actions { justify-content: start; }
}

@media (max-width: 560px) {
  .header-inner, .page-shell { width: min(100% - 28px, 1120px); }
  .header-inner { min-height: 64px; }
  .brand { gap: 8px; font-size: 13px; }
  .header-actions { gap: 11px; }
  .header-actions .nav-link { font-size: 11px; }
  .button-small { min-height: 33px; padding: 0 10px; font-size: 11px; }
  .page-shell { padding-top: 30px; }
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .inventory-grid { grid-template-columns: 1fr; gap: 13px; }
  .card-image { height: 210px; }
  .search-bar { flex-wrap: wrap; }
  .search-bar .form-input { max-width: none; flex: 1 1 100%; }
  .search-bar .button { flex: 1; }
  .detail-section { padding: 18px; }
  .detail-grid { grid-template-columns: 1fr; gap: 17px; }
  .detail-wide { grid-column: auto; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-upload-form { grid-template-columns: 1fr; }
  .photo-upload-form .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field-wide { grid-column: auto; }
  .panel, .login-card, .confirm-card { padding: 21px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .button { flex: 1; }
}

/* Filters, review flags, and grouped forms */
.filter-bar { flex-wrap: wrap; align-items: center; }
.filter-bar select.form-input { width: auto; max-width: 200px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.review-flag { display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 20px; background: #fbefe2; color: var(--clay); font-size: 10px; font-weight: 700; }
.status-sold, .status-given_away, .status-discarded { background: #efece6; color: var(--muted); }
.status-wanted { background: #eef0f7; color: #4a5378; }
.review-callout { margin-bottom: 20px; padding: 16px 18px; border: 1px solid #ecd6c2; border-radius: 7px; background: #fdf6ee; }
.review-callout h2 { margin: 0 0 6px; font-size: 15px; color: var(--clay); }
.review-callout p { margin: 4px 0; font-size: 13px; line-height: 1.55; }
.source-row { margin: 0 0 24px; font-size: 12px; color: var(--muted); }
.source-row summary { cursor: pointer; }
.source-row ol { margin: 8px 0 0; line-height: 1.6; }
.form-section { margin: 0 0 22px; padding: 0; border: 0; }
.form-section legend { margin-bottom: 12px; color: var(--clay); font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.form-field-check label { display: flex; align-items: center; gap: 8px; margin-top: 26px; font-weight: 600; }
.form-field[hidden] { display: none; }
