/* The transcript: messages, code, steps and tool calls, answer versions, sources. */

/* ---------- Transcript ---------- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px 16px;
  min-height: 0;
}

.msg,
.status-note,
.chat-empty-inner {
  max-width: calc(var(--gutter) + var(--measure));
  margin-left: auto;
  margin-right: auto;
}

.msg {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  column-gap: 0;
  margin-bottom: 18px;
}

/* The role column: who is speaking */
.msg-role {
  padding: 2px 16px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55rem;
  color: var(--text-faint);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-role.you {
  color: var(--amber);
}

.msg-role.err {
  color: var(--danger);
  /* Line up with the first text line inside the error box */
  padding-top: 8px;
}

.msg.user {
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.messages > .msg.user:first-child {
  padding-top: 0;
  border-top: none;
}

.msg-bubble {
  padding-left: 16px;
  border-left: 1px solid var(--amber);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.msg-body {
  min-width: 0;
  padding-left: 17px;
}

.markdown {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
}

.markdown p {
  margin: 0 0 0.8em;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 1.4em 0 0.5em;
  line-height: 1.3;
  font-weight: 600;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown h1 {
  font-size: 20px;
}

.markdown h2 {
  font-size: 17.5px;
}

.markdown h3,
.markdown h4 {
  font-size: 15.5px;
}

.markdown strong {
  font-weight: 600;
}

.markdown ul,
.markdown ol {
  padding-left: 1.4em;
  margin: 0 0 0.8em;
}

.markdown li {
  margin-bottom: 0.25em;
}

.markdown li::marker {
  color: var(--text-faint);
}

.markdown code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  padding: 1px 4px;
}

.markdown pre {
  background: #121211;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.9em 0;
}

.markdown pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.8px;
  line-height: 1.6;
  color: #ddd9d0;
}

.markdown blockquote {
  border-left: 2px solid var(--line);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 0.9em 0;
}

.markdown table {
  border-collapse: collapse;
  margin: 0.9em 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}

.markdown th,
.markdown td {
  border-bottom: 1px solid var(--line);
  padding: 6px 14px 6px 0;
  text-align: left;
  vertical-align: top;
}

.markdown th {
  font-weight: 600;
  color: var(--text-muted);
}

.markdown hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.4em 0;
}

.markdown img {
  max-width: 100%;
}

.msg.streaming .markdown::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  background: var(--amber);
  margin-left: 2px;
  vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
}

/* Waiting for the model: a blinking block cursor */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 1.55rem;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-faint);
  animation: tick 1.2s steps(1) infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes tick {
  0%,
  100% {
    background: var(--text-faint);
  }
  30% {
    background: var(--amber);
  }
}

.msg-body .typing-indicator {
  margin-top: 6px;
}

.status-note {
  padding-left: calc(var(--gutter) + 17px);
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

/* Errors in the transcript */
/* Same edge as the rule on user messages, text in the same column as all replies */
.msg-error-body {
  min-width: 0;
  padding: 8px 14px 8px 15px;
  border-left: 2px solid var(--danger);
  background: var(--danger-wash);
  color: #f0c4b8;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.msg-error-body strong {
  display: block;
  color: #fbe0d8;
  font-weight: 600;
  margin-bottom: 2px;
}

.msg-error-body .markdown {
  font-size: 14px;
  color: inherit;
}

.msg-error-body .markdown p {
  margin: 0;
}

.msg-error-body a {
  color: #fbe0d8;
}

/* Empty states */
.chat-empty-inner {
  padding: 10vh 0 0 calc(var(--gutter) + 17px);
  color: var(--text-muted);
}

.chat-empty-inner p {
  font-size: 14.5px;
  margin-bottom: 18px;
  max-width: 46ch;
}

.chat-empty-inner code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

.welcome-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 40px;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 14px;
}

.welcome .btn {
  margin-bottom: 14px;
}

.warning-box {
  max-width: calc(var(--gutter) + var(--measure));
  margin: 12px auto 0;
  border-left: 2px solid var(--amber);
  background: var(--amber-wash);
  color: #ead2a6;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.warning-box.error {
  border-left-color: var(--danger);
  background: var(--danger-wash);
  color: #f0c4b8;
}

