/* ============================================================
   ChatNova — Production CSS
   Approved design: Nunito + dark sidebar + blue accent
   Add to <head>:
   <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap" rel="stylesheet">
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --blue:      #2563eb;
  --blue-d:    #1d4ed8;
  --blue-lt:   #eff6ff;
  --blue-md:   #bfdbfe;
  --text:      #111827;
  --text2:     #6b7280;
  --text3:     #9ca3af;
  --border:    #e5e7eb;
  --bg:        #f9fafb;
  --white:     #ffffff;
  --sidebar:   #1e293b;
  --sidebar2:  #273449;
  --green:     #16a34a;
  --red:       #dc2626;
  --yellow:    #d97706;
  --sans:      'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:      'SF Mono', 'Fira Code', monospace;
  --sidebar-w: 260px;
}

/* ── BASE ── */
body {
  font-family: var(--sans);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════════ */
.chat-header {
  height: 56px;
  background: var(--white);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
}

.chat-header-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 20px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -0.03em;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-header-logo:hover { opacity: 0.85; }

.chat-header-logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.mobile-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text2);
  font-size: 20px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.mobile-toggle:hover { background: var(--bg); color: var(--blue); }

.chat-header-spacer { flex: 1; }

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

/* Model selector */
.model-selector { position: relative; }

.model-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.model-btn:hover { border-color: var(--blue); color: var(--blue); }
.model-btn span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.model-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
  width: 290px;
  z-index: 100;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.model-option:hover { background: var(--blue-lt); }
.model-option.selected { background: var(--blue-lt); }

.model-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: var(--bg);
  border: 2px solid var(--border);
  font-size: 17px;
  flex-shrink: 0;
}

.model-info { flex: 1; min-width: 0; }
.model-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-desc { font-size: 12px; font-weight: 500; color: var(--text3); margin-top: 1px; }
.model-check { color: var(--blue); font-size: 15px; flex-shrink: 0; }

/* Header buttons */
.header-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.header-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }

