/* ==========================================================================
   DeepAI Code — capa visual 1:1 móvil.
   Se carga después de base.css: redefine tokens, layout y componentes.
   Sin frameworks, sin imágenes externas y sin contenido generado visible.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Paleta DeepAI */
  --bg: #171716;
  --bg-elevated: #1b1b19;
  --panel: #1f1f1d;
  --panel-soft: #222220;
  --sidebar-bg: #111110;
  --line: #2c2c29;
  --line-soft: #242421;
  --ink: #f1efe8;
  --muted: #9b988e;
  --muted-2: #77746c;
  --accent: #e0528f;
  --accent-soft: rgba(224, 82, 143, 0.14);
  --accent-ink: #ffd9e8;
  --ok: #9ad29b;
  --danger: #e08a82;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --font-ui: 13px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --sidebar-w: min(86vw, 320px);
  --header-h: 56px;
  --ease: cubic-bezier(0.22, 0.7, 0.24, 1);
}

/* --------------------------------------------------------------------------
   Reset de la maqueta base: la app ocupa exactamente el viewport.
   -------------------------------------------------------------------------- */

html,
body {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--font-ui);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--ink);
  padding: 8px 12px;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:hover {
  background: #292926;
}

button:active {
  background: #30302c;
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

button[hidden],
input[hidden] {
  display: none !important;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #131312;
  color: var(--ink);
  caret-color: var(--accent);
}

a {
  color: #f3a7c6;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

::selection {
  background: rgba(224, 82, 143, 0.36);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid rgba(224, 82, 143, 0.72);
  outline-offset: 2px;
}

/* Scrollbars discretos (Chromium/WebKit) */
* {
  scrollbar-width: thin;
  scrollbar-color: #3a3a35 transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

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

*::-webkit-scrollbar-thumb {
  background: #343430;
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: #464640;
  background-clip: content-box;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app {
  position: relative;
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.workspace {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(224, 82, 143, 0.05), transparent 55%),
    var(--bg);
}

/* --------------------------------------------------------------------------
   Sidebar off-canvas
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  max-width: 100vw;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  border-radius: 0;
  transform: translateX(-102%);
  visibility: hidden;
  transition:
    transform 260ms var(--ease),
    visibility 0s linear 260ms;
  will-change: transform;
  box-shadow: 20px 0 48px rgba(0, 0, 0, 0.32);
}

#app[data-sidebar="open"] .sidebar {
  transform: translateX(0);
  visibility: visible;
  transition:
    transform 260ms var(--ease),
    visibility 0s linear 0s;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.56);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: default;
}

#app[data-sidebar="open"] .scrim,
#app[data-sidebar="open"] .scrim[hidden] {
  display: block !important;
}

.sidebar-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 10px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(224, 82, 143, 0.5);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
}

.sidebar-head-actions {
  display: flex;
  flex: none;
  gap: 2px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--line);
  background: #1d1d1b;
  color: var(--ink);
}

.new-chat {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 2px 12px 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1b1b19;
  color: var(--ink);
  font-size: 12.5px;
  text-align: left;
}

.new-chat:hover {
  border-color: #3b3b36;
  background: #20201e;
}

.new-chat-plus {
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 8px 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.side-section {
  margin: 0 0 14px;
  padding: 0 2px;
}

.side-section h2 {
  margin: 0 0 5px;
  padding: 3px 7px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}

.project-tree {
  display: grid;
  gap: 1px;
  margin-left: 12px;
  padding-left: 7px;
  border-left: 1px solid var(--line-soft);
}

.project-group {
  display: grid;
  gap: 1px;
}

.thread-list {
  display: grid;
  gap: 1px;
}

.project-row,
.thread-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #c7c4ba;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
}

.project-row:hover,
.thread-row:hover {
  border-color: transparent;
  background: #1b1b19;
  color: var(--ink);
}

.project-row.is-open {
  color: var(--ink);
}

.project-row > span,
.thread-row > span {
  min-width: 0;
}

.thread-row > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron,
.project-icon,
.thread-row > span[aria-hidden="true"] {
  flex: none;
  color: var(--muted-2);
  font-size: 10.5px;
}

.project-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connect-section {
  padding-bottom: 6px;
}

.connect-panel {
  margin: 0 2px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #161615;
}

.connect-panel summary {
  padding: 1px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.connect-panel summary::-webkit-details-marker {
  display: none;
}

.connect-panel summary::before {
  content: "›";
  display: inline-block;
  width: 12px;
  color: var(--muted-2);
  transition: transform 160ms var(--ease);
}

.connect-panel[open] summary::before {
  transform: rotate(90deg);
}

.connect-grid {
  display: grid;
  gap: 7px;
  padding-top: 9px;
}

.connect-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.connect-grid input {
  width: 100%;
  padding: 6px 7px;
  border-radius: 7px;
  background: #101010;
  font-size: 11.5px;
}

.connect-actions {
  display: flex;
  gap: 6px;
  padding-top: 2px;
}

.connect-actions button {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 7px;
  border-radius: 7px;
  background: #252522;
  font-size: 11px;
}

.connect-actions button.secondary {
  background: transparent;
  color: var(--muted);
}

.profile-row {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  text-align: left;
}

.profile-row:hover {
  background: #161615;
  color: var(--ink);
}

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(224, 82, 143, 0.38);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 9.5px;
  letter-spacing: 0.03em;
}

.profile-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-more {
  flex: none;
  color: var(--muted-2);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Header del chat
   -------------------------------------------------------------------------- */

.chat-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: var(--header-h);
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 23, 22, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.menu-btn {
  flex: none;
  border-color: var(--line);
  background: #1d1d1b;
  color: var(--ink);
  font-size: 15px;
}

.menu-btn:hover {
  border-color: #3c3c37;
  background: #232320;
}

.chat-title-wrap {
  display: grid;
  flex: 1 1 auto;
  gap: 1px;
  min-width: 0;
  padding: 0 2px;
}

.chat-title {
  overflow: hidden;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-subtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-subtitle:empty {
  display: none;
}

.pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #1d1d1b;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
}

.pill::before {
  content: "";
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.pill[data-state="on"] {
  border-color: rgba(110, 170, 110, 0.38);
  background: rgba(72, 120, 72, 0.14);
  color: var(--ok);
}

.pill[data-state="on"]::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(154, 210, 155, 0.12);
  opacity: 1;
}

.connection-pill[data-state="off"] {
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Timeline
   -------------------------------------------------------------------------- */

.timeline {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 14px 14px 22px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.timeline > * {
  flex: none;
}

.empty {
  margin: auto;
  padding: 24px 8px;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
}

/* Mensajes ---------------------------------------------------------------- */

.msg {
  max-width: 92%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.msg-agent {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
}

.msg-user {
  align-self: flex-end;
  max-width: 88%;
  padding: 8px 12px 9px;
  border: 1px solid #33332e;
  border-radius: 16px 16px 5px 16px;
  background: #252522;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.msg-agent .msg-meta {
  margin-bottom: 5px;
}

.msg-user .msg-meta {
  justify-content: flex-end;
  margin-bottom: 2px;
}

.msg-role {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.msg-agent .msg-role {
  color: var(--accent);
}

.msg-time {
  color: var(--muted-2);
  font-size: 9.5px;
}

.msg-time:empty {
  display: none;
}

.msg-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg-body > :first-child {
  margin-top: 0;
}

.msg-body > :last-child {
  margin-bottom: 0;
}

.msg-body p {
  margin: 0 0 10px;
}

.msg-body h1,
.msg-body h2,
.msg-body h3,
.msg-body h4,
.msg-body h5,
.msg-body h6 {
  margin: 16px 0 7px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.msg-body h1 {
  font-size: 1.42em;
}

.msg-body h2 {
  font-size: 1.24em;
}

.msg-body h3 {
  font-size: 1.1em;
}

.msg-body h4,
.msg-body h5,
.msg-body h6 {
  font-size: 1em;
  color: #d9d5ca;
}

.msg-body strong {
  color: #fffdf7;
  font-weight: 600;
}

.msg-body em {
  color: #e3dfd4;
}

.msg-body del {
  color: var(--muted-2);
}

.msg-body ul,
.msg-body ol {
  margin: 8px 0;
  padding-left: 19px;
}

.msg-body li {
  margin: 3px 0;
}

.msg-body li::marker {
  color: var(--muted-2);
}

.md-task-item {
  list-style: none;
  margin-left: -16px;
}

.md-task-checkbox {
  width: 12px;
  height: 12px;
  margin: 0 5px 0 0;
  vertical-align: -1px;
  accent-color: var(--accent);
}

.msg-body hr {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.msg-body blockquote,
.md-quote {
  margin: 10px 0;
  padding: 2px 0 2px 11px;
  border-left: 2px solid #3a3a34;
  color: #c2bfb5;
}

.msg-body blockquote p:last-child,
.md-quote p:last-child {
  margin-bottom: 0;
}

.msg-body a {
  color: #f3a7c6;
  text-decoration: underline;
  text-decoration-color: rgba(243, 167, 198, 0.38);
  text-underline-offset: 2px;
}

.msg-body a:hover {
  text-decoration-color: currentColor;
}

/* Código ------------------------------------------------------------------ */

.msg-body code,
.md-inline-code {
  padding: 1px 4px;
  border: 1px solid #2a2a26;
  border-radius: 4px;
  background: #20201d;
  color: #e8d9c6;
  font-family: var(--mono);
  font-size: 0.92em;
}

.msg-body pre,
.md-code {
  max-width: 100%;
  margin: 9px 0;
  padding: 10px 11px;
  overflow-x: auto;
  border: 1px solid #292925;
  border-radius: 10px;
  background: #101010;
  color: #ddd9cd;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  tab-size: 2;
  -webkit-overflow-scrolling: touch;
}

.msg-body pre code,
.md-code code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  white-space: pre;
}

.md-code-diff code {
  display: block;
  white-space: pre;
}

.diff-line {
  display: block;
  min-width: max-content;
  padding: 0 2px;
}

.diff-add {
  background: rgba(90, 160, 100, 0.12);
  color: #a9d6a6;
}

.diff-del {
  background: rgba(200, 90, 90, 0.12);
  color: #e0a19c;
}

.diff-hunk {
  color: #a9b9e0;
}

.diff-meta,
.diff-context {
  color: #9b988e;
}

/* Tablas ------------------------------------------------------------------ */

.md-table-wrap {
  max-width: 100%;
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  -webkit-overflow-scrolling: touch;
}

.msg-body table,
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  line-height: 1.45;
}

.msg-body th,
.msg-body td,
.md-table th,
.md-table td {
  padding: 6px 9px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.msg-body th:last-child,
.msg-body td:last-child,
.md-table th:last-child,
.md-table td:last-child {
  border-right: 0;
}

.msg-body tr:last-child td,
.md-table tr:last-child td {
  border-bottom: 0;
}

.msg-body th,
.md-table th {
  background: #20201d;
  color: #dedad0;
  font-weight: 600;
  white-space: nowrap;
}

/* Imágenes y adjuntos ----------------------------------------------------- */

.msg-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #101010;
}

.attachments {
  display: grid;
  gap: 4px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.attachment {
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1b1b19;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Alertas Markdown -------------------------------------------------------- */

.md-alert {
  margin: 10px 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted-2);
  border-radius: 8px;
  background: #1b1b19;
  color: #d4d0c5;
}

.md-alert > :last-child {
  margin-bottom: 0;
}

.md-alert-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.md-alert-note {
  border-left-color: #7f9ec4;
}

.md-alert-tip {
  border-left-color: #8fbc8f;
}

.md-alert-warning {
  border-left-color: #d8b45f;
}

.md-alert-caution {
  border-left-color: var(--danger);
}

.md-alert-important {
  border-left-color: var(--accent);
}

/* Tarjetas de actividad --------------------------------------------------- */

.card {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1b1b19;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.card > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.card-label {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.card-time {
  flex: none;
  color: var(--muted-2);
  font-size: 9.5px;
}

.card-time:empty {
  display: none;
}

.card-details {
  margin: 2px 0 0;
}

.card-details summary {
  color: #ddd9ce;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.card-details summary::-webkit-details-marker {
  display: none;
}

.card-details summary::before {
  content: "▸";
  display: inline-block;
  width: 13px;
  color: var(--muted-2);
  transition: transform 160ms var(--ease);
}

.card-details[open] summary::before {
  transform: rotate(90deg);
}

.card-pre,
.card-terminal {
  max-height: 230px;
  margin: 7px 0 0;
  padding: 8px 9px;
  overflow: auto;
  border: 1px solid #262623;
  border-radius: 7px;
  background: #0f0f0e;
  color: #c8c5ba;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-terminal {
  color: #b9cbb5;
}

.card-status {
  display: inline-block;
  margin-top: 5px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.card-body {
  display: grid;
  gap: 3px;
}

.card-title {
  margin: 1px 0 0;
  color: #ddd9ce;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
}

.card-text {
  margin: 0;
  color: var(--muted);
}

.card-tokens {
  margin: 1px 0 0;
  color: var(--muted-2);
  font-size: 10px;
}

.card-action {
  justify-self: start;
  margin-top: 4px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted-2);
  font-size: 9.5px;
}

.card-error {
  border-color: #5a3430;
  background: #211918;
  color: #e3b0aa;
}

.card-error .card-label,
.card-error .card-title {
  color: #e8a7a0;
}

.card-compaction {
  border-color: #554b30;
  background: #1f1c15;
  color: #d8c58d;
}

.card-compaction .card-label,
.card-compaction .card-title {
  color: #d8c58d;
}

.card-task {
  border-color: #345034;
  background: #171e17;
  color: #a9d4a9;
}

.card-task .card-label,
.card-task .card-title {
  color: #a9d4a9;
}

.card-unknown {
  border-style: dashed;
  background: #191918;
}

.card-unknown .card-label {
  color: #b3aa8e;
}

.card-session,
.card-workspaces,
.card-models,
.card-ack,
.card-auth {
  display: grid;
  gap: 2px;
}

.card-session strong,
.card-workspaces strong,
.card-models strong,
.card-ack strong,
.card-auth strong {
  color: #ddd9ce;
  font-size: 11.5px;
  font-weight: 500;
}

.card-session .card-status,
.card-workspaces .card-status,
.card-models .card-status,
.card-ack .card-status,
.card-auth .card-status {
  justify-self: start;
}

/* --------------------------------------------------------------------------
   Composer
   -------------------------------------------------------------------------- */

/* base.css fuerza min-width: 86px en los botones del composer; aquí manda
   el diseño circular compacto. */
.composer button {
  min-width: 0;
}

.composer {
  position: relative;
  z-index: 3;
  display: block;
  flex: none;
  padding: 7px 10px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(44, 44, 41, 0.72);
  background: linear-gradient(to top, var(--bg) 68%, rgba(23, 23, 22, 0.94));
}

.composer-box {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 7px 9px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #1c1c1a;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.025) inset;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.composer-box:focus-within {
  border-color: #47473f;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(224, 82, 143, 0.12);
}

.composer textarea,
#prompt {
  display: block;
  width: 100%;
  min-height: 26px;
  max-height: 148px;
  margin: 0;
  padding: 6px 6px 4px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  field-sizing: content;
}

.composer textarea::placeholder,
#prompt::placeholder {
  color: #77746c;
  opacity: 1;
}

.composer textarea:focus-visible,
#prompt:focus-visible {
  outline: 0;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 1px 0;
}

.attach-btn {
  flex: 0 0 auto;
  width: 32px;
  min-width: 0;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #232320;
  color: #cfcbc0;
  font-size: 15px;
}

.attach-btn:hover {
  border-color: #4a4a42;
  background: #2a2a26;
  color: var(--ink);
}

.model-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: min(72vw, 280px);
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #222220;
  color: #d6d2c7;
  font-size: 10.5px;
  line-height: 1.3;
  white-space: nowrap;
}

.model-pill:hover {
  border-color: #44443e;
  background: #282825;
}

.model-pill > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-dot {
  display: inline-grid;
  flex: none;
  place-items: center;
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
}

.model-version {
  flex: none;
  color: var(--muted-2);
  font-size: 9px;
}

.model-caret {
  flex: none;
  color: var(--muted-2);
  font-size: 10px;
}

.composer-spacer {
  flex: 1 1 auto;
  min-width: 4px;
}

.send-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 0;
  height: 34px;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  color: #1a1015;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(224, 82, 143, 0.28);
  transition: transform 140ms var(--ease), opacity 140ms var(--ease);
}

.send-btn:hover {
  background: #e9689d;
  border-color: #e9689d;
}

.send-btn:active {
  transform: scale(0.94);
}

.send-btn:disabled {
  border-color: rgba(224, 82, 143, 0.35);
  background: var(--accent-soft);
  color: #b97a95;
  opacity: 0.8;
  box-shadow: none;
}

.send-btn:disabled:hover {
  background: var(--accent-soft);
}

.stop-btn {
  border-color: #4d4d45;
  background: #33332e;
  color: #f0ede4;
  font-size: 10px;
  box-shadow: none;
}

.stop-btn:hover {
  border-color: #62625a;
  background: #3b3b35;
}

/* --------------------------------------------------------------------------
   Bottom sheet de modelos
   -------------------------------------------------------------------------- */

dialog.sheet {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 86dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.48);
}

dialog.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-rise 220ms var(--ease);
}

dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0.58);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

@keyframes sheet-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sheet-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-head strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sheet-head .icon-btn {
  flex: none;
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-note {
  margin: 0 0 12px;
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.5;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 7px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #222220;
  color: var(--ink);
  font-size: 12px;
}

.model-option > div {
  display: grid;
  flex: 1 1 auto;
  gap: 1px;
  min-width: 0;
}

.model-option strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-option small {
  color: var(--muted);
  font-size: 10px;
}

.model-option.is-selected {
  border-color: rgba(224, 82, 143, 0.55);
  background: rgba(224, 82, 143, 0.09);
}

.model-option.is-selected .model-dot,
.model-option.is-selected .check {
  color: var(--accent);
}

.check {
  flex: none;
  color: var(--accent);
  font-size: 12px;
}

.intelligence-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.intelligence-value {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #222220;
  color: var(--ink);
  font-size: 10.5px;
}

/* --------------------------------------------------------------------------
   Adaptación a pantallas anchas (tablet / escritorio)
   -------------------------------------------------------------------------- */

@media (min-width: 700px) {
  .chat-header {
    padding-inline: 16px;
  }

  .timeline {
    padding: 18px 28px 26px;
  }

  .msg-agent {
    max-width: 680px;
  }

  .msg-user {
    max-width: min(72%, 540px);
  }

  .composer {
    padding-inline: 18px;
  }

  dialog.sheet {
    inset: 0;
    width: min(430px, calc(100vw - 32px));
    max-width: 430px;
    max-height: min(640px, calc(100dvh - 48px));
    margin: auto;
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius-lg);
  }

  dialog.sheet[open] {
    animation: sheet-pop 180ms var(--ease);
  }

  .sheet-body {
    padding-bottom: 16px;
  }

  @keyframes sheet-pop {
    from {
      opacity: 0;
      transform: translateY(10px) scale(0.985);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
}

/* En escritorio sobra sitio: el sidebar se queda fijo y el drawer desaparece. */
@media (min-width: 960px) {
  .sidebar {
    transform: none;
    visibility: visible;
    width: 320px;
    box-shadow: none;
  }

  .workspace {
    margin-left: 320px;
  }

  .menu-btn,
  #sidebarClose {
    display: none;
  }

  .scrim,
  #app[data-sidebar="open"] .scrim,
  #app[data-sidebar="open"] .scrim[hidden] {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   Movimiento reducido
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Adaptación visual de la primera app
   La estructura es el shell DeepAI (sidebar + chat), pero los tokens,
   tipografía, burbujas y compositor recuperan la identidad cálida de la
   primera versión: Inter, coral y superficies de piedra.
   ========================================================================== */

:root {
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --bg: #1f1e1d;
  --bg-deep: #141312;
  --bg-elevated: #262524;
  --panel: #262524;
  --panel-soft: #302f2c;
  --sidebar-bg: #1b1a19;
  --line: #393733;
  --line-soft: #2c2b28;
  --ink: #f1eee7;
  --muted: #a7a39a;
  --muted-2: #7c7972;
  --accent: #d97757;
  --accent-soft: #3a2a24;
  --accent-ink: #fff4f0;
  --composer: #262524;
  --composer-border: #393733;
  --bubble: #32312e;
  --code-bg: #171615;
  --code-border: #302e2b;
  --danger: #d4776d;
  --ok: #7fba7a;

  --font-ui: 15px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 23px;
  --header-h: 60px;
}

html,
body {
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--font-ui);
}

button,
input,
textarea,
select {
  font-family: var(--sans);
  letter-spacing: -0.01em;
}

button {
  border-color: var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  font-size: 14px;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.035), 0 30px 80px rgba(0, 0, 0, 0.4);
}

.workspace {
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  width: min(88vw, 340px);
  background: var(--sidebar-bg);
  border-right-color: var(--line);
}

.sidebar-head {
  min-height: 60px;
  padding: 0 14px;
}

.brand {
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-size: 16px;
  background: var(--accent-soft);
}

.icon-btn {
  color: var(--text-soft, var(--ink));
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.055);
}

.new-chat {
  margin: 4px 12px 14px;
  min-height: 44px;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
}

.new-chat:hover {
  background: rgba(255, 255, 255, 0.045);
}

.new-chat-plus {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.side-section h2 {
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.project-row,
.thread-row {
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -0.012em;
}

.project-row {
  color: var(--text-soft, var(--ink));
  font-weight: 500;
}

.thread-row:hover,
.project-row:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
}

.thread-row.is-active,
.thread-row[aria-current="true"] {
  background: rgba(217, 119, 87, 0.12);
  color: var(--ink);
}

.thread-row.is-active::before {
  content: "";
  width: 3px;
  height: 15px;
  margin-right: 1px;
  border-radius: 99px;
  background: var(--accent);
}

.profile-row {
  min-height: 64px;
  border-top-color: var(--line);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff4f0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.connect-panel {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.018);
}

/* Cabecera del chat */
.chat-header {
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
}

.menu-btn {
  color: var(--muted);
}

.chat-title-wrap {
  gap: 1px;
}

.chat-title {
  font-size: 18px;
  font-weight: 450;
  letter-spacing: -0.025em;
}

.chat-subtitle {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: -0.02em;
}

.connection-pill {
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 9px;
}

.connection-pill[data-state="on"] {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 10%, var(--panel));
}

/* Timeline y mensajes */
.timeline {
  gap: 16px;
  padding: 16px 20px 24px;
}

.empty-home {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 100%;
  text-align: center;
}

.empty-greeting {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(41px, 11.2vw, 64px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.052em;
  text-wrap: balance;
}

.empty-hint {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  letter-spacing: -0.01em;
}

.msg {
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.msg-user {
  align-self: flex-end;
  max-width: 86%;
  padding: 11px 16px;
  border-radius: 20px;
  background: var(--bubble);
  color: var(--ink);
}

.msg-agent {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
}

.msg-meta {
  margin-bottom: 5px;
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: -0.01em;
}

.msg-role {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.msg-agent .msg-role {
  color: var(--accent);
}

.msg-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted-2);
}

.msg-body {
  color: var(--text-soft, var(--ink));
  font-size: 15.5px;
  line-height: 1.56;
  letter-spacing: -0.012em;
}

.msg-user .msg-body {
  color: var(--ink);
}

.msg-body h1,
.msg-body h2,
.msg-body h3,
.msg-body h4 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.msg-body code,
.msg-body pre {
  font-family: var(--mono);
}

.msg-body pre {
  border-color: var(--code-border);
  background: var(--code-bg);
  border-radius: 14px;
}

.msg-body code {
  background: var(--code-bg);
  border-radius: 5px;
}

.msg-body .md-image {
  border-radius: 18px;
  border-color: var(--line);
}

/* Composer */
.composer {
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 0;
  background: linear-gradient(to top, var(--bg) 72%, rgba(31, 30, 29, 0.9));
}

.composer-box {
  padding: 8px 11px 10px;
  border-color: var(--composer-border);
  border-radius: var(--radius-lg);
  background: var(--composer);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.12);
}

.composer-box:focus-within {
  border-color: #57534d;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(217, 119, 87, 0.16);
}

.composer textarea,
#prompt {
  padding: 11px 7px 4px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.45;
  letter-spacing: -0.015em;
}

.composer textarea::placeholder,
#prompt::placeholder {
  color: var(--muted);
}

