:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d1d1f;
  background: #f5f5f7;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-height: 100vh; }
button, select, textarea { font: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
}
.sidebar {
  background: #ececf0;
  padding: 18px;
  border-right: 1px solid #d8d8dc;
}
.brand { font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.new-chat {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.section-label {
  margin-top: 22px;
  font-size: 12px;
  color: #6e6e73;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.empty { margin-top: 10px; color: #8e8e93; font-size: 14px; }

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  background: #fff;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 22px;
  border-bottom: 1px solid #e5e5e7;
}
.toolbar h1 { margin: 0; font-size: 20px; }
.toolbar p { margin: 3px 0 0; color: #8e8e93; font-size: 12px; }
.controls { margin-left: auto; display: flex; gap: 8px; }
.controls select {
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px;
}
.messages {
  min-height: 0;
  overflow: auto;
  padding: 28px max(24px, calc((100vw - 900px) / 2));
}
.welcome { max-width: 720px; margin: 12vh auto 0; text-align: center; }
.welcome h2 { font-size: 30px; margin-bottom: 8px; }
.welcome p { color: #6e6e73; }

.message-row {
  display: flex;
  width: min(780px, 100%);
  margin: 0 auto 18px;
}
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }
.message-bubble {
  max-width: min(680px, 88%);
  white-space: pre-wrap;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f2f2f7;
}
.message-row.user .message-bubble {
  background: #1d1d1f;
  color: #fff;
}
.message-row.pending .message-bubble {
  color: #6e6e73;
}
.message-row.error .message-bubble {
  color: #b42318;
  background: #fff1f0;
}

.composer {
  width: min(780px, calc(100% - 32px));
  margin: 0 auto 18px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: end;
  border: 1px solid #d2d2d7;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,.06);
}
.composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 180px;
  resize: vertical;
  border: 0;
  outline: none;
  padding: 10px;
}
.composer button {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  background: #1d1d1f;
  color: #fff;
}
.composer button:disabled { opacity: .5; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .toolbar { align-items: flex-start; flex-wrap: wrap; }
  .controls { width: 100%; margin-left: 0; }
  .controls select { flex: 1; min-width: 0; }
  .messages { padding: 22px 16px; }
}

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

.chat-list-empty {
  color: #8e8e93;
  font-size: 13px;
  padding: 4px 2px;
}

.chat-item {
  border-radius: 10px;
  padding: 4px;
}

.chat-item.active {
  background: rgba(0, 0, 0, 0.06);
}

.chat-select {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 7px 8px;
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.chat-select:hover {
  background: rgba(0, 0, 0, 0.05);
}

.chat-actions {
  display: flex;
  gap: 4px;
  padding: 0 6px 4px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.chat-item:hover .chat-actions,
.chat-item.active .chat-actions {
  opacity: 1;
}

.chat-action {
  border: 0;
  background: transparent;
  color: #6e6e73;
  font-size: 11px;
  padding: 2px 4px;
  cursor: pointer;
}

.chat-action:hover {
  text-decoration: underline;
}

.chat-action.danger {
  color: #b42318;
}

.stop-button {
  border: 1px solid #d0d0d5;
  background: #fff;
  color: #1d1d1f;
}

.message-row.streaming .message-bubble::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  animation: stream-cursor 0.8s steps(1) infinite;
}

.message-row.stopped .message-bubble::after {
  content: " · stopped";
  color: #8e8e93;
  font-size: 12px;
}

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

/* M6J fixed-viewport chat layout:
   the browser page itself does not scroll; the conversation pane does. */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
}

.shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.chat-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.workspace {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.toolbar {
  flex: 0 0 auto;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.composer {
  flex: 0 0 auto;
  position: relative;
  bottom: auto;
  z-index: 10;
  background: #fff;
}

@media (max-width: 760px) {
  .shell,
  .workspace {
    height: 100dvh;
  }
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
}

.message-action {
  border: 0;
  background: transparent;
  color: #6e6e73;
  font-size: 12px;
  padding: 2px 0;
  cursor: pointer;
}

.message-action:hover {
  text-decoration: underline;
}

/* M6K message content/action layout */
.message-content {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: 72%;
}

.message-content .message-bubble {
  max-width: 100%;
}

.message-row.assistant .message-content {
  margin-right: auto;
  align-items: flex-start;
}

.message-row.user .message-content {
  margin-left: auto;
  align-items: flex-end;
}

.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
}

.message-action.icon-action {
  width: 30px;
  height: 30px;
  padding: 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6e6e73;
  cursor: pointer;
}

.message-action.icon-action:hover {
  background: rgba(0, 0, 0, 0.06);
}

.message-action.icon-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-row.assistant .message-actions {
  justify-content: flex-start;
}

.message-row.user .message-actions {
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .message-content {
    max-width: 88%;
  }
}

/* M6K reference-style action glyphs */
.message-action.icon-action {
  width: 28px;
  height: 28px;
  padding: 4px;
  color: #5f6368;
  border-radius: 7px;
}

.message-action.icon-action svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.55;
}

.message-actions {
  gap: 2px;
  margin-top: 6px;
}

/* M6L web research sources */
.research-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: min(760px, 100%);
}

.research-sources-label {
  flex-basis: 100%;
  font-size: 12px;
  color: #777;
}

.research-source {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 999px;
  color: #555;
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-source:hover {
  border-color: #aaa;
  color: #222;
}


/* Research runtime progress */
.research-progress {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px 2px;
  font-size: 12px;
  line-height: 1.4;
  color: #777;
}

.research-progress::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
  animation: research-progress-pulse 1.2s ease-in-out infinite;
}

.research-progress[hidden] {
  display: none;
}

@keyframes research-progress-pulse {
  0%, 100% { opacity: .3; transform: scale(.9); }
  50% { opacity: .8; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .research-progress::before {
    animation: none;
  }
}


/* Research result reading layout v4 */
.message-row.research-result {
  width: min(920px, 100%);
  margin-left: auto;
  margin-right: auto;
  justify-content: flex-start;
}

.message-row.research-result .message-content {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.message-row.research-result .message-bubble {
  width: 100%;
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  white-space: normal;
  color: #1d1d1f;
  font-size: 15px;
  line-height: 1.72;
}

.message-row.research-result .message-bubble p {
  margin: 0 0 15px;
}

.message-row.research-result .message-bubble p:last-child {
  margin-bottom: 0;
}

.message-row.research-result .message-bubble h2,
.message-row.research-result .message-bubble h3,
.message-row.research-result .message-bubble h4 {
  margin: 24px 0 10px;
  line-height: 1.3;
}

.message-row.research-result .message-bubble h2 { font-size: 21px; }
.message-row.research-result .message-bubble h3 { font-size: 18px; }
.message-row.research-result .message-bubble h4 { font-size: 16px; }

.message-row.research-result .message-bubble ul,
.message-row.research-result .message-bubble ol {
  margin: 10px 0 17px 1.35em;
  padding: 0;
}

.message-row.research-result .message-bubble li {
  margin: 7px 0;
}

.message-row.research-result .message-bubble strong {
  font-weight: 650;
}

.message-row.research-result .message-bubble code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(127, 127, 127, .12);
}

.research-sources {
  margin-top: 24px;
  padding-top: 15px;
  border-top: 1px solid rgba(0, 0, 0, .1);
}

.research-sources-label {
  margin-bottom: 8px;
  color: #6e6e73;
  font-size: 12px;
  font-weight: 600;
}

.research-source-list {
  display: grid;
  gap: 2px;
}

.research-source {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 7px;
  margin: 0 -8px;
  padding: 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.research-source:hover {
  background: rgba(0, 0, 0, .045);
}

.research-source-index {
  color: #86868b;
  font-size: 12px;
}

.research-source-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.research-source-title {
  overflow: hidden;
  color: #343437;
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-source-host {
  color: #8e8e93;
  font-size: 11px;
}

.research-sources.is-collapsed .research-source:nth-child(n+5) {
  display: none;
}

.research-sources-toggle {
  margin-top: 7px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: #6e6e73;
  font-size: 12px;
  cursor: pointer;
}

.research-sources-toggle:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.composer {
  width: min(920px, calc(100% - 32px));
}

.chat-item.active .chat-actions {
  opacity: 0;
}

.chat-item.active:hover .chat-actions,
.chat-item.active:focus-within .chat-actions {
  opacity: 1;
}

@media (max-width: 760px) {
  .message-row.research-result {
    width: 100%;
  }

  .message-row.research-result .message-bubble {
    font-size: 14px;
    line-height: 1.66;
  }

  .composer {
    width: calc(100% - 20px);
  }
}


/* Research layout v4.1 viewport refinement */
.messages {
  padding-left: clamp(24px, 4vw, 72px);
  padding-right: clamp(24px, 4vw, 72px);
  padding-bottom: 150px;
}

.message-row.research-result {
  width: min(920px, 100%);
}

.message-row.research-result .message-content {
  width: 100%;
}

@media (min-width: 1200px) {
  .message-row.research-result,
  .composer {
    width: min(920px, calc(100% - 48px));
  }
}

@media (max-width: 760px) {
  .messages {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 130px;
  }
}


/* Research layout v4.2 width refinement */
.message-row.research-result {
  width: min(780px, 100%);
}

.composer {
  width: min(780px, calc(100% - 32px));
}

@media (min-width: 1200px) {
  .message-row.research-result,
  .composer {
    width: min(780px, calc(100% - 48px));
  }
}

@media (max-width: 820px) {
  .message-row.research-result {
    width: 100%;
  }

  .composer {
    width: calc(100% - 24px);
  }
}

@media (max-width: 760px) {
  .composer {
    width: calc(100% - 20px);
  }
}


/* Research sources compact v4.3 */
.research-sources {
  margin-top: 18px;
  padding-top: 12px;
}

.research-sources-label {
  margin-bottom: 6px;
}

.research-source-list {
  gap: 4px;
}

.research-source {
  min-width: 0;
}

.research-source-compact {
  display: none;
}

.research-sources.is-collapsed .research-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.research-sources.is-collapsed .research-source {
  display: inline-flex;
  width: auto;
  max-width: 220px;
  grid-template-columns: none;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 999px;
  background: rgba(0, 0, 0, .025);
}

.research-sources.is-collapsed .research-source:nth-child(n+4) {
  display: none;
}

.research-sources.is-collapsed .research-source-copy {
  display: none;
}

.research-sources.is-collapsed .research-source-compact {
  display: block;
  max-width: 145px;
  overflow: hidden;
  color: #55555a;
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-sources.is-collapsed .research-source-index {
  flex: 0 0 auto;
  font-size: 11px;
}

.research-sources-toggle {
  margin-top: 5px;
  padding: 2px 0;
  font-size: 11px;
}

.research-sources:not(.is-collapsed) .research-source-compact {
  display: none;
}

@media (max-width: 760px) {
  .research-sources.is-collapsed .research-source {
    max-width: 180px;
  }

  .research-sources.is-collapsed .research-source-compact {
    max-width: 110px;
  }
}


/* Research sources hide URLs v4.4 */
.research-source-host {
  display: none;
}

.research-sources.is-collapsed .research-source-compact {
  max-width: 170px;
}


/* Message timestamps v4.5.1 */
.message-meta {
  display: flex;
  margin-top: 5px;
  min-height: 14px;
}

.message-time {
  color: #9a9a9f;
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
}

.message-row.user .message-meta {
  justify-content: flex-end;
  padding-right: 3px;
}

.message-row.assistant .message-meta {
  justify-content: flex-start;
  padding-left: 2px;
}

.message-row.research-result .message-meta {
  margin-top: 8px;
  padding-left: 0;
}

@media (max-width: 760px) {
  .message-time {
    font-size: 9px;
  }
}


/* Message timestamps visibility v4.6 */
.message-meta {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  overflow: visible !important;
  margin-top: 6px;
  min-height: 16px;
}

.message-time {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: #6e6e73;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.message-row.user .message-meta {
  justify-content: flex-end;
}

.message-row.assistant .message-meta {
  justify-content: flex-start;
}

.message-row.research-result .message-meta {
  margin-top: 10px;
}


/* Message timestamps deterministic v4.8 */
.message-meta {
  display: flex !important;
  width: 100%;
  margin-top: 7px !important;
  min-height: 16px !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.message-time {
  display: inline-block !important;
  color: #74747a !important;
  font-size: 11px !important;
  line-height: 1.4 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.message-row.user .message-meta {
  justify-content: flex-end !important;
}

.message-row.assistant .message-meta {
  justify-content: flex-start !important;
}

.message-row.research-result .message-meta {
  margin-top: 9px !important;
}

.mobile-sidebar-close-v3 {
  display: none;
}

/* MOBILE_SIDEBAR_DRAWER_V1 */
.mobile-sidebar-toggle {
  display: none;
}

.mobile-sidebar-overlay {
  display: none;
}

@media (max-width: 820px) {
  .mobile-menu-host {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    color: inherit;
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    z-index: 1202;
  }

  .mobile-sidebar-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }

  .mobile-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1198;
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(1px);
  }

  body.mobile-sidebar-open {
    overflow: hidden;
  }

  body.mobile-sidebar-open .mobile-sidebar-overlay {
    display: block;
  }
}

/* MOBILE_SIDEBAR_TOGGLE_POSITION_V2 */
@media (max-width: 820px) {
  .mobile-menu-host {
    position: relative;
  }

  .mobile-sidebar-toggle {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    left: 14px !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 14px !important;
    background: rgba(255, 255, 255, 0.98) !important;
    z-index: 1203 !important;
  }

  body:not(.mobile-sidebar-open) .mobile-sidebar-toggle {
    transform: translateY(52px);
  }

  body.mobile-sidebar-open .mobile-sidebar-toggle {
    transform: none;
  }
}

/* MOBILE_SIDEBAR_CONTROLS_V3 */
@media (max-width: 820px) {
  .mobile-menu-host {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
  }

  .mobile-sidebar-toggle {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    margin: 0 0 0 auto !important;
    border-radius: 12px !important;
    z-index: auto !important;
  }

  body.mobile-sidebar-open .mobile-sidebar-toggle {
    display: none !important;
  }

  .mobile-sidebar-close-v3 {
    display: none;
  }

  body.mobile-sidebar-open .mobile-sidebar-close-v3 {
    display: inline-flex;
    position: absolute;
    top: 14px;
    right: 14px;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    color: inherit;
    font: inherit;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    z-index: 1204;
    -webkit-tap-highlight-color: transparent;
  }
}

/* MOBILE_SIDEBAR_TOGGLE_LEFT_V4 */
@media (max-width: 820px) {
  .mobile-menu-host {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
  }

  .mobile-sidebar-toggle {
    order: -1 !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    position: static !important;
    transform: none !important;
  }

  .mobile-menu-host > h1,
  .mobile-menu-host > h2 {
    margin-left: 0 !important;
  }
}


/* Account System v1 */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(245, 245, 247, 0.94);
  backdrop-filter: blur(14px);
}
.auth-overlay[hidden] { display: none; }

.auth-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border: 1px solid #d2d2d7;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.14);
  padding: 28px;
}
.auth-brand {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.auth-tab {
  border: 1px solid #d2d2d7;
  background: #f5f5f7;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
}
.auth-tab.active {
  background: #111;
  color: #fff;
  border-color: #111;
}
.auth-form {
  display: grid;
  gap: 14px;
}
.auth-form[hidden] { display: none; }
.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
.auth-form input,
.auth-form select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #c7c7cc;
  border-radius: 9px;
  background: #fff;
  padding: 10px 11px;
  font: inherit;
}
.usage-purpose {
  border: 1px solid #e1e1e5;
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}
.usage-purpose legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
}
.usage-purpose label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 400;
}
.usage-purpose input { width: auto; }
.auth-primary {
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  background: #111;
  color: #fff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.auth-primary:disabled { opacity: .55; cursor: default; }
.auth-error {
  min-height: 18px;
  color: #b42318;
  font-size: 13px;
}
.auth-note {
  color: #666;
  font-size: 12px;
  line-height: 1.45;
}
.account-panel {
  margin: 10px 0 16px;
  padding: 10px;
  border: 1px solid #dedee3;
  border-radius: 10px;
  background: rgba(255,255,255,.72);
}
.account-panel[hidden] { display: none; }
.account-name {
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-email {
  margin-top: 2px;
  color: #6e6e73;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-logout {
  margin-top: 8px;
  border: 0;
  padding: 0;
  background: none;
  color: #555;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
@media (max-width: 700px) {
  .auth-grid { grid-template-columns: 1fr; }
  .usage-purpose { grid-template-columns: 1fr; }
  .auth-card { padding: 20px; }
}


/* Account System v1.1 — account identity at sidebar bottom. */
.sidebar .account-panel {
  margin-top: auto;
  margin-bottom: 0;
  flex: 0 0 auto;
}
/* Account System v1.2 — pin account card to the true bottom of the sidebar. */
.shell > .sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  box-sizing: border-box;
}

.shell > .sidebar .chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.shell > .sidebar .account-panel {
  margin-top: auto;
  margin-bottom: 0;
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .shell > .sidebar {
    display: none;
  }
}


.account-admin-link {
  display: inline-block;
  margin-right: 10px;
  color: inherit;
  font-size: 12px;
  text-decoration: underline;
}

.account-admin-link[hidden] {
  display: none;
}


/* CrossBorder AI brand mark */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  display: block;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}


/* Guest upgrade banner v1 */
.guest-upgrade-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 14px 18px 0;
  padding: 12px 16px;
  border: 1px solid #d9e6ff;
  border-radius: 12px;
  background: linear-gradient(90deg, #f6f9ff 0%, #f3fbff 100%);
  box-shadow: 0 1px 4px rgba(20, 50, 90, 0.06);
}

.guest-upgrade-banner[hidden] {
  display: none !important;
}

.guest-upgrade-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
}

.guest-upgrade-copy strong {
  font-size: 14px;
}

.guest-upgrade-copy span {
  color: #56606f;
}

.guest-upgrade-action {
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  padding: 9px 14px;
  background: #15171a;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.guest-upgrade-action:hover {
  opacity: 0.9;
}

@media (max-width: 720px) {
  .guest-upgrade-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin: 10px 12px 0;
  }

  .guest-upgrade-action {
    width: 100%;
  }
}
/* Account System v1.3-C — account preferences + application locale. */
.account-settings {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.account-settings-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.account-settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
}

