:root {
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --text-primary: #2C2C2A;
  --text-secondary: #5F5E5A;
  --text-muted: #B4B2A9;
  --border: #E5E3DA;
  --accent: #0F6E56;
  --accent-light: #E1F5EE;
  --radius: 10px;
  --nav-height: 76px;
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: block;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 20px;
}

.logo-icon-lg {
  width: 64px;
  height: 64px;
  border-radius: 16px;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 4;
  height: var(--nav-height);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topnav .logo {
  flex-shrink: 0;
  font-size: 18px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 1;
  min-width: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg);
}

.nav-item.active {
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-item-muted {
  color: var(--text-muted);
}

.nav-item-form-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin: 0;
  box-sizing: border-box;
}

.nav-logout-form {
  margin: 0;
}

.nav-item-form-btn.mask-mode-on {
  color: #A32D2D;
  font-weight: 500;
}

.tag-row-hidden {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.4;
}

.tag-row-hidden:has(input:checked) {
  opacity: 1;
}

@media (max-width: 600px) {
  :root {
    --nav-height: 68px;
  }

  .topnav {
    padding: 6px 10px;
  }

  .topnav .logo {
    font-size: 16px;
  }

  .nav-item {
    padding: 4px 6px;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }

  .nav-label {
    display: none;
  }

  .nav-item-desktop-only {
    display: none;
  }

  .nav-links {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex-shrink: 0;
  }
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.snap-launch-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
}

.snap-launch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
}

.snap-launch-btn svg {
  width: 56px;
  height: 56px;
}

@media (min-width: 900px) {
  .page-wide {
    max-width: 1400px;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 16px 14px 48px;
  }
}

.page-narrow {
  max-width: 560px;
}


.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  padding: 0;
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  border-radius: 14px;
  text-decoration: none;
  cursor: pointer;
}

.nav-action-btn svg {
  width: 30px;
  height: 30px;
}

.nav-action-btn:disabled {
  opacity: 0.6;
}

.nav-actions-compact .nav-action-btn {
  width: 34px;
  height: 34px;
}

.nav-actions-compact .nav-action-btn svg {
  width: 17px;
  height: 17px;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 24px;
}

/* Timeline grid */
.timeline-date.day-marker {
  grid-column: 1 / -1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 28px 0 8px;
  text-transform: capitalize;
}

.timeline-date.day-marker:first-child {
  margin-top: 0;
}

.entry-tile-date-badge {
  display: none;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  touch-action: pan-y;
}

