:root {
  --sidebar: #f7f7f8;
  --sidebar-hover: #ececef;
  --canvas: #ffffff;
  --soft: #f6f6f7;
  --line: #e7e7e9;
  --line-strong: #d9d9dd;
  --text: #202123;
  --muted: #6f7075;
  --faint: #9a9b9f;
  --dark: #202123;
  --dark-hover: #343541;
  --accent: #10a37f;
  --accent-soft: #e8f7f2;
  --danger: #c2413b;
  --danger-soft: #fff0ef;
  --warning: #9a6700;
  --warning-soft: #fff8db;
  --shadow: 0 16px 50px rgba(0, 0, 0, .14);
  --sidebar-width: 260px;
  --content-width: 768px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

::selection {
  background: rgba(16, 163, 127, .18);
}

.ui-icon {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text);
  font-size: 14px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  transition: transform .1s ease, filter .12s ease, opacity .12s ease;
  touch-action: manipulation;
}

button:not(:disabled):active {
  transform: translateY(1px) scale(.985);
  filter: brightness(.97);
}

button.is-busy {
  cursor: progress;
  opacity: .78;
}

button.is-busy::after {
  width: .85em;
  height: .85em;
  display: inline-block;
  margin-left: .5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  vertical-align: -.12em;
  animation: button-busy-spin .65s linear infinite;
}

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

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 8px 13px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.btn:hover {
  background: var(--soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.message-action:focus-visible,
.conversation-open:focus-visible,
.conversation-delete:focus-visible,
.auth-tab:focus-visible,
.image-link:focus-visible {
  outline: 3px solid rgba(16, 163, 127, .22);
  outline-offset: 2px;
}

.btn.primary {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.btn.primary:hover {
  background: var(--dark-hover);
}

#serviceRetry {
  width: 100%;
}

.btn.danger {
  border-color: #efc7c4;
  color: var(--danger);
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 20px;
}

.icon-btn:hover {
  background: var(--sidebar-hover);
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #8b8c91;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
}

.textarea {
  resize: vertical;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: #4e4f53;
  font-size: 13px;
  font-weight: 650;
}

.helper {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.status-line {
  min-height: 21px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.status-line.error {
  color: var(--danger);
}

.status-line.success {
  color: #08775d;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 50% 0, rgba(16, 163, 127, .07), transparent 34%),
    #f7f7f8;
}

.gate-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 28px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .08);
}

.gate-logo {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 15px;
  border-radius: 18px;
  object-fit: cover;
  background: transparent;
  box-shadow: 0 8px 22px rgba(64, 45, 100, .14);
}

.gate-card h1,
.gate-card h2 {
  margin: 0;
  text-align: center;
  font-size: 24px;
  letter-spacing: -.5px;
}

.gate-copy {
  margin: 9px 0 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 12px;
  background: var(--soft);
}

.auth-tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 9px;
  cursor: pointer;
  color: var(--muted);
}

.auth-tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .08);
}

.auth-form {
  display: grid;
  gap: 13px;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.remember-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--dark);
}

.pending-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 24px;
  font-weight: 800;
}

.pending-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.app-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  background: var(--canvas);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid #eeeeef;
}

.sidebar-head,
.new-chat,
.search-wrap,
.history-label,
.sidebar-foot {
  flex: 0 0 auto;
}

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

.brand {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 7px;
  font-weight: 750;
  letter-spacing: -.2px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 11px;
  background: transparent;
  object-fit: cover;
  box-shadow: 0 2px 9px rgba(64, 45, 100, .13);
}

.brand-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.brand-version {
  border: 1px solid #ded4f5;
  border-radius: 999px;
  background: #f3effc;
  padding: 2px 6px;
  color: #7656a8;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1px;
}

.new-chat {
  margin: 3px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, .72);
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .025);
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.new-chat:hover {
  border-color: #cacacf;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .045);
}

.search-wrap {
  position: relative;
  margin: 0 12px 8px;
}

