@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
  --pink: #ff35d7;
  --pink-glow: rgba(255, 53, 215, 0.4);
  --cyan: #47eaff;
  --cyan-glow: rgba(71, 234, 255, 0.3);
  --purple: #7135ff;
  --purple-glow: rgba(113, 53, 255, 0.3);
  --green: #39ff14;
  --green-glow: rgba(57, 255, 20, 0.4);
  --bg-dark: #060312;
  --window-bg: rgba(14, 8, 38, 0.65);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
}

body {
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  color: #fff;
  transition: color 0.65s ease, background-color 0.65s ease, background 0.65s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.96) 0%, rgba(71, 234, 255, 0.58) 18%, rgba(255, 53, 215, 0.28) 34%, transparent 58%),
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.9) 48%, transparent 56%);
  mix-blend-mode: screen;
}

body::after {
  content: attr(data-theme-transition-label);
  position: fixed;
  inset: -12%;
  z-index: 10000;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  color: rgba(255, 255, 255, 0.95);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  font-size: clamp(1.1rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: clamp(0.12rem, 1vw, 0.55rem);
  text-shadow:
    0 0 12px rgba(71, 234, 255, 0.95),
    0 0 30px rgba(255, 53, 215, 0.85),
    0 0 58px rgba(113, 53, 255, 0.7);
  background:
    linear-gradient(115deg,
      transparent 0%,
      transparent 34%,
      rgba(0, 0, 0, 0.86) 39%,
      rgba(18, 18, 18, 0.92) 47%,
      rgba(255, 255, 255, 0.92) 50%,
      rgba(71, 234, 255, 0.72) 53%,
      rgba(255, 53, 215, 0.54) 59%,
      transparent 68%,
      transparent 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 7px);
  mix-blend-mode: screen;
  transform: translateX(-58%) skewX(-8deg);
}

body.theme-transitioning::before {
  animation: themeFlash 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both;
}

body.theme-transitioning::after {
  animation: none;
  opacity: 0;
}

@keyframes themeFlash {
  0% { opacity: 0; transform: scale(0.98); }
  8% { opacity: 0.22; transform: scale(1); }
  58% { opacity: 0.08; transform: scale(1.02); }
  70% { opacity: 0.98; transform: scale(1.06); }
  82% { opacity: 0.48; }
  100% { opacity: 0; transform: scale(1.18); }
}

@keyframes themeWipe {
  0% { opacity: 0.72; transform: translateX(-72%) skewX(-8deg); }
  8% { opacity: 0.92; }
  48% { opacity: 0.96; }
  62% { opacity: 1; transform: translateX(-8%) skewX(-8deg); }
  78% { opacity: 0.82; }
  100% { opacity: 0; transform: translateX(72%) skewX(-8deg); }
}

@media (prefers-reduced-motion: reduce) {
  body.theme-transitioning::before,
  body.theme-transitioning::after {
    animation: none;
  }
}

.stage,
.window-content,
.chat-container,
.chat-history,
.message,
.message-meta,
.message-text,
.image-preview,
.preview-item,
.chat-form,
.attach-button,
.desktop-button,
.theme-toggle,
#messageInput,
#sendButton {
  transition:
    background 0.65s ease,
    background-color 0.65s ease,
    border-color 0.65s ease,
    border-radius 0.65s ease,
    box-shadow 0.65s ease,
    color 0.65s ease,
    filter 0.65s ease,
    opacity 0.65s ease,
    text-shadow 0.65s ease,
    transform 0.65s ease;
}

/* Full-screen wrapper container */
.stage {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, #160a3a 0%, #060312 100%);
}

/* Full-screen layout wrapper replacing the mock window */
.window-frame {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
  position: relative;
}



/* Content Area containing layers & chat overlay */
.window-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: 
    radial-gradient(circle at 50% 35%, rgba(255, 53, 215, 0.15) 0%, transparent 60%),
    linear-gradient(to bottom, #090526 0%, #150b38 45%, #2a0e5c 75%, #4f0a52 100%);
  display: flex;
  flex-direction: column;
}

/* Background scene elements with stacking */
.scene-layer {
  position: absolute;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: bottom center;
  visibility: visible;
  transition: opacity 0.65s ease, filter 0.65s ease, visibility 0s linear 0s;
}

.scene-sun {
  z-index: 11;
  width: min(38vw, 360px);
  aspect-ratio: 1;
  right: 12%;
  top: 15%;
  padding: 0;
  border: 0;
  appearance: none;
  cursor: pointer;
  background-image: url('Resources/sun.png');
  background-color: transparent;
  background-position: center;
  filter: drop-shadow(0 0 45px rgba(255, 53, 215, 0.6));
  animation: pulseSun 8s ease-in-out infinite alternate;
  pointer-events: auto;
}