.account-settings-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.account-settings-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.account-settings-header h2,
.account-settings-header p {
  margin: 0;
}

.account-settings-header p {
  margin-top: 4px;
  color: #666;
}

.account-settings-close {
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.account-settings-form label {
  display: grid;
  gap: 7px;
  font-weight: 600;
}

.account-settings-form select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #d8d8dc;
  border-radius: 9px;
  background: #fff;
  font: inherit;
}

.account-settings-models {
  display: grid;
  gap: 14px;
  padding-top: 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.account-settings-section-header {
  display: grid;
  gap: 4px;
  padding-top: 14px;
}

.account-settings-section-header h3,
.account-settings-section-header p {
  margin: 0;
}

.account-settings-section-header h3 {
  font-size: 15px;
}

.account-settings-section-header p {
  color: #666;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
}

.account-settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.account-settings-actions button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid #d8d8dc;
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.account-settings-actions .account-settings-save {
  border-color: #111;
  background: #111;
  color: #fff;
}

.account-settings-error {
  color: #a40000;
  font-size: 13px;
}


/* V13C_ACCOUNT_MENU_REFACTOR */

.account-panel {
  position: relative;
  width: 100%;
}

.account-trigger {
  appearance: none;
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.account-trigger:hover,
.account-trigger:focus-visible {
  background: rgba(0, 0, 0, 0.055);
}

.account-trigger:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.18);
  outline-offset: -2px;
}

