:root, [data-theme="dark"] {
  --bg-main: #212121;
  --bg-sidebar: #171717;
  --bg-pill: #2f2f2f;
  --bg-hover: #2a2a2a;
  --text-main: #ececec;
  --text-muted: #9b9b9b;
  --text-faint: #737373;
  --border-color: rgba(255, 255, 255, 0.08);
  --content-max-width: 760px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
  --banner-bg: #1c1826;
  --banner-border: rgba(156, 39, 176, 0.28);
  --banner-text: #dfc2ea;
  --badge-bg: rgba(156, 39, 176, 0.25);
  --badge-text: #e1bee7;
  --card-bg: #262626;
}

[data-theme="light"] {
  --bg-main: #ffffff;
  --bg-sidebar: #f7f7f8;
  --bg-pill: #f0f2f5;
  --bg-hover: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border-color: rgba(0, 0, 0, 0.08);
  --banner-bg: #faf5ff;
  --banner-border: rgba(156, 39, 176, 0.2);
  --banner-text: #6b21a8;
  --badge-bg: rgba(156, 39, 176, 0.12);
  --badge-text: #7e22ce;
  --card-bg: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Custom Slim Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 3px;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.layout {
  display: flex;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

@media (max-width: 640px) {
  .sidebar-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

.mobile-only-btn {
  display: none;
}

.hidden {
  display: none !important;
}

/* Sidebar with smooth slide animation (fixed width + margin-left so inner content never squishes) */
.sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 0 10px 10px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  transition: margin-left 0.24s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.18s ease;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed {
  margin-left: -260px;
  opacity: 0;
  border-right-color: transparent;
  pointer-events: none;
}

.sidebar-top {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 4px;
  flex-shrink: 0;
}

.global-top-controls {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
}

.global-brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  text-decoration: none;
}

.global-search-btn {
  transition: opacity 0.18s ease, width 0.18s ease;
}

.sidebar-icon-fill {
  opacity: 1;
  transition: opacity 0.16s ease;
}

.global-top-controls.is-sidebar-collapsed .sidebar-icon-fill {
  opacity: 0;
}

.global-top-controls.is-sidebar-collapsed .global-search-btn {
  opacity: 0;
  width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
}

.sidebar-top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-search-wrap {
  padding: 2px 2px 8px;
  flex-shrink: 0;
}

.sidebar-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.sidebar-search-input:focus {
  border-color: rgba(255, 255, 255, 0.24);
}

[data-theme="light"] .sidebar-search-input:focus {
  border-color: rgba(0, 0, 0, 0.24);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 38px;
  padding: 0 10px 0 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
}

.conv-item:hover {
  background: var(--bg-hover);
}

.conv-item.active {
  background: var(--bg-hover);
  color: var(--text-main);
  font-weight: 600;
  border-left: 3px solid #a855f7;
  padding-left: 7px;
}

.conv-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  line-height: 38px;
  user-select: none;
}

.conv-streaming-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.65);
}

.conv-item.is-streaming .conv-streaming-dot {
  display: inline-block;
  animation: convPulseBlue 1.2s ease-in-out infinite;
}

@keyframes convPulseBlue {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }
  60% {
    opacity: 0.45;
    box-shadow: 0 0 0 5px rgba(59, 130, 246, 0);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.conv-actions {
  display: none;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* Hover on any conversation shows actions */
.conv-item:hover .conv-actions {
  display: flex;
}

/* ACTIVE CONVERSATION: Directly and unconditionally show rename & delete buttons! */
.conv-item.active .conv-actions {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.conv-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
}

.conv-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* On active conversation, action buttons are crisp, clear and highlighted */
.conv-item.active .conv-action-btn {
  color: var(--text-main);
  opacity: 0.9;
}

.conv-item.active .conv-action-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.conv-action-btn.del-btn {
  color: #f87171;
}

.conv-action-btn.del-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444 !important;
}

.conv-action-btn.edit-btn:hover {
  background: rgba(192, 132, 252, 0.2);
  color: #c084fc !important;
}

.conv-edit-input {
  flex: 1;
  background: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid rgba(156, 39, 176, 0.6);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  height: 28px;
  box-shadow: 0 0 8px rgba(156, 39, 176, 0.2);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
}

.sidebar-footer-link,
.sidebar-footer-btn {
  flex: 1;
  min-width: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-footer-link svg,
.sidebar-footer-btn svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.sidebar-footer-link:hover,
.sidebar-footer-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-main);
  width: 100%;
  max-width: 100%;
}

/* Top Beta Banner */
.beta-banner {
  background: var(--banner-bg);
  border-bottom: 1px solid var(--banner-border);
  padding: max(7px, env(safe-area-inset-top, 7px)) max(16px, env(safe-area-inset-right, 16px)) 7px max(16px, env(safe-area-inset-left, 16px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--banner-text);
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
}

.beta-banner.hidden {
  display: none !important;
}

.beta-banner-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.beta-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.beta-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.beta-close-btn {
  background: transparent;
  border: none;
  color: var(--banner-text);
  opacity: 0.7;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
}

.beta-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.chat-header {
  height: 56px;
  padding: 0 max(18px, env(safe-area-inset-right, 18px)) 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: none;
  background: transparent;
  width: 100%;
  max-width: 100%;
  position: relative;
}

.chat-title-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(44vw, 320px);
  padding: 5px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 2;
}

[data-theme="light"] .chat-title-pill {
  background: rgba(15, 23, 42, 0.04);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.private-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

[data-theme="light"] .private-chat-btn {
  border-color: transparent;
  background: transparent;
}

.private-chat-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .private-chat-btn:hover {
  background: rgba(15, 23, 42, 0.06);
}

.private-chat-btn.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

[data-theme="light"] .private-chat-btn.is-active {
  color: #111827;
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.16);
}

.chat-main.is-private .input-pill {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.26);
}

