/* /chat: AI assistant. Uses the design tokens from style.css (light + dark). */
.chat { display: flex; flex-direction: column; gap: 14px; max-width: 820px; min-width: 0; }
.chat-list { display: flex; flex-direction: column; gap: 14px; min-height: 240px; min-width: 0; }

.chat-start { padding: 28px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.chat-start h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; margin-bottom: 14px; }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.starter { text-align: left; padding: 12px 14px; min-height: 44px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: .92rem; line-height: 1.4; cursor: pointer; }
.starter:hover { background: var(--surface-subtle); }

.msg { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }
.msg-who { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.msg-body { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); overflow-wrap: anywhere; min-width: 0; }
.msg.user { align-items: flex-end; }
.msg.user .msg-body { background: var(--text); color: var(--bg); border-color: var(--text); max-width: 90%; }
.msg.user .msg-who { text-align: right; }
.msg-body > * + * { margin-top: 10px; }
.msg-body p { margin: 0; line-height: 1.55; }
.msg-body p + p, .msg-body ul + p, .msg-body ol + p, .msg-body p + ul, .msg-body p + ol { margin-top: 10px; }
.msg-body ul, .msg-body ol { margin: 0; padding-left: 22px; line-height: 1.55; }
.msg-body li + li { margin-top: 4px; }
.msg-body code { font-family: var(--mono); font-size: .88em; padding: 1px 6px; border-radius: 6px; background: var(--surface-subtle); }
.msg-body a { font-family: var(--mono); font-size: .93em; overflow-wrap: anywhere; }
.msg-body .md-h { margin-top: 12px; }
.chat-stopped { color: var(--text-muted); font-size: .85rem; }

.tool-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 12px; border-radius: 9999px; border: 1px solid var(--border-strong); background: var(--surface-subtle); color: var(--text-muted); font-size: .82rem; font-weight: 500; line-height: 1.4; margin: 0 8px 8px 0; }
.tool-chip span { overflow-wrap: anywhere; }
.tool-chip.ok { color: var(--green-text); background: var(--green-tint); border-color: transparent; }
.tool-chip.err { color: var(--red); background: var(--red-tint); border-color: transparent; }
.tool-chip .spin { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: chat-spin .8s linear infinite; }
@keyframes chat-spin { to { transform: rotate(360deg); } }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: chat-bounce 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-bounce { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-error, .chat-status { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: .92rem; }
.chat-error { background: var(--red-tint); border-color: color-mix(in srgb, var(--red) 30%, transparent); }

.chat-form { position: sticky; bottom: 0; z-index: 2; display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.chat-input { width: 100%; min-height: 44px; max-height: 160px; resize: none; padding: 10px 12px; font: inherit; line-height: 1.4; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.chat-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); opacity: .8; }
.chat-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-actions .grow { flex: 1 1 0; }
.chat-actions .btn { min-height: 40px; }
.chat-quota { font-size: .82rem; font-weight: 500; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chat-quota.low { color: var(--red); }
.chat-note { font-size: .8rem; color: var(--text-muted); line-height: 1.5; }

.chat-soon .chat-examples { list-style: none; padding: 0; margin: 6px 0 4px; display: grid; gap: 8px; width: 100%; max-width: 460px; }
.chat-soon .chat-examples li { padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-subtle); color: var(--text); font-size: .92rem; text-align: left; }

@media (max-width: 600px) {
  .starters { grid-template-columns: 1fr; }
  .msg.user .msg-body { max-width: 100%; }
  .msg-body { padding: 10px 12px; }
  .chat-actions .btn { flex: 1 1 auto; }
  .chat-quota { flex: 1 0 100%; order: -1; }
  .chat-actions .grow { display: none; }
}
