:root {
  --bg: #f6efe6;
  --card: #fffaf4;
  --ink: #2d2620;
  --muted: #7a6d61;
  --line: #e6d9c8;
  --accent: #c2562f;
  --accent-ink: #fff;
  --ok: #3f7d4e;
  --ok-bg: #e3f0e4;
  --booked-bg: #efe7dc;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1915;
    --card: #28221c;
    --ink: #f3ebe1;
    --muted: #b3a597;
    --line: #3d342b;
    --accent: #e0774e;
    --ok: #8fcf9c;
    --ok-bg: #233a28;
    --booked-bg: #332b23;
    --danger: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-family: Georgia, "Times New Roman", serif; }
h2 { font-size: 1.4rem; font-family: Georgia, "Times New Roman", serif; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
p { margin: 0; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* header */
.hero { text-align: center; padding: 12px 0 20px; }
.hero .emoji { font-size: 2.5rem; }
.hero p { color: var(--muted); margin-top: 6px; white-space: pre-line; }

.summary {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; font-size: .875rem; color: var(--muted);
}

.filters { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 6px 14px; border-radius: 999px; font: inherit; font-size: .875rem; cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* gift list */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
}
.item:active { transform: scale(.99); }
.item.is-booked { opacity: .72; }
.thumb {
  flex: none; width: 64px; height: 64px; border-radius: 10px;
  background: var(--booked-bg) center/cover no-repeat;
  display: grid; place-items: center; font-size: 1.75rem;
}
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-price { color: var(--muted); font-size: .875rem; }
.chev { color: var(--muted); font-size: 1.25rem; }

.pill {
  display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.booked { background: var(--booked-bg); color: var(--muted); }
.pill.mine { background: var(--accent); color: var(--accent-ink); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* detail */
.back {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px;
  color: var(--muted); text-decoration: none; font-size: .95rem; padding: 6px 0;
}
.hero-img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius);
  background: var(--booked-bg); display: block; margin-bottom: 16px;
}
.detail-head { margin-bottom: 16px; }
.price { font-size: 1.15rem; font-weight: 600; margin-top: 6px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card p { white-space: pre-line; }
.reason { border-left: 4px solid var(--accent); }
.links { display: grid; gap: 8px; }
.link-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); background: var(--bg); font-weight: 500;
}
.link-btn span:last-child { color: var(--muted); }

/* forms & buttons */
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input, textarea {
  width: 100%; font: inherit; font-size: 16px; /* prevents iOS zoom */
  padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; font-weight: normal; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 64px; }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 6px;
  width: 100%; padding: 14px; border-radius: 12px; border: 0;
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 12px; font-size: .875rem; border-radius: 10px; }
.stack { display: grid; gap: 10px; margin-top: 16px; }

.booked-banner { text-align: center; }
.booked-banner .big { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }

.link-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 6px; margin-bottom: 6px; }
@media (max-width: 420px) {
  .link-row { grid-template-columns: 1fr auto; }
  .link-row input[name="linkUrl"] { grid-column: 1 / -1; grid-row: 2; }
}
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 10px; width: 44px; font-size: 1.1rem; cursor: pointer;
}

/* host */
.host-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.host-item { display: flex; gap: 10px; align-items: center; }
.host-item .item-body { flex: 1; }
.host-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

footer { text-align: center; margin-top: 32px; font-size: .8rem; }
footer a { color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  font-size: .9rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); z-index: 10;
}
#toast.error { background: var(--danger); color: #fff; }
