/* ========================================
   Chat — Message bubbles, chat list, welcome page.
   Edit here for bubble styles and AI result image display.
   ======================================== */
.chat-container {
  position: relative; z-index: 1;
  flex: 0 0 auto; overflow-y: auto;
  height: max(260px, calc(100vh - var(--input-panel-height, 380px) - 18px));
  padding: 80px 24px 18px;
  max-width: 1580px; margin: 0 auto; width: 100%;
}

.create-floating-brand {
  position: fixed;
  top: 14px;
  left: 24px;
  z-index: 100;
}

/* Welcome Message */
.welcome-message[hidden] { display: none !important; }
.welcome-message { text-align: center; padding: 60px 24px; }
.welcome-message h1 {
  font-size: clamp(32px, 5vw, 52px); font-weight: 800; line-height: 1.2; margin-bottom: 16px;
  background: linear-gradient(to right, #fff 30%, #a855f7 60%, #ec4899 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.welcome-message p { color: rgba(255,255,255,0.4); font-size: 16px; line-height: 1.6; }

/* Chat Messages */
.chat-messages { max-width: 1420px; margin: 0 auto; padding-top: 20px; }
.message-group { display: flex; gap: 16px; margin-bottom: 32px; animation: fadeInUp 0.4s ease-out; }
.chat-messages .message-group:last-child { margin-bottom: 10px; }

.message-user { flex-direction: row; }
.task-message { align-items: flex-start; }

.message-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background-size: cover; background-position: center; overflow: hidden;
}
.message-user .message-avatar { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.message-ai .message-avatar { background: rgba(255,255,255,0.1); }
.message-avatar.user-avatar-image { background-color: rgba(255,255,255,0.08); background-size: cover; background-position: center; }
.message-user .message-avatar.user-avatar-image,
.task-message .message-avatar.user-avatar-image { background-size: cover; background-position: center; }

.message-content { max-width: 70%; padding: 16px 20px; border-radius: 16px; line-height: 1.6; position: relative; word-break: break-word; }
.message-user .message-content { background: rgba(255,255,255,0.06); color: #fff; border-bottom-left-radius: 4px; }
.message-ai .message-content { background: rgba(255,255,255,0.06); color: #e8e8ec; border-bottom-left-radius: 4px; }

.task-card {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 220px;
  padding: 22px 24px;
  border-radius: 14px;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
}
.task-card-stack {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 16px;
}
.task-card-segment { min-width: 0; }
.task-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.task-segment-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(168,85,247,0.22);
  background: rgba(168,85,247,0.1);
  color: #cfc2e6;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.task-card-continuation {
  min-height: 0;
  padding-top: 18px;
}
.task-card-continuation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.task-card-continuation-title {
  color: #f1edf8;
  font-size: 14px;
  font-weight: 700;
}
.task-card-continuation .task-output { margin-top: 14px; }
.task-status-footer:not(:empty) { margin-top: 14px; }
.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.task-card-header .task-prompt {
  flex: 1;
  min-width: 0;
}
.task-edit-btn {
  position: relative;
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(168,85,247,0.34);
  background: rgba(168,85,247,0.14);
  color: #e6d7ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.task-edit-btn:hover { background: rgba(168,85,247,0.24); border-color: rgba(168,85,247,0.56); transform: translateY(-1px); }
.task-prompt { color: #fff; font-size: 17px; line-height: 1.55; font-weight: 600; word-break: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.task-meta-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(168,85,247,0.14);
  border: 1px solid rgba(168,85,247,0.22);
  color: #d9c2ff;
  font-size: 12px;
  line-height: 1.4;
}
.task-time-chip {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.58);
}
.task-retention-chip {
  background: rgba(20,184,166,0.12);
  border-color: rgba(20,184,166,0.24);
  color: #99f6e4;
}
.task-ref-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.task-output { margin-top: 16px; }

.message-ref-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.message-ref-img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; cursor: pointer; transition: all 0.3s; }
.message-ref-img:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/* AI Result */
.ai-result-frame {
  width: fit-content;
  max-width: min(50%, 620px);
  min-height: 0;
  border-radius: 12px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ai-result-image { width: auto; height: auto; max-width: 100%; max-height: clamp(160px, 22vh, 280px); object-fit: contain; border-radius: 12px; cursor: pointer; transition: all 0.3s; display: block; }
.ai-result-image:hover { transform: scale(1.02); box-shadow: 0 8px 24px rgba(168, 85, 247, 0.2); }
.ai-result-frame.ratio-1-3,
.ai-result-frame.ratio-9-21 { width: 180px; max-width: 100%; }
.ai-result-frame.ratio-1-2,
.ai-result-frame.ratio-9-16 { width: 220px; max-width: 100%; }
.ai-result-frame.ratio-2-3,
.ai-result-frame.ratio-3-4,
.ai-result-frame.ratio-4-5 { width: 260px; max-width: 100%; }
.ai-result-frame.ratio-1-1 { width: 300px; max-width: 100%; }
.ai-result-frame.ratio-3-2,
.ai-result-frame.ratio-4-3,
.ai-result-frame.ratio-5-4 { width: 360px; max-width: 100%; }
.ai-result-frame.ratio-16-9,
.ai-result-frame.ratio-2-1 { width: 420px; max-width: 100%; }
.ai-result-frame.ratio-3-1,
.ai-result-frame.ratio-21-9 { width: 520px; max-width: 100%; }
.ai-result-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  max-width: 1100px;
}
.ai-result-grid .ai-result-frame { flex: 0 1 auto; min-height: 0; }
.ai-result-grid.ratio-1-3 .ai-result-frame,
.ai-result-grid.ratio-9-21 .ai-result-frame { width: 180px; }
.ai-result-grid.ratio-1-2 .ai-result-frame,
.ai-result-grid.ratio-9-16 .ai-result-frame { width: 220px; }
.ai-result-grid.ratio-2-3 .ai-result-frame,
.ai-result-grid.ratio-3-4 .ai-result-frame,
.ai-result-grid.ratio-4-5 .ai-result-frame { width: 260px; }
.ai-result-grid.ratio-1-1 .ai-result-frame { width: 300px; }
.ai-result-grid.ratio-3-2 .ai-result-frame,
.ai-result-grid.ratio-4-3 .ai-result-frame,
.ai-result-grid.ratio-5-4 .ai-result-frame { width: 360px; }
.ai-result-grid.ratio-16-9 .ai-result-frame,
.ai-result-grid.ratio-2-1 .ai-result-frame { width: 420px; }
.ai-result-grid.ratio-3-1 .ai-result-frame,
.ai-result-grid.ratio-21-9 .ai-result-frame { width: 520px; }
.ai-result-grid .ai-result-image { width: 100%; height: auto; max-height: 360px; margin-top: 0; }
.video-result-grid .video-result-frame { width: 420px; max-width: 100%; aspect-ratio: 16 / 9; }
.ai-result-video { width: 100%; height: 100%; display: block; border-radius: 12px; background: #050509; object-fit: contain; }
.ai-result-grid .ai-result-placeholder { width: 220px; aspect-ratio: 1 / 1; height: auto; }
.ai-result-grid.ratio-1-3 .ai-result-placeholder { width: 120px; aspect-ratio: 1 / 3; }
.ai-result-grid.ratio-9-21 .ai-result-placeholder { width: 154px; aspect-ratio: 9 / 21; }
.ai-result-grid.ratio-1-2 .ai-result-placeholder { width: 180px; aspect-ratio: 1 / 2; }
.ai-result-grid.ratio-9-16 .ai-result-placeholder { width: 203px; aspect-ratio: 9 / 16; }
.ai-result-grid.ratio-2-3 .ai-result-placeholder { width: 240px; aspect-ratio: 2 / 3; }
.ai-result-grid.ratio-3-4 .ai-result-placeholder { width: 260px; aspect-ratio: 3 / 4; }
.ai-result-grid.ratio-4-5 .ai-result-placeholder { width: 260px; aspect-ratio: 4 / 5; }
.ai-result-grid.ratio-1-1 .ai-result-placeholder { width: 300px; aspect-ratio: 1 / 1; }
.ai-result-grid.ratio-3-2 .ai-result-placeholder,
.ai-result-grid.ratio-4-3 .ai-result-placeholder,
.ai-result-grid.ratio-5-4 .ai-result-placeholder { width: 360px; aspect-ratio: 4 / 3; }
.ai-result-grid.ratio-16-9 .ai-result-placeholder,
.ai-result-grid.ratio-2-1 .ai-result-placeholder { width: 420px; aspect-ratio: 16 / 9; }
.ai-result-grid.ratio-3-1 .ai-result-placeholder,
.ai-result-grid.ratio-21-9 .ai-result-placeholder { width: 520px; aspect-ratio: 21 / 9; }
.ai-result-placeholder { width: clamp(130px, 16vh, 220px); height: clamp(130px, 16vh, 220px); border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; }
.ai-result-failed-slot {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.98);
  color: #9f1239;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  max-height: 360px;
}
.ai-result-expired-slot {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.96);
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  max-height: 360px;
}
.task-resend-row { margin-top: 12px; display: flex; align-items: center; }
.task-resend-btn {
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.92);
  color: #17111f;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.task-resend-btn:hover { transform: translateY(-1px); background: #fff; box-shadow: 0 8px 20px rgba(0,0,0,0.22); }
.task-resend-btn:disabled { opacity: 0.64; cursor: wait; transform: none; box-shadow: none; }

@media (max-width: 760px) {
  .task-card-header,
  .task-card-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .task-card-actions { width: 100%; }
  .task-card-actions .task-edit-btn,
  .task-card-actions .task-segment-chip { justify-content: center; }
  .ai-result-frame,
  .ai-result-grid {
    width: 100%;
  }
  .ai-result-grid .ai-result-frame,
  .ai-result-grid .ai-result-placeholder {
    width: 100%;
    max-width: 100%;
  }
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0,0,0,0.9);
  overflow: hidden;
  contain: layout paint size;
}
.image-viewer.show { display: flex; }
.image-viewer-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  contain: strict;
}
.image-viewer-dragging,
.image-viewer-dragging .image-viewer-stage { cursor: grabbing; user-select: none; }
.image-viewer-img {
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: none;
  transform-origin: center center;
  will-change: transform;
  backface-visibility: hidden;
  transform: translate3d(0,0,0);
  contain: layout paint;
  user-select: none;
  -webkit-user-drag: none;
}
.image-viewer-dragging .image-viewer-img { border-radius: 0; }
.image-viewer-toolbar {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 2002;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(18,18,24,0.82);
  box-shadow: 0 12px 32px rgba(0,0,0,0.34);
}
.image-viewer-tool {
  height: 30px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.image-viewer-tool:hover { background: rgba(168,85,247,0.28); border-color: rgba(168,85,247,0.46); }
.image-viewer-zoom {
  min-width: 54px;
  color: rgba(255,255,255,0.82);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.image-viewer-close {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 2002;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.image-viewer-close:hover { background: rgba(239,68,68,0.22); color: #ffb4b4; }

.ai-loading { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.6); font-size: 14px; padding: 10px 0; }

.strands-wait {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: rgba(232,246,255,0.74);
  font-size: 14px;
  font-weight: 700;
}

.strands-loader {
  position: relative;
  flex: 0 0 auto;
  width: clamp(260px, 34vw, 420px);
  height: 128px;
  overflow: hidden;
  border-radius: 0;
  isolation: isolate;
  transform: translateZ(0);
}

.strands-loader[data-strands-loader]::before,
.strands-loader[data-strands-loader]::after {
  display: none;
}

.strands-loader[data-strands-loader] canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.strands-loader::before,
.strands-loader::after {
  content: "";
  position: absolute;
  inset: 8px 5%;
  border-radius: 999px;
  pointer-events: none;
}

.strands-loader::before {
  background:
    radial-gradient(ellipse at 22% 50%, rgba(56,189,248,0.42), transparent 34%),
    radial-gradient(ellipse at 76% 48%, rgba(244,114,182,0.34), transparent 36%);
  filter: blur(14px);
  opacity: 0.76;
  animation: strandsAura 2.7s ease-in-out infinite;
}

.strands-loader::after {
  top: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.58), transparent);
  box-shadow: 0 0 18px rgba(255,255,255,0.36);
  opacity: 0.68;
  animation: strandsCorePulse 1.9s ease-in-out infinite;
}

.strands-loader .strand {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 7px;
  border-radius: 999px;
  background-size: 220% 100%;
  opacity: 0.92;
  filter: drop-shadow(0 0 8px rgba(125,211,252,0.58));
  transform-origin: center;
  animation: strandsFlow 2.6s ease-in-out infinite;
}

.strands-loader .strand::before,
.strands-loader .strand::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
}

