/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Design tokens ===== */
:root {
  color-scheme: light;
  --zong-green: #8DC63F;
  --zong-pink: #FF3399;
  --zong-green-light: #eef7dc;
  --zong-pink-light: #ffe0f0;
  --zong-green-dark: #7ab535;
  --zong-pink-dark: #cc1a77;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #f8f9fb;
  --border: #e8eaed;
  --text: #1a1d23;
  --text2: #6b7280;
  --text3: #9ca3af;
  --radius: 12px;
  --radius-sm: 8px;
  --code-bg: #f2f9e3;
  --code-border: #d7ebad;
  --code-toolbar-bg: var(--zong-green);
  --code-toolbar-text: #ffffff;
  --code-lang-color: #ffffff;
  --code-copy-btn: rgba(255, 255, 255, 0.7);
  --code-copy-hover: rgba(0, 0, 0, 0.12);
  --code-text: var(--text);
  --code-scrollbar: var(--zong-green);
  --code-scrollbar-hover: var(--zong-green-dark);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;
  --surface: #1a1d24;
  --surface2: #22262e;
  --border: #2e3340;
  --text: #e6e8ec;
  --text2: #a4aab5;
  --text3: #6c7280;
  --zong-green-light: #1e2a17;
  --zong-pink-light: #2a1520;
  --zong-green-dark: #a5d95a;
  --zong-pink-dark: #ff5ca9;
  --code-bg: #12151c;
  --code-border: #2d3340;
  --code-toolbar-bg: #1a1e27;
  --code-toolbar-text: #e6e8ec;
  --code-lang-color: #a5d95a;
  --code-copy-btn: #9ca3af;
  --code-copy-hover: rgba(255, 255, 255, 0.1);
  --code-text: #e6edf3;
  --code-scrollbar: #374151;
  --code-scrollbar-hover: #4b5563;
}

/* Dark-mode overrides for hardcoded accent colors */
[data-theme="dark"] .theme-toggle,
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  color-scheme: dark;
}

/* ===== Login page ===== */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* Guarantees `el.hidden = true` always hides an element, even when some
   other class on it sets its own `display` (e.g. `.models-popup-loading`'s
   `display: flex`) — author rules otherwise silently beat the browser's
   default [hidden] behavior regardless of selector specificity. */
[hidden] {
  display: none !important;
}

body.login-page {
  background-color: #0a0a0f;
  background-image: url("logos/Group1000004900(1).png");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: scroll;
  color: #ffffff;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
}

html:has(body.login-page) {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

.login-container {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: clamp(1.5rem, 4vw, 3rem);
  row-gap: clamp(0.4rem, 1.2vh, 1rem);
  width: 100%;
  max-width: 1400px;
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vh, 1.5rem) clamp(1.25rem, 3.5vw, 3rem) clamp(0.75rem, 1.8vh, 1.25rem);
  overflow: hidden;
  box-sizing: border-box;
}

.login-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  min-height: 0;
}

.login-header__brands {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.login-header__logo {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
}

.login-header__logo--zong {
  max-width: 240px;
  max-height: clamp(48px, 8vh, 72px);
}

.login-header__logo--cm {
  max-width: 170px;
  max-height: clamp(42px, 7vh, 64px);
}

.login-header__divider {
  display: block;
  width: 1.5px;
  height: clamp(32px, 5.5vh, 48px);
  background: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

.login-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0;
  padding-top: 0.25rem;
}

.login-footer__models {
  display: block;
  width: auto;
  max-width: min(100%, 720px);
  max-height: clamp(48px, 11vh, 88px);
  height: auto;
  object-fit: contain;
}

.login-brand {
  max-width: 680px;
  padding-right: 0.75rem;
  min-height: 0;
  align-self: center;
}

.login-brand__eyebrow {
  font-size: clamp(0.95rem, 2vh, 1.15rem);
  font-weight: 500;
  color: var(--zong-green);
  letter-spacing: 0.01em;
  margin-bottom: clamp(0.4rem, 1vh, 0.75rem);
}

.login-brand__title {
  font-size: clamp(4rem, 10vh, 7rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.03em;
  margin-bottom: clamp(0.4rem, 1vh, 0.75rem);
}

.login-brand__title .mo {
  color: var(--zong-green);
}

.login-brand__title .ma {
  color: var(--zong-pink);
}

.login-brand__subtitle {
  font-size: clamp(1.35rem, 3vh, 2rem);
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: clamp(0.65rem, 1.5vh, 1.15rem);
}

.login-brand__desc {
  font-size: clamp(0.95rem, 2vh, 1.1rem);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.55;
  max-width: 600px;
  margin-bottom: clamp(0.75rem, 1.8vh, 1.25rem);
}

.login-brand__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(0.45rem, 1.1vh, 0.75rem);
}

.login-brand__list li {
  position: relative;
  padding-left: 1.25rem;
  font-size: clamp(1rem, 2.1vh, 1.15rem);
  font-weight: 500;
  color: #ffffff;
  line-height: 1.35;
}

.login-brand__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
}

.login-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0;
  align-self: center;
}

.login-page .form {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
  width: 100%;
  max-width: 460px;
  padding: clamp(2rem, 3.5vh, 2.75rem) clamp(1.75rem, 2.5vw, 2.5rem);
  color: #1a1a2e;
  box-sizing: border-box;
}

.form-header {
  text-align: center;
  margin-bottom: 0.35rem;
}