.chat-empty-inner .warning-box {
  margin: 0 0 16px;
}

/* ---------- Message actions ---------- */

.msg-actions {
  grid-column: 2;
  display: flex;
  gap: 2px;
  margin-top: 4px;
  padding-left: 13px;
  opacity: 0;
  transition: opacity 0.12s;
}

.msg:hover .msg-actions,
.msg:focus-within .msg-actions,
.msg-error .msg-actions {
  opacity: 1;
}

.msg-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-faint);
}

.msg-action svg {
  width: 13px;
  height: 13px;
}

.msg-action:hover {
  color: var(--text);
  background: var(--hover);
}

.msg-action.done {
  color: var(--ok);
}

/* On user messages the edit action sits in the role column, so it takes no extra line */
.msg.user {
  position: relative;
}

.msg.user .msg-actions {
  grid-column: auto;
  position: absolute;
  left: 0;
  top: calc(18px + 1.6rem);
  width: calc(var(--gutter) - 10px);
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

.messages > .msg.user:first-child .msg-actions {
  top: 1.6rem;
}

/* Editing a sent message */
.msg-edit {
  display: grid;
  gap: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--amber);
}

.msg-edit .textarea {
  min-height: 80px;
  font-size: 15px;
}

.msg-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-edit-actions .form-hint {
  margin: 0 auto 0 0;
}

/* ---------- Code blocks ---------- */

.markdown pre {
  position: relative;
  padding-top: 0;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  margin: 0 -14px 10px;
  padding: 0 6px 0 14px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 6px;
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-faint);
}

.code-copy svg {
  width: 12px;
  height: 12px;
}

.code-copy:hover {
  color: var(--text);
  background: var(--hover);
}

.code-copy.done {
  color: var(--ok);
}

/* Syntax colours: muted, warm, one accent for keywords */
.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-meta .hljs-keyword {
  color: #e0a040;
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute .hljs-string {
  color: #a9c48a;
}

.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
  color: #d9a07a;
}

