/* ===================================================================
   CHAT A.I+ — 3allemni Design System
   =================================================================== */

:root {
  /* Palette — 3allemni brand tokens */
  --bg-page:          #F5F7FA;
  --sidebar-bg:       #070C12;
  --sidebar-border:   rgba(255,255,255,0.07);
  --surface:          #ffffff;

  /* Brand blue (#356DF1 = 500) */
  --primary:          #356DF1;
  --primary-600:      #2458d0;
  --primary-700:      #1c44aa;
  --primary-200:      #a9c5f7;
  --primary-300:      #7aa3f3;
  --primary-50:       #eaf0fd;
  --primary-25:       #f4f7fe;

  /* Accent orange */
  --accent-500:       #F57F2A;
  --accent-600:       #d96414;

  /* Neutral grays (slate-leaning, from design system) */
  --text-900:         #101828;
  --text-700:         #344054;
  --text-500:         #667085;
  --text-400:         #98a2b3;
  --text-300:         #d0d5dd;

  --divider:          #e4e7ec;
  --divider-soft:     #f2f4f7;
  --black-btn:        #070C12;

  --upgrade-bg:       #356DF1;
  --upgrade-star:     #F57F2A;

  /* Radii — per design brief */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-pill: 999px;

  /* Shadows — neutral rgba(16,24,40,x) per design system */
  --shadow-xs:       0 1px 2px 0 rgba(16,24,40,0.05);
  --shadow-sm:       0 1px 3px 0 rgba(16,24,40,0.10), 0 1px 2px 0 rgba(16,24,40,0.06);
  --shadow-md:       0 4px 8px -2px rgba(16,24,40,0.10), 0 2px 4px -2px rgba(16,24,40,0.06);
  --shadow-lg:       0 12px 16px -4px rgba(16,24,40,0.08), 0 4px 6px -2px rgba(16,24,40,0.03);
  --shadow-focus:    0 0 0 4px rgba(53,109,241,0.12);
  --shadow-composer: 0 8px 24px -4px rgba(16,24,40,0.10), 0 2px 6px -2px rgba(16,24,40,0.06);

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  /* Motion — 3allemni standard */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:  120ms;
  --dur-normal: 200ms;

  /* Typography */
  --font-display: 'Syne', system-ui, sans-serif;
  --font:         'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-mono:    ui-monospace, 'SFMono-Regular', 'Consolas', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text-900);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

/* ===============================================================
   APP LAYOUT
   =============================================================== */
.app {
  display: flex;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--bg-page);
}

/* ===============================================================
   SIDEBAR — dark signature (#070C12)
   =============================================================== */
.sidebar {
  width: 270px;
  flex: 0 0 270px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-top {
  padding: 22px 18px 8px;
  flex: 0 0 auto;
}

/* Brand wordmark */
.brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ffffff;
  margin: 0 0 18px;
  line-height: 1;
}
.brand-plus {
  color: var(--accent-500);
  font-weight: 800;
  margin-left: 2px;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.btn-new-chat {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast);
  box-shadow: 0 4px 14px rgba(53,109,241,0.35);
}
.btn-new-chat:hover { background: var(--primary-600); }
.btn-new-chat:active { transform: translateY(0.5px); }

.btn-search-round {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.btn-search-round:hover { background: rgba(255,255,255,0.13); }
.btn-search-round:active { transform: translateY(0.5px); }

.conv-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 2px;
  margin-bottom: 8px;
}
.conv-head-label {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.conv-clear-all {
  background: none;
  border: none;
  color: var(--primary-300);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.conv-clear-all:hover {
  background: rgba(53,109,241,0.15);
  color: var(--primary-200);
}

/* History scroll */
.history-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 8px;
}
.history-scroll::-webkit-scrollbar { width: 3px; }
.history-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 2px;
}
.history-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.20);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-group-label {
  font-size: 10.5px;
  color: rgba(255,255,255,0.28);
  font-weight: 600;
  padding: 12px 8px 4px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  color: rgba(255,255,255,0.70);
  font-size: 13.5px;
  line-height: 1.2;
  user-select: none;
}
.history-item:hover { background: rgba(255,255,255,0.06); }
.history-item.active {
  background: rgba(53,109,241,0.16);
  color: var(--primary-200);
  font-weight: 600;
}

.history-item-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: rgba(255,255,255,0.35);
  display: inline-flex;
}
.history-item.active .history-item-icon { color: var(--primary-300); }

.history-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.history-item:hover .history-item-actions,
.history-item.active .history-item-actions { opacity: 1; }

