:root {
  --fs: 1;
  --accent: #b3202b; --fill: #b3202b; --accent2: #1f5d3a; --gold: #d4a63c;
  --bg: #fbf5ec; --bg2: #f3e8d6; --card: #ffffff; --text: #2a1f1c; --muted: #7a6a62; --line: rgba(0,0,0,.1);
  --radius: 18px;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-text="s"] { --fs: .88; }
[data-text="l"] { --fs: 1.2; }
[data-text="xl"] { --fs: 1.4; }
[data-accent="foret"]   { --accent: #1f5d3a; --fill: #1f5d3a; --accent2: #b3202b; --gold: #d4a63c; }
[data-accent="nuit"]    { --accent: #2b4a8b; --fill: #2b4a8b; --accent2: #46608f; --gold: #e3e8f2; }
[data-accent="or"]      { --accent: #8a5a10; --fill: #8a5a10; --accent2: #5a3b14; --gold: #e8c35a; }
[data-accent="givre"]   { --accent: #3f6d93; --fill: #3f6d93; --accent2: #b3202b; --gold: #ffffff; }
[data-accent="bordeaux"]{ --accent: #7a1f3d; --fill: #7a1f3d; --accent2: #9a5328; --gold: #e0b97a; }

[data-mode="dark"] {
  --bg: #121a1d; --bg2: #1b262a; --card: #1f2b30; --text: #f4ece4; --muted: #a99d94; --line: rgba(255,255,255,.12);
}
[data-mode="dark"][data-accent="sapin"]    { --accent: #ef6f78; }
[data-mode="dark"][data-accent="foret"]    { --accent: #4fae79; }
[data-mode="dark"][data-accent="nuit"]     { --accent: #7b9be0; }
[data-mode="dark"][data-accent="or"]       { --accent: #e0a94a; }
[data-mode="dark"][data-accent="givre"]    { --accent: #8fb6d6; }
[data-mode="dark"][data-accent="bordeaux"] { --accent: #e0709a; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans); font-size: calc(16px * var(--fs)); color: var(--text);
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%), linear-gradient(var(--bg), var(--bg2));
  background-attachment: fixed;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background .4s, color .4s;
}
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 14px 16px 40px; min-height: 100vh; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.btn { background: var(--fill); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent); transition: transform .15s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: none; border: 1.5px solid var(--accent); }
.btn.done { background: var(--accent2); }
.btn:disabled { opacity: .5; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: calc(18px * var(--fs)); display: grid; place-items: center; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0 14px; }
header.top h1 { font-family: var(--serif); font-size: calc(28px * var(--fs)); margin: 0; letter-spacing: .5px; }
header.top h1 small { display: block; font-family: var(--sans); font-size: calc(12px * var(--fs)); font-weight: 400; color: var(--muted); letter-spacing: 0; }
.tools { display: flex; gap: 8px; }

.banner { background: color-mix(in srgb, var(--gold) 30%, var(--card)); border: 1px solid var(--gold); border-radius: 12px; padding: 8px 12px; font-size: calc(13px * var(--fs)); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.hello { font-family: var(--serif); font-size: calc(18px * var(--fs)); text-align: center; margin: 4px 0 16px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; perspective: 800px; }
.tile {
  position: relative; aspect-ratio: 1 / 1.1; border-radius: 14px; display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(26px * var(--fs)); font-weight: 700; color: #fff;
  background: linear-gradient(145deg, var(--fill), color-mix(in srgb, var(--fill) 65%, #000));
  box-shadow: 0 4px 10px rgba(0,0,0,.18), inset 0 0 0 2px color-mix(in srgb, var(--gold) 60%, transparent);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), filter .3s, box-shadow .3s;
  overflow: hidden;
}
.tile::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.28), transparent 55%); pointer-events: none; }
.tile.locked { background: linear-gradient(145deg, var(--bg2), var(--card)); color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line); filter: saturate(.6); }
.tile.locked::after { display: none; }
.tile .lock { position: absolute; bottom: 6px; right: 7px; font-size: calc(11px * var(--fs)); }
.tile.seen { background: linear-gradient(145deg, var(--accent2), color-mix(in srgb, var(--accent2) 60%, #000)); }
.tile.today { animation: pulse 2.2s ease-in-out infinite; box-shadow: 0 0 0 3px var(--gold), 0 0 22px color-mix(in srgb, var(--gold) 70%, transparent); }
.tile .tick { position: absolute; top: 5px; right: 7px; font-size: calc(12px * var(--fs)); }
.tile:not(.locked):active { transform: rotateY(-18deg) scale(.96); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.view { animation: enter .45s cubic-bezier(.2,.8,.2,1); }
@keyframes enter { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; padding: 8px 0 12px; }
.day-title { font-family: var(--serif); text-align: center; font-size: calc(15px * var(--fs)); letter-spacing: 3px; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.photo { width: 100%; aspect-ratio: 4 / 5; max-height: 58vh; border-radius: var(--radius); object-fit: cover; background: var(--bg2); box-shadow: 0 10px 28px rgba(0,0,0,.25); border: 6px solid var(--card); opacity: 0; transform: scale(1.04); transition: opacity .8s, transform .9s cubic-bezier(.2,.8,.2,1); }
.photo.in { opacity: 1; transform: none; }
.quote { font-family: var(--serif); font-size: calc(22px * var(--fs)); line-height: 1.4; text-align: center; margin: 22px 8px; font-style: italic; opacity: 0; animation: enter .7s .35s forwards; }
.quote::before, .quote::after { color: var(--accent); font-size: calc(32px * var(--fs)); line-height: 0; vertical-align: -10px; }
.quote::before { content: "\201C\00a0"; } .quote::after { content: "\00a0\201D"; }
.voucher { background: var(--card); border: 2px dashed var(--accent); border-radius: var(--radius); padding: 18px; text-align: center; position: relative; opacity: 0; animation: enter .7s .6s forwards; }
.voucher .tag { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--fill); color: #fff; font-size: calc(11px * var(--fs)); letter-spacing: 2px; text-transform: uppercase; padding: 3px 12px; border-radius: 999px; white-space: nowrap; }
.voucher h3 { font-family: var(--serif); margin: 6px 0 6px; font-size: calc(20px * var(--fs)); }
.voucher p { margin: 0 0 14px; line-height: 1.45; }
.nav { display: flex; justify-content: space-between; margin-top: 22px; }
.empty { text-align: center; color: var(--muted); padding: 60px 10px; font-family: var(--serif); font-size: calc(18px * var(--fs)); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--bg); color: var(--text); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); animation: enter .3s; }
.sheet h2 { margin: 0 0 14px; font-family: var(--serif); }
.row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px 0; }
.swatch { border: 2px solid var(--line); border-radius: 12px; padding: 10px 6px; font-size: calc(12px * var(--fs)); background: var(--card); display: grid; gap: 6px; justify-items: center; }
.swatch i { width: 34px; height: 34px; border-radius: 50%; display: block; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.switch { width: 52px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.switch[aria-checked="true"] { background: var(--fill); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* Admin */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; list-style: none; }
.card summary::-webkit-details-marker { display: none; }
.pill { font-size: calc(11px * var(--fs)); padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--muted); font-weight: 500; }
.pill.ok { background: color-mix(in srgb, var(--accent2) 28%, transparent); color: var(--text); }
label.f { display: block; font-size: calc(12px * var(--fs)); color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=date], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 78px; resize: vertical; }
.thumb { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-top: 8px; }
.actions { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.msg { font-size: calc(13px * var(--fs)); color: var(--accent2); }
.err { color: #c0392b; }
.login { margin-top: 60px; text-align: center; }
.login .card { text-align: left; }

/* Accessibilité : focus visible partout */
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 55%, transparent); }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
p.hint { margin: 8px 0 0; }
.label { margin: 16px 0 4px; color: var(--muted); font-size: 13px; }
.sizes { display: flex; gap: 8px; align-items: flex-end; padding: 6px 0 10px; }
.size { flex: 1; height: 52px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-family: var(--serif); font-weight: 700; display: grid; place-items: center; }
.size[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.sheet-bg.center { align-items: center; padding: 20px; }
.sheet-bg.center .sheet { border-radius: 22px; max-width: 420px; text-align: center; }
.welcome-text { white-space: pre-line; font-family: var(--serif); font-size: 18px; line-height: 1.5; margin: 0 0 18px; }
.page-title { font-family: var(--serif); margin: 0 0 8px; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 4px 0 18px; }
.bar i { display: block; height: 100%; background: var(--accent2); border-radius: 999px; transition: width .6s; }
.memory { display: flex; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; align-items: stretch; }
.memory img { width: 84px; height: 104px; object-fit: cover; border-radius: 12px; flex: none; }
.memory-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.memory-body em { font-family: var(--serif); }
.memory-body .pill { align-self: flex-start; }
.view.final .photo { max-height: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), 0 14px 36px rgba(0,0,0,.35); }
.final-card { margin-top: 20px; padding: 20px; text-align: center; border-radius: var(--radius); background: linear-gradient(145deg, var(--fill), color-mix(in srgb, var(--fill) 60%, #000)); color: #fff; box-shadow: 0 0 0 3px var(--gold); animation: enter .8s .9s both; }
.final-card h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; }
.final-card p { margin: 0; white-space: pre-line; line-height: 1.5; }
.alert { border-left: 6px solid var(--gold); }
.alert.danger { border-left-color: #c0392b; background: color-mix(in srgb, #c0392b 10%, var(--card)); }
.alert.ok { border-left-color: var(--accent2); }
.alert p { margin: 8px 0 6px; }
.linklike { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: 4px; }
.minis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mini { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 999px; border: 2px solid var(--gold); background: var(--card); font-weight: 700; font-size: 13px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }
.swap { display: flex; gap: 8px; align-items: center; }
.swap select { flex: 1; }
.swap .btn { padding: 10px 16px; flex: none; }
.swap-msg { margin: 8px 0 0; }

/* Admin : barre des jours fixe, éditeur d'un seul jour */
.chips { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.chip { width: 100%; aspect-ratio: 1; min-height: 40px; padding: 0; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: calc(14px * var(--fs)); }
.chip.part { border-color: var(--gold); }
.chip.full { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.chip.cur { box-shadow: 0 0 0 3px var(--accent); transform: scale(1.08); }
.legend { font-size: calc(12px * var(--fs)); color: var(--muted); margin: 6px 0 12px; }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ed-head h2 { margin: 0; font-family: var(--serif); font-size: calc(20px * var(--fs)); text-align: center; }
.icon-btn:disabled { opacity: .35; }
.editor .actions { flex-wrap: wrap; }

.totop { position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); width: 48px; height: 48px; border-radius: 50%; background: var(--fill); color: #fff; font-size: calc(22px * var(--fs)); font-weight: 700; z-index: 70; box-shadow: 0 6px 18px rgba(0,0,0,.3); opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; transition: opacity .25s, transform .25s; }
.totop.show { opacity: 1; transform: none; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.sheet::-webkit-scrollbar { display: none; }
.prep ul.checks { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.prep li.ok { color: var(--accent2); } .prep li.ko { color: var(--danger, #b3261e); font-weight: 600; }
.prep[hidden] { display: none; }
