/**
 * Chatvora — ChatGPT-style homepage chat (scoped .sr-page-home, .sr-chatgpt).
 * Full viewport column: fixed nav, scrollable thread, pinned composer.
 */

/* ---------- Lock document scroll on homepage ---------- */

html.sr-page-home-html {
  overflow-x: clip;
  max-width: 100%;
}

html.sr-page-home-html,
html.sr-page-home-html body.sr-page-home {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

html.sr-page-home-html body.sr-page-home {
  overflow-x: clip;
  max-width: 100%;
}

.sr-page-home {
  --sr-nav-h: 56px;
}

/* Fixed navbar on homepage (overrides template sticky) */
.sr-page-home .navbar-area {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background-color: var(--DarkBg);
  border-bottom: 1px solid #1a243d;
}

/* ---------- App shell: sidebar + main ---------- */

.sr-chatgpt {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  height: calc(100dvh - var(--sr-nav-h));
  max-height: calc(100dvh - var(--sr-nav-h));
  margin-top: var(--sr-nav-h);
  padding-top: 0;
  box-sizing: border-box;
  background: var(--DarkBg, #05051e);
  overflow: hidden;
}

/* Never show template “short-prompt” link rows inside the chat shell */
.sr-chatgpt .short-prompt,
.sr-chatgpt__main .short-prompt {
  display: none !important;
}

/* Homepage mobile: logo left, hamburger right — hide search + account icons */
@media (max-width: 767.98px) {
  body.sr-page-home .navbar-area .other-all-option > .other-option.d-lg-none {
    display: none !important;
  }

  body.sr-page-home .navbar-area .navbar {
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  body.sr-page-home .navbar-area .other-all-option {
    margin-left: auto;
    flex-shrink: 0;
  }

  body.sr-page-home .navbar-area .navbar-brand:not(.sr-nav-brand-logo) {
    margin-right: 0.5rem;
    max-width: calc(100% - 3.5rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.sr-page-home .navbar-area .navbar-brand.sr-nav-brand-logo {
    margin-right: 0.5rem;
    max-width: calc(100% - 3.5rem);
    overflow: visible;
    align-items: center;
  }

  body.sr-page-home .navbar-area .navbar-brand.sr-nav-brand-logo .sr-nav-logo-img {
    max-width: 100%;
  }

  body.sr-page-home .navbar-area .container {
    max-width: 100%;
  }
}

/* Chat sidebar: mobile = overlay below navbar; desktop = fixed column */
@media (max-width: 767.98px) {
  body.sr-page-home .sr-chatgpt__sidebar.offcanvas {
    --bs-offcanvas-width: min(260px, 92vw);
    top: var(--sr-nav-h) !important;
    bottom: 0;
    height: calc(100dvh - var(--sr-nav-h)) !important;
    max-height: calc(100dvh - var(--sr-nav-h)) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 10, 20, 0.98) !important;
    color: #fff;
  }

  body.sr-page-home .offcanvas-backdrop {
    top: var(--sr-nav-h);
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    z-index: 1015;
  }
}

@media (min-width: 768px) {
  .sr-chatgpt > .sr-chatgpt__sidebar.offcanvas-md {
    position: fixed !important;
    left: 0;
    top: var(--sr-nav-h) !important;
    bottom: 0;
    transform: none !important;
    visibility: visible !important;
    z-index: 990;
    flex: 0 0 0;
    min-width: 0;
    width: 260px;
    max-width: 260px;
    height: calc(100dvh - var(--sr-nav-h)) !important;
    max-height: calc(100dvh - var(--sr-nav-h)) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    overflow: visible;
  }

  .sr-chatgpt__sidebar.offcanvas-md .sr-chatgpt__sidebar-offcanvas-header {
    display: none !important;
  }

  /* Logged-in chat: main panel clears fixed sidebar (sidebar is out of flex flow) */
  .sr-chatgpt--logged-in > .sr-chatgpt__main {
    margin-left: 260px;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    flex: 1 1 auto;
  }
}

@media (max-width: 767.98px) {
  .sr-chatgpt--logged-in > .sr-chatgpt__main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ---------- Sidebar (logged-in only; offcanvas-md + desktop column) ---------- */

.sr-chatgpt__sidebar {
  flex: 0 0 260px;
  width: 260px;
  background: rgba(8, 10, 20, 0.96);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 1028;
}

.sr-chatgpt__sidebar-offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.85rem 1rem;
}

.sr-chatgpt__sidebar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.sr-chatgpt__offcanvas-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 !important;
  overflow: hidden;
}

.sr-chatgpt__sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 16px 0.65rem 0.85rem;
  box-sizing: border-box;
}

.sr-chatgpt__new-chat {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sr-chatgpt__new-chat:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.sr-chatgpt__conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-top: 0.85rem;
  padding: 0.25rem 0;
}

.sr-chatgpt__conv-placeholder {
  margin: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.42);
  line-height: 1.45;
}

/* Sidebar conversation rows (persisted chats) */
.sr-sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.45rem 0.2rem;
  margin-top: 0.35rem;
}