.history-action-btn {
  background: transparent;
  border: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.history-action-btn:hover {
  background: rgba(53,109,241,0.15);
  color: var(--primary-200);
}

.history-item.disabled {
  color: rgba(255,255,255,0.22);
  cursor: not-allowed;
}

/* Sidebar footer */
.sidebar-footer {
  flex: 0 0 auto;
  padding: 10px 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 9px 12px;
  color: rgba(255,255,255,0.65);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.btn-settings:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.90);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 0;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(53,109,241,0.20);
  flex: 0 0 32px;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===============================================================
   MAIN
   =============================================================== */
.main {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-page);
}

.messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 56px 140px;
  scroll-behavior: smooth;
}
.messages-scroll::-webkit-scrollbar { width: 8px; }
.messages-scroll::-webkit-scrollbar-thumb {
  background: rgba(16,24,40,0.08);
  border-radius: 4px;
}

.messages {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ===== Message row ===== */
.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 28px;
  background: var(--primary-50);
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-author {
  font-size: 13.5px;
  color: var(--text-500);
  font-weight: 500;
}
.msg-author-brand {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.msg-verified {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  margin-left: 2px;
}

.msg-edit {
  background: transparent;
  border: none;
  color: var(--text-400);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.msg-edit:hover { background: var(--primary-50); color: var(--primary); }

.msg.user .msg-text {
  font-size: 14.5px;
  color: var(--text-700);
  font-weight: 500;
}
.msg.user .msg-author { display: none; }

/* Bot text */
.msg-text {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-900);
  word-wrap: break-word;
}
.msg-text p { margin: 0 0 12px; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text strong { color: var(--text-900); font-weight: 700; }
.msg-text ol, .msg-text ul {
  margin: 6px 0 12px;
  padding-left: 22px;
}
.msg-text ol { list-style: decimal; }
.msg-text ol li { padding-left: 4px; margin-bottom: 10px; }
.msg-text ul li { margin-bottom: 8px; }

/* ===== Message actions row ===== */
.msg-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.feedback-pill {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-xs);
  padding: 2px;
  gap: 0;
}
.feedback-btn {
  background: transparent;
  border: none;
  border-radius: var(--r-pill);
  width: 36px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-400);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.feedback-btn + .feedback-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 1px;
  background: var(--divider);
}
.feedback-btn:hover { background: var(--primary-50); color: var(--primary); }
.feedback-btn.active.up   { color: #22C55E; }
.feedback-btn.active.down { color: #EF4444; }
.feedback-btn.copied { color: var(--primary); }

.regenerate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-700);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  box-shadow: var(--shadow-xs);
}
.regenerate-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-50);
  color: var(--primary);
}
.regenerate-btn svg { width: 14px; height: 14px; }

/* ===============================================================
   COMPOSER (floating bar)
   =============================================================== */
.composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  display: flex;
  justify-content: center;
  padding: 0 56px;
  pointer-events: none;
  z-index: 5;
}
.composer {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--divider-soft);
  border-radius: var(--r-pill);
  padding: 8px 8px 8px 12px;
  box-shadow: var(--shadow-composer);
  transition: box-shadow var(--dur-normal) var(--ease-out), border-color var(--dur-normal);
}
.composer:focus-within {
  border-color: var(--primary-200);
  box-shadow: var(--shadow-composer), var(--shadow-focus);
}
.composer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #FDE68A 0%, #F472B6 50%, #8B5CF6 100%);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
}
.composer-avatar-emoji {
  font-size: 18px;
  line-height: 1;
}
.composer-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  color: var(--text-900);
  padding: 8px 4px;
  min-width: 0;
  font-family: inherit;
}
.composer-input::placeholder { color: var(--text-400); }

.composer-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast), box-shadow var(--dur-fast);
  box-shadow: 0 4px 14px rgba(53,109,241,0.40);
}
.composer-send:hover {
  background: var(--primary-600);
  box-shadow: 0 6px 18px rgba(53,109,241,0.45);
}
.composer-send:active { transform: translateY(0.5px); }
.composer-send svg { margin-left: 2px; margin-top: -1px; }

/* ===============================================================
   UPGRADE TAB
   =============================================================== */
.upgrade-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--upgrade-bg);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 22px 10px;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: -4px 0 20px rgba(53,109,241,0.30);
  transition: background var(--dur-fast), padding var(--dur-fast);
  z-index: 20;
}
.upgrade-tab:hover { background: var(--primary-600); }

.upgrade-tab-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.upgrade-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===============================================================
   MESSAGES CONTAINER
   =============================================================== */
#messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  scroll-behavior: smooth;
}
#messages-container::-webkit-scrollbar { width: 8px; }
#messages-container::-webkit-scrollbar-thumb {
  background: rgba(16,24,40,0.08);
  border-radius: 4px;
}
#messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(16,24,40,0.14);
}

/* ===============================================================
   MESSAGE ROWS + BUBBLES
   =============================================================== */
.message-row {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  animation: msgEnter var(--dur-normal) var(--ease-out) both;
}
.message-row.user { align-items: flex-end; }
.message-row.bot  { align-items: flex-start; }

.message-bubble {
  font-size: 14.5px;
  line-height: 1.65;
  word-wrap: break-word;
}

.message-bubble.user {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-lg);
  border-bottom-right-radius: 6px;
  max-width: 75%;
  box-shadow: 0 2px 8px rgba(53,109,241,0.22);
}

.message-bubble.bot {
  color: var(--text-900);
  padding: 4px 0;
  max-width: 100%;
}

@keyframes msgEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===============================================================
   TYPING INDICATOR
   =============================================================== */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--divider-soft);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
  width: fit-content;
  max-width: 760px;
}
.typing-indicator.visible { display: flex; }

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-300);
  animation: dotBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ===============================================================
   SCROLL TO BOTTOM BUTTON
   =============================================================== */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  color: var(--text-500);
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-normal) var(--ease-out);
  z-index: 6;
  opacity: 0;
}
.scroll-to-bottom-btn.visible {
  display: flex;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.scroll-to-bottom-btn:hover { background: var(--primary-50); color: var(--primary); }

/* ===============================================================
   COMPOSER — LOCKED STATE + ICON BUTTONS
   =============================================================== */
.composer.locked {
  opacity: 0.6;
  pointer-events: none;
}

.composer-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-400);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.composer-btn:hover { background: var(--primary-50); color: var(--primary); }

#mic-btn.is-recording {
  color: #EF4444;
  animation: pulseRecord 1.2s infinite;
}
@keyframes pulseRecord {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.35); }
  50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* ===============================================================
   OPTION BUTTONS
   =============================================================== */
.chat-options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chat-opt-btn {
  background: var(--primary-25);
  border: 1.5px solid var(--primary-50);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
  font-family: inherit;
}
.chat-opt-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  transform: translateY(-1px);
}
.chat-opt-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===============================================================
   MESSAGE ACTIONS ROW
   =============================================================== */
.message-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.feedback-row {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-xs);
  padding: 2px;
  gap: 0;
}

.message-actions-row .feedback-btn {
  background: transparent;
  border: none;
  border-radius: var(--r-pill);
  width: 36px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-400);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.message-actions-row .feedback-btn:hover { background: var(--primary-50); color: var(--primary); }
.message-actions-row .feedback-btn.active-positive { color: #22C55E; background: rgba(34,197,94,0.08); }
.message-actions-row .feedback-btn.active-negative { color: #EF4444; background: rgba(239,68,68,0.08); }
.message-actions-row .feedback-btn.copied { color: var(--primary); }

/* ===============================================================
   MARKDOWN OUTPUT STYLES
   =============================================================== */
.cv-answer { font-size: 14.5px; line-height: 1.7; color: var(--text-900); }
.cv-answer p { margin: 0 0 12px; }
.cv-answer p:last-child { margin-bottom: 0; }
.cv-answer strong { font-weight: 700; }
.cv-answer em { font-style: italic; }

.cv-title-lg {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-900);
  margin: 16px 0 8px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.cv-title-sm {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-700);
  margin: 12px 0 6px;
  line-height: 1.3;
}

.cv-list {
  margin: 6px 0 12px;
  padding-left: 22px;
}
.cv-list li { margin-bottom: 6px; line-height: 1.6; }

.cv-table-wrap {
  overflow-x: auto;
  margin: 12px 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.cv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.cv-table th, .cv-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--divider-soft);
}
.cv-table th {
  background: var(--primary-25);
  font-weight: 600;
  color: var(--primary-700);
}
.cv-table tr:last-child td { border-bottom: none; }
.cv-table tr:hover td { background: var(--primary-25); }