.account-trigger-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
}

.account-trigger-chevron {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
  opacity: 0.55;
  transform: rotate(-90deg);
}

.account-trigger[aria-expanded="true"] .account-trigger-chevron {
  transform: rotate(90deg);
}

.account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 50;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(18px);
}

.account-menu[hidden] {
  display: none !important;
}

.account-menu-identity {
  padding: 8px 10px 9px;
}

.account-menu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.account-menu .account-email {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  opacity: 0.58;
}

.account-menu-separator {
  height: 1px;
  margin: 4px 6px;
  background: rgba(0, 0, 0, 0.08);
}

.account-menu-item {
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
  background: rgba(0, 0, 0, 0.055);
}

.account-menu-item:focus-visible {
  outline: none;
}

.account-menu .account-logout {
  color: inherit;
}
/* V13C_ACCOUNT_MENU_VISUAL_POLISH */

/*
 * The account menu refactor intentionally reuses the existing account
 * selectors. Neutralize legacy card spacing here and keep this block after
 * the earlier account-system styles so the sidebar entry remains lightweight.
 */

.sidebar .account-panel {
  margin: 6px 0 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.sidebar .account-trigger {
  min-height: 40px;
  padding: 7px 9px;
  gap: 8px;
  border-radius: 8px;
}

.sidebar .account-trigger:hover,
.sidebar .account-trigger:focus-visible {
  background: rgba(0, 0, 0, 0.045);
}

.sidebar .account-trigger:focus-visible {
  outline: 1px solid rgba(0, 0, 0, 0.14);
  outline-offset: -1px;
}

.sidebar .account-trigger-name {
  font-size: 13px;
  font-weight: 560;
}

.sidebar .account-trigger-chevron {
  font-size: 15px;
  opacity: 0.38;
}

.sidebar .account-menu {
  left: 2px;
  right: 2px;
  bottom: calc(100% + 5px);
  padding: 4px;
  border-color: rgba(0, 0, 0, 0.085);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.985);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.09),
    0 1px 4px rgba(0, 0, 0, 0.045);
  backdrop-filter: blur(12px);
}