.search-wrap::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-52%);
  width: 14px;
  height: 14px;
  border: 1.7px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-wrap::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 23px;
  width: 5px;
  height: 1.7px;
  border-radius: 999px;
  background: var(--muted);
  transform: rotate(45deg);
  transform-origin: left center;
  pointer-events: none;
}

.history-search {
  width: 100%;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, .68);
  padding: 8px 10px 8px 34px;
  outline: none;
}

.history-search:focus {
  border-color: var(--line-strong);
  background: #fff;
}

.history-label {
  padding: 9px 18px 6px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .4px;
}

.conversation-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 0 8px 12px;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #c1c2c7 transparent;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 2px;
  align-items: center;
  border-radius: 10px;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--sidebar-hover);
}

.conversation-open,
.conversation-delete {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.conversation-open {
  min-width: 0;
  padding: 10px 9px;
  text-align: left;
}

.conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #35363a;
  font-size: 13px;
}

.conversation-time {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 10px;
}

.conversation-delete {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  opacity: 0;
  color: var(--muted);
}

.conversation-item:hover .conversation-delete,
.conversation-item:focus-within .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  background: rgba(255, 255, 255, .65);
  color: var(--danger);
}

.history-empty {
  padding: 22px 14px;
  color: var(--faint);
  text-align: center;
  font-size: 12px;
  line-height: 1.65;
}

.sidebar-foot {
  min-height: 0;
  padding: 10px;
  border-top: 1px solid #e5e5e5;
  display: grid;
  gap: 7px;
}

.sidebar-wallet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid #abefc6;
  border-radius: 10px;
  background: linear-gradient(135deg, #f0fdf4, #f8fffb);
  padding: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 2px 8px rgba(8, 116, 67, .04);
}

.sidebar-wallet-item {
  min-width: 0;
}

.sidebar-wallet-item + .sidebar-wallet-item {
  border-left: 1px solid #c9efda;
  padding-left: 7px;
}

.sidebar-wallet-item span {
  display: block;
  color: #66758d;
  font-size: 10px;
  font-weight: 800;
}

.sidebar-wallet-item strong {
  display: block;
  margin-top: 3px;
  color: #087443;
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.image-link,
.account-button {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}

.image-link:hover,
.account-button:hover {
  background: var(--sidebar-hover);
}

.side-icon,
.account-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 15px;
}

.account-avatar {
  border: 0;
  border-radius: 50%;
  background: #dcdde0;
  color: #46474b;
  font-weight: 800;
}

.side-copy,
.account-copy {
  min-width: 0;
  flex: 1;
}

.side-copy strong,
.account-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.side-copy span,
.account-copy span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.main {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  --composer-height: 142px;
  background:
    radial-gradient(ellipse at 52% 44%, rgba(16, 163, 127, .025), transparent 37%),
    var(--canvas);
}

.topbar {
  position: relative;
  z-index: 6;
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 7px 16px;
  border-bottom: 1px solid rgba(229, 229, 229, .75);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}

.mobile-menu {
  display: none;
  grid-column: 1;
  justify-self: start;
}

.model-control {
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.model-native-select {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.model-picker-button {
  max-width: 190px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--soft);
  padding: 0 9px 0 8px;
  color: #343541;
  font-weight: 650;
  outline: none;
  cursor: pointer;
  font-size: 12px;
}

.model-picker-button:hover,
.model-picker-button[aria-expanded="true"] {
  background: #ececee;
}

.model-picker-button:focus-visible,
.model-picker-menu:focus-visible {
  box-shadow: 0 0 0 3px rgba(16, 163, 127, .14);
}

.model-picker-button:disabled {
  cursor: not-allowed;
  opacity: .56;
}

.model-picker-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-picker-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .14s ease;
}

.model-picker-button[aria-expanded="true"] .model-picker-chevron {
  transform: rotate(180deg);
}

.model-provider-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #fff;
  color: #292a2e;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: -.7px;
}

