/* ═══════════════════════════════════════════════════════════════════
   Qorum · chat — superficie de producto, estética tinta y papel
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ink: #0B141F;
  --ink-2: #101D2C;
  --ink-3: #16273B;
  --ink-line: rgba(159, 186, 214, 0.14);
  --paper: #F2EDE2;
  --verde: #2BD98F;
  --verde-deep: #073B2A;
  --tx: #F1EDE2;
  --tx-mut: #93A7BC;
  --tx-dim: #8093AB;
  --tx-ink: #1C2620;
  --font-d: 'Archivo', sans-serif;
  --font-s: 'Piazzolla', serif;
  --font-m: 'Chivo Mono', monospace;
  --topbar-h: 56px;
  --composer-h: 132px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--tx);
  font-family: var(--font-d);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
.mono { font-family: var(--font-m); font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--verde); outline-offset: 3px; border-radius: 2px; }

.logo-ring circle { fill: var(--verde); }
.logo-tail circle { fill: var(--tx); }

/* ─── Topbar ─── */
.chat-topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 32px);
  background: rgba(11, 20, 31, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ink-line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .logo-q { width: 26px; height: 26px; overflow: visible; }
.brand-word { font-weight: 800; font-size: 15px; letter-spacing: 0.22em; }
.btn-nueva {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--tx-mut);
  background: transparent; border: 1px solid var(--ink-line); border-radius: 2px;
  padding: 7px 13px; cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
.btn-nueva:hover { color: var(--tx); border-color: var(--tx-mut); }
.btn-nueva svg { width: 15px; height: 15px; }

/* ─── Main / scroll ─── */
.chat-main {
  flex: 1 1 auto; overflow-y: auto;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}
.feed, .welcome {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px);
}

/* ─── Welcome ─── */
.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding-top: 40px; padding-bottom: 40px; gap: 4px;
}
.welcome-logo { width: 46px; height: 46px; overflow: visible; margin-bottom: 18px; }
.welcome h1 {
  font-size: clamp(28px, 5vw, 40px); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance;
}
.welcome h1::after { content: ''; }
.welcome-sub {
  color: var(--tx-mut); font-size: 16px; max-width: 460px;
  margin: 14px auto 30px; line-height: 1.6;
}
.sugerencias {
  display: grid; gap: 10px; width: 100%; max-width: 560px;
  grid-template-columns: repeat(2, 1fr);
}
.sug {
  font: inherit; font-size: 14px; text-align: left; color: var(--tx-mut);
  background: var(--ink-2); border: 1px solid var(--ink-line);
  border-radius: 3px; padding: 14px 16px; cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.1s;
}
.sug:hover { border-color: var(--verde); color: var(--tx); }
.sug:active { transform: scale(0.99); }

/* ─── Feed / mensajes ─── */
.feed { padding-top: 28px; padding-bottom: 28px; display: flex; flex-direction: column; gap: 26px; }
.feed:empty { display: none; }

.msg { display: flex; flex-direction: column; gap: 4px; opacity: 0; transform: translateY(10px); animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

.msg-role {
  font-family: var(--font-m); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--tx-dim);
}
.msg-user .msg-role { color: var(--verde); }
.msg-body { font-size: 15.5px; line-height: 1.7; color: var(--tx); }
.msg-user .msg-body {
  color: #E4F5EC;
}
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: #FFFFFF; font-weight: 700; }
.msg-body ul, .msg-body ol { margin: 4px 0 10px; padding-left: 22px; }
.msg-body li { margin-bottom: 5px; }
.msg-body code {
  font-family: var(--font-m); font-size: 0.88em;
  background: var(--ink-3); padding: 1px 6px; border-radius: 3px;
  color: var(--verde);
}

/* Typing */
.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--tx-mut);
  animation: tp 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes tp { 0%,60%,100% { opacity: 0.25; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.msg-error .msg-body { color: #F0997B; }

/* ─── Composer ─── */
.composer-wrap {
  flex: 0 0 auto;
  background: linear-gradient(to top, var(--ink) 70%, transparent);
  padding: 14px clamp(16px, 4vw, 32px) 12px;
}
.composer {
  width: 100%; max-width: 760px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--ink-2); border: 1px solid var(--ink-line);
  border-radius: 14px; padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}
.composer:focus-within { border-color: var(--tx-mut); }
#input {
  flex: 1; resize: none; border: none; background: transparent;
  font: inherit; font-size: 15.5px; color: var(--tx); line-height: 1.5;
  padding: 8px 0; max-height: 200px; overflow-y: auto;
}
#input::placeholder { color: var(--tx-dim); }
#input:focus { outline: none; }
.send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 9px;
  background: var(--verde); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.2s, opacity 0.2s, transform 0.1s;
}
.send svg { width: 19px; height: 19px; color: var(--verde-deep); }
.send:hover { filter: brightness(1.08); }
.send:active { transform: scale(0.92); }
.send:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }
.composer-fine {
  max-width: 760px; margin: 8px auto 0; text-align: center;
  font-size: 11.5px; color: var(--tx-dim); line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; opacity: 1; transform: none; }
  .chat-main { scroll-behavior: auto; }
}
@media (max-width: 540px) {
  .sugerencias { grid-template-columns: 1fr; }
}