.sr-sidebar-section-label:first-child {
  margin-top: 0;
}

.sr-conv-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 0.45rem;
  row-gap: 0.15rem;
  padding: 0.55rem 0.45rem;
  margin-bottom: 0.25rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.25s ease, transform 0.25s ease;
}

.sr-conv-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sr-conv-item.active,
.sr-conv-item.is-active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
}

.sr-conv-item-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 0.95rem;
  line-height: 1;
  width: 1.35rem;
  text-align: center;
  flex-shrink: 0;
  user-select: none;
}

.sr-conv-title {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-conv-time {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.42);
}

.sr-conv-item-actions {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.1rem;
}

.sr-conv-pin {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(245, 158, 11, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.sr-conv-delete {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.sr-conv-item:hover .sr-conv-pin,
.sr-conv-item:hover .sr-conv-delete {
  opacity: 1;
  color: rgba(255, 255, 255, 0.7);
}

.sr-conv-item:hover .sr-conv-pin {
  color: rgba(245, 158, 11, 0.95);
}

.sr-conv-pin:hover {
  color: #fcd34d !important;
  background: rgba(245, 158, 11, 0.12);
}

.sr-conv-delete:hover {
  color: #fecaca !important;
  background: rgba(248, 113, 113, 0.15);
}

.sr-conv-item--out {
  opacity: 0;
  transform: translateX(-6px);
}

.sr-chatgpt__sidebar-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.35rem 0.25rem;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.sr-chatgpt__avatar-circle {
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(124, 58, 237, 0.6));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  line-height: 1;
}

.sr-chatgpt__user-meta {
  min-width: 0;
}

.sr-chatgpt__user-email {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  word-break: break-all;
  line-height: 1.35;
}

.sr-chatgpt__sidebar-link {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
}

.sr-chatgpt__sidebar-link:hover {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sr-chatgpt__sidebar-link--dashboard {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
}

.sr-chatgpt__conv-row {
  display: flex;
  align-items: stretch;
  gap: 0.1rem;
  border-radius: 10px;
  margin-bottom: 0.15rem;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sr-chatgpt__conv-row.is-active {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.35);
}

.sr-chatgpt__conv-item {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.5rem 0.45rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  text-align: left;
  cursor: pointer;
  font-size: 0.84rem;
  line-height: 1.25;
}

.sr-chatgpt__conv-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sr-chatgpt__conv-row.is-active .sr-chatgpt__conv-item:hover {
  background: transparent;
}

.sr-chatgpt__conv-item-title {
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.sr-chatgpt__conv-item-time {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
}

.sr-chatgpt__conv-delete {
  flex: 0 0 auto;
  align-self: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-right: 0.15rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sr-chatgpt__conv-delete i {
  font-size: 1rem;
}

.sr-chatgpt__conv-row:hover .sr-chatgpt__conv-delete,
.sr-chatgpt__conv-row:focus-within .sr-chatgpt__conv-delete {
  opacity: 1;
}

.sr-chatgpt__conv-delete:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
}

.sr-chat__mobile-sidebar-toggle {
  position: absolute;
  top: 0.35rem;
  left: 0.45rem;
  z-index: 6;
  width: 2.4rem;
  height: 2.4rem;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 14, 24, 0.94);
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sr-chat__mobile-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.sr-chat__mobile-sidebar-toggle i {
  font-size: 1.35rem;
  line-height: 1;
}

@media (max-width: 767.98px) {
  .sr-chat__mobile-sidebar-toggle {
    display: flex;
  }

  .sr-chatgpt__main--logged-in .sr-chat__shell {
    padding-top: 2.75rem;
  }
}

/* ---------- Main chat column ---------- */

.sr-chatgpt__main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: clip;
}

.sr-chatgpt__main .sr-chat__shell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  padding: 0;
  background: transparent;
  border: none;
  max-height: none;
  overflow-x: clip;
}

.sr-chatgpt__main .sr-chat__alert {
  flex: 0 0 auto;
  margin: 0.5rem 0.75rem 0;
}

.sr-chatgpt__main .sr-chat__thread {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  margin: 0 0.5rem 0.35rem;
  border-radius: 0;
  border-left: none;
  border-right: none;
  background: rgba(6, 8, 14, 0.35);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sr-chatgpt__main .sr-chat__composer-wrap {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.5rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent 0%, rgba(5, 5, 20, 0.65) 40%);
}

/* ---------- Core chat tokens (.sr-chat) ---------- */

.sr-chat {
  color-scheme: dark;
  --sr-chat-bg: rgba(6, 8, 14, 0.78);
  --sr-chat-border: rgba(255, 255, 255, 0.09);
  --sr-chat-user-bg: linear-gradient(135deg, rgba(14, 114, 222, 0.42), rgba(37, 99, 235, 0.52));
  --sr-chat-user-border: rgba(96, 165, 250, 0.45);
  --sr-chat-assistant-bg: rgba(255, 255, 255, 0.06);
  --sr-chat-assistant-border: rgba(255, 255, 255, 0.12);
  --sr-chat-text: rgba(255, 255, 255, 0.94);
  --sr-chat-muted: rgba(255, 255, 255, 0.48);
  --sr-chat-radius: 14px;
  --sr-chat-max-bubble: min(82%, 44rem);
}

.sr-chat__shell {
  border-radius: 16px;
  padding: 0.35rem 0.15rem 0.5rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.sr-chat__alert {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: rgba(180, 83, 9, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.22);
  font-size: 0.88rem;
}

.sr-chat__thread {
  max-height: min(48vh, 480px);
  min-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.85rem 1.1rem;
  margin: 0 0.35rem 0.65rem;
  border-radius: var(--sr-chat-radius);
  background: var(--sr-chat-bg);
  border: 1px solid var(--sr-chat-border);
  scroll-behavior: smooth;
}

.sr-chat__thread:focus {
  outline: 2px solid rgba(59, 130, 246, 0.4);
  outline-offset: 1px;
}

.sr-chat__empty {
  margin: 0;
  padding: min(18vh, 7rem) 1rem 2rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.38);
}

.sr-chat__empty[hidden] {
  display: none !important;
}

.sr-chat__msg {
  display: flex;
  width: 100%;
  margin-bottom: 0.65rem;
}

.sr-chat__msg:last-child {
  margin-bottom: 0.2rem;
}

.sr-chat__msg--user {
  justify-content: flex-end;
}

.sr-chat__msg--assistant {
  justify-content: flex-start;
}

.sr-chat__msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  max-width: var(--sr-chat-max-bubble);
}

.sr-chat__msg-col--assistant,
.sr-chat__assistant-col.sr-chat__msg-col--assistant {
  align-items: flex-start;
}

.sr-chat__msg-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.38);
  line-height: 1.2;
  padding: 0 0.35rem;
}

