/* =========================================
   CHAT PAGE — FIXED VERSION
========================================= */

/* ===== LAYOUT ===== */

.chat-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ===== CHAT SECTION ===== */

.chat-section {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* ===== HEADER ===== */

.chat-header {
  height: 66px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap:10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: rgba(255, 255, 255, .03);
  backdrop-filter: blur(12px);
}


body.light-theme.page-chat .chat-header,
.light-theme .chat-header {
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .96);
  color: var(--text-light);
}

body.light-theme.page-chat #mainNavbar {
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border-light);
}

.chat-header-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-inline-start: auto;
}

/* ===== CHAT CONTAINER ===== */

.chat-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;

  display: flex;
  flex-direction: column;

  gap: 14px;

  padding: 24px;

  scroll-behavior: smooth;

  background: var(--bg-dark);
}

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

.light-theme .chat-container {
  background: var(--bg-light);
}

.light-theme .chat-section {
  background: var(--bg-light);
}

/* ===== MESSAGES ===== */

.msg {
  display: flex;
  flex-direction: column;

  max-width: 100%;
}

.msg-user {
  align-self: flex-start;
  margin-left: auto;
  width: fit-content;
  max-width: min(74%, 720px);
}

.msg-bot {
  align-self: flex-start;
  margin-left: auto;
  margin-right: 0;
  width: min(100%, 820px);
}

.msg .bubble {

  padding: 10px 16px;

  border-radius: 18px;

  font-family: Vazirmatn, IRANSansX, IRANSans, Dana, Shabnam, "Segoe UI", Tahoma, Arial, sans-serif;

  font-size: 16px;

  font-weight: 400;

  line-height: 1.78;

  letter-spacing: 0;

  word-break: break-word;

  text-rendering: optimizeLegibility;

  -webkit-font-smoothing: antialiased;
}

.msg-user .bubble {

  background: #0d7bf2;

  color: white;

  border-bottom-left-radius: 5px;
}

.msg-bot .bubble {

  background: transparent;

  color: #ececf1;

  border-radius: 0;

  border: 0;

  padding: 4px 2px 10px;
}

.light-theme .msg-bot .bubble {

  background: transparent;

  color: var(--text-light);

  border: 0;
}

.msg .meta {

  display: none;
}

/* ===== INPUT AREA ===== */

.chat-input-area {

  flex-shrink: 0;

  padding: 18px;

  border-top: 1px solid rgba(255, 255, 255, .06);

  background: rgba(11, 17, 32, .9);

  backdrop-filter: blur(12px);
}

.light-theme .chat-input-area {

  background: rgba(255, 255, 255, .9);

  border-top: 1px solid rgba(15, 23, 42, .08);
}

/* ===== FORM ===== */

#chatForm {

  display: flex;

  align-items: center;

  gap: 10px;
}

/* ===== TEXTAREA ===== */

#userInput {

  flex: 1;

  min-height: 52px;
  max-height: 180px;

  resize: none;

  border: none;

  border-radius: 18px;

  padding: 14px 18px;

  background: rgba(255, 255, 255, .06);

  color: white;

  font-size: 1rem;

  outline: none;
}

#userInput::placeholder {

  color: rgba(255, 255, 255, .5);
}

.light-theme #userInput {

  background: rgba(15, 23, 42, .05);

  color: var(--text-light);
}

.light-theme #userInput::placeholder {

  color: rgba(15, 23, 42, .4);
}

/* ===== BUTTONS ===== */

#send-btn,
#image-btn {

  width: 52px;
  height: 52px;

  flex-shrink: 0;

  border: none;

  border-radius: 16px;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  transition: .2s ease;
}

#send-btn {

  background: var(--primary);

  color: white;

  font-size: 1.1rem;
}

#send-btn:hover {

  background: var(--primary-hover);
}

#image-btn {

  background: rgba(255, 255, 255, .06);
}

.light-theme #image-btn {

  background: rgba(15, 23, 42, .05);
}

/* ===== SIDEBAR ===== */

.left-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(16px);
  padding: 14px 12px !important;
}

.left-sidebar .sidebar-header {
  flex-shrink: 0;
  margin-bottom: 0.5rem !important;
}

.left-sidebar .sidebar-header h4 {
  margin-bottom: 0.5rem !important;
  padding-bottom: 0.5rem !important;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
}

.left-sidebar .sidebar-header h4 svg {
  width: 16px;
  height: 16px;
}

.light-theme .left-sidebar {
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(255, 255, 255, 0.6);
}

/* ===== CHAT ITEMS ===== */