.attach-btn {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--text-soft, var(--ink));
  font-size: 23px;
  font-weight: 400;
}

.attach-btn:hover {
  background: rgba(255, 255, 255, 0.055);
}

.model-pill {
  max-width: min(70vw, 300px);
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: var(--text-soft, var(--ink));
  font-size: 14px;
  letter-spacing: -0.02em;
}

.model-pill:hover {
  background: transparent;
  border: 0;
}

.model-version {
  font-size: 10.5px;
  color: var(--muted);
}

.model-dot {
  color: var(--accent);
}

.send-btn {
  width: 39px;
  height: 39px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff4f0;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 5px 16px rgba(217, 119, 87, 0.2);
}

.send-btn:hover {
  background: #e18464;
}

.stop-btn {
  background: var(--danger);
  color: #fff;
}

.send-btn:disabled {
  background: var(--bubble);
  color: var(--muted);
  box-shadow: none;
}

/* Tarjetas de actividad y hojas */
.card {
  border-color: var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--muted);
  font-size: 13.5px;
}

.card-title {
  font-family: var(--sans);
  font-weight: 550;
  letter-spacing: -0.02em;
}

.sheet {
  background: var(--bg-elevated);
  border-color: var(--line);
  color: var(--ink);
  font-family: var(--sans);
}

