.chat-pane {
  flex: 1;
  overflow-y: auto;
  padding: 1.8rem 2rem;
  background: var(--bg-app);
}

.message-item {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  padding: 1rem 1.2rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.message-item.user-msg {
  background: var(--bg-subtle);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.01);
}

.message-item.assistant-msg {
  background: var(--bg-panel);
  box-shadow: var(--shadow-card);
}

.message-item:hover {
  border-color: #d0d7e2;
}

.msg-meta {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.msg-role {
  font-weight: 650;
  font-size: 0.8rem;
}

.msg-role.user {
  color: var(--color-heading);
}

.msg-role.assistant {
  color: var(--color-accent);
}

.msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: auto;
}

.version-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
}

.version-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  min-width: 3.5rem;
  text-align: center;
  letter-spacing: 0.02em;
}

.version-nav-btn {
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #d7dfeb;
  background: var(--bg-subtle);
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.version-nav-btn:hover:not(:disabled) {
  background: #edf2f7;
  border-color: #b8c3d3;
}

.version-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.msg-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-heading);
  margin: 0.5rem 0 0.6rem 0;
  word-break: break-word;
}

.msg-content > :first-child,
.reasoning-text > :first-child {
  margin-top: 0;
}

.msg-content > :last-child,
.reasoning-text > :last-child {
  margin-bottom: 0;
}

.reasoning-block {
  background: #f8fafd;
  border-left: 3px solid #6b7280;
  margin: 0.8rem 0 0.6rem 0;
  padding: 0.7rem 1rem;
  border-radius: 0.3rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #334155;
}

.reasoning-header {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
  user-select: none;
  font-family: inherit;
}

.reasoning-header-state {
  font-size: 0.65rem;
}

.reasoning-text {
  line-height: 1.55;
}

.typing-indicator {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--color-accent);
  border-radius: 50%;
  animation: typingPulse 0.8s infinite alternate;
}

@keyframes typingPulse {
  0% { transform: scale(0.6); opacity: 0.4; }
  100% { transform: scale(1.2); opacity: 1; }
}

.msg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
  min-height: 24px;
}

.message-item:hover .msg-actions {
  opacity: 1;
}

.action-sep {
  display: inline-block;
  width: 0;
  height: 1rem;
  border-left: 1px solid #e2e8f0;
  margin: 0 0.2rem;
  align-self: center;
}

.stop-generation-btn {
  position: fixed;
  bottom: 3.5rem;
  right: 2rem;
  width: 2.8rem;
  height: 2.8rem;
  background: var(--bg-accent-strong);
  border: none;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.stop-generation-btn:hover {
  background: var(--bg-accent-strong);
  filter: brightness(1.06);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.stop-generation-btn:active {
  transform: scale(0.94);
}

.stop-generation-btn svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: #fff;
}

.scroll-to-bottom-btn {
  position: fixed;
  left: 2rem;
  bottom: 3.5rem;
  width: 2.8rem;
  height: 2.8rem;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  z-index: 100;
  border: 1px solid #dce2eb;
  transition: opacity 0.2s, transform 0.2s;
  padding: 0;
}

.scroll-to-bottom-btn:hover {
  transform: translateY(-2px);
  background: #f8fafc;
}

.scroll-to-bottom-btn.is-invisible {
  opacity: 0;
  pointer-events: none;
}

.scroll-to-bottom-btn svg {
  width: 1.4rem;
  height: 1.4rem;
  stroke: #475569;
}

.status-bar {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--bg-panel);
  border-top: 1px solid var(--border-panel);
  padding: 0.6rem 2rem;
  flex-shrink: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  height: 100%;
  color: #6b7280;
  text-align: center;
}

.empty-state-title {
  font-weight: 500;
}

.message-edit-textarea {
  margin-top: 0.5rem;
  height: auto;
  overflow: hidden;
}

.system-prompt-textarea {
  overflow: auto;
  margin-top: 0;
  margin-bottom: 0.9rem;
}

.message-edit-actions {
  margin-top: 0.5rem;
}

.message-edit-save {
  margin-right: 0.5rem;
}

