pre code.hljs {
  display: block;
  overflow-x: auto;
  padding: 1em
}
code.hljs {
  padding: 3px 5px
}
/*!
  Theme: GitHub Dark Dimmed
  Description: Dark dimmed theme as seen on github.com
  Author: github.com
  Maintainer: @Hirse
  Updated: 2021-05-15

  Colors taken from GitHub's CSS
*/
.hljs {
  color: #adbac7;
  background: #22272e
}
.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ {
  /* prettylights-syntax-keyword */
  color: #f47067
}
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ {
  /* prettylights-syntax-entity */
  color: #dcbdfb
}
.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id {
  /* prettylights-syntax-constant */
  color: #6cb6ff
}
.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string {
  /* prettylights-syntax-string */
  color: #96d0ff
}
.hljs-built_in,
.hljs-symbol {
  /* prettylights-syntax-variable */
  color: #f69d50
}
.hljs-comment,
.hljs-code,
.hljs-formula {
  /* prettylights-syntax-comment */
  color: #768390
}
.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo {
  /* prettylights-syntax-entity-tag */
  color: #8ddb8c
}
.hljs-subst {
  /* prettylights-syntax-storage-modifier-import */
  color: #adbac7
}
.hljs-section {
  /* prettylights-syntax-markup-heading */
  color: #316dca;
  font-weight: bold
}
.hljs-bullet {
  /* prettylights-syntax-markup-list */
  color: #eac55f
}
.hljs-emphasis {
  /* prettylights-syntax-markup-italic */
  color: #adbac7;
  font-style: italic
}
.hljs-strong {
  /* prettylights-syntax-markup-bold */
  color: #adbac7;
  font-weight: bold
}
.hljs-addition {
  /* prettylights-syntax-markup-inserted */
  color: #b4f1b4;
  background-color: #1b4721
}
.hljs-deletion {
  /* prettylights-syntax-markup-deleted */
  color: #ffd8d3;
  background-color: #78191b
}
.hljs-char.escape_,
.hljs-link,
.hljs-params,
.hljs-property,
.hljs-punctuation,
.hljs-tag {
  /* purposely ignored */
  
}/* =========================================================================
   Max Chat — estilos base
   Paleta oscura por defecto, tema claro con [data-theme='light'].
   ========================================================================= */

:root {
  --bg: #0b0e14;
  --bg-elevated: #121722;
  --bg-panel: #0f141d;
  --bg-hover: #1a2130;
  --bg-active: #202a3d;
  --border: #1f2735;
  --border-strong: #2c364a;
  --text: #e8edf7;
  --text-muted: #97a3b8;
  --text-dim: #6b778c;
  --accent: #4f8cff;
  --accent-strong: #2f6ef0;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --danger: #ff5f6d;
  --danger-soft: rgba(255, 95, 109, 0.12);
  --success: #35d39a;
  --warning: #f5b544;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial,
    sans-serif;
}

html[data-theme='light'] {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-panel: #ffffff;
  --bg-hover: #eef1f7;
  --bg-active: #e4e9f4;
  --border: #e2e6ef;
  --border-strong: #cdd4e2;
  --text: #17202e;
  --text-muted: #5a6577;
  --text-dim: #8b95a7;
  --accent: #2f6ef0;
  --accent-strong: #1f57cc;
  --accent-soft: rgba(47, 110, 240, 0.1);
  --danger: #d93b4c;
  --danger-soft: rgba(217, 59, 76, 0.1);
  --shadow: 0 18px 40px rgba(23, 32, 46, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
}

/* --------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-columns: 296px 1fr;
  height: var(--app-height, 100%);
  max-height: var(--app-height, 100%);
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

/* -------------------------------------------------------------- sidebar */

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 0 0 10px;
  min-height: 0;
}

.sidebar__head {
  padding: 42px 16px 12px;
  display: grid;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  box-shadow: 0 6px 16px rgba(79, 140, 255, 0.35);
}

.brand__text {
  display: grid;
  line-height: 1.2;
}