.chat-list-item {

  display: block;

  padding: 7px 10px;

  border-radius: 10px;

  text-decoration: none;

  color: inherit;

  transition: .2s ease;

  margin-bottom: 0;
}

.chat-list-item:hover {

  background: rgba(59, 130, 246, .12);

  color: var(--primary);
}

.chat-list-item.active {

  background: var(--primary);

  color: white;
}

/* ===== QUOTA ===== */

#quota-row {

  margin-top: 10px;

  display: none;

  gap: 12px;
}

#quota-row.visible {

  display: flex;
}

#quota-warn {

  font-weight: 600;
}

.msg-bot.quota-notice .bubble {

  border-color: rgba(255, 193, 7, 0.45);

  background: rgba(255, 193, 7, 0.12);

  color: #ffe08a;
}

.light-theme .msg-bot.quota-notice .bubble {

  background: rgba(255, 193, 7, 0.15);

  color: #856404;
}

.msg-bot.soft-error-notice .bubble {
  width: min(100%, 560px);
  padding: 0;
  border: 0;
  background: transparent;
}

.soft-error-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(125, 211, 252, 0.2);
  border-radius: 16px;
  color: rgba(226, 232, 240, 0.94);
  background: rgba(15, 23, 42, 0.84);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.16);
}

.light-theme .soft-error-card {
  color: rgba(15, 23, 42, 0.82);
  border-color: rgba(14, 165, 233, 0.16);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.soft-error-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.12);
}

.soft-error-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.soft-error-body strong {
  font-size: 0.92rem;
  line-height: 1.5;
}

.soft-error-body span {
  color: var(--muted-dark);
  font-size: 0.86rem;
  line-height: 1.7;
}

.light-theme .soft-error-body span {
  color: var(--muted-light);
}

.soft-toast {
  position: fixed;
  inset-inline-start: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 5000;
  min-width: min(320px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 14px;
  color: rgba(248, 250, 252, 0.94);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 18px 48px rgba(2, 6, 23, 0.26);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.soft-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.soft-toast i {
  color: #7dd3fc;
  flex: 0 0 auto;
}

.soft-toast span {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.6;
}

.light-theme .soft-toast {
  color: rgba(15, 23, 42, 0.86);
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(14, 165, 233, 0.18);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.12);
}

@media (max-width: 991px) {
  .msg-bot.soft-error-notice {
    max-width: 100%;
  }

  .msg-bot.soft-error-notice .bubble {
    width: 100%;
  }

  .soft-error-card {
    padding: 12px 13px;
    border-radius: 14px;
  }

  .soft-toast {
    bottom: calc(var(--mobile-bottom-bar) + 14px);
  }
}

/* ===== SCROLLBAR ===== */

.chat-container::-webkit-scrollbar,
.right-sidebar::-webkit-scrollbar,
.chat-list-container::-webkit-scrollbar {

  width: 6px;
}

.chat-container::-webkit-scrollbar-thumb,
.right-sidebar::-webkit-scrollbar-thumb,
.chat-list-container::-webkit-scrollbar-thumb {

  background: rgba(255, 255, 255, .1);

  border-radius: 20px;
}

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

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

/* ===== MOBILE ===== */

@media(max-width: 991px) {

  .left-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    z-index: 3500;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
    border: none;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    visibility: hidden;
    padding: 12px 10px !important;
  }

  .left-sidebar .sidebar-header h4 {
    font-size: 0.9rem;
  }

  .left-sidebar.open {
    transform: translateX(0);
    visibility: visible;
  }

  .light-theme .left-sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
  }

  .msg {

    max-width: 92%;
  }

  .chat-container {

    padding: 16px;
  }

  .chat-input-area {

    padding: 10px;
  }

  #userInput {

    min-height: 48px;
    font-size: 16px;
  }

  #send-btn,
  #image-btn {

    width: 48px;
    height: 48px;
  }

  .chat-header {
    flex-wrap: nowrap;
    padding: 6px 10px;
    gap: 6px;
    min-height: var(--navbar-height, 46px);
    height: var(--navbar-height, 46px);
  }

  .chat-header-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 0;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .light-theme .chat-header-actions {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
  }
}



.btn-new-chat-minimal {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--primary);
  color: white !important;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.btn-new-chat-minimal:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.3);
}

.btn-new-chat-minimal:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .btn-new-chat-minimal span {
    display: none;
  }
  .btn-new-chat-minimal {
    padding: 8px;
  }
}

.chat-sidebar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  position: relative;
}

.chat-list-item {
  flex: 1;
  display: block;
  padding: 7px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-list-item:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateX(3px);
}

