:root {
  --bg: #f2f8fd;
  --paper: #f2f8fd; /* same as the page background */
  --ink: #1d2433;
  --muted: #5d6578;
  --navy: #1f3a6b;
  --ribbon: #b8322a;
  --gold: #c99a3b;
  --line: #d3e1ee;
  --shadow: 0 1px 2px rgba(29,36,51,.06), 0 8px 24px rgba(29,36,51,.08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f;
    --paper: #1a1f2b;
    --ink: #ece6da;
    --muted: #a3a9b8;
    --navy: #8fb0e8;
    --ribbon: #e0645a;
    --gold: #d9b05a;
    --line: #2c3343;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; }

/* Masthead */
.masthead { text-align: center; padding: 56px 0 8px; }
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ribbon);
}
.masthead h1 {
  margin: 0;
  font-family: "DM Serif Display", Georgia, serif;
  font-weight: 400;
  font-size: clamp(44px, 9vw, 92px);
  line-height: 1;
  color: var(--navy);
  letter-spacing: -.01em;
}
.lede { margin: 14px auto 0; max-width: 560px; color: var(--muted); font-size: 17px; }
.rule { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 30px auto 0; max-width: 420px; padding: 0 16px; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rule span { width: 10px; height: 10px; transform: rotate(45deg); background: var(--gold); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 32px 0 6px; }
.filters:empty { display: none; }
.chip {
  font: 500 14px/1 "Inter", sans-serif;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--navy); }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--paper); }
.count { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0 22px; min-height: 1em; }