.sheet-head strong {
  font-size: 17px;
  font-weight: 550;
  letter-spacing: -0.025em;
}

.sheet-note {
  color: var(--muted);
  font-size: 14px;
}

.model-option {
  border-color: var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.model-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.model-option strong {
  font-size: 15px;
  font-weight: 550;
}

.model-option small {
  font-family: var(--mono);
  color: var(--muted-2);
}

.intelligence-row,
.intelligence-value {
  font-size: 14px;
}

@media (min-width: 960px) {
  .app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

/* P0: estado de ejecución, adjuntos y catálogo real de modelos. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: -0.02em;
}

.run-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: run-pulse 1.2s ease-in-out infinite;
}

.run-state[hidden] {
  display: none;
}

@keyframes run-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 7px 2px;
}

.attachment-tray[hidden] {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 7px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.attachment-chip-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip-remove {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.attachment-chip-remove:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.attachment-error {
  width: 100%;
  color: var(--danger);
  font-family: var(--sans);
  font-size: 11px;
}

.model-search {
  display: block;
  margin: 0 0 10px;
}

.model-search input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
}

.model-options {
  max-height: min(46vh, 390px);
  overflow-y: auto;
  padding-right: 2px;
}

.model-provider-label {
  padding: 12px 4px 5px;
  color: var(--muted-2);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model-options .model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin-bottom: 5px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.model-options .model-option:hover {
  border-color: #57534d;
}

.model-options .model-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.model-options .model-option:disabled {
  opacity: 0.45;
}

.model-options .model-option > div {
  min-width: 0;
  flex: 1;
}

.model-options .model-option strong,
.model-options .model-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-options .model-option strong {
  font-size: 14px;
  font-weight: 550;
}

.model-options .model-option small {
  margin-top: 2px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
}

.model-options .check {
  color: var(--accent);
  font-size: 15px;
}

.model-options .model-empty {
  padding: 18px 6px;
  color: var(--muted);
  font-size: 13px;
}

.intelligence-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.intelligence-panel[hidden] {
  display: none;
}

.intelligence-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.intelligence-option {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.intelligence-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.intelligence-option:disabled {
  opacity: 0.45;
}

.model-status {
  min-height: 16px;
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.model-status.is-error {
  color: var(--danger);
}

/* ==========================================================================
   Bloque ALTO: búsqueda, estados vacíos, validación inline y accesibilidad.
   ========================================================================== */

:root {
  /* Texto pequeño (10-11px) sobre las superficies oscuras: contraste AA. */
  --muted-2: #99958c;
}

/* Drawer y búsqueda ------------------------------------------------------ */

.sidebar-search {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  margin: 0 12px 10px;
}

.sidebar-search[hidden] {
  display: none !important;
}

.sidebar-search input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #131312;
  color: var(--ink);
  font-size: 13px;
}

.sidebar-search input::placeholder {
  color: var(--muted-2);
}

.sidebar-search .icon-btn {
  flex: none;
  border-color: var(--line);
  background: var(--panel);
}

/* Objetivos táctiles principales >= 44px */
.icon-btn,
.new-chat,
.project-row,
.thread-row {
  min-width: 44px;
  min-height: 44px;
}

.project-row,
.thread-row {
  padding-block: 9px;
}

.model-pill,
.attach-btn,
.send-btn {
  min-height: 44px;
}

.attach-btn,
.send-btn {
  width: 44px;
  height: 44px;
}

.connect-grid input {
  min-height: 44px;
  font-size: 12.5px;
}

.connect-actions button {
  min-height: 44px;
  font-size: 12px;
}

.intelligence-option {
  min-height: 44px;
}

/* Errores inline de conexión -------------------------------------------- */

.field-error {
  margin: -2px 0 0;
  padding: 0 2px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.35;
}

.field-error[hidden] {
  display: none !important;
}

.connect-grid input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent);
}

