.preload,
.preload * {
  transition: none !important;
  -webkit-transition: none !important;
  -moz-transition: none !important;
  -ms-transition: none !important;
  -o-transition: none !important;
}

:root {
  --imessage-blue: #177BFF;
  --imessage-green: #34c759;
  --message-bg: var(--imessage-blue);
  --message-text: white;
  --input-bg: #f8f9fa;
  --border-color: #e0e0e0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --titlebar-bg: rgba(255, 255, 255, 0.85);
  --titlebar-text: #000000;
  --footer-bg: #ffffff;
  --system-bg: rgba(158, 158, 158, 0.3);
  --system-text: #666;
  --titlebar-height: 60px;
  --input-container-height: 160px;
  --message-padding: 10px;

  /* User bubble color options */
  --bubble-violet: #8b5cf6;
  --bubble-green: #34c759;
  --bubble-orange: rgb(254, 153, 0);
  --bubble-cyan: #00c7be;
  --bubble-pink: rgb(250, 122, 203);
  --bubble-yellow: #ffcc00;

  /* RGB versions for opacity/glow */
  --bubble-violet-rgb: 139, 92, 246;
  --bubble-green-rgb: 52, 199, 89;
  --bubble-orange-rgb: 254, 153, 0;
  --bubble-cyan-rgb: 0, 199, 190;
  --bubble-pink-rgb: 250, 122, 203;
  --bubble-yellow-rgb: 255, 204, 0;

  /* New variable for UI elements */
  --ui-accent-rgb: 23, 123, 255;
  /* iMessage Blue */

  --user-bubble-color: var(--bubble-green);
  --user-bubble-rgb: var(--bubble-green-rgb);
}

/* Import KaTeX CSS for LaTeX rendering */
@import url('https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css');

* {
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease, opacity 0.3s ease;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background-color: #f5f7fa;
  /* Fallback for light mode */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  transition: background 0.3s ease;
}

#root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  overflow: hidden;
  position: relative;
}

#root::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(#d3e0f0 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  opacity: 0.3;
  z-index: 0;
  pointer-events: none;
  transition: background-image 0.3s ease, opacity 0.3s ease;
}

.titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--titlebar-height);
  padding: 14px 20px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--titlebar-text);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  z-index: 1003;
  border-bottom: 1px solid #d3d3d3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.settings-btn {
  position: absolute;
  right: 70px;
  background: rgba(var(--ui-accent-rgb), 0.9);
  color: #ffffff;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.9;
}

@media (hover: hover) {
  .settings-btn:hover {
    opacity: 1;
    background: rgba(var(--ui-accent-rgb), 1.0);
    filter: brightness(0.9);
    transform: scale(1.1);
  }
}

.settings-btn:active {
  transform: scale(0.95);
}

.settings-btn:focus {
  outline: none;
  opacity: 1;
}

.clear-history-btn {
  position: absolute;
  right: 20px;
  background: rgba(220, 53, 69, 0.9);
  color: #ffffff;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.9;
}

@media (hover: hover) {
  .clear-history-btn:hover {
    opacity: 1;
    background: rgba(200, 35, 51, 0.9);
    transform: scale(1.1);
  }
}

.clear-history-btn:active {
  transform: scale(0.95);
}

.clear-history-btn:focus {
  outline: none;
  opacity: 1;
}

.settings-panel {
  position: fixed;
  top: calc(var(--titlebar-height) + (100vh - var(--titlebar-height)) / 2);
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: 16px;
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 24px;
  z-index: 1002;
  width: 320px;
  max-width: 90vw;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  pointer-events: none;
  overflow: visible;
}

.settings-panel.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.settings-overlay {
  position: fixed;
  top: var(--titlebar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.settings-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  transition: color 0.3s ease;
}

.settings-panel label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #e5e5e5;
  margin-bottom: 8px;
  transition: color 0.3s ease;
}

/* Image Viewer Panel */
.image-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2001;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.image-viewer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.image-viewer-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: 16px;
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 32px;
  z-index: 2002;
  width: fit-content;
  height: fit-content;
  max-width: 90vw;
  max-height: 90vh;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer-panel.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.image-viewer-img {
  border-radius: 8px;
  object-fit: contain;
  display: block;
}