.scene-sun:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 8px;
}

@keyframes pulseSun {
  0% { transform: scale(1); filter: drop-shadow(0 0 45px rgba(255, 53, 215, 0.6)); }
  100% { transform: scale(1.04); filter: drop-shadow(0 0 65px rgba(255, 53, 215, 0.85)); }
}

@keyframes gridMove {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 50px;
  }
}

/* Mountains and city skyline shifted up to match the grid horizon */
.scene-mountains {
  z-index: 2;
  width: 120%;
  height: 50%;
  left: -10%;
  bottom: 38%;
  background-image: url('Resources/cloud-mountains.png');
  background-position: bottom center;
  opacity: 0.5;
  filter: blur(2px) drop-shadow(0 0 20px rgba(255, 53, 215, 0.25));
}

.scene-city {
  z-index: 3;
  width: 85%;
  height: 28%;
  left: 7.5%;
  bottom: 38%;
  background-image: url('Resources/city-skyline.png');
  background-position: bottom center;
  opacity: 0.75;
  filter: drop-shadow(0 0 12px rgba(255, 53, 215, 0.35));
}

.scene-grid {
  z-index: 5;
  width: 200%;
  height: 45%;
  left: -50%;
  bottom: -5%;
  position: absolute;
  pointer-events: none;
  transform: perspective(180px) rotateX(72deg);
  transform-origin: top center;
  background-image:
    linear-gradient(to right, rgba(255, 53, 215, 0.5) 2px, transparent 2px),
    linear-gradient(to bottom, rgba(255, 53, 215, 0.5) 2px, transparent 2px);
  background-size: 50px 50px;
  background-repeat: repeat;
  animation: gridMove 2s linear infinite;
  opacity: 0.9;
  filter: drop-shadow(0 0 20px rgba(255, 53, 215, 0.5));
}

.scene-car {
  z-index: 6;
  width: clamp(500px, 56vw, 1040px);
  aspect-ratio: 16 / 9;
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(calc(-50% + var(--car-offset, 0px)));
  opacity: 1;
  visibility: visible;
  transition: opacity 0.65s ease, visibility 0s linear 0s;
}

/* Underglow removed so the 3D car sits cleanly on the grid */
.scene-car::after {
  content: none;
}

.car-model {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  background: transparent;
  transform: translateY(var(--car-bob, 0px)) rotateZ(var(--car-tilt, 0deg));
  transform-origin: 50% 80%;
  transition: transform 0.12s ease-out;
  animation: carRumble 0.12s infinite alternate ease-in-out;
  filter: drop-shadow(0 12px 8px rgba(0, 0, 0, 0.7));
}

@keyframes carRumble {
  0% {
    transform: translateY(0) rotateZ(var(--car-tilt, 0deg));
  }
  100% {
    transform: translateY(1px) rotateZ(var(--car-tilt, 0deg));
  }
}

@keyframes underglowPulse {
  0% {
    opacity: 0.8;
    transform: scale(0.98);
  }
  100% {
    opacity: 1;
    transform: scale(1.02);
  }
}



/* Subtle retro effects */
.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.65s ease, visibility 0s linear 0s;
}

.scanlines {
  z-index: 20;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(255, 255, 255, 0.012) 2px,
    rgba(255, 255, 255, 0.012) 4px
  );
}

.flicker {
  z-index: 21;
  background: rgba(255, 59, 215, 0.004);
  animation: vaporFlicker 0.2s infinite alternate;
}

@keyframes vaporFlicker {
  0% { opacity: 0.25; }
  100% { opacity: 0.45; }
}

/* Chat overlay structure - Centered Column (Vertically and Horizontally) */
.chat-container {
  z-index: 10;
  flex: none;
  height: auto;
  pointer-events: none;
  max-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  padding: 28px 34px;
  position: relative;
  width: 100%;
  max-width: 1040px;
  margin: auto;
}

.chat-container > * {
  pointer-events: auto;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  margin-bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  scrollbar-width: thin;
  scrollbar-color: var(--pink) rgba(14, 8, 38, 0.5);
}

.chat-history::-webkit-scrollbar {
  width: 8px;
}

.chat-history::-webkit-scrollbar-track {
  background: rgba(14, 8, 38, 0.4);
  border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, var(--cyan), var(--pink));
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(255, 53, 215, 0.4);
}