.brand__text strong {
  font-size: 15px;
  letter-spacing: 0.2px;
}

.brand__text span {
  font-size: 11.5px;
  color: var(--text-dim);
}

.sidebar__search {
  margin: 0 16px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-dim);
}

.sidebar__search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
}

.sidebar__search input::-webkit-search-cancel-button {
  display: none;
}

.sidebar__list {
  overflow-y: auto;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.sidebar__empty {
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 10px 8px;
  margin: 0;
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------- hilos */

.thread {
  position: relative;
  border-radius: 10px;
  display: flex;
  align-items: center;
}

.thread:hover {
  background: var(--bg-hover);
}

.thread--active {
  background: var(--bg-active);
}

.thread--editing {
  padding: 6px;
}

.thread__input {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--bg-elevated);
  padding: 6px 8px;
  outline: none;
}

.thread__main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 10px;
}

.thread__title {
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread__meta {
  font-size: 11px;
  color: var(--text-dim);
}

.thread__preview {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.thread__actions,
.thread__confirm {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
}

.thread__actions {
  opacity: 0;
  transition: opacity 0.12s ease;
}

.thread:hover .thread__actions {
  opacity: 1;
}

.thread__confirm {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- botones */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  background: var(--bg-hover);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button--primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.button--primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button--danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.button--block {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.12s ease, color 0.12s ease;
}

.icon-button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-button--lg {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
}

.icon-button--danger:hover {
  color: var(--danger);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.segmented__item {
  border: none;
  background: transparent;
  padding: 4px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.segmented__item--active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

/* ---------------------------------------------------------- cabecera */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  -webkit-app-region: drag;
}

.chat-header__info {
  min-width: 0;
}

.chat-header__title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__subtitle {
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.chat-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  -webkit-app-region: no-drag;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.chip--model {
  font-family: var(--mono);
  font-size: 10.5px;
}

.chip--live {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

/* ----------------------------------------------------------- mensajes */

.messages {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  height: 100%;
  padding: 26px 0 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.messages__inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.messages__end {
  height: 1px;
  width: 100%;
  flex: none;
}

.messages__loading {
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px 0;
}

.message {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
}

.message__avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin-top: 2px;
}

.message--assistant .message__avatar {
  background: linear-gradient(140deg, rgba(79, 140, 255, 0.2), rgba(123, 92, 255, 0.2));
  border-color: transparent;
  color: var(--accent);
}

.message__body {
  min-width: 0;
}

.message__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
}

.message__author {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.message__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.message__status--error {
  color: var(--danger);
}

.message__content {
  font-size: 14px;
}

.message__plain {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.message--user .message__content {
  background: var(--accent-soft);
  border: 1px solid rgba(79, 140, 255, 0.22);
  border-radius: var(--radius);
  padding: 9px 13px;
}

.message__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  min-height: 26px;
}

.message__meta {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.message__actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.message:hover .message__actions {
  opacity: 1;
}

.message__error {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 95, 109, 0.35);
  background: var(--danger-soft);
  color: var(--text);
}

.message__error svg {
  color: var(--danger);
  flex: none;
  margin-top: 2px;
}

.message__error strong {
  font-size: 12.5px;
}

.message__error p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- markdown */

.markdown > *:first-child {
  margin-top: 0;
}

.markdown > *:last-child {
  margin-bottom: 0;
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 10px;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 16px 0 8px;
  line-height: 1.3;
}

.markdown h1 {
  font-size: 19px;
}
.markdown h2 {
  font-size: 17px;
}
.markdown h3 {
  font-size: 15px;
}

.markdown ul,
.markdown ol {
  padding-left: 22px;
}

.markdown li + li {
  margin-top: 3px;
}

.markdown a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.markdown a:hover {
  border-bottom-color: var(--accent);
}

.markdown blockquote {
  margin: 0 0 10px;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.markdown code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}

.markdown pre {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0f131b;
  overflow-x: auto;
}

.markdown pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.6;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 13px;
}

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

.markdown th {
  background: var(--bg-elevated);
}

.markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.markdown img {
  max-width: 100%;
  border-radius: var(--radius);
}

/* ------------------------------------------------- razonamiento / estado */

.reasoning {
  margin: 0 0 8px;
}

.reasoning__toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
}

.reasoning__chevron {
  font-family: var(--mono);
}

.reasoning__text {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}

.caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 6px 0;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.1s infinite ease-in-out;
}

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

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ------------------------------------------------------------ bienvenida */

.welcome {
  text-align: center;
  padding: 46px 10px 10px;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.welcome__badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  box-shadow: 0 10px 26px rgba(79, 140, 255, 0.3);
}

.welcome__title {
  margin: 6px 0 0;
  font-size: 21px;
}

.welcome__text {
  margin: 0;
  max-width: 520px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.welcome__suggestions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 520px;
}

.welcome__suggestion {
  text-align: left;
  padding: 10px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.welcome__suggestion:hover {
  border-color: var(--accent);
  color: var(--text);
}

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

.composer {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.composer__box {
  max-width: 780px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.composer__box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer__input {
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  max-height: 260px;
  line-height: 1.55;
  padding: 6px 0;
}

.composer__actions {
  display: flex;
  align-items: center;
  padding-bottom: 2px;
}

.composer__footer {
  max-width: 780px;
  margin: 8px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.composer__meta {
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ servidor */

.server {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.server:hover {
  background: var(--bg-hover);
}

.server__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  flex: none;
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.server__dot--on {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(53, 211, 154, 0.15);
}

.server__dot--checking {
  background: var(--warning);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.server__text {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}

.server__text strong {
  font-size: 12px;
  font-weight: 600;
}

.server__text span {
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 40;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 12, 0.62);
  backdrop-filter: blur(2px);
}

.modal__panel {
  position: relative;
  width: min(680px, calc(100vw - 48px));
  max-height: calc(100vh - 80px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal__head h2 {
  margin: 0;
  font-size: 15.5px;
}

.modal__body {
  overflow-y: auto;
  padding: 16px 18px;
  display: grid;
  gap: 20px;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.fieldset {
  display: grid;
  gap: 12px;
}

.fieldset h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
}

.field {
  display: grid;
  gap: 5px;
}

.field > span {
  font-size: 12.5px;
  color: var(--text-muted);
}

.field small {
  font-size: 11px;
  color: var(--text-dim);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--bg-elevated);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.12s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.field--row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.field--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.inline-warning {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid rgba(245, 181, 68, 0.35);
  background: rgba(245, 181, 68, 0.1);
  font-size: 12px;
  color: var(--text);
}

.diagnostics {
  display: grid;
  gap: 7px;
  margin: 0;
  font-size: 12px;
}

.diagnostics > div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
}

.diagnostics dt {
  color: var(--text-dim);
}

.diagnostics dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
}

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(680px, calc(100vw - 48px));
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 60;
}

.toast--error {
  border-color: rgba(255, 95, 109, 0.4);
}

.toast--error svg {
  color: var(--danger);
  flex: none;
}

.toast--info svg {
  color: var(--accent);
  flex: none;
}

/* ---------------------------------------------------------- splash/fatal */

.splash,
.fatal {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.splash__mark {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  animation: pulse 1.6s infinite;
}

.fatal h1 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.fatal svg {
  color: var(--danger);
}

/* ---------------------------------------------------------- scrollbars */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------------------------------------------------------- login */

.login {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}

.login__card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px 26px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  justify-items: stretch;
}

.login__badge {
  justify-self: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  box-shadow: 0 10px 26px rgba(79, 140, 255, 0.3);
}

.login__title {
  margin: 0;
  text-align: center;
  font-size: 22px;
}

.login__subtitle {
  margin: 0 0 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.login__error {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 95, 109, 0.35);
  background: var(--danger-soft);
  font-size: 12.5px;
}

.login__error svg {
  color: var(--danger);
  flex: none;
}

.login__foot {
  margin: 2px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
}

.login__foot code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 4px;
}

.inline-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------------------------------------------------- traza del agente */

.chip--agent {
  color: #b07bff;
  border-color: rgba(176, 123, 255, 0.35);
  background: rgba(176, 123, 255, 0.14);
}

.trace {
  margin: 10px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  overflow: hidden;
}

.trace__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}

.trace--collapsed .trace__head {
  border-bottom: none;
}

.trace__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.trace__pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}

.trace__pulse--live {
  background: #b07bff;
  animation: pulse 1.2s infinite;
}

.trace__status {
  font-weight: 500;
  color: var(--text-dim);
}

.trace__chevron {
  font-family: var(--mono);
  color: var(--text-dim);
}

.trace__meta {
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

.trace__steps {
  list-style: none;
  margin: 0;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trace-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.trace-step__badge {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: lowercase;
}

.trace-step__badge--call {
  background: rgba(176, 123, 255, 0.16);
  color: #b07bff;
}

.trace-step__text {
  color: var(--text-muted);
  font-style: italic;
}

.trace-step--thought .trace-step__text {
  white-space: pre-wrap;
}

.trace-step__args {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  word-break: break-all;
}

.trace-step--result {
  flex-direction: column;
  gap: 3px;
}

.trace-step__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  padding: 1px 0;
  text-align: left;
}

.trace-step__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex: none;
}

.trace-step__dot--fail {
  background: var(--danger);
}

.trace-step__summary {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-step--failed .trace-step__summary {
  color: var(--danger);
}

.trace-step__time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  flex: none;
}

.trace-step__output {
  margin: 0 0 6px 14px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 280px;
  overflow: auto;
}

.trace__error {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}

/* === MOBILE COMPACT === */
.chat-header__title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-header__menu {
  display: none;
  -webkit-app-region: no-drag;
  flex: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .app,
  .main {
    height: var(--app-height, 100%);
    max-height: var(--app-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  .messages {
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .composer {
    flex: none;
    position: relative;
    z-index: 2;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top);
  }

  .app--sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.45);
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar__head {
    padding-top: 16px;
  }

  .chat-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 10px;
    padding: 8px 10px calc(8px + env(safe-area-inset-top, 0px) * 0);
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .chat-header__menu {
    display: inline-grid;
  }

  .chat-header__info {
    flex: 1 1 auto;
    min-width: 0;
  }

  .chat-header__title {
    font-size: 14px;
  }

  .chat-header__subtitle {
    gap: 6px;
    margin-top: 2px;
    flex-wrap: wrap;
    font-size: 11px;
  }

  .chat-header__actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .chip--model,
  .chat-header__settings {
    display: none;
  }

  .segmented__item {
    padding: 4px 9px;
    font-size: 12px;
  }

  .icon-button--lg {
    width: 34px;
    height: 34px;
  }

  .messages {
    padding: 12px 0 4px;
  }

  .messages__inner {
    padding: 0 12px;
    gap: 14px;
  }

  .message {
    grid-template-columns: 26px 1fr;
    gap: 8px;
  }

  .message__meta {
    font-size: 10.5px;
  }

  .composer {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer__box {
    gap: 8px;
    padding: 8px 8px 8px 12px;
    border-radius: 14px;
  }

  .composer__input {
    font-size: 16px; /* evita zoom iOS */
    line-height: 1.4;
    padding: 4px 0;
  }

  .composer__footer {
    margin-top: 6px;
    font-size: 10.5px;
  }

  .composer__hint-keys,
  .composer__hint-agent,
  .composer__model {
    display: none;
  }

  .composer__send span,
  .composer__stop {
    /* keep labels but shorten via CSS content not needed */
  }

  .composer__send,
  .composer__stop {
    padding: 8px 12px;
    font-size: 13px;
  }

  .welcome {
    padding: 28px 8px 8px;
  }
}

@media (max-width: 420px) {
  .chat-header__count {
    display: none;
  }

  .segmented--profile .segmented__item {
    padding: 4px 7px;
  }
}
