:root {
  --bg: #fbf7f2;
  --card: #ffffff;
  --text: #2b2323;
  --muted: #7a6d6a;
  --line: #ecdfd6;
  --red: #b3262e;
  --red-dark: #8f1d24;
  --green: #1f6b45;
  --green-soft: #e5f2ea;
  --gold: #d9a441;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(80, 30, 20, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171314;
    --card: #231d1e;
    --text: #f3ebe7;
    --muted: #b3a5a1;
    --line: #3a3031;
    --red: #e0525a;
    --red-dark: #c63c44;
    --green: #6fcf97;
    --green-soft: #1e3328;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 48px 16px 40px;
  text-align: center;
  color: #fff;
  background: linear-gradient(160deg, #8f1d24, #b3262e 55%, #1f6b45);
}
.hero.small { padding: 28px 16px 24px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 5vw, 2.6rem); }
.hero .subtitle { margin: 0 auto; max-width: 36rem; opacity: 0.92; }
.snow {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: radial-gradient(#fff 1.2px, transparent 1.6px), radial-gradient(#fff 1px, transparent 1.4px);
  background-size: 48px 48px, 31px 31px;
  background-position: 0 0, 15px 20px;
}

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }

h2 { margin: 0 0 12px; font-size: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card.narrow { max-width: 420px; margin: 24px auto; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row input { flex: 1; min-width: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .cols { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.95rem; }
label.check { flex-direction: row; align-items: center; font-weight: 400; gap: 8px; }

input, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
label.check input { width: auto; }
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  transition: transform 0.05s, background 0.15s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.small { padding: 6px 12px; font-size: 0.88rem; }
.btn.icon { padding: 6px 10px; font-size: 0.9rem; }
.btn.danger { color: var(--red); }
.btn.link-btn { border: none; background: none; color: var(--muted); text-decoration: underline; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h2 { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }

.gift { display: flex; flex-direction: column; padding: 0; overflow: hidden; margin: 0; }
.gift-image { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; display: block; }
.gift-image.placeholder {
  display: grid; place-items: center; font-size: 3rem;
  background: linear-gradient(135deg, var(--green-soft), var(--bg));
}
.gift-body { padding: 14px 16px 6px; flex: 1; }
.gift-body h3 { margin: 0 0 4px; font-size: 1.1rem; }
.price { margin: 0 0 6px; color: var(--green); font-weight: 600; }
.description { margin: 0 0 8px; white-space: pre-line; color: var(--muted); font-size: 0.95rem; }
.link { color: var(--red); font-weight: 600; text-decoration: none; font-size: 0.95rem; }
.link:hover { text-decoration: underline; }
.gift-footer { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.gift-footer .btn.primary { width: 100%; }
.badge { margin: 0; font-weight: 600; }
.gift.reserved .gift-image, .gift.reserved .gift-body { opacity: 0.55; }
.gift.mine { border-color: var(--green); }
.gift.mine .gift-image, .gift.mine .gift-body { opacity: 1; }
.gift.mine .badge { color: var(--green); }

.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-item { display: flex; align-items: center; gap: 14px; padding: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-item .gift-image { width: 64px; height: 64px; aspect-ratio: auto; border-radius: 10px; font-size: 1.6rem; flex: none; }
.admin-info { flex: 1; min-width: 160px; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-item.reserved { border-left: 4px solid var(--green); }

dialog {
  border: none; border-radius: var(--radius); padding: 24px;
  width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(20, 10, 10, 0.5); }
dialog h2 { font-size: 1.15rem; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: #2b2323; color: #fff; padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); z-index: 10; text-align: center;
}
#toast[data-kind="success"] { background: var(--green); }
#toast[data-kind="error"] { background: var(--red-dark); }
#toast[hidden] { display: none; }
