.chat-panel { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.chat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.chat-title { display: flex; align-items: center; gap: .65rem; font-size: .9rem; font-weight: 750; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 16%, transparent); }
.status-dot[data-ready="true"] { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent); }
.alpha-badge { border: 1px solid var(--border); border-radius: 999px; padding: .26rem .6rem; color: var(--text-muted); background: var(--surface); font-size: .72rem; }
.messages { min-height: 0; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .85rem; scroll-behavior: smooth; }
.empty-state { margin: auto; max-width: 580px; text-align: center; padding: 2rem 1rem; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 20px; background: var(--brand-soft); color: var(--brand); font-size: 1.6rem; }
.empty-state h2 { margin: 0; font-size: 1.25rem; }
.empty-state p { margin: .65rem auto 0; color: var(--text-muted); line-height: 1.6; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-top: 1.1rem; }
.suggestion-button { text-align: left; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--text); }
.suggestion-button:hover { border-color: var(--brand); background: var(--brand-soft); }
.message-row { display: flex; }
.message-row[data-role="user"] { justify-content: flex-end; }
.message { width: min(780px, 92%); border: 1px solid var(--border); border-radius: 16px; padding: .85rem .95rem; background: var(--surface-soft); }
.message-row[data-role="user"] .message { width: auto; max-width: 78%; background: var(--brand); border-color: var(--brand); color: var(--on-brand); border-bottom-right-radius: 5px; }
.message-row[data-role="assistant"] .message { border-bottom-left-radius: 5px; }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .42rem; font-size: .72rem; font-weight: 750; opacity: .75; }
.message-body { white-space: pre-wrap; line-height: 1.55; font-size: .91rem; }
.source-list { display: grid; gap: .55rem; margin-top: .9rem; }
.source-card { display: block; padding: .72rem .78rem; border: 1px solid var(--border); border-radius: 11px; color: inherit; text-decoration: none; background: var(--surface); }
.source-card:hover { border-color: var(--brand); }
.source-card strong { display: block; font-size: .85rem; line-height: 1.35; }
.source-tags { margin-top: .45rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.source-tag { display: inline-flex; padding: .18rem .42rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: .68rem; }
.message-error { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.typing { color: var(--text-muted); }
.composer { padding: .9rem; border-top: 1px solid var(--border); background: var(--surface-soft); }
.composer-box { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .65rem; border: 1px solid var(--border-strong); border-radius: 15px; background: var(--surface); padding: .45rem; }
.composer-actions { display: flex; align-items: center; gap: .42rem; }
.voice-dictation-button { display: grid; place-items: center; width: 42px; min-width: 42px; height: 42px; padding: 0; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface); color: var(--text); cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease; }
.voice-dictation-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.voice-dictation-button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft); }
.voice-dictation-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.voice-dictation-button[data-listening="true"] { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 12%, transparent); }
.voice-dictation-button:disabled { opacity: .42; cursor: not-allowed; }
.composer textarea { width: 100%; max-height: 160px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); padding: .52rem .55rem; line-height: 1.45; }
.composer-help { margin: .45rem .2rem 0; color: var(--text-muted); font-size: .7rem; }
.source-title { display: block; color: inherit; font-weight: 750; font-size: .85rem; line-height: 1.35; text-decoration: none; }
.source-title:hover { color: var(--brand); }
.source-snippet { display: block; margin-top: .3rem; color: var(--text-muted); font-size: .76rem; line-height: 1.4; }
.evidence-details { margin-top: .65rem; border-top: 1px solid var(--border); padding-top: .55rem; }
.evidence-details summary { cursor: pointer; color: var(--brand-strong); font-size: .74rem; font-weight: 700; }
.evidence-list { display: grid; gap: .5rem; margin-top: .55rem; }
.evidence-item { margin: 0; padding: .55rem .65rem; border-left: 3px solid var(--brand); background: var(--surface-soft); border-radius: 0 9px 9px 0; }
.evidence-label { display: block; color: var(--text-muted); font-size: .66rem; font-weight: 750; }
.evidence-item p { margin: .3rem 0 0; color: var(--text); font-size: .74rem; line-height: 1.45; }
.message-status { margin: -.1rem 0 .45rem; color: var(--text-muted); font-size: .74rem; font-weight: 700; }
.message-status[hidden] { display: none; }
.message-cancelled { border-style: dashed; }
.sources-panel { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .65rem; }
.sources-panel > summary { cursor: pointer; color: var(--brand-strong); font-size: .78rem; font-weight: 750; }
.followup-suggestions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.followup-button { border: 1px solid var(--border); border-radius: 999px; padding: .35rem .58rem; background: var(--surface); color: var(--text); cursor: pointer; font-size: .72rem; }
.followup-button:hover { border-color: var(--brand); background: var(--brand-soft); }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-danger:hover { filter: brightness(.94); }

