/* ==========================================================================
   Calopic browser chat
   ========================================================================== */
.chat-page {
  min-height: 100vh;
  background:
    radial-gradient(720px 380px at 70% -10%, rgba(232, 112, 42, 0.06), transparent 70%),
    var(--bg);
}

.chat-page .site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--glass-strong);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
}

.chat-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

/* --------------------------------------------------------------------------
   Auth
   -------------------------------------------------------------------------- */
.chat-auth {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 150px);
  padding: 40px 0;
}

.auth-card {
  width: min(440px, 100%);
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  box-shadow: var(--glass-shadow);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card h1 {
  margin-top: 26px;
  font-size: clamp(24px, 3.4vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.auth-sub {
  margin-top: 9px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.65;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.auth-form .field {
  display: block;
}

.auth-form .input {
  width: 100%;
  height: 44px;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-message {
  min-height: 18px;
  margin-top: 2px;
  color: #e7a79e;
  font-size: 12.5px;
  line-height: 1.5;
}

.auth-message[data-kind="success"] {
  color: var(--success);
}

.auth-switch {
  width: 100%;
  margin-top: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-switch:hover {
  color: var(--accent);
}

.auth-verify {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(232, 112, 42, 0.28);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Chat layout
   -------------------------------------------------------------------------- */
.chat-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  height: calc(100vh - 128px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  box-shadow: var(--glass-shadow);
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
  border-inline-end: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.08);
}

.chat-sidebar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 12px;
}

.chat-sidebar-head .btn {
  flex: 1;
}

.chat-sidebar-close {
  display: none;
}

.chat-sidebar-label {
  padding: 4px 8px 7px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chat-conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.chat-conversation {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  text-align: start;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.chat-conversation:hover {
  color: var(--text);
  background: var(--surface);
}

.chat-conversation.active {
  color: var(--text);
  border-color: var(--stroke);
  background: var(--surface-2);
}

.chat-conversation-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  color: var(--text-faint);
}

.chat-conversation-icon svg {
  width: 12px;
  height: 12px;
}

.chat-conversation-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.chat-conversation-title {
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conversation-time {
  color: var(--text-faint);
  font-size: 10px;
}

.chat-list-empty {
  padding: 14px 10px;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
}

.chat-list-empty strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text-dim);
  font-weight: 600;
}

.chat-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--stroke);
}

.chat-balance {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  color: var(--text-faint);
  font-size: 10.5px;
}

.chat-balance strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chat-account .btn {
  flex: 1;
}

.chat-signout {
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
}

.chat-signout:hover {
  color: var(--accent);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--stroke);
}

.chat-menu {
  display: none;
}

.chat-title-block {
  min-width: 0;
}

.chat-title-block h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chat-title-block span {
  display: block;
  overflow: hidden;
  max-width: 620px;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-api-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: auto;
  padding: 5px 9px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 550;
}

.chat-api-link:hover {
  color: var(--accent);
  border-color: rgba(232, 112, 42, 0.35);
}

.chat-api-link svg {
  width: 12px;
  height: 12px;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px clamp(14px, 4vw, 46px) 16px;
  scroll-behavior: smooth;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 20px;
  text-align: center;
}

.chat-empty img {
  opacity: 0.9;
  filter: drop-shadow(0 8px 22px rgba(232, 112, 42, 0.24));
}

.chat-empty h3 {
  margin-top: 16px;
  font-size: 19px;
  font-weight: 600;
}

.chat-empty p {
  max-width: 360px;
  margin-top: 7px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.chat-message {
  display: flex;
  gap: 9px;
  max-width: 760px;
  margin-bottom: 18px;
}

.chat-message.user {
  margin-inline-start: auto;
  justify-content: flex-end;
}

.chat-message-avatar {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: none;
  margin-top: 2px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-faint);
  font-size: 8px;
  font-weight: 700;
}

.chat-message.assistant .chat-message-avatar {
  background: var(--accent-soft);
}

.chat-message-body {
  min-width: 0;
  padding: 9px 13px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.7;
}

.chat-message.user .chat-message-body {
  border-end-end-radius: 4px;
  background: var(--accent-soft);
  border-color: rgba(232, 112, 42, 0.22);
}

.chat-message.assistant .chat-message-body {
  border-end-start-radius: 4px;
}

.chat-message-body p {
  margin: 0 0 9px;
}

.chat-message-body p:last-child {
  margin-bottom: 0;
}

.chat-message-body strong {
  color: var(--text);
  font-weight: 600;
}

.chat-message-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--well);
  color: #e8a87c;
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.chat-message-body pre {
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid var(--stroke);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
}

.chat-message-body pre code {
  display: block;
  padding: 12px;
  background: transparent;
  color: #d8d8de;
  font-size: 11.5px;
  line-height: 1.65;
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  border-bottom: 1px solid var(--stroke);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.copy-code {
  padding: 2px 6px;
  border: 1px solid var(--stroke);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 9.5px;
}

.copy-code:hover {
  color: var(--accent);
  border-color: rgba(232, 112, 42, 0.35);
}

.chat-message-error {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(217, 107, 94, 0.35);
  border-radius: 8px;
  background: rgba(217, 107, 94, 0.1);
  color: #e8a99f;
  font-size: 12px;
}

.chat-insufficient {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(232, 112, 42, 0.3);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 12px;
}

.chat-composer {
  margin: 0 clamp(14px, 4vw, 46px);
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--glass-shadow);
}

.chat-input {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 160px;
  resize: vertical;
  padding: 4px 4px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  outline: none;
}

.chat-input::placeholder {
  color: var(--text-faint);
}

.chat-composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-mode-label {
  padding: 3px 8px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-pill);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 600;
}

