/* The thread: rows of bubbles with the lane beside each Jet message, pills for
   days and notices, the waiting dots, and the Markdown inside Jet's bubbles. */
/* No scroll anchoring: a source row fills in after it opens, and the browser would scroll the row away to keep the rows below it still. */
.thread { position: absolute; inset: 0; overflow-y: auto; overflow-anchor: none; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.thread:focus-visible { outline-offset: -2px; }
.column {
  max-width: calc(820px + 2 * var(--gutter)); margin: 0 auto;
  padding: calc(.7 * 240px * var(--lane-scale)) var(--gutter) 48px;
}

.row { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }
/* The bubble rises in, not the lane: the live Jet stands in the lane and must not fade while it reacts to the send. */
.row > :not(.lane) { animation: rise 160ms ease-out; }
.row:not(.first) { margin-top: 2px; }
.row-user { justify-content: flex-end; }
.row-lane { min-height: 44px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.lane { position: relative; flex: 0 0 var(--lane); align-self: stretch; pointer-events: none; }

.bubble {
  position: relative; min-width: 0;
  max-width: min(560px, calc(100% - var(--lane) - 8px));
  padding: 8px 12px 6px; border-radius: 16px;
  font-size: var(--text-size); line-height: var(--text-line);
  overflow-wrap: anywhere;
}
/* A Jet reply is its cards above its bubble, in one column no wider than a bubble may be. */
.reply { display: flex; flex: 1 1 auto; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; max-width: min(560px, calc(100% - var(--lane) - 8px)); }
.reply > .bubble { max-width: 100%; }
.cards { display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.cards:empty { display: none; }

.row-jet .bubble { background: var(--bubble-jet); }
.row-user .bubble { background: var(--bubble-user); color: var(--on-user); max-width: min(560px, 78%, calc(100% - var(--lane) - 8px)); }
.row-user .body { white-space: pre-wrap; }

/* A sent message is its files above its bubble, in one column on the right. */
.sent { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; max-width: min(560px, 78%, calc(100% - var(--lane) - 8px)); }
.row-user .sent .bubble { max-width: 100%; }
.attachments { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 100%; }
.attachments:empty { display: none; }
.attach-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 100%; }
.attach-thumb { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; line-height: 0; }
.attach-image { display: block; min-width: 48px; min-height: 48px; max-width: 160px; max-height: 120px; object-fit: cover; }
.attach-chip {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; min-height: 44px; padding: 7px 14px 7px 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; color: var(--fg); text-decoration: none;
}
a.attach-chip:hover, .attach-thumb:hover { border-color: rgba(255, 255, 255, .22); }
.attach-text { display: flex; flex-direction: column; min-width: 0; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; line-height: 18px; }
.attach-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; line-height: 16px; }
.sent-time { font-size: 11px; line-height: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }

.row-jet:not(.first) .bubble { border-top-left-radius: 6px; }
.row-jet:not(.last) .bubble { border-bottom-left-radius: 6px; }
.row-jet.last .bubble { border-bottom-left-radius: 4px; }
.row-user:not(.first) .bubble { border-top-right-radius: 6px; }
.row-user:not(.last) .bubble { border-bottom-right-radius: 6px; }
.row-user.last .bubble { border-bottom-right-radius: 4px; }

.time { position: absolute; right: 12px; bottom: 6px; font-size: 11px; line-height: 14px; font-variant-numeric: tabular-nums; color: rgba(232, 237, 241, .55); }
.row-user .time { color: rgba(243, 247, 250, .7); }
.time-gap { display: inline-block; width: 44px; height: 1px; }
.time-below { padding-bottom: 22px; }

.pill {
  width: fit-content; max-width: 100%; margin: 16px auto; padding: 4px 12px;
  background: rgba(17, 27, 35, .85); border-radius: 999px;
  font-size: 12px; line-height: 16px; color: var(--muted); text-align: center;
}
.pill-banner { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; color: var(--fg); text-align: left; border: 1px solid var(--line); }
.pill-banner .action { position: relative; min-height: 36px; padding: 0 14px; font-size: 13px; }
.pill-banner .action::after { content: ""; position: absolute; inset: -4px; }

.dots { display: inline-flex; align-items: center; height: 21px; padding: 0 2px; }
.dots i { width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: dot 1200ms infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 160ms; }
.dots i:nth-child(3) { animation-delay: 320ms; }
@keyframes dot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
/* Hidden as well as transparent, so a screen reader does not read the line out before it shows. */
.still { margin-left: 8px; font-size: 12px; color: var(--muted); opacity: 0; visibility: hidden; animation: reveal 300ms 20s forwards; }
@keyframes reveal { to { opacity: 1; visibility: visible; } }
.reduced .dots i { animation: none; opacity: .7; }
.reduced .row > :not(.lane) { animation: fade 120ms ease-out; }
@keyframes fade { from { opacity: 0; } }

.is-error { padding-left: 10px; border-left: 2px solid var(--danger); }
.error p { margin: 0 0 8px; }
.error p:last-of-type { margin-bottom: 0; }
.error .hint { color: var(--muted); }
.error .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.stopped { margin: 4px 0 0; font-size: 12px; line-height: 16px; font-style: italic; color: var(--muted); }

.body > :first-child { margin-top: 0; }
.body p { margin: 0 0 8px; }
.body p:last-child, .body ul:last-child, .body ol:last-child { margin-bottom: 0; }
.body ul, .body ol { margin: 0 0 8px; padding-left: 20px; }
.body li { margin: 2px 0; }
.body h3, .body h4, .body h5, .body h6 { margin: 12px 0 4px; font-size: var(--text-size); line-height: var(--text-line); font-weight: 700; }
.body a { color: var(--link-jet); text-decoration: underline; text-underline-offset: 2px; }
.row-user .body a { color: var(--link-user); }
.body code { padding: 1px 5px; background: rgba(0, 0, 0, .28); border-radius: 4px; font: 13px/19px var(--mono); }
.code { position: relative; margin: 8px 0; }
.code pre { margin: 0; padding: 10px 12px; overflow-x: auto; background: rgba(0, 0, 0, .28); border-radius: 8px; font: 13px/19px var(--mono); }
.code pre code { padding: 0; background: none; border-radius: 0; font: inherit; }
.copy {
  position: absolute; top: 4px; right: 4px; min-width: 52px; min-height: 28px; padding: 0 10px;
  background: rgba(255, 255, 255, .08); border: 0; border-radius: 6px;
  font-size: 12px; opacity: .6; pointer-events: auto;
}
.copy::after { content: ""; position: absolute; inset: -8px; }
.copy:hover, .copy:focus-visible { opacity: 1; }
/* Bubbles and cards let any word break anywhere, which would shrink a table's columns to a letter wide. A table keeps its words whole and scrolls sideways instead. */
.body table { display: block; max-width: 100%; margin: 8px 0; overflow-x: auto; overflow-wrap: normal; border-collapse: collapse; }
.body th, .body td { padding: 4px 10px; border: 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.body thead th { font-weight: 600; border-bottom-color: rgba(255, 255, 255, .18); }
.body .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Math sits on its own classes, not under .body, so a formula outside a bubble looks the same.
   KaTeX's own size (1.21em) makes a line with a formula taller than a plain line. */
.math { font-family: var(--mono); }
.math .katex { font-size: 1.1em; }
.math-display { display: block; margin: 8px 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.math-display:last-child { margin-bottom: 0; }
.math-display .katex-display { margin: 0; }
.math-error { color: var(--danger); }

.jump {
  position: absolute; left: 50%; bottom: 16px; z-index: 4; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 18px 0 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 22px;
  font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.jump .icon { width: 18px; height: 18px; }
