/* ══════════════════════════════════════════════════════════════════
   SALVADOR DEV — PLAYGROUND
   Design system compartido con la landing: dark #0a0a0f + naranja #f97316
   ══════════════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0f;
  --bg-soft: #0e0e15;
  --panel: #12121a;
  --panel-2: #16161f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f0f5;
  --text-2: #c8c8db;
  --text-3: #9d9db8;
  --text-4: #6b6b8a;

  --accent: #f97316;
  --accent-bright: #fb923c;
  --accent-dim: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.15);
  --accent-soft: rgba(249, 115, 22, 0.08);

  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --sidebar-w: 312px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* fondo: grilla tenue + halo naranja */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 35%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: -280px;
  left: 50%;
  width: 900px;
  height: 520px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(249, 115, 22, 0.11), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(249, 115, 22, 0.3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); background-clip: content-box; }

/* ══════════════ LAYOUT ══════════════ */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 62px minmax(0, 1fr);
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-areas:
    'top top'
    'side main';
  height: 100dvh;
}

/* ══════════════ TOPBAR ══════════════ */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 15, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 0.65rem; color: var(--text); }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-dim));
  color: #0a0a0f;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 0 22px rgba(249, 115, 22, 0.35);
}

.brand-text { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; }
.brand-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  background: var(--accent-glow);
  color: var(--accent-bright);
  vertical-align: middle;
}
.brand-sep { color: var(--text-4); margin: 0 0.15rem; font-weight: 400; }
.brand-page { color: var(--text-3); font-weight: 500; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.chip-accent {
  border-color: rgba(249, 115, 22, 0.28);
  background: var(--accent-soft);
  color: var(--accent-bright);
}
.chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px currentColor;
}
.chip .dot.off { background: var(--text-4); box-shadow: none; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--text-3);
  border: 1px solid transparent;
  transition: 0.16s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.hide-desktop { display: none; }

/* ══════════════ SIDEBAR ══════════════ */
.sidebar {
  grid-area: side;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-soft), rgba(14, 14, 21, 0.6));
  padding: 1.1rem 1.1rem 2rem;
}

.side-block { margin-bottom: 1.5rem; }

.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 0.6rem;
}
.side-label span.hint { letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--text-4); font-size: 0.68rem; }

/* modelo */
.model-tabs {
  display: grid;
  gap: 0.4rem;
}
.model-tab {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  transition: 0.16s;
}
.model-tab:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.04); }
.model-tab[aria-pressed='true'] {
  border-color: rgba(249, 115, 22, 0.45);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.12);
}
.model-tab .mt-radio {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--text-4); flex: none;
  display: grid; place-items: center;
}
.model-tab[aria-pressed='true'] .mt-radio { border-color: var(--accent); }
.model-tab[aria-pressed='true'] .mt-radio::after {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.model-tab .mt-name { font-size: 0.83rem; font-weight: 600; }
.model-tab .mt-desc { font-size: 0.7rem; color: var(--text-4); line-height: 1.3; }
.model-tab .mt-body { min-width: 0; }

/* conexión */
.conn {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.02);
}
.conn-row { display: flex; align-items: center; gap: 0.45rem; font-size: 0.76rem; color: var(--text-2); }
.conn-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.conn-row .dot.warn { background: var(--warn); }
.conn-row .dot.err { background: var(--err); }
.conn-note { font-size: 0.7rem; color: var(--text-4); margin-top: 0.35rem; line-height: 1.45; }