/* Estados vacíos / de búsqueda ------------------------------------------ */

.sidebar-loading,
.sidebar-error,
.project-empty,
.recent-empty {
  margin: 2px 0;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.recent-empty {
  padding-left: 1px;
}

/* Foco visible y región de conversación --------------------------------- */

.timeline:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.msg-time {
  font-size: 11px;
}

/* ==========================================================================
   Bloque MEDIO: copiar, reintentar, menú de perfil y acciones de hilos.
   ========================================================================== */

/* Copiar código Markdown ------------------------------------------------ */

.md-code-wrap {
  position: relative;
  max-width: 100%;
  margin: 9px 0;
}

.md-code-wrap > .md-code {
  margin: 0;
  /* Reserva el lateral del botón flotante para no tapar la primera línea. */
  padding-right: 72px;
}

.md-copy-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--code-border);
  border-radius: 9px;
  background: color-mix(in srgb, var(--code-bg) 82%, var(--panel));
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1;
}

.md-copy-btn:hover,
.md-copy-btn:focus-visible {
  border-color: #57534d;
  background: var(--panel);
  color: var(--ink);
}

.md-copy-btn:focus-visible,
.msg-copy:focus-visible,
.card-copy:focus-visible,
.card-retry:focus-visible,
.thread-copy:focus-visible,
.profile-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Copiar respuesta ------------------------------------------------------ */

