/*
 * The conversation: timeline frame, messages, the docked request card, the action-log group, notices, turn footers,
 * Markdown and the rewind and fork dialogs. Follows docs/DESIGN.md: Claude's words are prose (--fs-prose, at most
 * about 70 characters a line), what Claude does is the monospace action log (tools.css). Tokens come from app.css.
 */

/* Hidden elements stay hidden even where a display rule below sets one. */
.tl-root [hidden] {
  display: none !important;
}

/* ---- Frame -------------------------------------------------------------------------------------------------------- */

.tl-root {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  --tl-dock: 0px;
}

.tl-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: calc(var(--tl-dock) + var(--space-4));
}

.tl-col {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-3);
}

/* Rhythm: 12 px between the blocks of a turn; 24 px where a turn starts (its user message) or a divider sits. The
   gaps are margins of the entries, so an entry's hidden parts (its message toolbar) never add to them. */
.tl-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tl-list > * + * {
  margin-top: var(--space-3);
}

.tl-list > * + [data-kind="user"],
.tl-list > [data-kind="user"] + *,
.tl-list > * + [data-kind="divider"],
.tl-list > [data-kind="divider"] + * {
  margin-top: var(--space-5);
}

.tl-head,
.tl-tail {
  min-height: 1px;
}

.tl-head:not(:empty) {
  margin-bottom: var(--space-3);
}

.tl-load-earlier {
  align-self: center;
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.tl-jump {
  position: sticky;
  bottom: calc(var(--tl-dock) + var(--space-3));
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow-md);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}

.tl-jump .icon {
  width: 12px;
  height: 12px;
}

.tl-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) 0;
}

.skel {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-sunken), var(--bg-hover), var(--bg-sunken));
  background-size: 200% 100%;
  animation: cards-sheen 1.4s ease-in-out infinite;
}

.skel-short {
  width: 30%;
}

.skel-mid {
  width: 55%;
}

.skel-long {
  width: 80%;
}

.tl-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}

.tl-state-text {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.tl-state-action {
  flex: 0 0 auto;
}

.tl-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-6) 0 var(--space-4);
}

.tl-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.tl-empty-icon .icon {
  width: 18px;
  height: 18px;
}

.tl-empty-title {
  margin: 0;
  color: var(--fg);
  font-size: var(--fs-lg);
  font-weight: 600;
}

/* The one line under the title: how to start (DESIGN.md, Empty states). */
.tl-empty-lead {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  line-height: 18px;
}

@keyframes cards-sheen {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

/* ---- Messages ----------------------------------------------------------------------------------------------------- */

.msg {
  position: relative;
  min-width: 0;
}

.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.msg-bubble {
  box-sizing: border-box;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  color: var(--fg);
  font-size: var(--fs-prose);
  line-height: 26px;
  overflow-wrap: anywhere;
}

.msg-text {
  white-space: pre-wrap;
}

.msg-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-bottom: 6px;
}

.msg-image {
  display: block;
  max-width: 220px;
  max-height: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  object-fit: cover;
}