.model-provider-icon svg {
  width: 13px;
  height: 13px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-provider-icon .provider-brand-image {
  display: block;
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.model-provider-icon.gemini {
  color: #4a4d50;
}

.model-provider-icon.gemini svg {
  fill: none;
  stroke: none;
}

.model-provider-icon.anthropic {
  background: #fff;
  color: #d97757;
}

.model-provider-icon.xai {
  color: #42464a;
  background: #fff;
}

.model-provider-icon.deepseek {
  color: #3568f4;
  background: #fff;
}

.model-picker-menu {
  width: min(310px, calc(100vw - 24px));
  max-height: min(440px, 60vh);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 45;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .98);
  padding: 7px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .17);
  backdrop-filter: blur(16px);
}

.model-picker-group + .model-picker-group {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--line);
}

.model-picker-group-label {
  padding: 6px 9px 4px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .04em;
}

.model-picker-option {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  padding: 6px 9px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.model-picker-option:hover,
.model-picker-option:focus-visible,
.model-picker-option[aria-selected="true"] {
  background: var(--soft);
  outline: none;
}

.model-picker-option-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.model-picker-check {
  width: 17px;
  flex: 0 0 17px;
  color: var(--accent);
  text-align: center;
  font-weight: 850;
}

.topbar-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 7px;
}

.messages-viewport {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #b8b9bd transparent;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

:is(.messages-viewport, .conversation-list)::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

:is(.messages-viewport, .conversation-list)::-webkit-scrollbar-track {
  background: transparent;
}

:is(.messages-viewport, .conversation-list)::-webkit-scrollbar-thumb {
  min-height: 48px;
  border: 3px solid transparent;
  border-radius: 999px;
  background: #bfc0c5;
  background-clip: padding-box;
}

:is(.messages-viewport, .conversation-list)::-webkit-scrollbar-thumb:hover {
  background-color: #919298;
}

.messages {
  width: min(var(--content-width), calc(100% - 32px));
  min-height: 100%;
  margin: 0 auto;
  padding: 20px 0 calc(var(--composer-height) + 20px);
}

.welcome {
  min-height: calc(100vh - 206px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 16px 0 38px;
}

.welcome-mark {
  width: 72px;
  height: 72px;
  display: block;
  border-radius: 22px;
  object-fit: cover;
  background: transparent;
  box-shadow: 0 12px 28px rgba(64, 45, 100, .15);
}

.welcome h1 {
  margin: 16px 0 5px;
  font-size: clamp(24px, 2.5vw, 30px);
  letter-spacing: -1px;
}

.welcome p {
  max-width: 540px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.message-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 0;
}

.message-row.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.message-body {
  min-width: 0;
  width: 100%;
}

.message-row.user .message-body {
  width: fit-content;
  max-width: min(78%, 650px);
}

.message-avatar {
  width: 30px;
  height: 30px;
  display: block;
  border-radius: 10px;
  object-fit: cover;
  background: transparent;
  box-shadow: 0 2px 8px rgba(64, 45, 100, .12);
}

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

.message-row.user .message-bubble {
  width: 100%;
  max-width: 100%;
  border-radius: 18px;
  background: var(--soft);
  padding: 11px 15px;
}

.message-row.message-failed .message-bubble {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 1px rgba(194, 65, 59, .22);
}

.message-row.message-failed .message-actions::before {
  margin-right: 5px;
  color: var(--danger);
  content: "发送失败，内容已恢复到输入框";
  font-size: 11px;
}

.message-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 7px;
  margin-bottom: 9px;
}

.message-image {
  width: 100%;
  max-height: 220px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  object-fit: cover;
}

.message-image-placeholder {
  min-height: 84px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  text-align: center;
}

.message-documents {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 240px));
  gap: 7px;
  margin-bottom: 9px;
}

.message-document {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .78);
  padding: 8px 10px;
}

.message-document-badge {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eeeef2;
  color: #5d5e64;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: -.02em;
}

