:root {
  color-scheme: dark;
  --bg: #050508;
  --text: #f4f2ee;
  --muted: rgba(244, 242, 238, 0.58);
  --faint: rgba(244, 242, 238, 0.32);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --edge: rgba(255, 255, 255, 0.16);
  --accent: #ffcf9a;
  --danger: #ff8a8a;
  --radius: 28px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

/* ---------- Reflets derrière ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora::after {
  /* grain très fin pour casser les dégradés */
  content: ""; position: absolute; inset: 0; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55;
  will-change: transform;
}
.b1 { width: 52vmax; height: 52vmax; left: -14vmax; top: -18vmax; background: radial-gradient(circle, #ff9a5c 0%, #b8325a 45%, transparent 70%); animation: drift1 26s ease-in-out infinite alternate; }
.b2 { width: 46vmax; height: 46vmax; right: -16vmax; top: 10vh; background: radial-gradient(circle, #3fc6d8 0%, #1b4fa8 50%, transparent 72%); animation: drift2 32s ease-in-out infinite alternate; opacity: 0.45; }
.b3 { width: 40vmax; height: 40vmax; left: 20vw; bottom: -22vmax; background: radial-gradient(circle, #f2d16b 0%, #c2563a 48%, transparent 72%); animation: drift3 38s ease-in-out infinite alternate; opacity: 0.35; }
.b4 { width: 22vmax; height: 22vmax; left: 55vw; top: 30vh; background: radial-gradient(circle, #ffffff 0%, #8fb7ff 40%, transparent 70%); animation: drift2 22s ease-in-out infinite alternate-reverse; opacity: 0.16; }
@keyframes drift1 { to { transform: translate(18vw, 22vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-22vw, 18vh) scale(0.9); } }
@keyframes drift3 { to { transform: translate(-10vw, -26vh) scale(1.2); } }

/* ---------- Verre liquide ---------- */
.glass {
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.03) 40%, rgba(255,255,255,0.05) 100%);
  -webkit-backdrop-filter: blur(22px) saturate(185%) brightness(1.06);
  backdrop-filter: blur(22px) saturate(185%) brightness(1.06);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0.5px rgba(255,255,255,0.45),      /* reflet du bord haut */
    inset 0 -1px 0.5px rgba(255,255,255,0.10),     /* rebond en bas */
    inset 1px 0 0.5px rgba(255,255,255,0.12),
    inset 0 0 22px rgba(255,255,255,0.05),         /* épaisseur du verre */
    0 24px 60px -20px rgba(0,0,0,0.65),
    0 2px 8px rgba(0,0,0,0.25);
}
/* liseré en dégradé : brillant en haut à gauche, sombre en bas à droite */
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; z-index: 1; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.55), rgba(255,255,255,0.08) 35%, rgba(255,255,255,0.02) 60%, rgba(255,255,255,0.28));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
/* reflet qui suit le doigt / la souris */
.glass::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 30%) var(--my, -20%), rgba(255,255,255,0.13), transparent 45%);
  opacity: var(--shine, 0.7); transition: opacity 0.4s var(--ease);
}
.glass > * { position: relative; z-index: 2; }

/* réfraction (Chrome / Edge) : le fond se tord légèrement au travers du verre */
.refract .glass {
  -webkit-backdrop-filter: url(#liquid) blur(18px) saturate(185%) brightness(1.06);
  backdrop-filter: url(#liquid) blur(18px) saturate(185%) brightness(1.06);
}

/* ---------- Mise en page ---------- */
.wrap { width: min(1120px, 100% - 32px); margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 0 64px; }
.center { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }

.kicker { font-size: 13px; letter-spacing: 0.02em; color: var(--accent); margin: 0 0 10px; font-weight: 500; }
h1 { font-size: clamp(34px, 7vw, 56px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 650; margin: 0; text-wrap: balance; }
h1 em { font-style: normal; background: linear-gradient(120deg, #fff 10%, #ffcf9a 55%, #ff9fb1 95%); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 20px; letter-spacing: -0.02em; margin: 0 0 16px; font-weight: 600; }
.sub { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 12px 0 0; }

/* ---------- Écran d'accueil ---------- */
.hero { width: min(460px, 100%); padding: 36px 30px 30px; text-align: center; border-radius: 36px; }
.hero h1 { font-size: clamp(34px, 9vw, 46px); }
.hero form { margin-top: 26px; display: grid; gap: 12px; text-align: left; }

/* ---------- Compte à rebours ---------- */
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 26px; }
.unit {
  padding: 14px 4px 11px; border-radius: 20px; text-align: center;
  background: rgba(255,255,255,0.045);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28), inset 0 -1px 0 rgba(255,255,255,0.06), inset 0 0 14px rgba(255,255,255,0.04);
}
.unit b { display: block; font-size: 30px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.unit span { display: block; font-size: 11px; color: var(--muted); margin-top: 7px; }
.countdown.today { display: block; }
.countdown.today .unit { padding: 18px; font-size: 18px; font-weight: 600; }

/* ---------- Champs et boutons ---------- */
label { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  padding: 13px 16px; border-radius: 16px; border: 0; outline: none;
  background: rgba(0,0,0,0.22);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.45), inset 0 -1px 0 rgba(255,255,255,0.10), 0 0 0 1px rgba(255,255,255,0.06);
  transition: box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; padding-right: 40px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f4f2ee' stroke-opacity='.6' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
select option { background: #16161c; color: var(--text); }
input:focus, textarea:focus, select:focus { background-color: rgba(0,0,0,0.3); box-shadow: inset 0 1px 3px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,207,154,0.6), 0 0 0 5px rgba(255,207,154,0.12); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); box-shadow: none; padding: 0; }
input[type=file] { padding: 10px; font-size: 14px; }

.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600; color: var(--text);
  padding: 13px 20px; border-radius: 999px; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  position: relative; isolation: isolate;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.05));
  -webkit-backdrop-filter: blur(14px) saturate(180%); backdrop-filter: blur(14px) saturate(180%);
  box-shadow: inset 0 1px 0.5px rgba(255,255,255,0.55), inset 0 -1px 0.5px rgba(255,255,255,0.12), inset 0 0 12px rgba(255,255,255,0.06), 0 8px 22px -10px rgba(0,0,0,0.6);
  transition: transform 0.18s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
@media (hover: hover) { .btn:hover { background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.08)); } }
.btn.primary { color: #1a1008; background: linear-gradient(180deg, #ffe2bf, #ffc489); box-shadow: inset 0 1px 0.5px rgba(255,255,255,0.9), inset 0 -2px 6px rgba(180,90,20,0.25), 0 10px 30px -10px rgba(255,170,90,0.6); }
@media (hover: hover) { .btn.primary:hover { background: linear-gradient(180deg, #fff0dc, #ffcf9a); } }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14); -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 2px 0 0; text-align: center; }

/* ---------- En-tête de la liste ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 26px 28px; margin-bottom: 22px;
}
.top .countdown { margin-top: 0; min-width: min(380px, 100%); }
.top .logout { position: absolute; top: 18px; right: 18px; z-index: 3; }
.top .logout + div { padding-right: 130px; }
@media (max-width: 760px) { .top .logout + div { padding-right: 0; padding-top: 34px; } }

/* ---------- Cartes cadeaux ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card { display: flex; flex-direction: column; overflow: hidden; border-radius: 26px; transition: transform 0.35s var(--ease); }
@media (hover: hover) { .card:hover { transform: translateY(-3px); } }
.card .img {
  aspect-ratio: 4 / 3; margin: 8px 8px 0; border-radius: 20px; overflow: hidden;
  background: rgba(255,255,255,0.92);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
  display: grid; place-items: center;
}
.card .img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .img.empty { background: linear-gradient(135deg, rgba(255,207,154,0.18), rgba(120,170,255,0.12)); font-size: 40px; }
.card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.card .note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; white-space: pre-line; }
.card .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,0.08); box-shadow: inset 0 1px 0 rgba(255,255,255,0.2); color: var(--text); }
.pill.fav { color: #1a1008; background: linear-gradient(180deg, #ffe2bf, #ffc489); }
.card .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.card .actions .btn { flex: 1; }
.card.taken { opacity: 0.55; }
.card.taken .img { filter: grayscale(0.7); }

/* ---------- Filtres par catégorie (barre en verre) ---------- */
.filters {
  display: flex; gap: 4px; padding: 5px; margin: 0 0 22px; width: fit-content; max-width: 100%;
  border-radius: 999px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.filters::-webkit-scrollbar { display: none; }
.filters button {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 550;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; position: relative; z-index: 2;
  transition: color 0.25s var(--ease), background 0.3s var(--ease), box-shadow 0.3s var(--ease);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.filters button small { opacity: 0.6; font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }
@media (hover: hover) { .filters button:hover { color: var(--text); } }
.filters button[aria-pressed="true"] {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.07));
  box-shadow: inset 0 1px 0.5px rgba(255,255,255,0.6), inset 0 -1px 0.5px rgba(255,255,255,0.12), 0 4px 14px -6px rgba(0,0,0,0.6);
}
.filters button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.section-title { display: flex; align-items: baseline; gap: 10px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 34px 4px 14px; }
.section-title:first-child { margin-top: 0; }
.section-title small { font-size: 14px; color: var(--faint); font-weight: 500; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { padding: 24px; }
.panel form { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.preview { aspect-ratio: 4 / 3; border-radius: 16px; background: rgba(255,255,255,0.92) center / contain no-repeat; }
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: 20px; background: rgba(255,255,255,0.04); box-shadow: inset 0 1px 0 rgba(255,255,255,0.12); }
.item .thumb { width: 64px; height: 64px; border-radius: 14px; flex: none; background: rgba(255,255,255,0.92) center / contain no-repeat; }
.item .txt { flex: 1; min-width: 0; }
.item .txt b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .txt small { color: var(--muted); font-size: 13px; }
.item .btns { display: flex; gap: 6px; }
.stack { display: grid; gap: 20px; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; padding: 12px 20px; border-radius: 999px; font-size: 14px; transition: 0.35s var(--ease); z-index: 20; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.fade-in { animation: fadeIn 0.6s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

@media (max-width: 760px) {
  .admin-grid { grid-template-columns: 1fr; }
  .top { padding: 22px 20px; }
  .unit b { font-size: 24px; }
  .item { flex-wrap: wrap; }
  .item .btns { width: 100%; }
  .item .btns .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  .fade-in { animation: none; }
  .card, .btn { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .btn { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: #16161c; }
}