.sr-chat__md {
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}

/* Assistant markdown (marked.js + DOMPurify) — .sr-bubble--assistant alias on bubble */
.sr-chat__bubble--assistant .sr-chat__md,
.sr-bubble--assistant .sr-chat__md {
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.95);
}

.sr-chat__bubble--assistant .sr-chat__md p,
.sr-bubble--assistant .sr-chat__md p {
  margin: 0 0 8px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.95);
}

.sr-chat__bubble--assistant .sr-chat__md p:last-child,
.sr-bubble--assistant .sr-chat__md p:last-child {
  margin-bottom: 0;
}

.sr-chat__bubble--assistant .sr-chat__md h1,
.sr-bubble--assistant .sr-chat__md h1 {
  font-size: 1.35rem;
}

.sr-chat__bubble--assistant .sr-chat__md h2,
.sr-bubble--assistant .sr-chat__md h2 {
  font-size: 1.2rem;
}

.sr-chat__bubble--assistant .sr-chat__md h3,
.sr-bubble--assistant .sr-chat__md h3 {
  font-size: 1.05rem;
}

.sr-chat__bubble--assistant .sr-chat__md h1,
.sr-chat__bubble--assistant .sr-chat__md h2,
.sr-chat__bubble--assistant .sr-chat__md h3,
.sr-bubble--assistant .sr-chat__md h1,
.sr-bubble--assistant .sr-chat__md h2,
.sr-bubble--assistant .sr-chat__md h3 {
  color: #fff;
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
  line-height: 1.35;
}