.cb-code-block {
  background: #F8F9FE;
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  margin: 12px 0;
  overflow: hidden;
  font-size: 13px;
  box-shadow: var(--shadow-xs);
}
.cb-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--primary-25);
  color: var(--primary-700);
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  border-bottom: 1px solid var(--primary-50);
}
.cb-copy-btn {
  background: transparent;
  border: 1px solid var(--primary-200);
  border-radius: 6px;
  color: var(--primary-600);
  font-size: 11.5px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.cb-copy-btn:hover {
  background: var(--primary-50);
  color: var(--primary);
}
.cb-copy-btn.copied { color: #22C55E; border-color: #22C55E; }

.cv-code {
  display: block;
  padding: 14px;
  color: var(--text-700);
  overflow-x: auto;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}
code { font-family: var(--font-mono); }

.cv-link {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-fast);
}
.cv-link:hover { border-bottom-color: var(--primary); }

.video-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-25);
  border: 1.5px solid var(--primary-50);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
  margin: 4px 0;
}
.video-link:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  transform: translateY(-1px);
}

.cv-text {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-900);
}

/* ===============================================================
   HISTORY EMPTY STATE + DELETE BTN
   =============================================================== */
.history-empty {
  padding: 24px 12px;
  text-align: center;
  color: rgba(255,255,255,0.28);
  font-size: 13px;
}

.history-item-delete {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.28);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
  flex-shrink: 0;
}
.history-item:hover .history-item-delete { opacity: 1; }
.history-item-delete:hover { color: #EF4444; background: rgba(239,68,68,0.12); }

/* ===============================================================
   USER AVATAR INITIAL + QUOTA BADGE
   =============================================================== */
.user-avatar-initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-200);
  background: rgba(53,109,241,0.20);
  border-radius: 50%;
  text-transform: uppercase;
}

.user-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.quota-badge {
  font-size: 11.5px;
  color: rgba(255,255,255,0.38);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quota-badge.low { color: #EF4444; font-weight: 600; }

/* ===============================================================
   MOBILE TOP BAR
   =============================================================== */
.main-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider-soft);
  flex: 0 0 auto;
  box-shadow: var(--shadow-xs);
}

.topbar-btn {
  background: transparent;
  border: 1px solid var(--divider);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-500);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.topbar-btn:hover { background: var(--primary-50); color: var(--primary); }

.topbar-brand {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.10em;
  color: var(--text-900);
}

/* ===============================================================
   SIDEBAR OVERLAY (mobile)
   =============================================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7,12,18,0.60);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ===============================================================
   VIDEO DRAWER
   =============================================================== */
.video-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 60%;
  background: var(--surface);
  box-shadow: -4px 0 32px rgba(16,24,40,0.14);
  transform: translateX(100%);
  transition: transform 0.32s var(--ease-out);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.video-drawer.open { transform: translateX(0); }

.video-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  flex: 0 0 auto;
}

.video-drawer-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-900);
  letter-spacing: -0.01em;
}

.video-drawer-close {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-400);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.video-drawer-close:hover { background: var(--primary-50); color: var(--primary); }

#video-iframe {
  flex: 1;
  border: none;
  width: 100%;
  background: #000;
}

.video-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7,12,18,0.45);
  z-index: 199;
}
.video-drawer-overlay.visible { display: block; }

/* ===============================================================
   LOGIN WALL
   =============================================================== */
.login-wall {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  text-align: center;
  padding: 24px;
  background: var(--bg-page);
}

.login-wall h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-900);
  margin: 0;
}

.login-wall p {
  font-size: 15px;
  color: var(--text-500);
  margin: 0;
  max-width: 340px;
  line-height: 1.6;
}

.login-btn {
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-pill);
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
  transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
  box-shadow: 0 4px 14px rgba(53,109,241,0.35);
  border: none;
  cursor: pointer;
}
.login-btn:hover {
  background: var(--primary-600);
  box-shadow: 0 6px 18px rgba(53,109,241,0.42);
}

/* ===============================================================
   RESPONSIVE
   =============================================================== */
@media (max-width: 960px) {
  .messages-scroll { padding: 20px 24px 140px; }
  .composer-wrap { padding: 0 24px; }
  #messages-container { padding: 20px 24px 140px; }
  .typing-indicator { margin: 0 24px 8px; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease-out);
    width: 82%;
    max-width: 320px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .main-topbar { display: flex; }
  .upgrade-tab { display: none; }
  #messages-container { padding: 16px 16px 140px; }
  .typing-indicator { margin: 0 16px 8px; }
  .composer-wrap { padding: 0 12px; bottom: 16px; }
  .message-bubble { max-width: 100%; }

  .video-drawer { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .video-drawer { transition: none; }
  .sidebar { transition: none; }
  @keyframes msgEnter { from { opacity: 1; transform: none; } }
  @keyframes dotBounce { 0%, 100% { transform: none; opacity: 0.6; } }
}