.sidebar .account-menu-identity {
  padding: 7px 8px 6px;
}

.sidebar .account-menu-name {
  font-size: 13px;
  font-weight: 590;
}

.sidebar .account-menu .account-email {
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.52;
}

.sidebar .account-menu-separator {
  margin: 3px 4px;
  background: rgba(0, 0, 0, 0.065);
}

.sidebar .account-menu-item {
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 13px;
}

.sidebar .account-menu-item:hover,
.sidebar .account-menu-item:focus-visible {
  background: rgba(0, 0, 0, 0.045);
}

/* Neutralize legacy account styles that are still valid elsewhere. */
.sidebar .account-menu .account-admin-link {
  margin-right: 0;
}

.sidebar .account-menu .account-settings {
  margin: 0;
}

.sidebar .account-menu .account-logout {
  margin-top: 0;
}

/* Keep hidden menu entries hidden even when legacy display rules exist. */
.sidebar .account-menu .account-admin-link[hidden],
.sidebar .account-menu .account-settings[hidden],
.sidebar .account-menu .account-logout[hidden] {
  display: none !important;
}

/* v1.3-E4 BYOK account settings */
.account-settings-byok {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.account-settings-byok-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 24px;
}

.account-settings-byok-status-row strong {
  font-size: 13px;
  font-weight: 600;
}

