:root {
  --night: #0b1a33;
  --night-2: #12284d;
  --red: #c8102e;
  --red-dark: #8e0b20;
  --gold: #f2c14e;
  --snow: #f7f9fc;
  --ink: #1d2433;
  --green: #1f6f4a;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--snow);
  background: radial-gradient(ellipse at top, var(--night-2), var(--night) 70%);
  overflow: hidden;
}

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.top, .countdown-bar, #chat, .composer { position: relative; z-index: 1; }
.top { z-index: 5; } /* le menu ☰ passe au-dessus du compte à rebours */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(var(--red), var(--red-dark));
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  border-bottom: 4px solid var(--snow);
}

.avatar {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  font-size: 30px;
  border-radius: 50%;
  background: var(--snow);
  box-shadow: 0 0 0 3px var(--gold);
}

.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 1.2rem; letter-spacing: .02em; }
.who p { margin: 2px 0 0; font-size: .85rem; opacity: .9; }

.actions { display: flex; gap: 8px; }

.pill {
  min-width: 42px; height: 36px; padding: 0 10px;
  border: 2px solid var(--snow);
  border-radius: 18px;
  background: transparent;
  color: var(--snow);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
}
.pill:active { background: rgba(255, 255, 255, .2); }

.actions { position: relative; }
.menu-btn { font-size: 1.25rem; line-height: 1; }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  min-width: 220px;
  padding: 6px;
  border-radius: 12px;
  background: var(--snow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  border-top: 4px solid var(--gold);
}
.menu[hidden] { display: none; }
.menu button {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: rgba(200, 16, 46, .1); outline: none; }
.menu #reset { color: var(--red); }

.countdown-bar {
  padding: 10px 12px 12px;
  text-align: center;
  background: rgba(11, 26, 51, .75);
  border-bottom: 1px solid rgba(242, 193, 78, .35);
}
.cd-title { margin: 0 0 6px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.countdown { display: flex; justify-content: center; gap: 8px; }
.unit {
  min-width: 64px;
  padding: 6px 4px;
  border-radius: 10px;
  background: var(--snow);
  color: var(--red);
  box-shadow: 0 2px 0 var(--red-dark), 0 3px 8px rgba(0, 0, 0, .3);
}
.unit b { display: block; font-size: 1.55rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.unit span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); }
.countdown.today .merry { font-size: 1.4rem; font-weight: 700; color: var(--gold); }

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.4;
  font-size: 1.02rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  animation: pop .25s ease-out;
}

.msg.santa {
  align-self: flex-start;
  background: var(--snow);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  border-left: 4px solid var(--red);
}

.msg.user {
  align-self: flex-end;
  background: var(--green);
  color: var(--snow);
  border-bottom-right-radius: 4px;
}

.msg.note {
  align-self: center;
  max-width: 92%;
  background: rgba(242, 193, 78, .15);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: .9rem;
  text-align: center;
  box-shadow: none;
}

.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11, 26, 51, .92);
  border-top: 1px solid rgba(255, 255, 255, .12);
}

#input {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 11px 14px;
  border: 2px solid transparent;
  border-radius: 22px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--snow);
  outline: none;
}
#input:focus { border-color: var(--gold); }

#send {
  width: 46px; height: 46px; flex: none;
  border: none;
  border-radius: 50%;
  background: var(--red);
  color: var(--snow);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--gold);
}
#send:disabled { opacity: .5; }

@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; }
}
