/*
 * Cortex Assistant — slideout chat UI.
 * Tokens: --rd-* only. See docs/design-system.md.
 *
 * Hooks the layout/JS depends on:
 *   #agent-slideout, .agent-slideout-open,
 *   #agent-slideout-body, [data-fullpage="true"], #agent-messages-<id>,
 *   #agent-pending-action-<id>.
 */

@layer components {
  /* The trigger button now lives in the redesign topbar (.rd-ai-trigger in
     redesign/shell.css), not as a fixed bottom-right tile, so it no longer
     collides with the Herald changelog widget. */

  /* ---------------------------------------------------------------- */
  /* Slideout shell.                                                  */
  /* ---------------------------------------------------------------- */
  .agent-slideout {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(460px, 96vw);
    background: var(--rd-bg-raised);
    border-left: 1px solid var(--rd-border);
    box-shadow: var(--rd-shadow-pop);
    transform: translateX(100%);
    transition: transform var(--rd-dur) var(--rd-ease);
    display: flex;
    flex-direction: column;
    z-index: 999;
    color: var(--rd-fg);
  }
  .agent-slideout-open {
    transform: translateX(0);
  }
  /* Full-page mode (used by agent_conversations#show) — drop the fixed
     positioning and let the slideout flow inside the layout. */
  .agent-slideout[data-fullpage="true"] {
    position: static;
    transform: none;
    height: auto;
    min-height: 70vh;
    width: 100%;
    border-left: 0;
    box-shadow: none;
    background: transparent;
  }

  /* ---------------------------------------------------------------- */
  /* Header — avatar + title + status + actions.                      */
  /* ---------------------------------------------------------------- */
  .agent-slideout-header {
    display: flex;
    align-items: center;
    gap: var(--rd-sp-3);
    padding: var(--rd-sp-3) var(--rd-sp-4);
    border-bottom: 1px solid var(--rd-border);
    background: var(--rd-bg-raised);
  }
  .agent-slideout-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    background: var(--rd-accent);
    color: var(--rd-accent-fg);
    border-radius: 0;
  }
  .agent-slideout-avatar svg {
    width: 18px;
    height: 18px;
  }
  .agent-slideout-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
  }
  .agent-slideout-title {
    margin: 0;
    font-family: var(--rd-font-sans);
    font-size: var(--rd-text-md);
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--rd-fg);
  }
  .agent-slideout-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--rd-text-xs);
    color: var(--rd-fg-muted);
    min-width: 0;
  }
  .agent-slideout-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rd-success);
    flex: 0 0 auto;
  }
  .agent-slideout-status-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .agent-slideout-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
  }
  .agent-slideout-icon-btn {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--rd-fg-muted);
    border: 0;
    border-radius: var(--rd-radius-md);
    cursor: pointer;
    transition:
      background var(--rd-dur-fast) var(--rd-ease),
      color var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-slideout-icon-btn:hover {
    background: var(--rd-bg-hover);
    color: var(--rd-fg);
  }
  .agent-slideout-icon-btn:focus-visible {
    outline: none;
    background: var(--rd-bg-hover);
    color: var(--rd-fg);
    box-shadow: 0 0 0 2px var(--rd-accent-soft);
  }

  /* ---------------------------------------------------------------- */
  /* Body — flex column hosting the empty state or the conversation.  */
  /* ---------------------------------------------------------------- */
  .agent-slideout-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--rd-bg);
    overflow: hidden;
  }

  /* ---------------------------------------------------------------- */
  /* Empty state.                                                     */
  /* ---------------------------------------------------------------- */
  .agent-empty {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--rd-sp-7) var(--rd-sp-5) var(--rd-sp-5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--rd-sp-3);
  }
  .agent-empty-icon {
    width: 48px;
    height: 48px;
    display: inline-grid;
    place-items: center;
    color: var(--rd-accent);
    background: var(--rd-accent-soft);
    border-radius: 14px;
  }
  .agent-empty h3 {
    margin: 0;
    font-size: var(--rd-text-lg);
    font-weight: 600;
    color: var(--rd-fg);
    letter-spacing: -0.01em;
  }
  .agent-empty p {
    margin: 0;
    color: var(--rd-fg-muted);
    font-size: var(--rd-text-sm);
    max-width: 32ch;
  }
  .agent-empty-examples {
    list-style: none;
    margin: var(--rd-sp-2) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 360px;
  }
  .agent-empty-examples li {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .agent-empty-example {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: var(--rd-bg-raised);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-md);
    color: var(--rd-fg);
    font: inherit;
    font-size: var(--rd-text-sm);
    text-align: left;
    cursor: pointer;
    transition: background var(--rd-dur-fast) var(--rd-ease),
                border-color var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-empty-example:hover {
    background: var(--rd-bg-sunken);
    border-color: var(--rd-border-strong);
  }
  .agent-empty-example:focus-visible {
    outline: 2px solid var(--rd-border-focus);
    outline-offset: 2px;
  }
  .agent-empty-example:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
  .agent-empty-actions {
    margin-top: var(--rd-sp-2);
  }

  /* ---------------------------------------------------------------- */
  /* History list — recent conversations rendered into the body.     */
  /* ---------------------------------------------------------------- */
  .agent-history {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .agent-history-head {
    padding: var(--rd-sp-3) var(--rd-sp-4);
    border-bottom: 1px solid var(--rd-border);
    background: var(--rd-bg-sunken);
  }
  .agent-history-title {
    margin: 0;
    font-size: var(--rd-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rd-fg-muted);
  }
  .agent-history-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: var(--rd-sp-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .agent-history-item {
    display: flex;
    align-items: stretch;
    gap: 2px;
    border-radius: var(--rd-radius-md);
    transition: background var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-history-item:hover {
    background: var(--rd-bg-hover);
  }
  .agent-history-item-button {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-radius: var(--rd-radius-md);
    color: var(--rd-fg);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .agent-history-item-button:focus-visible {
    outline: 2px solid var(--rd-border-focus);
    outline-offset: -2px;
  }
  .agent-history-item-title {
    font-size: var(--rd-text-sm);
    font-weight: 500;
    color: var(--rd-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .agent-history-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--rd-text-2xs);
    color: var(--rd-fg-muted);
    overflow: hidden;
  }
  .agent-history-item-project {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--rd-fg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .agent-history-item-project svg {
    flex: 0 0 auto;
  }
  .agent-history-item-time {
    flex: 0 0 auto;
  }
  .agent-history-item-delete {
    align-self: center;
    margin-right: 6px;
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--rd-fg-subtle);
    border: 0;
    border-radius: var(--rd-radius-sm);
    cursor: pointer;
    opacity: 0;
    transition:
      background var(--rd-dur-fast) var(--rd-ease),
      color var(--rd-dur-fast) var(--rd-ease),
      opacity var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-history-item:hover .agent-history-item-delete,
  .agent-history-item-delete:focus-visible {
    opacity: 1;
  }
  .agent-history-item-delete:hover {
    background: var(--rd-danger-soft);
    color: var(--rd-danger);
  }
  /* button_to renders an inline <form>; flatten it so the row stays a single
     flex line. */
  .agent-history-item form {
    display: contents;
  }
  .agent-history-empty {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--rd-sp-3);
    padding: var(--rd-sp-6);
    text-align: center;
    color: var(--rd-fg-muted);
  }
  .agent-history-empty p {
    margin: 0;
    font-size: var(--rd-text-sm);
  }

  /* ---------------------------------------------------------------- */
  /* Conversation panel.                                              */
  /* ---------------------------------------------------------------- */
  .agent-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .agent-panel-subheader {
    padding: 8px var(--rd-sp-4);
    border-bottom: 1px solid var(--rd-border);
    background: var(--rd-bg-sunken);
    font-size: var(--rd-text-xs);
    color: var(--rd-fg-muted);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .agent-pinned-project {
    color: var(--rd-fg);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid transparent;
  }
  .agent-pinned-project:hover {
    color: var(--rd-accent);
    border-bottom-color: var(--rd-accent);
  }
  .agent-panel-unavailable {
    flex: 1;
    display: grid;
    place-items: center;
    padding: var(--rd-sp-6);
    color: var(--rd-fg-muted);
    text-align: center;
  }
  .agent-panel-unavailable h2 {
    font-size: var(--rd-text-md);
    color: var(--rd-fg);
    margin: 0 0 4px;
  }
  .agent-panel-unavailable p {
    margin: 0;
    font-size: var(--rd-text-sm);
  }

  /* ---------------------------------------------------------------- */
  /* Messages.                                                        */
  /* ---------------------------------------------------------------- */
  .agent-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--rd-sp-4);
    list-style: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--rd-sp-4);
  }
  .agent-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 100%;
  }
  /* Hide the role label by default — the bubble side already conveys
     "user vs assistant". The `tool` row keeps it for clarity. */
  .agent-message-role {
    display: none;
    text-transform: uppercase;
    font-size: var(--rd-text-2xs);
    letter-spacing: 0.08em;
    color: var(--rd-fg-subtle);
    font-weight: 500;
  }
  .agent-message-content {
    word-break: break-word;
    font-size: var(--rd-text-sm);
    line-height: 1.5;
  }
  /* Zero default block margins so the bubble sizes to its content; restore
     spacing only between consecutive blocks. Applies to both simple_format
     output (user/tool) and rendered markdown (assistant). */
  .agent-message-content > :first-child { margin-top: 0; }
  .agent-message-content > :last-child { margin-bottom: 0; }
  .agent-message-content p,
  .agent-message-content ul,
  .agent-message-content ol,
  .agent-message-content blockquote,
  .agent-message-content pre,
  .agent-message-content table {
    margin: 0 0 8px;
  }
  .agent-message-content h1,
  .agent-message-content h2,
  .agent-message-content h3,
  .agent-message-content h4,
  .agent-message-content h5,
  .agent-message-content h6 {
    margin: 12px 0 4px;
    font-weight: 600;
    line-height: 1.3;
  }
  .agent-message-content h1 { font-size: var(--rd-text-lg); }
  .agent-message-content h2 { font-size: var(--rd-text-base); }
  .agent-message-content h3,
  .agent-message-content h4,
  .agent-message-content h5,
  .agent-message-content h6 { font-size: var(--rd-text-sm); }
  .agent-message-content ul,
  .agent-message-content ol {
    padding-left: 1.25em;
  }
  .agent-message-content li + li { margin-top: 2px; }
  .agent-message-content li > ul,
  .agent-message-content li > ol { margin: 2px 0 0; }
  .agent-message-content code {
    font-family: var(--rd-font-mono);
    font-size: 0.92em;
    padding: 1px 4px;
    background: var(--rd-bg-sunken);
    border: 1px solid var(--rd-border);
    border-radius: 3px;
  }
  .agent-message-content pre {
    padding: 8px 10px;
    background: var(--rd-bg-sunken);
    border: 1px solid var(--rd-border);
    border-radius: 4px;
    overflow-x: auto;
  }
  .agent-message-content pre code {
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }
  .agent-message-content blockquote {
    padding: 2px 0 2px 10px;
    border-left: 3px solid var(--rd-border-strong);
    color: var(--rd-fg-muted);
  }
  .agent-message-content a {
    color: var(--rd-accent);
    text-decoration: underline;
  }
  .agent-message-content table {
    border-collapse: collapse;
    width: 100%;
    font-size: var(--rd-text-xs);
  }
  .agent-message-content th,
  .agent-message-content td {
    padding: 4px 8px;
    border: 1px solid var(--rd-border);
    text-align: left;
  }
  .agent-message-content hr {
    border: 0;
    border-top: 1px solid var(--rd-border);
    margin: 10px 0;
  }

  /* User — right-aligned accent bubble. */
  .agent-message-user {
    align-items: flex-end;
  }
  .agent-message-user .agent-message-content {
    padding: 8px 12px;
    background: var(--rd-accent-soft);
    color: var(--rd-fg);
    border: 1px solid color-mix(in oklab, var(--rd-accent) 28%, transparent);
    border-radius: 0;
    max-width: 85%;
  }

  /* Assistant — left-aligned bubble next to the sparkle avatar. The grid
     keeps multi-line replies aligned with the speaker tile. */
  .agent-message-assistant {
    align-items: flex-start;
    display: grid;
    grid-template-columns: 28px 1fr;
    column-gap: 10px;
    row-gap: 6px;
  }
  .agent-message-assistant::before {
    content: "";
    grid-row: 1;
    grid-column: 1;
    width: 28px;
    height: 28px;
    background: var(--rd-accent);
    color: var(--rd-accent-fg);
    border-radius: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z'/><path d='M20 3v4'/><path d='M22 5h-4'/><path d='M4 17v2'/><path d='M5 18H3'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
  }
  .agent-message-assistant > .agent-message-content,
  .agent-message-assistant > .agent-typing-indicator,
  .agent-message-assistant > .agent-message-attachments,
  .agent-message-assistant > [id^="agent-pending-action-"],
  .agent-message-assistant > .agent-pending-state,
  .agent-message-assistant > .agent-callout {
    grid-column: 2;
  }
  .agent-message-assistant > .agent-message-role {
    grid-column: 2;
    grid-row: 1;
  }
  .agent-message-assistant > .agent-message-content {
    padding: 8px 12px;
    background: var(--rd-bg-raised);
    border: 1px solid var(--rd-border);
    border-radius: 0;
    max-width: 100%;
  }

  /* Tool — compact inline checklist, full width. Job results echo back
     here so the user can see what the agent actually ran. */
  .agent-message-tool {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    background: var(--rd-bg-raised);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-md);
    font-family: var(--rd-font-mono);
    font-size: var(--rd-text-xs);
    color: var(--rd-fg-muted);
    line-height: 1.35;
  }
  .agent-message-tool .agent-message-role {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--rd-success);
    margin-bottom: 0;
    line-height: 1;
  }
  .agent-message-tool .agent-message-role::before {
    content: "";
    width: 14px;
    height: 14px;
    background: var(--rd-success-soft);
    border-radius: 50%;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2334a853' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    flex: 0 0 auto;
  }
  .agent-message-tool .agent-message-content {
    color: var(--rd-fg);
    font-family: inherit;
    font-size: inherit;
    white-space: pre-wrap;
  }

  /* Attachments. */
  .agent-message-attachments {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .agent-message-attachments li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--rd-text-2xs);
    padding: 2px 8px;
    background: var(--rd-bg-sunken);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-full);
    color: var(--rd-fg-muted);
  }

  /* Typing indicator — three dots that pulse. */
  .agent-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--rd-bg-raised);
    border: 1px solid var(--rd-border);
    border-radius: 0;
  }
  .agent-typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--rd-fg-faint);
    border-radius: 50%;
    animation: agent-typing-bounce 1.1s infinite ease-in-out;
  }
  .agent-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
  .agent-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
  @keyframes agent-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-3px); opacity: 1; }
  }

  /* ---------------------------------------------------------------- */
  /* Pending action card — review-and-apply.                          */
  /* ---------------------------------------------------------------- */
  .agent-pending-action {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--rd-bg-raised);
    border: 1px solid var(--rd-warn);
    border-radius: var(--rd-radius-md);
    box-shadow: 0 0 0 3px var(--rd-warn-soft);
  }
  .agent-pending-action-summary {
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }
  .agent-pending-action-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    background: var(--rd-warn-soft);
    color: var(--rd-warn);
    border-radius: 8px;
  }
  .agent-pending-action-titles {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .agent-pending-action-title {
    font-size: var(--rd-text-sm);
    font-weight: 600;
    color: var(--rd-fg);
  }
  .agent-pending-action-meta {
    font-size: var(--rd-text-xs);
    color: var(--rd-fg-muted);
  }
  .agent-pending-action-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--rd-warn-soft);
    color: var(--rd-warn);
    border-radius: var(--rd-radius-full);
    font-size: var(--rd-text-2xs);
    font-weight: 500;
    letter-spacing: 0.02em;
    flex: 0 0 auto;
  }
  .agent-pending-action-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .agent-pending-action-list li {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 8px;
    background: var(--rd-bg-sunken);
    border-radius: var(--rd-radius-sm);
    font-family: var(--rd-font-mono);
    font-size: var(--rd-text-xs);
    color: var(--rd-fg);
    line-height: 1.4;
  }
  .agent-pending-action-list li::before {
    content: "";
    width: 4px;
    height: 4px;
    margin-top: 8px;
    border-radius: 50%;
    background: var(--rd-fg-faint);
    flex: 0 0 auto;
  }
  .agent-pending-tool {
    display: inline-block;
    padding: 1px 5px;
    background: var(--rd-bg-raised);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-sm);
    font-family: var(--rd-font-mono);
    font-size: var(--rd-text-2xs);
    color: var(--rd-fg-muted);
    margin-right: 4px;
  }
  .agent-pending-action-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
  }
  .agent-pending-action-hint {
    font-size: var(--rd-text-xs);
    color: var(--rd-fg-subtle);
    flex: 1;
    min-width: 0;
  }
  .agent-pending-action-buttons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .agent-pending-state {
    padding: 8px 10px;
    background: var(--rd-bg-sunken);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-sm);
    font-size: var(--rd-text-xs);
    color: var(--rd-fg-muted);
  }

  /* ---------------------------------------------------------------- */
  /* Inline callouts (failure notices).                               */
  /* ---------------------------------------------------------------- */
  .agent-callout {
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--rd-radius-md);
    font-size: var(--rd-text-sm);
    line-height: 1.4;
  }
  .agent-callout-warn {
    background: var(--rd-warn-soft);
    color: var(--rd-fg);
    border-color: color-mix(in oklab, var(--rd-warn) 30%, transparent);
  }
  .agent-callout-danger {
    background: var(--rd-danger-soft);
    color: var(--rd-fg);
    border-color: color-mix(in oklab, var(--rd-danger) 30%, transparent);
  }

  /* ---------------------------------------------------------------- */
  /* Composer.                                                        */
  /* ---------------------------------------------------------------- */
  .agent-composer {
    border-top: 1px solid var(--rd-border);
    padding: var(--rd-sp-3) var(--rd-sp-3) var(--rd-sp-2);
    background: var(--rd-bg-raised);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .agent-composer-shell {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 8px 8px 12px;
    background: var(--rd-bg-sunken);
    border: 1px solid var(--rd-border);
    border-radius: 0;
    transition: border-color var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-composer-shell:focus-within {
    border-color: var(--rd-border-focus);
  }
  .agent-composer-input {
    flex: 1;
    min-width: 0;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--rd-fg);
    font-family: var(--rd-font-sans);
    font-size: var(--rd-text-sm);
    line-height: 1.5;
    resize: none;
    padding: 6px 0;
    /* ~3 lines so longer drafts stay legible without expanding immediately;
       the controller grows it past this up to max-height as the user types. */
    min-height: 72px;
    max-height: 240px;
    overflow-y: auto;
  }
  .agent-composer-input:focus {
    outline: none;
  }
  .agent-composer-input::placeholder {
    color: var(--rd-fg-subtle);
  }
  .agent-composer-attach {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--rd-fg-muted);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-md);
    cursor: pointer;
    flex: 0 0 auto;
    transition:
      background var(--rd-dur-fast) var(--rd-ease),
      color var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-composer-attach:hover {
    background: var(--rd-bg-hover);
    color: var(--rd-fg);
  }
  .agent-composer-attach input[type="file"] {
    display: none;
  }
  .agent-composer-send {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    background: var(--rd-accent);
    color: var(--rd-accent-fg);
    border: 0;
    border-radius: var(--rd-radius-md);
    cursor: pointer;
    flex: 0 0 auto;
    transition: background var(--rd-dur-fast) var(--rd-ease);
  }
  .agent-composer-send:hover {
    background: var(--rd-accent-hover);
  }
  .agent-composer-send:disabled,
  .agent-composer-send[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
  }
  .agent-composer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 4px;
    color: var(--rd-fg-subtle);
    font-size: var(--rd-text-2xs);
    min-height: 18px;
  }
  .agent-composer-hints {
    display: inline-flex;
    align-items: center;
    gap: 12px;
  }
  .agent-composer-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .agent-composer-kbd {
    font-family: var(--rd-font-mono);
    font-size: 10px;
    padding: 1px 4px;
    background: var(--rd-bg-sunken);
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-sm);
    color: var(--rd-fg-muted);
    line-height: 1;
  }
  .agent-composer-status {
    text-align: right;
    color: var(--rd-fg-muted);
  }
  .agent-composer-status:empty {
    display: none;
  }

  /* ---------------------------------------------------------------- */
  /* Mobile.                                                          */
  /* ---------------------------------------------------------------- */
  @media (max-width: 540px) {
    .agent-slideout {
      width: 100vw;
    }
  }
}