.msg-files {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

.file-chip .icon {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
}

.file-chip > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  min-height: 24px;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

.msg-status-label {
  white-space: nowrap;
}

.msg-status.is-queued {
  color: var(--fg-subtle);
}

.msg-cancel {
  min-height: 24px;
  padding: 0 8px;
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.msg-failed {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  color: var(--danger);
  font-size: var(--fs-xs);
}

.msg-failed-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.msg-user.is-sending .msg-bubble {
  opacity: 0.72;
}

.msg-user.is-failed .msg-bubble {
  border: 1px solid var(--danger);
}

.msg-assistant {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.msg-body {
  min-width: 0;
}

.msg-notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-notes:empty {
  display: none;
}

.msg-note {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.msg-note.is-error {
  color: var(--danger);
}

.msg-note.is-muted {
  color: var(--fg-subtle);
}

/* The message toolbar floats under its message: it shows on hover, on focus or after a tap (touch), and takes no space,
   so the rhythm between blocks does not include it. */
.msg-actions {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease);
}

.msg:focus-within > .msg-actions,
.msg.is-actions > .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

/* Hover counts only where a pointer can hover. On touch screens the hover a tap leaves behind would keep the toolbar
   open, so there a tap alone shows and hides it (tapToggleActions in view.js). */
@media (hover: hover) {
  .msg:hover > .msg-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.msg-user > .msg-actions {
  justify-content: flex-end;
}

.msg-action {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
}

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

/* ---- Prose: Claude's words -------------------------------------------------------------------------------------- */

.md {
  max-width: 70ch;
  color: var(--fg);
  font-size: var(--fs-prose);
  line-height: 26px;
  overflow-wrap: anywhere;
}

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

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

.md p,
.md ul,
.md ol,
.md blockquote,
.md .code-block,
.md .md-table-wrap {
  margin: 0 0 12px;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 20px 0 8px;
  color: var(--fg);
  font-weight: 600;
  line-height: 1.3;
}

/* --fs-xl is the welcome title's size alone (DESIGN.md), so a heading in a message stops at --fs-lg. */
.md h1 {
  font-size: var(--fs-lg);
}

.md h2 {
  font-size: var(--fs-lg);
}

.md h3,
.md h4 {
  font-size: var(--fs-md);
}

.md ul,
.md ol {
  padding-left: 1.4em;
}

.md li + li {
  margin-top: 4px;
}

.md li > p {
  margin: 0 0 4px;
}

.md blockquote {
  padding: 0 0 0 14px;
  border-left: 2px solid var(--border-strong);
  color: var(--fg-muted);
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 2px;
}

.md hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.md code {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.md img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.md-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.md table {
  border-collapse: collapse;
  font-size: var(--fs-sm);
  line-height: 20px;
}

.md th,
.md td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

.md th {
  color: var(--fg-muted);
  font-weight: 600;
}

/* Fenced code: sunken, bordered, with its language and a copy button in the head. */
.code-block {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  font-size: var(--fs-prose);
  line-height: 1.55;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 30px;
  padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

.code-lang {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
}

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

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

.code-block pre {
  box-sizing: border-box;
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: calc(12.5px * var(--fs-scale, 1));
  line-height: 1.55;
  white-space: pre;
}

.code-block pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* Thinking: quiet, collapsible, the reasoning text in muted prose. */
.thinking {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.thinking-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  cursor: pointer;
  list-style: none;
}

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

.thinking-summary .icon {
  width: 12px;
  height: 12px;
  transition: transform 140ms var(--ease);
}

.thinking[open] > .thinking-summary .icon {
  transform: rotate(90deg);
}

.thinking-body {
  margin: 4px 0 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--border);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.draft-tool {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: var(--fs-sm);
}

.draft-tool-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  color: var(--fg-muted);
}

.draft-tool-name {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.draft-tool-body {
  margin: 0;
  max-height: 160px;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--border);
  overflow: hidden;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: calc(12.5px * var(--fs-scale, 1));
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.shimmer {
  background: linear-gradient(90deg, var(--fg-subtle), var(--fg), var(--fg-subtle));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: cards-sheen 1.8s linear infinite;
}

/* ---- Action-log group (work) and its rows ------------------------------------------------------------------------- */

.work {
  min-width: 0;
  font-size: var(--fs-sm);
}

.work-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 30px;
  color: var(--fg-muted);
  cursor: pointer;
  list-style: none;
}

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

.work-summary .icon {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  transition: transform 140ms var(--ease);
}

.work[open] > .work-summary .icon.icon-chevron-right {
  transform: rotate(90deg);
}

.work-label {
  flex: 0 0 auto;
  color: var(--fg-muted);
  font-weight: 500;
}

.work-count {
  flex: 0 0 auto;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

.work-running {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--accent);
}

.work-running-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-muted);
}

.work-summary > .work-running {
  flex: 1 1 auto;
}

.work-body {
  margin-top: 2px;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--border);
}

.work-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.work-item {
  min-width: 0;
}

.work-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.work-row.is-denied,
.work-row.is-error {
  color: var(--danger);
}

.work-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.work-row-title {
  color: var(--fg);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.work-row-text {
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

/* A summary rendered as Markdown keeps the row's small, muted text: no paragraph margins, inline code stays compact. */
.work-row-text > .md {
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.work-row-text > .md > :first-child {
  margin-top: 0;
}

.work-row-text > .md > :last-child {
  margin-bottom: 0;
}

.work-row-text.is-error {
  color: var(--danger);
}

.work-row-hint {
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
}

.work-row-output {
  margin: 4px 0 0;
  max-height: 180px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  overflow: auto;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: calc(12.5px * var(--fs-scale, 1));
  line-height: 1.55;
  white-space: pre-wrap;
}

.sub-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--border);
}

/* ---- The docked request card ---------------------------------------------------------------------------------------- */

/* The newest request sticks above the composer, the one place that asks for a decision. */
.request-slot {
  min-width: 0;
}

.request-slot.is-latest {
  position: sticky;
  bottom: var(--space-2);
  z-index: 3;
}

.request-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  box-sizing: border-box;
  padding: var(--space-3) var(--space-4) var(--space-4) calc(var(--space-4) + 3px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow-md);
  color: var(--fg);
}

.request-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--attention);
}

.request-card[data-state="sending"] {
  opacity: 0.85;
}

.request-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.request-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--attention);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.request-badge .icon {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
}