.chat-list-item.active {
  background: var(--primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.delete-chat-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.delete-chat-btn:hover {
  background: #ef4444;
  color: white;
  transform: scale(1.1);
}

.light-theme .chat-list-item {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.light-theme .chat-list-item:hover {
  background: rgba(59, 130, 246, 0.05);
}

/* دکمه‌های هدر چت: فقط موبایل */
.chat-refresh-btn,
.mobile-menu-btn {
  display: none !important;
}

@media (max-width: 991px) {
  .chat-refresh-btn,
  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    height: 38px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
  }

  .chat-refresh-btn {
    gap: 5px;
    padding: 0 12px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
  }

  .chat-refresh-btn svg,
  .mobile-menu-btn svg {
    flex-shrink: 0;
  }

  .mobile-menu-btn {
    width: 38px;
  }

  .chat-refresh-btn:hover,
  .mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  .light-theme .chat-refresh-btn,
  .light-theme .mobile-menu-btn {
    color: var(--text-light);
  }

  .light-theme .chat-refresh-btn:hover,
  .light-theme .mobile-menu-btn:hover {
    background: rgba(15, 23, 42, 0.08);
  }
}

.btn-close-sidebar {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: 0.2s;
}

.btn-close-sidebar:hover {
  opacity: 1;
  transform: rotate(90deg);
}

.chat-list-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-inline-end: 2px;
}

.chat-list-container ul {
  margin-bottom: 0;
}

.delete-chat-btn svg {
  width: 13px;
  height: 13px;
}

.chat-date {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
}

.chat-time {
  font-size: 0.65rem;
  opacity: 0.6;
  line-height: 1.2;
}

/* ... */


.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: 0.4s;
  z-index: 3400;
}

.sidebar-backdrop.show{

  opacity:1;
  pointer-events:auto;
}

/* ===== CLEAN CHAT-FIRST EXPERIENCE ===== */

body.page-chat .main-content {
  display: flex;
  min-height: calc(100vh - var(--navbar-height));
  min-height: calc(100dvh - var(--navbar-height));
}

.chat-layout {
  width: 100%;
  background: #0b0f19;
}

.light-theme .chat-layout {
  background: #f7f7f8;
}

.chat-section {
  background: inherit;
}

.chat-header {
  height: 56px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 15, 25, 0.88);
}