.sr-chat__bubble--assistant .sr-chat__md h1:first-child,
.sr-chat__bubble--assistant .sr-chat__md h2:first-child,
.sr-chat__bubble--assistant .sr-chat__md h3:first-child,
.sr-bubble--assistant .sr-chat__md h1:first-child,
.sr-bubble--assistant .sr-chat__md h2:first-child,
.sr-bubble--assistant .sr-chat__md h3:first-child {
  margin-top: 0;
}

.sr-chat__bubble--assistant .sr-chat__md ul,
.sr-chat__bubble--assistant .sr-chat__md ol,
.sr-bubble--assistant .sr-chat__md ul,
.sr-bubble--assistant .sr-chat__md ol {
  margin: 0.35rem 0 0.65rem;
  padding-left: 1.5rem;
  color: #fff;
}

.sr-chat__bubble--assistant .sr-chat__md li,
.sr-bubble--assistant .sr-chat__md li {
  margin-bottom: 0.25rem;
}

.sr-chat__bubble--assistant .sr-chat__md strong,
.sr-bubble--assistant .sr-chat__md strong {
  color: #fff;
  font-weight: 700;
}

.sr-chat__bubble--assistant .sr-chat__md a,
.sr-bubble--assistant .sr-chat__md a {
  color: #60a5fa;
  text-decoration: none;
}

.sr-chat__bubble--assistant .sr-chat__md a:hover,
.sr-bubble--assistant .sr-chat__md a:hover {
  text-decoration: underline;
}

.sr-chat__bubble--assistant .sr-chat__md pre,
.sr-bubble--assistant .sr-chat__md pre {
  margin: 0.5rem 0;
  padding: 12px;
  border-radius: 8px;
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
  max-width: 100%;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.sr-chat__bubble--assistant .sr-chat__md pre code,
.sr-bubble--assistant .sr-chat__md pre code {
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #fff;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  white-space: pre;
  display: block;
}

.sr-chat__bubble--assistant .sr-chat__md :not(pre) > code,
.sr-bubble--assistant .sr-chat__md :not(pre) > code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.9em;
  color: rgba(255, 255, 255, 0.95);
}

/* Legacy class if marked wraps inline code without parent selector match */
.sr-chat__bubble--assistant .sr-chat__md p code,
.sr-chat__bubble--assistant .sr-chat__md li code,
.sr-bubble--assistant .sr-chat__md p code,
.sr-bubble--assistant .sr-chat__md li code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.9em;
}