.account-settings-byok-key-row {
  display: grid;
  gap: 7px;
}

.account-settings-byok-key-row input {
  box-sizing: border-box;
  width: 100%;
}

.account-settings-byok-hint {
  margin: -3px 0 0;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.62;
}

.account-settings-byok-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-settings-byok-save,
.account-settings-byok-remove {
  min-height: 36px;
}

.account-settings-byok-remove:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Phase 4F-4 WeCom web unlink */
.account-settings-wecom-unlink {
  display: flex;
  justify-content: flex-start;
}

.account-settings-wecom-unlink[hidden] {
  display: none !important;
}

.account-settings-wecom-unlink-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d8d8dc;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.account-settings-wecom-unlink-button:disabled {
  opacity: 0.45;
  cursor: default;
}


/* V13E3B_GENERIC_PROVIDER_SETTINGS_UI */

.account-settings-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  overflow: auto;
}

.account-settings-form input {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #d8d8dc;
  border-radius: 9px;
  background: #fff;
  font: inherit;
}

.account-settings-providers {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.account-settings-providers-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.account-settings-providers-header > div {
  min-width: 0;
}

.account-settings-provider-add,
.account-settings-provider-editor-actions button,
.account-settings-provider-card-actions button,
.account-settings-provider-credential-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d8d8dc;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.account-settings-provider-add {
  flex: 0 0 auto;
}

.account-settings-provider-list {
  display: grid;
  gap: 10px;
}

.account-settings-provider-empty {
  margin: 0;
  padding: 14px;
  border: 1px dashed rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  font-size: 13px;
  opacity: 0.62;
}

.account-settings-provider-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.015);
}

