:root {
  --ink: #1a211c;
  --muted: #5c675f;
  --paper: #f3efe6;
  --card: #fbf8f2;
  --line: #d4cbbd;
  --teal: #0f3d3e;
  --danger: #7a2e2e;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #e8e0d1 0, transparent 240px),
    var(--paper);
  font: 17px/1.45 "Segoe UI", "Helvetica Neue", sans-serif;
}

h1, h2, h3 { font-weight: 500; }

h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 2.4rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lede, .summary, .meta, .notes, .empty {
  color: var(--muted);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--teal);
  border-radius: 4px;
  background: var(--teal);
  color: #f6f1e7;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--teal);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}

button.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #f6f1e7;
}

button:disabled { opacity: 0.6; cursor: wait; }

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.gate[hidden], #app[hidden] { display: none !important; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sheet {
  width: min(440px, 100%);
  margin: 0;
  padding: 28px 24px 22px;
  background: var(--card);
  border: 1px solid var(--line);
}

.sheet h1 { margin-bottom: 8px; }

.lede { margin: 0 0 18px; }

label {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  font-size: 0.92rem;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
}

textarea { min-height: 88px; resize: vertical; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input { width: auto; min-height: 0; }

.error {
  min-height: 1.3em;
  margin: 0 0 10px;
  color: var(--danger);
}

.form-actions, .header-actions, .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-actions { justify-content: flex-end; }

header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 24px 8px;
}

.search { margin: 0; flex: 1; }

.search input { min-width: 220px; background: var(--card); }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 24px 48px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #f6f1e7;
}

.chip .count { opacity: 0.75; }

.summary { margin: 0 0 8px; }

.place h2 {
  margin: 18px 0 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--teal);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gear {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto auto;
  gap: 8px 16px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

button.thumb, .thumb.empty {
  width: 72px;
  height: 72px;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #e7e0d4;
  color: var(--teal);
  font-family: Georgia, serif;
  font-size: 1.5rem;
}

.thumb img, #photo-preview, #viewer-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#photo-preview {
  width: 120px;
  height: 120px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.gear h3 { margin: 0; font-size: 1.05rem; }

.meta, .notes { margin: 2px 0 0; }

.notes { font-size: 0.92rem; }

.qty {
  margin: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.empty { margin: 24px 0; font-size: 1.05rem; }

dialog {
  padding: 0;
  border: none;
  background: transparent;
  max-width: calc(100vw - 24px);
}

dialog::backdrop { background: rgba(26, 33, 28, 0.48); }

.viewer-sheet {
  width: min(720px, 92vw);
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}

#viewer-img {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  background: #1a211c;
}

#viewer-close { margin-top: 12px; }

@media (max-width: 700px) {
  h1 { font-size: 2rem; }

  header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions { flex-wrap: wrap; }

  .search { flex: 1 1 100%; }

  .search input { min-width: 0; width: 100%; }

  .gear {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .qty { grid-column: 2; }

  .row-actions { grid-column: 1 / -1; }
}