.sr-chat__pre {
  margin: 0.5rem 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #0d0d14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  max-width: 100%;
}

.sr-chat__pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
  white-space: pre;
  display: block;
}

.sr-chat__thread-fatal-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 1rem 0.5rem;
  box-sizing: border-box;
}

.sr-chat__thread-fatal {
  display: inline-block;
  max-width: 90%;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  background: rgba(127, 29, 29, 0.55);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
}

@keyframes sr-chat-caret-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.15;
  }
}

.sr-chat__stream-caret {
  display: inline-block;
  margin-left: 1px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.65);
  animation: sr-chat-caret-blink 1s step-end infinite;
  vertical-align: baseline;
}

/* Streaming assistant reply — ChatGPT-style block cursor */
.sr-chat__bubble--assistant .sr-cursor,
.sr-bubble--assistant .sr-cursor,
.sr-chat__md .sr-cursor {
  display: inline-block;
  animation: sr-stream-cursor-blink 1s step-end infinite;
  color: #6366f1;
  font-weight: 300;
  vertical-align: text-bottom;
  margin-left: 1px;
}

@keyframes sr-stream-cursor-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sr-chat__md .sr-cursor {
    animation: none;
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sr-chat__stream-caret {
    animation: none;
    opacity: 0.8;
  }
}

.sr-chat__bubble {
  max-width: var(--sr-chat-max-bubble);
  padding: 0.6rem 0.95rem;
  border-radius: var(--sr-chat-radius);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--sr-chat-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.sr-chat__bubble--user {
  background: var(--sr-chat-user-bg);
  border: 1px solid var(--sr-chat-user-border);
  border-bottom-right-radius: 6px;
}

.sr-chat__bubble--assistant {
  background: var(--sr-chat-assistant-bg);
  border: 1px solid var(--sr-chat-assistant-border);
  border-bottom-left-radius: 6px;
}

.sr-chat__bubble--pending {
  color: var(--sr-chat-muted);
  font-style: italic;
}

.sr-chat__bubble--error {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
}

.sr-chat__composer-wrap {
  padding: 0 0.35rem;
}

.sr-chat__guest-hint {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.45;
}

.sr-chat__guest-hint a {
  color: rgba(147, 197, 253, 0.95);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sr-chat__guest-hint a:hover {
  color: #bfdbfe;
}

.sr-chat__composer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem 0.6rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.sr-chat__composer:focus-within {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2), 0 0 20px rgba(37, 99, 235, 0.12);
}

.sr-chat__input {
  resize: none;
  overflow-y: hidden;
  min-height: 2.75rem;
  max-height: none;
  max-width: 100%;
  box-sizing: border-box;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--sr-chat-text) !important;
  font-size: 0.9rem;
  padding: 0.35rem 0.15rem;
  line-height: 1.5;
}

.sr-chat__input:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.sr-chat__input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.sr-chat__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.sr-chat__toolbar--with-model {
  align-items: flex-end;
}

.sr-chat__model-field {
  flex: 1 1 12rem;
  min-width: 0;
}

.sr-chat__model-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.85rem;
  padding: 0.48rem 2rem 0.48rem 0.65rem;
  background-color: #141820 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: rgba(255, 255, 255, 0.94) !important;
  border-radius: 10px;
  cursor: pointer;
  color-scheme: dark;
  appearance: auto;
  -webkit-appearance: menulist;
}

.sr-chat__model-select option,
#sr-chat-model option {
  background-color: #141820;
  color: rgba(255, 255, 255, 0.94);
}

/* If nice-select ever wraps this control, strip the fake UI (native select stays) */
.sr-chatgpt .nice-select,
.sr-chat__shell .nice-select {
  display: none !important;
}

.sr-chatgpt select.sr-chat__model-select,
#sr-chat-model.sr-chat__model-select {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative;
  z-index: 2;
}