/* Zoom du fil sur iPhone : le mode compact est activé par pincement. */
@media (max-width: 899px) {
  .entry-grid.feed-grid-compact,
  .entry-grid-masonry.feed-grid-compact {
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .entry-grid-masonry.feed-grid-compact {
    grid-auto-rows: 38px;
  }

  .entry-grid.feed-grid-maxi-compact,
  .entry-grid-masonry.feed-grid-maxi-compact {
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
  }

  .entry-grid-masonry.feed-grid-maxi-compact {
    grid-auto-rows: 24px;
  }

  /* Vue muette en compact : les réglages d'affichage restent inchangés
     dès que l'on revient aux deux colonnes. */
  .entry-grid.feed-grid-compact .entry-tile-top,
  .entry-grid.feed-grid-compact .entry-tile-bottom {
    display: none;
  }

  /* Un moment sans média doit rester identifiable, même en vue muette. */
  .entry-grid.feed-grid-compact .entry-tile-plain .entry-tile-bottom {
    display: block;
  }

  .entry-grid.feed-grid-maxi-compact .entry-tile-top,
  .entry-grid.feed-grid-maxi-compact .entry-tile-bottom,
  .entry-grid.feed-grid-maxi-compact .mosaic-more {
    display: none;
  }

  /* Ne pas utiliser display:none : les images lazy doivent continuer à se
     charger plus bas dans le fil pour calculer leur couleur moyenne. */
  .entry-grid.feed-grid-maxi-compact .entry-tile img,
  .entry-grid.feed-grid-maxi-compact .entry-tile video {
    opacity: 0;
  }

  .entry-grid.feed-grid-maxi-compact .entry-tile {
    animation: maxiTilePulse 2.8s ease-in-out infinite;
    animation-delay: calc(var(--maxi-index, 0) * -0.19s);
    transform-origin: center;
    will-change: transform, filter;
  }

  @keyframes maxiTilePulse {
    0%, 100% {
      transform: scale(0.96);
      filter: brightness(0.92) saturate(0.95);
    }
    50% {
      transform: scale(1.04);
      filter: brightness(1.18) saturate(1.2);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .entry-grid.feed-grid-maxi-compact .entry-tile {
      animation: none;
    }
  }
}

/* Fil continu (pas de regroupement par date) : appliqué à toutes les
   largeurs sur .page-wide, badge de date affiché sur chaque tuile. */
.page-wide .day-marker {
  display: none;
}

.page-wide .entry-tile-date-badge {
  display: inline-flex;
}

@media (min-width: 900px) {
  .page-wide .entry-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
}

@media (min-width: 1300px) {
  .page-wide .entry-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Disposition alternative : colonnes en cascade (masonry) avec des tuiles
   de hauteurs variées, au lieu de la grille carrée stricte. Réglable
   dans les paramètres. */
.entry-grid-masonry {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 70px;
  grid-auto-flow: row dense;
  gap: 4px;
}

.entry-grid-masonry .entry-tile {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
}

.entry-grid-masonry .entry-tile:nth-child(5n+1) { grid-row: span 3; }
.entry-grid-masonry .entry-tile:nth-child(5n+2) { grid-row: span 2; }
.entry-grid-masonry .entry-tile:nth-child(5n+3) { grid-row: span 3; }
.entry-grid-masonry .entry-tile:nth-child(5n+4) { grid-row: span 2; }
.entry-grid-masonry .entry-tile:nth-child(5n+5) { grid-row: span 4; }

@media (min-width: 900px) {
  .page-wide .entry-grid-masonry {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 60px;
    gap: 8px;
  }
}

@media (min-width: 1300px) {
  .page-wide .entry-grid-masonry {
    grid-template-columns: repeat(6, 1fr);
  }
}

.entry-tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  text-decoration: none;
  background: var(--accent-light);
}

.entry-tile-clickable {
  cursor: pointer;
}

.entry-tile-uploading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.entry-upload-state {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-secondary);
  text-align: center;
}

.entry-upload-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.entry-tile-uploading.is-sending .entry-upload-icon {
  display: none;
}

.entry-tile-uploading.is-error .entry-upload-icon {
  background: rgba(163, 45, 45, 0.12);
  color: #A32D2D;
}

.entry-upload-text {
  max-width: 100%;
  font-size: clamp(10px, 3.5vw, 14px);
  font-weight: 500;
  line-height: 1.3;
}

.entry-upload-progress {
  width: min(150px, 85%);
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.entry-upload-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.15s ease-out;
}

.entry-upload-retry {
  padding: 6px 10px;
  border: 0;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.media-upload-card {
  width: 100%;
  min-height: 116px;
  margin: 12px 0;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.media-upload-card.is-sending .entry-upload-icon {
  display: none;
}

.media-upload-card.is-error .entry-upload-progress {
  display: none;
}

.media-upload-card.is-error .entry-upload-icon {
  background: rgba(163, 45, 45, 0.12);
  color: #A32D2D;
}

.mention-link {
  color: inherit;
  text-decoration: underline;
}

.entry-tile-plain {
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.entry-tile-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entry-tile-mosaic {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 1px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.entry-tile-mosaic-2 {
  grid-template-rows: 1fr;
}

.entry-tile-mosaic-3 .mosaic-cell:first-child {
  grid-row: span 2;
}

.mosaic-cell {
  position: relative;
  overflow: hidden;
}

.mosaic-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mosaic-more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

.entry-tile-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 22px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 1;
}

.entry-tile-top {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  z-index: 2;
}

.entry-tile-badge {
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.entry-tile-plain .entry-tile-badge {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.entry-tile-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  z-index: 1;
}

.entry-tile-photo .entry-tile-text {
  color: #fff;
  font-family: var(--entry-font, "Yuyu", cursive);
  font-size: calc(16px * var(--entry-font-scale, 1));
  font-weight: var(--entry-font-weight, 400);
  font-style: var(--entry-font-style, normal);
  line-height: 1.3;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-tile-plain .entry-tile-bottom {
  position: static;
  background: none;
  padding: 10px;
  width: 100%;
}

.entry-tile-plain .entry-tile-text {
  color: var(--text-primary);
  font-family: var(--entry-font, "Yuyu", cursive);
  font-size: calc(17px * var(--entry-font-scale, 1));
  font-weight: var(--entry-font-weight, 400);
  font-style: var(--entry-font-style, normal);
  line-height: 1.4;
  margin: 0;
  text-align: center;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tags */
.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
}

.btn-cancel {
  flex: 1;
  background: #2b6fd9;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
}

.btn-cancel:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-delete {
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}

.btn-delete:hover {
  color: #A32D2D;
}

.delete-friend-form {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}


.existing-media {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.existing-media-item {
  position: relative;
  margin: 0;
}

.existing-media-item img.existing-media-photo {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  cursor: pointer;
}

.existing-media-item video {
  max-width: 140px;
  max-height: 100px;
  border-radius: var(--radius);
}

.existing-media-remove {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--surface);
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.existing-media-item.marked-for-delete img,
.existing-media-item.marked-for-delete video {
  opacity: 0.3;
}

.existing-media-item.marked-for-delete .existing-media-remove {
  background: #A32D2D;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden {
  display: none;
}

.lightbox-media img,
.lightbox-media video {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.hero-slide-expand {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 46px;
  left: 8px;
  z-index: 2;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.hero-slide-expand svg {
  width: 32px;
  height: 32px;
}

.lightbox-btn {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 24px;
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.edit-nav-arrow {
  display: none;
}

@media (min-width: 900px) {
  .edit-nav-arrow {
    display: flex;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 24px;
    text-decoration: none;
    z-index: 50;
  }

  .edit-nav-arrow-left {
    left: calc(50% - 280px - 60px);
  }

  .edit-nav-arrow-right {
    right: calc(50% - 280px - 60px);
  }
}

.text-nav-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.text-nav-middle {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.text-nav-middle .meta-row {
  gap: 4px;
  justify-content: center;
}

.text-nav-arrow {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 20px;
  text-decoration: none;
}

@media (min-width: 900px) {
  .text-nav-arrow {
    display: none;
  }
}

.friend-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
}

/* Forms */
.event-form, .inline-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: end;
}

.form-row > * { flex: 1; }

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 16px;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px 16px;
}

.modal-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.datetime-compact {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 0 6px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.datetime-edit-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 4px;
  margin: 0;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.datetime-edit-btn svg {
  width: 14px;
  height: 14px;
}

.datetime-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.event-form .datetime-group input {
  width: auto;
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.datetime-group input:first-child {
  border-right: 1px solid var(--border);
}

.datetime-group-compact {
  flex: 0 0 auto;
}

.datetime-group.datetime-group-compact input {
  padding: 10px 8px;
  font-size: 13px;
}

.datetime-group.datetime-group-compact input[type="date"] {
  flex: 0 0 142px;
}

.datetime-group.datetime-group-compact input[type="time"] {
  flex: 0 0 108px;
}

@media (max-width: 600px) {
  .datetime-group.datetime-group-compact input[type="date"] {
    flex-basis: 148px;
  }

  .datetime-group.datetime-group-compact input[type="time"] {
    flex-basis: 112px;
  }
}

.location-wrapper {
  flex: 1;
  min-width: 0;
}

.gps-dot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  background: none;
  border: none;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  align-self: center;
}

.text-hero {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
}

.text-hero-textarea-wrap {
  flex: 1;
  display: flex;
}

.text-hero textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  resize: none;
  padding: 56px 24px 24px;
  font-family: var(--entry-font, "Yuyu", cursive);
  font-size: calc(26px * var(--entry-font-scale, 1));
  line-height: 1.4;
  text-align: left;
  color: var(--text-primary);
}

.text-hero textarea:focus {
  outline: none;
}

.location-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.hero-top-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.hero-top-overlay .datetime-compact {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  max-width: 60vw;
}

.hero-top-overlay #datetimeText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

.hero-top-overlay .datetime-edit-btn {
  color: rgba(255, 255, 255, 0.85);
}

.back-to-feed-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.back-to-feed-btn svg {
  width: 18px;
  height: 18px;
}

.hero-top-overlay .gps-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  font-size: 16px;
  align-self: center;
}

.hero-top-overlay .gps-dot svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 4px;
}

/* Resserre les boutons pour qu'ils tiennent sur une ligne sans déborder */
.meta-row .tag-dropdown-btn {
  padding: 0 12px;
  font-size: 13px;
}

.meta-row .people-dropdown-btn {
  padding: 0 11px;
}

.meta-row .attach-btn {
  width: 38px;
  height: 38px;
}

.meta-row .attach-btn svg {
  width: 17px;
  height: 17px;
}

.meta-row select.mood-select {
  flex: 0 0 44px;
  width: 44px;
}

.event-form select.mood-select {
  flex: 0 0 52px;
  width: 52px;
  height: 44px;
  padding: 0 2px;
  text-align: center;
  text-align-last: center;
  border-radius: 22px;
}

.tag-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.tag-dropdown-btn {
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
}

.hidden-toggle-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  text-align: center;
}

.meta-row .hidden-toggle-btn {
  width: 38px;
  height: 38px;
}

.hidden-toggle-active {
  background: rgba(163, 45, 45, 0.12);
  border-color: #A32D2D;
  color: #A32D2D;
}

.tag-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  min-width: 180px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-dropdown-panel.hidden {
  display: none;
}

.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  margin: 0;
}

.tag-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.tag-option span {
  line-height: 1.2;
}

.tag-option:hover {
  background: var(--bg);
}

/* Sélecteur « Personnes » (silhouette) — réutilise .tag-dropdown */
.people-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
}

.people-dropdown-btn svg {
  width: 20px;
  height: 20px;
}

.people-count {
  font-size: 14px;
  line-height: 1;
}

.people-count.hidden {
  display: none;
}

.people-empty {
  padding: 16px;
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  grid-column: 1 / -1;
  text-align: center;
}

.people-empty a {
  color: var(--accent);
}

/* Chips des personnes taguées, affichées sur le hero */
.tagged-friends {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  pointer-events: auto;
}

.tagged-friends:empty {
  display: none;
}

.tagged-friend-chip {
  font-size: 12px;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
}

/* Sur le hero « texte seul » (fond clair), on épingle les chips en bas */
.text-hero .tagged-friends {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  margin: 0;
  z-index: 2;
}

/* --- Écran plein de sélection des personnes --- */
body.people-picker-open {
  overflow: hidden;
}

body.lightbox-open {
  overflow: hidden;
}

.people-picker {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.people-picker.hidden {
  display: none;
}

.people-picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}

.people-picker-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.people-picker-close svg {
  width: 20px;
  height: 20px;
}

.people-picker-search-wrap {
  flex: 1;
}

.people-picker-search {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
}

.people-picker-search:focus {
  outline: none;
  border-color: var(--accent);
}

.people-picker-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.people-picker-discovery {
  padding: 14px 12px 0;
}

.people-picker-discovery.hidden,
.people-picker.searching .people-picker-discovery,
.people-picker.searching .people-picker-all-title {
  display: none;
}

.people-picker-section-title,
.people-picker-all-title {
  margin: 0 0 9px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.people-picker-all-title {
  padding: 16px 12px 0;
}

.people-picker-quick-list {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 1px 5px;
  scrollbar-width: none;
}

.people-picker-quick-list::-webkit-scrollbar {
  display: none;
}

.people-picker-quick-person {
  appearance: none;
  flex: 0 0 58px;
  width: 58px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.people-picker-quick-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  margin: 0 auto 5px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.people-picker-quick-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.people-picker-quick-avatar .people-picker-initials {
  font-size: 14px;
}

.people-picker-quick-person.selected .people-picker-quick-avatar {
  border-color: var(--accent);
}

.people-picker-quick-person.selected .people-picker-check {
  display: flex;
}

.people-picker-quick-person .people-picker-check svg {
  width: 21px;
  height: 21px;
}

.people-picker-quick-name {
  display: block;
  width: 58px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people-picker-grid {
  overflow: visible;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 14px 8px;
  padding: 0 12px;
  align-content: start;
}

.people-picker-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  cursor: pointer;
}

.people-picker-tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.people-picker-avatar {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid transparent;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s ease;
}

.people-picker-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.people-picker-initials {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}

.people-picker-check {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 110, 86, 0.55);
  color: #fff;
}

.people-picker-check svg {
  width: 30px;
  height: 30px;
}

.people-picker-tile.selected .people-picker-avatar {
  border-color: var(--accent);
}

.people-picker-tile.selected .people-picker-check {
  display: flex;
}

.people-picker-name {
  max-width: 84px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: center;
  overflow: hidden;
  line-height: 1.3;
}

/* --- Réorganisation des photos d'un moment (glisser-déposer) --- */
body.photo-reorder-open {
  overflow: hidden;
}

.people-picker-title {
  font-weight: 600;
  color: var(--text-primary);
}

.reorder-hint {
  padding: 0 16px 12px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.reorder-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  padding: 0 12px 16px;
  align-content: start;
}

.reorder-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  cursor: grab;
  border: 2px solid transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.reorder-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.reorder-tile-video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  background: #000;
}

.reorder-tile.dragging {
  opacity: 0.4;
  border-color: var(--accent);
}

.reorder-tile-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #FF5C4D;
  cursor: pointer;
  touch-action: none;
  z-index: 2;
}

.reorder-tile-delete svg {
  width: 16px;
  height: 16px;
}

.reorder-modal-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* En dessous de ~768px (mobile), le panneau reste plein écran, cohérent
   avec le sélecteur de personnes. Au-dessus, il se comporte comme une
   vraie boîte de dialogue centrée plutôt que de coller le contenu en
   haut à gauche d'une page vide. */
@media (min-width: 768px) {
  .reorder-panel {
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
  }

  .reorder-panel .reorder-modal-card {
    flex: none;
    width: min(640px, 90vw);
    max-height: 80vh;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
  }

  .reorder-panel .people-picker-header {
    padding-top: 12px;
  }
}

.attach-btn {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  vertical-align: middle;
}

.attach-btn svg {
  width: 20px;
  height: 20px;
}

.attach-btn.has-file {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.attach-btn.recording {
  background: #A32D2D;
  border-color: #A32D2D;
  color: #fff;
  animation: record-pulse 1s infinite;
}

.attach-btn-danger {
  background: #A32D2D;
  border-color: #A32D2D;
  color: #fff;
}

.attach-btn-loading {
  opacity: 0.5;
  pointer-events: none;
}

@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(163, 45, 45, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(163, 45, 45, 0); }
}

.sound-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.sound-preview-item audio {
  flex: 1;
  min-width: 0;
}

.sound-preview-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--surface);
  border: none;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.photo-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.photo-preview {
  position: relative;
  width: 64px;
  height: 64px;
}

.photo-preview img,
.photo-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

.photo-preview-video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.photo-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--surface);
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 10px;
}