.login-page .logo {
  display: block;
  width: 100%;
  max-width: 185px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.login-form-tagline {
  margin: 0.55rem 0 0;
  text-align: center;
  font-family: "Roboto", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  color: #1a1a2e;
  white-space: nowrap;
}

.login-form-tagline .moma-green {
  color: var(--zong-green);
}

.login-form-tagline .moma-pink {
  color: var(--zong-pink);
}

.login-page .field label {
  font-size: 0.95rem;
  color: #1f2937;
  font-weight: 600;
}

.login-page .inputForm {
  padding: 0 1rem;
  min-height: 3.1rem;
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(229, 231, 235, 0.95);
}

.login-page .inputForm:focus-within {
  background: #ffffff;
}

.login-page .input {
  font-size: 1rem;
  padding: 0.9rem 0;
  color: #1a1a2e;
}

.login-page .captcha-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.login-page .captcha-visual {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 148px;
  min-height: 3.1rem;
  padding: 0.25rem 0.35rem;
  border-radius: 10px;
  border: 1.5px solid rgba(229, 231, 235, 0.95);
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
}

.login-page .captcha-image {
  display: block;
  width: 140px;
  height: 48px;
  object-fit: contain;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.login-page .captcha-image.is-loading {
  opacity: 0.35;
  filter: blur(1px);
}

.login-page .captcha-refresh {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.1rem;
  min-height: 3.1rem;
  border: 1.5px solid rgba(229, 231, 235, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.login-page .captcha-refresh:hover {
  color: var(--zong-green-dark);
  border-color: var(--zong-green);
  background: #ffffff;
}

.login-page .captcha-refresh:active {
  transform: scale(0.96);
}

.login-page .captcha-refresh.is-spinning svg {
  animation: captcha-spin 0.55s linear;
}

@keyframes captcha-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.login-page .captcha-input-wrap {
  flex: 1;
  min-width: 0;
}

.login-page .captcha-input {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

.login-page .captcha-input::placeholder {
  letter-spacing: normal;
  text-transform: none;
  font-weight: 400;
}

.login-page .otp-box {
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a2e;
}

.login-page .otp-box:focus,
.login-page .otp-box.filled {
  background: #ffffff;
}

.login-page .button-submit {
  padding: 0.95rem;
  font-size: 1.05rem;
  opacity: 1;
  background: var(--zong-green);
  color: #ffffff;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.inputForm {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 0 0.875rem;
  background: #fafafa;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.inputForm:focus-within {
  border-color: var(--zong-green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(141, 198, 63, 0.1);
}

.inputForm svg {
  flex-shrink: 0;
  fill: #9ca3af;
  transition: fill 0.2s ease;
}

.inputForm:focus-within svg {
  fill: var(--zong-green);
}

.input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.9rem;
  color: #1a1a2e;
  padding: 0.75rem 0;
  font-family: inherit;
}

.input::placeholder {
  color: #9ca3af;
}

.button-submit {
  width: 100%;
  padding: 0.8rem;
  background: var(--zong-green);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: background 0.2s ease, transform 0.1s ease;
}

.button-submit:hover {
  background: var(--zong-green-dark);
}

.button-submit:active {
  transform: scale(0.98);
  background: #6a9e2e;
}

.button-submit {
  position: relative;
}

.button-submit:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-submit .btn-dots {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.button-submit.loading .btn-text {
  visibility: hidden;
}

.button-submit.loading .btn-dots {
  display: flex;
}

.button-submit .btn-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  animation: bounce 1.2s infinite;
}

.button-submit .btn-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.button-submit .btn-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: -0.25rem;
}

.button-resend {
  width: 100%;
  padding: 0.7rem;
  background: transparent;
  color: var(--zong-green-dark);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--zong-green);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.button-resend:hover {
  background: var(--zong-green-light);
  border-color: var(--zong-green-dark);
  color: var(--zong-green-dark);
}

.button-resend:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 900px) {
  .login-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    align-content: center;
    justify-items: center;
    row-gap: 1rem;
    padding: 1.25rem 1rem;
  }

  .login-header,
  .login-brand {
    display: none;
  }

  .login-panel {
    width: 100%;
    max-width: 420px;
    align-self: center;
  }

  .login-footer {
    align-self: end;
  }

  .login-footer__models {
    max-height: clamp(40px, 10vh, 64px);
  }

  .login-page .form {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .login-page .form {
    padding: 1.5rem 1.25rem;
    border-radius: 14px;
  }

  /* The captcha row's fixed-width image box + refresh button leave almost
     no room for the code input on narrow phones — wrap the image onto its
     own line so the input keeps a usable width underneath it. */
  .login-page .captcha-row {
    flex-wrap: wrap;
  }

  .login-page .captcha-visual {
    width: 100%;
  }

  .login-page .captcha-input-wrap {
    flex: 1 1 auto;
  }

  .login-form-tagline {
    white-space: normal;
  }
}

.otp-boxes {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.otp-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a2e;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.otp-box:focus {
  border-color: var(--zong-green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(141, 198, 63, 0.15);
  transform: translateY(-1px);
}

.otp-box.filled {
  border-color: var(--zong-green);
  background: var(--zong-green-light, #eef7dc);
  color: var(--zong-green-dark, #7ab535);
}

@media (max-width: 480px) {
  .otp-boxes {
    gap: 0.375rem;
  }

  .otp-box {
    font-size: 1.15rem;
  }
}

/* ===== Smart Router UI ===== */
html:has(.app) {
  height: 100%;
}

html:has(.app) body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  min-height: auto;
  color: inherit;
}

.app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

.main-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.navbar-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 16px;
}

.hamburger-btn {
  height: 34px;
  width: 34px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.15s;
}

.hamburger-btn:hover {
  background: var(--zong-green-light);
  border-color: var(--zong-green);
  color: var(--zong-green-dark);
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--zong-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.brand-name span {
  color: var(--zong-pink);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--zong-green);
}

.nav-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text2);
  background: var(--surface);
  font-weight: 500;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 0 0 16px;
  overflow: hidden;
  height: 100vh;
  transition: width 0.2s ease, padding 0.2s ease, border-color 0.2s ease, transform 0.25s ease;
}

.sidebar.collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
  overflow: hidden;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {

  .sidebar,
  .sidebar.collapsed {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 300;
    width: min(280px, 86vw);
    height: 100vh;
    height: 100dvh;
    padding: 16px 16px 0;
    border-right: 1px solid var(--border);
    transform: translateX(-105%);
    box-shadow: none;
    overflow: hidden;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(15, 18, 24, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .hamburger-btn {
    display: flex;
  }

  .app,
  .main-col {
    height: 100vh;
    height: 100dvh;
  }

  .navbar {
    padding: 0 12px;
    height: 48px;
  }

  .navbar-center {
    font-size: 11px;
    padding: 0 6px;
  }

  .navbar-right {
    margin-left: auto;
    flex-shrink: 0;
  }

  .navbar-right .logout-toggle {
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .messages {
    padding: 8px 10px 6px;
    gap: 10px;
  }

  .empty-state {
    padding: 8px 10px;
    gap: 10px;
    justify-content: center;
  }

  .empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
  }

  .empty-state .hint-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 0;
  }

  .empty-state .hint-chip {
    justify-content: flex-start;
    width: 100%;
    padding: 9px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
  }

  .empty-state .hint-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .empty-state .hint-chip--extra {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .msg {
    max-width: 92%;
  }

  .msg-bubble {
    padding: 10px 13px;
    font-size: 13.5px;
  }

  .msg-image {
    max-width: min(260px, 100%);
  }

  .msg-audio {
    width: min(260px, 100%);
  }

  .error-bubble {
    max-width: 92%;
  }

  .file-preview-bar {
    padding: 6px 12px;
  }

  .chat-col>.model-selector-wrap {
    width: calc(100% - 20px);
    max-width: none;
    margin: 0 10px 8px;
  }

  .chat-col>.input-area {
    width: calc(100% - 20px);
    max-width: none;
    margin: 0 10px 12px;
    padding: 6px 8px;
    border-radius: 18px;
  }

  .input-area textarea {
    font-size: 14px;
  }

  .icon-btn,
  .send-btn {
    height: 36px;
    width: 36px;
  }

  .preview-overlay {
    padding: 10px;
  }

  .preview-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  .navbar-center {
    display: none;
  }

  .navbar-brand {
    flex: 0 0 auto;
  }

  .navbar-right {
    margin-left: auto;
    flex: 0 0 auto;
  }

  .navbar-right .logout-toggle {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .empty-title {
    font-size: 18px;
  }

  .empty-state {
    padding: 6px 8px;
    gap: 8px;
  }

  .empty-state .hint-chip {
    padding: 8px 9px;
    font-size: 11px;
    gap: 5px;
  }

  .chat-col>.model-selector-wrap {
    width: calc(100% - 16px);
    margin: 0 8px 6px;
  }

  .model-pill {
    padding: 5px 10px;
    font-size: 12px;
  }

  .chat-col>.input-area {
    width: calc(100% - 16px);
    margin: 0 8px 10px;
  }

  .msg {
    max-width: 96%;
  }
}

.sidebar-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding-right: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Gutter width stays constant at all times (thin / 6px) so the scrollbar
     appearing never shifts the content width — only its thumb color toggles
     between transparent and themed on hover, nothing reflows. */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.sidebar-scroll:hover {
  scrollbar-color: var(--zong-green) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  transition: background 0.15s;
}

.sidebar-scroll:hover::-webkit-scrollbar-thumb {
  background: var(--zong-green);
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--zong-green-dark);
}

.sidebar-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.sidebar-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 10px;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.model-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.model-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.model-dot.active {
  background: var(--zong-green);
}

.model-dot.cloud {
  background: #3b82f6;
}

.model-info {
  flex: 1;
  min-width: 0;
}

.model-name {
  font-weight: 500;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-intent {
  font-size: 10px;
  color: var(--text3);
  margin-top: 1px;
}

.model-badge-sm {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-local {
  background: var(--zong-green-light);
  color: var(--zong-green-dark);
}

.badge-cloud {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-anthropic {
  background: #f3e8ff;
  color: #7c3aed;
}

.badge-cmcc {
  background: #dcfce7;
  color: #166534;
}

.config-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.config-label {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.config-input {
  width: 100%;
  font-size: 11px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.config-input:focus {
  border-color: var(--zong-green);
}

/* .stats-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
} */

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

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

.stat-label {
  color: var(--text2);
}

.stat-value {
  font-weight: 600;
  color: var(--text);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fafbfc;
}

.chat-topbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  flex-shrink: 0;
}

.chat-topbar-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--zong-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.chat-topbar-info {
  flex: 1;
}

.chat-topbar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.chat-topbar-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 2px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--zong-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px -2px rgba(141, 198, 63, 0.45);
}

.sidebar-brand-info {
  flex: 1;
  min-width: 0;
}

.sidebar-brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
  line-height: 1.2;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  color: var(--bg);
  background: var(--zong-green);
  border: none;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  cursor: pointer;
}

.new-chat-btn:hover {
  background: var(--zong-green-dark);
}

.recent-chats {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 12px;
}

.recent-chats-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-chats-empty {
  font-size: 12px;
  color: var(--text3);
  padding: 6px 2px;
}

.recent-chat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.recent-chat-item:hover {
  background: var(--zong-green-light);
  border-color: var(--zong-green);
}

.recent-chat-item.active {
  background: var(--zong-green-light);
  border-color: var(--zong-green);
}

.recent-chat-preview {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-chat-time {
  font-size: 10.5px;
  color: var(--text3);
}

.clear-btn {
  font-size: 12px;
  color: var(--text3);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.clear-btn:hover {
  background: var(--surface2);
  color: var(--text2);
}

/* ===== Sidebar settings menu ===== */

.sidebar-footer {
  position: relative;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 12px;
  padding-right: 16px;
  padding-bottom: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.settings-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.settings-trigger i {
  font-size: 16px;
}

.settings-trigger:hover,
.sidebar-footer.open .settings-trigger {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

.settings-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px -8px rgba(26, 29, 35, 0.18);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 50;
}

.sidebar-footer:hover .settings-menu,
.sidebar-footer.open .settings-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.settings-separator {
  width: 100%;
  border-top: 1px solid var(--border);
  margin: 5px 0;
}

.settings-list {
  color: var(--text);
  list-style-type: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.settings-item svg {
  flex-shrink: 0;
  color: var(--text3);
  z-index: 1;
  transition: all 0.2s ease;
}

.settings-item:hover {
  background: var(--surface2);
}

.settings-item .settings-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s ease;
}

/* -- Favorite item -- */

.settings-favorite .settings-fav-label {
  position: absolute;
  transform: translateY(-100%) translateX(-15px) scale(0.8);
  opacity: 0;
}

.settings-favorite .settings-checkbox {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  appearance: none;
  margin: 0;
  cursor: pointer;
  z-index: 10;
}

.settings-favorite .settings-checkbox:checked~.settings-fav-label {
  transform: translateY(0);
  opacity: 1;
}

.settings-favorite .settings-checkbox:checked~.settings-label:not(.settings-fav-label) {
  transform: translateY(110%) translateX(-6px) scale(0.8);
  opacity: 0;
}

.settings-favorite .settings-checkbox:checked~.settings-icon-star {
  fill: #f5a623;
  stroke: #f5a623;
}

/* -- Rename item -- */

.settings-rename:has(.settings-toggler:checked) {
  background-color: var(--surface2);
  overflow: hidden;
}

.settings-rename:has(.settings-toggler:checked) .settings-label {
  opacity: 0;
  transform: translateY(100%);
}

.settings-rename:has(.settings-toggler:checked)>svg {
  transform: translateY(130%);
}

.settings-rename:has(.settings-toggler:checked) .settings-input-container {
  transform: translateY(0);
}

.settings-rename:has(.settings-toggler:checked) .settings-input-container .settings-icons {
  top: 50%;
}

.settings-toggler {
  position: absolute;
  left: 0;
  top: 0;
  appearance: none;
  margin: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 10;
}

.settings-input-container {
  transform: translateY(-100%);
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  transition: transform 0.2s ease;
}

.settings-text-input {
  width: 75%;
  background: transparent;
  border: none;
  outline: none;
  height: 100%;
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  font-family: inherit;
  z-index: 5;
}

.settings-icons {
  position: absolute;
  top: -50%;
  right: 4px;
  transform: translateY(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: top 0.2s ease;
  gap: 6px;
}

.settings-icons svg {
  background-color: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  padding: 3px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-icons svg:hover {
  background-color: var(--zong-green-light);
  border-color: var(--zong-green);
  color: var(--zong-green-dark);
}

/* -- Clear all chats (delete) item -- */

.settings-delete {
  color: #c0392b;
}

.settings-delete svg {
  color: #c0392b;
}

.settings-delete:hover {
  background: #fbe9e7;
}

.settings-delete .settings-action {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%) translateX(-15px) scale(0.8);
}

.settings-delete::before {
  content: "";
  position: absolute;
  background-color: #f6cdc7;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
}

.settings-delete:active .settings-label {
  opacity: 0;
  visibility: hidden;
  transform: translateY(100%) translateX(-15px) scale(0.8);
}

.settings-delete:active .settings-action {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.settings-delete:active::before {
  animation: settings-delete-fill 2.5s ease-in-out forwards 0.2s;
}

@keyframes settings-delete-fill {
  from {
    width: 0%;
  }

  to {
    width: 100%;
  }
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages {
  scrollbar-width: thin;
  scrollbar-color: var(--zong-green) transparent;
}

.messages::-webkit-scrollbar {
  width: 4px;
  background: transparent;
}

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

.messages::-webkit-scrollbar-thumb {
  background: var(--zong-green);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--zong-green-dark);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
  text-align: center;
  padding: 60px 40px;
}

/* When there's no conversation yet, the composer lives inside .empty-state
   (moved there by updateComposerPosition in ChatModule.js) so it floats
   centered with the greeting instead of staying pinned to the bottom. */
.empty-state .input-area {
  margin: 20px auto 0;
  max-width: 640px;
  width: 100%;
}

.chat-loader {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text3);
  font-size: 13px;
}

.chat-loader.visible {
  display: flex;
}

.chat-loader-text {
  font-weight: 500;
}

/* Speeder loader — adapted from Uiverse.io by anand_4957, recolored to
   the Zong palette and namespaced under .chat-* to avoid clashing with
   other rules in this stylesheet. */
.chat-speeder-wrap {
  position: relative;
  width: 220px;
  height: 90px;
}

.chat-speeder {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -50px;
  animation: chat-speeder-move 0.4s linear infinite;
}

.chat-speeder>span {
  height: 5px;
  width: 35px;
  background: var(--zong-pink);
  position: absolute;
  top: -19px;
  left: 60px;
  border-radius: 2px 10px 1px 0;
}

.chat-speeder-base span {
  position: absolute;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-right: 100px solid var(--zong-pink);
  border-bottom: 6px solid transparent;
}

.chat-speeder-base span:before {
  content: "";
  height: 22px;
  width: 22px;
  border-radius: 50%;
  background: var(--zong-pink);
  position: absolute;
  right: -110px;
  top: -16px;
}

.chat-speeder-base span:after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-top: 0 solid transparent;
  border-right: 55px solid var(--zong-pink);
  border-bottom: 16px solid transparent;
  top: -16px;
  right: -98px;
}

.chat-speeder-face {
  position: absolute;
  height: 12px;
  width: 20px;
  background: var(--zong-pink);
  border-radius: 20px 20px 0 0;
  transform: rotate(-40deg);
  right: -125px;
  top: -15px;
}

.chat-speeder-face:after {
  content: "";
  height: 12px;
  width: 12px;
  background: var(--zong-pink);
  right: 4px;
  top: 7px;
  position: absolute;
  transform: rotate(40deg);
  transform-origin: 50% 50%;
  border-radius: 0 0 0 2px;
}

.chat-speeder>span>span:nth-child(1),
.chat-speeder>span>span:nth-child(2),
.chat-speeder>span>span:nth-child(3),
.chat-speeder>span>span:nth-child(4) {
  width: 30px;
  height: 1px;
  background: var(--zong-pink);
  position: absolute;
  animation: chat-fazer1 0.2s linear infinite;
}

.chat-speeder>span>span:nth-child(2) {
  top: 3px;
  animation: chat-fazer2 0.4s linear infinite;
}

.chat-speeder>span>span:nth-child(3) {
  top: 1px;
  animation: chat-fazer3 0.4s linear infinite;
  animation-delay: -1s;
}

.chat-speeder>span>span:nth-child(4) {
  top: 4px;
  animation: chat-fazer4 1s linear infinite;
  animation-delay: -1s;
}

@keyframes chat-fazer1 {
  0% {
    left: 0;
  }

  100% {
    left: -80px;
    opacity: 0;
  }
}

@keyframes chat-fazer2 {
  0% {
    left: 0;
  }

  100% {
    left: -100px;
    opacity: 0;
  }
}

@keyframes chat-fazer3 {
  0% {
    left: 0;
  }

  100% {
    left: -50px;
    opacity: 0;
  }
}

@keyframes chat-fazer4 {
  0% {
    left: 0;
  }

  100% {
    left: -150px;
    opacity: 0;
  }
}

@keyframes chat-speeder-move {
  0% {
    transform: translate(2px, 1px) rotate(0deg);
  }

  10% {
    transform: translate(-1px, -3px) rotate(-1deg);
  }

  20% {
    transform: translate(-2px, 0px) rotate(1deg);
  }

  30% {
    transform: translate(1px, 2px) rotate(0deg);
  }

  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }

  50% {
    transform: translate(-1px, 3px) rotate(-1deg);
  }

  60% {
    transform: translate(-1px, 1px) rotate(0deg);
  }

  70% {
    transform: translate(3px, 1px) rotate(-1deg);
  }

  80% {
    transform: translate(-2px, -1px) rotate(1deg);
  }

  90% {
    transform: translate(2px, 1px) rotate(0deg);
  }

  100% {
    transform: translate(1px, -2px) rotate(-1deg);
  }
}

.chat-longfazers {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  overflow: hidden;
}

.chat-longfazers span {
  position: absolute;
  height: 2px;
  width: 20%;
  background: var(--border);
}

.chat-longfazers span:nth-child(1) {
  top: 20%;
  animation: chat-lf 0.6s linear infinite;
  animation-delay: -5s;
}

.chat-longfazers span:nth-child(2) {
  top: 40%;
  animation: chat-lf2 0.8s linear infinite;
  animation-delay: -1s;
}

.chat-longfazers span:nth-child(3) {
  top: 60%;
  animation: chat-lf3 0.6s linear infinite;
}

.chat-longfazers span:nth-child(4) {
  top: 80%;
  animation: chat-lf4 0.5s linear infinite;
  animation-delay: -3s;
}

@keyframes chat-lf {
  0% {
    left: 200%;
  }

  100% {
    left: -200%;
    opacity: 0;
  }
}

@keyframes chat-lf2 {
  0% {
    left: 200%;
  }

  100% {
    left: -200%;
    opacity: 0;
  }
}

@keyframes chat-lf3 {
  0% {
    left: 200%;
  }

  100% {
    left: -100%;
    opacity: 0;
  }
}

@keyframes chat-lf4 {
  0% {
    left: 200%;
  }

  100% {
    left: -100%;
    opacity: 0;
  }
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--zong-green-light), var(--zong-pink-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--zong-pink);
}

.empty-greeting {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text2);
}

.empty-sub {
  font-size: 13px;
  color: var(--text3);
  line-height: 1.6;
  max-width: 340px;
}

.hint-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: inherit;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
}

.hint-chip i {
  font-size: 15px;
  color: var(--zong-green);
  flex-shrink: 0;
}

.hint-chip:hover {
  border-color: var(--zong-green);
  color: var(--zong-green-dark);
  background: var(--zong-green-light);
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-actions {
  display: flex;
  margin-top: 4px;
  padding: 0 4px;
}

.msg-copy-btn,
.msg-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.msg-copy-btn svg,
.msg-edit-btn svg {
  width: 13px;
  height: 13px;
}

.msg-copy-btn:hover,
.msg-edit-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.msg-copy-btn.copied {
  color: var(--zong-green-dark);
}

.msg-copy-btn.copy-failed {
  color: var(--zong-pink-dark);
}

/* Requests (user messages): action buttons only reveal on hover. */
.msg.user .msg-copy-btn,
.msg.user .msg-edit-btn {
  opacity: 0;
}

.msg.user:hover .msg-copy-btn,
.msg.user:hover .msg-edit-btn {
  opacity: 1;
}

/* Responses (assistant messages): copy button is always shown. */
.msg.assistant .msg-copy-btn {
  opacity: 0.7;
}

.msg.assistant .msg-copy-btn:hover {
  opacity: 1;
}

/* Touch devices have no :hover — keep the request's action buttons reachable
   instead of hiding it behind an interaction that can't happen. */
@media (hover: none) {
  .msg.user .msg-copy-btn,
  .msg.user .msg-edit-btn {
    opacity: 0.6;
  }
}

.msg-bubble {
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--zong-pink), #cc1a77);
  color: #fff;
  border-bottom-right-radius: 4px;
  /* User messages are shown as plain text (not Markdown-rendered), so
     newlines from the raw input still need to be preserved manually. */
  white-space: pre-wrap;
}

.msg.assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  /* Assistant content is rendered Markdown → real <p>/<ul>/<pre> elements
     already carry their own spacing; pre-wrap here would double it up. */
  white-space: normal;
}

/* ===== Markdown content inside assistant messages ===== */

.msg-bubble p {
  margin: 0 0 8px;
}

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

.msg-bubble strong {
  font-weight: 700;
}

.msg-bubble em {
  font-style: italic;
}

.msg-bubble ul,
.msg-bubble ol {
  margin: 0 0 8px;
  padding-left: 22px;
}

.msg-bubble ul:last-child,
.msg-bubble ol:last-child {
  margin-bottom: 0;
}

.msg-bubble li {
  margin-bottom: 3px;
}

.msg-bubble li:last-child {
  margin-bottom: 0;
}

.msg-bubble li>ul,
.msg-bubble li>ol {
  margin-top: 3px;
}

.msg-bubble h1,
.msg-bubble h2,
.msg-bubble h3,
.msg-bubble h4 {
  margin: 12px 0 6px;
  font-weight: 700;
  line-height: 1.3;
}

.msg-bubble h1:first-child,
.msg-bubble h2:first-child,
.msg-bubble h3:first-child,
.msg-bubble h4:first-child {
  margin-top: 0;
}

.msg-bubble h1 {
  font-size: 18px;
}

.msg-bubble h2 {
  font-size: 16.5px;
}

.msg-bubble h3 {
  font-size: 15px;
}

.msg-bubble h4 {
  font-size: 14px;
}

.msg-bubble code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 4px;
}

.msg-bubble pre {
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  white-space: pre;
  direction: ltr;
  background: var(--code-bg);
  color: var(--code-text);
}

.msg-bubble pre:last-child {
  margin-bottom: 0;
}

.msg-bubble pre code {
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}

/* enhanceCodeBlocks() wraps every <pre> in this container right after
   render, adding the language label + copy button toolbar on top — the
   wrapper owns the outer spacing/radius/background from here on, so the
   inner <pre> rules above are only a fallback for the brief moment before
   JS runs (or if it fails to for any reason). */
.code-block-wrapper {
  position: relative;
  margin: 8px 0;
  border-radius: 10px;
  border: 1.5px solid var(--code-border);
  background: var(--code-bg);
  overflow: hidden;
  direction: ltr;
}

.code-block-wrapper:last-child {
  margin-bottom: 0;
}

.code-block-wrapper pre {
  margin: 0;
  border-radius: 0;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--code-scrollbar) transparent;
  background: var(--code-bg);
}

.code-block-wrapper pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background: transparent;
}

.code-block-wrapper pre::-webkit-scrollbar-track {
  background: transparent;
}

.code-block-wrapper pre::-webkit-scrollbar-thumb {
  background: var(--code-scrollbar);
  border-radius: 3px;
}

.code-block-wrapper pre::-webkit-scrollbar-thumb:hover {
  background: var(--code-scrollbar-hover);
}

.code-block-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--code-toolbar-bg);
  border-bottom: 1px solid var(--code-border);
}

