/* ============ AAP - Calipso Assurances ============ */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

:root {
  --bg: #F7F9FC;
  --bg-elev: #FFFFFF;
  --bg-sidebar: #EEF2F8;
  --bg-soft: #F2F5FA;
  --ink: #0E1A2E;             /* Logo deep navy */
  --ink-2: #2A3A55;
  --ink-3: #6A7790;
  --ink-4: #A0AABE;
  --line: #DCE3EE;
  --line-2: #C9D2E0;
  --accent: #2D6BFF;          /* Calipso cobalt blue from logo */
  --accent-2: #5A8DFF;
  --accent-soft: #E2EBFF;
  --gold: #C9A961;
  --green: #2E7D5C;
  --green-soft: #DDEDE5;
  --blue: #0E1A2E;            /* Logo navy */
  --blue-soft: #DCE5F2;
  --shadow-sm: 0 1px 2px rgba(26,25,22,0.04), 0 1px 1px rgba(26,25,22,0.02);
  --shadow-md: 0 4px 16px rgba(26,25,22,0.06), 0 1px 3px rgba(26,25,22,0.04);
  --shadow-lg: 0 20px 50px rgba(26,25,22,0.10), 0 6px 18px rgba(26,25,22,0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  overflow: hidden;
}

.serif { font-family: 'Instrument Serif', serif; font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: 'Geist Mono', monospace; font-feature-settings: "zero"; }

/* ===== App Shell ===== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  background: var(--bg);
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.sidebar-header {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.logo-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1A1916 0%, #2A2823 100%);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  padding: 5px;
}
.logo-mark img {
  width: 100%; height: auto;
  position: relative;
  z-index: 2;
  filter: brightness(1.1) drop-shadow(0 0 4px rgba(58,95,125,0.5));
  animation: miniLogoBob 3s ease-in-out infinite;
}
@keyframes miniLogoBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1px) scale(1.05); }
}
.logo-mark::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(199,93,44,0.4), transparent 60%);
  animation: orbShift 6s ease-in-out infinite;
}
@keyframes orbShift {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(20%, 15%); }
}
.logo-text { line-height: 1; }
.logo-text .brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.logo-text .brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

.new-chat-btn {
  margin: 14px;
  padding: 11px 14px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: transform 0.15s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
}
.new-chat-btn:hover { background: #2A2823; transform: translateY(-1px); }
.new-chat-btn::after {
  content: ''; position: absolute; top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s ease;
}
.new-chat-btn:hover::after { left: 100%; }

.sidebar-section {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.conv-list::-webkit-scrollbar { width: 0; }

.conv-item {
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  transition: background 0.15s ease;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}
.conv-item:hover { background: rgba(0,0,0,0.04); }
.conv-item.active {
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-weight: 500;
}
.conv-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.conv-item.active .dot { opacity: 1; }
.conv-item .conv-text { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-item .conv-time {
  font-size: 10px;
  color: var(--ink-3, #aaa);
  flex-shrink: 0;
  margin-left: auto;
}
.sidebar-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3, #bbb);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--ink));
  display: grid; place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-info { line-height: 1.2; flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 500; }
.user-info .role { font-size: 11px; color: var(--ink-3); }

/* ===== Main / Chat ===== */
.main {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.chat-header {
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(250,250,247,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
}
.chat-title-wrap { display: flex; align-items: center; gap: 12px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  position: relative;
}
.live-dot::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0.4;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50% { transform: scale(1.6); opacity: 0; }
}
.chat-title { font-size: 14px; font-weight: 500; }
.chat-title .sub { color: var(--ink-3); font-weight: 400; margin-left: 8px; font-size: 12.5px; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 9px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: all 0.15s ease;
}
.icon-btn:hover { border-color: var(--ink-3); color: var(--ink); transform: translateY(-1px); }

/* ===== Messages ===== */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
}
.messages-wrap::-webkit-scrollbar { width: 8px; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.messages {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 28px 180px;
}

/* Welcome screen */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 40px;
  text-align: center;
  animation: welcomeIn 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes welcomeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ===== Logo Calipso animé (welcome) ===== */
.logo-stage {
  position: relative;
  width: 320px !important;
  height: 160px !important;
  margin-bottom: 32px;
  display: grid;
  place-items: center;
  perspective: 1000px;
  flex-shrink: 0;
}
.logo-glow {
  position: absolute;
  inset: -40px;
  background:
    radial-gradient(ellipse at center, rgba(58, 95, 125, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 30% 60%, rgba(199, 93, 44, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 40%, rgba(201, 169, 97, 0.18) 0%, transparent 60%);
  filter: blur(24px);
  animation: logoGlow 4s ease-in-out infinite;
  z-index: 0;
}
@keyframes logoGlow {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.7; }
  33% { transform: scale(1.18) rotate(120deg); opacity: 1; }
  66% { transform: scale(1.05) rotate(240deg); opacity: 0.85; }
}
.logo-rings {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.logo-rings::before, .logo-rings::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 150px; height: 150px;
  margin: -75px 0 0 -75px;
  border-radius: 50%;
  border: 1.5px solid rgba(58, 95, 125, 0.35);
  animation: ringPulse 3s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.logo-rings::after {
  animation-delay: 1.5s;
  border-color: rgba(199, 93, 44, 0.35);
}
@keyframes ringPulse {
  0% { transform: scale(0.3); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Orbit dots around logo */
.logo-orbit {
  position: absolute;
  inset: 0;
  z-index: 1;
  animation: orbitSpin 8s linear infinite;
}
.logo-orbit.r2 { animation-duration: 11s; animation-direction: reverse; }
.logo-orbit.r3 { animation-duration: 14s; }
.logo-orbit .dot {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  top: 50%; left: 50%;
  margin: -4px;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent), 0 0 4px white;
}
.logo-orbit .dot.b { background: #3A5F7D; box-shadow: 0 0 14px #3A5F7D, 0 0 4px white; }
.logo-orbit .dot.g { background: var(--gold); box-shadow: 0 0 14px var(--gold), 0 0 4px white; }
.logo-orbit .dot.d1 { transform: translate(140px, 0); }
.logo-orbit .dot.d2 { transform: translate(-140px, 0); }
.logo-orbit.r2 .dot.d1 { transform: translate(110px, 60px); }
.logo-orbit.r2 .dot.d2 { transform: translate(-110px, -60px); }
.logo-orbit.r3 .dot.d1 { transform: translate(80px, -90px); }
.logo-orbit.r3 .dot.d2 { transform: translate(-80px, 90px); }
@keyframes orbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.welcome .logo-img {
  position: relative;
  z-index: 2;
  width: 240px !important;
  height: auto;
  filter: drop-shadow(0 14px 30px rgba(58, 95, 125, 0.45));
  animation: logoFloat 4s ease-in-out infinite !important;
  transform-style: preserve-3d;
  will-change: transform;
}
@keyframes logoFloat {
  0%   { transform: translateY(0) rotateY(0deg) rotateX(0deg) scale(1); }
  25%  { transform: translateY(-10px) rotateY(15deg) rotateX(-4deg) scale(1.04); }
  50%  { transform: translateY(-16px) rotateY(0deg) rotateX(0deg) scale(1.06); }
  75%  { transform: translateY(-10px) rotateY(-15deg) rotateX(4deg) scale(1.04); }
  100% { transform: translateY(0) rotateY(0deg) rotateX(0deg) scale(1); }
}
@keyframes logoEntrance {
  0% { opacity: 0; transform: translateY(30px) scale(0.7) rotateX(-30deg); filter: blur(16px) drop-shadow(0 14px 30px rgba(58,95,125,0.45)); }
  60% { filter: blur(0) drop-shadow(0 14px 30px rgba(58,95,125,0.45)); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateX(0); filter: blur(0) drop-shadow(0 14px 30px rgba(58,95,125,0.45)); }
}
.logo-shine {
  position: absolute;
  top: 50%; left: 50%;
  width: 70px;
  height: 100px;
  margin: -50px 0 0 -120px;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.85) 50%, transparent 70%);
  z-index: 3;
  pointer-events: none;
  mix-blend-mode: overlay;
  animation: logoShine 3.5s ease-in-out infinite;
  opacity: 0;
}
@keyframes logoShine {
  0%, 100% { transform: translateX(0); opacity: 0; }
  30% { opacity: 0; }
  50% { opacity: 1; }
  80% { transform: translateX(240px); opacity: 0; }
}

/* Light beams */
.logo-beam {
  position: absolute;
  top: 50%; left: 50%;
  width: 2px;
  height: 200px;
  margin: -100px 0 0 -1px;
  background: linear-gradient(to bottom, transparent, rgba(58,95,125,0.4), transparent);
  z-index: 0;
  transform-origin: center;
  animation: beamSpin 6s linear infinite;
  opacity: 0.6;
}
.logo-beam.b2 { animation-duration: 8s; animation-direction: reverse; background: linear-gradient(to bottom, transparent, rgba(199,93,44,0.35), transparent); }
.logo-beam.b3 { animation-duration: 10s; background: linear-gradient(to bottom, transparent, rgba(201,169,97,0.3), transparent); }
@keyframes beamSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.logo-spark {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 4px white;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}
.logo-spark.s1 { top: 18%; left: 18%; animation: sparkle 2.4s ease-in-out infinite 0.2s; }
.logo-spark.s2 { top: 64%; left: 82%; animation: sparkle 2.4s ease-in-out infinite 1.0s; background: #3A5F7D; box-shadow: 0 0 12px #3A5F7D, 0 0 4px white; }
.logo-spark.s3 { top: 30%; left: 88%; animation: sparkle 2.4s ease-in-out infinite 1.6s; }
.logo-spark.s4 { top: 70%; left: 12%; animation: sparkle 2.4s ease-in-out infinite 0.6s; background: var(--gold); box-shadow: 0 0 12px var(--gold), 0 0 4px white; }
.logo-spark.s5 { top: 8%; left: 50%; animation: sparkle 2.4s ease-in-out infinite 1.4s; background: #3A5F7D; box-shadow: 0 0 12px #3A5F7D, 0 0 4px white; }
.logo-spark.s6 { top: 90%; left: 50%; animation: sparkle 2.4s ease-in-out infinite 0.4s; }
@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.3); }
  50% { opacity: 1; transform: scale(1.5); }
}

.welcome h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 56px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  line-height: 1;
}
.welcome h1 em { font-style: italic; color: var(--accent); }
.welcome .greeting {
  color: var(--ink-3);
  font-size: 16px;
  margin: 0 0 36px;
  max-width: 460px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 240px));
  gap: 10px;
  width: 100%;
  max-width: 520px;
}
.suggestion {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  animation: suggIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.suggestion:nth-child(1) { animation-delay: 0.1s; }
.suggestion:nth-child(2) { animation-delay: 0.18s; }
.suggestion:nth-child(3) { animation-delay: 0.26s; }
.suggestion:nth-child(4) { animation-delay: 0.34s; }
@keyframes suggIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.suggestion:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.suggestion .s-label {
  font-size: 11px; font-weight: 500;
  color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.05em;
}
.suggestion .s-text { font-size: 13.5px; color: var(--ink); line-height: 1.4; }

/* Message bubbles */
.message-row {
  display: flex;
  gap: 14px;
  margin-bottom: 28px;
  animation: msgIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  margin-top: 2px;
}
.msg-avatar.user {
  background: linear-gradient(135deg, #2A2823, #1A1916);
  color: var(--bg);
}
.msg-avatar.ai {
  background:
    radial-gradient(circle at 30% 30%, #B8CFFF 0%, transparent 50%),
    linear-gradient(135deg, var(--accent), var(--ink));
  color: white;
  position: relative;
  overflow: hidden;
}
.msg-avatar.ai::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 70%, rgba(255,255,255,0.3), transparent 60%);
  animation: orbShift 3s ease-in-out infinite;
}

.msg-content { flex: 1; min-width: 0; }
.msg-name { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.msg-name .timestamp { color: var(--ink-4); font-weight: 400; margin-left: 8px; font-size: 11.5px; }

.msg-body {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
  word-wrap: break-word;
}
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { font-weight: 600; }
.msg-body ul { margin: 8px 0; padding-left: 20px; }
.msg-body li { margin-bottom: 4px; }
.msg-body code {
  font-family: 'Geist Mono', monospace;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid var(--line);
}

/* Streaming caret */
.caret {
  display: inline-block;
  width: 8px; height: 16px;
  background: var(--accent);
  vertical-align: -3px;
  margin-left: 2px;
  animation: caret 0.9s steps(2) infinite;
  border-radius: 1px;
}
@keyframes caret { 50% { opacity: 0; } }

/* Thinking indicator */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-3);
  animation: msgIn 0.4s ease;
}
.thinking-dots { display: flex; gap: 4px; }
.thinking-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinkPulse 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkPulse {
  0%, 60%, 100% { transform: scale(0.7); opacity: 0.4; }
  30% { transform: scale(1.2); opacity: 1; }
}
.thinking-shimmer {
  background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink) 50%, var(--ink-3) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2s linear infinite;
  font-weight: 500;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Tool calls */
