/* Like Messages: no side panel; the conversation spans the main and side columns of the shared grid. */
.layout.in-agent .content {
  grid-column: 2 / -1;
}

/* Tira, the agent (src/ui/agent.js): a full-height conversation with a centered column and the composer at the
   bottom. Its own file so the agent's look stays apart from the rest of styles.css. */

/* The section fills the viewport: the page itself doesn't scroll, the conversation does. */
.layout.in-agent .content {
  padding-bottom: 0;
}

/* No browser margins in here: the spacing below is the section's own. */
.agent-page :is(h2, h3, h4, h5, h6, p, ul, ol, blockquote, pre) {
  margin: 0;
}

.agent-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.agent-new {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.agent-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.agent-column {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------------------------------------------------------------- the empty chat */

.agent-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 12vh 8px 0;
}

.agent-welcome h2 {
  font-size: 24px;
  font-weight: 750;
}

.agent-welcome p {
  max-width: 440px;
}

.agent-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}

.agent-prompts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin-top: 14px;
}

.agent-prompt {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.agent-prompt:hover {
  background: var(--surface-2);
}

/* ---------------------------------------------------------------- messages */

.agent-row {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.agent-row.mine {
  justify-content: flex-end;
}

.agent-bubble {
  max-width: 80%;
  padding: 9px 14px;
  border-radius: 18px;
  background: var(--surface-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.agent-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.agent-reply {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-text {
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.agent-page .agent-text > * + * {
  margin-top: 0.7em;
}

.agent-text h3,
.agent-text h4,
.agent-text h5,
.agent-text h6 {
  font-size: 16px;
  font-weight: 700;
}

.agent-page .agent-text :is(ul, ol) {
  padding-left: 1.4em;
}

.agent-text li + li {
  margin-top: 0.25em;
}

.agent-text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 0.9em var(--mono);
}

.agent-text pre {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  overflow-x: auto;
}

.agent-text pre code {
  padding: 0;
  background: none;
}

.agent-text blockquote {
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.agent-table {
  overflow-x: auto;
}

.agent-text table {
  border-collapse: collapse;
  font-size: 14px;
}

.agent-text th,
.agent-text td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

/* While a reply streams, a caret trails its last words (after the last block, or the last item of a list). */
.agent-row[data-status="streaming"] .agent-text > :last-child:not(ul, ol, pre, div)::after,
.agent-row[data-status="streaming"] .agent-text > :last-child:is(ul, ol) > li:last-child::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--muted);
  animation: agent-blink 1s steps(2) infinite;
}

@keyframes agent-blink {
  50% {
    opacity: 0;
  }
}

.agent-typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.agent-typing span:not(.visually-hidden) {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: agent-bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes agent-bounce {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: none;
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.agent-note {
  font-size: 14px;
  color: var(--muted);
}

.agent-note.danger {
  color: var(--danger);
}

/* ---------------------------------------------------------------- tool activity */

.agent-page .agent-tools {
  padding: 0;
}

.agent-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  font-size: 13.5px;
  color: var(--muted);
}

.agent-tool {
  display: flex;
  align-items: center;
  gap: 7px;
}

.agent-tool.done .icon {
  color: var(--accent);
}

.agent-tool.failed {
  color: var(--danger);
}

.agent-dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: agent-spin 0.8s linear infinite;
}

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

.agent-plugin {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
}

/* ---------------------------------------------------------------- cards, choices, chips */

.agent-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.agent-card.nested {
  padding: 10px 12px;
  background: var(--surface-2);
}

.agent-card h4 {
  font-size: 15px;
  font-weight: 700;
}

.agent-card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.agent-card-row > span:last-child {
  text-align: right;
  overflow-wrap: anywhere;
}

.agent-card-row .strong {
  font-weight: 700;
}

.agent-card-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.agent-wallet-only {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 13.5px;
}

.agent-choice-label {
  font-weight: 600;
  margin-bottom: 6px;
}

.agent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.agent-chip:hover:not(:disabled) {
  background: var(--surface-2);
}

.agent-chip:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------------------------------------------------------------- the composer */

.agent-composer {
  flex: none;
  width: 100%;
  max-width: 752px;
  margin: 0 auto;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
}

.agent-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.06);
}

.agent-composer-box:focus-within {
  border-color: var(--accent);
}

/* The global field look (border, focus ring) is the box's here, not the textarea's. */
.agent-composer textarea,
.agent-composer textarea:focus {
  flex: 1;
  width: auto;
  min-height: 24px;
  max-height: 200px;
  padding: 5px 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.agent-count {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
}

.agent-count.danger {
  color: var(--danger);
}

.agent-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  cursor: pointer;
}

.agent-send:disabled {
  opacity: 0.3;
  cursor: default;
}

.agent-hint {
  margin-top: 6px;
  font-size: 12px;
  text-align: center;
}

/* ---------------------------------------------------------------- the plugins panel */

.agent-page .agent-plugins {
  padding: 0;
}

.agent-plugins {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  list-style: none;
}

.agent-plugins li {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.agent-plugin-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.agent-plugin-tools {
  margin-top: 6px;
  font-size: 13px;
}

.agent-status {
  font-size: 13px;
  font-weight: 600;
}

.agent-status.active {
  color: var(--accent);
}

.agent-status.paused,
.agent-status.off {
  color: var(--muted);
}

/* Phones: above the tab bar. */
@media (max-width: 720px) {
  .agent-page {
    height: calc(100dvh - var(--tab-bar) - env(safe-area-inset-bottom));
  }

  .layout.in-agent .content {
    min-height: 0;
    padding-bottom: 0;
  }

  .agent-prompts {
    grid-template-columns: 1fr;
  }

  .agent-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-text *::after,
  .agent-dot,
  .agent-typing span {
    animation: none;
  }
}