[data-theme="light"] .chat-main.is-private .input-pill {
  border-color: rgba(0, 0, 0, 0.26);
}

.chat-main.is-private.is-empty .quick-starts {
  opacity: 0;
  transform: translateY(8px);
  max-height: 0;
  margin-top: 0;
  pointer-events: none;
}

.private-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  max-height: 60px;
  opacity: 1;
  overflow: hidden;
  transition: opacity 0.24s ease,
              transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
              max-height 0.24s cubic-bezier(0.22, 1, 0.36, 1),
              margin-top 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.private-notice svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.chat-main:not(.is-private) .private-notice,
.chat-main:not(.is-empty) .private-notice {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.beta-banner.hidden + .chat-header {
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(56px + env(safe-area-inset-top, 0px));
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(142, 36, 170, 0.45));
}

.model-brand {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  padding: 20px max(24px, env(safe-area-inset-right, 24px)) 24px max(24px, env(safe-area-inset-left, 24px));
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}

/* Centered Empty State */
.empty-state {
  margin: auto;
  text-align: center;
  padding: 0 16px 24px;
}

.empty-state-logo-wrap {
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
}

.empty-state-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 0 26px rgba(168, 45, 205, 0.55)) drop-shadow(0 0 10px rgba(142, 36, 170, 0.4));
  user-select: none;
}

.empty-state h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

/* Messages */
.messages-container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.messages-container:empty {
  display: none;
}

.msg-row {
  display: flex;
  width: 100%;
  line-height: 1.65;
  font-size: 15px;
}

.msg-user {
  justify-content: flex-end;
}

.msg-user .msg-bubble {
  background-color: var(--bg-pill);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 20px;
  max-width: 70%;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible;
}

.user-msg-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(128, 128, 128, 0.12);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.user-msg-toggle-btn:hover {
  color: var(--text-main);
  background: rgba(128, 128, 128, 0.22);
  border-color: var(--text-muted);
}

.msg-assistant {
  justify-content: flex-start;
  gap: 14px;
  align-items: flex-start;
}

.assistant-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.assistant-logo-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.msg-assistant .msg-bubble {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
  color: var(--text-main);
}

.msg-content > *:first-child {
  margin-top: 0 !important;
}

.msg-content > *:last-child {
  margin-bottom: 0 !important;
}

.msg-content h3,
.msg-content h4 {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  margin: 16px 0 8px;
}

.msg-content p {
  margin-bottom: 12px;
  word-break: break-word;
}

.msg-content strong {
  font-weight: 600;
}

.msg-content ul,
.msg-content ol {
  margin-bottom: 14px;
  padding-left: 24px;
}

.msg-content li {
  margin-bottom: 6px;
}

.inline-code {
  background-color: var(--bg-pill);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: #ff80bf;
}

[data-theme="light"] .inline-code {
  color: #b81467;
}

.code-block-wrap {
  margin: 14px 0 16px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #181818;
  max-width: 100%;
  box-sizing: border-box;
}

.msg-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 14px 0;
  box-sizing: border-box;
}

.msg-content th,
.msg-content td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  font-size: 13.5px;
  text-align: left;
}

.msg-content th {
  background: var(--bg-pill);
  font-weight: 600;
}

.msg-content p,
.msg-content li,
.msg-content blockquote {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ==========================================================================
   Math, Exponents, Subscripts & KaTeX Formula Typography
   ========================================================================== */

sup, .math-exp {
  font-size: 0.76em;
  vertical-align: super;
  line-height: 0;
  position: relative;
  top: -0.28em;
  font-family: inherit;
  font-weight: 600;
  color: #c084fc;
}

[data-theme="light"] sup,
[data-theme="light"] .math-exp {
  color: #7c3aed;
}

sub, .math-sub {
  font-size: 0.76em;
  vertical-align: sub;
  line-height: 0;
  position: relative;
  bottom: -0.2em;
  font-family: inherit;
  color: #93c5fd;
}

[data-theme="light"] sub,
[data-theme="light"] .math-sub {
  color: #2563eb;
}

.math-inline {
  display: inline-block;
  padding: 0 2px;
  vertical-align: baseline;
}

.math-display {
  display: block;
  text-align: center;
  margin: 16px 0;
  padding: 12px 16px;
  background: rgba(139, 92, 246, 0.05);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

[data-theme="light"] .math-display {
  background: rgba(124, 58, 237, 0.04);
  border-color: rgba(124, 58, 237, 0.16);
}

.math-fallback {
  font-family: "Cambria Math", "KaTeX_Math", "Times New Roman", serif;
  font-size: 1.05em;
  letter-spacing: 0.02em;
}

.math-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  padding: 0 4px;
  font-size: 0.9em;
  line-height: 1.1;
}

.frac-num {
  border-bottom: 1.5px solid currentColor;
  padding-bottom: 2px;
}

.frac-den {
  padding-top: 2px;
}

.math-sqrt {
  display: inline-flex;
  align-items: center;
}

.sqrt-body {
  border-top: 1.5px solid currentColor;
  padding-top: 1px;
  padding-left: 2px;
  padding-right: 2px;
}

/* KaTeX Color & Size Polishing */
.katex {
  font-size: 1.08em !important;
  color: inherit !important;
}

.katex-display {
  margin: 12px 0 !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding: 8px 0 !important;
}

/* ==========================================================================
   AI Reasoning & Thought Process Interactive Card
   ========================================================================== */
.reasoning-block {
  margin: 14px 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  background: rgba(139, 92, 246, 0.04);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.reasoning-block:hover {
  border-color: rgba(139, 92, 246, 0.45);
}

.reasoning-header {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: #c084fc;
  user-select: none;
  background: rgba(139, 92, 246, 0.08);
  transition: background 0.2s ease;
}

.reasoning-header::-webkit-details-marker {
  display: none;
}

.reasoning-header:hover {
  background: rgba(139, 92, 246, 0.14);
}

.reasoning-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c084fc;
}

.reasoning-title {
  flex: 1;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.reasoning-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.2);
  color: #e9d5ff;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

[data-theme="light"] .reasoning-header {
  color: #6d28d9;
  background: rgba(109, 40, 217, 0.07);
}

[data-theme="light"] .reasoning-badge {
  background: rgba(109, 40, 217, 0.12);
  color: #5b21b6;
  border-color: rgba(109, 40, 217, 0.2);
}

.reasoning-content {
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-muted);
  border-top: 1px solid rgba(139, 92, 246, 0.18);
  background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .reasoning-content {
  background: rgba(255, 255, 255, 0.6);
  color: #4b5563;
}

/* Blockquote & Divider & Task Checkbox */
.msg-quote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3.5px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.06);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-main);
}