.key-form { display: flex; gap: 0.35rem; margin-top: 0.6rem; }
.key-form input {
  flex: 1; min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
.key-form input:focus { outline: none; border-color: rgba(249, 115, 22, 0.45); }
.key-form button {
  padding: 0 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  color: var(--text-2);
}
.key-form button:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.link-btn {
  font-size: 0.72rem; color: var(--text-4);
  text-decoration: underline; text-underline-offset: 2px;
  margin-top: 0.5rem;
}
.link-btn:hover { color: var(--err); }

/* presets */
.presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.preset {
  padding: 0.3rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.73rem;
  color: var(--text-2);
  transition: 0.15s;
}
.preset:hover { border-color: rgba(249, 115, 22, 0.35); color: var(--text); }
.preset[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: rgba(249, 115, 22, 0.4);
  color: var(--accent-bright);
}

.field {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  font-size: 0.79rem;
  color: var(--text-2);
  resize: vertical;
  line-height: 1.5;
}
.field:focus { outline: none; border-color: rgba(249, 115, 22, 0.4); background: rgba(0, 0, 0, 0.45); }
.field::placeholder { color: var(--text-4); }

/* sliders */
.slider-row { margin-bottom: 0.85rem; }
.slider-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 0.76rem; color: var(--text-2); margin-bottom: 0.25rem;
}
.slider-head output {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-bright);
  background: var(--accent-soft);
  padding: 0.05rem 0.4rem;
  border-radius: 5px;
  min-width: 2.6rem;
  text-align: center;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.5), 0 0 12px rgba(249, 115, 22, 0.45);
  cursor: pointer;
}
input[type='range']::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.5);
  cursor: pointer;
}

/* switch */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}
.switch-row .sr-txt { font-size: 0.76rem; color: var(--text-2); line-height: 1.3; }
.switch-row .sr-txt small { display: block; color: var(--text-4); font-size: 0.68rem; }
.switch {
  position: relative;
  width: 38px; height: 21px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  flex: none;
  transition: 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--text-3);
  transition: 0.2s;
}
.switch[aria-checked='true'] { background: rgba(249, 115, 22, 0.28); border-color: rgba(249, 115, 22, 0.5); }
.switch[aria-checked='true']::after { transform: translateX(17px); background: var(--accent-bright); }

/* stats */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.02);
}
.stat b { display: block; font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--text); }
.stat span { font-size: 0.63rem; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.06em; }

.side-foot {
  font-size: 0.68rem;
  color: var(--text-4);
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

/* ══════════════ MAIN ══════════════ */
.main {
  grid-area: main;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  position: relative;
}

.thread-wrap {
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 1.75rem 1.5rem 0.5rem;
}
.thread { max-width: 860px; margin: 0 auto; padding-bottom: 1rem; }

/* empty state */
.empty { max-width: 780px; margin: 3.5vh auto 0; animation: fadeUp 0.5s ease both; }
.empty-badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.32rem 0.75rem;
  border-radius: 99px;
  border: 1px solid rgba(249, 115, 22, 0.25);
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 0.7rem; font-weight: 600;
  margin-bottom: 1.1rem;
}
.empty-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty h1 {
  font-family: var(--font-head);
  font-size: clamp(1.9rem, 4.2vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin-bottom: 0.7rem;
}
.empty h1 .grad {
  background: linear-gradient(120deg, var(--accent-bright), var(--accent) 55%, #fdba74);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.empty p { color: var(--text-3); font-size: 0.94rem; max-width: 560px; }
.empty p kbd {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
  color: var(--text-2);
}

.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.65rem;
  margin-top: 1.8rem;
}
.ex-card {
  text-align: left;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  transition: 0.18s;
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}
.ex-card:hover {
  border-color: rgba(249, 115, 22, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  background: linear-gradient(160deg, rgba(249, 115, 22, 0.1), rgba(255, 255, 255, 0.02));
}
.ex-card .ex-ico {
  width: 26px; height: 26px; flex: none;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(249, 115, 22, 0.22);
  color: var(--accent-bright);
  font-size: 0.8rem;
}
.ex-card b { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.1rem; }
.ex-card span { font-size: 0.74rem; color: var(--text-4); line-height: 1.4; }

/* ══════════════ MENSAJES ══════════════ */
.msg { padding: 0.85rem 0; }
.msg + .msg { border-top: 1px solid rgba(255, 255, 255, 0.045); }

.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  max-width: min(85%, 660px);
  background: linear-gradient(150deg, rgba(249, 115, 22, 0.14), rgba(249, 115, 22, 0.05));
  border: 1px solid rgba(249, 115, 22, 0.22);
  border-radius: 14px 14px 4px 14px;
  padding: 0.65rem 0.9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.msg-ai .ai-head {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-4);
}
.ai-avatar {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-dim));
  color: #0a0a0f;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.66rem;
}
.ai-name { color: var(--text-2); font-weight: 600; font-size: 0.78rem; }
.ai-head .model-tag {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: var(--text-4);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 0.3rem;
}