.tool-call {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  overflow: hidden;
  animation: toolIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  transition: box-shadow 0.2s ease;
}
.tool-call:hover { box-shadow: var(--shadow-sm); }
@keyframes toolIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.tool-header {
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.tool-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.tool-icon.crm { background: var(--blue-soft); color: var(--blue); }
.tool-icon.calc { background: var(--green-soft); color: var(--green); }
.tool-icon.search { background: #F4EAD8; color: #8A6A20; }
.tool-call.running .tool-icon::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
  opacity: 0.5;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tool-name { font-weight: 500; flex: 1; }
.tool-status { font-size: 11.5px; color: var(--ink-3); }
.tool-status.done { color: var(--green); }
.tool-chevron {
  color: var(--ink-4);
  transition: transform 0.2s ease;
}
.tool-call.expanded .tool-chevron { transform: rotate(90deg); }

.tool-body {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  padding: 12px 14px;
  color: var(--ink-2);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
}
.tool-call.expanded .tool-body {
  max-height: 360px;
  padding: 12px 14px;
  border-top-width: 1px;
  overflow-y: auto;
}
.tool-line { margin: 2px 0; display: flex; gap: 10px; }
.tool-line .k { color: var(--accent); min-width: 80px; }
.tool-line .v { color: var(--ink); }

.tool-progress {
  height: 2px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.tool-call.running .tool-progress::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  width: 40%;
  animation: progressSlide 1.2s ease-in-out infinite;
}
@keyframes progressSlide {
  from { left: -40%; }
  to { left: 100%; }
}

/* Result cards inside AI message */
.result-card {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--bg-elev);
  animation: toolIn 0.5s ease;
}
.result-card .rc-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 8px;
}
.rc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rc-stat .label { font-size: 11.5px; color: var(--ink-3); }
.rc-stat .value { font-size: 22px; font-family: 'Instrument Serif', serif; color: var(--ink); }
.rc-stat .value .unit { font-size: 12px; color: var(--ink-3); margin-left: 4px; font-family: 'Geist'; }