.conversation-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; min-width: 0; }
.conversation-select { width: min(260px, 28vw); min-height: 36px; border: 1px solid var(--border); border-radius: 9px; padding: .35rem .55rem; background: var(--surface); color: var(--text); font-size: .74rem; }
.button-compact { min-height: 36px; padding: .4rem .7rem; font-size: .74rem; font-weight: 700; }
.edit-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .55rem; padding: .55rem .65rem; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: 10px; background: color-mix(in srgb, var(--warning) 10%, var(--surface)); color: var(--text); font-size: .72rem; }
.edit-bar[hidden] { display: none; }
.message-footer { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-top: .75rem; padding-top: .55rem; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.message-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.message-action { border: 0; background: transparent; color: var(--text-muted); padding: .2rem .35rem; border-radius: 7px; cursor: pointer; font-size: .7rem; font-weight: 700; }
.message-action:hover { color: var(--brand-strong); background: var(--brand-soft); }
.message-action-danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.message-feedback { color: var(--success); font-size: .7rem; font-weight: 750; }
.message-feedback[hidden] { display: none; }
.message-body > :first-child { margin-top: 0; }
.message-body > :last-child { margin-bottom: 0; }
.message-body p { margin: .55rem 0; }
.message-body h2, .message-body h3, .message-body h4 { margin: .8rem 0 .4rem; line-height: 1.3; }
.message-body h2 { font-size: 1.05rem; }
.message-body h3 { font-size: .98rem; }
.message-body h4 { font-size: .92rem; }
.message-body ul, .message-body ol { margin: .55rem 0; padding-left: 1.25rem; }
.message-body li + li { margin-top: .25rem; }
.message-body blockquote { margin: .65rem 0; padding: .55rem .7rem; border-left: 3px solid var(--brand); background: var(--surface); border-radius: 0 9px 9px 0; }
.message-body pre { overflow-x: auto; margin: .65rem 0; padding: .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.message-body code { padding: .08rem .25rem; border-radius: 5px; background: var(--bg); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .86em; }
.message-body pre code { padding: 0; background: transparent; }
.message-body a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.source-reference { display: inline-flex; border-radius: 999px; padding: .05rem .35rem; background: var(--brand-soft); color: var(--brand-strong); font-size: .78em; font-weight: 750; }
.document-details { margin-top: .65rem; border-top: 1px solid var(--border); padding-top: .55rem; }
.document-details summary { cursor: pointer; color: var(--brand-strong); font-size: .74rem; font-weight: 700; }
.document-list { display: grid; gap: .42rem; margin: .55rem 0 0; padding: 0; list-style: none; }
.document-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: start; padding: .48rem .55rem; border-radius: 8px; background: var(--surface-soft); }
.document-list a { color: var(--text); font-size: .74rem; line-height: 1.35; }
.document-list a:hover { color: var(--brand-strong); }
.document-kind { margin: 0 !important; padding: .12rem .35rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong) !important; font-size: .62rem !important; white-space: nowrap; }