.light-theme .chat-header {
  background: rgba(247, 247, 248, 0.92);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

.chat-container {
  width: 100%;
  max-width: min(1120px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 34px clamp(18px, 4vw, 48px);
  background: transparent !important;
  gap: 24px;
}

.msg {
  max-width: 100%;
}

.msg-user {
  width: fit-content;
  max-width: min(74%, 720px);
}

.msg-bot {
  align-self: flex-start;
  margin-left: auto;
  margin-right: 0;
  width: min(100%, 820px);
}

.msg-bot .bubble {
  width: 100%;
}

.msg .bubble {
  position: relative;
  border-radius: 18px;
  box-shadow: none;
  font-family: Vazirmatn, IRANSansX, IRANSans, Dana, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  letter-spacing: 0;
}

.msg-user .bubble {
  background: #0d7bf2;
  border-bottom-left-radius: 5px;
}

.msg-bot .bubble {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 2px 10px;
  color: #ececf1;
}

.light-theme .msg-user .bubble {
  background: #0d7bf2;
}

.light-theme .msg-bot .bubble {
  background: transparent;
  border-color: transparent;
}

.msg .text {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  text-wrap: pretty;
  font-size: 1rem;
  line-height: 1.85;
  font-weight: 420;
}

.msg .text p {
  margin: 0 0 13px;
}

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

.msg .text ul,
.msg .text ol {
  margin: 0 0 13px;
  padding-right: 28px;
}

.msg .text li {
  margin-bottom: 7px;
}

.msg .text a {
  color: #7db4ff;
  text-underline-offset: 3px;
}

.msg .text code,
.msg .text pre {
  direction: ltr;
  text-align: left;
  font-family: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, "Liberation Mono", monospace;
}

.msg .text code {
  unicode-bidi: isolate;
}

.msg .text pre {
  position: relative;
  margin: 12px 0;
  padding: 42px 14px 14px;
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.72);
  color: #e5e7eb;
  line-height: 1.75;
}

.light-theme .msg .text pre {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(241, 245, 249, 0.92);
  color: #0f172a;
}

.msg .text :not(pre) > code {
  padding: 2px 6px;
  border-radius: 7px;
  background: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
  font-size: 0.88em;
}

.light-theme .msg .text :not(pre) > code {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

.message-copy-btn,
.code-copy-btn {
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: rgba(226, 232, 240, 0.86);
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.light-theme .message-copy-btn,
.light-theme .code-copy-btn {
  color: rgba(15, 23, 42, 0.76);
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(15, 23, 42, 0.12);
}

.message-actions {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  margin-top: 5px;
  padding-inline: 2px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.msg-user .message-actions {
  direction: rtl;
  justify-content: flex-start;
  margin-top: 3px;
  padding-inline: 0 2px;
}

.msg-bot .message-actions {
  justify-content: flex-start;
}

.message-copy-btn {
  min-width: 0;
  min-height: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.message-copy-btn i {
  font-size: 0.92rem;
  line-height: 1;
}

.message-copy-btn span {
  line-height: 1;
}

.msg-user .message-copy-btn {
  width: 29px;
  min-width: 29px;
  padding: 0;
  color: rgba(226, 232, 240, 0.78);
  background: rgba(15, 23, 42, 0.34);
  border-color: rgba(148, 163, 184, 0.14);
}

.msg-user .message-copy-btn span {
  display: none;
}

.light-theme .msg-user .message-copy-btn {
  color: rgba(15, 23, 42, 0.62);
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(15, 23, 42, 0.09);
}

.msg:hover .message-actions,
.msg:focus-within .message-actions {
  opacity: 1;
  transform: translateY(0);
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0.9;
}

.message-copy-btn:hover,
.code-copy-btn:hover {
  opacity: 1;
  border-color: rgba(96, 165, 250, 0.44);
  background: rgba(30, 41, 59, 0.94);
}

.light-theme .message-copy-btn:hover,
.light-theme .code-copy-btn:hover {
  background: rgba(248, 250, 252, 0.96);
}

.message-copy-btn.copied,
.code-copy-btn.copied {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.38);
}

.message-copy-btn.copy-failed,
.code-copy-btn.copy-failed {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.38);
}

.chat-input-area {
  padding: 14px 18px 18px;
  background: linear-gradient(180deg, rgba(11, 15, 25, 0), #0b0f19 24%);
  border-top: 0;
}

.light-theme .chat-input-area {
  background: linear-gradient(180deg, rgba(247, 247, 248, 0), #f7f7f8 24%);
  border-top: 0;
}

#chatForm {
  max-width: min(1120px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: #111827;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.light-theme #chatForm {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

#userInput,
.light-theme #userInput {
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 12px;
  background: transparent;
}

#send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.chat-refresh-btn,
.mobile-menu-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  cursor: pointer;
}

.light-theme .chat-refresh-btn,
.light-theme .mobile-menu-btn {
  border-color: rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.04);
}

.left-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: min(320px, 88vw);
  height: 100vh;
  height: 100dvh;
  z-index: 3500;
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s ease;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 18px 0 40px rgba(0, 0, 0, 0.28);
}

.left-sidebar.open {
  transform: translateX(0);
  visibility: visible;
}

.light-theme .left-sidebar {
  background: rgba(255, 255, 255, 0.98);
  border-right-color: rgba(15, 23, 42, 0.08);
}

.chat-empty-state {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--text-dark);
  padding: 24px 16px;
}

.light-theme .chat-empty-state {
  color: var(--text-light);
}

.chat-empty-logo {
  width: 76px;
  height: 76px;
  border-radius: 26px;
  display: grid;
  place-items: center;
  padding: 7px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.2), transparent 56%),
    linear-gradient(145deg, rgba(56, 189, 248, 0.22), rgba(59, 130, 246, 0.12)),
    rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    0 18px 44px rgba(37, 99, 235, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.light-theme .chat-empty-logo {
  background:
    linear-gradient(145deg, rgba(14, 165, 233, 0.12), rgba(37, 99, 235, 0.08)),
    rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.chat-empty-logo img {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  object-fit: contain;
  object-position: center;
}

.chat-empty-state h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
}

.chat-empty-state p {
  max-width: 520px;
  margin: 0;
  color: var(--muted-dark);
  line-height: 1.9;
}

.light-theme .chat-empty-state p {
  color: var(--muted-light);
}

.msg-bot.signup-notice .bubble {
  width: min(100%, 680px);
  padding: 0;
  border: 0;
  background: transparent;
}

.signup-required-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 20px;
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.2), transparent 34%),
    linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.94));
  box-shadow: 0 22px 60px rgba(2, 6, 23, 0.28);
}

.signup-required-card::before {
  content: "";
  position: absolute;
  inset-inline: 20px;
  top: 0;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
}

.light-theme .signup-required-card {
  border-color: rgba(14, 165, 233, 0.22);
  background:
    radial-gradient(circle at 0 0, rgba(14, 165, 233, 0.12), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
}

.signup-required-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.signup-required-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #e0f2fe;
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(125, 211, 252, 0.24);
}