.lead-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.lead-row:last-child { border-bottom: 0; }
.lead-row .lead-name { flex: 1; font-weight: 500; }
.lead-row .lead-co { color: var(--ink-3); font-size: 12px; }
.lead-row .lead-score {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 500;
}
.lead-row .lead-score.warm { background: #F8E8D0; color: #A06820; }
.lead-row .lead-score.cold { background: var(--bg-soft); color: var(--ink-3); }

/* ===== Composer ===== */
.composer-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px 28px 24px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  z-index: 4;
  pointer-events: none;
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.composer.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(199,93,44,0.08), var(--shadow-md);
}
.composer::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(120deg, transparent, var(--accent), transparent);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.composer.streaming::before {
  opacity: 1;
  animation: borderRotate 3s linear infinite;
}
@keyframes borderRotate {
  from { background: conic-gradient(from 0deg, transparent, var(--accent), transparent 30%); }
  to { background: conic-gradient(from 360deg, transparent, var(--accent), transparent 30%); }
}

.composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  padding: 6px 4px;
  min-height: 24px;
  max-height: 200px;
}
.composer textarea::placeholder { color: var(--ink-4); }
.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  margin-top: 4px;
}
.composer-tools { display: flex; gap: 4px; }
.composer-icon-btn {
  width: 30px; height: 30px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  border-radius: 7px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.15s ease;
}
.composer-icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.send-btn {
  width: 32px; height: 32px;
  border: none;
  border-radius: 9px;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s ease;
}
.send-btn:disabled { background: var(--line-2); cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: var(--accent); transform: translateY(-1px) scale(1.05); }
.send-btn.stop { background: var(--accent); }
.send-btn.stop:hover { background: #A04A20; }

.composer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 10px;
}
.composer-hint kbd {
  font-family: 'Geist Mono', monospace;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  margin: 0 2px;
}

