.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 28px 22px 18px;
}

.message-list {
  width: min(920px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty {
  margin: auto;
  padding-top: 20vh;
  color: var(--muted);
  text-align: center;
  font-size: 18px;
}

.message {
  max-width: min(76%, 720px);
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: var(--user);
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
  white-space: normal;
}

.message.assistant {
  max-width: min(86%, 820px);
}

.assistant-text-segment {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4,
.message.assistant h5,
.message.assistant h6,
.message.assistant p,
.message.assistant ul,
.message.assistant ol {
  max-width: 100%;
}

.assistant-markdown-heading {
  margin: 14px 0 8px;
  color: var(--text);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.assistant-markdown-heading:first-child {
  margin-top: 0;
}

.message.assistant h1 {
  font-size: 25px;
}

.message.assistant h2 {
  font-size: 22px;
}

.message.assistant h3 {
  font-size: 19px;
}

.message.assistant h4 {
  font-size: 17px;
}

.message.assistant h5,
.message.assistant h6 {
  font-size: 15px;
}

.assistant-markdown-paragraph {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}

.assistant-markdown-paragraph:last-child {
  margin-bottom: 0;
}

.assistant-markdown-list {
  margin: 0 0 10px;
  padding-left: 24px;
}

.assistant-markdown-list li {
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.message.assistant strong {
  font-weight: 800;
}

.message.assistant em {
  font-style: italic;
}

.assistant-inline-code {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #171615;
  color: var(--accent-hover);
  font-family: Consolas, "Courier New", monospace;
  font-size: .92em;
  overflow-wrap: anywhere;
}

.message.assistant a {
  color: var(--accent-hover);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.message.assistant a:hover {
  color: var(--accent);
}

.math-inline,
.math-display {
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
}

.math-inline {
  display: inline-flex;
  max-width: 100%;
  align-items: baseline;
  gap: 2px;
  vertical-align: baseline;
  white-space: nowrap;
}

.math-display {
  display: block;
  max-width: 100%;
  margin: 10px 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  white-space: nowrap;
  scrollbar-width: thin;
}

.math-display:first-child {
  margin-top: 0;
}

.math-display:last-child {
  margin-bottom: 0;
}

.math-frac {
  display: inline-flex;
  min-width: 1.4em;
  flex-direction: column;
  align-items: stretch;
  margin: 0 2px;
  text-align: center;
  vertical-align: middle;
}

.math-frac-num {
  display: block;
  padding: 0 3px 1px;
  border-bottom: 1px solid currentColor;
  line-height: 1.1;
}

.math-frac-den {
  display: block;
  padding: 1px 3px 0;
  line-height: 1.1;
}

.math-root {
  display: inline-flex;
  align-items: stretch;
  margin: 0 2px;
  vertical-align: middle;
}

.math-root-symbol {
  padding-right: 2px;
  font-size: 1.15em;
  line-height: 1;
}

.math-root-value {
  display: inline-flex;
  align-items: baseline;
  padding: 1px 3px 0 2px;
  border-top: 1px solid currentColor;
}

.math-text {
  font-family: inherit;
}

.math-sup,
.math-sub {
  font-size: .72em;
  line-height: 0;
}

.math-fallback {
  font-family: Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

.assistant-markdown-table-wrap {
  max-width: 100%;
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #171615;
}

.assistant-markdown-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 14px;
}

.assistant-markdown-table th,
.assistant-markdown-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.assistant-markdown-table th:last-child,
.assistant-markdown-table td:last-child {
  border-right: 0;
}

.assistant-markdown-table tr:last-child td {
  border-bottom: 0;
}

.assistant-markdown-table th {
  background: var(--panel-soft);
  color: var(--accent-hover);
  font-weight: 800;
}

.assistant-copy-block {
  max-width: 100%;
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #171615;
}

.assistant-copy-block:first-child {
  margin-top: 0;
}

.assistant-copy-block:last-child {
  margin-bottom: 0;
}

.assistant-copy-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 7px 9px 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.assistant-copy-block-language {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-copy-block-copy {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  border-radius: 7px;
  background: var(--accent);
  color: #1b120d;
  font-size: 13px;
  font-weight: 700;
}

.assistant-copy-block-copy:hover {
  background: var(--accent-hover);
}

.assistant-copy-block pre {
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
}

.assistant-copy-block code {
  display: block;
  min-width: max-content;
  padding: 13px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: normal;
}

.image-search-gallery {
  width: 100%;
  margin: 10px 0 12px;
}

.image-search-heading {
  margin-bottom: 10px;
  color: var(--accent-hover);
  font-size: 14px;
  font-weight: 700;
}

.image-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  width: 100%;
}

.image-search-card {
  min-width: 0;
  display: grid;
  grid-template-rows: 132px auto auto auto;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.image-search-preview {
  display: flex;
  min-width: 0;
  width: 100%;
  height: 132px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 7px;
  background: #151413;
  color: var(--muted);
  text-decoration: none;
}

.image-search-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.image-search-placeholder {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.image-search-title {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.image-search-domain {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.image-search-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.image-search-source,
.image-search-analyze {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.image-search-source:hover,
.image-search-analyze:hover {
  border-color: var(--accent);
}

.image-search-analyze:disabled {
  cursor: default;
  opacity: .65;
}

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

.composer-wrap {
  border-top: 1px solid var(--border);
  padding: 16px 22px 20px;
  background: rgba(25, 24, 23, .94);
}

.composer {
  width: min(920px, 100%);
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.composer-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  width: 100%;
}

.composer textarea {
  width: 100%;
  max-height: 190px;
  min-height: 38px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  line-height: 1.45;
  padding: 8px;
}

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

.send {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #1b120d;
  font-size: 20px;
  font-weight: 800;
}

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

.send:disabled {
  cursor: default;
  opacity: .55;
}