.strands-loader .strand::before {
  filter: blur(7px);
  opacity: 0.54;
}

.strands-loader .strand::after {
  left: 12%;
  right: 12%;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.82);
  filter: blur(0.2px);
  opacity: 0.42;
}

.strands-loader .strand-a {
  background-image: linear-gradient(90deg, transparent, #22d3ee 18%, #f0f9ff 48%, #f472b6 72%, transparent);
  transform: translateY(-12px) rotate(-5deg) scaleX(0.92);
  animation-delay: -0.15s;
}

.strands-loader .strand-b {
  background-image: linear-gradient(90deg, transparent, #a7f3d0 16%, #67e8f9 42%, #fde68a 68%, transparent);
  transform: translateY(-2px) rotate(2.5deg) scaleX(1);
  animation-delay: -0.55s;
  filter: drop-shadow(0 0 9px rgba(250,204,21,0.42));
}

.strands-loader .strand-c {
  background-image: linear-gradient(90deg, transparent, #f9a8d4 20%, #fff7ed 48%, #38bdf8 74%, transparent);
  transform: translateY(10px) rotate(-2deg) scaleX(0.86);
  animation-delay: -0.95s;
  filter: drop-shadow(0 0 10px rgba(244,114,182,0.5));
}

.strands-loader .strand-core {
  top: calc(50% - 1px);
  height: 2px;
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,0.28), #ffffff 50%, rgba(255,255,255,0.28), transparent);
  transform: scaleX(0.78);
  opacity: 0.88;
  filter: drop-shadow(0 0 12px rgba(255,255,255,0.72));
  animation: strandsCore 1.7s ease-in-out infinite;
}

.strands-wait-label {
  min-width: 0;
  color: rgba(232,246,255,0.7);
  line-height: 1.35;
}

.strands-wait.is-compact {
  width: 100%;
  height: 100%;
  justify-content: center;
}

.strands-wait.is-compact .strands-loader {
  width: min(92%, 260px);
  height: min(68%, 150px);
  min-height: 96px;
}

.strands-wait.is-compact .strands-loader .strand {
  height: 5px;
}

.loading-spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.1); border-top-color: #a855f7; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes strandsFlow {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
    opacity: 1;
  }
}

