* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  background: linear-gradient(180deg, #2f6fc9 0%, #5b9be6 55%, #8fbdf0 100%) fixed;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body.night { background: linear-gradient(180deg, #0a1730 0%, #1d2f57 60%, #34487a 100%) fixed; }

[hidden] { display: none !important; }

ol { list-style: none; margin: 0; padding: 0; }

button, select, input, textarea { font: inherit; color: inherit; }

/* ---------- Météo ---------- */

#weather {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 24px);
}

#search input {
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 16px;
  outline: none;
}

#search input::placeholder { color: rgba(255, 255, 255, 0.75); }

.now { text-align: center; padding: 28px 0 20px; }

.now h1 { margin: 0; font-size: 30px; font-weight: 500; }

.temperature {
  margin: 0;
  font-size: 96px;
  font-weight: 200;
  line-height: 1.1;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.condition { margin: 0; font-size: 20px; }

.range { margin: 4px 0 0; font-size: 17px; opacity: 0.9; }

.card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hourly { display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none; }

.hourly::-webkit-scrollbar { display: none; }

.hourly li { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 40px; font-size: 15px; }

.hourly .glyph { font-size: 22px; }

.daily li {
  display: grid;
  grid-template-columns: 1fr 40px 44px 44px;
  align-items: center;
  padding: 8px 0;
  font-size: 17px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.daily li:first-child { border-top: 0; }

.daily .glyph { font-size: 20px; text-align: center; }

.daily .min { text-align: right; opacity: 0.7; }

.daily .max { text-align: right; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.tile { display: flex; flex-direction: column; gap: 6px; }

.tile span { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }

.tile strong { font-size: 22px; font-weight: 400; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 15px;
  white-space: nowrap;
}

/* ---------- Conversation ---------- */

#chat { position: fixed; inset: 0; background: #000; color: #e9ecf1; }

.thread { position: absolute; inset: 0; display: flex; flex-direction: column; background: #101318; }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: #171b22;
  font-size: 15px;
}

.bar > button:first-child { padding: 6px 10px; border: 0; border-radius: 8px; background: #252b35; }

.pending { flex: 1; text-align: center; font-size: 13px; opacity: 0.7; }

.items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* Lignes à plat avec un filet de couleur par auteur, plutôt que des bulles. */
.items li {
  padding: 2px 0 2px 10px;
  border-left: 3px solid #5b9be6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.items li.mine { border-left-color: #e0566b; }

.items li.notice { border: 0; padding: 0; text-align: center; font-size: 13px; opacity: 0.6; }

.items li .author { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: #5b9be6; }

.items li.mine .author { color: #e0566b; }

.items li p { margin: 2px 0 0; }

.items li small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.6; }

.items li button {
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: #5b9be6;
  color: #fff;
  font-weight: 600;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: #171b22;
}

.composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 12px;
  border: 0;
  border-radius: 18px;
  background: #252b35;
  font-size: 16px;
  resize: none;
  outline: none;
}

.icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #252b35;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.icon.send, .icon.shoot { background: #2f6fc9; }

.icon.recording, .icon.active { background: #c23b3b; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(40, 44, 52, 0.85);
  color: #fff;
  font-size: 15px;
}

.pill.primary { background: #2f6fc9; font-weight: 600; }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #e0566b;
  font-size: 11px;
  font-weight: 700;
}

/* ---------- Appareil photo ---------- */

.camera, .editor, .viewer { position: absolute; inset: 0; background: #000; overflow: hidden; }

.camera > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.camera > video.mirrored { transform: scaleX(-1); }

.camera-top, .camera-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

.camera-top { top: env(safe-area-inset-top); }

.camera-bottom { bottom: calc(env(safe-area-inset-bottom) + 16px); }

.camera .icon, .editor .icon, .viewer .icon { background: rgba(20, 22, 28, 0.55); }

.camera-clock {
  padding: 4px 12px;
  border-radius: 999px;
  background: #c23b3b;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.shutter {
  width: 76px;
  height: 76px;
  padding: 0;
  border: 5px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.15s, background 0.15s;
}

.shutter.recording { transform: scale(1.2); background: #c23b3b; }

/* ---------- Éditeur (après la prise) ---------- */

.editor-media, .editor-media > *, .editor-draw { position: absolute; inset: 0; width: 100%; height: 100%; }

.editor-media > .cover, .stage > .cover { object-fit: cover; }

.editor-media > .contain, .stage > .contain { object-fit: contain; }

.editor-draw { pointer-events: none; touch-action: none; }

.editor.drawing .editor-draw { pointer-events: auto; }

.editor.drawing .caption { pointer-events: none; }

.caption {
  position: absolute;
  left: 0;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 17px;
  text-align: center;
  outline: none;
  touch-action: none;
}

.editor-discard { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 20px; }

.editor-tools {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.editor-tools .icon { font-weight: 700; }

.editor-tools .icon.active { background: #2f6fc9; }

.colors { display: flex; flex-direction: column; gap: 8px; }

.colors button { width: 26px; height: 26px; padding: 0; border: 2px solid #fff; border-radius: 50%; }

.colors button.active { transform: scale(1.3); }

.editor-send { position: absolute; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 24px); }

/* ---------- Lecture plein écran ---------- */

.viewer { z-index: 2; }

.viewer-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* La scène reprend les proportions de l'écran de l'expéditeur : le texte et le dessin restent à leur place. */
.stage { position: relative; flex: none; }

.stage > * { position: absolute; inset: 0; width: 100%; height: 100%; }

.viewer-content audio { width: 90%; }

.viewer-bar {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  height: 3px;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
}

.viewer-close { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 20px; }

/* ---------- Autocollants ---------- */

.camera-side { display: flex; gap: 10px; width: 96px; }

.camera-side.end { justify-content: flex-end; }

.editor-stickers { position: absolute; inset: 0; pointer-events: none; }

.sticker {
  position: absolute;
  height: auto;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  cursor: grab;
}

.sticker.emoji { line-height: 1; white-space: nowrap; }

.editor.drawing .sticker { pointer-events: none; }

/* À la lecture, un autocollant garde sa place dans la scène et ne capte pas le toucher. */
.stage > .sticker { inset: auto; height: auto; pointer-events: none; }

.trash {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(20, 22, 28, 0.55);
  font-size: 24px;
  transition: transform 0.15s, background 0.15s;
}

.trash.hot { transform: translateX(-50%) scale(1.3); background: #c23b3b; }

.stickers { position: absolute; inset: 0; display: flex; flex-direction: column; background: #101318; z-index: 1; }

.stickers-top { display: flex; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; min-height: 40px; }

.stickers-top input {
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 20px;
  background: #252b35;
  font-size: 16px;
  outline: none;
}

.stickers-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.stickers-emoji { display: grid; grid-template-columns: repeat(8, 1fr); padding: 0 6px 8px; }

.stickers-emoji button { padding: 6px 0; border: 0; background: none; font-size: 28px; line-height: 1; }

.stickers-grid { columns: 3; column-gap: 6px; padding: 0 6px; }

.stickers-grid button {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: #1b2029;
  break-inside: avoid;
}

.stickers-grid img { display: block; width: 100%; height: 100%; object-fit: contain; }

.stickers-status { margin: 0; padding: 8px 12px; text-align: center; font-size: 14px; opacity: 0.7; }

.stickers-status:empty { display: none; }

.stickers-credit {
  margin: 0;
  padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.6;
}