.hljs-comment,
.hljs-quote,
.hljs-deletion {
  color: #77736b;
  font-style: italic;
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: #e8e6e1;
  font-weight: 500;
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-property {
  color: #b9b3a6;
}

.hljs-type,
.hljs-title.class_,
.hljs-tag,
.hljs-name {
  color: #c9b98f;
}

.hljs-meta {
  color: #8f8b84;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 600;
}

/* ---------- Answer versions ---------- */
.msg-actions:has(.version-nav) {
  opacity: 1;
}

.version-nav {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  padding-right: 6px;
  border-right: 1px solid var(--line-soft);
}

.version-count {
  min-width: 30px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.version-step {
  padding: 0 3px;
}

.version-step:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ---------- Steps: reasoning and tool calls before an answer ---------- */

/* One block above the answer. The line sits where the amber line of your
   messages sits; folded it is a single summary line. */
.work {
  min-width: 0;
  margin: 0 0 12px -17px;
  border-left: 1px solid var(--line);
  padding-left: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.work summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.work summary::-webkit-details-marker {
  display: none;
}

.work summary::before {
  content: "▸";
  flex: none;
  color: var(--text-faint);
  transition: transform 0.12s;
}

.work > summary::before {
  color: var(--amber);
}

.work[open] > summary::before,
.work-step[open] > summary::before,
.tool-detail[open] > summary::before {
  transform: rotate(90deg);
}

.work-summary:hover,
.work-step > summary:hover,
.tool-detail > summary:hover {
  color: var(--text-muted);
}

.work-title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.work-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work.live > .work-summary .work-title::after {
  content: " …";
  color: var(--amber);
  animation: blink 1s steps(2) infinite;
}

.work.has-error > .work-summary .work-meta {
  color: var(--danger);
}

.work-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin-top: 6px;
}

/* A single step: the summary already names it, so it is not listed again. */
.work.single > .work-steps > .tool-step > .tool-detail > summary,
.work.single > .work-steps > .reasoning-step > summary {
  display: none;
}

.work.single > .work-steps {
  margin-top: 2px;
}

.work.single > .work-steps > .tool-step > .tool-detail,
.work.single > .work-steps > .reasoning-step {
  display: block;
}

/* One line per step: name, then what came of it – cut off, never wrapped. */
.work-step > summary,
.tool-detail > summary {
  padding: 2px 0;
}

.step-name {
  flex: none;
  color: var(--text);
  white-space: nowrap;
}

.reasoning-step .step-name {
  color: var(--text-muted);
}

.step-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.reasoning-step .step-info {
  color: var(--text-faint);
}

.step-state {
  flex: none;
}

.step-state:empty {
  display: none;
}

.tool-step.running .step-state,
.tool-step.awaiting .step-state,
.reasoning-step[data-live] .step-name {
  color: var(--amber);
}

.tool-step.error .step-state,
.tool-step.error .step-name {
  color: var(--danger);
}

.reasoning-text {
  margin: 4px 0 8px 18px;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.tool-detail > pre,
.tool-confirm-args {
  margin: 4px 0 8px 18px;
  padding: 10px 12px;
  background: #121211;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
  color: #cfcbc2;
}

.tool-detail > pre.tool-args-text {
  color: var(--text-muted);
}

.tool-confirm-args {
  flex-basis: 100%;
  margin: 0;
}

.work .hidden {
  display: none;
}

.work .tool-confirm {
  font-family: var(--font-sans);
  color: var(--text);
}

.work.live > .work-summary .work-meta {
  color: var(--amber);
}

/* ---------- Tool confirmation ---------- */

.tool-confirm {
  display: flex;
  margin-left: 18px;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 2px solid var(--amber);
  background: var(--amber-wash);
  font-size: 13px;
}

.tool-confirm span {
  margin-right: auto;
}

/* ---------- History cut ---------- */

.context-cut {
  max-width: calc(var(--gutter) + var(--measure));
  margin: 4px auto 22px;
  padding: 8px 0 8px calc(var(--gutter) + 17px);
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.context-cut span {
  flex: 1;
}

.context-cut .link-btn {
  white-space: nowrap;
  color: var(--text-muted);
}

/* ---------- Sources below an answer ---------- */
.sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.sources-label {
  margin-right: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.source-chip {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
}

.source-chip:hover {
  border-color: var(--amber);
  color: var(--amber);
}

/* ---------- Start screens ---------- */

.ready {
  max-width: calc(var(--gutter) + var(--measure));
  margin: 0 auto;
  padding: 8vh 0 24px;
}

.ready-model {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: calc(var(--gutter) + 17px);
  margin-bottom: 28px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}

.ready-model span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ready-model .brand-caret {
  flex-shrink: 0;
}

.ready-warning {
  margin: 0 0 20px calc(var(--gutter) + 17px);
}

.ready-block {
  margin-bottom: 22px;
}

.ready-block > .msg-role {
  padding-top: 5px;
}

.ready-rows {
  padding-left: 17px;
  display: grid;
}

.ready-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

.ready-row:last-child {
  border-bottom: none;
}

.ready-key {
  color: var(--text-muted);
}

.ready-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: left;
}

.ready-value.off {
  color: var(--text-faint);
}

button.ready-value:hover {
  color: var(--amber);
}

.ready-suggestions {
  padding-left: 17px;
  display: grid;
  gap: 2px;
}

.suggestion {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.suggestion:last-child {
  border-bottom: none;
}

.suggestion::before {
  content: "▸";
  color: var(--amber);
  font-size: 12px;
}

.suggestion-text {
  color: var(--text);
  font-size: 14.5px;
}

.suggestion-hint {
  margin-left: auto;
  padding-left: 12px;
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.suggestion:hover .suggestion-text {
  color: var(--amber-strong);
}

.ready-note {
  padding-left: 17px;
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 60ch;
}

.ready-start {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-left: 17px;
}

.ready-start .ready-note {
  padding-left: 0;
  margin: 0;
}

.ready-start code,
.ready-note code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
}

.ready-recent {
  padding-left: 17px;
  display: grid;
}

.recent-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
  color: var(--text);
}

.recent-time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.recent-item:hover .recent-title {
  color: var(--amber-strong);
}

/* Under an answer that only saw the beginning of a large document */
.coverage-note {
  margin: 10px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--amber);
  font-size: 12.5px;
  color: var(--text-muted);
}