.insta-note-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  display: flex;
  flex-direction: column;
}

.insta-note-overlay.hidden {
  display: none !important;
}

.insta-note-media {
  position: absolute;
  inset: 0;
}

.insta-note-media img,
.insta-note-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.insta-note-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
}

.insta-note-icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.insta-note-save-btn {
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent, #fff);
  color: #000;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.insta-note-bottom {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.insta-note-text {
  width: 100%;
  resize: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
}

.insta-note-text::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.insta-upload-status {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 310;
  width: max-content;
  max-width: calc(100vw - 28px);
  min-height: 48px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.insta-upload-status.hidden {
  display: none;
}

.insta-upload-status-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
}

.insta-upload-status.is-sending .insta-upload-status-icon {
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  background: transparent;
  animation: insta-upload-spin 0.8s linear infinite;
}

.insta-upload-status.is-error .insta-upload-status-icon {
  background: rgba(163, 45, 45, 0.12);
  color: #A32D2D;
}

.insta-upload-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}

.insta-upload-status-action,
.insta-upload-status-dismiss {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.insta-upload-status-dismiss {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
}

@keyframes insta-upload-spin {
  to { transform: rotate(360deg); }
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
}

.event-form input,
.event-form select,
.event-form textarea {
  width: 100%;
}

textarea { resize: vertical; }

#qcText {
  resize: none;
  overflow: hidden;
}