.code-block-lang {
  font-size: 11px;
  font-weight: 700;
  color: var(--code-lang-color);
  text-transform: lowercase;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.code-block-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--code-copy-btn);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.code-block-wrapper:hover .code-block-copy {
  opacity: 1;
}

.code-block-copy:hover {
  background: var(--code-copy-hover);
  color: var(--code-toolbar-text);
}

.code-block-copy svg {
  width: 14px;
  height: 14px;
}

.code-block-copy.copied {
  color: var(--code-lang-color);
  background: var(--code-copy-hover);
  opacity: 1;
}

.code-block-copy.copy-failed {
  color: var(--zong-pink-dark);
  opacity: 1;
}

/* Touch devices have no :hover state — keep the button visibly usable
   instead of requiring an impossible hover to discover it. */
@media (hover: none) {
  .code-block-copy {
    opacity: 0.8;
  }
}

.msg-bubble blockquote {
  margin: 8px 0;
  padding: 2px 12px;
  border-left: 3px solid;
}

.msg-bubble blockquote:last-child {
  margin-bottom: 0;
}

.msg-bubble hr {
  margin: 10px 0;
  border: none;
  border-top: 1px solid;
}

.msg-bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13px;
}

.msg-bubble th,
.msg-bubble td {
  border: 1px solid;
  padding: 6px 10px;
  text-align: left;
}