.custom-select-wrapper {
  position: relative;
  width: 100%;
  font-family: inherit;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d3d3d3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 16px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease, background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-select-trigger:hover {
  background: rgba(255, 255, 255, 0.6);
}

.custom-select.open .custom-select-trigger {
  border-color: rgba(var(--ui-accent-rgb), 0.6);
  background: rgba(255, 255, 255, 0.7);
}

.arrow {
  border: solid #333;
  border-width: 0 2px 2px 0;
  display: inline-block;
  padding: 3px;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.custom-select.open .arrow {
  transform: rotate(-135deg);
  -webkit-transform: rotate(-135deg);
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgb(255, 255, 255);
  border: 1px solid #d3d3d3;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  height: 0;
  max-height: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.custom-select.open .custom-options {
  opacity: 1;
  visibility: visible;
  height: auto;
  overflow-y: auto;
  pointer-events: auto;
  transform: translateY(0);
  border-radius: 8px;
}

.custom-option {
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.custom-option:hover {
  background-color: rgba(var(--ui-accent-rgb), 0.1);
}

.custom-option.selected {
  background-color: rgba(var(--ui-accent-rgb), 0.2);
  font-weight: 500;
}

.theme-toggle {
  position: relative;
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid #d3d3d3;
  width: 100%;
  margin-top: 8px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.theme-toggle-slider {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: rgba(var(--ui-accent-rgb), 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 9999px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.theme-option {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
  color: #444444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.theme-option:focus {
  outline: none;
}

.theme-option.active {
  color: white;
}

/* Dark Mode Variables */
/* Dark Mode Variables */
html[data-theme="dark"] {
  --imessage-blue: #177BFF;
  --imessage-green: #34c759;
  --message-bg: var(--imessage-blue);
  --message-text: white;
  --input-bg: #2a2a2a;
  --border-color: #404040;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --titlebar-bg: rgba(30, 30, 30, 0.95);
  --titlebar-text: #ffffff;
  --footer-bg: #1a1a1a;
  --system-bg: rgba(80, 80, 80, 0.3);
  --system-text: #b0b0b0;
}

html[data-theme="dark"],
[data-theme="dark"] body {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  background-color: #1a1a1a;
  /* Fallback/Base color */
}

[data-theme="dark"] #root::before {
  background-image: radial-gradient(#404040 1.2px, transparent 1.2px);
  opacity: 0.2;
}

[data-theme="dark"] .titlebar {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  color: var(--titlebar-text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .settings-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .settings-overlay {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .settings-panel h3 {
  color: #ffffff;
}

[data-theme="dark"] .settings-panel label {
  color: #e5e5e5;
}

[data-theme="dark"] .image-viewer-overlay {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .image-viewer-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}


[data-theme="dark"] .custom-select-trigger {
  background: rgba(60, 60, 60, 0.5);
  color: #e0e0e0;
  border-color: #d3d3d3;
}

[data-theme="dark"] .custom-select-trigger:hover {
  background: rgba(70, 70, 70, 0.6);
}

[data-theme="dark"] .custom-select.open .custom-select-trigger {
  background: rgba(80, 80, 80, 0.7);
  border-color: rgba(var(--ui-accent-rgb), 0.6);
}

[data-theme="dark"] .arrow {
  border-color: #e0e0e0;
}

[data-theme="dark"] .custom-options {
  background: rgb(50, 50, 50);
  border-color: #d3d3d3;
}

[data-theme="dark"] .custom-option {
  color: #e0e0e0;
}

[data-theme="dark"] .custom-option:hover {
  background-color: rgba(var(--ui-accent-rgb), 0.15);
}

[data-theme="dark"] .custom-option.selected {
  background-color: rgba(var(--ui-accent-rgb), 0.25);
}

[data-theme="dark"] .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: #d3d3d3;
}

[data-theme="dark"] .theme-option {
  color: #cccccc;
}

[data-theme="dark"] .theme-option.active {
  color: #ffffff;
}

[data-theme="dark"] .model-option {
  color: #cccccc;
}

[data-theme="dark"] .input-wrapper {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .model-toggle {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] #message-input {
  background-color: rgba(60, 60, 60, 0.5);
  color: #ffffff;
}

[data-theme="dark"] #message-input::placeholder {
  color: #cccccc;
}

[data-theme="dark"] #message-input:focus {
  background-color: rgba(70, 70, 70, 0.7);
}

[data-theme="dark"] .footer-text {
  color: #cccccc;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .chat-container {
  background-color: #000000;
}



.content-below-titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
  padding-top: 0;
  z-index: 1;
}

.chat-container {
  flex: 1;
  padding: 10px var(--message-padding);
  padding-top: calc(var(--titlebar-height) + 10px);
  padding-bottom: calc(var(--input-container-height) + 15px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #ffffff;
  -ms-overflow-style: none;
  scrollbar-width: none;
  height: 100%;
  position: relative;
}

.chat-container::-webkit-scrollbar {
  display: none;
}

.message {
  width: fit-content;
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  position: relative;
  animation: messageAppear 0.2s ease-out;
  line-height: 1.5;
  font-size: 16px;
  background-color: var(--message-bg);
  color: var(--message-text);
  overflow-wrap: break-word;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.message-image {
  max-width: 200px;
  max-height: 300px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.message-image:hover {
  transform: scale(1.02);
}

.message p {
  margin: 0 0 8px 0;
}

.message p:last-child {
  margin-bottom: 0;
}

.message code {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.message pre {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message pre code {
  background-color: transparent;
  padding: 0;
}

.message strong {
  font-weight: 700;
}

.message em {
  font-style: italic;
}

.message ul,
.message ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message li {
  margin: 4px 0;
}

.message a {
  color: inherit;
  text-decoration: underline;
}

.message blockquote {
  border-left: 3px solid rgba(255, 255, 255, 0.5);
  padding-left: 12px;
  margin: 8px 0;
  font-style: italic;
}

/* KaTeX (LaTeX) styling within messages */
.message .katex {
  font-size: 1.1em;
  color: inherit;
}

.message .katex-display {
  margin: 12px 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

.message .katex-display>.katex {
  display: inline-block;
  text-align: center;
  white-space: nowrap;
}

/* Ensure KaTeX elements inherit text color in messages */
.message .katex .mord,
.message .katex .mop,
.message .katex .mrel,
.message .katex .mopen,
.message .katex .mclose,
.message .katex .mpunct,
.message .katex .minner {
  color: inherit;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

.message.sent {
  align-self: flex-end;
  background-color: var(--user-bubble-color);
}

.message.received {
  align-self: flex-start;
}

.message.system {
  align-self: center;
  background-color: var(--system-bg);
  color: var(--system-text);
  max-width: 90%;
  text-align: center;
  font-size: 14px;
  padding: 10px 14px;
  animation: messageAppear 0.3s ease-out;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.message.loading {
  min-width: 60px;
  padding: 16px 20px;
}

.message.loading .dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.message.loading .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.8);
  animation: dotFade 1.4s infinite ease-in-out;
}

.message.loading .dot:nth-child(1) {
  animation-delay: 0s;
}

.message.loading .dot:nth-child(2) {
  animation-delay: 0.2s;
}

/* Generated Images */
.generated-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin-top: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.generated-image:hover {
  transform: scale(1.02);
}

.message.loading .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotFade {

  0%,
  100% {
    opacity: 0.2;
  }

  50% {
    opacity: 1;
  }
}

.input-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: transparent;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
  height: auto;
  max-height: 400px;
}

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

.image-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: transparent;
  padding: 0;
  width: 100%;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.25, 1, 0.5, 1),
    opacity 0.3s ease-in-out,
    padding 0.3s ease,
    margin-bottom 0.3s ease;
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: 0;
  order: -1;
}

.image-preview-container.has-images {
  max-height: 120px;
  opacity: 1;
  visibility: visible;
  padding: 8px 0;
  margin-bottom: 8px;
  transition: max-height 0.4s cubic-bezier(0.25, 1, 0.5, 1),
    opacity 0.3s ease-in-out,
    padding 0.3s ease,
    margin-bottom 0.3s ease;
}

.image-preview {
  position: relative;
  width: 80px;
  height: 80px;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.remove-image-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
}

.remove-image-btn svg {
  width: 12px;
  height: 12px;
  stroke-width: 3;
}

.remove-image-btn:hover {
  background: rgba(200, 35, 51, 0.9);
  transform: scale(1.1);
}

.input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: 16px;
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 10px;
  width: 90%;
  max-width: 800px;
  margin: 0 auto;
  min-width: auto;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-controls {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

.input-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: space-between;
}

.model-toggle {
  position: relative;
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  align-self: center;
  width: fit-content;
  max-width: 100%;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.model-toggle-slider {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: rgba(var(--ui-accent-rgb), 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 9999px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.model-option {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.3s ease;
  min-width: auto;
  width: auto;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  color: #444444;
  display: flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.model-option:focus {
  outline: none;
}

.model-option.active {
  color: white;
}

#upload-button {
  order: 1;
  border: none;
  background-color: rgba(var(--ui-accent-rgb), 0.9);
  color: white;
  font-weight: 600;
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

#upload-button svg {
  width: 24px;
  height: 24px;
  color: white;
  transition: transform 0.2s ease;
}

@media (hover: hover) {
  #upload-button:hover {
    background-color: rgba(var(--ui-accent-rgb), 1.0);
    filter: brightness(0.9);
    transform: scale(1.1);
    z-index: 10;
  }
}

#upload-button:active {
  transform: scale(0.95);
}

#upload-button:disabled {
  cursor: not-allowed;
  transform: scale(1);
  opacity: 0.6;
}

#message-input {
  order: 2;
  flex: 1;
  border: none;
  padding: 6px 10px;
  border-radius: 15px;
  background-color: #ededed;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  resize: none;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s ease;
  min-height: 16px;
  max-height: 200px;
  width: 100%;
  min-width: 0;
  max-width: 80vw;
  overflow-y: auto;
  line-height: 1.4;
  align-self: flex-end;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#message-input::-webkit-scrollbar {
  display: none;
}

#message-input::placeholder {
  color: #444444;
  opacity: 1;
}

#message-input:focus {
  outline: none;
  background-color: #e5e5e5;
}

#send-button {
  order: 3;
  border: none;
  background-color: rgba(var(--ui-accent-rgb), 0.9);
  color: white;
  font-weight: 600;
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
  position: relative;
}

#send-button svg {
  width: 20px;
  height: 20px;
  color: white;
  transition: transform 0.2s ease;
}

@media (hover: hover) {
  #send-button:hover {
    background-color: rgba(var(--ui-accent-rgb), 1.0);
    filter: brightness(0.9);
    transform: scale(1.1);
  }
}

#send-button:active {
  transform: scale(0.95);
}

#send-button:disabled {
  cursor: not-allowed;
  transform: scale(1);
  opacity: 0.6;
}

.footer-text {
  text-align: center;
  padding: 8px 15px;
  font-size: 11px;
  color: #444444;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: 16px;
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  margin: 0 auto;
  align-self: center;
  width: fit-content;
  max-width: 100%;
  white-space: nowrap;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow:
      0 0 18px rgba(var(--ui-accent-rgb), 0.4),
      0 0 35px rgba(var(--ui-accent-rgb), 0.5),
      0 0 50px rgba(var(--ui-accent-rgb), 0.3);
  }

  50% {
    box-shadow:
      0 0 22px rgba(var(--ui-accent-rgb), 0.5),
      0 0 45px rgba(var(--ui-accent-rgb), 0.6),
      0 0 70px rgba(var(--ui-accent-rgb), 0.4);
  }
}

