html,
body,
#app {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-inline svg {
  display: block;
  width: 100%;
  height: 100%;
}

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

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scalePulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }

  50% {
    transform: scale(1.3);
    opacity: 1;
  }
}

.animate-scale-pulse {
  animation: scalePulse 1.2s ease-in-out infinite;
}

@keyframes pulseRing {
  0% {
    transform: scale(0.85);
    opacity: 0.6;
  }

  70% {
    transform: scale(1.2);
    opacity: 0.1;
  }

  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.animate-pulse-ring {
  animation: pulseRing 1.2s ease-out infinite;
}

.audio-wave {
  --level: 0;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}

.audio-wave .wave-bar {
  width: 3px;
  border-radius: 999px;
  background-color: #111827;
  transition: height 0.12s ease;
}

.audio-wave .wave-bar-1 {
  height: calc(4px + 10px * var(--level));
  opacity: 0.8;
}

.audio-wave .wave-bar-2 {
  height: calc(4px + 12px * var(--level));
  opacity: 0.9;
}

.audio-wave .wave-bar-3 {
  height: calc(4px + 14px * var(--level));
  opacity: 1;
}

.audio-wave .wave-bar-4 {
  height: calc(4px + 11px * var(--level));
  opacity: 0.85;
}

.scrollbar-gutter-stable {
  scrollbar-gutter: stable;
}

.error-message-container {
  border: 2px solid #dc2626;
  background-color: #fef2f2;
  border-radius: 12px;
  padding: 16px;
  margin: 8px 0;
  animation: fadeIn 0.3s ease-in-out;
}

.error-message-container:hover {
  border-color: #b91c1c;
  background-color: #fee2e2;
}

.markdown-body pre {
  background: #272822;
  color: #f8f8f2;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  overflow: auto;
  border: 1px solid #e5e7eb;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: inherit;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-body table th,
.markdown-body table td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.75rem;
}

/* Math rendering adjustments */
@media (min-width: 1024px) {
  .math-block {
    overflow-x: visible !important;
    overflow-y: visible !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0;
  }

  .math-block .katex-display {
    overflow-x: visible !important;
    overflow-y: visible !important;
    margin: 0 !important;
  }

  .math-block .katex {
    font-size: 1.1em;
    max-width: 100%;
  }

  .math-block>.math-inner {
    max-width: 100%;
    transform-origin: center center;
    transition: transform 0.2s ease-out;
    width: fit-content;
  }
}

@media (max-width: 1023px) {
  .math-block {
    overflow-x: auto !important;
    overflow-y: visible !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0;
    position: relative;
  }

  .math-block::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
  }

  .math-block .katex {
    font-size: 1em;
    white-space: nowrap;
  }

  .math-block .katex-display {
    overflow-x: visible !important;
    margin: 0.25em 0 !important;
  }

  .math-block.has-scroll::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 48px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.85) 30%, transparent 100%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
  }

  .math-block.has-scroll.scrolled-end::after {
    opacity: 0;
  }

  @media (prefers-color-scheme: dark) {
    .math-block.has-scroll::after {
      background: linear-gradient(to left, rgba(30, 30, 30, 0.98) 0%, rgba(30, 30, 30, 0.85) 30%, transparent 100%);
    }
  }

  .bg-gray-100 .math-block.has-scroll::after,
  .bg-gray-50 .math-block.has-scroll::after {
    background: linear-gradient(to left, rgba(249, 250, 251, 0.98) 0%, rgba(249, 250, 251, 0.85) 30%, transparent 100%);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .math-block .katex {
    font-size: 0.95em;
  }
}

@media (max-width: 639px) {
  .math-block {
    padding: 0.25rem 0;
  }

  .math-block .katex {
    font-size: 0.9em;
  }
}

.math-inline {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
}

.math-inline .katex {
  max-width: 100%;
}