/* Markdown structure within chat bubbles; all colors follow the existing day/night theme. */
.bubble { min-width: 0; overflow-wrap: anywhere; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
  line-height: 1.45; font-weight: 650; margin: .8em 0 .45em; color: inherit;
}
.bubble h1 { font-size: 1.45em; }
.bubble h2 { font-size: 1.3em; }
.bubble h3 { font-size: 1.15em; }
.bubble h4, .bubble h5, .bubble h6 { font-size: 1em; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: .45em 0; padding-inline-start: 1.65em; }
.bubble li { margin: .25em 0; padding-inline-start: .1em; }
.bubble li > ul, .bubble li > ol { margin: .25em 0; }
.bubble li > p { margin: .4em 0; }
.bubble blockquote {
  margin: .6em 0; padding: .25em 0 .25em .8em;
  border-inline-start: 3px solid var(--border); color: var(--text-light);
}
.bubble blockquote > :first-child { margin-top: 0; }
.bubble blockquote > :last-child { margin-bottom: 0; }
.bubble del, .bubble s { opacity: .8; text-decoration: line-through; }
.bubble hr { margin: .85em 0; border: 0; border-top: 1px solid var(--border); }
.bubble a:not(.file-download) { color: inherit; text-decoration: underline; text-underline-offset: .18em; overflow-wrap: anywhere; }
.bubble a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
.bubble img.chat-img { max-width: 100%; height: auto; object-fit: contain; }
.bubble pre { max-width: 100%; white-space: pre; overflow-wrap: normal; }
.bubble pre code { white-space: pre; overflow-wrap: normal; }
.bubble .md-table-scroll {
  max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; margin: .6em 0; border: 1px solid var(--border); border-radius: 9px;
}
.bubble .md-table-scroll:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.bubble table { width: max-content; min-width: 100%; max-width: none; border-collapse: collapse; font-size: .9em; line-height: 1.6; }
.bubble th, .bubble td { padding: .5em .65em; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); min-width: 4em; max-width: 22em; vertical-align: top; }
.bubble th { font-weight: 600; text-align: left; background: var(--bg); }
.bubble tr:last-child td { border-bottom: 0; }
.bubble th:last-child, .bubble td:last-child { border-inline-end: 0; }
/* Table cells have their own grid; keep the speech spans semantic without capsule padding. */
.bubble th .say, .bubble td .say,
html.night .row.ai .bubble th .say, html.night .row.ai .bubble td .say,
html.night .row.me .bubble th .say, html.night .row.me .bubble td .say {
  display: inline; padding: 0; background: none; box-shadow: none; border-radius: 0; line-height: inherit; color: inherit;
}

/* Quiet, opt-in web references below the reply, outside the speech bubble. */
.web-sources { max-width: min(100%, 34rem); min-width: 0; margin: 3px 0 0 2px; color: var(--text-light); font-size: 11px; line-height: 1.6; text-shadow: none; }
.web-sources > summary { width: fit-content; padding: 3px 7px; border-radius: 8px; cursor: pointer; list-style: none; background: var(--bg); user-select: none; }
.web-sources > summary::-webkit-details-marker { display: none; }
.web-sources > summary::after { content: ' ›'; display: inline-block; margin-left: 3px; }
.web-sources[open] > summary::after { transform: rotate(90deg); }
.web-sources > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.web-source-links { padding: 7px 9px; margin-top: 3px; border-inline-start: 1px solid var(--border); font-size: 12px; overflow-wrap: anywhere; }
.web-source-links ul, .web-source-links ol { padding-inline-start: 1.3em; margin: 0; }
.web-source-links li + li { margin-top: 5px; }
.web-source-links p { margin: 0; }
.web-source-links a { color: inherit; text-decoration: underline; text-underline-offset: .15em; }
.web-source-links .say { display: inline; padding: 0; background: none; box-shadow: none; color: inherit; }