/* Message bubbles */
.message {
  max-width: 76%;
  padding: 22px 28px;
  border-radius: 20px;
  font-family: 'Share Tech Mono', monospace;
  position: relative;
  line-height: 1.65;
  word-wrap: break-word;
  animation: fadeInMessage 0.25s ease-out forwards;
}

@keyframes fadeInMessage {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-message {
  align-self: flex-end;
  background: rgba(255, 53, 215, 0.12);
  border: 1px solid rgba(255, 53, 215, 0.55);
  box-shadow: 0 0 16px rgba(255, 53, 215, 0.22), inset 0 0 12px rgba(255, 53, 215, 0.12);
  backdrop-filter: blur(12px) saturate(1.2);
  color: #fff2fc;
  text-shadow: 0 0 4px rgba(255, 53, 215, 0.4);
}

.ai-message {
  align-self: flex-start;
  background: var(--window-bg);
  border: 1px solid rgba(71, 234, 255, 0.5);
  box-shadow: 0 0 16px rgba(71, 234, 255, 0.18), inset 0 0 12px rgba(71, 234, 255, 0.08);
  backdrop-filter: blur(12px) saturate(1.2);
  color: #edfaff;
  text-shadow: 0 0 4px rgba(71, 234, 255, 0.35);
}

.system-message {
  align-self: center;
  background: rgba(255, 53, 215, 0.08);
  border: 1px solid rgba(255, 53, 215, 0.35);
  box-shadow: 0 0 10px rgba(255, 53, 215, 0.1);
  backdrop-filter: blur(8px);
  color: #ffa2f2;
  font-size: 0.92rem;
  max-width: 90%;
  text-align: center;
}

.message-meta {
  font-size: 0.82rem;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  font-weight: bold;
}

.user-message .message-meta {
  color: var(--pink);
  text-shadow: 0 0 6px rgba(255, 53, 215, 0.5);
  text-align: right;
}

.ai-message .message-meta {
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(71, 234, 255, 0.5);
}

.system-message .message-meta {
  color: var(--purple);
  text-shadow: 0 0 6px rgba(113, 53, 255, 0.5);
}

.message-text {
  font-size: 1.1rem;
  letter-spacing: 0.25px;
  white-space: pre-wrap;
  word-break: break-word;
}

.thinking {
  min-width: 18rem;
}

.thinking .message-text {
  white-space: nowrap;
  word-break: normal;
}

.thinking .message-text::after {
  content: '';
  display: inline-block;
  width: 3ch;
  text-align: left;
  vertical-align: baseline;
  white-space: nowrap;
  animation: typingDots 1.1s steps(4, end) infinite;
}

@keyframes typingDots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75%, 100% { content: '...'; }
}

/* Image attachment list within bubble */
.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.message-images img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  border: 1px solid rgba(255, 53, 215, 0.4);
  box-shadow: 0 0 8px rgba(255, 53, 215, 0.2);
  object-fit: cover;
  transition: transform 0.2s;
}

.message-images img:hover {
  transform: scale(1.03);
  border-color: var(--pink);
}

/* Preview of selected files above input bar */
.image-preview {
  display: none;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  background: rgba(14, 8, 38, 0.75);
  border: 1px solid rgba(71, 234, 255, 0.35);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  z-index: 30;
}

.image-preview.has-images {
  display: flex;
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 53, 215, 0.3);
  border-radius: 8px;
  padding: 4px 8px;
  color: #fff;
  font-size: 0.85rem;
}

.preview-item img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

.preview-item span {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-item button {
  background: transparent;
  border: none;
  color: var(--pink);
  font-weight: bold;
  cursor: pointer;
  font-size: 1rem;
}

.preview-item button:hover {
  color: var(--cyan);
}

/* Chat Form Capsule */
.chat-form {
  display: flex;
  align-items: center;
  background: rgba(14, 8, 38, 0.7);
  border: 1px solid rgba(113, 53, 255, 0.5);
  box-shadow: 0 0 22px rgba(113, 53, 255, 0.25), inset 0 0 12px rgba(113, 53, 255, 0.15);
  border-radius: 34px;
  padding: 14px 20px;
  gap: 16px;
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 30;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.chat-form:focus-within {
  border-color: var(--pink);
  box-shadow: 0 0 25px rgba(255, 53, 215, 0.35), inset 0 0 12px rgba(255, 53, 215, 0.15);
}

#imageInput {
  display: none;
}

/* Buttons in the input bar */
.attach-button,
.desktop-button {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.attach-button {
  font-size: 1.35rem;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(71, 234, 255, 0.5);
  padding: 4px;
}

.attach-button:hover {
  color: var(--pink);
  transform: scale(1.15) rotate(15deg);
  text-shadow: 0 0 8px rgba(255, 53, 215, 0.5);
}

.desktop-button {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(71, 234, 255, 0.4);
  background: rgba(71, 234, 255, 0.06);
  color: var(--cyan);
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(71, 234, 255, 0.4);
}

.desktop-button:hover {
  border-color: var(--pink);
  background: rgba(255, 53, 215, 0.12);
  color: var(--pink);
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(255, 53, 215, 0.25);
  text-shadow: 0 0 6px rgba(255, 53, 215, 0.5);
}

.theme-toggle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 53, 215, 0.45);
  background: rgba(255, 53, 215, 0.08);
  color: var(--pink);
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(255, 53, 215, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--cyan);
  background: rgba(71, 234, 255, 0.12);
  color: var(--cyan);
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(71, 234, 255, 0.25);
  text-shadow: 0 0 6px rgba(71, 234, 255, 0.5);
}