.signup-required-icon i {
  font-size: 1.15rem;
}

.light-theme .signup-required-icon {
  color: #0284c7;
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.18);
}

.signup-required-body {
  min-width: 0;
}

.signup-required-kicker {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: #bae6fd;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
}

.light-theme .signup-required-kicker {
  color: #0369a1;
  background: rgba(14, 165, 233, 0.08);
  border-color: rgba(14, 165, 233, 0.12);
}

.signup-required-card h2 {
  margin: 0;
  color: var(--text-dark);
  font-size: 1.22rem;
  font-weight: 850;
  line-height: 1.45;
}

.light-theme .signup-required-card h2 {
  color: var(--text-light);
}

.signup-required-card p {
  max-width: 54ch;
  margin: 8px 0 0;
  color: var(--muted-dark);
  font-size: 0.95rem;
  line-height: 1.85;
}

.light-theme .signup-required-card p {
  color: var(--muted-light);
}

.signup-required-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.signup-required-perks span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  color: rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 700;
}

.signup-required-perks i {
  color: #67e8f9;
}

.light-theme .signup-required-perks span {
  color: rgba(15, 23, 42, 0.72);
  background: rgba(15, 23, 42, 0.035);
  border-color: rgba(15, 23, 42, 0.07);
}

.light-theme .signup-required-perks i {
  color: #0891b2;
}

.signup-required-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.signup-required-actions a {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  box-shadow: none;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.signup-required-actions a:hover {
  transform: translateY(-1px);
}

.signup-required-primary {
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border: 1px solid rgba(125, 211, 252, 0.36);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.26);
}

.signup-required-primary:hover {
  color: #fff;
  background: linear-gradient(135deg, #0284c7, #1d4ed8);
  border-color: rgba(186, 230, 253, 0.48);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.32);
}

.signup-required-secondary {
  color: #e0f2fe;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(226, 232, 240, 0.14);
}

.signup-required-secondary:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(147, 197, 253, 0.36);
}

.light-theme .signup-required-secondary {
  color: #075985;
  background: rgba(14, 165, 233, 0.07);
  border-color: rgba(14, 165, 233, 0.16);
}

.light-theme .signup-required-secondary:hover {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.1);
}

#quota-row {
  max-width: min(1120px, calc(100vw - 48px));
  margin: 8px auto 0;
}

@media (min-width: 1280px) {
  .msg-user {
    max-width: min(68%, 760px);
  }

  .msg-bot {
    width: min(100%, 860px);
    max-width: min(82%, 860px);
  }
}

@media (max-width: 991px) {
  body.page-chat .main-content {
    min-height: calc(100vh - var(--navbar-height, 46px));
    min-height: calc(100dvh - var(--navbar-height, 46px));
  }

  .chat-container {
    padding: 18px 14px;
    gap: 14px;
  }

  .msg {
    max-width: 92%;
  }

  .msg-bot.signup-notice {
    max-width: 100%;
  }

  .msg-bot.signup-notice .bubble {
    width: 100%;
  }

  .signup-required-card {
    gap: 12px;
    padding: 16px;
    border-radius: 16px;
  }

  .signup-required-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .signup-required-card h2 {
    font-size: 1.06rem;
  }

  .signup-required-card p {
    font-size: 0.88rem;
  }

  .signup-required-perks {
    gap: 6px;
  }

  .signup-required-perks span {
    font-size: 0.72rem;
    padding-inline: 8px;
  }

  .signup-required-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .signup-required-actions a {
    min-width: 0;
    padding-inline: 10px;
    min-height: 44px;
  }

  .chat-input-area {
    padding: 10px 10px calc(10px + var(--safe-bottom));
  }

  #chatForm {
    border-radius: 16px;
  }
}

/* ===== CHAT WITH SITE FOOTER ===== */