@keyframes pulseSent {

  0%,
  100% {
    box-shadow:
      0 0 18px rgba(var(--user-bubble-rgb), 0.4),
      0 0 35px rgba(var(--user-bubble-rgb), 0.5),
      0 0 50px rgba(var(--user-bubble-rgb), 0.3);
  }

  50% {
    box-shadow:
      0 0 22px rgba(var(--user-bubble-rgb), 0.5),
      0 0 45px rgba(var(--user-bubble-rgb), 0.6),
      0 0 70px rgba(var(--user-bubble-rgb), 0.4);
  }
}

.message.received:not(.loading) {
  animation: messageAppear 0.3s ease-out;
  box-shadow:
    0 0 18px rgba(23, 123, 255, 0.4),
    0 0 35px rgba(23, 123, 255, 0.5),
    0 0 50px rgba(23, 123, 255, 0.3);
}

.message.sent {
  animation: messageAppear 0.3s ease-out;
  box-shadow:
    0 0 18px rgba(var(--user-bubble-rgb), 0.4),
    0 0 35px rgba(var(--user-bubble-rgb), 0.5),
    0 0 50px rgba(var(--user-bubble-rgb), 0.3);
}

.message.loading {
  animation: messageAppear 0.3s ease-out;
  box-shadow:
    0 0 18px rgba(23, 123, 255, 0.4),
    0 0 35px rgba(23, 123, 255, 0.5),
    0 0 50px rgba(23, 123, 255, 0.3);
}