.header-balance {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.header-balance:hover { border-color: var(--blue); color: var(--blue); }
.header-balance b { color: var(--text); }

.header-user-avatar {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
  text-decoration: none;
}
.header-user-avatar:hover { opacity: 0.85; }

.mobile-new-chat {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: transparent;
  font-size: 18px; color: var(--text2);
  cursor: pointer; flex-shrink: 0;
  transition: all 0.12s;
}
.mobile-new-chat:hover { border-color: var(--blue); color: var(--blue); }

/* ══════════════════════════════════════════
   BODY ROW
   ══════════════════════════════════════════ */
.body-row {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.sidebar.hidden { transform: translateX(-100%); width: 0; }

/* ★ НОВЫЙ ЧАТ — крупнее, жирнее */
.new-chat-btn {
  margin: 14px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  background: var(--blue);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.new-chat-btn:hover { background: var(--blue-d); }
.new-chat-btn i { font-size: 14px; }

.sidebar-header { display: none; }

.chats-section-label {
  padding: 12px 14px 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #475569;
  user-select: none;
}

.chats-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  -webkit-overflow-scrolling: touch;
}

.chat-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-item:hover { background: var(--sidebar2); }
.chat-item.active { background: #1e40af; }

.chat-item-content { flex: 1; min-width: 0; }

.chat-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.chat-item.active .chat-item-title { color: #fff; font-weight: 700; }

.chat-item-meta {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  margin-top: 1px;
}

.chat-item-actions {
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity 0.1s;
  flex-shrink: 0;
}
.chat-item:hover .chat-item-actions { opacity: 1; }

.chat-action-btn {
  background: transparent; border: none;
  padding: 4px 6px;
  cursor: pointer; color: #475569;
  border-radius: 6px; font-size: 13px;
  transition: all 0.1s; line-height: 1;
}
.chat-action-btn:hover { background: rgba(239,68,68,0.2); color: #f87171; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #273449;
}

.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px;
  cursor: pointer; transition: background 0.1s;
}
.user-info:hover { background: var(--sidebar2); }

.user-avatar {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 700; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-balance { font-size: 12px; font-weight: 600; color: #64748b; margin-top: 1px; }

.guest-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px;
  cursor: pointer; transition: background 0.1s;
}
.guest-info:hover { background: var(--sidebar2) !important; }

.sidebar-bottom-links {
  padding: 8px 12px 12px;
  border-top: 1px solid #273449;
}
.sidebar-links-row { display: flex; gap: 14px; margin-bottom: 6px; }
.sidebar-link-mini {
  font-size: 12px; font-weight: 600; color: #475569;
  text-decoration: none; transition: color 0.1s;
  display: flex; align-items: center; gap: 4px;
}
.sidebar-link-mini:hover { color: #94a3b8; }
.sidebar-copyright { font-size: 11px; font-weight: 500; color: #374151; margin-top: 4px; }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999; opacity: 0; visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  height: 100dvh;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ══════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════ */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
  background: var(--white);
}

.messages-container {
  flex: 1; overflow-y: auto;
  padding: 32px 0;
  -webkit-overflow-scrolling: touch;
}

.messages-inner {
  max-width: 760px; margin: 0 auto;
  padding: 0 28px;
  display: flex; flex-direction: column;
  gap: 20px;
}

/* Message block */
.message { display: flex; flex-direction: column; gap: 5px; }

.message-label {
  font-size: 13px; font-weight: 700; color: var(--text3);
  padding: 0 2px; letter-spacing: 0.02em;
}
.message.user .message-label { color: var(--blue); }

.message-content {
  padding: 14px 18px;
  border-radius: 4px 16px 16px 16px;
  font-size: 17px; line-height: 1.65; font-weight: 400;
  background: var(--bg); border: 2px solid var(--border);
  color: var(--text); word-wrap: break-word;
}
.message.user .message-content {
  background: var(--blue); color: #fff; border-color: var(--blue);
  border-radius: 16px 4px 16px 16px;
  align-self: flex-end; max-width: 80%;
  font-weight: 600;
}

.message-avatar { display: none; }

.message-text {
  font-size: 17px; line-height: 1.65; font-weight: 400;
  word-wrap: break-word; overflow-x: hidden;
}
.message.user .message-text { color: #fff; }

.message-text p { margin-bottom: 10px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text h1, .message-text h2, .message-text h3 { font-size: 18px; font-weight: 800; margin: 18px 0 8px; color: var(--text); }
.message-text ul, .message-text ol { padding-left: 22px; margin-bottom: 10px; }
.message-text li { margin-bottom: 4px; }
.message-text pre { background: #1e293b; border-radius: 10px; padding: 16px 18px; overflow-x: auto; margin: 12px 0; font-size: 14px; line-height: 1.6; }
.message-text code { font-family: var(--mono); font-size: 14px; background: var(--bg); border: 2px solid var(--border); padding: 1px 6px; border-radius: 6px; font-weight: 600; }
.message-text pre code { background: transparent; border: none; padding: 0; color: #e2e8f0; font-weight: 400; }
.message.user .message-text code { background: rgba(255,255,255,0.2); border-color: transparent; color: #fff; }
.message-text blockquote { border-left: 4px solid var(--blue-md); padding-left: 14px; color: var(--text2); margin: 12px 0; }
.message-text table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 15px; }
.message-text th, .message-text td { border: 2px solid var(--border); padding: 8px 12px; text-align: left; }
.message-text th { background: var(--bg); font-weight: 700; }

.message-image { max-width: 380px; width: 100%; border-radius: 12px; margin-top: 12px; border: 2px solid var(--border); }

.message-time { font-size: 12px; font-weight: 600; color: var(--text3); padding: 0 2px; margin-top: 2px; }
.message.user .message-time { color: rgba(255,255,255,0.5); align-self: flex-end; }

.message-model-label { font-size: 12px; font-weight: 600; color: var(--text3); padding: 0 2px; margin-top: 2px; }

.typing-indicator { display: flex; gap: 5px; padding: 14px 18px; }
.typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); animation: tdot 1.3s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes tdot { 0%,60%,100%{transform:translateY(0);opacity:0.3;} 30%{transform:translateY(-8px);opacity:1;} }

/* ── Input ── */
.input-container {
  padding: 14px 0 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--border);
  background: var(--white); flex-shrink: 0;
}
.input-wrapper { max-width: 760px; margin: 0 auto; padding: 0 28px; }

.input-area {
  border: 2px solid var(--border); border-radius: 14px;
  background: var(--bg); overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
}
.input-area.focused {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(191,219,254,0.4);
  background: var(--white);
}

.input-main-row {
  display: flex; align-items: flex-end;
  padding: 10px 12px 10px 16px; gap: 0;
}

.image-upload-btn {
  background: transparent; border: none;
  padding: 6px 8px; cursor: pointer;
  color: var(--text3); font-size: 18px;
  border-radius: 8px; transition: all 0.12s;
  flex-shrink: 0; align-self: flex-end; margin-bottom: 3px;
}
.image-upload-btn:hover { background: var(--blue-lt); color: var(--blue); }

.message-input {
  flex: 1; border: none; background: transparent;
  font-family: var(--sans); font-size: 17px; font-weight: 500;
  color: var(--text); resize: none; outline: none;
  min-height: 28px; max-height: 160px; line-height: 1.5;
  padding: 0 0 0 8px;
}
.message-input::placeholder { color: var(--text3); font-weight: 400; }

.send-btn {
  width: 40px; height: 40px;
  background: var(--blue); color: #fff; border: none;
  border-radius: 10px; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: 10px; align-self: flex-end;
  transition: background 0.15s, transform 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--blue-d); transform: scale(1.06); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; transform: none; }

.input-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px 10px;
  border-top: 1px solid var(--border);
}
.input-tool-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; background: transparent;
  border-radius: 7px; font-family: var(--sans);
  font-size: 14px; font-weight: 700; color: var(--text2);
  cursor: pointer; transition: all 0.12s;
}
.input-tool-btn:hover { background: var(--blue-lt); color: var(--blue); }
.input-tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.input-hint { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text3); }

.image-preview { padding: 0 14px 12px; display: none; position: relative; }
.image-preview.hidden { display: none !important; }
.image-preview img { max-width: 160px; border-radius: 10px; border: 2px solid var(--border); }
.remove-image-btn {
  position: absolute; top: 5px; right: 5px;
  background: rgba(0,0,0,0.55); color: #fff; border: none;
  border-radius: 50%; width: 22px; height: 22px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 11px; transition: background 0.12s;
}
.remove-image-btn:hover { background: rgba(220,38,38,0.85); }

/* ══════════════════════════════════════════
   WELCOME SCREEN
   ══════════════════════════════════════════ */
.welcome-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 28px 32px;
  max-width: 760px; margin: 0 auto; width: 100%;
  gap: 16px; min-height: 100%;
}

/* ★ Заголовок крупнее */
.welcome-title {
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  text-align: center;
}

.welcome-subtitle {
  font-size: 18px; font-weight: 500; color: var(--text2);
  text-align: center; line-height: 1.55; max-width: 500px;
  margin-top: -4px;
}

/* ★ Карточки — шире, больше padding, синяя тень при hover */
.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 600px;
  margin-top: 8px;
}

.suggestion-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column; gap: 8px;
}
.suggestion-card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-md);
  transform: translateY(-2px);
  background: var(--blue-lt);
}

