@import url("https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap");

/* Theme tokens */
:root {
  --paper: #fff7e8;
  --paper-2: #f9edd6;
  --ink: #2b2b2b;
  --muted: #6b5b4f;
  --accent: #ff6b6b;
  --accent-2: #4ea8de;
  --accent-3: #ffd166;
  --border: #2b2b2b;
  --card: #fffdf7;
  --chip: #fff3d6;
  --chip-active: #ffe1a8;
  --spotlight: #f59e0b;
  --shadow: 6px 6px 0 rgba(43, 43, 43, 0.18);
}

/* Base */
* { box-sizing: border-box; }

body {
  font-family: "Comic Neue", "Trebuchet MS", sans-serif;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 6% -10%, rgba(255, 214, 166, 0.55) 0%, transparent 65%),
    radial-gradient(900px 520px at 96% -20%, rgba(178, 235, 242, 0.55) 0%, transparent 60%),
    repeating-linear-gradient(0deg, var(--paper) 0, var(--paper) 24px, var(--paper-2) 24px, var(--paper-2) 25px);
}

/* Layout */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  position: relative;
}

.title {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(43, 43, 43, 0.2);
  animation: title-pop 650ms ease both;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
  display: inline-flex;
  gap: 6px;
  padding: 6px 10px;
  border: 2px dashed var(--border);
  background: var(--card);
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  animation: panel-pop 500ms ease both;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.control input,
.control select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid var(--border);
  font-size: 14px;
  background: #fff;
}

.btn {
  padding: 9px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--accent);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease;
  position: relative;
}

.btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 rgba(43, 43, 43, 0.25);
}
.btn:active:not(:disabled) {
  transform: translate(0, 0) scale(0.98);
  box-shadow: 2px 2px 0 rgba(43, 43, 43, 0.2);
}
.btn::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 10px;
  border: 2px dashed rgba(43, 43, 43, 0.12);
  pointer-events: none;
}