.msg-bubble a {
  text-decoration: underline;
  word-break: break-word;
}

.msg.assistant .msg-bubble code {
  background: var(--surface2);
  color: var(--text);
}

.msg.assistant .msg-bubble pre {
  background: var(--code-bg);
}

.msg.assistant .msg-bubble pre code {
  /* Must explicitly reset background here, not just rely on the generic
     .msg-bubble pre code rule above — .msg.assistant .msg-bubble code (the
     *inline* code styling) has higher specificity and would otherwise win,
     painting a background on every line of the multi-line inline <code>
     element individually (each line box gets its own little rounded rect,
     since background on an inline element renders per line fragment). */
  background: none;
  color: var(--code-text);
}

.msg.assistant .msg-bubble blockquote {
  border-left-color: var(--zong-green);
  color: var(--text2);
}

.msg.assistant .msg-bubble hr {
  border-top-color: var(--border);
}

.msg.assistant .msg-bubble th,
.msg.assistant .msg-bubble td {
  border-color: var(--border);
}

.msg.assistant .msg-bubble a {
  color: var(--zong-green-dark);
}

.msg-image {
  max-width: 260px;
  max-height: 260px;
  border-radius: 12px;
  display: block;
  object-fit: cover;
  cursor: pointer;
}

.msg-audio {
  display: block;
  width: 260px;
  max-width: 100%;
  height: 40px;
  border-radius: 20px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.intent-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: capitalize;
}

