/* =========================================================================
   Ask AI — chat page. Uses the shared Ascent tokens from theme.css.
   ========================================================================= */

.chat-wrap{
  max-width:820px;
  margin:0 auto;
  padding:24px 16px 0;
  height:calc(100vh - 66px);      /* fill below the fixed nav */
  display:flex;
  flex-direction:column;
}

.chat-head{ text-align:center; margin-bottom:14px; }
.chat-head .eyebrow{
  display:inline-block; font-family:var(--font-mono); font-size:.72rem;
  letter-spacing:.14em; text-transform:uppercase; color:var(--accent);
  background:var(--accent-soft); padding:4px 10px; border-radius:999px; margin-bottom:8px;
}
.chat-head h1{ font-family:var(--font-display); font-size:1.6rem; margin:0 0 4px; }
.chat-head p{ color:var(--text-soft); margin:0; font-size:.95rem; }

.chat-meta{ display:flex; gap:10px; justify-content:center; align-items:center; margin-top:10px; }
.quota-pill{
  font-family:var(--font-mono); font-size:.7rem; letter-spacing:.04em;
  padding:4px 10px; border-radius:999px;
  background:var(--surface-2); border:1px solid var(--border); color:var(--text-faint);
}
.quota-pill.low{ background:var(--warn-bg); border-color:var(--warn); color:var(--warn); }
.clear-chat{
  font-size:.72rem; padding:4px 10px; border-radius:999px; cursor:pointer;
  background:none; border:1px solid var(--border); color:var(--text-faint);
  transition:all var(--t-fast) var(--ease);
}
.clear-chat:hover{ border-color:var(--fail); color:var(--fail); }

