:root {
  --bg-main: #000b1a;
  --bg-elevated: #050b20;
  --bg-header: #020616;
  --bg-input: #050a17;
  --border-subtle: #1b2340;
  --accent-blue: #0099ff;
  --accent-pink: #ff00a2;
  --accent-green: #00ff99;
  --text-primary: #e8f1ff;
  --text-secondary: #9ca9c9;
  --text-muted: #596080;
  --shadow-soft: 0 0 25px rgba(0, 0, 0, 0.6);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --transition-fast: 160ms ease-out;
  --transition-med: 220ms ease-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at top, #091a2c 0, #00040c 55%, #000000 100%);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-root {
  width: 100%;
  max-width: 1024px;
  height: 100vh;
  max-height: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, rgba(0, 10, 30, 0.96), rgba(0, 0, 0, 0.98));
  border-radius: 18px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(107, 124, 194, 0.24);
  overflow: hidden;
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: radial-gradient(circle at top left, #09152c 0, #020617 45%, #00040c 100%);
  border-bottom: 1px solid rgba(61, 88, 170, 0.55);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: radial-gradient(circle at 20% 20%, #46b5ff, #ff5ac3 45%, #1b1f3a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    0 0 16px rgba(70, 181, 255, 0.75),
    0 0 32px rgba(255, 90, 195, 0.55);
}

.logo-icon i {
  color: #050816;
  font-size: 18px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.app-tagline {
  font-size: 11px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(64, 255, 180, 0.15), rgba(70, 181, 255, 0.1));
  border: 1px solid rgba(64, 255, 180, 0.35);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(64, 255, 180, 0.85);
}

.status-text {
  font-size: 11px;
  color: var(--accent-green);
}

/* Layout */

.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 3.3fr) minmax(220px, 1.2fr);
  gap: 10px;
  padding: 10px;
  min-height: 0;
}

.chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, #050b1e 0, #02040d 55%, #000000 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  padding: 10px 12px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 104, 173, 0.8) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(88, 104, 173, 0.85);
  border-radius: 999px;
}

/* Messages */

.message-row {
  display: flex;
  margin-bottom: 10px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.message-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, #46b5ff, #0a1027);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-inline: 6px;
  box-shadow: 0 0 16px rgba(70, 181, 255, 0.6);
}