.btn.btn-lite {
  background: var(--accent-2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Participants */
.participants {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  animation: panel-pop 500ms ease both;
  position: relative;
  overflow: hidden;
}
.participants::before {
  content: "Equipe";
  position: absolute;
  top: 10px;
  right: -22px;
  transform: rotate(8deg);
  background: var(--accent-3);
  border: 2px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.participants-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.participants-title {
  font-size: 16px;
  font-weight: 700;
}

.participants-count {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  border: 2px dashed var(--border);
  background: var(--chip);
}

.participants-spotlight {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.participants-spotlight select {
  padding: 6px 10px;
  border-radius: 999px;
  border: 2px solid var(--border);
  font-size: 12px;
  background: #fff;
  color: var(--ink);
}

.participants-actions {
  display: flex;
  gap: 8px;
}

.participants-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.participant-chip {
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--chip);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  box-shadow: 3px 3px 0 rgba(43, 43, 43, 0.15);
}

.participant-chip:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0 rgba(43, 43, 43, 0.25);
}

.participant-chip.is-active {
  background: var(--chip-active);
  font-weight: 700;
}

.participant-chip.is-spotlight {
  border-color: var(--spotlight);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
  animation: glow-pulse 1.6s ease-in-out infinite;
}

.participant-chip:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Cards + grid */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

@media (min-width: 1100px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

.grid .card:nth-child(1) { animation-delay: 60ms; }
.grid .card:nth-child(2) { animation-delay: 120ms; }
.grid .card:nth-child(3) { animation-delay: 180ms; }
.grid .card:nth-child(4) { animation-delay: 240ms; }
.grid .card:nth-child(5) { animation-delay: 300ms; }
.grid .card:nth-child(6) { animation-delay: 360ms; }
.grid .card:nth-child(7) { animation-delay: 420ms; }
.grid .card:nth-child(8) { animation-delay: 480ms; }
.grid .card:nth-child(9) { animation-delay: 540ms; }
.grid .card:nth-child(10) { animation-delay: 600ms; }
.grid .card:nth-child(11) { animation-delay: 660ms; }
.grid .card:nth-child(12) { animation-delay: 720ms; }
.grid .card:nth-child(13) { animation-delay: 780ms; }
.grid .card:nth-child(14) { animation-delay: 840ms; }

.card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: card-pop 520ms ease both;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.card:hover {
  transform: translate(-3px, -3px) rotate(-0.2deg);
  box-shadow: 10px 10px 0 rgba(43, 43, 43, 0.2);
}
.card:hover::before {
  animation: sticker-bounce 420ms ease;
}
.card::before {
  content: "WOUAH";
  position: absolute;
  top: 8px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  transform: rotate(-6deg);
  box-shadow: 3px 3px 0 rgba(43, 43, 43, 0.15);
}
.card::after {
  content: "";
  position: absolute;
  left: -6px;
  top: -6px;
  width: 40px;
  height: 20px;
  background: #f1d4a8;
  border: 2px solid var(--border);
  transform: rotate(-12deg);
}

.grid .card:nth-child(2)::before { content: "BOUM"; background: #ffe1a8; }
.grid .card:nth-child(3)::before { content: "POP"; background: #c7f9cc; }
.grid .card:nth-child(4)::before { content: "ZAP"; background: #cdb4db; }
.grid .card:nth-child(5)::before { content: "VLAM"; background: #ffd6a5; }
.grid .card:nth-child(6)::before { content: "BOUM"; background: #bde0fe; }
.grid .card:nth-child(7)::before { content: "PAF"; background: #ffc8dd; }
.grid .card:nth-child(8)::before { content: "ZOOM"; background: #d9f99d; }
.grid .card:nth-child(9)::before { content: "CLAC"; background: #fde68a; }
.grid .card:nth-child(10)::before { content: "HEP"; background: #e0f2fe; }
.grid .card:nth-child(11)::before { content: "LOL"; background: #fecdd3; }
.grid .card:nth-child(12)::before { content: "OUH"; background: #ddd6fe; }
.grid .card:nth-child(13)::before { content: "ETINCELLE"; background: #bbf7d0; }

.card-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-head .card-title {
  margin: 0;
}

.segmented {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fff;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.seg-btn.is-active {
  background: var(--accent-3);
  box-shadow: 2px 2px 0 rgba(43, 43, 43, 0.2);
}

/* Charts */
.chart { height: 320px; }
canvas { width: 100%; height: 100%; }
.big { grid-column: 1 / -1; }

/* Heatmap */
.heatmap-wrap { overflow: auto; }
.heatmap {
  display: grid;
  gap: var(--hm-gap, 6px);
  align-items: center;
  align-content: start;
  overflow: visible;
  position: relative;
}
.heatmap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.4) 45%, transparent 70%);
  opacity: 0.6;
  mix-blend-mode: screen;
  transform: translateX(-120%);
  animation: shimmer 6s ease-in-out infinite;
  pointer-events: none;
}
.hm-corner {
  width: 100%;
  height: var(--hm-header, 90px);
}
.hm-rowlabel, .hm-collabel {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.hm-rowlabel.is-spotlight,
.hm-collabel.is-spotlight {
  color: #b45309;
  font-weight: 700;
}
.hm-collabel {
  height: var(--hm-header, 90px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  width: var(--hm-cell, 22px);
  position: relative;
  overflow: visible;
}
.hm-collabel .hm-coltext {
  position: absolute;
  left: 0;
  bottom: 0;
  transform: rotate(-55deg);
  transform-origin: left bottom;
  display: inline-block;
  pointer-events: none;
}
.hm-rowlabel {
  line-height: var(--hm-cell, 22px);
  padding-right: 6px;
}
.hm-cell {
  width: var(--hm-cell, 22px);
  height: var(--hm-cell, 22px);
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, box-shadow 120ms ease, outline 120ms ease;
}
.hm-value {
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
  user-select: none;
}
.hm-cell.is-hot {
  outline: 2px solid rgba(42, 111, 151, 0.35);
  box-shadow: 0 2px 8px rgba(42, 111, 151, 0.25);
  transform: translateY(-1px);
}
.hm-cell:hover {
  transform: translateY(-2px) scale(1.05);
}
.hm-cell.is-spotlight {
  outline: 2px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.12) inset;
}
.hm-cell.is-spotlight-both {
  outline: 2px solid rgba(245, 158, 11, 0.7);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.35);
}
.hm-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}
.hm-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid rgba(0, 0, 0, 0.08);
}

/* Messages */
.smallnote {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, #fffdf7 0%, #fff2d9 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 4px 4px 0 rgba(43, 43, 43, 0.12);
  animation: card-pop 480ms ease both;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.msg-item.is-clickable {
  cursor: pointer;
}
.msg-item.is-clickable:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(43, 43, 43, 0.2);
}

.msg-item.is-expanded {
  border-color: var(--accent-2);
  box-shadow: 0 6px 14px rgba(78, 168, 222, 0.3);
}

.msg-meta {
  font-size: 12px;
  color: var(--muted);
}

.msg-content {
  font-size: 14px;
  line-height: 1.4;
}

.msg-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.msg-photo {
  display: flex;
  justify-content: center;
}

.msg-photo img,
.msg-photo video {
  width: auto !important;
  height: auto !important;
  max-height: 260px;
  max-width: 360px;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #111;
}

.msg-photo img {
  cursor: zoom-in;
}

.msg-photo.is-context img,
.msg-photo.is-context video {
  max-height: 200px;
  max-width: 300px;
}

.msg-context {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-left: 4px solid var(--accent-3);
  margin: 4px 0;
  background: #fff9ec;
}

.context-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

.context-meta {
  color: var(--muted);
  font-size: 11px;
}

.context-text {
  font-size: 12px;
  line-height: 1.35;
}

/* Streaks */
.streaks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.streak-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.streak-control-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.streak-range {
  position: relative;
  height: 36px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background:
    linear-gradient(
      90deg,
      #fff3da 0%,
      #fff3da calc(var(--streak-start) * 1%),
      #ffe1a8 calc(var(--streak-start) * 1%),
      #ffe1a8 calc(var(--streak-end) * 1%),
      #fff3da calc(var(--streak-end) * 1%),
      #fff3da 100%
    );
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12);
}
.streak-range::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  height: 2px;
  background: rgba(0, 0, 0, 0.12);
  transform: translateY(-50%);
}

.streak-slider {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  width: calc(100% - 16px);
  height: 0;
  background: transparent;
  pointer-events: none;
  transform: translateY(-50%);
}
.streak-slider.is-start { z-index: 2; }
.streak-slider.is-end { z-index: 3; }
.streak-slider::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
  margin-top: -10px;
}
.streak-slider::-moz-range-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.streak-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: transparent;
}
.streak-slider::-moz-range-track {
  height: 2px;
  background: transparent;
}

.streak-range-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.streak-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr auto;
  gap: 12px;
  align-items: center;
}

.streak-row.is-spotlight .streak-name {
  color: #b45309;
}

.streak-name {
  font-size: 13px;
  font-weight: 700;
}

.streak-track {
  position: relative;
  height: 28px;
  border: 2px dashed var(--border);
  background: #fff3da;
  border-radius: 999px;
  overflow: visible;
}

.streak-seg {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
  transition: transform 120ms ease;
  z-index: 2;
}

.streak-seg:hover {
  transform: translateY(-2px) scale(1.02);
}

.streak-seg:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: -28px;
  right: 0;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  z-index: 3;
}

.streak-label {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  color: #1f2933;
}

.streak-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.streak-longest,
.streak-total,
.streak-window {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fff;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  animation: fade-in 200ms ease both;
}

.lightbox img {
  max-width: min(92vw, 1200px);
  max-height: 90vh;
  border-radius: 16px;
  border: 2px solid #ffffff2b;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  animation: zoom-in 240ms ease both;
}

/* Tooltip + status */
.hm-tooltip {
  position: fixed;
  z-index: 20;
  background: #111827;
  color: #f9fafb;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 120ms ease, transform 120ms ease;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.2);
}

.hm-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* Motion */
@keyframes card-pop {
  0% { opacity: 0; transform: translateY(12px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes panel-pop {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes title-pop {
  0% { opacity: 0; transform: translateY(8px) rotate(-1deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35); }
}

@keyframes shimmer {
  0% { transform: translateX(-120%); }
  60% { transform: translateX(120%); }
  100% { transform: translateX(120%); }
}

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes zoom-in {
  0% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@keyframes sticker-bounce {
  0% { transform: rotate(-6deg) scale(1); }
  40% { transform: rotate(-2deg) scale(1.08); }
  100% { transform: rotate(-6deg) scale(1); }
}