/* vv7.0.0-beta.3 · acciones accesibles, progreso y métricas */
.message-actions { gap: .45rem; }
.message-action {
  min-height: 30px;
  padding: .3rem .5rem;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.message-action:hover { color: var(--brand-strong); background: var(--brand-soft); }
.message-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.message-row[data-role="user"] .message-footer {
  border-top-color: color-mix(in srgb, var(--on-brand) 38%, transparent);
}
.message-row[data-role="user"] .message-action {
  border: 1px solid color-mix(in srgb, var(--on-brand) 48%, transparent);
  background: color-mix(in srgb, var(--on-brand) 12%, transparent);
  color: var(--on-brand);
  opacity: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
}
.message-row[data-role="user"] .message-action:hover {
  border-color: color-mix(in srgb, var(--on-brand) 88%, transparent);
  background: color-mix(in srgb, var(--on-brand) 24%, transparent);
  color: var(--on-brand);
}
.message-row[data-role="user"] .message-action:focus-visible {
  outline-color: var(--on-brand);
}
.message-row[data-role="user"] .message-feedback { color: var(--on-brand); }

.message-metrics {
  display: inline-flex;
  justify-content: flex-end;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.message-progress {
  display: grid;
  gap: .38rem;
  margin: .1rem 0 .65rem;
  padding: .55rem .62rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}
.message-progress[hidden] { display: none; }
.message-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 750;
}
.message-progress-header span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 72%, transparent);
}
.message-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width .2s ease;
}
.message-progress[data-phase="retrying"] .message-progress-bar { background: var(--warning); }
.message-progress[data-phase="streaming"] .message-progress-bar {
  background: linear-gradient(90deg, var(--brand), var(--accent));
}
.status-value { font-variant-numeric: tabular-nums; }
.status-value[data-state="error"] { color: var(--danger); }
.chat-title [data-network="offline"] { color: var(--danger); }