.message-document-details {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.message-document-details strong {
  overflow: hidden;
  color: #34353a;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-document-details span {
  color: var(--faint);
  font-size: 10px;
}

.message-content {
  color: #2f3034;
  font-size: 15px;
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.message-content > :first-child {
  margin-top: 0;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content :is(h1, h2, h3, h4, h5, h6) {
  margin: 1.2em 0 .5em;
  color: #25262a;
  line-height: 1.35;
}

.message-content h1 { font-size: 1.55em; }
.message-content h2 { font-size: 1.35em; }
.message-content h3 { font-size: 1.18em; }
.message-content :is(h4, h5, h6) { font-size: 1em; }

.message-content p {
  margin: .7em 0;
}

.message-content :is(ul, ol) {
  margin: .65em 0;
  padding-left: 1.55em;
}

.message-content li + li {
  margin-top: .25em;
}

.message-content blockquote {
  margin: .85em 0;
  border-left: 3px solid #d6d6da;
  padding: .15em 0 .15em 1em;
  color: #66676c;
}

.message-content hr {
  height: 1px;
  margin: 1.25em 0;
  border: 0;
  background: var(--line);
}

.message-content :not(pre) > code {
  border-radius: 5px;
  background: #f0f0f2;
  padding: .12em .36em;
  color: #33343a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .9em;
}

.markdown-table-wrap {
  max-width: 100%;
  margin: .9em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.55;
}

.message-content :is(th, td) {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.message-content th {
  background: #f6f6f7;
  font-weight: 750;
}

.message-content tr:last-child td {
  border-bottom: 0;
}

.message-content :is(th, td):last-child {
  border-right: 0;
}

.markdown-link {
  display: inline-flex;
  max-width: 100%;
  align-items: baseline;
  gap: 5px;
  color: #2f6f9f;
  vertical-align: baseline;
}

.markdown-link-url {
  max-width: min(420px, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #66717a;
  font-size: .86em;
}

.markdown-copy-link {
  border: 0;
  border-radius: 6px;
  background: #eef3f6;
  padding: 2px 6px;
  color: #456474;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
}

.message-content.streaming-text,
.plain-segment {
  white-space: pre-wrap;
}

.plain-segment + .plain-segment {
  margin-top: 10px;
}

.reasoning {
  margin: 0 0 12px;
  border-left: 2px solid var(--line-strong);
  padding-left: 12px;
  color: var(--muted);
  font-size: 13px;
}

.reasoning summary {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 5px;
  list-style: none;
  cursor: pointer;
  color: #65666b;
  font-weight: 650;
  user-select: none;
}

.reasoning summary::-webkit-details-marker {
  display: none;
}

.reasoning summary::before {
  content: "›";
  font-size: 16px;
  line-height: 1;
  transition: transform .15s ease;
}

.reasoning[open] summary::before {
  transform: rotate(90deg);
}

.reasoning-text {
  margin-top: 8px;
  white-space: pre-wrap;
  line-height: 1.65;
}

.code-block {
  margin: 13px 0;
  overflow: hidden;
  border: 1px solid #2e3034;
  border-radius: 11px;
  background: #1f2023;
  color: #f4f4f4;
}

.code-head {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px 7px 13px;
  border-bottom: 1px solid #34363b;
  background: #292a2e;
  color: #b9bbc0;
  font-size: 11px;
}

.code-copy {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #d7d8dc;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 11px;
}

.code-copy:hover {
  background: #3a3c41;
}

.code-block pre {
  margin: 0;
  overflow-x: auto;
  padding: 14px;
  scrollbar-width: thin;
}

.code-block code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.62;
  white-space: pre;
  tab-size: 2;
}

.message-meta {
  min-height: 18px;
  margin-top: 7px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}

.message-meta.error {
  color: var(--danger);
}

.turn-cost {
  margin-top: 7px;
  color: #8b8c91;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.turn-cost.fallback-route {
  color: #7b5c12;
  font-weight: 600;
}

.message-actions {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  opacity: .52;
  transition: opacity .15s ease;
}

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

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

.message-action {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
  color: #74757a;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}

.message-action:hover {
  background: #ececee;
  color: #333439;
}

.message-action:active {
  transform: scale(.94);
}

.message-action.copied {
  background: var(--accent-soft);
  color: #08775d;
}

.message-action-icon {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thinking-indicator {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #6e6f74;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.thinking-summary {
  margin: 0 0 7px;
  color: #8b8c91;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #77787d;
  animation: thinking-pulse 1.15s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes thinking-pulse {
  0%, 65%, 100% { opacity: .28; transform: translateY(0); }
  32% { opacity: 1; transform: translateY(-2px); }
}

.typing-dot::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  border-radius: 2px;
  background: #727378;
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.composer-dock {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 28%, #fff);
  padding: 30px 16px max(13px, env(safe-area-inset-bottom));
}

.scroll-to-bottom {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: calc(var(--composer-height) + 8px);
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .96);
  color: #505157;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .1);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, opacity .16s ease;
}

.scroll-to-bottom:hover {
  transform: translateX(-50%) translateY(1px);
  background: #f6f6f7;
}

.edit-message-banner {
  min-height: 34px;
  margin: -1px -2px 7px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f4f0fc;
  padding: 6px 9px 6px 11px;
  color: #62458e;
  font-size: 11px;
}

.edit-message-banner button {
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, .72);
  padding: 4px 7px;
  color: inherit;
  cursor: pointer;
}

.composer {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  pointer-events: auto;
}

.composer-box {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: #fff;
  padding: 8px 9px 8px 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .075), 0 1px 3px rgba(0, 0, 0, .04);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.composer-dock.dragging-attachments .composer-box {
  border-color: var(--accent);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .09), 0 0 0 4px rgba(16, 163, 127, .11);
}

.attachment-drop-hint {
  position: absolute;
  inset: 6px;
  z-index: 9;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(16, 163, 127, .56);
  border-radius: 16px;
  background: rgba(242, 252, 249, .96);
  color: #087d62;
  font-size: 13px;
  font-weight: 650;
  pointer-events: none;
}

.composer-box:focus-within {
  border-color: #c6c6ca;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .09), 0 0 0 3px rgba(16, 163, 127, .055);
}

.attachment-tray {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 1px 7px;
  scrollbar-width: thin;
}

.attachment-item {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
}

.attachment-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.attachment-item.document {
  width: 242px;
  flex-basis: 242px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 31px 8px 9px;
  background: #fafafa;
}

.attachment-document-icon {
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #ececf0;
  color: #595a60;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: -.03em;
}

.attachment-document-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.attachment-document-copy strong,
.attachment-document-copy > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-document-copy strong {
  color: #37383c;
  font-size: 11px;
  font-weight: 650;
}

.attachment-document-meta {
  color: var(--faint);
  font-size: 9px;
}

.attachment-document-meta.error {
  color: var(--danger);
}

.attachment-retry {
  position: absolute;
  right: 27px;
  bottom: 5px;
  border: 0;
  border-radius: 6px;
  background: var(--danger-soft);
  padding: 2px 5px;
  color: var(--danger);
  cursor: pointer;
  font-size: 9px;
}

.attachment-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(24, 25, 28, .82);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.composer-input {
  width: 100%;
  max-height: 190px;
  min-height: 31px;
  overflow-y: hidden;
  border: 0;
  resize: none;
  outline: none;
  background: transparent;
  padding: 5px 3px 7px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

.composer-input::placeholder {
  color: #98999e;
}

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-tool-group {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.composer-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tool-button,
.prompt-preset-select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #56575c;
  font-size: 12px;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  cursor: pointer;
}

.tool-button:hover,
.prompt-preset-select:hover {
  background: var(--soft);
}

.prompt-preset-select {
  min-width: 0;
  max-width: 180px;
  padding: 0 28px 0 10px;
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
}

.search-toggle {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  padding: 5px 9px;
  cursor: pointer;
  color: #56575c;
  font-size: 12px;
  user-select: none;
}

.search-toggle[hidden] {
  display: none;
}

.search-toggle:has(input:checked) {
  border-color: #a9ded0;
  background: var(--accent-soft);
  color: #08775d;
}

.search-toggle:has(input:focus-visible) {
  outline: 2px solid rgba(16, 163, 127, .34);
  outline-offset: 2px;
}

.search-toggle:has(input:disabled) {
  cursor: not-allowed;
  opacity: .56;
}

.search-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a3a4a8;
}

.search-toggle:has(input:checked) .toggle-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, .12);
}

.send-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--dark);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  line-height: 1;
  transition: background .12s ease, transform .1s ease, filter .12s ease;
}

