* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body { height: 100%; }

body {
  background: #aa6767;
  color: #fff;
  font-family: monospace;
  animation: pulseBg 6s ease-in-out infinite;
}

@keyframes pulseBg {
  0%   { background-color: #aa6767; }
  50%  { background-color: #7a3f3f; }
  100% { background-color: #aa6767; }
}

.app {
  width: 100vw;
  height: 100vh;
}

/* IMPORTANT:
   keep the overall app clipped to the viewport,
   let ONLY .messages scroll horizontally */
.chat {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* back to hidden: prevents input row drifting sideways */
  min-height: 0;
}

/* Scroll viewport */
.messages {
  position: relative;
  flex: 1;
  min-width: 0;              /* critical for flex children that scroll */
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;

  padding: 12px;
  font-size: 18px;
  line-height: 1.35;
}

/* The growing plane INSIDE the scroll viewport */
.messages-canvas {
  position: relative;
  height: 100%;
  /* width is set by JS (canvasW) */
}

/* Absolute bubbles live in the canvas, not in .messages */
.message-row {
  position: absolute;

  /* stop shrink-to-fit “newspaper columns” */
  width: max-content;

  /* readable cap, but not forced columns */
  max-width: min(520px, 70vw);

  min-width: 0;
}

.bubble {
  display: inline-block;
  max-width: min(520px, 70vw);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  padding: 2px 4px;
}

/* images revealed under “skin” */
.bubble img.reveal-photo {
  display: block;
  max-width: 240px;
  height: auto;
  margin-top: 10px;
}

@keyframes shake {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-2px, 1px); }
  40%  { transform: translate(2px, -1px); }
  60%  { transform: translate(-2px, -1px); }
  80%  { transform: translate(2px, 1px); }
  100% { transform: translate(0, 0); }
}

.shake { animation: shake 0.35s linear 0s 2; }
.messages.global-shake .bubble { animation: shake 0.25s linear 0s 3; }

.skin-trigger {
  display: inline-block;
  cursor: default;
  text-decoration: none;
  opacity: 0.9;
}
.skin-trigger:hover {
  opacity: 1;
  animation: shake 0.25s linear 0s 2;
}

/* Continuous shake until revealed */
.shake-loop { animation: shake 0.5s linear 0s infinite; }
.photo-carrier.shake-loop, .snap-trigger.shake-loop, .skin-trigger.shake-loop { opacity: 1; }

.message-row.bot .bubble {
  color: #ffd6d6;
  text-shadow:
    0 0 6px rgba(255, 77, 77, 0.55),
    0 0 14px rgba(255, 77, 77, 0.35);
}

.message-row.user .bubble {
  color: #cfe6ff;
  text-shadow:
    0 0 6px rgba(77, 163, 255, 0.55),
    0 0 14px rgba(77, 163, 255, 0.35);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.input-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #000;
  color: #fff;
  font-size: 16px;
}

.input-row button {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #000;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.download-group {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  padding: 6px 8px;
}

.download-link {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  cursor: pointer;
  display: block;
}

.download-link:hover {
  color: rgba(255, 255, 255, 1);
  text-decoration: underline;
}

/* optional nicer scrollbar */
.messages::-webkit-scrollbar { height: 10px; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
}
.messages::-webkit-scrollbar-track { background: rgba(0,0,0,0.15); }
.photo-carrier { display: inline-block; cursor: default; }
.photo-carrier:hover { animation: shake 0.25s linear 0s 2; }

/* Visual hint when the user's input is being interrupted by the bot */
.input-row input.interrupted {
  opacity: 0.85;
  border-color: hotpink;
  box-shadow: 0 0 10px rgba(255, 105, 180, 0.18);
}