@media (max-width: 768px) {
  :root {
    --titlebar-height: 54px;
    --message-padding: 10px;
  }

  html,
  body {
    height: 100vh;
    height: -webkit-fill-available;
  }

  #root {
    height: 100vh;
    height: -webkit-fill-available;
  }

  .message {
    width: fit-content;
    max-width: 100%;
    padding: 12px 14px;
  }

  .message.system {
    max-width: 90%;
    font-size: 13px;
  }

  .message-image {
    max-width: 150px;
    max-height: 225px;
  }

  .input-container {
    padding: 12px;
    max-height: 350px;
  }

  .titlebar {
    padding: 12px 20px;
    font-size: 20px;
  }

  #message-input {
    padding: 8px 12px;
    font-size: 16px;
    max-height: 150px;
  }

  .settings-btn {
    right: 65px;
    font-size: 18px;
    padding: 8px;
  }

  .clear-history-btn {
    right: 15px;
    font-size: 18px;
    padding: 8px;
  }

  #send-button,
  #upload-button {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .footer-text {
    font-size: 10px;
    padding: 8px 12px;
  }

  .chat-container {
    padding-bottom: 180px;
  }

  .model-toggle {
    gap: 0;
    padding: 4px;
    align-self: center;
    width: fit-content;
    max-width: 100%;
  }

  .model-option {
    padding: 7px 14px;
    font-size: 13px;
    min-width: auto;
    width: auto;
    white-space: nowrap;
  }

  .image-preview {
    width: 60px;
    height: 60px;
  }

  .image-viewer-panel {
    max-width: 90vw;
    max-height: 85vh;
    padding: 12px;
  }

  .image-viewer-img {
    max-height: calc(85vh - 32px);
  }
}