/* iOS Safari zooms in on focus when a field's font-size is under 16px,
   which shifts the whole page layout. Force 16px on mobile regardless
   of any more specific rule elsewhere. */
@media (max-width: 600px) {
  input, select, textarea {
    font-size: 16px !important;
  }

  .text-hero textarea {
    font-size: calc(22px * var(--entry-font-scale, 1)) !important;
  }
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  margin-top: 16px;
  font-weight: 500;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  text-decoration: none;
  display: inline-block;
}

.mention-wrapper {
  position: relative;
}

.mention-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.mention-menu.hidden { display: none; }

.mention-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.mention-option:hover {
  background: var(--accent-light);
}

/* Friends */
.friend-search-wrap {
  margin-bottom: 16px;
}

.friend-search {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
  box-sizing: border-box;
}

.friend-search:focus {
  outline: none;
  border-color: var(--accent);
}

.friend-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 12px 4px;
}

.friend-avatar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: inherit;
  text-align: center;
}

.friend-avatar-wrap {
  position: relative;
  width: 54px;
  height: 54px;
}

.friend-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
  font-size: 16px;
}

.friend-category-badge {
  position: absolute;
  bottom: -2px;
  left: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.friend-count-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.friend-avatar-name {
  font-size: 12px;
  font-weight: 500;
  margin: 0;
  max-width: 66px;
  text-align: center;
  overflow: hidden;
  line-height: 1.3;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 16px;
}

.avatar-photo {
  object-fit: cover;
}

.avatar-cropper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.avatar-canvas {
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  touch-action: none;
}

.avatar-cropper input[type="range"] {
  width: 100px;
}

.avatar-cropper-trigger {
  position: relative;
  cursor: pointer;
  display: block;
}

.avatar-cropper-plus {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-muted);
  pointer-events: none;
}

