:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --ink: #1d1d1b;
  --muted: #6b6a64;
  --line: #e2dfd6;
  --accent: #0f5c4d;
  --accent-ink: #ffffff;
  --ok: #1f7a4a;
  --err: #b3261e;
  --warn-bg: #fff4d6;
  --warn-line: #e0a400;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1d1d1b;
    --surface-2: #262624;
    --ink: #ecebe6;
    --muted: #a19f97;
    --line: #34332f;
    --accent: #5cc3a8;
    --accent-ink: #0c1f1a;
    --ok: #63c58c;
    --err: #ff8a80;
    --warn-bg: #3a2f10;
    --warn-line: #d9a400;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-family: var(--mono); font-size: 12px; }

.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.chat { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.mensajes { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.vacio { margin: auto; max-width: 640px; text-align: center; color: var(--muted); }
.ejemplos { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ejemplos button { text-align: left; white-space: normal; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.ejemplos button:hover { border-color: var(--accent); }

.msg { max-width: 860px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: transparent; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; width: 100%; }
.msg.confirm { border: 2px solid var(--warn-line); background: var(--warn-bg); }
.msg.error { border-color: var(--err); }
.msg .label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.tag-confirm { background: var(--warn-line); color: #1d1d1b; border-radius: 999px; padding: 1px 8px; font-size: 11px; }

.md p { margin: 6px 0; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md h1, .md h2, .md h3 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 12px 0 4px; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }

.tools { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
details.tool { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
details.tool summary { cursor: pointer; padding: 6px 10px; display: flex; gap: 8px; align-items: baseline; list-style: none; }
details.tool summary::-webkit-details-marker { display: none; }
.tool-name { font-family: var(--mono); font-weight: 600; }
.tool-status { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 0 6px; }
.tool-status.ok { color: var(--ok); border: 1px solid var(--ok); }
.tool-status.err { color: var(--err); border: 1px solid var(--err); }
.tool-status.guard { color: #1d1d1b; background: var(--warn-line); }
.tool-res { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
details.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; max-height: 320px; overflow: auto; }

.pensando { align-self: flex-start; color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.pensando::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }

.banner { margin: 0 20px; padding: 10px 14px; border: 2px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.banner-actions { margin-left: auto; display: flex; gap: 8px; }

.composer { display: flex; gap: 8px; padding: 14px 20px; }
textarea { flex: 1; resize: vertical; min-height: 46px; max-height: 200px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { border: 0; border-radius: 10px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
button:disabled { opacity: .5; cursor: progress; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.small { padding: 2px 8px; font-size: 12px; }

.panel { padding: 16px; overflow-y: auto; background: var(--surface); }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.archivos, .herramientas { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 12px; }
.archivos li, .herramientas li { padding: 3px 0; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.archivos a { color: var(--accent); text-decoration: none; }
.archivos a:hover { text-decoration: underline; }
.mt { margin-top: 20px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .panel { border-top: 1px solid var(--line); max-height: 40vh; }
  .chat { border-right: 0; }
  .top { padding: 10px 16px; }
  .mensajes, .composer { padding-left: 16px; padding-right: 16px; }
  .banner { margin: 0 16px; }
  #modelo { display: none; }
}