.agent-toggle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(71, 234, 255, 0.4);
  background: rgba(71, 234, 255, 0.06);
  color: var(--cyan);
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(71, 234, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.agent-toggle:hover {
  border-color: var(--pink);
  background: rgba(255, 53, 215, 0.12);
  color: var(--pink);
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(255, 53, 215, 0.25);
  text-shadow: 0 0 6px rgba(255, 53, 215, 0.5);
}

.agent-toggle.gemini-mode {
  border: 1px solid rgba(255, 53, 215, 0.45);
  background: rgba(255, 53, 215, 0.08);
  color: var(--pink);
  text-shadow: 0 0 6px rgba(255, 53, 215, 0.4);
}

.agent-toggle.gemini-mode:hover {
  border-color: var(--green);
  background: rgba(57, 255, 20, 0.12);
  color: var(--green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.25);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.5);
}

.agent-toggle.qbit-mode {
  border: 1px solid rgba(57, 255, 20, 0.45);
  background: rgba(57, 255, 20, 0.08);
  color: var(--green);
  text-shadow: 0 0 6px rgba(57, 255, 20, 0.4);
}

.agent-toggle.qbit-mode:hover {
  border-color: var(--cyan);
  background: rgba(71, 234, 255, 0.12);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(71, 234, 255, 0.25);
  text-shadow: 0 0 6px rgba(71, 234, 255, 0.5);
}

/* Input area */
#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.2rem;
  padding: 14px 16px;
  letter-spacing: 0.5px;
}

#messageInput::placeholder {
  color: rgba(255, 255, 255, 0.35);
  text-shadow: none;
}

/* Send button styled as pill */
#sendButton {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  border: none;
  border-radius: 20px;
  color: #fff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 12px 28px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(255, 53, 215, 0.45);
  transition: all 0.2s ease;
}

#sendButton:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(255, 53, 215, 0.7);
  filter: brightness(1.12);
}

#sendButton:active {
  transform: translateY(1px);
}

#sendButton:disabled,
.attach-button:disabled,
.desktop-button:disabled,
.theme-toggle:disabled,
.agent-toggle:disabled,
#messageInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  filter: none !important;
}


body.vaporwave-mode .chat-form {
  background: rgba(14, 8, 38, 0.7);
  border-color: rgba(113, 53, 255, 0.5);
  box-shadow: 0 0 22px rgba(113, 53, 255, 0.25), inset 0 0 12px rgba(113, 53, 255, 0.15);
}

body.vaporwave-mode #sendButton {
  background: linear-gradient(135deg, #ffffff 0%, #ffebfb 42%, #f6d8ff 100%);
  color: #180021;
  border: 2px solid rgba(255, 53, 215, 0.85);
  box-shadow: 0 0 20px rgba(255, 53, 215, 0.62), inset 0 0 14px rgba(255, 53, 215, 0.16);
  text-shadow: none;
  font-weight: 900;
}

/* Visually hidden label helper */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


body.theme-transitioning .chat-container {
  animation: consolePhaseShift 2.85s ease-out both;
}

body.color-bloom-transition.vaporwave-mode .stage {
  animation: stageBackgroundBloom 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both;
}

body.color-bloom-transition.vaporwave-mode .window-content {
  animation: contentBackgroundBloom 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both;
}

body.color-bloom-transition.vaporwave-mode .scene-layer,
body.color-bloom-transition.vaporwave-mode .scene-car {
  opacity: 1;
  visibility: visible;
  animation: assetBlackToColor 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both;
}

