.chat-pane {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.messages { min-height: 0; overflow: auto; scrollbar-gutter: stable; padding: 16px 6vw 28px; }
.jump-bottom {
  position: absolute;
  right: max(24px, 6vw);
  bottom: 92px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.jump-bottom svg { width: 20px; height: 20px; }
.jump-bottom:hover, .jump-bottom:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.app-shell[data-theme="dark"] .jump-bottom { color: var(--accent); }
.app-shell[data-theme="dark"] .jump-bottom:hover, .app-shell[data-theme="dark"] .jump-bottom:focus-visible { color: #fff; }
.sib-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.sib-nav svg { width: 20px; height: 20px; }
.sib-nav:hover, .sib-nav:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.sib-prev { left: 8px; }
.sib-next { right: 8px; }
.empty-state { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; }
.empty-logo { width: min(230px, 64vw); height: auto; margin: 0 auto 6px; color: var(--text); }
.empty-state p { margin-top: 0; }
.empty-system-prompt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.empty-system-prompt:hover { border-color: var(--accent); }
.empty-system-prompt svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--muted); }
.empty-system-prompt:hover svg { color: var(--accent); }
.loading-messages { width: 100%; }
.loading-pair { opacity: .86; }
.loading-card { padding: 18px 16px; pointer-events: none; }
.loading-line {
  height: 12px;
  margin-bottom: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--panel-2) 0%, color-mix(in srgb, var(--panel-2), var(--text) 10%) 45%, var(--panel-2) 90%);
  background-size: 220% 100%;
  animation: loading-strobe 1.15s ease-in-out infinite;
}
.loading-line:last-child { margin-bottom: 0; }
.loading-line.short { width: 34%; }
.loading-line.title { width: 22%; }
.loading-line.wide { width: 76%; }
@keyframes loading-strobe {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
.message-pair { display: grid; gap: 12px; width: 100%; min-width: 0; margin: 0 auto 12px; max-width: 920px; }
.message-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: visible;
  transition: box-shadow .14s ease;
}
.message-card[data-streaming="true"]::after {
  content: '';
  position: absolute;
  inset: -1px;
  border: 0 solid var(--accent);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  pointer-events: none;
  animation: pulse-border 2.4s ease-in-out infinite;
}
@keyframes pulse-border { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
.message-card.recently-collapsed { border-color: var(--accent); }
.message-card.expanded:has(.message-edge-collapse:hover),
.message-card.expanded:has(.message-edge-collapse:focus-visible) {
  box-shadow: inset -5px 0 0 var(--accent);
}
.message-edge-collapse {
  display: none;
  position: absolute;
  top: 0;
  right: -12px;
  bottom: 0;
  z-index: 3;
  width: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.message-card.expanded .message-edge-collapse { display: block; }
.message-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.message-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-column: 1;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.message-meta:not(:has(.message-avatar)) { grid-template-columns: minmax(0, 1fr); }
.message-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-avatar { grid-column: 1; grid-row: 1; }
.system-prompt-avatar svg { width: 17px; height: 17px; }
.message-role {
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-meta:has(.message-avatar) .message-role { grid-column: 2; }
.message-preview {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-tools { grid-column: 2; grid-row: 1; display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.arrow { transition: transform .16s ease; }
.message-card.expanded .arrow { transform: rotate(90deg); }
.message-body {
  display: none;
  min-width: 0;
  padding: 0 14px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.message-card.expanded .message-body { display: block; }
.queued-output { margin: 0; color: var(--muted); font-style: italic; }
.message-body h1, .message-body h2, .message-body h3, .message-body h4, .message-body h5, .message-body h6 {
  margin: 16px 0 8px;
  line-height: 1.2;
  white-space: normal;
}
.message-body h1 { font-size: 1.55rem; }
.message-body h2 { font-size: 1.35rem; }
.message-body h3 { font-size: 1.16rem; }
.message-body h4, .message-body h5, .message-body h6 { font-size: 1rem; }
.message-body code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
}
.message-body code.inline-code { cursor: pointer; transition: border-color .15s ease, color .15s ease; }
.message-body code.inline-code:hover { border-color: var(--accent); }
.message-body code.inline-code.copied { color: var(--accent); border-color: var(--accent); }
/* Rendered math (KaTeX) is click-to-copy, mirroring inline-code: pointer on
   hover, accent recolor on the transient .copied flash. Inline math is the
   .katex node; display math targets the whole .katex-display row. */
.message-body .katex, .message-body .katex-display { cursor: pointer; transition: color .15s ease; }
.message-body .katex:hover, .message-body .katex-display:hover { color: var(--accent); }
.message-body .katex.copied, .message-body .katex-display.copied { color: var(--accent); }
.code-block { position: relative; min-width: 0; margin: 12px 0; overflow-wrap: normal; }
.message-body pre {
  overflow: auto;
  margin: 0;
  padding: 12px 52px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  white-space: pre;
}
.message-body pre code { padding: 0; border: 0; border-radius: 0; background: transparent; overflow-wrap: normal; }
.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.copy-code svg { width: 17px; height: 17px; }
.copy-code.copied { color: var(--accent); border-color: var(--accent); }
.copy-code:hover { border-color: var(--accent); }
.markdown-table-wrap {
  position: relative;
  overflow: auto;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.markdown-table-wrap table { width: 100%; border-collapse: collapse; white-space: normal; }
.copy-table-csv {
  position: sticky;
  top: 8px;
  left: calc(100% - 38px);
  z-index: 2;
  display: grid;
  place-items: center;
  float: right;
  width: 30px;
  height: 30px;
  margin: 8px 8px -38px 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.copy-table-csv svg { width: 17px; height: 17px; }
.copy-table-csv.copied { color: var(--accent); border-color: var(--accent); }
.copy-table-csv:hover { border-color: var(--accent); }
.markdown-table-wrap th, .markdown-table-wrap td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.markdown-table-wrap th { background: var(--panel-2); font-weight: 800; }
.markdown-table-wrap tr:last-child td { border-bottom: 0; }
.markdown-table-wrap tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel-2) 42%, transparent); }
.copy-message-button, .edit-button, .refresh-button, .stop-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}
.copy-message-button:hover, .edit-button:hover, .refresh-button:hover, .stop-button:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
}
.copy-message-button.copied { color: var(--accent); }
.refresh-button:disabled { cursor: default; opacity: .45; }
.refresh-button:disabled:hover { background: transparent; color: var(--muted); }
.edit-box {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 10px;
  outline: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.edit-box:focus { border-color: var(--accent); }
.edit-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.edit-attachment-placeholder {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10px;
}
.edit-attachment-add {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.edit-attachment-add:hover { border-color: var(--accent); color: var(--accent); }
.inline-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.thinking {
  position: relative;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}
.thinking::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
  pointer-events: none;
}
.thinking-edge-collapse {
  display: none;
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.thinking[open] .thinking-edge-collapse { display: block; }
.thinking[open]:has(.thinking-edge-collapse:hover),
.thinking[open]:has(.thinking-edge-collapse:focus-visible) {
  box-shadow: inset 5px 0 0 var(--accent), inset 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}
.thinking summary {
  cursor: pointer;
  padding: 8px 12px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: .02em;
  user-select: none;
}
.thinking.active-thinking summary,
.message-preview.active-thinking {
  animation: connecting-strobe 1.8s ease-in-out infinite;
}
.message-preview.active-thinking {
  color: var(--accent);
  font-weight: 400;
}
.thinking > div {
  padding: 0 12px 12px;
  color: color-mix(in srgb, var(--muted) 84%, var(--text));
  font-size: .94em;
}
.connecting-placeholder {
  color: var(--muted);
  animation: connecting-strobe 1.8s ease-in-out infinite;
}
.tool-call {
  position: relative;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.tool-call::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
  pointer-events: none;
}
.tool-edge-collapse {
  display: none;
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.tool-call[open] .tool-edge-collapse { display: block; }
.tool-call[open]:has(.tool-edge-collapse:hover),
.tool-call[open]:has(.tool-edge-collapse:focus-visible) {
  box-shadow: inset 5px 0 0 var(--accent), inset 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}
.tool-call summary {
  cursor: pointer;
  padding: 6px 12px;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}
.tool-calling summary {
  animation: connecting-strobe 1.8s ease-in-out infinite;
}
.tool-call-body {
  padding: 0 12px 10px;
}
.tool-summary-simple {
  position: relative;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  padding: 6px 12px;
  color: var(--accent);
  font-weight: 600;
  cursor: default;
  user-select: none;
}
.tool-summary-simple::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
  pointer-events: none;
}
.tool-summary-simple.tool-calling {
  animation: connecting-strobe 1.8s ease-in-out infinite;
}
@keyframes connecting-strobe {
  0%, 100% { opacity: .42; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .connecting-placeholder,
  .thinking.active-thinking summary,
  .tool-summary-simple.tool-calling,
  .message-preview.active-thinking { animation: none; }
}