@supports (padding: max(0px)) {
  .titlebar {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(14px, env(safe-area-inset-top));
    height: calc(var(--titlebar-height) + env(safe-area-inset-top));
  }

  .content-below-titlebar {
    padding-top: 0;
  }

  .chat-container {
    padding-top: calc(var(--titlebar-height) + env(safe-area-inset-top) + 10px);
  }

  .input-container {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .chat-container {
    padding-left: max(var(--message-padding), env(safe-area-inset-left));
    padding-right: max(var(--message-padding), env(safe-area-inset-right));
  }

  .footer-text {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.mt-4 {
  margin-top: 24px !important;
}


/* Notification Panel (Experimental Mode) */
.notification-panel {
  position: fixed;
  top: calc(var(--titlebar-height) + (100vh - var(--titlebar-height)) / 2);
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: 16px;
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 24px;
  z-index: 1005;
  width: 320px;
  max-width: 90vw;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.notification-panel.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.notification-panel h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  transition: color 0.3s ease;
}

.notification-panel p {
  color: #e5e5e5;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
  line-height: 1.5;
  transition: color 0.3s ease;
}

.notification-actions {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
}

.notification-btn {
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 120px;
}

.notification-btn.yes {
  background: rgba(220, 53, 69, 0.9);
  color: #ffffff;
}

.notification-btn.no {
  background: rgba(var(--ui-accent-rgb), 0.9);
  color: #ffffff;
}

.notification-btn.yes:hover {
  background: rgba(200, 35, 51, 1);
  transform: scale(1.05);
}

.notification-btn.no:hover {
  background: rgba(var(--ui-accent-rgb), 1);
  transform: scale(1.05);
}

/* Dark Mode for Notification Panel */
[data-theme="dark"] .notification-panel {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid #d3d3d3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .notification-panel h3 {
  color: #ffffff;
}

[data-theme="dark"] .notification-panel p {
  color: #cccccc;
}

/* Experimental Toggle Styles */
.experimental-toggle {
  position: relative;
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid #d3d3d3;
  width: 100%;
  margin-top: 8px;
  transition: background 0.3s ease, border-color 0.3s ease;
  margin-bottom: 24px;
}

[data-theme="dark"] .experimental-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: #d3d3d3;
}

.experimental-option {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
  color: #444444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  outline: none;
}

[data-theme="dark"] .experimental-option {
  color: #cccccc;
}

.experimental-option.active {
  color: white;
}

.experimental-toggle-slider {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: rgba(var(--ui-accent-rgb), 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 9999px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}