.sr-chat__model-select:focus {
  border-color: rgba(59, 130, 246, 0.5) !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
  outline: none;
}

.sr-chat__assistant-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: var(--sr-chat-max-bubble);
  gap: 0.35rem;
}

.sr-chat__assistant-col .sr-chat__bubble {
  max-width: 100%;
}

.sr-chat__meta {
  font-size: 0.72rem;
  color: var(--sr-chat-muted);
  padding: 0 0.15rem;
  line-height: 1.3;
}

.sr-chat__send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.48rem 1.1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.45);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.85), rgba(29, 78, 216, 0.92));
  color: #fff !important;
  transition: filter 0.15s ease, border-color 0.15s ease;
}

.sr-chat__send:hover:not(:disabled) {
  filter: brightness(1.06);
}

.sr-chat__send:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.7);
  outline-offset: 2px;
}

.sr-chat__send-icon {
  font-size: 1.15rem;
  line-height: 1;
}

/* Mobile composer: stack controls, full-width send, no horizontal overflow */
@media (max-width: 767.98px) {
  .sr-page-home .sr-chat {
    --sr-chat-max-bubble: min(92vw, 100%);
  }

  .sr-chatgpt__main .sr-chat__thread {
    margin-left: 0;
    margin-right: 0;
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
  }

  .sr-chatgpt__main .sr-chat__composer-wrap {
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
  }

  .sr-chatgpt__main .sr-chat__alert {
    margin-left: max(0.5rem, env(safe-area-inset-left, 0px));
    margin-right: max(0.5rem, env(safe-area-inset-right, 0px));
  }

  /* Homepage hero chat only — do not force full-width send / stacked toolbar on chat.php */
  .sr-chatgpt__main .sr-chat__toolbar--with-model {
    flex-direction: column;
    align-items: stretch;
  }

  .sr-chatgpt__main .sr-chat__model-field {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .sr-chatgpt__main .sr-chat__send {
    width: 100%;
    min-width: 0;
    padding: 0.55rem 1rem;
  }

  .sr-chatgpt__main .sr-chat__send-icon {
    display: none !important;
  }
}

.sr-chat__send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (max-width: 575.98px) {
  .sr-chat {
    --sr-chat-max-bubble: 90%;
  }

  .sr-chat__thread {
    max-height: min(42vh, 400px);
    min-height: 180px;
  }
}

/* Non-homepage: keep shell framing */
.sr-page-home .sr-chat__shell {
  padding: 0;
  background: transparent;
  border: none;
}

/* Homepage hero: composer first (above thread), outer shell matches chat.php */
.sr-home-hero-chat .sr-home-hero-composer.sr-claude-composer-outer {
  background: transparent;
  border: none;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  margin: 0;
  border-radius: 0;
}

.sr-home-hero-chat .sr-claude-composer-inner {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

/* Inner .sr-composer styling is shared with chat.php via sr-chat-layout + sr-custom */

.sr-home-hero-chat .sr-home-hero-composer .sr-chat__send:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed;
  filter: none;
}

/* Typing dots (homepage hero; also safe if sr-chat-layout is absent) */
.sr-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.sr-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #818cf8;
  animation: sr-typing-bounce 1.2s ease-in-out infinite;
}

.sr-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.sr-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes sr-typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Homepage hero: Claude-style bubbles (same structure as chat.php) */
.sr-home-hero-chat .sr-bubble-user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.sr-home-hero-chat .sr-bubble-user__stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  width: fit-content;
  max-width: min(560px, 85vw, 100%);
  min-width: min(13rem, calc(100vw - 48px));
  flex-shrink: 0;
  box-sizing: border-box;
}

.sr-home-hero-chat .sr-bubble-user .sr-bubble-content {
  background: #2563eb;
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  max-width: 100%;
  width: fit-content;
  min-width: min(12rem, 100%);
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}

.sr-home-hero-chat .sr-bubble-assistant {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  align-items: flex-start;
}