body.page-chat {
  height: 100dvh !important;
  min-height: 100dvh;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

body.page-chat .app-wrapper {
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 0;
  overflow: hidden !important;
}

body.page-chat .main-content {
  flex: 1 1 auto;
  display: flex;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.page-chat .chat-layout {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

body.page-chat .site-footer {
  flex-shrink: 0;
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  min-height: 60px !important;
  margin-top: 0;
  padding: 7px max(18px, var(--safe-left)) 7px max(18px, var(--safe-right));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.light-theme.page-chat .site-footer {
  border-top-color: rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.94);
}

body.page-chat .footer-social-link {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

body.page-chat .footer-copy {
  color: rgba(248, 250, 252, 0.9);
  font-size: 0.78rem;
}

body.page-chat .footer-brand-link {
  color: #fb923c;
}

body.light-theme.page-chat .footer-copy {
  color: rgba(15, 23, 42, 0.76);
}

body.light-theme.page-chat .footer-social-link {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.12);
}

body.page-chat .footer-enamad img {
  max-height: 44px;
  max-width: 68px;
  opacity: 1;
}

@media (max-width: 991px) {
  body.page-chat .main-content {
    padding-bottom: 0 !important;
  }

  body.page-chat .chat-layout {
    height: auto;
    min-height: 0;
  }

  body.page-chat .site-footer {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    justify-items: center;
    gap: 6px;
    min-height: 0 !important;
    padding: 8px max(12px, var(--safe-left)) calc(var(--mobile-bottom-bar) + 8px) max(12px, var(--safe-right)) !important;
    text-align: center;
  }

  body.page-chat .footer-copy,
  body.page-chat .footer-socials,
  body.page-chat .footer-enamad {
    justify-self: center;
  }

  body.page-chat .footer-copy {
    font-size: 0.68rem;
  }

  body.page-chat .footer-socials {
    gap: 6px;
  }

  body.page-chat .footer-social-link {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

body.page-chat .footer-enamad img {
    max-height: 38px;
    max-width: 58px;
  }
}

/* ===== POLISHED CHATGPT-LIKE COMPOSER ===== */

body.page-chat .chat-input-area {
  padding: 10px 18px 12px !important;
  border: 0 !important;
  background:
    linear-gradient(180deg, rgba(11, 15, 25, 0), rgba(11, 15, 25, 0.96) 42%);
  box-shadow: none !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.light-theme.page-chat .chat-input-area {
  background:
    linear-gradient(180deg, rgba(247, 247, 248, 0), rgba(247, 247, 248, 0.98) 42%) !important;
}

body.page-chat #chatForm {
  position: relative;
  width: min(100%, 640px);
  max-width: calc(100vw - 72px);
  min-height: 44px;
  margin: 0 auto;
  padding: 5px 5px 5px 10px;
  gap: 7px;
  align-items: flex-end !important;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 22px;
  background: rgba(17, 24, 39, 0.96);
  box-shadow:
    0 18px 44px rgba(2, 6, 23, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

body.page-chat #chatForm:focus-within {
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow:
    0 18px 46px rgba(2, 6, 23, 0.3),
    0 0 0 3px rgba(59, 130, 246, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

body.light-theme.page-chat #chatForm {
  border-color: rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 16px 34px rgba(15, 23, 42, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

body.light-theme.page-chat #chatForm:focus-within {
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow:
    0 16px 36px rgba(15, 23, 42, 0.1),
    0 0 0 3px rgba(37, 99, 235, 0.1);
}

body.page-chat #userInput,
body.light-theme.page-chat #userInput {
  min-height: 34px;
  max-height: 132px;
  padding: 6px 4px 5px 8px;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  color: var(--text-dark);
  font-size: 0.9rem;
  line-height: 1.65;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body.page-chat #userInput::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body.light-theme.page-chat #userInput {
  color: var(--text-light);
}

body.page-chat #userInput::placeholder {
  color: rgba(203, 213, 225, 0.56);
}

body.light-theme.page-chat #userInput::placeholder {
  color: rgba(71, 85, 105, 0.52);
}

body.page-chat #send-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  margin: 0;
  border-radius: 999px;
  color: #020617;
  background: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.22);
  font-size: 1.08rem;
}

body.page-chat #send-btn i {
  display: block;
  line-height: 1;
  transform: translateY(-1px);
  text-shadow: 0 0 0 currentColor, 0 1px 2px rgba(2, 6, 23, 0.2);
}

body.page-chat #send-btn:hover {
  color: #fff;
  background: var(--primary);
  border-color: rgba(147, 197, 253, 0.5);
  transform: translateY(-1px);
}

body.page-chat #send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

body.light-theme.page-chat #send-btn {
  color: #fff;
  background: #0f172a;
  border-color: rgba(15, 23, 42, 0.16);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

body.light-theme.page-chat #send-btn i {
  text-shadow: 0 0 0 currentColor, 0 1px 2px rgba(255, 255, 255, 0.18);
}

body.light-theme.page-chat #send-btn:hover {
  background: var(--primary);
  border-color: rgba(37, 99, 235, 0.35);
}

body.page-chat #quota-row {
  width: min(100%, 640px);
  max-width: calc(100vw - 72px);
  margin: 6px auto 0;
  padding: 0 12px;
}