.msg-divider {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color) 20%, var(--border-color) 80%, transparent);
  margin: 18px 0;
}

.task-checkbox {
  font-size: 1.1em;
  line-height: 1;
  vertical-align: middle;
  margin-right: 4px;
}
.task-checkbox.checked {
  color: #10b981;
}
.task-checkbox.unchecked {
  color: var(--text-muted);
}

[data-theme="light"] .code-block-wrap {
  background: #1f242d;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #111111;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-copy-code {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-copy-code:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.code-block-wrap pre {
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: #ececec;
}

/* Typing cursor */
.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background-color: var(--text-main);
  vertical-align: middle;
  margin-left: 4px;
  animation: blink 0.9s infinite;
}

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

/* Input Area */
.input-area {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 max(18px, env(safe-area-inset-right, 18px)) max(14px, env(safe-area-inset-bottom, 14px)) max(18px, env(safe-area-inset-left, 18px));
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Attachment Options Menu Popover */
.attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: max(18px, env(safe-area-inset-left, 18px));
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 210px;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom left;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.attach-menu.hidden {
  display: none !important;
}

.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--text-main);
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.attach-menu-item:hover {
  background-color: var(--bg-hover);
}

.attach-menu-item:active {
  transform: scale(0.98);
}

.attach-menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attach-menu-icon.file-icon {
  background: rgba(147, 51, 234, 0.15);
  color: #c084fc;
}

.attach-menu-icon.photo-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.attach-menu-icon.camera-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.attach-menu-label {
  display: flex;
  flex-direction: column;
}

.attach-menu-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
}

.attach-menu-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Attached File & Photo Preview */
.attached-images-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  max-width: 100%;
}

.attached-images-strip.hidden {
  display: none !important;
}

.attached-img-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-pill);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 4px;
  max-width: 100%;
}

.attached-img-item.compact {
  padding: 0;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: visible;
}

.attached-img-item.compact img {
  width: 56px;
  height: 56px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
}

.attached-img-item.single {
  padding: 4px 10px 4px 4px;
}

.attached-img-item.single img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.attached-img-name {
  font-size: 12.5px;
  color: var(--text-main);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-img-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #18181b;
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.attached-img-remove:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.attached-img-add-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1.5px dashed var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.attached-img-add-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.attached-img-count {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: 2px;
}

.attached-doc-badge {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(128, 128, 128, 0.16);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.attached-img-item.compact .attached-doc-badge {
  width: 56px;
  height: 56px;
  border-radius: 9px;
  font-size: 12px;
}

.msg-img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.msg-img-grid .msg-attached-img {
  max-width: 140px;
  max-height: 140px;
  border-radius: 10px;
  object-fit: cover;
}

.attached-file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px 10px 4px 6px;
  background-color: var(--bg-pill);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 12.5px;
  color: var(--text-main);
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.attached-file-preview {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.attached-file-preview.hidden {
  display: none !important;
}

#attached-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-file-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  flex-shrink: 0;
}

.remove-file-btn:hover {
  color: #ff5555;
}

/* User Message Attached Image in Chat Bubble */
.msg-img-wrap {
  margin: 6px 0 10px;
  max-width: 100%;
}

.msg-attached-img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: block;
}

.input-pill {
  background-color: var(--bg-pill);
  border-radius: 9999px;
  padding: 5px 8px 5px 12px;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  transition: min-height 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              padding 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.18s ease,
              box-shadow 0.18s ease,
              border-radius 0.15s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-main.is-empty:not(.has-draft) .input-pill {
  min-height: 58px;
  padding: 8px 10px 8px 14px;
}

.input-pill.multiline {
  align-items: flex-end;
  border-radius: 26px;
  padding-bottom: 8px;
}

.input-pill:focus-within {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.24);
}

[data-theme="light"] .input-pill:focus-within {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.attach-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.attach-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.globe-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.globe-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.globe-btn.active {
  background: rgba(168, 45, 205, 0.18);
  border-color: rgba(168, 45, 205, 0.7);
  color: #c084fc;
  box-shadow: 0 0 12px rgba(168, 45, 205, 0.4);
}

.globe-btn.active:hover {
  background: rgba(168, 45, 205, 0.28);
  border-color: #d8b4fe;
  color: #ffffff;
  box-shadow: 0 0 18px rgba(168, 45, 205, 0.6);
}

#chat-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 24px;
  max-height: 180px;
  resize: none;
  padding: 4px 2px;
  margin: 0;
  display: block;
  overflow-y: auto;
  box-sizing: border-box;
}

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

.action-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, background-color 0.15s, transform 0.12s ease;
}

.send-circle {
  background-color: var(--text-main);
  color: var(--bg-main);
}

.send-circle:hover:not(:disabled) {
  transform: scale(1.05);
}

.send-circle:disabled {
  background-color: var(--bg-hover);
  color: var(--text-faint);
  cursor: default;
  opacity: 0.6;
}

.stop-circle {
  background-color: var(--text-main);
  color: var(--bg-main);
}