.send-btn:hover {
  background: var(--dark-hover);
}

.send-btn:disabled {
  background: #d7d7d9;
  cursor: not-allowed;
}

.send-btn.stop {
  font-size: 13px;
}

.composer-note {
  margin: 6px 0 0;
  color: var(--faint);
  text-align: center;
  font-size: 10px;
}

.scrim {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 22px;
  background: rgba(24, 24, 27, .42);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, .7);
}

.modal-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  min-height: 0;
  overflow-y: auto;
  padding: 17px;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.settings-section {
  display: grid;
  gap: 12px;
}

.settings-section + .settings-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h3 {
  margin: 0;
  font-size: 15px;
}

.preset-list {
  display: grid;
  gap: 8px;
}

.preset-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.preset-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 11px 12px;
}

.preset-card.active {
  border-color: #a9ded0;
  background: var(--accent-soft);
}

.preset-copy {
  min-width: 0;
}

.preset-copy strong,
.preset-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-copy strong {
  font-size: 13px;
}

.preset-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.preset-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.preset-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 11px;
}

.preset-action.primary {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.preset-action.danger {
  border-color: #efb9b9;
  background: #fff4f4;
  color: #b42318;
}

.preset-editor {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--soft);
  padding: 13px;
}

.preset-editor .textarea {
  min-height: 150px;
  line-height: 1.6;
}