/* ★ Иконка крупнее */
.suggestion-icon { font-size: 26px; }

/* ★ suggestion-text теперь содержит заголовок + описание */
.suggestion-text { display: flex; flex-direction: column; gap: 4px; }
.suggestion-title { font-size: 17px; font-weight: 800; color: var(--text); }
.suggestion-desc  { font-size: 14px; font-weight: 500; color: var(--text2); line-height: 1.4; }

/* Обратная совместимость — если в PHP один тег .suggestion-text */
.suggestion-text strong {
  display: block;
  font-size: 17px; font-weight: 800; color: var(--text);
  margin-bottom: 3px;
}

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 4px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 15px; font-weight: 600; width: 100%; max-width: 600px;
}
.alert-warning { background: #fffbeb; border: 2px solid #fde68a; color: #92400e; }
.alert a { color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* SEO block */
.seo-content { margin-top: 32px; border-top: 2px solid var(--border); padding-top: 28px; text-align: left; width: 100%; }
.seo-content h2 { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 10px; letter-spacing: -0.02em; }
.seo-content h3 { font-size: 17px; font-weight: 700; color: var(--text); margin: 18px 0 6px; }
.seo-content p  { font-size: 15px; line-height: 1.7; font-weight: 400; color: var(--text2); margin-bottom: 8px; }

/* Error */
.error-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; padding: 40px; }
.error-icon  { font-size: 56px; margin-bottom: 18px; }
.error-title { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.error-message { font-size: 16px; font-weight: 500; color: var(--text2); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px; }
.modal-content { background: var(--white); border: 2px solid var(--border); border-radius: 16px; max-width: 480px; width: 100%; box-shadow: 0 16px 48px rgba(0,0,0,0.14); overflow: hidden; }
.modal-header { padding: 18px 22px; border-bottom: 2px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.modal-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--text3); padding: 3px 6px; border-radius: 7px; transition: all 0.12s; line-height: 1; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px; }
.share-controls { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg); border-radius: 10px; margin-top: 6px; }
.share-toggle { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text2); cursor: pointer; }
.share-toggle input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; }
.share-link-container { display: flex; gap: 8px; flex: 1; }
.share-link-input { flex: 1; padding: 8px 12px; border: 2px solid var(--border); border-radius: 10px; font-family: var(--mono); font-size: 12px; font-weight: 600; background: var(--white); color: var(--text2); outline: none; }
.share-link-input:focus { border-color: var(--blue); }
.copy-link-btn { background: var(--blue); color: #fff; border: none; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-family: var(--sans); font-size: 14px; font-weight: 700; white-space: nowrap; transition: background 0.15s; }
.copy-link-btn:hover { background: var(--blue-d); }
.copy-link-btn.copied { background: var(--green); }
.public-badge  { display: inline-flex; align-items: center; gap: 5px; background: #f0fdf4; color: var(--green); border: 2px solid #bbf7d0; padding: 3px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.private-badge { display: inline-flex; align-items: center; gap: 5px; background: var(--bg); color: var(--text3); border: 2px solid var(--border); padding: 3px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; }

/* MathJax */
mjx-container { max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; -webkit-overflow-scrolling: touch; }
mjx-container[display="true"] { display: block; margin: 14px 0; }

/* File preview */
.file-preview-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border: 2px solid var(--border); border-radius: 10px; max-width: 200px; }
.file-preview-icon { font-size: 20px; }
.file-preview-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text2); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Utils */
.hidden { display: none !important; }
.hidden-desktop { display: none !important; }

