:root {
  --bg: #f7f3ec;
  --bg-accent: #efe6d8;
  --surface: #ffffff;
  --surface-2: #fbf8f3;
  --text: #2a2522;
  --muted: #6f655d;
  --border: #e3d9cc;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --green: #1f6f4a;
  --green-soft: #e3f2ea;
  --gold: #b7862b;
  --gold-soft: #fbf1dc;
  --focus: #2f6fd6;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 6px 24px rgb(60 40 20 / 8%);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191c;
    --bg-accent: #1e2125;
    --surface: #22262b;
    --surface-2: #1c1f23;
    --text: #ece7e1;
    --muted: #a69d94;
    --border: #353a41;
    --red: #ef6c62;
    --red-soft: #3a2422;
    --green: #5cc394;
    --green-soft: #1d3329;
    --gold: #e0b45a;
    --gold-soft: #3a3020;
    --focus: #7aa7ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

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

a { color: var(--green); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }

.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.container.wide { max-width: 1180px; }

.site-header {
  background: linear-gradient(135deg, var(--red) 0%, #8e1c16 100%);
  color: #fff;
  padding: 20px 0 22px;
  margin-bottom: 24px;
}
@media (prefers-color-scheme: dark) {
  .site-header { background: linear-gradient(135deg, #7d1f19 0%, #4f120e 100%); }
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site-header a { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; }
.brand .logo { font-size: 1.8rem; }
.header-actions { display: flex; gap: 8px; align-items: center; }

.site-footer { color: var(--muted); font-size: .85rem; text-align: center; padding: 32px 0; }
.site-footer a { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card.flat { box-shadow: none; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.event-card { display: block; text-decoration: none; color: inherit; transition: transform .12s ease; }
a.event-card:hover { transform: translateY(-2px); }
.event-card .event-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.event-date { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: .9rem;
  background: var(--green-soft); color: var(--green); font-weight: 600;
}
.chip.budget { background: var(--gold-soft); color: var(--gold); }

.message {
  white-space: pre-line;
  background: var(--surface-2);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0 0;
}
.message-label { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gold); display: block; margin-bottom: 4px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* Formulaires */
label { font-weight: 600; display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--focus);
}
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--green); flex: none; }
.check strong { font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.code-input { letter-spacing: .3em; font-variant-numeric: tabular-nums; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  min-height: 42px;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--border)); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .875rem; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.on-dark { background: rgb(255 255 255 / 14%); border-color: rgb(255 255 255 / 30%); color: #fff; }
.btn.block { width: 100%; }
.btn.big { font-size: 1.1rem; padding: 14px 22px; }

/* Messages */
.alert { border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.alert.error { background: var(--red-soft); color: var(--red); }
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.info { background: var(--gold-soft); color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 100; max-width: calc(100vw - 32px);
  animation: toast-in .2s ease;
}
.toast.error { background: var(--red); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Révélation */
.reveal { text-align: center; padding: 12px 0; }
.gift-button {
  font-size: 5rem; line-height: 1; background: none; border: none; cursor: pointer;
  padding: 10px; border-radius: 20px;
  animation: wiggle 2.4s ease-in-out infinite;
}
.gift-button:hover { animation-duration: .8s; }
@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-8deg); } 88% { transform: rotate(8deg); }
  92% { transform: rotate(-5deg); } 96% { transform: rotate(4deg); }
}
.recipient-label { color: var(--muted); margin-bottom: 4px; }
.recipient-name {
  font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; color: var(--red);
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
  overflow-wrap: anywhere;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .gift-button, .recipient-name, .toast { animation: none; }
}
.wishlist-view {
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px 14px; text-align: left;
}

/* Admin */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.warn { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }

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

.admin-layout { display: grid; grid-template-columns: 1fr; gap: 0; }

.events-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.events-grid .card { margin: 0; cursor: pointer; }
.events-grid .card:hover { border-color: var(--green); }

.progress { height: 8px; background: var(--bg-accent); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--green); border-radius: 99px; }

.link-box { display: flex; gap: 8px; align-items: center; }
.link-box input { font-family: ui-monospace, monospace; font-size: .85rem; }

table.people { width: 100%; border-collapse: collapse; }
table.people th {
  text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  border-bottom: 2px solid var(--border); padding: 8px 8px;
}
table.people td { border-bottom: 1px solid var(--border); padding: 10px 8px; vertical-align: middle; }
table.people tr:last-child td { border-bottom: none; }
.person-name { font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.secret { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.secret .revealed-name { font-weight: 700; color: var(--red); }
.actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 860px) {
  table.people thead { display: none; }
  table.people, table.people tbody, table.people tr, table.people td { display: block; width: 100%; }
  table.people tr { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; background: var(--surface-2); }
  table.people td { border: none; padding: 5px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
  table.people td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; }
  .actions { justify-content: flex-start; }
}

.excl-list { list-style: none; padding: 0; margin: 0 0 12px; }
.excl-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }

.mode-options { display: grid; gap: 8px; }
.mode-options .check { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; }
.mode-options .check:has(input:checked) { border-color: var(--green); background: var(--green-soft); }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog textarea { min-height: 220px; font-size: .9rem; }

.login-box { max-width: 400px; margin: 40px auto; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.big-emoji { font-size: 3rem; line-height: 1.1; display: block; margin-bottom: 8px; }