.message-row.user .message-avatar {
  background: radial-gradient(circle, #ff5ac3, #1b1027);
  box-shadow: 0 0 16px rgba(255, 90, 195, 0.6);
}

.message-avatar span,
.message-avatar i {
  font-size: 15px;
  font-weight: 700;
  color: #050816;
}

.message-content {
  max-width: 80%;
  display: flex;
  flex-direction: column;
}

.message-bubble {
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  background: rgba(12, 19, 49, 0.92);
  border: 1px solid rgba(99, 123, 199, 0.8);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.message-row.user .message-bubble {
  background: radial-gradient(circle at top left, rgba(255, 90, 195, 0.16), rgba(14, 18, 48, 0.96));
  border-color: rgba(255, 90, 195, 0.7);

  /* Core layout properties for wrapping */
  display: inline-block;       /* Fits to content width instead of full row */
  word-wrap: break-word;      /* Legacy support for word breaking */
  overflow-wrap: break-word;  /* Modern property to break long words */
  white-space: pre-wrap;      /* Preserves line breaks but allows wrapping */
  height: auto;               /* Ensures height is dynamic */
}

.message-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.message-username {
  font-weight: 500;
  letter-spacing: 0.02em;
}

.message-timestamp {
  opacity: 0.9;
}

.message-intent-tag {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(120deg, rgba(70, 181, 255, 0.12), rgba(255, 90, 195, 0.18));
  border: 1px solid rgba(70, 181, 255, 0.55);
  color: var(--accent-blue);
}

/* Typing indicator */

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-blue);
  opacity: 0.2;
  animation: typingPulse 900ms infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingPulse {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Chat input */

.chat-input-area {
  padding: 8px;
  border-top: 1px solid var(--border-subtle);
  background: linear-gradient(to top, #02040a, rgba(5, 10, 23, 0.96));
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: radial-gradient(circle at top, #040918 0, #02030a 55%, #000000 100%);
  border-radius: 999px;
  padding: 4px 6px 4px 8px;
  border: 1px solid rgba(76, 97, 185, 0.8);
  box-shadow:
    0 0 18px rgba(70, 181, 255, 0.25),
    0 0 30px rgba(0, 0, 0, 0.9);
}

.chat-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  max-height: 70px;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.icon-button {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: radial-gradient(circle at 30% 0%, rgba(70, 181, 255, 0.15), rgba(10, 15, 35, 0.9));
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

.icon-button:hover {
  background: radial-gradient(circle at 30% 0%, rgba(255, 90, 195, 0.26), rgba(12, 18, 45, 1));
  color: var(--accent-pink);
  transform: translateY(-0.5px);
  box-shadow: 0 0 16px rgba(255, 90, 195, 0.6);
}

.icon-button:active {
  transform: translateY(0.5px) scale(0.96);
  box-shadow: none;
}

.mic-button {
  position: relative;
}

.mic-button.active {
  background: radial-gradient(circle at 30% 0%, rgba(255, 90, 195, 0.5), rgba(10, 15, 35, 1));
  color: var(--accent-pink);
  box-shadow:
    0 0 12px rgba(255, 90, 195, 0.9),
    0 0 20px rgba(70, 181, 255, 0.7);
}

.mic-button.active::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(255, 90, 195, 0.6);
  animation: micPulse 1.2s infinite ease-out;
}

.mic-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

@keyframes micPulse {
  0% {
    opacity: 0.8;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.25);
  }
}

.send-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #020617;
  background-image: linear-gradient(120deg, #46b5ff, #ff5ac3);
  box-shadow:
    0 0 18px rgba(70, 181, 255, 0.8),
    0 0 28px rgba(255, 90, 195, 0.8);
  transition: transform var(--transition-med), box-shadow var(--transition-med), filter var(--transition-med);
}

.send-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.send-button:active {
  transform: translateY(0);
  filter: brightness(0.96);
  box-shadow:
    0 0 12px rgba(70, 181, 255, 0.7),
    0 0 18px rgba(255, 90, 195, 0.7);
}

.send-button i {
  font-size: 12px;
}

/* Sidebar */

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

.sidebar-section {
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  background: radial-gradient(circle at top, #030718 0, #02020b 60%, #000000 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.sidebar-title i {
  color: var(--accent-blue);
}

.intent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr 1fr;
  font-size: 11px;
}

.intent-pill {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(70, 181, 255, 0.4);
  background: radial-gradient(circle at 0 0, rgba(70, 181, 255, 0.18), rgba(12, 18, 48, 0.85));
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.intent-pill.active {
  border-color: rgba(255, 90, 195, 0.9);
  background: radial-gradient(circle at 0 0, rgba(255, 90, 195, 0.32), rgba(12, 18, 48, 0.95));
  color: var(--accent-pink);
}

.intent-pill.active i {
  color: var(--accent-pink);
}

.intent-pill span {
  font-size: 10px;
  text-transform: uppercase;
}

.intent-pill i {
  font-size: 10px;
  color: var(--accent-blue);
}

/* Sidebar banner */

.sidebar-banner {
  width: 100%;
  margin: 10px 0;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-banner img {
  display: block;
  width: 100%;
  max-height: 80px;
  object-fit: cover;
}

/* Social links */

.social-links {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.social-poster {
  width: 100%;
  max-height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background-image: linear-gradient(120deg, rgba(70, 181, 255, 0.35), rgba(255, 90, 195, 0.4));
  border: 1px solid rgba(70, 181, 255, 0.6);
  position: relative;
  box-shadow: 0 0 22px rgba(0, 0, 0, 0.7);
}

.social-poster-overlay {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  gap: 8px;
  padding: 8px 10px;
  backdrop-filter: blur(4px);
  background: radial-gradient(circle at top left, rgba(0, 11, 30, 0.4), rgba(0, 0, 0, 0.7));
  font-size: 11px;
  color: var(--text-primary);
}

.social-poster-overlay i {
  font-size: 16px;
  color: #020617;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.social-links a {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(70, 181, 255, 0.2), rgba(15, 20, 45, 0.95));
  color: var(--text-secondary);
  border: 1px solid rgba(70, 181, 255, 0.4);
  text-decoration: none;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), text-decoration var(--transition-fast);
}

.social-links a:hover {
  background: radial-gradient(circle at top, rgba(255, 90, 195, 0.3), rgba(15, 20, 45, 1));
  color: var(--accent-pink);
  border-color: rgba(255, 90, 195, 0.8);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(255, 90, 195, 0.8);
  text-decoration: none;
}

/* Intent panel */

.intent-panel {
  position: absolute;
  right: 12px;
  bottom: 78px;
  width: min(360px, 92%);
  background: radial-gradient(circle at top, #040a1c 0, #02030a 60%, #000000 100%);
  border-radius: 16px;
  border: 1px solid rgba(70, 181, 255, 0.6);
  box-shadow:
    0 0 18px rgba(70, 181, 255, 0.5),
    0 18px 55px rgba(0, 0, 0, 0.9);
  padding: 8px 10px;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  pointer-events: none;
  transition:
    opacity var(--transition-med),
    transform var(--transition-med);
  z-index: 20;
}

.intent-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.intent-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.intent-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.intent-panel-title i {
  color: var(--accent-blue);
}

.intent-panel-body {
  font-size: 11px;
  color: var(--text-secondary);
}

.intent-panel-body .panel-section {
  margin-bottom: 6px;
}

.intent-panel-body .panel-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.intent-panel-body .panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(70, 181, 255, 0.6);
  background: radial-gradient(circle at 0 0, rgba(70, 181, 255, 0.22), rgba(8, 13, 35, 1));
  font-size: 10px;
}

.intent-panel-body .panel-badge i {
  color: var(--accent-blue);
}

/* Wikipedia block inside answers */

.wiki-block {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px dashed rgba(70, 181, 255, 0.6);
  background: radial-gradient(circle at top, rgba(70, 181, 255, 0.1), rgba(7, 11, 30, 0.98));
}

.wiki-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.wiki-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.wiki-title i {
  color: var(--accent-blue);
}

.wiki-link {
  font-size: 10px;
  color: var(--accent-blue);
  text-decoration: none;
}

.wiki-link:hover {
  text-decoration: underline;
}

.wiki-thumb {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 4px;
}

/* Responsive */

@media (max-width: 840px) {
  /* Stop vertical centering on mobile (THIS fixes header clipping) */
  body {
    align-items: flex-start;
  }

  .app-root {
    max-width: 100%;
    height: 100svh;      /* real visible mobile viewport */
    max-height: none;   /* remove desktop constraint */
    border-radius: 0;
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 4fr) auto;
    gap: 8px;
  }

  .sidebar {
    flex-direction: row;
    display: none;
  }

  .sidebar-section {
    flex: 1;
    min-height: 120px;
  }

  .intent-panel {
    right: 50%;
    transform: translateX(50%) translateY(10px) scale(0.96);
  }

  .intent-panel.visible {
    transform: translateX(50%) translateY(0) scale(1);
  }

  .message-content {
    max-width: 88%;
  }

  .send-button span {
    display: none;
  }

  .send-button {
    padding: 10px;
  }
}