@keyframes strandsAura {
  0%, 100% {
    opacity: 0.52;
    transform: translateX(-4%) scaleX(0.92);
  }
  50% {
    opacity: 0.88;
    transform: translateX(4%) scaleX(1.05);
  }
}

@keyframes strandsCore {
  0%, 100% {
    opacity: 0.34;
    transform: translateX(-8%) scaleX(0.58);
  }
  50% {
    opacity: 0.94;
    transform: translateX(8%) scaleX(0.94);
  }
}

@keyframes strandsCorePulse {
  0%, 100% { opacity: 0.28; transform: scaleX(0.72); }
  50% { opacity: 0.74; transform: scaleX(1); }
}

.ai-error { color: rgba(239, 68, 68, 0.9); font-size: 14px; margin-top: 8px; }
.ai-warning { color: rgba(250, 204, 21, 0.92); font-size: 13px; margin-top: 10px; }

.jump-to-bottom-btn {
  position: fixed;
  right: 24px;
  bottom: calc(var(--input-panel-height, 380px) + 18px);
  z-index: 60;
  display: none;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(168,85,247,0.35);
  background: rgba(20,20,28,0.86);
  color: #e9ddff;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  backdrop-filter: blur(12px);
}
.jump-to-bottom-btn.show { display: flex; }
.jump-to-bottom-btn:hover { background: rgba(168,85,247,0.22); border-color: rgba(168,85,247,0.58); }