.preset-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.parameter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.parameter-field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 10px;
}

.parameter-field > span {
  color: #3f4045;
  font-size: 12px;
  font-weight: 750;
}

.parameter-field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 0 9px;
  outline: none;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.parameter-field input:focus {
  border-color: #9dcfc3;
  box-shadow: 0 0 0 3px rgba(16, 163, 127, .08);
}

.parameter-help {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.parameter-capability-note {
  border-radius: 9px;
  background: #f5f3fa;
  padding: 8px 10px;
  color: #685b79;
  font-size: 11px;
  line-height: 1.55;
}

.parameter-modal {
  width: min(580px, 100%);
}

.parameter-custom-fields {
  display: grid;
  gap: 10px;
  margin-top: 13px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  z-index: 120;
  top: 70px;
  right: 18px;
  max-width: min(460px, calc(100vw - 32px));
  transform: translateY(-10px);
  border-radius: 11px;
  background: #25262a;
  color: #fff;
  padding: 10px 14px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  font-size: 13px;
  line-height: 1.5;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

@media (max-width: 760px) {
  :root {
    --content-width: 100%;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: 14px 0 38px rgba(0, 0, 0, .13);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .scrim {
    position: fixed;
    z-index: 45;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, .28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.sidebar-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .topbar {
    min-height: 58px;
    padding: 7px 9px;
  }

  .model-picker-button {
    max-width: min(148px, 42vw);
  }

  .topbar-settings {
    display: none;
  }

  .messages {
    width: calc(100% - 24px);
    padding-top: 14px;
    padding-bottom: calc(var(--composer-height) + 14px);
  }

  .message-row {
    gap: 10px;
    padding: 14px 0;
  }

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

  .composer-dock {
    left: 0;
    padding: 28px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer-box {
    border-radius: 21px;
  }

  .welcome {
    min-height: calc(100vh - 210px);
  }

  .composer-tool-group {
    width: 100%;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    gap: 5px;
  }

  .composer-tools {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .composer-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 5px;
  }

  .search-toggle > span:last-child {
    display: none;
  }

  .prompt-preset-select {
    max-width: 126px;
  }

  .tool-button span {
    display: none;
  }

  .message-images {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .message-documents {
    grid-template-columns: minmax(0, 1fr);
  }

  .attachment-item.document {
    width: 218px;
    flex-basis: 218px;
  }

  .parameter-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
  }

  .gate-card {
    padding: 23px 20px;
  }

  .toast {
    top: 68px;
    right: 12px;
    max-width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