/* Gallery — rows: description box on the left, then 5 photos */
.gallery { display: flex; flex-direction: column; gap: 22px; padding-bottom: 64px; }
.photorow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; align-items: start; }
.rowdesc {
  background: var(--bg); border-radius: 6px; box-shadow: none; padding: 4px 4px 4px 0;
  font-size: 14px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
  align-self: stretch; display: flex; flex-direction: column; gap: 6px;
}
.rowdesc.blank { background: transparent; box-shadow: none; }
.rowdesc textarea {
  font: 400 14px/1.5 "Inter", sans-serif; width: 100%; color: var(--ink); resize: vertical;
  background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px;
}
.rowdesc textarea:focus, .rowdesc .price-input:focus { outline: none; border-color: var(--navy); }
.rowdesc .price-input {
  font: 600 14px/1.4 "Inter", sans-serif; width: 100%; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 6px 9px;
}
.price-line { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.price-line.two { grid-template-columns: 1fr 1fr; }
.price-line.item { grid-template-columns: 2fr 1fr; } /* longer Item# box */
.info-body .note-input[readonly] { background: var(--bg); color: var(--navy); font-weight: 600; cursor: default; }
.brand-input { font-weight: 500 !important; cursor: pointer; }
.brand-input.empty { color: var(--muted) !important; font-weight: 400 !important; }
.rowdesc .note-input { font-weight: 400; }
.rowdesc .price { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; }
.rowdesc .price .note { font-weight: 500; color: var(--muted); }
.rowdesc .price { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 600; color: var(--navy); white-space: normal; }
.rowremove { align-self: flex-start; padding: 0; font-size: 12px; margin-top: auto; }
@media (max-width: 900px) {
  .photorow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rowdesc { grid-column: 1 / -1; }
  .rowdesc.blank { display: none; }
}
.tile {
  margin: 0; display: flex; flex-direction: column; width: 100%;
  padding: 0; border: 0; background: var(--paper); cursor: zoom-in;
  border-radius: 6px; overflow: hidden; box-shadow: var(--shadow);
  text-align: left; color: inherit; font: inherit;
  transition: transform .2s ease, box-shadow .2s ease;
}
.tile:hover { transform: translateY(-2px); }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.tile img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line); }
.tile .cap { padding: 9px 11px 11px; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .cap small, .tile .cap .badge { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cap small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.empty { text-align: center; padding: 40px 0 80px; color: var(--muted); }
.empty h2 { font-family: "DM Serif Display", Georgia, serif; font-weight: 400; color: var(--navy); font-size: 30px; margin: 0 0 8px; }
code { background: var(--paper); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; font-size: .9em; }

.footer { border-top: 1px solid var(--line); padding: 26px 0 40px; text-align: center; color: var(--muted); font-size: 13px; }
.footer p { margin: 0; }

/* Buttons */
.btn {
  font: 600 14px/1 "Inter", sans-serif; padding: 11px 18px; border-radius: 6px;
  border: 0; background: var(--navy); color: var(--paper); cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn-link { font: 500 14px "Inter", sans-serif; background: none; border: 0; padding: 4px; color: var(--navy); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn-link.subtle { color: var(--muted); font-size: 13px; text-decoration: none; }
.btn-link.subtle:hover { text-decoration: underline; }
.btn-danger { font: 500 13px "Inter", sans-serif; background: none; border: 1px solid rgba(224,100,90,.5); color: #f08a80; padding: 7px 12px; border-radius: 6px; cursor: pointer; }
.btn-danger:hover { background: rgba(224,100,90,.12); }
.dot { margin: 0 4px; }

/* Edit pill (only on devices that opened the edit link) */
.editpill {
  position: fixed; top: 14px; right: 16px; z-index: 45;
  font: 600 14px/1 "Inter", sans-serif; padding: 10px 20px; border-radius: 999px;
  border: 1.5px solid var(--navy); background: var(--paper); color: var(--navy);
  box-shadow: var(--shadow); cursor: pointer; transition: background .15s, color .15s;
}
.editpill:hover { background: var(--navy); color: var(--paper); }
.editpill[aria-pressed="true"] { background: var(--navy); color: var(--paper); }
.editpill[hidden] { display: none; }
body.has-pill main.wrap { padding-top: 68px; }

/* Edit bar (unused) */
.editbar { position: sticky; top: 0; z-index: 40; background: var(--navy); color: var(--paper); font-size: 14px; }
.editbar[hidden] { display: none; }
.editbar-in { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.editbar .btn-link { color: var(--paper); }

/* Upload area */
.drop { margin: 32px 0 8px; border: 2px dashed var(--line); border-radius: 10px; background: var(--paper); padding: 26px 16px; text-align: center; transition: border-color .15s, background .15s; }
.drop[hidden] { display: none; }
.drop.over { border-color: var(--navy); background: color-mix(in srgb, var(--navy) 6%, var(--paper)); }
.drop-title { margin: 0; font-family: "DM Serif Display", Georgia, serif; font-size: 26px; color: var(--navy); }
.drop-sub { margin: 4px 0 12px; color: var(--muted); }
.drop-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.queue { list-style: none; margin: 16px auto 0; padding: 0; max-width: 520px; text-align: left; }
.queue:empty { display: none; }
.queue li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-top: 1px solid var(--line); font-size: 14px; }
.queue li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .ok { color: #2e7d4f; } .queue .bad { color: var(--ribbon); } .queue .busy { color: var(--muted); }
.tile .badge { display: block; margin-top: 4px; font-size: 11px; color: var(--ribbon); }

/* Viewer: photo + description box */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #0d1017; display: flex; }
.lightbox[hidden] { display: none; }
.lb-body { flex: 1; display: grid; grid-template-columns: minmax(0,1fr); min-height: 0; }
.lb-panel { display: none !important; } /* photo only, no side panel */
.lb-del { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(13,16,23,.75); }
.lb-del[hidden] { display: none; }
.lb-count { position: absolute; bottom: 22px; right: 24px; margin: 0; color: #9aa1b0; font-size: 13px; }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; padding: 56px 72px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 112px); object-fit: contain; border-radius: 3px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb-panel {
  background: #161a24; color: #e8e2d6; border-left: 1px solid #262c3a;
  padding: 64px 24px 24px; overflow-y: auto; display: flex; flex-direction: column;
}
.lb-panel h2 { margin: 0 0 6px; font-family: "DM Serif Display", Georgia, serif; font-weight: 400; font-size: 28px; line-height: 1.15; color: #fff; }
.lb-meta { margin: 0 0 16px; color: #9aa1b0; font-size: 13px; }
.lb-meta:empty { display: none; }
.lb-desc { white-space: pre-wrap; font-size: 15px; line-height: 1.65; color: #d6d0c4; }
.lb-desc.none { color: #7d8496; font-style: italic; }
.lb-pos { margin: auto 0 0; padding-top: 16px; color: #7d8496; font-size: 12px; }
#lb-edit { display: flex; flex-direction: column; gap: 12px; flex: 1; }
#lb-edit[hidden] { display: none; }
#lb-edit label, .modal label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #9aa1b0; }
#lb-edit .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#lb-edit .grow { flex: 1; }
#lb-edit input, #lb-edit textarea {
  font: 400 15px/1.5 "Inter", sans-serif; text-transform: none; letter-spacing: 0;
  background: #0f131b; color: #f1ece2; border: 1px solid #2c3343; border-radius: 6px; padding: 9px 11px; width: 100%;
}
#lb-edit textarea { flex: 1; min-height: 180px; resize: vertical; }
#lb-edit input:focus, #lb-edit textarea:focus { outline: none; border-color: var(--gold); }
.edit-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.saved { font-size: 13px; color: #9aa1b0; }
.saved.ok { color: #7fcf9b; } .saved.bad { color: #f08a80; }
.lb-btn {
  position: absolute; border: 0; background: rgba(255,255,255,.08); color: #fff; z-index: 2;
  width: 48px; height: 48px; border-radius: 50%; font-size: 30px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; transition: background .15s;
}
.lb-btn:hover { background: rgba(255,255,255,.18); }
.lb-close { top: 12px; right: 12px; font-size: 32px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

/* Sign-in modal */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10,12,18,.6); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--paper); color: var(--ink); border-radius: 10px; padding: 24px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 16px; font-family: "DM Serif Display", Georgia, serif; font-weight: 400; color: var(--navy); font-size: 26px; }
.modal label { color: var(--muted); }
.modal input { font: 400 16px "Inter", sans-serif; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.err { color: var(--ribbon); font-size: 13px; min-height: 1.2em; margin: 8px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 14px; }

@media (max-width: 860px) {
  .lightbox { overflow-y: auto; }
  .lb-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; min-height: 100%; }
  .lb-stage { padding: 56px 8px 12px; }
  .lb-stage img { max-height: calc(100vh - 150px); }
  .lb-panel { border-left: 0; border-top: 1px solid #262c3a; padding: 20px 16px 28px; }
  .lb-prev, .lb-next { width: 40px; height: 40px; font-size: 26px; }
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
}
@media (max-width: 640px) {
  .masthead { padding-top: 40px; }
  .photorow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile .cap { padding: 7px 9px 9px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }

/* Edit mode: input boxes on each card + empty "Add photo" boxes */
.editcard { cursor: default; }
.editcard:hover { transform: none; }
.editcard .pic { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; width: 100%; }
.editcard .fields { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.editcard input, .editcard textarea {
  font: 400 13px/1.4 "Inter", sans-serif; width: 100%; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; resize: vertical;
}
.editcard input { font-weight: 600; }
.editcard input:focus, .editcard textarea:focus { outline: none; border-color: var(--navy); }
.cardsaved { font-size: 11px; color: var(--muted); min-height: 14px; }
.cardsaved.ok { color: #2e7d4f; } .cardsaved.bad { color: var(--ribbon); }
.slot {
  aspect-ratio: 4 / 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--line); background: transparent; box-shadow: none; cursor: pointer; color: var(--muted);
}
.slot:hover, .slot.over { border-color: var(--navy); color: var(--navy); background: var(--paper); transform: none; }
.slot .plus { font-size: 34px; line-height: 1; font-weight: 300; }
.slot .slot-text { font-size: 13px; font-weight: 500; }
.slot.busy { border-style: solid; color: var(--navy); cursor: progress; }
.slot:focus-within { outline: 3px solid var(--gold); outline-offset: 3px; }

/* Info box (left of each row) and its popup */
.infobtn {
  font: 400 14px/1.5 "Inter", sans-serif; color: var(--ink); cursor: pointer; text-align: left;
  border: 1.5px dashed var(--line); border-radius: 6px; background: var(--bg);
  min-height: 100%; aspect-ratio: auto; display: flex; flex-direction: column; padding: 10px 12px;
  transition: border-color .15s, background .15s;
}
.infobtn:not(.filled) { align-items: center; justify-content: center; }
.infobtn .info-label { font: 600 16px/1 "Inter", sans-serif; color: var(--navy); }
.infobtn.filled { border-style: solid; }
.infobtn:hover { border-color: var(--navy); background: var(--paper); }
.infobtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.info-card { max-width: 440px; }
.info-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.info-head h2 { margin: 0; }
.info-x { border: 0; background: none; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.info-x:hover { color: var(--ink); }
.info-body { display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.55; }
.info-body .desc-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.info-body textarea {
  font: 400 15px/1.5 "Inter", sans-serif; width: 100%; color: var(--ink); resize: vertical;
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px;
}
.info-body .price-input {
  font: 600 15px/1.4 "Inter", sans-serif; width: 100%; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 8px 11px;
}
.info-body .note-input { font-weight: 400; }
.info-body textarea:focus, .info-body .price-input:focus { outline: none; border-color: var(--navy); }
.info-body .price { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 600; color: var(--navy); }
.info-body .price .note { font-weight: 500; color: var(--muted); }
.info-body .rowremove { align-self: flex-start; margin-top: 4px; }
@media (max-width: 900px) { .infobtn { min-height: 0; padding: 12px; } }

/* Type checkboxes in the Info popup */
.info-body .cats { border: 0; margin: 2px 0 4px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; }
.info-body .cats legend { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; padding: 0; }
.info-body .cat { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink); cursor: pointer; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.info-body .cat input { width: 16px; height: 16px; accent-color: var(--navy); margin: 0; }
.info-body .cat:has(input:checked) { border-color: var(--navy); }
.filters { margin: 0 0 18px; }

.info-body .newopt { grid-column: 1 / -1; display: flex; gap: 6px; }
.info-body .newopt[hidden] { display: none; }
.info-body .newopt .price-input { flex: 1; font-weight: 400; }
.info-body .newopt .btn { padding: 8px 16px; }

/* Item# and Price 2px smaller */
.rowdesc .price { font-size: 12px; }
.info-body .price-line .price-input { font-size: 13px; }
.info-body .price { font-size: 13px; }

/* Item# and Price on two lines */
.rowdesc .price, .info-body .price { flex-direction: column; justify-content: flex-start; gap: 2px; }
.info-body .price-line.item { grid-template-columns: 1fr; }

/* Brand / Type filter checkboxes at the top */
.filters { flex-direction: column; align-items: center; gap: 10px; }
.fgroup { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px; }
.fgroup legend { float: left; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 6px; padding: 0; }
.fcheck { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; }
.fcheck input { width: 15px; height: 15px; margin: 0; accent-color: var(--navy); }
.fcheck:has(input:checked) { border-color: var(--navy); color: var(--navy); font-weight: 600; }
.fclear { font-size: 13px; }