.intent-general_chat {
  background: #e8f0fe;
  color: #1a56db;
}

.intent-code {
  background: #ede9fe;
  color: #5b21b6;
}

.intent-table {
  background: var(--zong-green-light);
  color: var(--zong-green-dark);
}

.intent-image_analysis {
  background: #fef3c7;
  color: #92400e;
}

.intent-voice {
  background: var(--zong-pink-light);
  color: var(--zong-pink-dark);
}

.intent-premium {
  background: #f3e8ff;
  color: #7c3aed;
}

.intent-llama {
  background: #fee2e2;
  color: #b91c1c;
}

.intent-document {
  background: #fef3c7;
  color: #92400e;
}

.intent-image_generation {
  background: #ede9fe;
  color: #5b21b6;
}

.intent-coding_advanced {
  background: #dcfce7;
  color: #166534;
}

.intent-multilingual {
  background: #fae8ff;
  color: #a21caf;
}

.intent-web_search {
  background: #dbeafe;
  color: #1d4ed8;
}

/*
 * Model identity styling — hidden from end users per product requirements.
 * Kept commented for potential internal/debug reuse.
 */
/* .model-label {
  font-size: 11px;
  color: var(--text3);
}

.model-type-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

.type-local {
  background: var(--zong-green-light);
  color: var(--zong-green-dark);
}

.type-openai {
  background: #dbeafe;
  color: #1d4ed8;
}

.type-claude {
  background: #f3e8ff;
  color: #7c3aed;
}

.type-cmcc {
  background: #dcfce7;
  color: #166534;
}

.type-gemini {
  background: #dbeafe;
  color: #1d4ed8;
} */