body.color-bloom-transition.vaporwave-mode .scene-sun { animation-delay: 0s; }
body.color-bloom-transition.vaporwave-mode .scene-mountains { animation: mountainBlackToColor 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both; }
body.color-bloom-transition.vaporwave-mode .scene-city { animation: skylineBlackToColor 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both; }
body.color-bloom-transition.vaporwave-mode .scene-grid { animation: gridMove 2s linear infinite, gridBlackToColor 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both; animation-delay: 0s, 0s; }
body.color-bloom-transition.vaporwave-mode .scene-car { animation-delay: 0s; }
body.color-bloom-transition.vaporwave-mode .car-model { animation: carRumble 0.12s infinite alternate ease-in-out, carBlackToColor 2.85s cubic-bezier(0.16, 0.84, 0.24, 1) both; }

body.theme-transitioning.vaporwave-mode:not(.color-bloom-transition) .scene-sun { animation: pulseSun 8s ease-in-out infinite alternate, sceneReveal 0.88s 0.05s ease-out both; }
body.theme-transitioning.vaporwave-mode:not(.color-bloom-transition) .scene-mountains { animation: sceneReveal 0.88s 0.1s ease-out both; }
body.theme-transitioning.vaporwave-mode:not(.color-bloom-transition) .scene-city { animation: sceneReveal 0.88s 0.16s ease-out both; }
body.theme-transitioning.vaporwave-mode:not(.color-bloom-transition) .scene-grid { animation: gridMove 2s linear infinite, sceneReveal 0.88s 0.2s ease-out both; }
body.theme-transitioning.vaporwave-mode:not(.color-bloom-transition) .scene-car { animation: sceneReveal 0.88s 0.28s ease-out both; }

@keyframes consolePhaseShift {
  0% { filter: grayscale(1) contrast(1.25) brightness(0.88); transform: scale(1); }
  58% { filter: grayscale(1) contrast(1.35) brightness(0.95); transform: scale(1.004); }
  72% { filter: saturate(2.4) brightness(1.32); transform: scale(1.016); }
  100% { filter: saturate(1) brightness(1); transform: scale(1); }
}