/* Animations */
@keyframes slideIn  { from{transform:translateX(60px);opacity:0;} to{transform:translateX(0);opacity:1;} }
@keyframes slideOut { from{transform:translateX(0);opacity:1;} to{transform:translateX(60px);opacity:0;} }

/* ══════════════════════════════════════════
   RESPONSIVE ≤ 768px
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    height: 100dvh; z-index: 1000;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  .sidebar.active { transform: translateX(0); }
  .sidebar.hidden { transform: translateX(-100%); }

  .mobile-toggle   { display: flex; }
  .mobile-new-chat { display: flex; }

  .chat-header { padding: 0 14px; height: 52px; }
  .chat-header-logo { font-size: 18px; }
  .header-btn span { display: none; }
  .header-btn { padding: 7px 10px; }
  .header-balance span:not(b) { display: none; }
  .model-btn span { max-width: 90px; }

  .messages-container { padding: 20px 0; }
  .messages-inner { padding: 0 16px; gap: 16px; }

  .input-container { padding: 10px 0 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .input-wrapper { padding: 0 14px; }
  .input-hint { display: none; }

  .message-content { font-size: 16px; }
  .message-text    { font-size: 16px; }
  .message.user .message-content { max-width: 90%; }

  .welcome-screen { padding: 28px 16px; }
  .welcome-title  { font-size: 26px; }
  .welcome-subtitle { font-size: 16px; }
  .suggestions-grid { grid-template-columns: 1fr; max-width: 100%; }

  mjx-container { font-size: 85% !important; }
  mjx-container[display="true"] { overflow-x: auto; }
}