/* Lea Raw chat — extracted from the inline <style> block in edit.html.haml,
   following the tools/prompt_rules.css pattern. Everything is scoped to
   .lea-raw (body via :has()) so nothing leaks to other pages. */

body:has(.lea-raw) {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  background: #f5f5f5;
}

.lea-raw { display: flex; flex-direction: column; min-height: calc(100dvh - 80px); max-width: 800px; margin: 0 auto; width: 100%; }
.lea-raw .messages { flex: 1; overflow-y: auto; padding: 1rem; padding-bottom: 120px; display: flex; flex-direction: column; gap: 0.75rem; }
.lea-raw .chat-form-wrapper { position: fixed; bottom: 12px; left: 12px; right: 12px; max-width: 776px; margin: 0 auto; z-index: 900; background: #fff; border-radius: 12px; box-shadow: 0 2px 16px rgba(0,0,0,.10); padding: 0.75rem 1rem 1rem; }

/* ── Event timeline ────────────────────────────────────────────────────── */

.lea-raw .event-row { display: flex; gap: 1rem; align-items: flex-start; }
.lea-raw .event-time { font-size: 0.7rem; color: #9ca3af; font-family: monospace; white-space: nowrap; padding-top: 0.8rem; min-width: 5.5rem; text-align: right; }
.lea-raw .event-body { flex: 1; min-width: 0; }
.lea-raw .event-bubble { border-radius: 0.75rem; padding: 0.75rem 1rem; font-size: 0.875rem; line-height: 1.6; }
.lea-raw .event-label { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.lea-raw .bubble--streaming { opacity: 0.85; }

.lea-raw .event-start { background: #e5eced; border-left: 3px solid #5a7280; }
.lea-raw .event-start .event-label { color: #1d4ed8; }
.lea-raw .event-start .event-content { color: #1e3a8a; white-space: pre-wrap; }

.lea-raw .event-text { background: #fff; border: 1px solid #e5e7eb; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.lea-raw .event-text .event-content { color: #374151; overflow-wrap: break-word; word-break: break-word; }

.lea-raw .event-tool { background: #fffbeb; border-left: 3px solid #f59e0b; }
.lea-raw .event-tool .event-label { color: #b45309; }
.lea-raw .event-tool .event-content { font-family: monospace; font-size: 0.8rem; color: #78350f; }

.lea-raw .event-thinking { background: #f3f4f6; border-left: 3px solid #9ca3af; }
.lea-raw .event-thinking .event-label { color: #6b7280; }
.lea-raw .event-thinking .event-content { color: #4b5563; font-style: italic; white-space: pre-wrap; }

.lea-raw .event-tool-result { background: #f9fafb; border-left: 3px solid #d1d5db; }
.lea-raw .event-tool-result .event-label { color: #6b7280; }
.lea-raw .event-tool-result .event-content { color: #374151; white-space: pre-wrap; }

.lea-raw .event-result { background: #f0fdf4; border: 1px solid #86efac; }
.lea-raw .event-result .event-label { color: #166534; }
.lea-raw .event-result .event-content { color: #14532d; }

.lea-raw .event-error { background: #fee2e2; border-left: 3px solid #ef4444; }
.lea-raw .event-error .event-label { color: #991b1b; }
.lea-raw .event-error .event-content { color: #7f1d1d; font-family: monospace; font-size: 0.8rem; word-break: break-all; }

.lea-raw .event-other { background: #f9fafb; border: 1px solid #f3f4f6; }
.lea-raw .event-other .event-label { color: #9ca3af; }

/* ── Markdown ──────────────────────────────────────────────────────────── */

.lea-raw .event-md > *:first-child { margin-top: 0; }
.lea-raw .event-md > *:last-child { margin-bottom: 0; }
.lea-raw .event-md h1, .lea-raw .event-md h2, .lea-raw .event-md h3 { font-weight: 700; margin: 1em 0 0.4em; line-height: 1.3; }
.lea-raw .event-md h1 { font-size: 1.25em; }
.lea-raw .event-md h2 { font-size: 1.1em; }
.lea-raw .event-md h3 { font-size: 1em; }
.lea-raw .event-md p { margin: 0.4em 0; }
.lea-raw .event-md ul, .lea-raw .event-md ol { margin: 0.4em 0; padding-left: 1.5em; }
.lea-raw .event-md li { margin: 0.1em 0; }
.lea-raw .event-md code { background: #f3f4f6; border-radius: 0.2em; padding: 0.1em 0.3em; font-family: monospace; font-size: 0.85em; }
.lea-raw .event-md pre { background: #f3f4f6; border-radius: 0.375rem; padding: 0.75em 1em; overflow-x: auto; margin: 0.5em 0; }
.lea-raw .event-md pre code { background: none; padding: 0; font-size: 0.8em; }
.lea-raw .event-md hr { border: none; border-top: 1px solid #e5e7eb; margin: 0.75em 0; }
.lea-raw .event-md strong { font-weight: 700; }
.lea-raw .event-md em { font-style: italic; }
.lea-raw .event-md blockquote { border-left: 3px solid #d1d5db; margin: 0.5em 0; padding: 0 0.75em; color: #6b7280; }
.lea-raw .event-md table { border-collapse: collapse; width: 100%; margin: 0.6em 0; font-size: 0.875em; }
.lea-raw .event-md th, .lea-raw .event-md td { border: 1px solid #e5e7eb; padding: 0.4em 0.75em; text-align: left; }
.lea-raw .event-md th { background: #f9fafb; font-weight: 600; }
.lea-raw .event-md tr:nth-child(even) { background: #f9fafb; }

/* ── Form ──────────────────────────────────────────────────────────────── */

.lea-raw textarea { width: 100%; box-sizing: border-box; padding: 0.6rem 0.75rem; border: 1px solid #ccc; border-radius: 0.5rem; resize: none; font-size: 1rem; font-family: inherit; line-height: 1.4; }
.lea-raw textarea:focus { outline: none; border-color: #465A64; }
.lea-raw textarea:disabled { background: #f9f9f9; color: #aaa; }
.lea-raw .form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; margin-top: 0.4rem; }
.lea-raw .safe-mode-label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: #6b7280; cursor: pointer; user-select: none; }
.lea-raw .safe-mode-label input[type=checkbox] { cursor: pointer; }
.lea-raw input[type=submit] { padding: 0.5rem 1.2rem; background: #465A64; color: #fff; border: none; border-radius: 0.5rem; cursor: pointer; font-size: 0.9rem; }
.lea-raw input[type=submit]:disabled { background: #93c5fd; cursor: not-allowed; }
.lea-raw .spinner { display: inline-block; width: 0.7em; height: 0.7em; border: 2px solid #bbb; border-top-color: #555; border-radius: 50%; animation: spin 0.7s linear infinite; margin-left: 0.4rem; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.lea-raw .monitor-link { font-size: 0.75rem; color: #9ca3af; text-align: center; padding: 0.25rem; }
.lea-raw .monitor-link a { color: #9ca3af; }
