html, body {
  height: 100%;
  overflow: hidden;
}

.chat-layout {
  display: flex;
  height: calc(100vh - 56px); /* below the navbar */
}

.chat-sidebar {
  width: 260px;
  flex: 0 0 260px;
  min-width: 160px;
  max-width: 70vw;
  overflow-y: auto;
}

.chat-resizer {
  flex: 0 0 5px;
  width: 5px;
  cursor: col-resize;
  background: var(--bs-border-color);
  position: relative;
}

.chat-resizer:hover,
.chat-resizer.chat-resizer-active {
  background: var(--bs-primary);
}

/* Widens the hit area beyond the visible 5px bar without affecting layout. */
.chat-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
}

/* Set on <body> while dragging so text selection / hover states elsewhere
   on the page don't fight the drag. */
body.chat-resizing {
  cursor: col-resize;
  user-select: none;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.4rem 0.4rem 0.75rem;
  border-radius: 0.375rem;
  margin: 0 0.5rem 0.25rem;
}

.chat-list-item:hover {
  background: var(--bs-tertiary-bg);
}

.chat-list-item.active {
  background: var(--bs-primary-bg-subtle);
  box-shadow: inset 3px 0 0 var(--bs-primary);
  color: var(--bs-primary-text-emphasis);
  font-weight: 600;
}

.chat-list-item.active .chat-list-item-link { color: var(--bs-primary-text-emphasis); }

.chat-list-item-link {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--bs-body-color);
  text-decoration: none;
}

.chat-list-item-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.1rem;
  opacity: 0;
}

.chat-list-item:hover .chat-list-item-actions,
.chat-list-item.renaming .chat-list-item-actions {
  opacity: 1;
}

.chat-item-action-btn {
  border: 0;
  background: transparent;
  color: var(--bs-secondary-color);
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  line-height: 1;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-block;
}

.chat-item-action-btn:hover {
  background: var(--bs-border-color);
  color: var(--bs-body-color);
}

.chat-list-item-rename-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.05rem 0.3rem;
  font-size: inherit;
}

.chat-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.chat-transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-bubble {
  /* The transcript is a column flexbox; without this, a bubble with overflow set (assistant
     replies) is shrunk vertically to fit the viewport instead of growing the scroll area. */
  flex-shrink: 0;
  max-width: 70ch;
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--bs-primary);
  color: var(--bs-white);
}

/* pre-wrap belongs on the text node itself, not the bubble wrapper -- the
   wrapper's whitespace-formatted HTML (newlines/indentation around
   .chat-bubble-text) would otherwise render as extra blank lines. */
.chat-bubble-user .chat-bubble-text {
  white-space: pre-wrap;
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bs-tertiary-bg);
  /* Specs are long, table-heavy documents: let assistant replies use the full width. */
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

/* Rendered markdown (assistant replies) */
.markdown-body { line-height: 1.55; overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.2em 0 0.5em; font-weight: 600; line-height: 1.25;
}
.markdown-body h1 { font-size: 1.5rem; }
.markdown-body h2 { font-size: 1.3rem; padding-bottom: 0.25em; border-bottom: 1px solid var(--bs-border-color); }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 1rem; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote,
.markdown-body pre, .markdown-body table { margin: 0 0 0.85em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li > ul, .markdown-body li > ol { margin: 0.25em 0; }
.markdown-body li + li { margin-top: 0.2em; }
.markdown-body blockquote {
  padding: 0.1em 1em; color: var(--bs-secondary-color);
  border-left: 0.25em solid var(--bs-border-color);
}
.markdown-body hr { margin: 1.2em 0; }
.markdown-body a { text-decoration: underline; }
.markdown-body code {
  padding: 0.15em 0.35em; border-radius: 0.3rem; font-size: 0.875em;
  background: var(--bs-secondary-bg); color: var(--bs-body-color);
}
.markdown-body pre {
  padding: 0.75rem 1rem; border-radius: 0.5rem; overflow-x: auto;
  background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color);
}
.markdown-body pre code { padding: 0; background: none; font-size: 0.85em; white-space: pre; }
.markdown-body table {
  display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; width: max-content;
}
.markdown-body th, .markdown-body td {
  padding: 0.4rem 0.75rem; border: 1px solid var(--bs-border-color); vertical-align: top;
}
.markdown-body th { background: var(--bs-secondary-bg); font-weight: 600; }
.markdown-body tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bs-secondary-bg) 45%, transparent); }
.markdown-body img { max-width: 100%; }
.markdown-body input[type=checkbox] { margin-right: 0.4em; }