.msg-body { font-size: 0.94rem; color: var(--text-2); overflow-wrap: anywhere; }
.msg-body > *:first-child { margin-top: 0; }
.msg-body > *:last-child { margin-bottom: 0; }
.msg-body p { margin: 0.6rem 0; }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  font-family: var(--font-head);
  color: var(--text);
  line-height: 1.3;
  margin: 1.2rem 0 0.5rem;
  letter-spacing: -0.015em;
}
.msg-body h1 { font-size: 1.32rem; }
.msg-body h2 { font-size: 1.16rem; }
.msg-body h3 { font-size: 1.02rem; }
.msg-body h4 { font-size: 0.94rem; }
.msg-body strong { color: var(--text); font-weight: 600; }
.msg-body em { color: var(--text-2); }
.msg-body ul, .msg-body ol { margin: 0.6rem 0 0.6rem 1.25rem; }
.msg-body li { margin: 0.22rem 0; }
.msg-body li::marker { color: var(--accent); }
.msg-body a { color: var(--accent-bright); text-decoration: underline; text-underline-offset: 2px; }
.msg-body blockquote {
  border-left: 2px solid rgba(249, 115, 22, 0.5);
  padding: 0.15rem 0 0.15rem 0.85rem;
  margin: 0.7rem 0;
  color: var(--text-3);
}
.msg-body hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }
.msg-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.08em 0.34em;
  color: #fdba74;
  white-space: break-spaces;
}
.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  display: block;
  overflow-x: auto;
}
.msg-body th, .msg-body td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  text-align: left;
}
.msg-body th { background: rgba(255, 255, 255, 0.05); color: var(--text); font-weight: 600; }