.sr-home-hero-chat .sr-bubble-assistant__stack {
  flex: 1;
  min-width: 0;
  max-width: calc(85% + 32px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.sr-home-hero-chat .sr-bubble-assistant__stack .sr-bubble-content {
  max-width: 100%;
}

.sr-home-hero-chat .sr-bubble-assistant .sr-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  font-weight: 600;
}

.sr-home-hero-chat .sr-bubble-assistant .sr-bubble-content {
  background: #111118;
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 4px 18px 18px 18px;
  padding: 12px 16px;
  max-width: 85%;
  line-height: 1.7;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.sr-home-hero-chat .sr-msg-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  line-height: 1.2;
}

.sr-home-hero-chat .sr-bubble-user__stack .sr-msg-time {
  text-align: right;
  width: 100%;
}

@media (max-width: 767.98px) {
  .sr-home-hero-chat .sr-bubble-user__stack,
  .sr-home-hero-chat .sr-bubble-assistant__stack {
    max-width: min(92vw, 560px);
  }
}

/* Account dropdown in navbar */
.sr-nav-account .dropdown-menu {
  min-width: 11rem;
}

.sr-nav-account .shop-button {
  position: relative;
}

.sr-nav-account .cart-number {
  display: none !important;
}

/* =============================================================================
   Claude-style full-page chat (chat.php — .sr-chat-app)
   ============================================================================= */

html.sr-chat-app-html,
html.sr-chat-app-html body.sr-chat-app.sr-page-home {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: #0a0a0f !important;
}

/* Navbar visible on chat.php; same --sr-nav-h as .sr-page-home (56px) */

body.sr-chat-app .sr-chatgpt {
  margin-top: var(--sr-nav-h);
  height: calc(100dvh - var(--sr-nav-h));
  max-height: calc(100dvh - var(--sr-nav-h));
  background: #0a0a0f !important;
  overflow: hidden;
}

body.sr-chat-app .sr-chatgpt__sidebar {
  background: #111118 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
}

body.sr-chat-app .sr-chatgpt__new-chat {
  background: #2563eb !important;
  border: 1px solid rgba(37, 99, 235, 0.6) !important;
  color: #fff !important;
  font-weight: 600;
}

body.sr-chat-app .sr-chatgpt__new-chat:hover {
  filter: brightness(1.08);
  background: #2563eb !important;
}

body.sr-chat-app .sr-chatgpt__conv-row.is-active,
body.sr-chat-app .sr-conv-item.active,
body.sr-chat-app .sr-conv-item.is-active {
  background: rgba(37, 99, 235, 0.22) !important;
  border-color: rgba(37, 99, 235, 0.45) !important;
}

/* Main column: header + flex body */
.sr-chatgpt__main--claude {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #0a0a0f;
}

.sr-claude-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0.35rem 0.75rem;
  padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #0a0a0f;
  z-index: 5;
}

.sr-claude-topbar__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.02em;
}

.sr-claude-topbar__spacer {
  width: 2.5rem;
  flex-shrink: 0;
}