.account-settings-provider-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.account-settings-provider-identity {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.account-settings-provider-name {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.account-settings-provider-credential-status {
  font-size: 12px;
  opacity: 0.62;
}

.account-settings-provider-card-actions,
.account-settings-provider-credential-actions,
.account-settings-provider-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-settings-provider-card-actions {
  flex: 0 0 auto;
}

.account-settings-provider-delete {
  opacity: 0.72;
}

.account-settings-provider-meta {
  display: grid;
  gap: 6px;
}

.account-settings-provider-meta-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.28fr) minmax(0, 1fr);
  gap: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.account-settings-provider-meta-label {
  opacity: 0.55;
}

.account-settings-provider-meta-value {
  overflow-wrap: anywhere;
}

.account-settings-provider-credential {
  display: grid;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.account-settings-provider-credential-label {
  font-size: 13px;
  font-weight: 600;
}

.account-settings-provider-credential-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.62;
}

.account-settings-provider-credential-actions button:disabled,
.account-settings-provider-editor-actions button:disabled {
  cursor: default;
  opacity: 0.45;
}

.account-settings-provider-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
}

.account-settings-provider-editor[hidden] {
  display: none !important;
}

.account-settings-provider-editor-heading {
  font-size: 14px;
}

.account-settings-provider-editor-actions {
  justify-content: flex-end;
}

.account-settings-provider-editor-save {
  border-color: #111 !important;
  background: #111 !important;
  color: #fff !important;
}

.account-settings-error[data-kind="success"] {
  color: inherit;
}

@media (max-width: 620px) {
  .account-settings-providers-header,
  .account-settings-provider-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .account-settings-provider-add {
    width: 100%;
  }

  .account-settings-provider-card-actions button {
    flex: 1 1 auto;
  }

  .account-settings-provider-meta-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .account-settings-provider-editor-actions button,
  .account-settings-provider-credential-actions button {
    flex: 1 1 auto;
  }
}


/* V13E3C_CUSTOM_MODEL_SETTINGS_UI */

.account-settings-custom-models {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.account-settings-custom-models-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.account-settings-custom-models-header > div {
  min-width: 0;
}

.account-settings-custom-model-add,
.account-settings-custom-model-card-actions button,
.account-settings-custom-model-editor-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d8d8dc;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.account-settings-custom-model-add {
  flex: 0 0 auto;
}

.account-settings-custom-model-add:disabled {
  cursor: default;
  opacity: 0.45;
}

.account-settings-custom-model-list {
  display: grid;
  gap: 10px;
}

.account-settings-custom-model-empty {
  margin: 0;
  padding: 14px;
  border: 1px dashed rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  font-size: 13px;
  opacity: 0.62;
}

.account-settings-custom-model-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.015);
}