/* Disclaimer text under input pill */
.input-disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 8px;
  letter-spacing: -0.01em;
  user-select: none;
}

/* Settings Modal (Centered Floating Island) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.18s ease;
  overflow-y: auto;
}

.modal-card {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  width: min(88vw, 430px);
  max-height: min(72dvh, 520px);
  margin: auto;
  padding: 18px 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1 1 auto;
  padding-right: 4px;
}

.feedback-type-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.feedback-type-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.feedback-type-btn.active {
  background: var(--text-main);
  color: var(--bg-main);
  border-color: var(--text-main);
}

.settings-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.settings-input:focus {
  border-color: var(--text-muted);
}

.feedback-status {
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.feedback-status.success {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}

.feedback-status.error {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
}

.feedback-submit-btn {
  min-width: 110px;
  font-weight: 600;
}

.settings-row-col {
  flex-direction: column;
  align-items: stretch !important;
  gap: 8px;
}

.settings-textarea {
  width: 100%;
  resize: vertical;
  min-height: 68px;
  max-height: 140px;
  background: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}

.settings-textarea:focus {
  border-color: rgba(168, 85, 247, 0.5);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.settings-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.settings-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-select {
  background: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13.5px;
  outline: none;
  cursor: pointer;
}

.settings-btn {
  background: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.settings-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(168, 45, 205, 0.5);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-danger:hover {
  background: #ef4444;
  color: #ffffff;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   Responsive Breakpoints: Tablets, Phones, & Small Screens
   ========================================================================== */

/* Tablet Push Sidebar (641px - 768px) & Mobile Drawer (<= 640px) */
@media (max-width: 768px) {
  .sidebar {
    width: 230px;
    min-width: 230px;
    max-width: 40vw;
    padding: 0 10px 8px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    transition: margin-left 0.24s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.18s ease;
  }

  .sidebar.collapsed {
    margin-left: -230px;
    opacity: 0 !important;
    border-right-color: transparent !important;
    pointer-events: none !important;
  }

  .chat-main {
    min-width: 0;
    flex: 1;
    overflow-x: hidden;
  }

  .chat-header {
    height: 56px;
    padding: 0 max(10px, env(safe-area-inset-right, 10px)) 0 12px;
    display: flex;
    align-items: center;
    position: relative;
    border-bottom: none;
    background: transparent;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .chat-title-pill {
    max-width: 38vw;
    padding: 4px 10px;
    font-size: 12px;
  }

  .private-chat-btn {
    height: 30px;
    padding: 0 10px;
    font-size: 12.5px;
    gap: 5px;
  }

  .chat-main.is-empty .empty-state h1 {
    font-size: clamp(0.95rem, 4.3vw, 1.65rem);
    line-height: 1.25;
    white-space: nowrap;
    text-align: center;
    max-width: 100%;
    padding: 0 8px;
  }

  .message-row,
  .message-bubble,
  .message-content {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .message-content pre,
  .message-content table {
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
  }
}

/* Narrow Mobile Phones (<= 640px): Clean overlay drawer so chat never gets squished */
@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 272px;
    min-width: 272px;
    max-width: 82vw;
    margin-left: 0 !important;
    height: 100%;
    height: 100dvh;
    z-index: 100;
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.45);
    transform: translateX(0);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
    opacity: 1;
    padding: 0 10px max(10px, env(safe-area-inset-bottom, 10px)) 10px;
  }

  .sidebar.collapsed {
    transform: translateX(-100%) !important;
    width: 272px !important;
    margin-left: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .input-area {
    padding: 0 10px max(12px, env(safe-area-inset-bottom, 12px)) 10px;
  }

  .input-pill {
    padding: 4px 6px 4px 8px;
    gap: 4px;
  }

  #chat-input {
    min-width: 0;
    font-size: 14px;
  }
}

  .beta-banner.hidden + .chat-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(52px + env(safe-area-inset-top, 0px));
  }

  #btn-open-sidebar {
    display: flex !important;
    z-index: 2;
  }

  .brand-container {
    position: static;
    left: auto;
    transform: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .brand-logo {
    width: 24px;
    height: 24px;
  }

  .model-brand {
    font-size: 15.5px;
  }

  /* Chat scroll & message rows */
  .chat-scroll {
    padding: 10px max(12px, env(safe-area-inset-right, 12px)) 14px max(12px, env(safe-area-inset-left, 12px));
    width: 100%;
    max-width: 100%;
  }

  .messages-container {
    gap: 16px;
    width: 100%;
    max-width: 100%;
  }

  .msg-row {
    padding: 4px 0;
    gap: 10px;
    width: 100%;
    max-width: 100%;
  }

  .msg-user .msg-bubble {
    max-width: 85%;
    padding: 9px 14px;
    font-size: 14.5px;
    border-radius: 17px;
  }

  .assistant-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  .assistant-icon-img {
    width: 20px;
    height: 20px;
  }

  .msg-content {
    font-size: 14.5px;
    line-height: 1.55;
  }

  .code-block-wrap pre {
    font-size: 12.5px;
    padding: 10px 12px;
  }

  /* Empty state */
  .empty-state {
    padding: 0 12px 16px;
  }

  .empty-state-logo {
    width: 58px;
    height: 58px;
  }

  .empty-state h1 {
    font-size: 20px;
    margin-top: 8px;
  }

  /* Input area */
  .input-area {
    padding: 0 max(10px, env(safe-area-inset-right, 10px)) max(8px, env(safe-area-inset-bottom, 8px)) max(10px, env(safe-area-inset-left, 10px));
    width: 100%;
    max-width: 100%;
  }

  .input-pill {
    min-height: 44px;
    padding: 4px 6px 4px 8px;
    gap: 6px;
    border-radius: 22px;
    width: 100%;
    max-width: 100%;
  }

  #chat-input {
    font-size: 16px !important; /* Prevents auto-zoom on iOS Safari */
    padding: 4px 0;
    min-height: 22px;
    min-width: 0 !important;
  }

  .attach-btn,
  .globe-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .action-circle {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .input-disclaimer {
    font-size: 10px;
    margin-top: 4px;
    padding: 0 4px;
    line-height: 1.3;
    white-space: normal;
  }

  /* Beta banner */
  .beta-banner {
    padding: max(6px, env(safe-area-inset-top, 6px)) max(10px, env(safe-area-inset-right, 10px)) 6px max(10px, env(safe-area-inset-left, 10px));
    font-size: 11px;
    gap: 6px;
  }

  .beta-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow: hidden;
  }

  /* Settings modal on mobile (compact centered floating island) */
  .modal-card {
    width: min(86vw, 370px);
    max-width: 86vw;
    max-height: 70dvh;
    padding: 16px 18px;
    border-radius: 18px;
  }

  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .settings-row .settings-select,
  .settings-row .settings-btn,
  .settings-row .btn-danger {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 9px 14px;
  }
}