body.sr-chat-app .sr-claude-topbar .sr-chat__mobile-sidebar-toggle {
  position: relative;
  top: auto;
  left: auto;
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(26, 26, 46, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (min-width: 768px) {
  body.sr-chat-app .sr-claude-topbar .sr-chat__mobile-sidebar-toggle {
    display: none;
  }
}

.sr-claude-main-column {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sr-claude-chat-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: none !important;
}

body.sr-chat-app .sr-claude-chat-root .sr-chat__alert {
  flex: 0 0 auto;
  margin: 0.5rem 1rem 0;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  width: calc(100% - 2rem);
}

.sr-claude-thread-outer {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #0a0a0f;
}

body.sr-chat-app .sr-claude-thread-outer .sr-chat__thread {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  margin: 0 auto;
  width: 100%;
  max-width: 760px;
  padding: 20px;
  box-sizing: border-box;
  border: none !important;
  border-radius: 0 !important;
  background: #0a0a0f !important;
  display: flex;
  flex-direction: column;
}

body.sr-chat-app .sr-chat__empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  padding: 2rem 1rem;
  color: rgba(255, 255, 255, 0.35) !important;
}

.sr-claude-composer-outer {
  flex: 0 0 auto;
  background: #111118;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.sr-claude-composer-inner {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

body.sr-chat-app .sr-claude-composer-outer .sr-chat__guest-hint {
  margin-bottom: 0.65rem;
}

body.sr-chat-app .sr-claude-composer-outer .sr-chat__composer {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  gap: 0.65rem;
}

body.sr-chat-app .sr-claude-composer-outer .sr-chat__composer:focus-within {
  box-shadow: none !important;
}

body.sr-chat-app .sr-claude-composer-outer .sr-chat__input {
  background: #1a1a2e !important;
  border-radius: 12px !important;
  padding: 12px 16px !important;
  min-height: 3rem;
  max-height: 200px;
}

body.sr-chat-app .sr-chat__send:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed;
  filter: none;
}

/* Bubbles — Claude-like */
body.sr-chat-app .sr-chat__msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 70%;
  gap: 0.25rem;
}

body.sr-chat-app .sr-chat__msg-col--assistant {
  align-items: flex-start;
  max-width: 85%;
}

body.sr-chat-app .sr-chat__assistant-col {
  max-width: 85%;
}

body.sr-chat-app .sr-chat__bubble--user {
  background: #2563eb !important;
  border: none !important;
  color: #fff !important;
  border-radius: 18px 18px 4px 18px !important;
  max-width: 100% !important;
  white-space: normal !important;
}

body.sr-chat-app .sr-chat__bubble--assistant {
  background: #1a1a2e !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  color: rgba(255, 255, 255, 0.95) !important;
  border-radius: 18px 18px 18px 4px !important;
  max-width: 100% !important;
  white-space: normal !important;
}

body.sr-chat-app .sr-chat__msg-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.38);
  line-height: 1.2;
  padding: 0 0.35rem;
}

body.sr-chat-app .sr-claude-composer-outer .sr-chat__model-select {
  background-color: #1a1a2e !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

@media (max-width: 767.98px) {
  body.sr-chat-app .sr-chat__msg-col,
  body.sr-chat-app .sr-chat__msg-col--assistant,
  body.sr-chat-app .sr-chat__assistant-col {
    max-width: min(92vw, 560px);
  }
}

/* Nuclear fix — user bubbles must not collapse to one character per line */
.sr-bubble-wrap,
.sr-message-wrap,
[class*='bubble-wrap'],
[class*='message-wrap'] {
  display: flex !important;
  width: 100% !important;
  min-width: 0 !important;
}

.sr-bubble-wrap.user,
.sr-message-wrap.user,
[class*='bubble-wrap'].user {
  justify-content: flex-end !important;
}

.sr-bubble-wrap.assistant,
.sr-message-wrap.assistant,
[class*='bubble-wrap'].assistant {
  justify-content: flex-start !important;
}

/* The actual bubble content (user only — assistant uses avatar + stack layout).
   Never use min-width:0 here — it lets flex shrink the bubble to ~1ch wide (vertical glyphs). */
.sr-bubble-user .sr-bubble-content,
.sr-home-bubble.user,
.sr-bubble-wrap.sr-bubble-user > .sr-bubble-user__stack {
  max-width: min(560px, 85vw, 100%) !important;
  min-width: min(12rem, 100%) !important;
  width: fit-content !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

.sr-bubble-user .sr-bubble-content {
  display: block !important;
}

/* Homepage hero column — mirrors .sr-bubble-user__stack sizing when JS omits stack class */
.sr-home-bubble-col--user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  width: fit-content;
  max-width: min(560px, 85vw, 100%);
  min-width: min(13rem, calc(100vw - 48px));
  margin-left: auto;
  flex-shrink: 0;
  box-sizing: border-box;
}