.account-settings-custom-model-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.account-settings-custom-model-identity {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.account-settings-custom-model-name {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.account-settings-custom-model-upstream {
  overflow-wrap: anywhere;
  font-size: 12px;
  opacity: 0.62;
}

.account-settings-custom-model-card-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.account-settings-custom-model-delete {
  opacity: 0.72;
}

.account-settings-custom-model-capability-summary {
  font-size: 12px;
  opacity: 0.66;
}

.account-settings-custom-model-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
}

.account-settings-custom-model-editor[hidden] {
  display: none !important;
}

.account-settings-custom-model-editor-heading {
  font-size: 14px;
}

.account-settings-custom-model-capabilities {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 10px;
}

.account-settings-custom-model-capabilities legend {
  padding: 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.account-settings-custom-model-capability {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: auto !important;
}

.account-settings-custom-model-capability input {
  width: auto !important;
  min-height: auto !important;
  margin: 0;
}

.account-settings-custom-model-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.account-settings-custom-model-editor-save {
  border-color: #111 !important;
  background: #111 !important;
  color: #fff !important;
}

.account-settings-custom-model-editor-save:disabled {
  cursor: default;
  opacity: 0.45;
}

@media (max-width: 620px) {
  .account-settings-custom-models-header,
  .account-settings-custom-model-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .account-settings-custom-model-add {
    width: 100%;
  }

  .account-settings-custom-model-card-actions button,
  .account-settings-custom-model-editor-actions button {
    flex: 1 1 auto;
  }
}

/* GUEST_LOCALE_A2_MANUAL_OVERRIDE */

.sidebar .account-menu-language {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 13px;
}

.sidebar .account-menu-language[hidden] {
  display: none !important;
}

.sidebar .account-menu-language > span {
  opacity: 0.62;
}

.sidebar .account-menu-language select {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: right;
  cursor: pointer;
}


/* UX2B_VISUAL_POLISH */

.toolbar {
  min-height: 68px;
  padding: 12px 20px;
  gap: 16px;
  background: rgba(255, 255, 255, 0.94);
}

.toolbar-brand {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.toolbar-brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 680;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.toolbar-brand-alias {
  margin: 0;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f1f3;
  color: #202124;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 520;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls .mode-select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 96px;
  height: 36px;
  padding: 0 34px 0 13px;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 11px;
  outline: 0;
  background-color: #f7f7f8;
  background-image:
    linear-gradient(45deg, transparent 50%, #6e6e73 50%),
    linear-gradient(135deg, #6e6e73 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 15px,
    calc(100% - 12px) 15px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  color: #252528;
  font-size: 13px;
  font-weight: 560;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.controls .mode-select:hover {
  background-color: #f1f1f3;
  border-color: rgba(0, 0, 0, 0.13);
}

.controls .mode-select:focus-visible {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.055);
}

.controls .mode-select:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (max-width: 760px) {
  .toolbar {
    min-height: 60px;
    padding: 10px 14px;
    align-items: center;
    flex-wrap: nowrap;
  }

  .toolbar-brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 7px;
  }

  .toolbar-brand h1 {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .toolbar-brand-alias {
    flex: 0 0 auto;
    padding: 2px 6px;
    font-size: 14px;
    font-weight: 520;
  }

  .controls {
    width: auto;
    margin-left: auto;
    flex: 0 0 auto;
  }

  .controls .mode-select {
    min-width: 82px;
    max-width: 132px;
    height: 34px;
    padding-left: 11px;
    padding-right: 30px;
    font-size: 12px;
  }
}


/* UX2C_BRAND_ALIAS_POLISH */


/* UX2D_YUEJIE_BRAND_BADGE */


/* MOBILE_DYNAMIC_VIEWPORT_FIX
   iOS Safari resolves 100vh against the large viewport.
   Use the dynamic viewport when supported so document height
   matches the actually visible viewport after keyboard changes. */
@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  }
}


/* UX3A_MOBILE_READING_POLISH */
@media (max-width: 760px) {
  .welcome {
    margin: 8vh auto 0;
  }

  .welcome h2 {
    font-size: 26px;
    margin-bottom: 7px;
  }

  .welcome p {
    font-size: 14px;
    line-height: 1.5;
  }

  .message-bubble {
    font-size: 15px;
    line-height: 1.66;
  }

  .research-source-compact {
    font-size: 12px;
    line-height: 1.35;
  }
}


/* UX3B_PROMPT_CHIPS_AND_CONTENT_WIDTH */
.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.prompt-chip {
  appearance: none;
  border: 1px solid #d8d8dc;
  border-radius: 999px;
  background: #ffffff;
  color: #343438;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease;
}

.prompt-chip:hover {
  background: #f5f5f7;
  border-color: #c8c8cc;
}

.prompt-chip:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .message-row.assistant .message-content {
    max-width: 94%;
  }

  .message-row.user .message-content {
    max-width: 88%;
  }

  .prompt-chips {
    gap: 7px;
    margin-top: 16px;
    padding: 0 4px;
  }

  .prompt-chip {
    padding: 8px 11px;
    font-size: 12px;
  }
}

/* Phase 3D — WeChat customer-service entry */
.wecom-entry-wrap {
  margin-top: 10px;
}

.wecom-entry {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 12px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.wecom-entry:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.18);
}

.wecom-entry:active {
  transform: translateY(1px);
}

.wecom-entry-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #07c160;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.wecom-entry-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.wecom-entry-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.wecom-entry-copy small {
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.62;
}

