/* Chat v2 — handoff styles, fully scoped under .ai-chat-v2 to avoid collision
   with legacy .ai-msg / .ai-text rules in index.css. Tokens come from index.css. */

/* ===== Embed mode (native iOS WKWebView) =====
   Triggered by ?embed=1 → <html data-embed="1">. Hides web app chrome so
   the chat surface fits cleanly inside the native navigation header.
   Recent Chats also hide because the web Firebase JS SDK can't see the
   iOS-side authenticated user (no Firebase Auth bridge yet). */
html[data-embed="1"] .headernav,
html[data-embed="1"] #aceapp-header,
html[data-embed="1"] #mySidenav,
html[data-embed="1"] .sidenav,
html[data-embed="1"] #left-nav,
html[data-embed="1"] .right-nav,
html[data-embed="1"] #accountDropdown { display: none !important; }
html[data-embed="1"] body { padding: 0 !important; margin: 0 !important; }
html[data-embed="1"] .ai-chat-v2 { min-height: 100vh; }
html[data-embed="1"] .ai-chat-v2 .ai-recent,
html[data-embed="1"] .ai-chat-v2 .ai-thread-bar { display: none !important; }


.ai-chat-v2 {
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: calc(100vh - 60px);
  position: relative;
  font-family: 'Point', 'Point Book', system-ui, sans-serif;
  color: var(--ace-text, #1e293b);
  text-align: left;
}
.ai-chat-v2 *, .ai-chat-v2 *::before, .ai-chat-v2 *::after { box-sizing: border-box; }

/* ===== state toggle ===== */
.ai-chat-v2[data-state="empty"] .ai-thread { display: none; }
.ai-chat-v2[data-state="thread"] .ai-hero,
.ai-chat-v2[data-state="thread"] .ai-suggest,
.ai-chat-v2[data-state="thread"] .ai-recent { display: none; }
.ai-chat-v2[data-state="empty"] .ai-thread-title { opacity: 0.6; }

/* ===== Stage ===== */
.ai-chat-v2 .ai-chat-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0;
  position: relative;
  padding: 28px 32px 0;
}
.ai-chat-v2 .ai-chat-col {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-bottom: 140px;
}