@media (max-width: 1500px) {
  .jump-to-bottom-btn {
    right: 20px;
  }
}

/* ReactBits-inspired dark skin */
.welcome-message h1 {
  background: linear-gradient(90deg, #ffffff 8%, #dad1f6 42%, var(--rb-primary-2) 68%, var(--rb-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-message p {
  color: var(--rb-muted);
}

.message-user .message-avatar {
  background: linear-gradient(135deg, var(--rb-primary), var(--rb-primary-3));
  box-shadow: 0 0 24px rgba(82,39,255,0.34);
}

.message-ai .message-avatar {
  background: rgba(218,209,246,0.1);
  color: #dad1f6;
  box-shadow: 0 0 0 1px var(--rb-line) inset;
}

.message-user .message-content,
.message-ai .message-content {
  background: rgba(22,16,38,0.72);
  border: 1px solid var(--rb-line);
  color: var(--rb-text);
  box-shadow: 0 14px 36px rgba(0,0,0,0.22);
}

.message-user .message-content {
  background:
    linear-gradient(135deg, rgba(82,39,255,0.2), rgba(22,16,38,0.72));
}

.task-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.064), rgba(255,255,255,0.026)),
    rgba(18,15,23,0.78);
  border-color: var(--rb-line);
  box-shadow:
    0 18px 54px rgba(0,0,0,0.34),
    0 0 0 1px rgba(255,255,255,0.018) inset;
}