.msg-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 2px;
}

.msg-copy {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted-2);
  font-size: 11px;
}

.msg-copy:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
}

/* Acciones de tarjetas de actividad ------------------------------------ */

.card-copy,
.card-retry {
  justify-self: start;
  min-height: 44px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.card-copy:hover,
.card-retry:hover {
  border-color: #57534d;
  background: rgba(255, 255, 255, 0.045);
}

.card-retry {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent);
}

/* Menú de perfil -------------------------------------------------------- */

dialog.profile-menu {
  position: fixed;
  inset: auto auto calc(74px + env(safe-area-inset-bottom)) 12px;
  width: min(310px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.5);
}

dialog.profile-menu::backdrop {
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.profile-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 4px 8px 4px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.profile-menu-head strong {
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.015em;
}

.profile-menu-actions {
  display: grid;
  gap: 2px;
  padding: 6px;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}

.profile-menu-item:hover {
  background: rgba(255, 255, 255, 0.055);
}

.profile-menu-item[hidden] {
  display: none;
}

.profile-menu-status {
  min-height: 18px;
  margin: 0;
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* Acción contextual de hilos ------------------------------------------- */

.thread-item {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
}

.thread-item .thread-row {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.thread-copy {
  flex: none;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1;
}

.thread-copy:hover {
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}