/* ---------- message stream ---------- */
.chat-stream{
  flex:1; overflow-y:auto; padding:8px 2px 16px;
  display:flex; flex-direction:column; gap:16px;
}
.msg{ display:flex; gap:12px; align-items:flex-start; }
.msg .avatar{
  flex:0 0 34px; width:34px; height:34px; border-radius:50%;
  display:grid; place-items:center; font-size:1rem; font-weight:700;
  font-family:var(--font-display);
}
.msg.user .avatar{ background:var(--surface-3); color:var(--text-soft); }
.msg.ai .avatar{ background:var(--grad-brand); color:#fff; }

.msg .bubble{
  flex:1; min-width:0; padding:12px 16px; border-radius:var(--r-lg);
  border:1px solid var(--border); background:var(--surface);
  box-shadow:var(--shadow-sm); line-height:1.6; font-size:.95rem;
  overflow-wrap:anywhere;
}
.msg.user .bubble{ background:var(--surface-2); }

/* rendered markdown inside a bubble */
.bubble p{ margin:0 0 10px; } .bubble p:last-child{ margin-bottom:0; }
.bubble ul,.bubble ol{ margin:0 0 10px; padding-left:22px; }
.bubble li{ margin:3px 0; }
.bubble h1,.bubble h2,.bubble h3,.bubble h4{ font-family:var(--font-display); margin:14px 0 6px; line-height:1.3; }
.bubble h1{ font-size:1.2rem; } .bubble h2{ font-size:1.1rem; }
.bubble h3{ font-size:1rem; } .bubble h4{ font-size:.94rem; color:var(--text-soft); }
.bubble > h1:first-child,.bubble > h2:first-child,.bubble > h3:first-child,.bubble > h4:first-child{ margin-top:0; }
.bubble a{ color:var(--accent); }
.bubble code{
  font-family:var(--font-mono); font-size:.86em;
  background:var(--surface-3); padding:.12em .4em; border-radius:6px;
}
.bubble pre{
  background:var(--code-bg); color:var(--code-text); border-radius:var(--r);
  padding:14px 16px; overflow-x:auto; margin:0 0 10px; position:relative;
  border:1px solid var(--code-line);
}
.bubble pre code{ background:none; padding:0; color:inherit; font-size:.85rem; line-height:1.55; }
.bubble pre .copy-code{
  position:absolute; top:8px; right:8px; font-size:.7rem; font-family:var(--font-mono);
  padding:3px 8px; border-radius:6px; cursor:pointer; opacity:.7;
  background:rgba(255,255,255,.08); color:var(--code-text); border:1px solid var(--code-line);
}
.bubble pre .copy-code:hover{ opacity:1; }
.bubble blockquote{ margin:0 0 10px; padding:2px 0 2px 14px; border-left:3px solid var(--border-strong); color:var(--text-soft); }

/* tables — scroll inside the bubble rather than stretching it */
.bubble .table-wrap{ overflow-x:auto; margin:0 0 12px; border:1px solid var(--border); border-radius:var(--r); }
.bubble table{ border-collapse:collapse; width:100%; font-size:.88rem; }
.bubble th,.bubble td{ padding:8px 12px; text-align:left; border-bottom:1px solid var(--border); vertical-align:top; }
.bubble td{ overflow-wrap:anywhere; }          /* wrap prose so narrow tables need no scroll */
.bubble thead th{
  background:var(--surface-2); font-family:var(--font-display);
  font-weight:600; font-size:.82rem; white-space:nowrap;
}
.bubble tbody tr:last-child td{ border-bottom:none; }
.bubble tbody tr:nth-child(even){ background:var(--surface-2); }

/* typing dots while the first token is pending */
.typing{ display:inline-flex; gap:4px; padding:4px 0; }
.typing span{ width:7px; height:7px; border-radius:50%; background:var(--text-faint); animation:blink 1.2s infinite both; }
.typing span:nth-child(2){ animation-delay:.2s; } .typing span:nth-child(3){ animation-delay:.4s; }
@keyframes blink{ 0%,80%,100%{ opacity:.25; } 40%{ opacity:1; } }

.chat-error{
  color:var(--fail); background:var(--fail-bg); border:1px solid var(--fail);
  padding:10px 14px; border-radius:var(--r); font-size:.9rem; margin:0 0 4px;
}

/* ---------- suggestion chips (empty state) ---------- */
.chat-suggest{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:6px; }
.chat-suggest button{
  font-size:.85rem; padding:8px 14px; border-radius:999px; cursor:pointer;
  background:var(--surface-2); border:1px solid var(--border); color:var(--text-soft);
  transition:all var(--t-fast) var(--ease);
}
.chat-suggest button:hover{ border-color:var(--accent); color:var(--text); background:var(--accent-soft); }

/* ---------- composer ---------- */
.chat-composer{
  border-top:1px solid var(--border); padding:12px 0 16px; background:var(--bg);
}
.composer-row{
  display:flex; gap:10px; align-items:flex-end;
  background:var(--surface); border:1px solid var(--border-strong);
  border-radius:var(--r-lg); padding:8px 8px 8px 14px; box-shadow:var(--shadow-sm);
  transition:border-color var(--t-fast) var(--ease);
}
.composer-row:focus-within{ border-color:var(--accent); }
.chat-composer textarea{
  flex:1; border:none; background:none; resize:none; outline:none;
  font-family:var(--font-body); font-size:.98rem; color:var(--text);
  line-height:1.5; max-height:180px; padding:6px 0;
}
.chat-composer textarea::placeholder{ color:var(--text-faint); }
.send-btn{
  flex:0 0 auto; width:40px; height:40px; border-radius:12px; cursor:pointer;
  border:none; background:var(--grad-brand); color:#fff;
  display:grid; place-items:center; transition:opacity var(--t-fast) var(--ease);
}
.send-btn:disabled{ opacity:.4; cursor:not-allowed; }
.send-btn svg{ width:20px; height:20px; }
.composer-hint{ text-align:center; color:var(--text-faint); font-size:.75rem; margin:8px 0 0; }

@media (max-width:600px){
  .chat-wrap{ height:calc(100vh - 58px); }
  .chat-head h1{ font-size:1.35rem; }
}