/* vv7.0.0-rc.2 · lectura, foco y composición */
.chat-panel { position: relative; }
.messages:focus-visible { outline-offset: -4px; }
.composer-support { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.character-count { margin: .45rem .2rem 0; color: var(--text-muted); font-size: .7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.character-count[data-warning="true"] { color: var(--warning); font-weight: 800; }
.scroll-latest {
  position: absolute;
  right: 1.1rem;
  bottom: 92px;
  z-index: 4;
  min-height: 38px;
  padding: .45rem .72rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 800;
}
.scroll-latest:hover { border-color: var(--brand); color: var(--brand-strong); }
.message-row { scroll-margin-block: 1rem; }
.message-actions button, .followup-button, .suggestion-button, summary { touch-action: manipulation; }
summary { min-height: 28px; }

/* v7.1.0-beta.14 · feedback estructurado */
.feedback-reasons { position: relative; }
.feedback-reasons > summary { list-style: none; display: inline-flex; align-items: center; }
.feedback-reasons > summary::-webkit-details-marker { display: none; }
.feedback-reason-menu {
  position: absolute;
  z-index: 12;
  left: 0;
  bottom: calc(100% + .35rem);
  display: grid;
  min-width: 170px;
  gap: .25rem;
  padding: .45rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}
.feedback-reason-menu .message-action { width: 100%; justify-content: flex-start; text-align: left; }
.feedback-sent-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: .3rem .55rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: .7rem;
  font-weight: 800;
}

/* v7.1.0-beta.18 · portada, categorías y fuentes enriquecidas */
.chat-toolbar { background: color-mix(in srgb, var(--surface) 96%, var(--brand-soft)); }
.service-pill { display: inline-flex; align-items: center; gap: .55rem; min-height: 34px; padding: .35rem .65rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: .75rem; font-weight: 800; }
.empty-state { width: 100%; max-width: 920px; padding: 1.6rem 1rem 2rem; text-align: left; }
.empty-intro { max-width: 760px; margin: 0 auto; text-align: center; }
.empty-eyebrow { display: inline-flex; padding: .28rem .65rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: .72rem; font-weight: 850; letter-spacing: .02em; }
.empty-state h2 { margin-top: .75rem; font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -.03em; }
.empty-description { max-width: 720px; font-size: .98rem; }
.official-notice { max-width: 720px; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); font-size: .76rem; }
.category-section, .example-section { margin-top: 1.35rem; }
.category-section h3, .example-section h3 { margin: 0 0 .65rem; font-size: .82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.category-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .55rem; }
.category-button { display: flex; min-height: 94px; flex-direction: column; justify-content: center; gap: .45rem; padding: .7rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 800; text-align: left; }
.category-button:hover { transform: translateY(-2px); border-color: var(--brand); background: var(--brand-soft); }
.category-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand-strong); font-size: 1rem; }
.composer-notice { margin: .2rem .2rem 0; color: var(--text-muted); font-size: .66rem; }
.composer-support > div { min-width: 0; }
.message-row[data-role="assistant"] .message { width: min(860px, 96%); background: var(--surface); }
.sources-panel { margin-top: 1rem; padding-top: .85rem; }
.sources-panel-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.sources-panel-header h3 { margin: 0; font-size: .82rem; }
.source-count { display: grid; min-width: 24px; height: 24px; place-items: center; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: .68rem; font-weight: 900; }
.source-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.source-card { display: flex; flex-direction: column; gap: .55rem; padding: .8rem; }
.source-card-primary { grid-column: 1 / -1; border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface)); }
.source-card-header { display: grid; gap: .42rem; }
.source-role { display: inline-flex; width: fit-content; padding: .18rem .45rem; border-radius: 999px; background: var(--surface-soft); color: var(--text-muted); font-size: .62rem; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.source-role-primary { background: var(--brand); color: var(--on-brand); }
.source-meta { display: flex; flex-wrap: wrap; gap: .35rem; }
.source-meta span { display: inline-flex; margin: 0; padding: .16rem .38rem; border-radius: 999px; background: var(--surface-soft); color: var(--text-muted); font-size: .64rem; }
.source-snippet { margin: 0; }
.source-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; }
.source-action { display: inline-flex; align-items: center; min-height: 32px; padding: .35rem .55rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; font-size: .68rem; font-weight: 800; text-decoration: none; }
.source-action:hover { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft); }
.source-action-primary { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }
.source-action-primary:hover { color: var(--on-brand); filter: brightness(.95); }
.source-why { border-top: 1px solid var(--border); padding-top: .45rem; }
.source-why summary { cursor: pointer; color: var(--text-muted); font-size: .68rem; font-weight: 800; }
.source-why p { margin: .4rem 0 0; color: var(--text-muted); font-size: .7rem; line-height: 1.4; }
.feedback-reason-menu { display: none; }
.feedback-form { position: absolute; z-index: 20; left: 0; bottom: calc(100% + .4rem); width: min(340px, 80vw); padding: .75rem; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface-raised); box-shadow: var(--shadow); }
.feedback-options { display: grid; gap: .35rem; margin: 0; padding: 0; border: 0; }
.feedback-option { display: flex; gap: .45rem; align-items: center; font-size: .72rem; cursor: pointer; }
.feedback-comment-label { display: grid; gap: .35rem; margin-top: .65rem; color: var(--text-muted); font-size: .7rem; font-weight: 800; }
.feedback-comment-label textarea { width: 100%; resize: vertical; padding: .55rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
.feedback-form-actions { display: flex; justify-content: flex-end; gap: .45rem; margin-top: .65rem; }

/* v7.1.0-beta.18.2 · estado final visible y respuesta estable */
.message-status[data-state="completed"] {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: .35rem;
  margin-bottom: .55rem;
  padding: .24rem .5rem;
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  color: var(--success);
  font-size: .68rem;
  font-weight: 850;
}
.message-status[data-state="completed"]::before {
  content: "✓";
  font-weight: 950;
}


/* v7.1.0-hotfix.2 · síntesis, citas enlazadas y contraste claro/oscuro */
.message-row[data-role="assistant"] .message,
.message-row[data-role="assistant"] .message-body,
.message-row[data-role="assistant"] .message-body p,
.message-row[data-role="assistant"] .message-body li,
.message-row[data-role="assistant"] .message-body h2,
.message-row[data-role="assistant"] .message-body h3,
.message-row[data-role="assistant"] .message-body h4 {
  color: var(--text);
}
.message-row[data-role="user"] .message,
.message-row[data-role="user"] .message-body,
.message-row[data-role="user"] .message-meta,
.message-row[data-role="user"] .message-body p,
.message-row[data-role="user"] .message-body li {
  color: var(--on-brand);
}
.source-card {
  color: var(--text);
  background: var(--surface);
}
.source-card-primary {
  color: var(--text);
}
.source-title { color: var(--text); }
.source-title:hover { color: var(--brand-strong); }
.source-snippet,
.source-why p { color: var(--text-muted); }
.source-meta span {
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface-soft) 92%, var(--brand-soft));
}
.source-role {
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.source-role-primary {
  color: var(--on-brand);
  border-color: var(--brand);
}
.source-reference {
  border: 1px solid color-mix(in srgb, var(--brand) 34%, var(--border));
  color: var(--brand-strong);
  background: var(--brand-soft);
  text-decoration: none;
  white-space: nowrap;
}
.source-reference-link { cursor: pointer; }
.source-reference-link:hover,
.source-reference-link:focus-visible {
  border-color: var(--brand);
  color: var(--on-brand);
  background: var(--brand);
}
.document-list li { color: var(--text); }
.document-list a {
  color: var(--accent);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.document-kind {
  color: var(--brand-strong) !important;
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--border));
}
html[data-theme="dark"] .message-body blockquote,
html[data-theme="dark"] .evidence-item {
  background: color-mix(in srgb, var(--surface-soft) 90%, var(--brand-soft));
  color: var(--text);
}
html[data-theme="dark"] .source-card-primary {
  background: color-mix(in srgb, var(--surface) 84%, var(--brand-soft));
}