.request-time {
  flex: 0 0 auto;
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.request-title {
  margin: 0;
  color: var(--fg);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 22px;
  overflow-wrap: anywhere;
}

.request-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.request-text {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  line-height: 20px;
  overflow-wrap: anywhere;
}

.request-plan {
  max-height: 46vh;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  overflow-y: auto;
}

.request-json,
.request-url,
.request-tool,
.request-chip {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.request-json {
  margin: 0;
  max-height: 180px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  overflow: auto;
  color: var(--fg);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.request-kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  font-size: var(--fs-sm);
}

.request-k {
  color: var(--fg-muted);
}

.request-v {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.request-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: var(--fs-sm);
  word-break: break-all;
}

.request-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--fg);
}

.request-reason,
.request-required {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

/* The runtime's reason for asking: an info glyph, then the sentence, on one baseline. */
.request-reason {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.request-reason > .icon {
  flex: none;
  align-self: center;
}

.request-required {
  color: var(--danger);
}

.request-options,
.request-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.request-suggestions-title,
.request-q-legend {
  margin: 0;
  padding: 0;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.request-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  cursor: pointer;
}

.request-option:hover,
.request-option:focus-visible {
  background: var(--bg-hover);
}

.request-option-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.request-option-label {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.request-option-desc {
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  line-height: 16px;
  overflow-wrap: anywhere;
}

/* "Also allow in future" is a compact checklist: no box or tint per item, a hairline only between items. The box and the
   first line of the title share a centre line (14 px box, 20 px line). */
.request-suggestions {
  gap: 0;
}

.request-suggestions-title {
  margin-bottom: 4px;
}

.request-suggestion {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 6px 0;
  color: var(--fg);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.request-suggestion + .request-suggestion {
  border-top: 1px solid var(--border);
}

.request-suggestion-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.request-suggestion-title {
  font-weight: 500;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.request-suggestion-meta {
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  line-height: 16px;
  overflow-wrap: anywhere;
}

.request-suggestion-check {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.request-check {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

/* A boolean field: the box and its text are one label, so they stay on one line and align on the same centre. */
.request-field-check {
  gap: 4px;
  min-width: 0;
}

.request-check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  min-width: 0;
  color: var(--fg);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.request-check-label .field-label {
  margin: 0;
}

.request-note {
  margin: 0;
}

.request-note-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.request-note-toggle::-webkit-details-marker {
  display: none;
}

.request-note-toggle:hover {
  color: var(--fg);
}

.request-field,
.request-form,
.request-deny-field,
.request-other,
.request-feedback {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.request-question {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.request-q-text {
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.request-deny-input,
.request-other-input,
.request-input,
.request-mode {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  resize: vertical;
}

.request-deny-input:focus-visible,
.request-other-input:focus-visible,
.request-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.request-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: 2px;
}

.request-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.request-btn.btn-deny {
  border: 1px solid var(--danger);
  background: var(--bg-elev);
  color: var(--danger);
}

.request-btn.btn-deny:hover {
  background: var(--bg-hover);
}

.request-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  opacity: 0.7;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1;
}

.request-status {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

.request-status.is-error {
  color: var(--danger);
}

.request-status.is-info {
  color: var(--fg-muted);
}

.request-card :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.request-card[data-state="sending"] .request-btn,
.request-card[data-state="stale"] .request-btn {
  pointer-events: none;
}

/* ---- Notices, dividers, turn footers ----------------------------------------------------------------------------- */

.notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.notice.is-error {
  color: var(--danger);
}

.notice.is-warning {
  color: var(--attention);
}

.notice-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.notice-action {
  min-height: 28px;
  font-size: var(--fs-xs);
}

.notice-collapse {
  min-width: 0;
  width: 100%;
}

/* A collapsed note that is the notice's whole body stays on the icon's line; opened, its text wraps inside it. */
.notice-collapse.is-body {
  flex: 1 1 0;
  width: auto;
}

.notice-collapse > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  cursor: pointer;
  list-style: none;
}

.notice-collapse > summary::-webkit-details-marker {
  display: none;
}

/* A small chevron says the raw error opens; it turns when the detail is open. */
.notice-collapse > summary::after {
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  margin: 0 2px 2px 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: '';
  transform: rotate(45deg);
  transition: transform 140ms var(--ease);
}

.notice-collapse[open] > summary::after {
  margin-bottom: -2px;
  transform: rotate(-135deg);
}

@media (prefers-reduced-motion: reduce) {
  .notice-collapse > summary::after {
    transition: none;
  }
}

/* The raw error of a retry, under the notice line: mono, indented under a rule, never a box. */
.notice-detail {
  min-width: 0;
  margin: 0 0 0 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--border);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.divider-label {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The compacting row keeps the divider's box (same height, same rhythm), so the boundary turns it into the divider
   without moving the conversation. Its two rules become slim bars that sweep while the compaction runs. */
.divider.is-compacting {
  color: var(--fg-muted);
}

.divider.is-compacting::before,
.divider.is-compacting::after {
  height: 2px;
  border-radius: 999px;
  background-color: var(--accent-soft);
  background-image: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
  background-repeat: no-repeat;
  background-size: 40% 100%;
  animation: compacting-sweep 1400ms linear infinite;
}

@keyframes compacting-sweep {
  from {
    background-position: -67% 0;
  }

  to {
    background-position: 167% 0;
  }
}

.divider-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.divider-elapsed {
  flex: 0 0 auto;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  /* The sweep stops: the two rules stay as static, half-strength bars. */
  .divider.is-compacting::before,
  .divider.is-compacting::after {
    animation: none;
    background-color: var(--accent);
    background-image: none;
    opacity: 0.5;
  }
}

.withdrawn {
  color: var(--fg-subtle);
  font-size: var(--fs-sm);
  font-style: italic;
}

/* An answer the gateway gave on its own (unattended mode): one muted line with an icon. It has no buttons and
   no card. */
.work-auto {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  min-height: 30px;
  padding: 4px 8px;
  color: var(--fg-subtle);
  font-size: var(--fs-sm);
}

.work-auto > .icon {
  flex: 0 0 auto;
  margin-top: 3px;
}

.work-auto-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.work-auto-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-width: 0;
}

.work-auto-text {
  overflow-wrap: anywhere;
}

.work-auto-tool {
  color: var(--fg-muted);
  font-weight: 500;
}

.work-auto-target {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The question an automatic answer replied to: collapsed under the line, prose, indented under a rule. */
.work-auto-detail {
  color: var(--fg-muted);
}

.work-auto-question {
  min-width: 0;
  margin: 2px 0 0 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--border);
  color: var(--fg-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The turn footer: one muted sentence ("Done in 0.9 s, 3 turns"), never a row of separators. */
.turn-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.turn-result-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.turn-result-line .icon {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  color: var(--success);
}

.turn-result.is-error .turn-result-line {
  color: var(--danger);
}

.turn-result.is-error .turn-result-line .icon {
  color: var(--danger);
}

.turn-result.is-interrupted .turn-result-line .icon {
  color: var(--fg-subtle);
}

.turn-errors,
.turn-denials {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.turn-denials {
  color: var(--fg-muted);
}

/* ---- Other cards: generic tool details, raw command output, hooks, tasks ------------------------------------------ */

.generic {
  min-width: 0;
  font-size: var(--fs-sm);
}

.generic-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  color: var(--fg-muted);
  cursor: pointer;
  list-style: none;
}

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

.generic-label {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.generic-hint {
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
}

.generic-body {
  margin: 0 0 0 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--border);
  overflow-x: auto;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: calc(12.5px * var(--fs-scale, 1));
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cmd-output {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cmd-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

.cmd-body {
  box-sizing: border-box;
  margin: 0;
  max-height: 240px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  overflow: auto;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: calc(12.5px * var(--fs-scale, 1));
  line-height: 1.55;
  white-space: pre-wrap;
}

/* Rewind and fork dialogs */
.rewind-form,
.rewind-preview,
.rewind-files,
.rewind-modes,
.rewind-mode {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.rewind-modes {
  margin: 0;
  padding: 0;
  border: 0;
}

.rewind-mode {
  flex-direction: row;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.rewind-mode:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.rewind-mode-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rewind-mode-label {
  font-weight: 500;
}

.rewind-mode-hint,
.rewind-note {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  line-height: 16px;
}

.rewind-files {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

.rewind-error {
  margin: 0;
  color: var(--danger);
  font-size: var(--fs-sm);
}

/* Pickers inside request cards: the question list and the checklists share one row style. */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.choice-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
}

.choice-label {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.choice-hint {
  color: var(--fg-muted);
  font-size: var(--fs-xs);
}

/* ---- Accessibility and motion ------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .skel,
  .shimmer {
    animation: none;
  }

  .shimmer {
    color: var(--fg-muted);
    background: none;
  }

  .tl-jump,
  .msg-actions,
  .work-summary .icon,
  .thinking-summary .icon {
    transition: none;
  }
}

@media (pointer: coarse) {
  /* Touch targets: 44 px for the actions a finger reaches for. */
  .msg-action,
  .msg-cancel,
  .code-copy,
  .notice-action,
  .notice-collapse > summary,
  .request-btn,
  .request-option,
  .request-suggestion,
  .request-check-label,
  .request-note-toggle,
  .tl-load-earlier,
  .tl-jump {
    min-height: 44px;
  }

  /* A suggestion row: the whole line is the target, with the box centred on it. */
  .request-suggestion {
    align-items: center;
  }
}