/* Floating particles in welcome */
.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.particle {
  position: absolute;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.15;
  animation: floatUp 12s linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(110vh) translateX(0) scale(0.5); opacity: 0; }
  10% { opacity: 0.2; }
  90% { opacity: 0.2; }
  to { transform: translateY(-10vh) translateX(40px) scale(1); opacity: 0; }
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 500;
}
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }

/* Scroll fade */
.fade-top {
  position: absolute;
  top: 57px; left: 0; right: 0; height: 24px;
  background: linear-gradient(to bottom, var(--bg), transparent);
  pointer-events: none;
  z-index: 3;
}

/* Devis quote table */
.quote-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.quote-table th, .quote-table td {
  text-align: left;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.quote-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.quote-table td.num { text-align: right; font-family: 'Geist Mono', monospace; }
.quote-table tfoot td { border-bottom: 0; font-weight: 600; padding-top: 12px; }
.quote-total { font-family: 'Instrument Serif', serif; font-size: 22px; }

/* Sources */
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.source-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.source-pill .num {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 600;
}


/* ============ ISSUE TRACKER DRAWER ============ */
.issues-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px 6px 9px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.2s ease;
}
.issues-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.issues-toggle.has-items {
  background: linear-gradient(135deg, var(--accent), #1A4FE0);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(45, 107, 255, 0.3);
}
.issues-toggle .badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.25);
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
}
.issues-toggle:not(.has-items) .badge {
  background: var(--bg-soft);
  color: var(--ink-3);
}