.chat-send {
  margin-inline-start: auto;
  height: 34px;
  padding-inline: 14px;
  font-size: 12px;
}

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

.chat-send[data-streaming="true"] {
  background: var(--surface-3);
  color: var(--text);
}

.chat-browser-note {
  padding: 9px clamp(14px, 4vw, 46px) 13px;
  color: var(--text-faint);
  font-size: 10.5px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Modal / toast
   -------------------------------------------------------------------------- */
.chat-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.chat-modal {
  width: min(520px, 100%);
  max-height: min(80vh, 700px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  background: var(--bg-soft);
  box-shadow: var(--glass-shadow-strong);
}

.chat-modal h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chat-modal p {
  margin-top: 7px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.pack-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: start;
}

.pack-option:hover {
  border-color: rgba(232, 112, 42, 0.4);
}

.pack-option strong {
  font-size: 13px;
}

.pack-option span {
  color: var(--text-faint);
  font-size: 11px;
}

.chat-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.chat-toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.chat-toast {
  max-width: 340px;
  padding: 10px 13px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  background: var(--glass-strong);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  box-shadow: var(--glass-shadow);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: auto;
}

.chat-toast[data-kind="error"] {
  border-color: rgba(217, 107, 94, 0.35);
  color: #e8a99f;
}

.chat-toast[data-kind="success"] {
  border-color: rgba(121, 181, 142, 0.35);
  color: #a8c9b3;
}

/* --------------------------------------------------------------------------
   Responsive / RTL
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .chat-app {
    grid-template-columns: minmax(0, 1fr);
    height: calc(100vh - 110px);
  }
  .chat-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 50;
    width: min(300px, 86vw);
    padding-top: 74px;
    background: var(--bg-soft);
    border-inline-end: 1px solid var(--stroke);
    transform: translateX(-102%);
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  [dir="rtl"] .chat-sidebar {
    transform: translateX(102%);
  }
  .chat-app.sidebar-open .chat-sidebar {
    transform: translateX(0);
  }
  .chat-sidebar-close,
  .chat-menu {
    display: inline-flex;
  }
  .chat-topbar {
    padding-inline: 12px;
  }
  .chat-title-block span {
    max-width: 52vw;
  }
}

@media (max-width: 560px) {
  .chat-shell {
    width: 100%;
    padding: 0;
  }
  .chat-app {
    border-radius: 0;
    border-inline: 0;
    height: calc(100vh - 64px);
  }
  .chat-auth {
    padding: 24px 16px;
  }
  .chat-messages {
    padding-inline: 14px;
  }
  .chat-composer {
    margin-inline: 10px;
  }
  .chat-browser-note {
    padding-inline: 10px;
  }
  .chat-api-link span {
    display: none;
  }
  .pack-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* Code stays LTR in RTL layouts. */
[dir="rtl"] .chat-message-body pre {
  direction: ltr;
  text-align: left;
}

/* ==========================================================================
   app.calopic.top integration (browser chat)
   ========================================================================== */
/* Browser chat has no conversation sidebar: use a single full-width column. */
.chat-app {
  grid-template-columns: minmax(0, 1fr);
}

.chat-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.chat-model-select {
  height: 30px;
  padding: 0 26px 0 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.chat-balance-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.chat-balance-pill strong {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chat-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-dim);
  transition: color 160ms ease, border-color 160ms ease;
}

.chat-icon-btn:hover {
  color: var(--accent);
  border-color: rgba(232, 112, 42, 0.35);
}

.chat-icon-btn svg {
  width: 14px;
  height: 14px;
}

.chat-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 10px clamp(14px, 4vw, 46px) 0;
  padding: 10px 13px;
  border: 1px solid rgba(217, 107, 94, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(217, 107, 94, 0.08);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}

.chat-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-banner-copy strong {
  color: #e8a99f;
  font-size: 12.5px;
}

.chat-key-setup {
  width: min(520px, 100%);
  margin: 34px auto;
  padding: 22px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--glass-shadow);
  text-align: center;
}

.chat-key-setup h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chat-key-setup p {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.65;
}

.chat-key-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}