/* Extra Small Phones (<= 400px) */
@media (max-width: 400px) {
  .empty-state-logo {
    width: 48px;
    height: 48px;
  }

  .empty-state h1 {
    font-size: 17px;
  }

  .chat-scroll {
    padding: 6px max(8px, env(safe-area-inset-right, 8px)) 10px max(8px, env(safe-area-inset-left, 8px));
  }

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

  .input-pill {
    padding: 3px 5px 3px 6px;
    gap: 4px;
    min-height: 40px;
  }

  .attach-btn,
  .globe-btn,
  .mic-btn {
    width: 29px;
    height: 29px;
  }

  .attach-btn svg,
  .globe-btn svg {
    width: 16px;
    height: 16px;
  }

  .action-circle {
    width: 29px;
    height: 29px;
  }

  .beta-badge {
    font-size: 9px;
    padding: 1px 4px;
  }
}

/* Large Screens & Ultra-Wide Displays (>= 1440px) */
@media (min-width: 1440px) {
  :root {
    --content-max-width: 820px;
  }

  .msg-content {
    font-size: 15.5px;
    line-height: 1.62;
  }
}

/* ==========================================================================
   Model Selector Dropdown & Header
   ========================================================================== */
.model-selector-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}

.model-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 13px 6px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.16s ease;
  user-select: none;
  white-space: nowrap;
}

.model-selector-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.22);
}

[data-theme="light"] .model-selector-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

.model-selector-btn.open {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: none;
}

[data-theme="light"] .model-selector-btn.open {
  border-color: rgba(0, 0, 0, 0.26);
}

.model-selector-name {
  letter-spacing: -0.01em;
}

.model-selector-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(168, 85, 247, 0.55);
  color: #d8b4fe;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.model-selector-badge.hidden {
  display: none !important;
}

.chevron-icon {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.model-selector-btn.open .chevron-icon {
  transform: rotate(180deg);
}

.model-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.32), 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: modelMenuFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.model-dropdown-menu.hidden {
  display: none !important;
}

@keyframes modelMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.model-opt-item {
  width: 100%;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.15s ease;
  font-family: inherit;
  position: relative;
  box-sizing: border-box;
}

.model-opt-item:hover {
  background: var(--bg-hover);
}

.model-opt-item.active {
  background: var(--bg-pill);
  border-color: rgba(255, 255, 255, 0.18);
}

[data-theme="light"] .model-opt-item.active {
  border-color: rgba(0, 0, 0, 0.16);
}

.model-opt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-opt-title-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.model-opt-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.model-opt-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

[data-theme="light"] .model-opt-tag {
  background: rgba(0, 0, 0, 0.06);
}

.purple-tag {
  background: rgba(168, 85, 247, 0.16) !important;
  border: 1px solid rgba(168, 85, 247, 0.55) !important;
  color: #d8b4fe !important;
}

[data-theme="light"] .purple-tag {
  background: rgba(147, 51, 234, 0.1) !important;
  border: 1px solid rgba(147, 51, 234, 0.45) !important;
  color: #7e22ce !important;
}

.model-opt-check {
  color: var(--text-main);
  font-weight: 700;
  font-size: 13px;
}

.model-opt-check.hidden {
  display: none !important;
}

.model-opt-desc {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Distinct Purple Box for From-Scratch Blurn't 1.1 with corner Beta badge */
.model-opt-scratch {
  background: rgba(147, 51, 234, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.32);
  padding-top: 14px;
  overflow: hidden;
}

.model-opt-scratch:hover {
  background: rgba(147, 51, 234, 0.14);
  border-color: rgba(168, 85, 247, 0.55);
}

.model-opt-scratch.active {
  background: rgba(147, 51, 234, 0.16);
  border-color: #8b5cf6;
  box-shadow: 0 0 0 1px #8b5cf6;
}

.scratch-badge-corner {
  position: absolute;
  top: 0;
  left: 0;
  background: linear-gradient(135deg, #7e22ce, #9333ea);
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  padding: 1.5px 7px 2px 6px;
  border-bottom-right-radius: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ==========================================================================
   Logo Visibility & Radiance (Dark & Light Modes)
   ========================================================================== */
.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  transition: filter 0.25s ease, transform 0.2s ease;
  flex-shrink: 0;
}

[data-theme="dark"] .brand-logo {
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.35));
}

[data-theme="light"] .brand-logo,
[data-theme="light"] .empty-state-logo,
[data-theme="light"] .assistant-logo-img,
[data-theme="light"] .sidebar-brand-logo {
  filter: invert(1) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}

.empty-state-logo-wrap {
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 24px;
  transition: all 0.25s ease;
}

[data-theme="dark"] .empty-state-logo-wrap {
  padding: 6px;
}

[data-theme="light"] .empty-state-logo-wrap {
  padding: 6px;
}

.empty-state-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  user-select: none;
  transition: filter 0.25s ease;
}