.wecom-entry-dialog {
  width: min(390px, calc(100vw - 28px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
}

.wecom-entry-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
}

.wecom-dialog-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 26px 26px 22px;
  border-radius: 18px;
  background: #fff;
  color: #111827;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  text-align: center;
}

.wecom-dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.wecom-dialog-brand {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.wecom-dialog-card h2 {
  margin: 0;
  font-size: 20px;
}

.wecom-dialog-card p {
  margin: 0;
  color: #64748b;
  font-size: 14px;
}

.wecom-dialog-qr {
  width: 210px;
  height: 210px;
  max-width: 70vw;
  max-height: 70vw;
  border-radius: 10px;
}

.wecom-dialog-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  background: #07c160;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.wecom-dialog-note {
  max-width: 290px;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.4;
}

@media (max-width: 700px) {
  .wecom-entry-copy small {
    display: none;
  }
}

/* Phase 4D-2: WeChat Customer Service account linking */
.account-settings-wecom {
  display: grid;
  gap: 14px;
  padding-top: 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.account-settings-wecom-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 38px;
}

.account-settings-wecom-status-row > span {
  font-size: 13px;
  font-weight: 600;
}

.account-settings-wecom-status-row strong {
  font-size: 13px;
  font-weight: 600;
}

.account-settings-wecom-status-row strong[data-linked="true"] {
  color: #16794a;
}

.account-settings-wecom-link {
  display: grid;
  gap: 10px;
}

.account-settings-wecom-link[hidden] {
  display: none;
}

.account-settings-wecom-link input {
  width: 100%;
  box-sizing: border-box;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #d8d8dc;
  border-radius: 9px;
  background: #fff;
  font: inherit;
}

.account-settings-wecom-actions {
  display: flex;
  justify-content: flex-end;
}

.account-settings-wecom-submit {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #111;
  border-radius: 9px;
  background: #111;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.account-settings-wecom-submit:disabled {
  opacity: 0.55;
  cursor: default;
}

.account-settings-wecom-message {
  margin: 0;
  color: #16794a;
  font-size: 13px;
  line-height: 1.4;
}

.account-settings-wecom-message.is-error {
  color: #a40000;
}

/* Phase 4G-1G: ephemeral browser image preview */
.cb-image-preview[hidden], .cb-image-select[hidden] { display: none !important; }
.cb-image-preview { width: min(780px, calc(100% - 32px)); margin: 0 auto 8px; padding: 8px 12px; background: #f5f5f7; border-radius: 12px; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.cb-image-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.cb-image-preview span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cb-image-preview button { padding: 6px 10px; cursor: pointer; }
.composer .cb-image-select { padding: 10px 12px; white-space: nowrap; }


/* Phase 4G-1G Mac attachment icon alignment */

form.composer button.mac-attachment-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  margin: 0 2px 4px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #77777c;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 120ms ease,
              color 120ms ease;
}

form.composer button.mac-attachment-button:hover {
  background: #f1f1f3;
  color: #343438;
}

form.composer button.mac-attachment-button:focus-visible {
  outline: 2px solid #77777c;
  outline-offset: 2px;
}

form.composer button.mac-attachment-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

form.composer button.mac-attachment-button svg {
  display: block;
  width: 19px;
  height: 19px;
  pointer-events: none;
}

/* Phase 7A-54: owner's ChatGPT plan connection */
.account-settings-chatgpt[hidden],
.account-settings-chatgpt [hidden] {
  display: none !important;
}

.account-settings-chatgpt-actions {
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.account-settings-chatgpt-steps {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.account-settings-chatgpt-open {
  font-size: 13px;
  font-weight: 600;
}