.tokens-label {
  font-size: 11px;
  color: var(--text3);
}

.file-preview-bar {
  padding: 6px 24px;
  background: var(--zong-green-light);
  border-top: 1px solid var(--border);
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--zong-green-dark);
  flex-shrink: 0;
}

.file-preview-bar.visible {
  display: flex;
}

.file-preview-bar button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--zong-pink);
  font-size: 14px;
  display: flex;
  align-items: center;
  margin-left: auto;
}

/* Recording lives inline inside .input-area itself — textarea/attach button
   hide and the waveform + timer take their place, so there's no separate
   bar or "Stop & Send" button; the mic button (already morphed into a stop
   icon) is the only control needed to end recording. */
.recording-inline {
  display: none;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 4px;
}

.input-area.recording textarea,
.input-area.recording #attach-btn,
.input-area.recording #send-btn {
  display: none;
}

.input-area.recording .recording-inline {
  display: flex;
}

.recording-inline #recording-timer {
  font-size: 13px;
  font-weight: 600;
  color: var(--zong-pink-dark);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.recording-action {
  height: 32px;
  width: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.recording-cancel {
  background: var(--surface2);
  color: var(--text2);
}

.recording-cancel:hover {
  background: #fde2e2;
  color: #b91c1c;
}

.recording-send {
  background: var(--zong-green);
  color: #fff;
}

.recording-send:hover {
  background: var(--zong-green-dark);
}

.recording-action:active {
  transform: scale(0.9);
}

.recording-waveform {
  display: block;
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 28px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.input-area.settling .recording-waveform {
  opacity: 0.25;
}

.input-area.settling #recording-timer {
  opacity: 0.3;
}

.typing-wrap {
  align-self: flex-start;
}

.typing {
  display: flex;
  gap: 5px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(1) {
  background: var(--zong-green);
}

.typing span:nth-child(2) {
  background: var(--zong-pink);
  animation-delay: 0.2s;
}

.typing span:nth-child(3) {
  background: var(--zong-green);
  animation-delay: 0.4s;
}

@keyframes bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-6px);
  }
}

.error-bubble {
  font-size: 13px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  align-self: flex-start;
  max-width: 72%;
}

.model-selector-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 75%;
  max-width: 760px;
  margin: 0 auto 10px;
  user-select: none;
}

.empty-state .model-selector-wrap {
  margin: 20px auto 0px;
  max-width: 640px;
  width: 100%;
}

.model-pill-selector {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  gap: 3px;
  box-shadow: 0 1px 4px rgba(20, 20, 30, 0.04);
}

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.16s ease-in-out;
  line-height: 1.2;
  outline: none;
}

.model-pill:hover:not(.active) {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .model-pill:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06);
}

.model-pill.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-color: var(--border);
}

[data-theme="dark"] .model-pill.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.12);
}

.model-pill-icon {
  font-size: 14px;
  line-height: 1;
}

.model-pill-label {
  letter-spacing: 0.1px;
}

.model-pill:focus-visible {
  outline: 2px solid var(--zong-green);
  outline-offset: 1px;
}

.model-selector-wrap.is-locked .model-pill-selector {
  border-color: var(--border);
}

.model-selector-wrap.is-locked .model-pill:not(.active) {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.model-selector-wrap.is-locked .model-pill.active {
  cursor: default;
}

.model-lock-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  color: var(--text3);
  font-size: 13px;
  cursor: help;
  transition: color 0.15s;
}

.model-lock-indicator:hover {
  color: var(--text2);
}

.input-area {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  background: var(--surface);
  flex-shrink: 0;
  width: 75%;
  max-width: 760px;
  margin: 0 auto 22px;
  padding: 8px 10px 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 2px 10px rgba(20, 20, 30, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-area:focus-within {
  border-color: var(--zong-green);
  box-shadow: 0 0 0 3px rgba(141, 198, 63, 0.14), 0 2px 10px rgba(20, 20, 30, 0.04);
}

.input-area textarea {
  flex: 1;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  padding: 10px 6px;
  border: none;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
  min-height: 24px;
  max-height: 120px;
  outline: none;
}

.input-area textarea::placeholder {
  color: var(--text3);
}

.icon-btn {
  height: 38px;
  width: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--zong-green-light);
  color: var(--zong-green-dark);
}

.icon-btn.recording {
  background: var(--zong-pink-light);
  color: var(--zong-pink);
  animation: mic-pulse-glow 1.4s ease-in-out infinite;
}

@keyframes mic-pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 51, 153, 0.35);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(255, 51, 153, 0);
  }
}

.send-btn {
  height: 38px;
  width: 38px;
  border-radius: 50%;
  border: none;
  background: var(--zong-green);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}

.send-btn:hover:not(:disabled) {
  background: var(--zong-green-dark);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.send-btn.is-stopping {
  background: var(--zong-pink-dark);
}

.send-btn.is-stopping:hover:not(:disabled) {
  background: var(--zong-pink-dark);
  filter: brightness(1.1);
}

.send-btn:disabled {
  background: var(--border);
  color: var(--text3);
  cursor: not-allowed;
}

.footer-note {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

/* Preview modal */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}

.preview-overlay.visible {
  display: flex;
}

.preview-modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-modal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.preview-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.preview-modal-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.preview-modal-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--zong-green) transparent;
}