.issues-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 26, 46, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.issues-overlay.open { opacity: 1; pointer-events: auto; }

.issues-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(14, 26, 46, 0.15);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.issues-drawer.open { transform: translateX(0); }

.issues-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.issues-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(45, 107, 255, 0.08), transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(14, 26, 46, 0.04), transparent 50%);
  pointer-events: none;
}
.issues-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.issues-title {
  font-family: 'Instrument Serif', serif;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.1;
}
.issues-title em { color: var(--accent); font-style: italic; }
.issues-subtitle {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 4px;
  position: relative;
}
.issues-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-3);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s ease;
}
.issues-close:hover { color: var(--ink); border-color: var(--ink-3); transform: rotate(90deg); }

.issues-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px 22px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.istat {
  text-align: center;
  padding: 4px 4px;
  border-right: 1px solid var(--line);
}
.istat:last-child { border-right: 0; }
.istat .v {
  font-family: 'Instrument Serif', serif;
  font-size: 24px;
  color: var(--ink);
  line-height: 1;
}
.istat .v.crit { color: #C53030; }
.istat .v.warn { color: #B7791F; }
.istat .v.minor { color: var(--accent); }
.istat .v.ok { color: var(--green); }
.istat .l {
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
  font-weight: 500;
}

.issues-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 100px;
  position: relative;
}
.issues-list::-webkit-scrollbar { width: 6px; }
.issues-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.issue-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 10px;
  margin-bottom: 10px;
  position: relative;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  animation: issueIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes issueIn {
  from { opacity: 0; transform: translateX(20px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
.issue-card:hover {
  border-color: var(--line-2);
  box-shadow: 0 6px 20px rgba(14, 26, 46, 0.07);
  transform: translateY(-1px);
}
.issue-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  border-radius: 12px 0 0 12px;
  background: var(--accent);
}
.issue-card.severity-critical::before { background: #C53030; }
.issue-card.severity-warning::before { background: #B7791F; }
.issue-card.severity-minor::before { background: var(--accent); }
.issue-card.resolved { opacity: 0.55; }
.issue-card.resolved .issue-title-text { text-decoration: line-through; }

.issue-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.severity-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.severity-chip.critical { background: #FED7D7; color: #C53030; }
.severity-chip.warning { background: #FAF089; color: #975A16; }
.severity-chip.minor { background: var(--accent-soft); color: var(--accent); }
.severity-chip .pulse-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
}
.severity-chip.critical .pulse-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  animation: pulse 1.5s ease-out infinite;
}
.cat-chip {
  font-size: 10px;
  color: var(--ink-3);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.issue-time {
  font-size: 10.5px;
  color: var(--ink-4);
  font-family: 'Geist Mono', monospace;
  margin-left: auto;
}

.issue-title-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.35;
}
.issue-desc {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
}
.issue-quote {
  font-size: 11.5px;
  color: var(--ink-3);
  font-style: italic;
  padding: 7px 10px;
  background: var(--bg-soft);
  border-radius: 6px;
  border-left: 2px solid var(--line-2);
  margin-bottom: 8px;
  line-height: 1.45;
  max-height: 50px;
  overflow: hidden;
  position: relative;
}
.issue-quote::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 14px;
  background: linear-gradient(to bottom, transparent, var(--bg-soft));
}

.issue-actions {
  display: flex;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  margin-top: 6px;
}
.iact {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  border-radius: 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.iact:hover { background: var(--bg-soft); color: var(--ink); }
.iact.resolve:hover { background: #E3F4EA; color: var(--green); }
.iact.delete:hover { background: #FED7D7; color: #C53030; }

.issue-add-fab-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px 22px 18px;
  background: linear-gradient(to top, var(--bg-elev) 60%, transparent);
  z-index: 3;
  pointer-events: none;
}
.issue-add-fab {
  width: 100%;
  padding: 13px;
  background: var(--ink);
  color: var(--bg-elev);
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(14, 26, 46, 0.18);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
}
.issue-add-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.issue-add-fab:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(45, 107, 255, 0.35);
}
.issue-add-fab:hover::before { transform: translateX(100%); }

.issue-form {
  background: linear-gradient(180deg, var(--bg-soft), var(--bg-elev));
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  animation: formIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 8px 24px rgba(45, 107, 255, 0.12);
}
@keyframes formIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.issue-form-title {
  font-family: 'Instrument Serif', serif;
  font-size: 20px;
  margin: 0 0 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.field { margin-bottom: 10px; }
.field-label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 5px;
}
.field-input, .field-textarea, .field-select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
.field-textarea { min-height: 70px; resize: vertical; line-height: 1.5; }
.field-input:focus, .field-textarea:focus, .field-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 107, 255, 0.12);
}

.severity-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.sev-pick {
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-elev);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.sev-pick:hover { border-color: var(--ink-3); color: var(--ink-2); }
.sev-pick.active.critical { background: #FED7D7; color: #C53030; border-color: #C53030; }
.sev-pick.active.warning { background: #FAF089; color: #975A16; border-color: #B7791F; }
.sev-pick.active.minor { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.sev-pick .pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.btn-secondary {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-secondary:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-primary {
  flex: 1;
  padding: 9px 14px;
  border: none;
  background: var(--ink);
  color: var(--bg-elev);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--line-2); cursor: not-allowed; }

.issues-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
}
.issues-empty .ico {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: grid; place-items: center;
  margin: 0 auto 14px;
  color: var(--ink-4);
  animation: emptyFloat 3s ease-in-out infinite;
}
@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.issues-empty h3 {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 6px;
  font-weight: 400;
}
.issues-empty p {
  font-size: 13px;
  margin: 0 auto;
  max-width: 280px;
  line-height: 1.5;
}

.flag-btn {
  margin-top: 10px;
  padding: 5px 10px 5px 8px;
  border: 1px dashed var(--line-2);
  background: transparent;
  color: var(--ink-3);
  border-radius: 7px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  opacity: 0.7;
}
.flag-btn:hover {
  opacity: 1;
  border-color: #C53030;
  border-style: solid;
  color: #C53030;
  background: #FFF5F5;
  transform: translateY(-1px);
}
.flag-btn.flagged {
  opacity: 1;
  border-color: #C53030;
  border-style: solid;
  color: #C53030;
  background: #FED7D7;
}
.flag-btn.flagged svg { animation: flagBounce 0.5s ease; }
@keyframes flagBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}