.tool-chips {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tool-chips + .md-target { margin-top: 0.6rem; }

.model-note {
  margin: 0.4rem 0;
  padding-left: 0.7rem;
  border-left: 3px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
}
.model-note summary { cursor: pointer; font-size: 0.8rem; }

.chat-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

.chat-status-spinner {
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--bs-border-color);
  border-top-color: var(--bs-secondary-color);
  border-radius: 50%;
  animation: chat-status-spin 0.8s linear infinite;
}

.chat-list-item-working { display: none; flex: none; margin-right: 0.4rem; border-top-color: var(--bs-primary); }
.chat-list-item.running .chat-list-item-working { display: inline-block; }
.chat-list-item.running .chat-list-item-title { font-weight: 600; }

@keyframes chat-status-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .chat-status-spinner { animation: none; }
}

.tool-chip {
  font-size: 0.85rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: var(--bs-body-bg);
}

.tool-chip summary {
  cursor: pointer;
  color: var(--bs-secondary-color);
}

.tool-chip-error summary {
  color: var(--bs-danger);
}

.tool-chip pre {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-composer {
  flex: 0 0 auto;
  padding: 0.75rem 1.5rem 1.25rem;
}

/* claude.ai/new-style input card: a plain textarea on top, with the
   model/assistant/repo pickers and the send button tucked into a toolbar
   row underneath rather than crammed alongside the textarea. */
.chat-composer-box {
  max-width: 48rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem 0.6rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 1.25rem;
  background: var(--bs-body-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.chat-composer-input {
  resize: none;
  border: 0;
  background: transparent;
  padding: 0.25rem 0.25rem;
  max-height: 40vh;
  overflow-y: auto;
}

.chat-composer-input:focus {
  border: 0;
  box-shadow: none;
  outline: none;
}

.chat-composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.chat-composer-toolbar { align-items: flex-end; }

/* Context meter + send button stay together at the right, even when the pickers wrap. */
.chat-composer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.chat-composer-provider {
  width: auto;
  flex: 0 0 auto;
  font-size: 0.75rem;
}

.chat-composer-persona {
  width: auto;
  max-width: 200px;
  min-width: 0;
  flex: 0 1 auto;
  font-size: 0.75rem;
}

.chat-composer-repos {
  width: auto;
  max-width: 180px;
  flex: 0 0 auto;
}

.chat-composer-repos .repo-select-toggle {
  font-size: 0.75rem;
}

.chat-context-usage {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--bs-secondary-color, #6c757d);
  white-space: nowrap;
}

.chat-context-usage-bar {
  display: inline-block;
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--bs-tertiary-bg, #e9ecef);
  overflow: hidden;
}

.chat-context-usage-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--bs-primary, #0d6efd);
  transition: width 0.2s ease;
}

.chat-context-usage-fill-warn {
  background: var(--bs-warning, #ffc107);
}

.chat-context-usage-fill-danger {
  background: var(--bs-danger, #dc3545);
}

.chat-composer-send {
  flex: 0 0 auto;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chat-composer-stop {
  background: var(--bs-danger, #dc3545);
  border-color: var(--bs-danger, #dc3545);
}

.repo-select-menu {
  max-height: 260px;
  overflow-y: auto;
  min-width: 220px;
}

.repo-select-hint {
  font-size: 0.75rem;
}

.chat-composer-web { white-space: nowrap; flex: 0 0 auto; }

.tool-chip-sources {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  word-break: break-word;
}

.steps-btn { margin-top: 0.6rem; }

/* Reasoning steps modal: a timeline -- a numbered marker per step joined by a line, each
   step's content in its own card, so the steps read as a sequence instead of running together. */
.steps-flow { display: flex; flex-direction: column; }
.step { display: flex; align-items: stretch; gap: 0.9rem; }
.step-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.step-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--bs-primary);
  color: var(--bs-white, #fff);
  font-weight: 600;
  font-size: 0.85rem;
}
.step-line { flex: 1 1 auto; width: 2px; min-height: 0.75rem; margin: 0.25rem 0; background: var(--bs-border-color); }
.step:last-child .step-line { visibility: hidden; }
.step-card {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.6rem;
  background: var(--bs-body-bg);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.step-card-head { font-size: 0.8rem; font-weight: 600; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: 0.03em; }
.step-label { font-size: 0.75rem; color: var(--bs-secondary-color); margin-bottom: 0.2rem; }
.step-thinking { color: var(--bs-secondary-color); font-size: 0.9rem; }