@media (max-width: 991px) {
  :root {
    --mobile-bottom-bar: calc(42px + 8px + var(--safe-bottom));
  }

  body.page-chat .site-footer {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
  }

  body.page-chat .main-content {
    flex: 1 1 auto;
    padding-bottom: 0 !important;
  }

  body.page-chat .chat-input-area {
    margin: 0 !important;
    padding: 8px 10px calc(var(--mobile-bottom-bar) + 6px) !important;
    border-radius: 0 !important;
    position: relative;
    z-index: 2;
  }

  body.page-chat .chat-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding-inline: 8px !important;
  }

  body.page-chat .chat-header-start {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
  }

  body.page-chat .chat-header-start .nak-ad,
  body.page-chat .chat-header-start [class*="ad"] {
    display: none !important;
  }

  body.page-chat .btn-new-chat-minimal {
    flex: 0 0 auto;
    min-height: 32px !important;
    height: 32px;
    max-width: 108px;
    padding: 0 10px !important;
    gap: 5px !important;
    border-radius: 11px !important;
    font-size: 0.76rem !important;
    white-space: nowrap;
    overflow: hidden;
  }

  body.page-chat .btn-new-chat-minimal svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }

  .message-actions {
    opacity: 1;
    transform: none;
    margin-top: 4px;
  }

  .message-copy-btn {
    min-height: 27px;
    height: 27px;
    padding-inline: 8px;
    font-size: 0.7rem;
  }

  .code-copy-btn {
    opacity: 0.86;
  }

  body.page-chat #chatForm {
    max-width: calc(100vw - 28px);
    min-height: 44px;
    padding: 5px 5px 5px 9px;
    border-radius: 20px;
  }

  body.page-chat #userInput,
  body.light-theme.page-chat #userInput {
    min-height: 34px;
    padding-top: 5px;
    padding-bottom: 5px;
    font-size: 16px;
  }

  body.page-chat #send-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 1.06rem;
  }

  body.page-chat #quota-row {
    max-width: 100%;
    padding-inline: 10px;
  }
}

@media (max-width: 991px) {
  .mobile-bottom-nav {
    height: 42px !important;
    left: calc(14px + var(--safe-left)) !important;
    right: calc(14px + var(--safe-right)) !important;
    bottom: calc(8px + var(--safe-bottom)) !important;
    padding: 0 5px !important;
    border-radius: 15px !important;
    gap: 2px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28) !important;
  }

  .mobile-nav-link {
    min-width: 0;
    min-height: 36px !important;
    height: 36px !important;
    gap: 1px !important;
    padding: 0 3px !important;
    border-radius: 11px !important;
    font-size: 0.56rem !important;
    line-height: 1.1;
  }

  .mobile-nav-link i,
  #mobileThemeEmoji {
    font-size: 1.02rem !important;
    line-height: 1;
  }

  .mobile-nav-link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bottom-nav .profile-block,
  .mobile-bottom-nav a[href*="change_password"] {
    display: none !important;
  }

  .mobile-bottom-nav form {
    flex: 1 1 0 !important;
    min-width: 0;
  }
}

body.page-chat.has-chat-messages .site-footer,
html.pwa-standalone body.page-chat .site-footer {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}

@media (display-mode: standalone) {
  body.page-chat .site-footer {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
  }
}

/* ===== STABLE CHAT HEADER ACTIONS ===== */

