.chat-box-input-flex-container {
    display: flex;
    flex-direction: row;
    align-items: left;
    /* gap: 10px; */
}

#chat-box-input-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    position: relative;
    width: 100%;
    z-index: 2;
    /* padding: 0 0; */
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    position: static;  /* Change to static so absolute positioning is relative to #chat-box-input-wrapper */
    width: fit-content;
    margin: 0 auto;
}

.chat-box {
    /* padding: 10px; */
    font-size: 30px;
    line-height: 1.5;
    text-align: left;
    white-space: pre-wrap; 
    box-sizing: border-box; 
    border-radius: 8px;
    transition: background-color 0.2s;
    /* width: 100px; */
    margin: 0 auto; /* Center the chat-box */
    position: relative;
    z-index: 2;
}

#chat-box:focus {
    outline: none; 
}

#chat-box.show-placeholder::before {
    content: attr(data-placeholder);
}

#chat-box:not(:empty)::before {
    content: none;
} 


.chat-box-button i {
    color: var(--text-color-special);
}

#chat-box-assist-message {
    flex-shrink: 0;
    margin-right: 1rem;
    background: white;
    border-radius: 0.8rem;
    padding: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 0;
    max-width: 300px;
    border: 2px solid var(--text-color-special);
    position: absolute;
    left: calc(50% - 560px);
    top: 0rem; 
    /* transform: translateY(-50%); */
    z-index: 3;
  /* Preserve user/newline breaks and allow wrapping */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Adjust arrow positions to match new positioning */
#chat-box-assist-message::after {
    content: '';
    position: absolute;
    right: -20px;
    top: 70%;
    width: 0;
    height: 0;
    border: 20px solid transparent;
    border-left-color: var(--text-color-special);
    border-right: 0;
    border-bottom: 0;
    margin-top: -10px;
    z-index: 0;
}

#chat-box-assist-message::before {
    content: '';
    position: absolute;
    right: -17px;
    top: 70%;
    width: 0;
    height: 0;
    border: 18px solid transparent;
    border-left-color: white;
    border-right: 0;
    border-bottom: 0;
    margin-top: -9px;
    z-index: 1;
}

/* Hide MathLive's hamburger/menu toggle */
math-field::part(menu-toggle) {
  display: none !important;
}

math-field {
  text-align: center;
}

math-field::part(content) {
  justify-content: center;
}


/* Remove MathLive placeholder highlight background */
math-field::part(placeholder) {
  background: transparent !important;
}

math-field::part(placeholder),
math-field::part(selection) {
  background: transparent !important;
}

/* Remove the focus/selection highlight (the gray background) */
math-field:focus-within {
  --selection-background-color: transparent;
  --contains-highlight-background-color: transparent;
}

/* Optional: keep selection text readable if you ever select something */
math-field:focus-within {
  --selection-color: inherit;
}

/* Allow MathLive content to wrap instead of staying a single unbreakable line */
math-field::part(content) {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  max-width: 100% !important;
}

/*
 * Fix for long math lines not wrapping in KaTeX output.
 * This targets the elements generated by KaTeX for displaying math in messages.
 */
.katex {
    white-space: normal !important;
    word-wrap: break-word; /* Legacy fallback */
    overflow-wrap: break-word;
    word-break: break-all; /* More aggressive wrapping */
    display: inline-block; /* Ensures it respects container width */
    max-width: 100%;
}

.katex-display {
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    display: block;
    max-width: 100%;
}

/* Landing page override: make chat box white-only on site_main landing page */
.chat-box.landing-chat {
  background: #ffffff;
  color: #000000;
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.06);
  transition: box-shadow 180ms ease, transform 180ms ease;
  z-index: 4;
}

.chat-box.landing-chat:hover {
  box-shadow: 0 14px 40px rgba(0,0,0,0.14);
  transform: translateY(-3px);
}

/* Small image preview (used by both main and landing pages) */
.small-image-preview {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 150px;
    border-radius: 10px;
    border: 2px solid #ccc;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.16);
    background-color: white;
    transition: transform 0.25s ease-in-out;
    transform-origin: top right;
    z-index: 22000; /* Ensure it's above most UI elements */
}

.small-image-preview:hover {
    transform: scale(1.4) translate(-12px, 12px);
}

/* Landing page modifier: place preview a bit lower so it doesn't overlap hero content */
.small-image-preview.landing-preview {
  top: 72px; /* lower than default 10px */
  right: 12px;
}

@media (max-width: 700px) {
  .small-image-preview.landing-preview { top: 56px; right: 8px; width: 120px; }
}