@keyframes stageBackgroundBloom {
  0%, 62% {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
      linear-gradient(0deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
      #f2f2f2;
    background-size: 32px 32px;
  }
  72%, 100% {
    background: radial-gradient(circle at center, #160a3a 0%, #060312 100%);
    background-size: auto;
  }
}

@keyframes contentBackgroundBloom {
  0%, 62% {
    background: linear-gradient(180deg, #ffffff 0%, #ececec 100%);
  }
  72%, 100% {
    background:
      radial-gradient(circle at 50% 35%, rgba(255, 53, 215, 0.15) 0%, transparent 60%),
      linear-gradient(to bottom, #090526 0%, #150b38 45%, #2a0e5c 75%, #4f0a52 100%);
  }
}

@keyframes assetBlackToColor {
  0% {
    opacity: 0;
    filter: grayscale(1) brightness(0) contrast(1.6) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  }
  14% {
    opacity: 1;
    filter: grayscale(1) brightness(0) contrast(1.9) drop-shadow(0 0 20px rgba(0, 0, 0, 0.9));
  }
  58% {
    opacity: 1;
    filter: grayscale(1) brightness(0.05) contrast(2.2) drop-shadow(0 0 28px rgba(0, 0, 0, 0.95));
  }
  68% {
    opacity: 1;
    filter: grayscale(0.65) brightness(1.85) saturate(2.8) contrast(1.28) drop-shadow(0 0 36px rgba(255, 255, 255, 0.68));
  }
  78% {
    opacity: 1;
    filter: grayscale(0.08) brightness(1.18) saturate(1.9) contrast(1.08) drop-shadow(0 0 34px rgba(255, 53, 215, 0.62));
  }
  100% {
    opacity: 1;
  }
}

@keyframes mountainBlackToColor {
  0% {
    opacity: 0;
    filter: grayscale(1) brightness(0) contrast(1.6) blur(2px) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  }
  14%, 58% {
    opacity: 0.5;
    filter: grayscale(1) brightness(0.05) contrast(2.1) blur(2px) drop-shadow(0 0 24px rgba(0, 0, 0, 0.85));
  }
  68% {
    opacity: 0.5;
    filter: grayscale(0.55) brightness(1.55) saturate(2.2) contrast(1.18) blur(2px) drop-shadow(0 0 28px rgba(255, 255, 255, 0.48));
  }
  84% {
    opacity: 0.5;
    filter: grayscale(0.08) brightness(1.08) saturate(1.35) contrast(1.04) blur(2px) drop-shadow(0 0 22px rgba(255, 53, 215, 0.34));
  }
  100% {
    opacity: 0.5;
    filter: blur(2px) drop-shadow(0 0 20px rgba(255, 53, 215, 0.25));
  }
}

@keyframes skylineBlackToColor {
  0% {
    opacity: 0;
    filter: grayscale(1) brightness(0) contrast(1.6) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  }
  14%, 58% {
    opacity: 0.75;
    filter: grayscale(1) brightness(0.05) contrast(2.1) drop-shadow(0 0 24px rgba(0, 0, 0, 0.85));
  }
  68% {
    opacity: 0.75;
    filter: grayscale(0.55) brightness(1.55) saturate(2.2) contrast(1.18) drop-shadow(0 0 28px rgba(255, 255, 255, 0.48));
  }
  84% {
    opacity: 0.75;
    filter: grayscale(0.08) brightness(1.08) saturate(1.35) contrast(1.04) drop-shadow(0 0 18px rgba(255, 53, 215, 0.38));
  }
  100% {
    opacity: 0.75;
    filter: drop-shadow(0 0 12px rgba(255, 53, 215, 0.35));
  }
}

@keyframes gridBlackToColor {
  0% {
    opacity: 0;
    filter: grayscale(1) brightness(0) contrast(1.8) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  }
  14% {
    opacity: 1;
    filter: grayscale(1) brightness(0.08) contrast(2.1) drop-shadow(0 0 18px rgba(0, 0, 0, 0.9));
  }
  58% {
    opacity: 1;
    filter: grayscale(1) brightness(0.1) contrast(2.4) drop-shadow(0 0 24px rgba(0, 0, 0, 1));
  }
  68% {
    filter: grayscale(0.5) brightness(1.85) saturate(3) contrast(1.25) drop-shadow(0 0 32px rgba(255, 255, 255, 0.72));
  }
  100% {
    opacity: 0.9;
    filter: drop-shadow(0 0 20px rgba(255, 53, 215, 0.5));
  }
}

@keyframes carBlackToColor {
  0%, 58% {
    filter: grayscale(1) brightness(0.08) contrast(2) drop-shadow(0 14px 12px rgba(0, 0, 0, 0.95));
  }
  68% {
    filter: grayscale(0.35) brightness(1.55) saturate(2.4) contrast(1.18) drop-shadow(0 0 32px rgba(71, 234, 255, 0.65));
  }
  100% {
    filter: drop-shadow(0 12px 8px rgba(0, 0, 0, 0.7));
  }
}

@keyframes sceneReveal {
  0% { opacity: 0; filter: blur(8px) brightness(1.8); }
  55% { opacity: 1; filter: blur(2px) brightness(1.35); }
  100% { opacity: 1; }
}

/* Desktop default: work-safe black-and-white mode. The VPR button adds
   body.vaporwave-mode to reveal the normal vaporwave scene. */
@media (min-width: 769px) {
  body:not(.vaporwave-mode) {
    font-family: Arial, Helvetica, sans-serif;
    color: #111;
    background: #f4f4f4;
  }

  body:not(.vaporwave-mode) .stage {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
      linear-gradient(0deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
      #f2f2f2;
    background-size: 32px 32px;
  }

  body:not(.vaporwave-mode) .window-content {
    background: linear-gradient(180deg, #ffffff 0%, #ececec 100%);
  }

  body:not(.vaporwave-mode) .scene-layer,
  body:not(.vaporwave-mode) .scene-car,
  body:not(.vaporwave-mode) .crt-overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.65s ease, filter 0.65s ease, visibility 0s linear 0.65s;
  }

  body:not(.vaporwave-mode) .scene-sun {
    opacity: 0;
    visibility: visible;
    pointer-events: auto;
    filter: brightness(0) contrast(1.35) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
    animation: none;
    transition: opacity 0.22s ease, filter 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
  }

  body:not(.vaporwave-mode) .scene-sun:is(:hover, :focus-visible) {
    opacity: 1;
    filter: brightness(0) contrast(1.45) drop-shadow(0 0 20px rgba(0, 0, 0, 0.35));
    transform: scale(1.035);
  }

  body.vaporwave-mode .scene-sun {
    pointer-events: auto;
  }

  body:not(.vaporwave-mode) .chat-container {
    max-width: 1120px;
    max-height: min(88vh, 860px);
    padding: 30px 36px;
  }

  body:not(.vaporwave-mode) .chat-container::before {
    content: 'SYSTEM OPERATIONS CONSOLE';
    align-self: flex-start;
    margin: 0 0 16px 22px;
    padding: 6px 10px;
    border: 1px solid #111;
    background: #fff;
    color: #111;
    font: 700 0.8rem Arial, Helvetica, sans-serif;
    letter-spacing: 1.2px;
  }

  body:not(.vaporwave-mode) .chat-history {
    padding: 18px 22px;
    margin-bottom: 22px;
    gap: 18px;
    scrollbar-color: #333 #dedede;
  }

  body:not(.vaporwave-mode) .chat-history::-webkit-scrollbar-track {
    background: #dedede;
  }

  body:not(.vaporwave-mode) .chat-history::-webkit-scrollbar-thumb {
    background: #333;
    box-shadow: none;
  }

  body:not(.vaporwave-mode) .message {
    font-family: Arial, Helvetica, sans-serif;
    border-radius: 6px;
    padding: 16px 18px;
    line-height: 1.5;
    color: #111;
    text-shadow: none;
    backdrop-filter: none;
    box-shadow: none;
  }

  body:not(.vaporwave-mode) .user-message {
    background: #111;
    border: 1px solid #111;
    color: #fff;
  }

  body:not(.vaporwave-mode) .ai-message {
    background: #fff;
    border: 1px solid #222;
    color: #111;
  }

  body:not(.vaporwave-mode) .system-message {
    background: #e9e9e9;
    border: 1px dashed #555;
    color: #111;
  }

  body:not(.vaporwave-mode) .message-meta,
  body:not(.vaporwave-mode) .user-message .message-meta,
  body:not(.vaporwave-mode) .ai-message .message-meta,
  body:not(.vaporwave-mode) .system-message .message-meta {
    color: inherit;
    text-shadow: none;
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0.8px;
  }

  body:not(.vaporwave-mode) .message-text {
    font-size: 1rem;
    letter-spacing: 0;
  }

  body:not(.vaporwave-mode) .image-preview {
    background: #fff;
    border: 1px solid #222;
    border-radius: 6px;
    backdrop-filter: none;
  }

  body:not(.vaporwave-mode) .preview-item {
    background: #eee;
    border: 1px solid #777;
    color: #111;
  }

  body:not(.vaporwave-mode) .preview-item button {
    color: #111;
  }

  body:not(.vaporwave-mode) .chat-form {
    background: #fff;
    border: 1px solid #111;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    backdrop-filter: none;
  }

  body:not(.vaporwave-mode) .chat-form:focus-within {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
  }

  body:not(.vaporwave-mode) .attach-button,
  body:not(.vaporwave-mode) .desktop-button,
  body:not(.vaporwave-mode) .agent-toggle,
  body:not(.vaporwave-mode) #sendButton {
    font-family: Arial, Helvetica, sans-serif;
    color: #111;
    background: #f7f7f7;
    border: 1px solid #111;
    border-radius: 4px;
    box-shadow: none;
    text-shadow: none;
  }

  body:not(.vaporwave-mode) .attach-button {
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 1rem;
  }

  body:not(.vaporwave-mode) .desktop-button {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  body:not(.vaporwave-mode) .agent-toggle {
    padding: 8px 10px;
    font-size: 0.78rem;
    color: #b85a00;
    font-weight: 800;
  }

  body:not(.vaporwave-mode) .agent-toggle.gemini-mode {
    color: #1f6feb;
  }

  body:not(.vaporwave-mode) .agent-toggle.qbit-mode {
    color: #008b9a;
  }

  body:not(.vaporwave-mode) #sendButton {
    color: #fff;
    background: #111;
    font-weight: 800;
  }

  body:not(.vaporwave-mode) .attach-button:hover,
  body:not(.vaporwave-mode) .desktop-button:hover,
  body:not(.vaporwave-mode) .agent-toggle:hover,
  body:not(.vaporwave-mode) #sendButton:hover {
    transform: translateY(-1px);
    filter: none;
    background: #111;
    color: #fff;
  }

  body:not(.vaporwave-mode) #messageInput {
    font-family: Arial, Helvetica, sans-serif;
    color: #111;
    font-size: 1rem;
    letter-spacing: 0;
  }

  body:not(.vaporwave-mode) #messageInput::placeholder {
    color: #777;
  }
}



/* Mobile design */
@media (max-width: 768px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  .stage {
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .window-frame {
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    animation: none;
  }

  .window-content {
    min-height: 100%;
    background:
      radial-gradient(circle at 70% 14%, rgba(255, 53, 215, 0.18) 0%, transparent 34%),
      linear-gradient(to bottom, #090526 0%, #150b38 45%, #2a0e5c 76%, #4f0a52 100%);
  }

  .scene-sun {
    width: clamp(116px, 42vw, 180px);
    top: max(18px, env(safe-area-inset-top));
    right: -8px;
    opacity: 0.92;
  }

  .scene-mountains {
    width: 150%;
    height: 32%;
    left: -25%;
    bottom: 30%;
    opacity: 0.5;
    filter: blur(1.5px);
  }

  .scene-city {
    width: 130%;
    height: 20%;
    left: -15%;
    bottom: 30%;
    opacity: 0.68;
  }

  .scene-grid {
    width: 260%;
    left: -80%;
    height: 34%;
    bottom: -7%;
    transform: perspective(130px) rotateX(72deg);
    background-size: 42px 42px;
  }

  .scene-car {
    display: block;
    width: clamp(150px, 46vw, 240px);
    bottom: 18%;
    left: 50%;
    opacity: 0.95;
    background-image: url('/Resources/car.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    filter: drop-shadow(0 9px 8px rgba(0, 0, 0, 0.58));
  }

  .car-model {
    display: none;
  }

  .chat-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0 auto;
    padding:
      calc(env(safe-area-inset-top) + 12px)
      clamp(12px, 4vw, 18px)
      calc(env(safe-area-inset-bottom) + 12px);
    justify-content: flex-end;
  }

  .chat-history {
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 12px;
    padding: 8px 2px 10px;
    gap: 14px;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .chat-history::-webkit-scrollbar {
    width: 0;
    display: none;
  }

  .message {
    max-width: min(92%, 560px);
    padding: 13px 15px;
    border-radius: 16px;
    line-height: 1.5;
  }

  .system-message {
    max-width: 94%;
    font-size: 0.78rem;
  }

  .message-meta {
    font-size: 0.72rem;
    margin-bottom: 7px;
    letter-spacing: 1px;
  }

  .message-text {
    font-size: clamp(0.92rem, 3.8vw, 1rem);
    letter-spacing: 0.1px;
  }

  .thinking {
    min-width: 12rem;
  }

  .message-images {
    gap: 8px;
  }

  .message-images img {
    max-width: min(100%, 170px);
    max-height: 135px;
  }

  .image-preview {
    max-height: 118px;
    overflow-y: auto;
    gap: 8px;
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 14px;
  }

  .preview-item {
    max-width: 100%;
    flex: 1 1 150px;
    padding: 5px 7px;
    font-size: 0.76rem;
  }

  .preview-item span {
    max-width: none;
    min-width: 0;
  }

  .chat-form {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 68px;
    grid-template-areas:
      "attach input send"
      "desk desk desk";
    gap: 8px;
    align-items: center;
    padding: 9px;
    border-radius: 24px;
    background: rgba(10, 5, 28, 0.82);
    box-shadow: 0 0 18px rgba(113, 53, 255, 0.24), inset 0 0 10px rgba(113, 53, 255, 0.12);
  }

  .attach-button {
    grid-area: attach;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: rgba(71, 234, 255, 0.08);
    border: 1px solid rgba(71, 234, 255, 0.3);
    font-size: 1.15rem;
  }

  .desktop-button {
    grid-area: desk;
    width: 100%;
    min-height: 34px;
    padding: 8px 10px;
    border-radius: 16px;
    font-size: 0.72rem;
    justify-content: center;
  }

  .theme-toggle {
    display: none;
  }

  #messageInput {
    grid-area: input;
    min-width: 0;
    width: 100%;
    padding: 11px 4px;
    font-size: 16px;
  }

  #messageInput::placeholder {
    color: rgba(255, 255, 255, 0.42);
  }

  #sendButton {
    grid-area: send;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 18px;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
  }
}

@media (max-width: 430px) {
  .chat-container {
    padding:
      calc(env(safe-area-inset-top) + 10px)
      10px
      calc(env(safe-area-inset-bottom) + 10px);
  }

  .message {
    max-width: 94%;
    padding: 12px 13px;
  }

  .desktop-button {
    font-size: 0.68rem;
    letter-spacing: 0.5px;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .scene-sun {
    width: 130px;
    top: 10px;
  }

  .scene-mountains,
  .scene-city {
    bottom: 24%;
  }

  .scene-grid {
    height: 30%;
  }

  .chat-container {
    padding: 8px 12px;
  }

  .chat-history {
    gap: 10px;
    margin-bottom: 8px;
  }

  .message {
    padding: 10px 12px;
  }

  .message-text {
    font-size: 0.88rem;
  }

  .chat-form {
    grid-template-columns: 40px 82px minmax(0, 1fr) 64px;
    grid-template-areas: "attach desk input send";
    border-radius: 22px;
    padding: 7px;
  }

  .attach-button,
  #sendButton {
    min-height: 40px;
    height: 40px;
  }

  .desktop-button {
    min-height: 40px;
    height: 40px;
    padding: 0 8px;
  }
}