body.page-chat .chat-header-actions {
  flex: 0 0 auto;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  height: 34px;
  padding: 2px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.light-theme.page-chat .chat-header-actions {
  background: rgba(15, 23, 42, 0.045);
  border-color: rgba(15, 23, 42, 0.08);
}

body.page-chat .chat-refresh-btn,
body.page-chat .mobile-menu-btn {
  flex: 0 0 30px !important;
  width: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  display: inline-grid !important;
  place-items: center;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: inherit;
  line-height: 1 !important;
  overflow: hidden;
}

body.page-chat .chat-refresh-btn span {
  display: none !important;
}

body.page-chat .chat-refresh-btn svg,
body.page-chat .mobile-menu-btn svg {
  width: 17px !important;
  height: 17px !important;
  display: block;
  flex: 0 0 auto;
  margin: 0 !important;
}

body.page-chat .mobile-menu-btn svg {
  width: 19px !important;
  height: 19px !important;
}

body.page-chat .chat-refresh-btn:hover,
body.page-chat .mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

body.light-theme.page-chat .chat-refresh-btn:hover,
body.light-theme.page-chat .mobile-menu-btn:hover {
  background: rgba(15, 23, 42, 0.08) !important;
}

@media (max-width: 360px) {
  body.page-chat .chat-header-actions {
    gap: 2px;
  }

  body.page-chat .chat-refresh-btn,
  body.page-chat .mobile-menu-btn {
    flex-basis: 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
  }
}

/* ===== MOBILE NEW CHAT ACTION ===== */

@media (max-width: 991px) {
  body.page-chat .btn-new-chat-minimal {
    flex: 0 1 auto;
    height: 32px !important;
    min-height: 32px !important;
    max-width: 122px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px !important;
    padding: 0 10px 0 8px !important;
    border-radius: 999px !important;
    color: #eff6ff !important;
    background:
      linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(14, 165, 233, 0.92));
    border: 1px solid rgba(191, 219, 254, 0.28);
    box-shadow:
      0 8px 20px rgba(37, 99, 235, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.16);
    font-size: 0.74rem !important;
    font-weight: 850;
    line-height: 1;
    white-space: nowrap;
  }

  body.page-chat .btn-new-chat-minimal svg {
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
  }

  body.page-chat .btn-new-chat-minimal span {
    display: inline-block !important;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.page-chat .btn-new-chat-minimal:hover {
    background:
      linear-gradient(135deg, rgba(37, 99, 235, 1), rgba(2, 132, 199, 0.98));
    transform: translateY(-1px);
  }

  body.page-chat .btn-new-chat-minimal:active {
    transform: scale(0.97);
  }

  body.light-theme.page-chat .btn-new-chat-minimal {
    color: #fff !important;
    border-color: rgba(37, 99, 235, 0.18);
    box-shadow:
      0 8px 18px rgba(37, 99, 235, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

@media (max-width: 380px) {
  body.page-chat .btn-new-chat-minimal {
    max-width: 36px;
    width: 36px;
    padding: 0 !important;
  }

  body.page-chat .btn-new-chat-minimal span {
    display: none !important;
  }
}

/* ===== MOBILE TOP APP BAR OVERRIDES ===== */

@media (max-width: 991px) {
  :root {
    --mobile-bottom-bar: var(--safe-bottom);
  }

  body.page-chat {
    height: 100dvh !important;
    min-height: 100dvh !important;
  }

  body.page-chat .app-wrapper {
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  body.page-chat .chat-layout,
  body.page-chat .chat-section {
    min-height: 0 !important;
  }

  .mobile-bottom-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.page-chat .chat-header {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
  }

  body.page-chat .chat-input-area {
    padding: 6px 10px 6px !important;
  }

  body.page-chat.mobile-keyboard-open .chat-input-area {
    padding-bottom: 6px !important;
  }

  html.pwa-standalone body.page-chat:not(.mobile-keyboard-open) .chat-input-area {
    padding-bottom: calc(6px + var(--safe-bottom)) !important;
  }

  body.page-chat .mobile-top-actions {
    height: 36px;
    gap: 4px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 17px;
    background: rgba(15, 23, 42, 0.72);
  }

  body.light-theme.page-chat .mobile-top-actions {
    border-color: rgba(15, 23, 42, 0.1);
    background: rgba(248, 250, 252, 0.92);
    box-shadow:
      0 10px 26px rgba(15, 23, 42, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.78);
  }

  body.light-theme.page-chat .mobile-top-link,
  body.light-theme.page-chat .mobile-top-icon,
  body.light-theme.page-chat .mobile-main-tab,
  body.light-theme.page-chat .mobile-chat-tool,
  body.light-theme.page-chat .mobile-theme-action {
    color: #0f172a;
    background: transparent;
  }

  body.page-chat .mobile-main-tab {
    min-width: 28px;
    width: auto;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    border-radius: 13px;
  }

  body.page-chat .mobile-main-tab span {
    display: none;
    font-size: 0.68rem;
    font-weight: 850;
  }

  body.page-chat .mobile-main-tab.active {
    min-width: 52px;
    padding-inline: 8px;
  }

  body.page-chat .mobile-main-tab.active span {
    display: inline;
  }

  body.light-theme.page-chat .mobile-main-tab.active {
    color: #0f172a;
    background: rgba(37, 99, 235, 0.12);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.14);
  }

  body.page-chat .mobile-blog-tab i {
    font-size: 1rem;
    transform: translateY(-0.5px) scaleX(1.06);
  }

  body.page-chat .mobile-chat-new {
    min-width: 64px;
    height: 30px;
    padding-inline: 8px;
    border-radius: 13px;
    font-size: 0.68rem;
  }

  body.page-chat .mobile-chat-tool,
  body.page-chat .mobile-theme-action {
    width: 30px;
    min-width: 30px;
    height: 30px;
    border-radius: 13px;
  }

  body.page-chat .mobile-account-action,
  body.page-chat .mobile-top-form {
    display: none !important;
  }
}