.avatar-cropper-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  pointer-events: none;
}

.add-friend-form {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.add-friend-form-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.add-friend-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 160px;
}

.add-friend-fields input,
.add-friend-fields select,
.add-friend-fields button {
  width: 100%;
}

.add-friend-tile {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.friend-avatar-add {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong, var(--border));
}

.friend-name {
  margin: 0;
  font-weight: 500;
  font-size: 14px;
}

.friend-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.friend-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.friend-avatar-edit-wrap {
  position: relative;
  flex-shrink: 0;
}

.friend-edit-pencil {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.friend-edit-pencil svg {
  width: 13px;
  height: 13px;
}

.stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 500;
  margin: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.history-item-text {
  flex: 1;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.history-item-open-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
}

.history-item-open-btn svg {
  width: 16px;
  height: 16px;
}

.history-item-open-btn:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.history-date {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 12px;
}

/* Heatmap */
.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.heatmap-header h3 {
  text-transform: capitalize;
  margin: 0;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.heat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
}

.heat-empty { visibility: hidden; }
.heat-0 { background: var(--surface); border: 1px solid var(--border); }
.heat-1 { background: #9FE1CB; color: #04342C; }
.heat-2 { background: #5DCAA5; color: #04342C; }
.heat-3 { background: #0F6E56; color: #fff; }

.heat-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.heat-legend .heat-cell {
  width: 14px;
  height: 14px;
  aspect-ratio: unset;
}

.heat-cell-clickable {
  cursor: pointer;
}

.heat-cell-clickable:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.heat-cell-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  font-weight: 700;
}

.day-entries-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.day-entries-title {
  text-transform: capitalize;
  margin: 0 0 12px;
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: min(320px, calc(100% - 32px));
  text-align: center;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.error {
  color: #A32D2D;
  font-size: 14px;
}

.remember-me-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  margin: 4px 0 8px;
  cursor: pointer;
}

.remember-me-label input {
  width: auto;
}

/* Trash */
.trash-tile-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trash-tile-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.trash-tile-actions form {
  margin: 0;
}

.trash-tile-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trash-tile-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.trash-tile-btn-danger:hover {
  border-color: #A32D2D;
  color: #A32D2D;
}

/* Map */
.map-view {
  height: 70vh;
  min-height: 320px;
  border-radius: 12px;
  overflow: hidden;
}

.hero-slide-map-panel {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 4;
  background: rgba(0, 0, 0, 0.75);
  border-radius: var(--radius);
  padding: 8px;
}

.hero-slide-map-panel .entry-map {
  margin-top: 0;
  height: 180px;
}

.hero-slide-map-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.entry-map {
  height: 220px;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 10px;
}

/* Hero photo carousel (edit view) */
.hero-carousel-wrap {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.hero-carousel {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.hero-carousel::-webkit-scrollbar {
  display: none;
}

.hero-slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: center;
  aspect-ratio: 4 / 5;
  background: #000;
}

.hero-slide img,
.hero-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}

.hero-slide.marked-for-delete img,
.hero-slide.marked-for-delete video {
  opacity: 0.3;
}

.hero-slide-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 2;
}

.hero-slide-remove svg {
  width: 40px;
  height: 40px;
}

.hero-photo-count {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 12px;
}

.hero-top-overlay .hero-photo-count {
  position: static;
  flex: 0 0 auto;
}

.hero-photo-count svg {
  width: 14px;
  height: 14px;
}

.hero-photo-nav {
  display: none;
}

@media (min-width: 900px) {
  .hero-photo-nav {
    display: flex;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
  }

  .hero-photo-nav-prev {
    left: 10px;
  }

  .hero-photo-nav-next {
    right: 10px;
  }
}

.hero-text-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 50%;
  padding: 20px 12px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7) 40%);
  z-index: 1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hero-text-overlay .mention-wrapper {
  pointer-events: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.hero-text-overlay textarea {
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: transparent;
  border: none;
  color: #fff;
  resize: none;
  font-family: var(--entry-font, "Yuyu", cursive);
  font-size: calc(16px * var(--entry-font-scale, 1));
  font-weight: var(--entry-font-weight, 400);
  font-style: var(--entry-font-style, normal);
  padding: 0;
  min-height: 44px;
  overflow-y: auto;
  box-sizing: border-box;
}

.hero-text-overlay textarea::placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.hero-text-overlay textarea:focus {
  outline: none;
}

.hero-text-display {
  padding-right: 40px;
  pointer-events: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.hero-text-display-text {
  color: #fff;
  font-family: var(--entry-font, "Yuyu", cursive);
  font-size: calc(16px * var(--entry-font-scale, 1));
  font-weight: var(--entry-font-weight, 400);
  font-style: var(--entry-font-style, normal);
  white-space: pre-wrap;
  word-break: break-word;
}

.hero-text-placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.hero-text-edit-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  cursor: pointer;
  pointer-events: auto;
}

.hero-text-edit-btn svg {
  width: 16px;
  height: 16px;
}

.hero-text-edit-btn .hero-text-done-icon.hidden {
  display: none;
}

.text-hero-edit-btn {
  top: 56px;
  right: 24px;
  bottom: auto;
}

.text-hero-display {
  padding: 56px 24px 24px;
}

.text-hero-display .hero-text-display-text {
  color: var(--text-primary);
  font-family: var(--entry-font, "Yuyu", cursive);
  font-size: calc(26px * var(--entry-font-scale, 1));
  line-height: 1.4;
}

.text-hero-display .hero-text-placeholder {
  color: var(--text-secondary);
}

/* Tag colors — placed last to reliably win over .entry-tile-badge etc. */
.tag.tag-coral, .entry-tile-badge.tag-coral { background: #FAECE7; color: #712B13; }
.tag.tag-pink, .entry-tile-badge.tag-pink { background: #FBEAF0; color: #72243E; }
.tag.tag-teal, .entry-tile-badge.tag-teal { background: #E1F5EE; color: #085041; }
.tag.tag-blue, .entry-tile-badge.tag-blue { background: #E6F1FB; color: #0C447C; }
.tag.tag-green, .entry-tile-badge.tag-green { background: #EAF3DE; color: #27500A; }
.tag.tag-purple, .entry-tile-badge.tag-purple { background: #EEEDFE; color: #3C3489; }
.tag.tag-amber, .entry-tile-badge.tag-amber { background: #FAEEDA; color: #633806; }
.tag.tag-gray, .entry-tile-badge.tag-gray { background: #F1EFE8; color: #444441; }

/* Tags management page */
.tags-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tag-row-name {
  flex: 1 1 120px;
  min-width: 0;
}

.tag-row-usage {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.color-picker {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  background: none;
  overflow: hidden;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-picker::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.tag-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.add-tag-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: var(--radius);
}

.add-tag-form input[type="text"] {
  flex: 1 1 120px;
  min-width: 0;
}

/* Settings page */
.settings-section-title {
  font-size: 15px;
  margin: 28px 0 12px;
}

.settings-section-title:first-child {
  margin-top: 0;
}

.stats-panel {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.tile-display-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.tile-display-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.tile-display-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.stats-tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stats-tile-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.stats-tile-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.backup-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.backup-panel .settings-section-title {
  margin: 0 0 4px;
}

.backup-panel .settings-hint {
  margin: 0;
}

.trashed-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.trashed-media-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trashed-media-item a {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.trashed-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trashed-media-video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-secondary);
}

.trashed-media-date {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.trashed-media-item form {
  display: flex;
}

.trashed-media-item .btn-sm {
  width: 100%;
}

.font-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.font-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-size: 16px;
  line-height: 1.2;
}

.font-option input {
  display: none;
}

.font-option-selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.font-option-delete {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.font-option-delete:hover {
  color: #A32D2D;
}

.font-style-panel {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.font-preview-tile {
  width: 140px;
  flex-shrink: 0;
  margin: 0;
}

.font-style-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.font-style-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-style-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
}

.font-style-toggle-active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--text-primary);
}

.add-custom-font-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.add-custom-font-form input[type="url"] {
  flex: 1 1 220px;
  min-width: 0;
}

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.settings-hint code {
  font-size: 11px;
}

.font-size-form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.font-size-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.font-size-value {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
}
