:root {
  color-scheme: dark;
}

html,
body {
  height: 100%;
}

body {
  background-color: #0b0f19;
  color: #e5e7eb;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.glass {
  background: rgba(18, 24, 38, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.glass-card {
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.96), rgba(13, 18, 30, 0.96));
  border: 1px solid rgba(55, 65, 81, 0.8);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.22);
}

.glass-card:hover {
  border-color: rgba(59, 130, 246, 0.32);
}

input[type='text'],
textarea,
select {
  background-color: rgba(11, 15, 25, 0.58);
  border: 1px solid #1f2937;
  color: #e5e7eb;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

input[type='text']:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.typing-dot {
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

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

@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.shimmer-bg {
  background: linear-gradient(90deg, #111827 25%, #243042 50%, #111827 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.ai-content {
  color: #d1d5db;
  line-height: 1.7;
}

.ai-content h1,
.ai-content h2,
.ai-content h3 {
  color: #ffffff;
  font-weight: 700;
  margin-top: 1.15rem;
  margin-bottom: 0.55rem;
  letter-spacing: 0;
}

.ai-content h1 {
  font-size: 1.35rem;
}

.ai-content h2 {
  font-size: 1.18rem;
}

.ai-content h3 {
  font-size: 1.05rem;
}

.ai-content p {
  margin-bottom: 0.8rem;
}

.ai-content ul,
.ai-content ol {
  padding-left: 1.3rem;
  margin-bottom: 1rem;
}

.ai-content ul {
  list-style-type: disc;
}

.ai-content ol {
  list-style-type: decimal;
}

.ai-content li {
  margin-bottom: 0.38rem;
}

.ai-content strong {
  color: #fff;
  font-weight: 700;
}

.ai-content code {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(55, 65, 81, 0.7);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  color: #93c5fd;
}

.ai-content blockquote {
  border-left: 3px solid #38bdf8;
  padding-left: 1rem;
  color: #bfdbfe;
  background: rgba(14, 165, 233, 0.06);
  border-radius: 0 10px 10px 0;
}

.result-shell {
  position: relative;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.result-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(55, 65, 81, 0.85);
  background: rgba(11, 15, 25, 0.7);
  color: #bfdbfe;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.result-action:hover {
  color: #fff;
  border-color: rgba(59, 130, 246, 0.75);
  background: rgba(37, 99, 235, 0.16);
}

.pb-safe {
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Progress dots ──────────────────────────────────────────── */
.progress-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #374151;
  flex-shrink: 0;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.progress-dot.done {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

/* ── Streaming cursor ───────────────────────────────────────── */
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #3b82f6;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
  border-radius: 1px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Chat panel ─────────────────────────────────────────────── */
.chat-panel {
  border-top: 1px solid rgba(55, 65, 81, 0.6);
  padding-top: 1.5rem;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-bubble-user {
  align-self: flex-end;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #e5e7eb;
  border-radius: 16px 16px 4px 16px;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-ai {
  align-self: flex-start;
  background: rgba(18, 24, 38, 0.8);
  border: 1px solid rgba(55, 65, 81, 0.7);
  color: #d1d5db;
  border-radius: 4px 16px 16px 16px;
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  max-width: 95%;
  line-height: 1.6;
  word-break: break-word;
}

.chat-bubble-ai .ai-content,
.chat-bubble-ai p { margin-bottom: 0.5rem; }
.chat-bubble-ai h1, .chat-bubble-ai h2, .chat-bubble-ai h3 { font-size: 0.95rem; font-weight: 600; color: #fff; margin: 0.5rem 0 0.25rem; }
.chat-bubble-ai ul { padding-left: 1.2rem; margin-bottom: 0.5rem; list-style: disc; }
.chat-bubble-ai li { margin-bottom: 0.2rem; }
.chat-bubble-ai strong { color: #fff; }
.chat-bubble-ai code { background: rgba(15,23,42,0.9); border: 1px solid rgba(55,65,81,0.7); border-radius: 4px; padding: 0.05rem 0.3rem; color: #93c5fd; font-size: 0.82em; }

.chat-input-wrap {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-followup-input {
  flex: 1;
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  font-size: 0.875rem;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.5;
  background-color: rgba(11, 15, 25, 0.58);
  border: 1px solid #1f2937;
  color: #e5e7eb;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-followup-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background-color 0.2s, transform 0.1s;
}

.chat-send-btn:hover { background: #2563eb; }
.chat-send-btn:active { transform: scale(0.95); }

/* ── Stream content in-progress ─────────────────────────────── */
.stream-content {
  min-height: 60px;
}

/* ── Auth user pill ─────────────────────────────────────────── */
#auth-user-pill {
  display: flex;
  align-items: center;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 767px) {
  .mobile-stack-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .mobile-stack-actions button {
    width: 100%;
  }
}
