:root {
  --bg: #fbf7f0;
  --card: #ffffff;
  --ink: #2b2420;
  --muted: #7a6e66;
  --line: #eadfd2;
  --red: #b3262e;
  --red-dark: #8e1c23;
  --green: #1f6b45;
  --green-soft: #e3f1e8;
  --gold: #c99a2e;
  --gold-soft: #fbf1d9;
  --radius: 12px;
}

/* ---------- thèmes ---------- */
/* Noël : rouge / vert, petits flocons dans la barre */
body.theme-noel .topbar {
  background-color: #b3262e;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.55) 1.5px, transparent 2px),
    radial-gradient(circle, rgba(255,255,255,.35) 1px, transparent 1.5px);
  background-size: 46px 46px, 28px 28px;
  background-position: 0 0, 14px 18px;
}

/* Anniversaires : rose / violet, confettis */
body.theme-anniv {
  --bg: #fdf6fb;
  --line: #efdbe9;
  --red: #c2367a;
  --red-dark: #9b2660;
  --green: #5b3fc4;
  --green-soft: #ece7fb;
  --gold: #f2a900;
  --gold-soft: #fff3d1;
}
body.theme-anniv .topbar,
.tile-anniv {
  background-color: #c2367a;
  background-image:
    radial-gradient(circle, #ffd54a 2px, transparent 2.5px),
    radial-gradient(circle, #4fd1c5 2px, transparent 2.5px),
    radial-gradient(circle, rgba(255,255,255,.8) 1.5px, transparent 2px),
    linear-gradient(100deg, #c2367a, #6a3fc4);
  background-size: 58px 38px, 74px 46px, 40px 30px, 100% 100%;
  background-position: 0 0, 28px 18px, 12px 9px, 0 0;
}

/* Accueil : neutre, aux couleurs des deux événements */
body.theme-home { --red: #6a2f7a; --red-dark: #4f2059; }
body.theme-home .topbar { background: linear-gradient(100deg, #b3262e, #6a3fc4); }

/* ---------- accueil : les briques ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 8px; }
.tile {
  display: flex; flex-direction: column; gap: 8px; min-height: 230px; padding: 28px 24px;
  border-radius: 18px; color: #fff; text-decoration: none; text-shadow: 0 1px 4px rgba(40, 10, 30, .55);
  box-shadow: 0 6px 18px rgba(60, 20, 40, .18); transition: transform .15s, box-shadow .15s;
}
.tile:hover, .tile:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(60, 20, 40, .25); }
.tile-noel {
  background-color: #b3262e;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.5) 1.5px, transparent 2px),
    radial-gradient(circle, rgba(255,255,255,.3) 1px, transparent 1.5px),
    linear-gradient(135deg, #b3262e, #1f6b45);
  background-size: 46px 46px, 28px 28px, 100% 100%;
  background-position: 0 0, 14px 18px, 0 0;
}
.tile-emoji { font-size: 3rem; line-height: 1; }
.tile-title { font-size: 1.6rem; font-weight: 800; }
.tile-stats { font-size: .92rem; opacity: .92; }
.tile-go {
  margin-top: auto; align-self: flex-start; font-weight: 700;
  background: rgba(255,255,255,.2); padding: 6px 14px; border-radius: 999px;
}

/* admin : une carte par événement */
.year-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 8px; }
.year-panel h3 { margin: 0 0 4px; }
.year-panel.year-noel { border-top: 4px solid #b3262e; }
.year-panel.year-anniv { border-top: 4px solid #c2367a; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--red); }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 20px;
  background: var(--red);
  color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; }
#nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#nav a, #nav button {
  color: #fff;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .95rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
#nav a:hover, #nav button:hover { background: rgba(255,255,255,.15); }
#nav a.active { background: rgba(255,255,255,.25); }
#nav .who { opacity: .85; padding: 6px 4px 6px 12px; font-size: .9rem; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 24px; }

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.2rem; margin: 28px 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- cartes / formulaires ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.auth { max-width: 400px; margin: 40px auto; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 8px; cursor: pointer; font: inherit;
}
.tabs button.on { background: var(--red); color: #fff; border-color: var(--red); }

form .row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
label { font-size: .85rem; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=url], textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
textarea { min-height: 60px; resize: vertical; }
.hint { font-size: .8rem; color: var(--muted); }

/* image collée */
.img-preview:empty { display: none; }
.img-preview {
  display: flex; align-items: center; gap: 12px; margin-top: 6px;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #f4eee6;
}
.img-preview img { max-width: 140px; max-height: 110px; border-radius: 6px; background: #fff; }
.linkish { color: var(--red); text-decoration: underline; cursor: pointer; font-weight: 400; font-size: inherit; }
form.dropping { outline: 3px dashed var(--gold); outline-offset: 6px; border-radius: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  background: var(--red); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--red-dark); }
.btn.green { background: var(--green); }
.btn.green:hover { background: #17533a; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.error { background: #fde8e8; color: var(--red-dark); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice { background: var(--gold-soft); border: 1px solid #efdcaa; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .92rem; }

/* ---------- liste d'envies ---------- */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.item.taken { border-color: #b9dcc7; }
.item.mine { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.item .pic { width: 100%; height: 170px; object-fit: contain; background: #f4eee6; display: block; }
.item .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item .title { font-weight: 700; font-size: 1.02rem; word-break: break-word; }
.item .note { color: var(--muted); font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.item .link { font-size: .88rem; word-break: break-all; }
.item .foot-actions { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.badge { display: inline-block; font-size: .8rem; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.badge.free { background: var(--gold-soft); color: #7a5a10; }
.badge.taken { background: var(--green-soft); color: var(--green); }

.check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: .9rem;
}
.check input { width: 18px; height: 18px; accent-color: var(--green); }

.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- membres ---------- */
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.member {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.member:hover { border-color: var(--red); }
.member .name { font-weight: 700; font-size: 1.05rem; }
.member .stats { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 8px;
}

/* ---------- extras ---------- */
.secret { background: #f2f7f4; border: 1px dashed #9cc9ad; border-radius: var(--radius); padding: 16px; margin-top: 28px; }
.secret h2 { margin-top: 0; }
.extra { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #d6e8dc; }
.extra:first-of-type { border-top: 0; }
.extra .by { font-size: .82rem; color: var(--muted); }

.gift-group { margin-bottom: 18px; }
.gift-group ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- message temporaire ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- idées ---------- */
.extra { flex-wrap: wrap; }
.extra-thumb { flex: none; }
.extra-thumb img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px; display: block;
  background: #fff; border: 1px solid var(--line);
}
.extra > div:not(.extra-actions) { flex: 1 1 200px; min-width: 0; }
.extra { justify-content: flex-start; }
.extra-head { font-size: 1rem; margin: 18px 0 4px; }
.extra-head .hint { font-weight: 400; }
.extra.idea strong::before { content: "💡 "; }
.extra.idea { background: var(--gold-soft); border-radius: 8px; padding: 10px 12px; border-top: 0; margin-top: 6px; }
.extra-form { margin-top: 18px; padding-top: 14px; border-top: 1px dashed #9cc9ad; }

/* ---------- nom masqué ---------- */
.check.anon { font-size: .82rem; padding: 4px 9px; color: var(--muted); background: #faf7f3; }
.check.anon input { width: 15px; height: 15px; }
.extra-actions { flex: none; align-items: center; justify-content: flex-end; }

/* ---------- années / archives ---------- */
.badge { background: #efe9e2; color: var(--muted); }
.reuse {
  margin-top: 20px; background: var(--green-soft); border: 1px solid #b9dcc7;
  border-radius: var(--radius); padding: 12px 16px;
}
.reuse summary { cursor: pointer; font-weight: 700; color: var(--green); }
.reuse-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.reuse-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 8px; padding: 8px 10px; }
.reuse-row img, .reuse-noimg {
  width: 48px; height: 48px; object-fit: contain; border-radius: 6px; background: #f4eee6;
  flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.reuse-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reuse-txt strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.year-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.year-tabs a {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  text-decoration: none; color: var(--ink); font-weight: 600;
}
.year-tabs a.on { background: var(--red); border-color: var(--red); color: #fff; }
.archive-extras { margin-top: 12px; }
.archive-extras ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- admin ---------- */
.admin-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 260px 300px; gap: 10px 16px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.admin-row .actions { justify-content: flex-end; }
.admin-row:first-child { border-top: 0; padding-top: 0; }
.admin-who { display: flex; gap: 10px; align-items: center; }
.avatar.small { width: 32px; height: 32px; margin: 0; font-size: .9rem; flex: none; }
.admin-pw { display: flex; gap: 6px; }
.admin-pw input { min-width: 0; }
.badge.admin { background: #f6e1e2; color: var(--red-dark); }
.btn.danger { color: var(--red); border-color: #f0c9cb; }
.btn.danger:hover { background: #fde8e8; }

@media (max-width: 760px) {
  .admin-row { grid-template-columns: 1fr; }
  .admin-row .actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; }
}

/* ---------- partage ---------- */
.share-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: #fff; border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 12px; margin: -4px 0 18px;
}
.share-label { font-weight: 600; margin-right: 4px; }
.share-welcome {
  max-width: 420px; margin: 0 auto 14px; text-align: center;
  background: var(--gold-soft); border: 1px solid #efdcaa; border-radius: 10px; padding: 12px 14px;
}
.share-url { flex: 1 1 100%; font-size: .85rem; }
