:root {
  --bg: #fbf7f4;
  --card: #ffffff;
  --ink: #2b2b33;
  --muted: #6b6b76;
  --accent: #d98a8a;
  --accent-ink: #7a3b3b;
  --line: #e9e1da;
  --amazon: #e9a23b;
  --external: #7fa7c9;
  --danger: #c0504d;
  --shadow: 0 6px 20px rgba(60, 40, 40, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.admin-header { padding: 2rem 1.25rem 1rem; text-align: center; }
.welcome { color: var(--muted); margin: .25rem 0; }
.event { color: var(--accent-ink); font-weight: 600; }

/* Public hero: small, faded, pencil-painted feel; text left, photo right */
.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  text-align: left;
}
.hero-text { flex: 1 1 auto; min-width: 0; }
.hero-photo {
  flex: none;
  width: 40%;
  max-width: 230px;
  height: auto;
  /* The photo sits on the warm page background with feathered white edges.
     `multiply` melts those near-white edges into the cream bg, and the gentle
     radial mask softens the outer ring so it dissolves into the page. */
  mix-blend-mode: multiply;
  -webkit-mask-image: radial-gradient(ellipse 88% 86% at 50% 50%, #000 66%, transparent 100%);
  mask-image: radial-gradient(ellipse 88% 86% at 50% 50%, #000 66%, transparent 100%);
}
.hero-title {
  margin: 0 0 .45rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-weight: 500;
  font-size: 1.45rem;
  line-height: 1.25;
  letter-spacing: .01em;
  color: var(--ink);
}
.hero-quote {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
}
.hero .event { margin: .6rem 0 0; font-size: .9rem; }

.registry { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.empty { text-align: center; color: var(--muted); padding: 3rem 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card.is-gifted { opacity: .6; }
.item-img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #fff; display: block; padding: 14px; box-sizing: border-box; border-bottom: 1px solid var(--line); }
.item-img.placeholder { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; color: var(--muted); background: #faf7f4; }
.card-body { padding: .9rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.item-title {
  font-size: .82rem;
  font-weight: 400;
  line-height: 1.4;
  margin: 0;
  color: #4a4a52;
  letter-spacing: .01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.3em;
}
.meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto; }
.price { font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.state { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; }
.state.available { background: #e7f3ea; color: #2f7a47; }
.state.gifted { background: #f0e7e7; color: #8a5a5a; }
.state.held { background: #fbf0e0; color: #9a6b2f; }
.card.is-reserved { opacity: .85; }
.btn.reserved { background: #e7ddd2; color: #7a5a3b; cursor: not-allowed; font-weight: 500; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.modal-actions .btn { flex: 1 1 auto; text-align: center; }

.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: .6rem .9rem; font-size: .95rem; cursor: pointer; font-weight: 600;
  text-align: center;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { background: #cfc7c1; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--accent-ink); border: 1px solid var(--line); }
.btn.small { padding: .35rem .6rem; font-size: .85rem; }

.modal { position: fixed; inset: 0; background: rgba(40,30,30,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 16px; max-width: 480px; width: 100%; padding: 1.5rem; position: relative; box-shadow: var(--shadow); max-height: 90vh; overflow:auto; }
.modal-close { position: absolute; top: .6rem; right: .8rem; background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.modal h3 { margin-top: 0; }
.address { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: .75rem; margin: .5rem 0 0; }
.hp { display: none; }
.note { font-size: .85rem; }

/* Purchase modal */
.modal-lead { color: var(--muted); margin: .25rem 0 1rem; }
.modal-thanks { margin: 1rem 0 0; font-style: italic; color: var(--muted); font-size: .88rem; text-align: center; }
.steps { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 1.1rem; }
.steps > li { padding-left: .25rem; }
.step-text { display: block; margin-bottom: .5rem; font-weight: 500; color: var(--ink); }
.steps .btn { display: inline-block; }
.claim-form { display: flex; flex-direction: column; gap: .6rem; margin-top: .25rem; }
.claim-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.claim-form input, .claim-form textarea {
  padding: .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem;
  color: var(--ink); font-family: inherit; width: 100%; box-sizing: border-box;
}
.claim-form textarea { resize: vertical; min-height: 4.5rem; }
.claim-form input[type=number] { max-width: 8rem; }
.form-error { color: var(--danger); font-size: .85rem; margin: .1rem 0 0; }
.out-of-sync h2 { color: #9a6b2f; }

.site-footer { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: .9rem; }

/* Admin */
.admin-header { display: flex; justify-content: space-between; align-items: center; text-align: left; flex-wrap: wrap; gap: 1rem; max-width: 1100px; margin: 0 auto; }
.admin-header h1 { margin: 0; }
.header-actions { display: flex; gap: .5rem; }
.muted { color: var(--muted); }
.admin { max-width: 1100px; margin: 0 auto; padding: 1rem; display: flex; flex-direction: column; gap: 1.25rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; text-align: center; }
.stat .n { display: block; font-size: 1.6rem; font-weight: 700; }
.stat .n.small { font-size: .95rem; }
.stat .l { color: var(--muted); font-size: .85rem; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.form-grid label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: .25rem; }
.form-grid label.full, .form-grid .full, .form-grid fieldset.full { grid-column: 1 / -1; }
.form-grid input, .form-grid textarea { padding: .5rem; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; color: var(--ink); }
.form-grid label.checkbox { flex-direction: row; align-items: center; gap: .5rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; }
legend { color: var(--muted); font-size: .85rem; padding: 0 .4rem; }

.table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.link { background: none; border: none; color: var(--accent-ink); cursor: pointer; padding: 0; font-size: .9rem; text-decoration: underline; }
.link.danger { color: var(--danger); }
.rowflag { font-size: .7rem; background: #f0e7e7; color: #8a5a5a; padding: .05rem .35rem; border-radius: 6px; }

/* Drag-to-reorder (admin items table) */
.drag-cell { width: 1.8rem; text-align: center; color: var(--muted); }
.drag-handle { cursor: grab; user-select: none; font-size: 1rem; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.items-table tbody tr.dragging { opacity: .55; background: #f6efe9; }

/* Gift card badge (public card + admin) */
.state.giftcard { background: #eaf1f8; color: #3f6f9f; }
.staged-list { display: flex; flex-direction: column; gap: .4rem; margin: .75rem 0; }
.staged-item { border: 1px solid var(--line); border-radius: 8px; padding: .5rem; font-size: .9rem; }
.carousel { display: flex; gap: .5rem; overflow-x: auto; padding: .5rem 0 .75rem; }
.carousel-item { flex: 0 0 auto; border: 2px solid var(--line); border-radius: 10px; padding: 2px; background: #fff; cursor: pointer; }
.carousel-item.selected { border-color: var(--accent); }
.carousel-item img { display: block; width: 96px; height: 96px; object-fit: contain; border-radius: 8px; }
.help-steps { margin: .25rem 0 .75rem 1.1rem; padding: 0; font-size: .9rem; }
.help-steps li { margin: .15rem 0; }
.code-block { background: #2b2b33; color: #f3efe9; border-radius: 10px; padding: .75rem .9rem; font-size: .82rem; overflow-x: auto; white-space: pre; line-height: 1.5; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  /* Two smaller item columns on phones; falls back to one when too narrow. */
  .grid { gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  /* Keep the side-by-side layout on phones, just smaller. */
  .hero { gap: .9rem; padding: 1.1rem 1rem .6rem; }
  .hero-photo { width: 38%; max-width: 130px; }
  .hero-title { font-size: 1.05rem; margin-bottom: .3rem; line-height: 1.2; }
  .hero-quote { font-size: .82rem; line-height: 1.45; }
  .hero .event { font-size: .8rem; margin-top: .4rem; }
  /* Purchase modal as a bottom sheet on phones, floated off the edges so its
     borders and rounded corners stay visible on every screen. */
  .modal { align-items: flex-end; padding: .6rem; }
  .modal-card { max-width: none; width: 100%; border-radius: 16px; max-height: 82vh; padding: 1.1rem 1rem 1.25rem; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; flex: none; }
  .steps .btn { width: 100%; text-align: center; }
}