.preview-modal-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background: transparent;
}

.preview-modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.preview-modal-body::-webkit-scrollbar-thumb {
  background: var(--zong-green);
  border-radius: 4px;
}

.preview-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--zong-green-dark);
}

.preview-modal-body img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
}

.preview-modal-body pre {
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  text-align: left;
  width: 100%;
  font-family: ui-monospace, monospace;
}

/* ===== Models catalog popup ===== */

.models-popup-modal {
  width: 760px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.models-popup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.models-popup-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--zong-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px -2px rgba(141, 198, 63, 0.45);
}

.models-popup-header-info {
  flex: 1;
  min-width: 0;
}

.models-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.models-popup-subtitle {
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.models-popup-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--zong-green-dark);
  background: var(--zong-green-light);
  border-radius: 20px;
  padding: 3px 10px;
  flex-shrink: 0;
}

.models-popup-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.models-popup-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.models-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--zong-green) transparent;
}

.models-popup-body::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.models-popup-body::-webkit-scrollbar-track {
  background: transparent;
}

.models-popup-body::-webkit-scrollbar-thumb {
  background: var(--zong-green);
  border-radius: 4px;
}

.models-popup-body::-webkit-scrollbar-thumb:hover {
  background: var(--zong-green-dark);
}

.models-popup-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  padding: 40px 0;
}

.models-popup-loading.hidden {
  display: none;
}

.models-popup-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--zong-green);
  animation: models-popup-spin 0.7s linear infinite;
}

@keyframes models-popup-spin {
  to {
    transform: rotate(360deg);
  }
}

.models-popup-error {
  text-align: center;
  color: var(--zong-pink-dark);
  font-size: 13px;
  padding: 40px 0;
}

.models-popup-empty {
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  padding: 40px 0;
}

.models-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.models-popup-footer-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text3);
}

.models-popup-footer-close {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.models-popup-footer-close:hover {
  background: var(--zong-green);
  border-color: var(--zong-green);
  color: #fff;
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 640px) {
  .models-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.model-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.model-card:hover {
  border-color: var(--zong-green);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgba(26, 29, 35, 0.15);
}

.model-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 24px;
}

.model-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.model-card-provider {
  font-size: 10px;
  font-weight: 700;
  color: var(--zong-green-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.model-card-description {
  font-size: 11.5px;
  color: var(--text2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-card-intent {
  align-self: flex-start;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--zong-pink-dark);
  background: var(--zong-pink-light);
  border-radius: 4px;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.model-card-updated {
  margin-top: auto;
  font-size: 10px;
  color: var(--text3);
}

.preview-doc-icon {
  font-size: 64px;
}

.preview-doc-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text2);
  font-size: 13px;
}

.msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
}

.msg-file-chip:hover {
  border-color: var(--zong-green);
  background: var(--zong-green-light);
}

.msg-file-chip .chip-icon {
  font-size: 18px;
}

.fallback-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
  animation: fallback-pulse 1.5s ease-in-out 2;
}

@keyframes fallback-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(251, 191, 36, 0);
  }
}

.fallback-banner {
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
}

/* Debug panel */
.debug-toggle {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text2);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
}

.debug-toggle.active {
  background: var(--zong-pink-light);
  border-color: var(--zong-pink);
  color: var(--zong-pink-dark);
}

.debug-panel {
  position: fixed;
  top: 52px;
  right: 0;
  width: 380px;
  height: calc(100vh - 52px);
  background: #0d0f14;
  border-left: 1px solid #2a2d36;
  z-index: 200;
  display: none;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
}

.debug-panel.visible {
  display: flex;
}

.debug-header {
  padding: 12px 16px;
  border-bottom: 1px solid #2a2d36;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.debug-header-title {
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debug-header button {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
}

.debug-header button:hover {
  color: #fff;
}

.debug-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--zong-green) transparent;
}

.debug-body::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.debug-body::-webkit-scrollbar-thumb {
  background: var(--zong-green);
  border-radius: 4px;
}

.debug-body::-webkit-scrollbar-thumb:hover {
  background: var(--zong-green-dark);
}

.debug-section-label {
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  margin-top: 14px;
}

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

.debug-turn {
  background: #161922;
  border: 1px solid #2a2d36;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 12px;
}

.debug-turn-role {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.debug-turn-role.user {
  color: var(--zong-pink);
}

.debug-turn-role.assistant {
  color: var(--zong-green);
}

.debug-turn-content {
  color: #d1d5db;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 100px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--zong-green) transparent;
}

.debug-turn-content::-webkit-scrollbar {
  width: 5px;
  background: transparent;
}

.debug-turn-content::-webkit-scrollbar-thumb {
  background: var(--zong-green);
  border-radius: 3px;
}

.debug-empty {
  color: #6b7280;
  font-size: 12px;
  text-align: center;
  padding: 20px 0;
}

.debug-raw {
  background: #161922;
  border: 1px solid #2a2d36;
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  color: #9ca3af;
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--zong-green) transparent;
}

.debug-raw::-webkit-scrollbar {
  width: 5px;
  background: transparent;
}

.debug-raw::-webkit-scrollbar-thumb {
  background: var(--zong-green);
  border-radius: 3px;
}

.debug-copy-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #2a2d36;
  background: #161922;
  color: #9ca3af;
  cursor: pointer;
  margin-top: 6px;
}

.debug-copy-btn:hover {
  color: #fff;
  border-color: #3a3d46;
}

/* From Uiverse.io by andrew-demchenk0 */
.error {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  /* width: 320px; */
  padding: 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: start;
  background: #EF665B;
  border-radius: 8px;
  box-shadow: 0px 0px 5px -3px #111;
}

.error__icon {
  width: 20px;
  height: 20px;
  transform: translateY(-2px);
  margin-right: 8px;
}

.error__icon path {
  fill: #fff;
}

.error__title {
  font-weight: 500;
  font-size: 14px;
  color: #fff;
}

.error__close {
  width: 20px;
  height: 20px;
  cursor: pointer;
  margin-left: auto;
}

.error__close path {
  fill: #fff;
}

/* The same notification box used for login/OTP feedback, but with a green
   success treatment for "OTP sent/reset successfully" instead of the red
   error look. */
.success {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  padding: 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: start;
  background: #4caf50;
  border-radius: 8px;
  box-shadow: 0px 0px 5px -3px #111;
}

.success .error__icon path {
  fill: #fff;
}

.success .error__title {
  color: #fff;
}

.success .error__close path {
  fill: #fff;
}