.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.7), rgba(120,209,225,0.34), transparent);
  pointer-events: none;
}

.task-edit-btn,
.task-resend-btn {
  border-color: rgba(139,92,246,0.34);
  background: rgba(82,39,255,0.15);
  color: #dad1f6;
}

.task-edit-btn:hover,
.task-resend-btn:hover,
.jump-to-bottom-btn:hover {
  background: rgba(82,39,255,0.26);
  border-color: rgba(139,92,246,0.58);
  color: #fff;
  box-shadow: 0 0 28px rgba(82,39,255,0.24);
}

.task-prompt {
  color: var(--rb-text);
}

.task-meta-chip,
.gallery-meta span {
  background: rgba(82,39,255,0.14);
  border-color: rgba(139,92,246,0.26);
  color: #dad1f6;
}

.task-time-chip {
  background: rgba(255,255,255,0.055);
  border-color: var(--rb-line);
  color: var(--rb-muted);
}

.task-retention-chip {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.26);
  color: #a7f3d0;
}

.message-ref-img,
.ai-result-image,
.ai-result-video {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}

.ai-result-image:hover {
  box-shadow:
    0 12px 34px rgba(0,0,0,0.3),
    0 0 32px rgba(82,39,255,0.28);
}

.ai-result-placeholder,
.ai-result-failed-slot,
.ai-result-expired-slot {
  background: rgba(18,15,23,0.78);
  border-color: var(--rb-line);
  color: var(--rb-muted);
  box-shadow: 0 12px 32px rgba(0,0,0,0.24);
}

.ai-result-failed-slot {
  color: #fda4af;
  border-color: rgba(244,63,94,0.24);
  background: rgba(127,29,29,0.16);
}

.ai-result-expired-slot {
  color: #dad1f6;
}

.task-resend-btn:disabled {
  color: rgba(218,209,246,0.48);
}

.ai-loading,
.strands-wait-label {
  color: rgba(218,209,246,0.76);
}

.loading-spinner {
  border-color: rgba(218,209,246,0.14);
  border-top-color: var(--rb-primary-2);
}

.strands-loader::before {
  background:
    linear-gradient(90deg, rgba(82,39,255,0.42), transparent 42%),
    linear-gradient(270deg, rgba(120,209,225,0.36), transparent 44%);
}

.ai-error {
  color: #fda4af;
}

.ai-warning {
  color: #fde68a;
}