.empty-input-row {
  --empty-input-gap: 0.625rem;
  --empty-send-btn-width: 4.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--empty-input-gap);
  width: 100%;
}

.empty-input-spacer {
  flex: 0 0 var(--empty-send-btn-width);
}

.empty-input-wrapper {
  width: min(100%, 620px);
  flex: none;
}

.empty-input-shell {
  width: 100%;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 1px;
  background: var(--bg-panel);
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.empty-input-shell:focus-within {
  border-color: var(--bg-accent);
  box-shadow: var(--focus-ring);
}

.empty-input-shell textarea {
  flex: 1;
  width: 100%;
  padding: 0.50rem 1rem 0.42rem 0.75rem;
  font-size: 0.92rem;
  border: 0;
  border-radius: calc(0.4rem - 1px);
  box-sizing: border-box;
  min-height: 2.25rem;
  max-height: 168px;
  outline: none;
  resize: none;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  line-height: 1.3;
  font-family: inherit;
  background: transparent;
}

.empty-input-shell textarea::-webkit-scrollbar {
  width: 10px;
}

.empty-input-shell textarea::-webkit-scrollbar-track {
  background: transparent;
}

.empty-input-shell textarea::-webkit-scrollbar-thumb {
  background-color: rgba(100, 116, 139, 0.75);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.empty-input-row button {
  width: var(--empty-send-btn-width);
  min-width: var(--empty-send-btn-width);
  height: 2.25rem;
  flex: none;
  padding: 0;
}

@media (max-width: 700px) {
  .top-bar {
    padding: 0.8rem 1rem;
  }
  .chat-pane {
    padding: 1rem 1rem;
  }
  .status-bar {
    padding: 0.5rem 1rem;
  }
  .stop-generation-btn {
    right: 1rem;
    bottom: 3rem;
  }
  .scroll-to-bottom-btn {
    left: 1rem;
    bottom: 3rem;
  }
  .empty-input-row {
    flex-wrap: wrap;
  }
  .empty-input-spacer {
    display: none;
  }
  .empty-input-wrapper {
    width: 100%;
  }
  .empty-input-row button {
    width: auto;
    min-width: 4.5rem;
    padding: 0 0.9rem;
  }
}

/* === Shared prose styles (Markdown rendering output) === */

.prose-content p {
  margin: 0.55rem 0;
}

.prose-content h1,
.prose-content h2,
.prose-content h3,
.prose-content h4,
.prose-content h5,
.prose-content h6 {
  margin: 0.85rem 0 0.5rem;
  line-height: 1.35;
}

.prose-content ul,
.prose-content ol {
  margin: 0.45rem 0 0.7rem 1.4rem;
}

.prose-content li {
  margin: 0.22rem 0;
}

.prose-content blockquote {
  border-left: 3px solid #cbd5e1;
  margin: 0.7rem 0;
  padding: 0.2rem 0 0.2rem 0.75rem;
  color: #475569;
  background: rgba(241, 245, 249, 0.6);
}

.prose-content code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: #eef2f7;
  padding: 0.1rem 0.35rem;
  border-radius: 0.3rem;
  font-size: 0.86em;
}

.prose-content pre {
  background: var(--bg-accent-strong);
  color: #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem 0.9rem;
  margin: 0.7rem 0;
  overflow-x: auto;
}

.prose-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.prose-content a {
  color: #1d4ed8;
  text-decoration: underline;
}

.prose-content table {
  border-collapse: collapse;
  margin: 0.7rem 0;
  width: 100%;
}

.prose-content th,
.prose-content td {
  border: 1px solid #dbe3ee;
  padding: 0.35rem 0.5rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.prose-content hr {
  border: 0;
  border-top: 1px solid #d9e2ef;
  margin: 0.85rem 0;
}

/* === KaTeX Math Rendering === */

.prose-content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0.85rem 0;
  padding: 0.15rem 0;
}

.prose-content .katex {
  font-size: 1.05em;
  line-height: 1.2;
}

.prose-content .katex .katex-html {
  white-space: normal;
}

.prose-content .katex-display > .katex {
  text-align: center;
  display: block;
  max-width: 100%;
}

.prose-content .katex .katex-error {
  color: #cc0000;
  font-style: italic;
}