/* hotfix.24 · structured municipal viewer recommendations */
.viewer-recommendations { margin-top: .85rem; padding-top: .8rem; border-top: 1px solid var(--border-subtle, #dfe5ea); }
.viewer-recommendations-title { margin: 0 0 .55rem; font-size: .92rem; }
.viewer-recommendations-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .55rem; }
.viewer-recommendation-card { display: flex; flex-direction: column; gap: .28rem; padding: .7rem .8rem; border: 1px solid var(--border-subtle, #dfe5ea); border-radius: .7rem; text-decoration: none; color: inherit; background: var(--surface-raised, #fff); }
.viewer-recommendation-card:hover, .viewer-recommendation-card:focus-visible { border-color: currentColor; }
.viewer-recommendation-card span { font-size: .85rem; line-height: 1.35; }
.viewer-recommendation-action { font-weight: 700; margin-top: .15rem; }


/* v7.1.0-hotfix.31 · fuentes complementarias plegables y control tipográfico incremental */
.source-card-complementary {
  padding: 0;
  overflow: clip;
}
.source-card-summary {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .55rem;
  min-height: 48px;
  padding: .7rem .8rem;
  cursor: pointer;
  list-style: none;
}
.source-card-summary::-webkit-details-marker { display: none; }
.source-card-summary::after {
  content: '⌄';
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  transition: transform .15s ease;
}
.source-card-complementary[open] > .source-card-summary::after { transform: rotate(180deg); }
.source-summary-title {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: .82rem;
  line-height: 1.35;
}
.source-card-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: .55rem;
  padding: 0 .8rem .8rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  padding-top: .65rem;
}
.icon-button:disabled {
  opacity: .42;
  cursor: not-allowed;
}


/* v7.1.0-hotfix.37 · dictado robusto y estado visible */
.voice-status { margin: .38rem .15rem 0; color: var(--text-muted); font-size: .7rem; font-weight: 700; }
.voice-status[data-state="listening"] { color: var(--danger); }
.voice-status[data-state="error"] { color: var(--danger); }
.voice-status[data-state="warning"] { color: var(--text-muted); }
.voice-dictation-button[data-listening="true"] svg { animation: voice-mic-pulse 1.1s ease-in-out infinite; }
@keyframes voice-mic-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.88); opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .voice-dictation-button[data-listening="true"] svg { animation: none; } }