[data-theme="dark"] .empty-state-logo {
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}

.btn-danger-subtle {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
}

.btn-danger-subtle:hover {
  background: rgba(239, 68, 68, 0.2) !important;
}

/* Mobile Responsiveness for Model Switcher & Header */
@media (max-width: 600px) {
  .chat-header {
    gap: 8px;
    padding: 0 12px;
  }
  .brand-container {
    position: static;
    left: auto;
    transform: none;
    flex-shrink: 0;
  }
  .model-selector-wrapper {
    position: relative;
    flex-shrink: 0;
  }
  .model-selector-btn {
    padding: 5px 9px 5px 10px;
    font-size: 13.5px;
    white-space: nowrap;
  }
  .model-dropdown-menu {
    position: fixed !important;
    top: 94px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: 320px;
    margin: 0 auto;
  }
}

/* ==========================================================================
   Claude-Style Deliverable Cards (Files, PDFs, Nano Banana Images)
   ========================================================================== */
.artifact-card {
  margin: 12px 0;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.artifact-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-pill);
  flex-wrap: wrap;
}

.artifact-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.artifact-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(168, 85, 247, 0.14);
  color: #c084fc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.artifact-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.artifact-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.artifact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.artifact-btn {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.artifact-btn:hover {
  background: var(--bg-hover);
}

.artifact-btn-primary {
  background: var(--text-main);
  color: var(--bg-main);
  border-color: transparent;
}

.artifact-btn-primary:hover {
  opacity: 0.9;
  background: var(--text-main);
}

.artifact-preview {
  max-height: 320px;
  overflow: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
}

.artifact-pdf-preview {
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  padding: 10px;
}

.artifact-pdf-frame {
  width: 100%;
  height: 460px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
}

.artifact-html-preview {
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  padding: 0;
}

.artifact-html-frame {
  width: 100%;
  height: 440px;
  border: none;
  display: block;
  background: #ffffff;
}

/* Quick-Start Suggestion Cards */
.quick-starts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
  width: 100%;
  max-width: 560px;
}

.quick-start-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.quick-start-card:hover {
  background: var(--bg-pill);
  border-color: rgba(168, 85, 247, 0.35);
  transform: translateY(-1px);
}

.quick-start-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}

.quick-start-desc {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 540px) {
  .quick-starts {
    grid-template-columns: 1fr;
  }
}

/* Microphone Button */
.mic-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.mic-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.mic-btn.recording {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Message Bottom Action Bar */
.msg-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.msg-action-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.msg-action-btn:hover {
  background: var(--bg-pill);
  color: var(--text-main);
}

.nano-image-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.nano-image-preview {
  max-width: 100%;
  max-height: 440px;
  border-radius: 10px;
  object-fit: contain;
}

.nano-image-status {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 6px;
}

/* Animated Image Generation Placeholder */
.image-gen-loader {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: linear-gradient(120deg, var(--bg-pill) 20%, rgba(168, 85, 247, 0.14) 50%, var(--bg-pill) 80%);
  background-size: 220% 220%;
  animation: blurntImgShimmer 2.2s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
}

.image-gen-orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(168, 85, 247, 0.22);
  border-top-color: #a855f7;
  animation: blurntImgSpin 1s linear infinite, blurntImgPulse 2s ease-in-out infinite;
}

.image-gen-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

@keyframes blurntImgShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes blurntImgSpin {
  to { transform: rotate(360deg); }
}

@keyframes blurntImgPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.25); }
  50% { box-shadow: 0 0 20px 4px rgba(168, 85, 247, 0.35); }
}

/* ==========================================================================
   Grok-Style Chat Layout (Preserves All Blurn't AI Features & Responsive Safety)
   ========================================================================== */
[data-theme="dark"] {
  --bg-main: #161617;
  --bg-sidebar: #141415;
  --bg-pill: #202022;
  --bg-hover: #28282b;
  --card-bg: #1c1c1e;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
}

[data-theme="light"] {
  --bg-main: #ffffff;
  --bg-sidebar: #f7f7f8;
  --bg-pill: #f0f2f5;
  --bg-hover: #e5e7eb;
  --card-bg: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
}

.modal-card,
.model-dropdown-menu {
  background-color: var(--card-bg) !important;
  opacity: 1 !important;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 4px;
}

.sidebar-brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.sidebar-new-chat-wrap {
  padding: 4px 12px 10px;
}

.grok-new-chat-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.grok-new-chat-pill:hover {
  background: var(--bg-hover);
}