/* Minimal black pass with restrained ReactBits-inspired motion */
.welcome-message h1 {
  background: linear-gradient(90deg, #ffffff 0%, #d6d3dc 58%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.message-user .message-avatar {
  background: linear-gradient(135deg, #18151f, var(--rb-primary));
  box-shadow: 0 0 18px rgba(124,58,237,0.18);
}

.message-ai .message-avatar {
  background: rgba(255,255,255,0.055);
}

.message-user .message-content,
.message-ai .message-content {
  background: rgba(12,12,16,0.78);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 14px 34px rgba(0,0,0,0.3);
}

.message-user .message-content {
  background:
    radial-gradient(circle at 0% 0%, rgba(139,92,246,0.09), transparent 42%),
    rgba(12,12,16,0.8);
}

.task-card {
  background:
    linear-gradient(145deg, rgba(255,255,255,0.075), rgba(139,92,246,0.035) 38%, rgba(5,6,12,0.08)),
    rgba(16,16,24,0.62);
  border-color: rgba(255,255,255,0.16);
  -webkit-backdrop-filter: blur(10px) saturate(125%);
  backdrop-filter: blur(10px) saturate(125%);
  box-shadow:
    0 18px 50px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.025);
}

.task-card::before {
  background: linear-gradient(90deg, transparent, rgba(139,92,246,0.32), transparent);
  opacity: 0.78;
}

.task-edit-btn,
.task-resend-btn {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,0.045);
  border-color: rgba(139,92,246,0.22);
  color: rgba(244,244,245,0.86);
}

.task-edit-btn::before,
.task-resend-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 48%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.16), transparent);
  animation: rbShineSweep 7s ease-in-out infinite;
  pointer-events: none;
}

.task-edit-btn:hover,
.task-resend-btn:hover {
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.36);
  box-shadow: 0 0 18px rgba(124,58,237,0.12);
}

.task-meta-chip,
.gallery-meta span {
  background: rgba(139,92,246,0.09);
  border-color: rgba(139,92,246,0.18);
  color: rgba(226,220,239,0.9);
}

.task-time-chip {
  background: rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.08);
  color: var(--rb-muted);
}

.task-retention-chip {
  background: rgba(52,211,153,0.08);
  border-color: rgba(52,211,153,0.18);
}

.ai-result-placeholder,
.ai-result-failed-slot,
.ai-result-expired-slot {
  background: rgba(8,8,11,0.82);
  border-color: rgba(255,255,255,0.08);
}

.ai-result-image:hover {
  box-shadow:
    0 12px 34px rgba(0,0,0,0.34),
    0 0 22px rgba(124,58,237,0.14);
}

/* UI polish layer: separate generated results from the conversation surface. */
.task-card {
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,0.075), rgba(255,255,255,0.035)), rgba(15,14,22,0.72);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 18px 44px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.05);
}

.ai-result-image {
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.2);
}

.task-output {
  margin-top: 18px;
}

.task-ref-images {
  margin-top: 16px;
  gap: 10px;
}

.message-ref-img {
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 24px rgba(0,0,0,0.18);
}

.task-edit-btn,
.task-resend-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(168,85,247,0.28);
  background: rgba(168,85,247,0.14);
  color: #ead9ff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.task-edit-btn:hover,
.task-resend-btn:hover {
  transform: translateY(-1px);
  background: rgba(168,85,247,0.22);
  border-color: rgba(196,181,253,0.46);
  box-shadow: 0 12px 24px rgba(124,58,237,0.16);
}

.task-resend-row {
  display: flex;
  align-items: center;
  margin-top: 14px;
}

.strands-wait {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.strands-wait-label {
  color: rgba(255,255,255,0.72);
  font-size: 13px;
  font-weight: 600;
}

.strands-wait.ai-loading {
  display: flex;
  width: 100%;
  min-height: 144px;
  justify-content: center;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.strands-wait.ai-loading .strands-wait-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-result-placeholder {
  background:
    linear-gradient(135deg, rgba(168,85,247,0.12), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.035);
  border-color: rgba(255,255,255,0.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.ai-result-failed-slot {
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(127,29,29,0.08);
}

.video-result-grid .video-result-frame,
.ai-result-frame {
  box-shadow: 0 18px 34px rgba(0,0,0,0.18);
}

@media (max-width: 768px) {
  .task-card {
    padding: 18px;
    border-radius: 16px;
  }

  /* Matches the create-page mobile density step in
     create-responsive-desktop.css (which wins there on specificity). */
  .task-prompt {
    font-size: 14px;
  }

  .task-card-header {
    gap: 12px;
  }
}