/* código */
.code-block {
  margin: 0.8rem 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #0b0b11;
  overflow: hidden;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--line);
}
.code-lang {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.code-copy {
  font-size: 0.68rem;
  color: var(--text-3);
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.code-copy:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.code-copy.done { color: var(--ok); }
.code-block pre {
  margin: 0;
  padding: 0.8rem 0.9rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  color: #d5d5e3;
  tab-size: 2;
}

/* tokens de sintaxis */
.tok-com { color: #5c6070; font-style: italic; }
.tok-str { color: #a5e39a; }
.tok-num { color: #fdba74; }
.tok-kw { color: #f472b6; }
.tok-fn { color: #7dd3fc; }
.tok-attr { color: #fbbf24; }
.tok-tag { color: #f472b6; }
.tok-punc { color: #8b8ba7; }

/* razonamiento */
.reason { margin: 0.35rem 0 0.7rem; }
.reason summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.74rem;
  color: var(--text-4);
  padding: 0.2rem 0.5rem 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
}
.reason summary::-webkit-details-marker { display: none; }
.reason summary:hover { color: var(--text-2); border-color: var(--line-strong); }
.reason summary .caret { transition: transform 0.18s; display: inline-block; }
.reason[open] summary .caret { transform: rotate(90deg); }
.reason .reason-body {
  margin-top: 0.45rem;
  padding: 0.6rem 0.8rem;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--text-4);
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  animation: fadeUp 0.2s ease both;
}

/* meta + acciones */
.msg-meta {
  display: flex; align-items: center; gap: 0.7rem;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  color: var(--text-4);
  font-family: var(--font-mono);
  flex-wrap: wrap;
}
.msg-meta span { display: inline-flex; align-items: center; gap: 0.28rem; }
.msg-meta .sep { opacity: 0.4; }

.msg-actions { display: flex; gap: 0.25rem; margin-top: 0.5rem; opacity: 0; transition: 0.15s; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-4);
  padding: 0.22rem 0.5rem;
  border-radius: 6px;
  border: 1px solid transparent;
}
.msg-actions button:hover { color: var(--text-2); background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.msg-actions svg { width: 13px; height: 13px; }

.caret-blink::after {
  content: '▋';
  color: var(--accent);
  margin-left: 1px;
  animation: blink 1s steps(2) infinite;
  font-size: 0.85em;
}
.app:not(.busy) .caret-blink::after { content: none; }

.thinking-dots { display: inline-flex; gap: 4px; padding: 0.4rem 0; }
.thinking-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.1s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }

/* imágenes adjuntas */
.attach-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.attach-thumb {
  position: relative;
  width: 74px; height: 74px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb button {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  display: grid; place-items: center;
  line-height: 1;
}
.msg-imgs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; justify-content: flex-end; }
.msg-imgs img {
  max-width: 190px;
  max-height: 190px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  display: block;
}

/* ══════════════ COMPOSER ══════════════ */
.composer-wrap {
  padding: 0.6rem 1.5rem 1rem;
  background: linear-gradient(180deg, rgba(10, 10, 15, 0), rgba(10, 10, 15, 0.92) 40%);
}
.composer {
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(21, 21, 30, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within {
  border-color: rgba(249, 115, 22, 0.45);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(249, 115, 22, 0.08);
}
.composer-inner { padding: 0.15rem 0.35rem 0.15rem 0.35rem; }

.composer textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  resize: none;
  padding: 0.65rem 0.6rem 0.15rem;
  font-size: 0.94rem;
  line-height: 1.55;
  max-height: 220px;
  color: var(--text);
}
.composer textarea::placeholder { color: var(--text-4); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.45rem 0.45rem;
}
.composer-bar .grow { flex: 1; }
.tok-est {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-4);
  padding-right: 0.3rem;
  white-space: nowrap;
}

.send-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  height: 34px; min-width: 34px;
  padding: 0 0.75rem;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-dim));
  color: #0a0a0f;
  font-weight: 700;
  font-size: 0.8rem;
  transition: 0.16s;
  box-shadow: 0 4px 18px rgba(249, 115, 22, 0.28);
}
.send-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.send-btn svg { width: 15px; height: 15px; }

.stop-btn {
  display: none;
  align-items: center; gap: 0.4rem;
  height: 34px;
  padding: 0 0.7rem;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  font-size: 0.78rem;
  font-weight: 600;
}
.stop-btn:hover { background: rgba(248, 113, 113, 0.2); }
.app.busy .stop-btn { display: inline-flex; }
.app.busy .send-btn { display: none; }

.composer-hint {
  max-width: 860px;
  margin: 0.45rem auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.67rem;
  color: var(--text-4);
  padding: 0 0.35rem;
}
.composer-hint kbd {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.25rem;
  color: var(--text-3);
}

/* ══════════════ TOASTS ══════════════ */
.toasts {
  position: fixed;
  bottom: 5.6rem;
  right: 1.5rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: min(92vw, 520px);
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 0.8rem;
  background: rgba(28, 28, 38, 0.97);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease both;
  display: flex; align-items: center; gap: 0.5rem;
}
.toast.err { border-color: rgba(248, 113, 113, 0.45); color: #fecaca; }
.toast.ok { border-color: rgba(52, 211, 153, 0.4); color: #a7f3d0; }
.toast button {
  text-decoration: underline;
  color: var(--accent-bright);
  font-size: 0.78rem;
  font-weight: 600;
}

/* overlay mobile */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 39;
}

/* ══════════════ ANIMACIONES ══════════════ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-4px); opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .thread-wrap { scroll-behavior: auto; }
}

/* ══════════════ RESPONSIVE ══════════════ */
@media (max-width: 920px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'top'
      'main';
  }
  .hide-desktop { display: grid; }
  .chip-opt { display: none; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(88vw, 330px);
    z-index: 40;
    transform: translateX(-102%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--panel);
    box-shadow: 30px 0 60px rgba(0, 0, 0, 0.5);
    padding-top: 1.2rem;
  }
  .sidebar.open { transform: none; }
  .sidebar .side-close { display: grid; }
  .overlay.show { display: block; }

  .thread-wrap { padding: 1.2rem 0.9rem 0.4rem; }
  .composer-wrap { padding: 0.5rem 0.7rem 0.8rem; }
  .composer-hint { font-size: 0.63rem; }
  .empty { margin-top: 1rem; }
  .msg-user .bubble { max-width: 92%; }
  .msg-actions { opacity: 1; }
  .brand-text .brand-page, .brand-text .brand-sep { display: none; }

  .toasts { left: 0.8rem; right: 0.8rem; bottom: 6.2rem; align-items: stretch; }
  .toast { max-width: none; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 0.7rem; gap: 0.5rem; }
  .chip { font-size: 0.68rem; padding: 0.28rem 0.55rem; }
  .empty h1 { font-size: 1.7rem; }
  .examples { grid-template-columns: 1fr; }
}

.side-close { display: none; }