.logout-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 5px 12px;
  border-radius: 10px;

  font-size: 14px;
  font-weight: 600;
  font-family: Arial, sans-serif;
  text-decoration: none;

  color: #ffffff;
  background: linear-gradient(135deg, #8dc63f, #6aa82f);

  border: none;
  cursor: pointer;

  transition: all 0.25s ease-in-out;

  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.logout-toggle:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #7ab833, #5f9628);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

.logout-toggle:active {
  transform: translateY(0px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.logout-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(141, 198, 63, 0.4);
}

.stats-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 1px 4px rgba(20, 20, 30, 0.04);
}

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

.stats-title-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.stats-title {
  font-size: 14px;
  font-weight: 700;
  color: #1a1d23;
  letter-spacing: -0.01em;
  text-transform: none;
}

.stats-usage-ratio {
  font-size: 13px;
  font-weight: 500;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}

.usage-progress {
  width: 100%;
  height: 6px;
  margin-top: 0;
  background: #eceef2;
  border-radius: 999px;
  overflow: hidden;
}

.usage-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s ease, background 0.3s ease;
  background: var(--zong-pink);
}

.stats-usage-percent {
  display: block;
  font-size: 11px;
  color: var(--text3);
  text-align: right;
  margin-top: 4px;
  font-weight: 500;
}

.icon-btn-stats {
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text3);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.icon-btn-stats:hover {
  background: var(--zong-green-light);
  color: var(--zong-green-dark);
}

.icon-btn-stats.spinning i {
  animation: spin 0.7s linear infinite;
}

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

/* ===== Theme toggle (navbar) ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  margin-right: 10px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-size: 16px;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--zong-green);
}

.theme-toggle i {
  font-size: 18px;
  line-height: 1;
}

.theme-toggle .theme-toggle-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .theme-toggle-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .theme-toggle-moon {
  display: inline-block;
}

/* ===== Dark-mode contrast fixes for hardcoded colors ===== */
[data-theme="dark"] .navbar,
[data-theme="dark"] .sidebar,
[data-theme="dark"] .settings-menu {
  box-shadow: 0 4px 14px -10px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] body {
  background-color: var(--bg);
  color: var(--text);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--text3);
}

/* Chat/tag chips that use hardcoded blue/purple/green accents */
[data-theme="dark"] .badge-blue,
[data-theme="dark"] [style*="background: #dbeafe"] {
  background: #1e3a5f !important;
  color: #93c5fd !important;
}

/* Error state contrast */
[data-theme="dark"] .error,
[data-theme="dark"] .form-error {
  background: #3a1a1a;
  color: #fca5a5;
}

/* Chat column (new-chat / empty-state background) uses hardcoded #fafbfc */
[data-theme="dark"] .chat-col {
  background: var(--bg);
}

/* Model card logos ship as PNGs with white/light backgrounds. In dark mode
   the transparent card surface would swallow dark logo artwork, so give the
   image a light plate to keep every logo legible. */
[data-theme="dark"] .model-card-image {
  background: #eef1f5;
  border-color: var(--border);
}

/* Login page override — force light theme, its design is background-image driven */
[data-theme="dark"] body.login-page {
  color-scheme: light;
}

/* Stats card (Tokens box in sidebar) */
[data-theme="dark"] .stats-card {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .stats-title {
  color: var(--text);
}

[data-theme="dark"] .stats-usage-ratio {
  color: var(--text2);
}

[data-theme="dark"] .usage-progress {
  background: var(--surface2);
}

/* Clear All Chats — hover + text + fill visible on dark */
[data-theme="dark"] .settings-delete {
  color: #f87171;
}

[data-theme="dark"] .settings-delete svg {
  color: #f87171;
}

[data-theme="dark"] .settings-delete:hover {
  background: rgba(248, 113, 113, 0.15);
}

[data-theme="dark"] .settings-delete::before {
  background-color: rgba(248, 113, 113, 0.28);
}

/* Sidebar MoMA tagline ("Mixture of Models and Agent Platform") */
[data-theme="dark"] .sidebar-moma-brand-tagline {
  color: var(--text);
}

/* Code block styling in dark mode */
[data-theme="dark"] .code-block-wrapper {
  border-color: var(--code-border);
  background: var(--code-bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .code-block-toolbar {
  background: var(--code-toolbar-bg);
  border-bottom: 1px solid var(--code-border);
}

[data-theme="dark"] .code-block-lang {
  color: var(--code-lang-color);
}

[data-theme="dark"] .code-block-copy {
  color: var(--code-copy-btn);
}

[data-theme="dark"] .code-block-copy:hover {
  background: var(--code-copy-hover);
  color: var(--code-toolbar-text);
}

[data-theme="dark"] .code-block-copy.copied {
  color: var(--code-lang-color);
  background: rgba(165, 217, 90, 0.15);
}

[data-theme="dark"] .msg.assistant .msg-bubble pre {
  background: var(--code-bg);
}

[data-theme="dark"] .msg.assistant .msg-bubble pre code {
  color: var(--code-text);
}

[data-theme="dark"] .msg.assistant .msg-bubble code:not(pre code) {
  background: #222733;
  color: #e6edf3;
  border: 1px solid #2d3340;
}

/* ===== Toast notifications ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: start;
  gap: 0 12px;
  padding: 16px 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow:
    0 12px 40px rgba(26, 29, 35, 0.12),
    0 4px 12px rgba(26, 29, 35, 0.06);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateX(28px) scale(0.98);
  transition:
    opacity 0.32s ease,
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast--visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.toast--leaving {
  opacity: 0;
  transform: translateX(28px) scale(0.98);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.toast__accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
}

.toast--success .toast__accent {
  background: linear-gradient(180deg, var(--zong-green), var(--zong-green-dark));
}

.toast--error .toast__accent {
  background: linear-gradient(180deg, #f87171, #dc2626);
}

.toast--warning .toast__accent {
  background: linear-gradient(180deg, #fbbf24, #d97706);
}

.toast--info .toast__accent {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.toast__icon {
  grid-row: 1 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
}

.toast--success .toast__icon {
  color: var(--zong-green-dark);
  background: var(--zong-green-light);
}

.toast--error .toast__icon {
  color: #b91c1c;
  background: #fef2f2;
}

.toast--warning .toast__icon {
  color: #b45309;
  background: #fffbeb;
}

.toast--info .toast__icon {
  color: #1d4ed8;
  background: #eff6ff;
}

.toast__icon .ti {
  font-size: 20px;
  line-height: 1;
}

.toast__content {
  min-width: 0;
  padding-top: 2px;
}

.toast__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}

.toast__message {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text2);
  word-break: break-word;
}

.toast__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: -4px -4px 0 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.toast__close:hover {
  background: var(--surface2);
  color: var(--text);
}

.toast__close .ti {
  font-size: 16px;
}

.toast__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  transform-origin: left center;
  transform: scaleX(1);
  animation: toast-progress linear forwards;
}

.toast--success .toast__progress {
  background: linear-gradient(90deg, var(--zong-green), var(--zong-green-dark));
}

.toast--error .toast__progress {
  background: linear-gradient(90deg, #f87171, #dc2626);
}

.toast--warning .toast__progress {
  background: linear-gradient(90deg, #fbbf24, #d97706);
}

.toast--info .toast__progress {
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}

@keyframes toast-progress {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}