.chat-key-note {
  margin-top: 12px;
  color: var(--text-faint) !important;
  font-size: 10.5px !important;
}

.chat-message-cost {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--stroke);
  color: var(--text-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
}

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

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

.chat-typing em {
  margin-inline-start: 6px;
  color: var(--text-faint);
  font-size: 11px;
  font-style: normal;
}

@keyframes chat-typing-bounce {
  0%,
  70%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-message-body .code-block {
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
}

.chat-message-body .code-block pre {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.chat-message-body .code-block:first-child {
  margin-top: 0;
}

.chat-message-body ul {
  margin: 6px 0;
  padding-inline-start: 20px;
}

.chat-message-body li {
  margin: 3px 0;
}

.chat-message-body h3 {
  margin: 10px 0 6px;
  font-size: 14.5px;
  font-weight: 600;
}

.chat-message-error {
  border-color: rgba(217, 107, 94, 0.35);
  background: rgba(217, 107, 94, 0.08);
}

.chat-message-error p {
  color: var(--text-dim);
}

.chat-message-error .btn {
  margin-top: 8px;
}

@media (max-width: 900px) {
  .chat-topbar {
    flex-wrap: wrap;
  }
  .chat-topbar-actions {
    width: 100%;
    margin-inline-start: 0;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .chat-model span,
  .chat-balance-pill > span:first-child {
    display: none;
  }
  .chat-topbar-actions {
    gap: 6px;
  }
  .chat-banner {
    margin-inline: 10px;
  }
  .chat-key-setup {
    margin: 18px 10px;
    padding: 18px 15px;
  }
}

/* chat-main-fix: no sidebar in the browser chat; single column, composer pinned to bottom */
.chat-app { grid-template-columns: minmax(0, 1fr); }
.chat-main { height: 100%; }
.chat-messages { flex: 1 1 auto; min-height: 0; }


/* chat-avatar-logo: assistant avatar uses the brand mark instead of letters */
.chat-message-avatar{overflow:hidden}
.chat-message-avatar img{width:100%;height:100%;object-fit:contain;display:block;padding:5px}

/* ==========================================================================
   Stop generation: the send button becomes a Stop button in the same slot.
   ========================================================================== */
.chat-send .chat-stop-icon {
  display: none;
}

.chat-send[data-mode="stop"] {
  background: #d96b5e;
  border-color: transparent;
  color: #fff;
}

.chat-send[data-mode="stop"]:hover {
  background: #c85c50;
  color: #fff;
}

.chat-send[data-mode="stop"] .chat-send-icon {
  display: none;
}

.chat-send[data-mode="stop"] .chat-stop-icon {
  display: inline-block;
}

/* Keep the stop action clickable even though the composer input is disabled. */
.chat-send[data-mode="stop"]:disabled {
  opacity: 1;
}

.chat-message-body.chat-message-stopped {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-style: dashed;
  background: transparent;
  color: var(--text-faint);
  font-size: 11.5px;
  font-style: italic;
}

.chat-message-stopped::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #d96b5e;
}

@media (max-width: 560px) {
  .chat-send[data-mode="stop"] {
    min-width: 92px;
  }
}

/* ==========================================================================
   Web search toggle + search sources list
   ========================================================================== */
.chat-composer-row .chat-websearch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: auto;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: #d6d8de;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border-color: rgba(255,255,255,.16);
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.chat-composer-row .chat-websearch svg {
  width: 13px;
  height: 13px;
  color: currentColor;
  opacity: 1;
}

/* Off state must read as an active control, not a disabled one. */
.chat-composer-row .chat-websearch:hover {
  color: var(--text);
  border-color: rgba(232, 112, 42, 0.5);
  background: var(--surface-2);
}

.chat-composer-row .chat-websearch:active {
  transform: translateY(1px);
}

/* On state: orange highlight on a light orange fill. */
.chat-composer-row .chat-websearch.is-on,
.chat-composer-row .chat-websearch[aria-pressed="true"] {
  background: rgba(232, 112, 42, 0.22);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.chat-composer-row .chat-websearch.is-on:hover,
.chat-composer-row .chat-websearch[aria-pressed="true"]:hover {
  background: rgba(232, 112, 42, 0.3);
  border-color: var(--accent);
  color: var(--accent);
}

.chat-composer-row .chat-send {
  margin-inline-start: 8px;
}

.chat-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--stroke);
}

.chat-sources-title {
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-sources-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 0;
  padding-inline-start: 16px;
}

.chat-sources-list li {
  margin: 0;
}

.chat-source-link {
  color: var(--accent);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
}

.chat-source-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-source-snippet {
  display: -webkit-box;
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

[dir="rtl"] .chat-sources-list {
  padding-inline-start: 0;
  padding-inline-end: 16px;
}

@media (max-width: 560px) {
  .chat-composer-row .chat-websearch {
    gap: 4px;
    padding: 0 8px;
    font-size: 10.5px;
  }
  .chat-composer-row .chat-websearch svg {
    width: 12px;
    height: 12px;
  }
  .chat-source-snippet {
    -webkit-line-clamp: 1;
  }
}


/* ChatGPT-style single composer pill */
.chat-composer {
  margin: 0 clamp(14px, 4vw, 46px) 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.chat-composer-shell {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 9px;
  border: 1px solid var(--stroke);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--glass-shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.chat-composer-shell:focus-within {
  border-color: rgba(232, 112, 42, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 112, 42, 0.08), var(--glass-shadow);
}

.chat-composer-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding-bottom: 1px;
}

.chat-attach,
.chat-composer .chat-websearch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.chat-attach {
  width: 34px;
  padding: 0;
}

.chat-attach svg {
  width: 18px;
  height: 18px;
}

.chat-attach:hover,
.chat-composer .chat-websearch:hover {
  background: var(--surface-2);
  color: var(--text);
}

.chat-composer .chat-websearch {
  gap: 6px;
  padding: 0 10px;
}

.chat-composer .chat-websearch svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.chat-composer .chat-websearch.is-on,
.chat-composer .chat-websearch[aria-pressed="true"] {
  border-color: rgba(232, 112, 42, 0.5);
  background: rgba(232, 112, 42, 0.14);
  color: var(--accent);
}

.chat-composer .chat-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 34px;
  max-height: 180px;
  resize: none;
  padding: 7px 5px 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  outline: none;
}

.chat-composer .chat-input::placeholder {
  color: var(--text-faint);
}

.chat-composer .chat-send {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  align-self: flex-end;
}

.chat-composer .chat-send svg {
  width: 16px;
  height: 16px;
}

.chat-composer .chat-send[data-mode="stop"] {
  border-radius: 50%;
  background: #d96b5e;
}

.chat-composer .chat-send[data-mode="stop"] .chat-send-icon {
  display: none;
}

.chat-composer .chat-send[data-mode="stop"] .chat-stop-icon {
  display: inline-block;
}

.chat-model-select {
  border-color: var(--stroke);
  background-color: var(--surface-2);
  color: var(--text);
}

.chat-topbar-actions .chat-model {
  color: var(--text-faint);
}

@media (max-width: 560px) {
  .chat-composer {
    margin-inline: 10px;
    margin-bottom: 10px;
  }
  .chat-composer-shell {
    gap: 3px;
    padding: 6px 7px;
    border-radius: 24px;
  }
  .chat-attach {
    width: 32px;
    height: 32px;
  }
  .chat-attach svg {
    width: 17px;
    height: 17px;
  }
  .chat-composer .chat-websearch {
    width: 32px;
    height: 32px;
    padding: 0;
    gap: 0;
  }
  .chat-composer .chat-websearch span {
    display: none;
  }
  .chat-composer .chat-websearch svg {
    width: 15px;
    height: 15px;
  }
  .chat-composer .chat-input {
    min-height: 32px;
    padding: 6px 4px 4px;
    font-size: 16px;
  }
  .chat-composer .chat-send {
    width: 34px;
    min-width: 34px !important;
    height: 34px;
  }
  .chat-composer .chat-send[data-mode="stop"] {
    min-width: 34px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-composer-shell,
  .chat-attach,
  .chat-composer .chat-websearch,
  .chat-composer .chat-send {
    transition: none !important;
  }
}

/* composer width/font fixes */
.chat-composer {
  display: block;
  width: auto;
  box-sizing: border-box;
}

.chat-composer-shell {
  width: 100%;
  box-sizing: border-box;
}

.chat-composer .chat-input {
  font-weight: 400;
}

@media (max-width: 900px) {
  .chat-topbar-actions .chat-model {
    order: 1;
    margin-inline-start: 8px;
  }
}

/* ==========================================================================
   Email verification (register form): send-code button + code input + hints
   ========================================================================== */
.auth-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-code-row .input {
  flex: 1;
  min-width: 0;
}

.auth-code-btn {
  flex: none;
  height: 44px;
  padding-inline: 12px;
  font-size: 12px;
  white-space: nowrap;
}

.auth-code-btn:disabled {
  opacity: 0.75;
  cursor: default;
}

.auth-code-input {
  width: 100%;
  letter-spacing: 0.18em;
  font-family: var(--font-mono);
  text-align: center;
}

.auth-hint {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(232, 112, 42, 0.28);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
}

.auth-hint[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .auth-code-row {
    flex-wrap: wrap;
  }
  .auth-code-btn {
    width: 100%;
    height: 40px;
  }
}

/* ==========================================================================
   chat-radius-pass — one consistent rounded language, no square-in-round
   ========================================================================== */
.chat-composer {
  border-radius: 20px;
  padding: 8px 10px;
}
.chat-input {
  border-radius: 14px;
  padding: 8px 8px;
  background: transparent;
}
.chat-input:focus { outline: none; }
.chat-composer-row { border-radius: 14px; }
.chat-composer-row .chat-websearch,
.chat-send,
.chat-stop { border-radius: 999px; }
.chat-msg-body { border-radius: 16px; }
.chat-bubble { border-radius: 16px; }
.chat-modal { border-radius: 20px; }
.auth-card { border-radius: 22px; }
.auth-form .input,
.auth-form input,
.auth-code-row input { border-radius: 12px; }
.btn, .btn-lg, button.btn { border-radius: 12px; }