.grok-plus-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-section-title {
  padding: 8px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Centered Composer Stage when Empty, Bottom Composer when Chatting */
.chat-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.chat-main.is-empty .chat-stage {
  justify-content: center;
  align-items: center;
  padding-bottom: 6vh;
}

.chat-main.is-empty .chat-scroll {
  flex: 0 0 auto;
  overflow: visible;
  width: 100%;
  padding-bottom: 18px;
}

.chat-main.is-empty .empty-state {
  min-height: auto;
  padding: 0 16px;
}

.chat-main.is-empty .empty-state-logo-wrap {
  margin-bottom: 14px;
}

.chat-main.is-empty .empty-state-logo {
  width: 44px;
  height: 44px;
}

.chat-main.is-empty .empty-state h1 {
  font-size: clamp(1.55rem, 3vw, 2.05rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  transition: opacity 0.22s ease,
              transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.22s ease;
}

.chat-main.is-empty .empty-state h1.is-switching {
  opacity: 0;
  transform: translateY(-6px);
  filter: blur(4px);
}

.chat-main:not(.is-empty) .quick-starts {
  display: none;
}

.chat-main.is-empty .input-area {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.chat-main.is-empty .input-disclaimer {
  display: none;
}

/* Grok Clean Vertical Quick-Start List Below Centered Pill */
.chat-main.is-empty .quick-starts {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 16px;
  padding: 0 8px;
  max-width: 100%;
  max-height: 240px;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
  transition: opacity 0.2s ease,
              transform 0.2s ease,
              max-height 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              margin-top 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-main.is-empty.has-draft .quick-starts {
  opacity: 0;
  transform: translateY(8px);
  max-height: 0;
  margin-top: 0;
  pointer-events: none;
}

.chat-main .input-area {
  transition: max-width 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-main.is-empty .chat-scroll {
  transition: flex 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-main.is-empty .quick-start-card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: auto;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
}

.chat-main.is-empty .quick-start-card:hover {
  background: var(--bg-pill);
  transform: none;
}

.qs-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  flex-shrink: 0;
  white-space: nowrap;
  text-align: center;
  font-size: 13px;
  line-height: 1;
  color: var(--text-muted);
  font-family: var(--font-mono);
  transition: transform 0.15s ease;
}

.qs-icon-blue {
  color: #3b82f6;
}

.qs-icon-purple {
  color: #a855f7;
}

.qs-icon-emerald {
  color: #10b981;
  font-weight: 700;
}

.qs-icon-amber {
  color: #f59e0b;
}

.chat-main.is-empty .quick-start-card.qs-blue:hover {
  background: rgba(59, 130, 246, 0.1);
}

.chat-main.is-empty .quick-start-card.qs-purple:hover {
  background: rgba(168, 85, 247, 0.1);
}

.chat-main.is-empty .quick-start-card.qs-emerald:hover {
  background: rgba(16, 185, 129, 0.1);
}

.chat-main.is-empty .quick-start-card.qs-amber:hover {
  background: rgba(245, 158, 11, 0.1);
}

.chat-main.is-empty .quick-start-title {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.chat-main.is-empty .quick-start-card:hover .quick-start-title {
  color: var(--text-main);
}

/* Inline Model Selector inside Input Pill */
.input-pill .model-selector-wrapper {
  position: relative;
  flex-shrink: 0;
}

.input-pill .model-selector-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  gap: 5px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

[data-theme="light"] .input-pill .model-selector-btn {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.06);
}

.input-pill .model-selector-btn:hover,
.input-pill .model-selector-btn.open {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .input-pill .model-selector-btn:hover,
[data-theme="light"] .input-pill .model-selector-btn.open {
  background: rgba(15, 23, 42, 0.09);
  border-color: rgba(15, 23, 42, 0.12);
}

.input-pill .model-dropdown-menu {
  right: 0 !important;
  left: auto !important;
  bottom: calc(100% + 12px);
  top: auto;
  width: 272px;
  border-radius: 16px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.52);
  gap: 2px;
}

[data-theme="light"] .input-pill .model-dropdown-menu {
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.input-pill .model-opt-item {
  border: none !important;
  border-radius: 10px;
  padding: 9px 12px;
}

.input-pill .model-opt-item.active {
  background: rgba(255, 255, 255, 0.07);
}

[data-theme="light"] .input-pill .model-opt-item.active {
  background: rgba(15, 23, 42, 0.06);
}

.input-pill .model-opt-desc {
  font-size: 11.5px;
  margin-top: 2px;
  color: var(--text-muted);
}

.model-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

.model-menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 6px;
}

.model-menu-footer-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.model-menu-footer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.model-menu-footer-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.model-free-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 9999px;
  background: #ffffff;
  color: #111827;
  flex-shrink: 0;
}

[data-theme="light"] .model-free-pill {
  background: #111827;
  color: #ffffff;
}

.chat-main.is-empty .input-pill .model-dropdown-menu {
  top: calc(100% + 10px);
  bottom: auto;
}

@media (max-width: 600px) {
  .input-pill .model-selector-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  #chat-input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .input-pill .model-dropdown-menu,
  .chat-main.is-empty .input-pill .model-dropdown-menu {
    position: fixed !important;
    top: auto !important;
    bottom: 84px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: 320px;
    margin: 0 auto;
  }
}

/* Settings Spectrum Temperature Slider (synced with landing.css style) */
.temp-slider-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.temp-slider-badge {
  font-size: 13px;
  font-weight: 700;
  color: #eab308;
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.temp-slider-wrap {
  width: 100%;
  margin-top: 8px;
}

.spectrum-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, #ef4444, #eab308, #22c55e);
  outline: none;
  cursor: pointer;
}

.spectrum-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(15, 23, 42, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.spectrum-slider::-webkit-slider-thumb:hover {
  transform: scale(1.08);
}

.spectrum-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(15, 23, 42, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.temp-slider-stops {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 8px;
}

.temp-stop-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.temp-stop-btn:hover,
.temp-stop-btn.is-active {
  color: var(--text-main);
  font-weight: 600;
}

.artifact-btn:disabled,
.btn-copy-code:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Mobile single-line greeting guarantee (must follow base .chat-main.is-empty .empty-state h1) */
@media (max-width: 640px) {
  .chat-main.is-empty .empty-state {
    width: 100%;
    max-width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
  }

  .chat-main.is-empty .empty-state h1 {
    font-size: clamp(0.95rem, 4.3vw, 1.35rem);
    line-height: 1.25;
    white-space: nowrap;
    max-width: 100%;
    padding: 0;
  }
}

.conv-pin-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
}

/* 3-dot Floating Context Menu for Conversations */
.conv-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 196px;
  padding: 6px;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.conv-menu-item:hover {
  background: var(--bg-hover);
}

.conv-menu-item svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.conv-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

.conv-menu-item.danger {
  color: #ef4444;
}

.conv-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* Grok-Style Delete Confirmation Modal */
.delete-confirm-card {
  width: min(90vw, 340px) !important;
  max-width: 340px !important;
  padding: 20px !important;
  border-radius: 18px !important;
  gap: 0;
}

.delete-confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 8px;
}

.delete-confirm-desc {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 0 18px;
}

.delete-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.delete-confirm-btn-danger,
.delete-confirm-btn-cancel {
  width: 100%;
  padding: 10px 14px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.delete-confirm-btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

.delete-confirm-btn-danger:hover {
  background: rgba(239, 68, 68, 0.26);
}

.delete-confirm-btn-cancel {
  background: rgba(128, 128, 128, 0.14);
  color: var(--text-main);
  border-color: var(--border-color);
}

.delete-confirm-btn-cancel:hover {
  background: rgba(128, 128, 128, 0.24);
}

/* ==========================================================================
   Auth Modal, Sidebar Guest/Profile Footer & Profile Popup (Theme-Unified)
   ========================================================================== */
.sidebar-auth-guest {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.sidebar-guest-card {
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-guest-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: normal;
}

.sidebar-guest-desc {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: normal;
  overflow-wrap: break-word;
}

.sidebar-guest-btn {
  margin-top: 4px;
  width: 100%;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.sidebar-guest-btn:hover {
  background: var(--bg-hover);
}

.sidebar-auth-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.sidebar-profile-trigger {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
}

.sidebar-profile-trigger:hover {
  background: var(--bg-hover);
}

.sidebar-avatar-wrap {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-avatar-initial {
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-github-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.sidebar-github-pill:hover {
  background: var(--bg-hover);
}

.sidebar-github-pill svg {
  flex-shrink: 0;
}

/* Auth Modal (Oturum aç veya kaydol) */
.auth-modal-card {
  position: relative;
  width: min(92vw, 400px) !important;
  max-width: 400px !important;
  padding: 28px 24px 24px !important;
  border-radius: 22px !important;
  gap: 14px;
  text-align: center;
}

.auth-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
}

.auth-modal-title {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 650;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.auth-modal-sub {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.auth-google-btn {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.auth-google-btn:hover {
  background: var(--bg-hover);
}

.auth-modal-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.auth-modal-divider::before,
.auth-modal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.auth-modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-modal-input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

[data-theme="light"] .auth-modal-input {
  background: #f9fafb;
}

.auth-modal-input:focus {
  border-color: var(--text-muted);
}

.auth-modal-submit {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: var(--text-main);
  color: var(--bg-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.auth-modal-submit:hover {
  opacity: 0.9;
}

.auth-modal-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Profile Popup Menu */
.profile-popup-menu {
  min-width: 230px;
  max-width: min(88vw, 270px);
}

.profile-popup-header {
  padding: 6px 10px 4px;
}

.profile-popup-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-popup-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-info-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--border-color);
}

.profile-info-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.profile-info-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  word-break: break-all;
  text-align: right;
}

/* ============================================
   SIDEBAR KÜTÜPHANE & HAFIZA & PAYLAŞIM
   ============================================ */
.sidebar-library-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 20px);
  margin: 4px 10px 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  text-align: left;
}

.sidebar-library-btn:hover {
  background: rgba(128, 128, 128, 0.14);
}

.sidebar-library-btn svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar.collapsed .sidebar-library-btn {
  width: 40px;
  height: 40px;
  margin: 4px auto 8px;
  padding: 0;
  justify-content: center;
}

.sidebar.collapsed .sidebar-library-btn .library-btn-label {
  display: none;
}

.memory-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.memory-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.memory-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(128, 128, 128, 0.35);
  border-radius: 999px;
  transition: 0.2s;
}

.memory-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: 0.2s;
}

.memory-switch input:checked + .memory-slider {
  background-color: #10a37f;
}

.memory-switch input:checked + .memory-slider::before {
  transform: translateX(20px);
}

.library-modal-card {
  max-width: 860px;
  width: min(94vw, 860px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.library-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 14px;
  border-bottom: 1px solid var(--border-color);
}

.library-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.library-tab:hover {
  color: var(--text-main);
  background: rgba(128, 128, 128, 0.1);
}

.library-tab.active {
  background: var(--text-main);
  color: var(--bg-main);
  border-color: var(--text-main);
}

.library-grid {
  padding: 18px 22px 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.library-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(128, 128, 128, 0.05);
}

.library-card-thumb {
  height: 140px;
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.library-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.library-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: rgba(128, 128, 128, 0.18);
  color: var(--text-main);
}

.library-card-code-preview {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.4;
  overflow: hidden;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.28);
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

.library-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.library-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.library-card-actions button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.library-card-actions button:hover {
  background: rgba(128, 128, 128, 0.14);
}

.library-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   GROK-STYLE CATEGORIZED SETTINGS MODAL
   ============================================ */
.settings-modal-card {
  max-width: 780px;
  width: min(94vw, 780px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}

.settings-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 410px;
  overflow: hidden;
  flex: 1;
}

.settings-nav {
  border-right: 1px solid var(--border-color);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  background: rgba(128, 128, 128, 0.03);
}

.settings-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(128, 128, 128, 0.08);
  color: var(--text-muted);
}

.settings-search-wrap input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  color: var(--text-main);
  font-size: 13.5px;
  font-family: inherit;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.settings-nav-item:hover {
  background: rgba(128, 128, 128, 0.12);
  color: var(--text-main);
}

.settings-nav-item.active {
  background: rgba(128, 128, 128, 0.18);
  color: var(--text-main);
  font-weight: 600;
}

.settings-nav-item svg {
  flex-shrink: 0;
}

.settings-content {
  padding: 18px 22px;
  overflow-y: auto;
}

.settings-section-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.settings-badge-ok {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 163, 127, 0.16);
  color: #10a37f;
}

#settings-password-row #settings-new-password {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

#settings-password-row #btn-save-account-password {
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .settings-nav {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
  }
  .settings-search-wrap {
    width: 100%;
    margin-bottom: 4px;
  }
  .settings-nav-item {
    width: auto;
    padding: 7px 11px;
    font-size: 12.5px;
  }
  .settings-content {
    padding: 14px 16px;
  }
}