/* ===== Hero (empty state) ===== */
.ai-chat-v2 .ai-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 0 8px;
}
.ai-chat-v2 .ai-hero-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--ace-ice, #E6F7FD), #fff);
  border: 1px solid #bfe6f5;
  display: grid;
  place-items: center;
  color: var(--ace-navy, #023C5B);
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(2, 60, 91, 0.08);
}
.ai-chat-v2 .ai-hero h1 {
  font-size: 26px;
  font-weight: 900;
  color: var(--ace-navy, #023C5B);
  letter-spacing: -.3px;
  margin: 0;
}
.ai-chat-v2 .ai-hero p {
  margin: 8px 0 18px;
  font-size: 14px;
  color: var(--ace-text-secondary, #64748b);
  max-width: 460px;
  line-height: 1.5;
}

.ai-chat-v2 .ai-scope {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 auto;
}
.ai-chat-v2 .ai-scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  color: var(--ace-navy, #023C5B);
  background: var(--ace-ice, #E6F7FD);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #bfe6f5;
}
.ai-chat-v2 .ai-scope-chip svg { color: #FF7182; }

/* ===== Suggestions ===== */
.ai-chat-v2 .ai-suggest { display: flex; flex-direction: column; gap: 16px; }
.ai-chat-v2 .ai-suggest-group { display: flex; flex-direction: column; gap: 8px; }
.ai-chat-v2 .ai-suggest-cat {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ace-text-muted, #94a3b8);
  padding: 0 4px;
}
.ai-chat-v2 .ai-suggest-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.ai-chat-v2 .ai-suggest-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--ace-radius-md, 10px);
  background: #fff;
  border: 1px solid var(--ace-border, #e8ecf4);
  font: inherit;
  color: var(--ace-text, #1e293b);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all .15s ease;
}
.ai-chat-v2 .ai-suggest-card:hover {
  border-color: #bfe6f5;
  background: var(--ace-ice, #E6F7FD);
  color: var(--ace-navy, #023C5B);
  transform: translateY(-1px);
  box-shadow: var(--ace-shadow-card, 0 1px 4px rgba(0, 0, 0, 0.06));
}
.ai-chat-v2 .ai-suggest-card .ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ace-surface-hover, #f1f5f9);
  color: var(--ace-text-secondary, #64748b);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ai-chat-v2 .ai-suggest-card:hover .ic { background: #fff; color: var(--ace-navy, #023C5B); }
.ai-chat-v2 .ai-suggest-card .t { flex: 1; min-width: 0; }

/* ===== Recent ===== */
.ai-chat-v2 .ai-recent {
  background: var(--ace-surface-alt, #f8f9fc);
  border: 1px solid var(--ace-border, #e8ecf4);
  border-radius: var(--ace-radius-md, 10px);
  padding: 6px 8px;
}
.ai-chat-v2 .ai-recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ace-text-muted, #94a3b8);
}
.ai-chat-v2 .ai-recent-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--ace-text-muted, #94a3b8);
  font-weight: 500;
  text-align: center;
}
.ai-chat-v2 .ai-recent-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.ai-chat-v2 .ai-recent-row:hover { background: var(--ace-surface-hover, #f1f5f9); }
.ai-chat-v2 .ai-recent-row .q {
  font-size: 13px;
  color: var(--ace-text, #1e293b);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.ai-chat-v2 .ai-recent-row .w {
  font-size: 11px;
  color: var(--ace-text-muted, #94a3b8);
  font-weight: 600;
  flex-shrink: 0;
}

/* ===== Composer (pinned bottom) ===== */
.ai-chat-v2 .ai-composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 32px 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 28%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 5;
}
.ai-chat-v2 .ai-composer {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 8px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--ace-border, #e8ecf4);
  box-shadow: 0 6px 20px rgba(2, 60, 91, 0.06);
}
.ai-chat-v2 .ai-composer:focus-within {
  border-color: #bfe6f5;
  box-shadow: 0 6px 20px rgba(2, 60, 91, 0.10), 0 0 0 3px rgba(90, 200, 242, 0.15);
}
.ai-chat-v2 .ai-composer input {
  flex: 1;
  height: 36px;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  color: var(--ace-text, #1e293b);
}
.ai-chat-v2 .ai-composer-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--ace-text-secondary, #64748b);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ai-chat-v2 .ai-composer-icon:hover {
  background: var(--ace-surface-hover, #f1f5f9);
  color: var(--ace-navy, #023C5B);
}
.ai-chat-v2 .ai-composer-mic.is-listening {
  background: var(--ace-pink, #FFDFE3);
  color: var(--ace-critical, #C41230);
  animation: ai-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes ai-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 18, 48, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(196, 18, 48, 0); }
}
.ai-chat-v2 .ai-composer-send {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: var(--ace-blue, #5AC8F2);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ai-chat-v2 .ai-composer-send:hover { background: var(--ace-blue-hover, #48b8e0); }
.ai-chat-v2 .ai-composer-send:disabled { opacity: .55; cursor: not-allowed; }
.ai-chat-v2 .ai-composer-hint {
  font-size: 11px;
  color: var(--ace-text-muted, #94a3b8);
  font-weight: 500;
}

/* ===== Thread bar ===== */
.ai-chat-v2 .ai-thread-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  border-bottom: 1px solid var(--ace-border, #e8ecf4);
  background: #fff;
  gap: 12px;
}
.ai-chat-v2 .ai-thread-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ace-navy, #023C5B);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.ai-chat-v2 .ai-thread-title svg { color: var(--ace-blue, #5AC8F2); flex-shrink: 0; }
.ai-chat-v2 .ai-thread-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
/* Composer foot row — hint on left, model picker on right */
.ai-chat-v2 .ai-composer-foot {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

/* Model warning banner — sits just above the composer */
.ai-chat-v2 .ai-model-banner {
  width: 100%;
  max-width: 760px;
  margin-bottom: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-chat-v2 .ai-model-banner[data-tone="info"] {
  background: var(--ace-ice, #E6F7FD);
  color: var(--ace-navy, #023C5B);
  border: 1px solid #bfe6f5;
}
.ai-chat-v2 .ai-model-banner[data-tone="warn"] {
  background: var(--ace-peach, #FCE5CD);
  color: #7a4715;
  border: 1px solid #f3cf9c;
}
.ai-chat-v2 .ai-model-banner[hidden] { display: none; }
.ai-chat-v2 .ai-model-select {
  height: 24px;
  padding: 0 22px 0 6px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--ace-text-muted, #94a3b8);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.ai-chat-v2 .ai-model-select:hover {
  color: var(--ace-navy, #023C5B);
  background-color: var(--ace-surface-hover, #f1f5f9);
}
.ai-chat-v2 .ai-model-select:focus {
  outline: none;
  background-color: var(--ace-surface-hover, #f1f5f9);
  color: var(--ace-navy, #023C5B);
  box-shadow: 0 0 0 2px rgba(90, 200, 242, 0.20);
}

.ai-chat-v2 .ai-newchat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--ace-border, #e8ecf4);
  background: #fff;
  color: var(--ace-navy, #023C5B);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.ai-chat-v2 .ai-newchat-btn:hover {
  background: var(--ace-surface-hover, #f1f5f9);
  border-color: #cbd9e2;
}

/* ===== Thread / messages ===== */
.ai-chat-v2 .ai-thread {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 0 140px;
}
.ai-chat-v2 .ai-msg { display: flex; flex-direction: column; gap: 4px; }
.ai-chat-v2 .ai-msg-user { align-items: flex-end; }
.ai-chat-v2 .ai-msg-bot { flex-direction: row; align-items: flex-start; gap: 12px; }

.ai-chat-v2 .ai-av-bot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ace-blue, #5AC8F2), var(--ace-navy, #023C5B));
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 16px;
}

.ai-chat-v2 .ai-bot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-chat-v2 .ai-meta {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ace-text-muted, #94a3b8);
}
.ai-chat-v2 .ai-bubble-user {
  background: var(--ace-navy, #023C5B);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px 14px 4px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 80%;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-chat-v2 .ai-bubble-bot {
  background: var(--ace-surface-alt, #f8f9fc);
  border: 1px solid var(--ace-border, #e8ecf4);
  padding: 16px 18px;
  border-radius: 4px 14px 14px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ace-text, #1e293b);
  word-wrap: break-word;
}
.ai-chat-v2 .ai-bubble-bot p { margin: 0 0 8px; }
.ai-chat-v2 .ai-bubble-bot p:last-child { margin-bottom: 0; }
.ai-chat-v2 .ai-bubble-bot .ai-resp-h1,
.ai-chat-v2 .ai-bubble-bot .ai-resp-h2,
.ai-chat-v2 .ai-bubble-bot .ai-resp-h3 {
  font-weight: 800;
  color: var(--ace-navy, #023C5B);
  margin: 8px 0 6px;
}
.ai-chat-v2 .ai-bubble-bot .ai-resp-h1 { font-size: 15px; }
.ai-chat-v2 .ai-bubble-bot .ai-resp-h2 { font-size: 14px; }
.ai-chat-v2 .ai-bubble-bot .ai-resp-h3 { font-size: 13px; }
.ai-chat-v2 .ai-bubble-bot .ai-resp-bullet { padding: 2px 0 2px 14px; position: relative; }
.ai-chat-v2 .ai-bubble-bot .ai-resp-bullet::before {
  content: '•';
  position: absolute;
  left: 2px;
  color: var(--ace-blue, #5AC8F2);
}
.ai-chat-v2 .ai-bubble-bot .ai-resp-bullet .ai-resp-num {
  font-weight: 700;
  color: var(--ace-navy, #023C5B);
  margin-right: 4px;
}
.ai-chat-v2 .ai-bubble-bot .ai-resp-bullet:has(.ai-resp-num)::before { content: ''; }
.ai-chat-v2 .ai-bubble-bot a.ai-resp-store-link {
  color: var(--ace-blue, #5AC8F2);
  text-decoration: none;
  font-weight: 700;
}
.ai-chat-v2 .ai-bubble-bot a.ai-resp-store-link:hover { text-decoration: underline; }

/* Markdown tables inside assistant bubbles */
.ai-chat-v2 .ai-bubble-bot .ai-md-table-wrap {
  margin: 10px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--ace-border, #e8ecf4);
}
.ai-chat-v2 .ai-bubble-bot .ai-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: #fff;
}
.ai-chat-v2 .ai-bubble-bot .ai-md-table thead th {
  background: var(--ace-navy, #023C5B);
  color: #fff;
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 8px 12px;
  white-space: nowrap;
}
.ai-chat-v2 .ai-bubble-bot .ai-md-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--ace-border-soft, #f1f5f9);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
  white-space: nowrap;
}
.ai-chat-v2 .ai-bubble-bot .ai-md-table tbody tr:last-child td { border-bottom: 0; }
.ai-chat-v2 .ai-bubble-bot .ai-md-table tbody tr:hover { background: var(--ace-surface-alt, #f8f9fc); }

/* Mobile: stacked card layout — each row becomes a key:value card */
@media (max-width: 560px) {
  .ai-chat-v2 .ai-bubble-bot .ai-md-table-wrap {
    border: 0;
    overflow-x: visible;
    margin: 8px 0;
  }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table { display: block; }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table thead { display: none; }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table tbody,
  .ai-chat-v2 .ai-bubble-bot .ai-md-table tr { display: block; }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table tr {
    background: #fff;
    border: 1px solid var(--ace-border, #e8ecf4);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table tbody tr:hover { background: #fff; }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    white-space: normal;
    font-size: 13px;
  }
  .ai-chat-v2 .ai-bubble-bot .ai-md-table td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--ace-text-muted, #94a3b8);
    flex-shrink: 0;
  }
}

/* Typing indicator inside reserved bot bubble */
.ai-chat-v2 .ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ace-text-secondary, #64748b);
  font-weight: 600;
}
.ai-chat-v2 .ai-typing-dots {
  display: inline-flex;
  gap: 3px;
}
.ai-chat-v2 .ai-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ace-blue, #5AC8F2);
  animation: ai-typing-bounce 1.2s infinite ease-in-out;
}
.ai-chat-v2 .ai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-chat-v2 .ai-typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* Inline error state */
.ai-chat-v2 .ai-error {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-chat-v2 .ai-error-msg {
  font-size: 13px;
  color: var(--ace-critical, #C41230);
  font-weight: 600;
}
.ai-chat-v2 .ai-retry {
  align-self: flex-start;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ace-blue, #5AC8F2);
  color: #fff;
  border: 0;
  cursor: pointer;
}
.ai-chat-v2 .ai-retry:hover { background: var(--ace-blue-hover, #48b8e0); }

/* Action row */
.ai-chat-v2 .ai-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.ai-chat-v2 .ai-actions button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--ace-text-secondary, #64748b);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ai-chat-v2 .ai-actions button:hover {
  background: var(--ace-surface-hover, #f1f5f9);
  color: var(--ace-navy, #023C5B);
}
.ai-chat-v2 .ai-actions button:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.ai-chat-v2 .ai-actions button.is-active {
  background: var(--ace-ice, #E6F7FD);
  color: var(--ace-navy, #023C5B);
}
.ai-chat-v2 .ai-source {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--ace-text-muted, #94a3b8);
  text-transform: uppercase;
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .ai-chat-v2 .ai-chat-stage { padding: 20px 16px 0; }
  .ai-chat-v2 .ai-suggest-list { grid-template-columns: 1fr; }
  .ai-chat-v2 .ai-composer-wrap { padding: 12px 16px 16px; }
  .ai-chat-v2 .ai-thread-bar { padding: 10px 16px; }
  .ai-chat-v2 .ai-bubble-user { max-width: 88%; }
  .ai-chat-v2 .ai-thread { padding: 18px 0 130px; }
  .ai-chat-v2 .ai-hero h1 { font-size: 22px; }
}

/* ===== Negative feedback modal ===== */
.ai-fb-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.ai-fb-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  max-width: 480px; width: 100%;
  padding: 22px 22px 18px;
  font-family: inherit;
}
.ai-fb-modal .ai-fb-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.ai-fb-modal .ai-fb-head h2 {
  font-size: 17px; font-weight: 600; margin: 0; color: #0f172a;
}
.ai-fb-modal .ai-fb-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  color: #64748b; cursor: pointer; padding: 4px 8px;
}
.ai-fb-modal .ai-fb-close:hover { color: #0f172a; }
.ai-fb-modal .ai-fb-cats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 12px;
}
.ai-fb-modal .ai-fb-cats button {
  background: #f1f5f9; border: 1px solid transparent;
  padding: 10px 12px; border-radius: 8px; font-size: 13px;
  color: #334155; cursor: pointer; text-align: left;
  transition: background .12s, border-color .12s;
}
.ai-fb-modal .ai-fb-cats button:hover { background: #e2e8f0; }
.ai-fb-modal .ai-fb-cats button.is-active {
  background: #fef3c7; border-color: #fbbf24; color: #78350f; font-weight: 500;
}
.ai-fb-modal .ai-fb-comment {
  width: 100%; min-height: 80px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: #0f172a;
  resize: vertical; box-sizing: border-box;
  margin-bottom: 12px;
}
.ai-fb-modal .ai-fb-comment:focus { outline: none; border-color: #60a5fa; }
.ai-fb-modal .ai-fb-foot {
  display: flex; justify-content: flex-end;
}
.ai-fb-modal .ai-fb-submit {
  background: #0f172a; color: #fff; border: none;
  padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.ai-fb-modal .ai-fb-submit:disabled {
  background: #cbd5e1; cursor: not-allowed;
}
.ai-fb-modal .ai-fb-submit:not(:disabled):hover { background: #1e293b; }
@media (max-width: 480px) {
  .ai-fb-modal .ai-fb-cats { grid-template-columns: 1fr; }
}

/* ===== Persistent recent-chats sidebar (collapsible) ===== */
.ai-chat-v2 .ai-chat-stage {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 1fr auto;
  gap: 0;
}
.ai-chat-v2 .ai-recent-side {
  grid-row: 1 / span 2;
  background: #fafafa;
  border-right: 1px solid #e2e8f0;
  padding: 18px 14px 24px;
  overflow-y: auto;
  transition: width .18s ease, padding .18s ease;
}
.ai-chat-v2 .ai-recent-side-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.ai-chat-v2 .ai-recent-side-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: #64748b;
}
.ai-chat-v2 .ai-recent-toggle {
  width: 24px; height: 24px;
  background: #fff; border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 16px; font-weight: 600; line-height: 1;
  color: #334155; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ai-chat-v2 .ai-recent-toggle:hover { background: #f1f5f9; }
.ai-chat-v2 .ai-recent-side-body {
  display: flex; flex-direction: column; gap: 4px;
}
.ai-chat-v2 .ai-recent-side-body .ai-recent-row {
  display: block; width: 100%;
  background: transparent; border: none;
  text-align: left; padding: 8px 10px;
  border-radius: 6px; cursor: pointer;
  transition: background .12s;
}
.ai-chat-v2 .ai-recent-side-body .ai-recent-row:hover { background: #e2e8f0; }
.ai-chat-v2 .ai-recent-side-body .ai-recent-row .q {
  display: block; font-size: 13px; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-chat-v2 .ai-recent-side-body .ai-recent-row .w {
  display: block; font-size: 11px; color: #94a3b8; margin-top: 2px;
}
.ai-chat-v2 .ai-recent-side-body .ai-recent-empty {
  font-size: 12px; color: #94a3b8; padding: 8px 10px;
}

/* Collapsed state: thin rail, just the toggle */
.ai-chat-v2[data-recent="collapsed"] .ai-chat-stage {
  grid-template-columns: 36px 1fr;
}
.ai-chat-v2[data-recent="collapsed"] .ai-recent-side {
  padding: 14px 6px;
}
.ai-chat-v2[data-recent="collapsed"] .ai-recent-side-title,
.ai-chat-v2[data-recent="collapsed"] .ai-recent-side-body {
  display: none;
}
.ai-chat-v2[data-recent="collapsed"] .ai-recent-side-head {
  justify-content: center;
  margin-bottom: 0;
}

/* Hide the old in-column recent block (wasn't removed structurally elsewhere) */
.ai-chat-v2 .ai-chat-col .ai-recent { display: none !important; }

@media (max-width: 720px) {
  .ai-chat-v2 .ai-chat-stage { grid-template-columns: 0 1fr; }
  .ai-chat-v2 .ai-recent-side {
    position: fixed; top: 56px; left: 0; bottom: 0;
    width: 240px; z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .ai-chat-v2[data-recent="expanded"] .ai-recent-side { transform: translateX(0); }
  .ai-chat-v2[data-recent="collapsed"] .ai-recent-side { transform: translateX(-100%); }
}