/* hotfix.45 · inspector de evidencias RAG */
.evidence-inspector-help{margin:.55rem 0 .7rem;color:var(--color-text-muted,#5c6873);font-size:.82rem;line-height:1.35}
.evidence-debug-item{margin:.55rem 0;padding:.65rem .72rem;border:1px solid rgba(35,87,111,.16);border-radius:.55rem;background:rgba(247,250,252,.75)}
.evidence-debug-meta{font-size:.75rem;font-weight:700;color:var(--color-text-muted,#56616b);margin-bottom:.28rem}
.evidence-debug-section{font-size:.82rem;font-weight:700;line-height:1.35;margin:.15rem 0}
.evidence-debug-key,.evidence-debug-signals{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.72rem;color:var(--color-text-muted,#65717c);overflow-wrap:anywhere}
.evidence-debug-text{white-space:pre-wrap;margin:.45rem 0 .25rem;line-height:1.45}


/* v7.1.0-hotfix.82 · Markdown tables in assistant messages */
.chat-markdown-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: .55rem 0 .8rem;
  border: 1px solid var(--color-border, #d8e2e8);
  border-radius: .55rem;
  background: var(--color-surface, #fff);
}

.chat-markdown-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 34rem;
  font-size: .95em;
}

.chat-markdown-table th,
.chat-markdown-table td {
  padding: .55rem .65rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border, #d8e2e8);
}

.chat-markdown-table th {
  font-weight: 700;
  background: rgba(0, 0, 0, .035);
}

.chat-markdown-table tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 700px) {
  .chat-markdown-table {
    min-width: 30rem;
    font-size: .9em;
  }
}
/* v7.1.0-hotfix.102 · fuentes en columna única + tarjetas plegadas + contraste de consulta */
.source-list {
  grid-template-columns: minmax(0, 1fr) !important;
}
.source-card,
.source-card-primary,
.source-card-complementary {
  grid-column: 1 / -1 !important;
  width: 100%;
  max-width: none;
  padding: 0;
  overflow: clip;
}
.source-card-summary {
  width: 100%;
}
.source-card[open] > .source-card-summary::after {
  transform: rotate(180deg);
}
.source-card-primary {
  background: color-mix(in srgb, var(--brand-soft) 32%, var(--surface));
}
.message-row[data-role="assistant"] .message {
  background: color-mix(in srgb, var(--brand-soft) 14%, var(--surface));
}
html[data-theme="dark"] .message-row[data-role="assistant"] .message {
  background: color-mix(in srgb, var(--brand-soft) 20%, var(--surface));
}
html[data-theme="dark"] .message-row[data-role="user"] .message {
  background: color-mix(in srgb, var(--brand-soft) 56%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  color: var(--text);
}


/* v7.1.0-hotfix.103 · restaura consulta del usuario y aumenta contraste de respuesta del bot */
.message-row[data-role="user"] .message {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.message-row[data-role="user"] .message-body,
.message-row[data-role="user"] .message-meta,
.message-row[data-role="user"] .message-body p,
.message-row[data-role="user"] .message-body li {
  color: var(--on-brand);
}
.message-row[data-role="user"] .message-action,
.message-row[data-role="user"] .message-feedback {
  color: var(--on-brand);
}
.message-row[data-role="assistant"] .message {
  background: color-mix(in srgb, var(--brand-soft) 32%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 20%, var(--border));
}
html[data-theme="dark"] .message-row[data-role="assistant"] .message {
  background: color-mix(in srgb, var(--brand-soft) 30%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 24%, var(--border));
}

/* v7.1.0-hotfix.108 · contraste correcto del usuario en modo oscuro */
html[data-theme="dark"] .message-row[data-role="user"] .message {
  background: color-mix(in srgb, var(--brand) 48%, var(--brand-soft));
  border-color: color-mix(in srgb, var(--brand) 72%, var(--border));
  color: #ffffff;
}
html[data-theme="dark"] .message-row[data-role="user"] .message-body,
html[data-theme="dark"] .message-row[data-role="user"] .message-meta,
html[data-theme="dark"] .message-row[data-role="user"] .message-body p,
html[data-theme="dark"] .message-row[data-role="user"] .message-body li,
html[data-theme="dark"] .message-row[data-role="user"] .message-action,
html[data-theme="dark"] .message-row[data-role="user"] .message-feedback {
  color: #ffffff;
}
html[data-theme="dark"] .message-row[data-role="user"] .message-action {
  border-color: color-mix(in srgb, #ffffff 40%, transparent);
}
