/* ============================================================================
   IFG Chat Pro — Legal Tech Edition
   Couleurs IFG + Style élégant du Radar
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,400;500;600&display=swap');

:root {
  /* Couleurs IFG (landing page) */
  --ifg-dark: #050A14;
  --ifg-deep: #0A1628;
  --ifg-card: #111827;
  --ifg-gold: #C5A572;
  --ifg-gold-bright: #D4B896;
  --ifg-gold-dim: rgba(197, 165, 114, 0.15);
  
  /* Texte */
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-tertiary: rgba(255, 255, 255, 0.38);
  
  /* Bordures */
  --border: rgba(197, 165, 114, 0.15);
  --border-strong: rgba(197, 165, 114, 0.25);
  
  /* Typographie Legal Tech (du radar) */
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;
  
  /* Rayons */
  --radius: 8px;
  --radius-sm: 6px;
  --transition: all 0.2s ease;
  
  /* Safe areas */
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --chat-max-width: 820px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--ifg-dark);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Preserve Font Awesome icons */
.fas, .far, .fab, .fal, .fad {
  font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands' !important;
  font-weight: 900;
}

/* ============================================================================
   Header Standard (Toutes les pages)
   ============================================================================ */
.header {
  background: var(--ifg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-section {
  display: flex;
  align-items: center;
}

.logo {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--ifg-gold);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.logo img {
  height: 38px;
  display: block;
}

/* Navigation Desktop — always hidden, use burger menu */
.header-nav-desktop {
  display: none;
}

.header-nav-link {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
}

.header-nav-link:hover {
  color: var(--ifg-gold);
  background: var(--ifg-gold-dim);
}

.header-nav-link i {
  font-size: 13px;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Language Dropdown */
.lang-dropdown {
  position: relative;
}

.lang-current {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
}

.lang-dropdown:hover .lang-current {
  color: var(--ifg-gold);
  background: var(--ifg-gold-dim);
}

.lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--ifg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition);
  z-index: 200;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.lang-dropdown:hover .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-menu a {
  display: block;
  padding: 10px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.lang-menu a:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
}

/* Trial Indicator */
.trial-indicator {
  background: var(--ifg-gold-dim);
  border: 1px solid var(--ifg-gold);
  color: var(--ifg-gold);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
}

/* Burger Button — always visible */
.burger-btn {
  display: flex;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  align-items: center;
  justify-content: center;
}

.burger-btn:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
  border-color: var(--ifg-gold);
}

/* ============================================================================
   Burger Menu (Mobile)
   ============================================================================ */

.burger-menu {
  position: fixed;
  top: 0;
  right: -340px;
  left: auto;
  width: 340px;
  height: 100vh;
  background: var(--ifg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding-bottom: 40px;
}

.burger-menu:not(.hidden) {
  right: 0;
}

.burger-menu.hidden {
  display: none;
}

.menu-header {
  padding: 28px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-avatar {
  width: 48px;
  height: 48px;
  background: var(--ifg-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ifg-dark);
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.menu-user-info {
  flex: 1;
}

.menu-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  font-family: var(--font-sans);
}

.menu-email {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.menu-item:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
}

.menu-item i {
  width: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  transition: var(--transition);
}

.menu-item:hover i {
  color: var(--ifg-gold);
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 24px;
}

.menu-section-label {
  padding: 16px 24px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-sans);
}

.menu-usage-section {
  padding: 20px 24px;
  background: rgba(0,0,0,0.2);
  margin: 12px 0;
}

.menu-usage-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: var(--font-sans);
}

.menu-usage-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--ifg-gold);
  font-family: var(--font-sans);
}

.menu-lang-selector {
  padding: 8px 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-lang-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.menu-lang-select {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.9);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  padding: 0 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-sans);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ifg-gold) 50%),
    linear-gradient(135deg, var(--ifg-gold) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.menu-lang-select:focus {
  border-color: var(--ifg-gold);
  box-shadow: 0 0 0 3px rgba(197, 165, 114, 0.14);
}

.menu-logout {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 12px;
  font-family: var(--font-sans);
}

.menu-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ============================================================================
   History Panel
   ============================================================================ */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--ifg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.history-panel:not(.hidden) {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.history-panel.hidden {
  visibility: hidden;
  pointer-events: none;
}

.history-header {
  padding: 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-header h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-header h3 i {
  color: var(--ifg-gold);
  font-size: 18px;
}

.history-close {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-close:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
  border-color: var(--ifg-gold);
}

.history-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 50px;
  color: var(--text-muted);
  font-size: 15px;
  font-family: var(--font-sans);
}

/* History Item */
.history-item {
  padding: 18px 20px;
  background: var(--ifg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--ifg-gold);
  background: rgba(197, 165, 114, 0.05);
  transform: translateX(-4px);
}

.history-item-title {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.history-item-date {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

/* ============================================================================
   Export PDF Modal
   ============================================================================ */
.export-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.export-modal.hidden {
  display: none;
}

.export-modal-content {
  background: var(--ifg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.export-modal-header {
  padding: 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.export-modal-header h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 14px;
}

.export-modal-header h3 i {
  color: var(--ifg-gold);
}

.export-modal-close {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-modal-close:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
  border-color: var(--ifg-gold);
}

.export-form-group {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.export-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  font-family: var(--font-sans);
}

.export-form-group input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  background: var(--ifg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  transition: var(--transition);
}

.export-form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--ifg-gold);
  box-shadow: 0 0 0 3px rgba(197, 165, 114, 0.1);
}

.export-form-group input[type="file"] {
  color: var(--text-muted);
  font-size: 14px;
}

.export-logo-preview {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  text-align: center;
}

.export-logo-preview.hidden {
  display: none;
}

.export-logo-preview img {
  max-width: 140px;
  max-height: 70px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: contain;
}

.export-form-group img {
  max-width: 140px;
  max-height: 70px;
  margin-top: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.export-modal-actions {
  padding: 24px 28px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.export-btn {
  padding: 14px 28px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.export-btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.export-btn-secondary:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--text-muted);
}

.export-btn-primary {
  background: var(--ifg-gold);
  color: var(--ifg-dark);
}

.export-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(197, 165, 114, 0.3);
}

/* ============================================================================
   Main Chat Area
   ============================================================================ */
.messages-area,
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-container {
  width: 100%;
  max-width: 100%;
}

.chat-messages,
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 30px 24px 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Welcome Screen */
.welcome-container,
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px 40px;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 24px;
  opacity: 0.8;
}

.welcome-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 40px;
}

.welcome-screen h2 {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.welcome-screen .subtitle {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 30px;
  max-width: 740px;
}

.welcome-trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 1px solid rgba(197, 165, 114, 0.28);
  background: rgba(197, 165, 114, 0.12);
  color: var(--ifg-gold-bright);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.welcome-trial-badge i {
  font-size: 11px;
  color: var(--ifg-gold);
}

.welcome-trial-label {
  color: var(--text-primary);
  font-weight: 600;
}

.welcome-trial-sep {
  color: var(--text-muted);
  opacity: 0.8;
}

.welcome-trial-count {
  color: var(--ifg-gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.welcome-trial-unit {
  color: var(--text-secondary);
  font-weight: 500;
}

.suggested-questions {
  width: 100%;
}

.suggested-questions-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 16px;
  font-family: var(--font-sans);
}

.suggested-question-btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  background: var(--ifg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 10px;
  line-height: 1.5;
}

.suggested-question-btn:hover {
  border-color: var(--ifg-gold);
  background: var(--ifg-gold-dim);
  color: var(--text-primary);
}

/* ============================================================================
   Paywall Overlay (End of Trial)
   ============================================================================ */
.ifg-paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(110% 85% at 50% 0%, rgba(24, 43, 74, 0.34) 0%, rgba(3, 8, 18, 0.92) 62%),
    rgba(3, 8, 18, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: ifgPaywallFadeIn 0.22s ease-out;
}

.ifg-paywall-card {
  position: relative;
  width: min(760px, 100%);
  border-radius: 18px;
  padding: 30px 30px 26px;
  border: 1px solid rgba(197, 165, 114, 0.2);
  background:
    linear-gradient(180deg, rgba(26, 44, 71, 0.22) 0%, rgba(8, 15, 29, 0) 32%),
    #071226;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
  color: var(--text-primary);
  animation: ifgPaywallRise 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.ifg-paywall-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
}

.ifg-paywall-close:hover {
  border-color: rgba(197, 165, 114, 0.4);
  color: var(--ifg-gold);
  background: rgba(197, 165, 114, 0.08);
}

.ifg-paywall-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 1px solid rgba(197, 165, 114, 0.28);
  background: rgba(197, 165, 114, 0.12);
  color: var(--ifg-gold-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ifg-paywall-title {
  margin: 0 0 10px;
  text-align: left;
  font-family: var(--font-serif);
  font-size: clamp(34px, 3.7vw, 46px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.ifg-paywall-sub {
  margin: 0 0 16px;
  max-width: 620px;
  text-align: left;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.55;
}

.ifg-paywall-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.ifg-paywall-point {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(197, 165, 114, 0.22);
  background: rgba(197, 165, 114, 0.08);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.ifg-paywall-plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.ifg-paywall-plan {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
  padding: 14px 14px 12px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

.ifg-paywall-plan:hover {
  border-color: rgba(197, 165, 114, 0.5);
  background: rgba(197, 165, 114, 0.08);
  transform: translateY(-1px);
}

.ifg-paywall-plan.is-featured {
  border-color: rgba(197, 165, 114, 0.62);
  background: linear-gradient(145deg, rgba(197, 165, 114, 0.16), rgba(197, 165, 114, 0.06));
}

.ifg-paywall-plan-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #081224;
  background: var(--ifg-gold);
}

.ifg-paywall-plan-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.ifg-paywall-plan-price {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ifg-gold-bright);
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.ifg-paywall-plan-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.ifg-paywall-cta {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  text-align: center;
  text-decoration: none;
  background: var(--ifg-gold);
  color: #071226;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: var(--transition);
}

.ifg-paywall-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(197, 165, 114, 0.34);
}

.ifg-paywall-legal {
  margin: 12px 0 0;
  text-align: left;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

@keyframes ifgPaywallFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (max-width: 680px) {
  .ifg-paywall-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .ifg-paywall-card {
    width: 100%;
    border-radius: 16px;
    padding: 22px 16px 16px;
  }

  .ifg-paywall-title {
    font-size: clamp(30px, 9vw, 38px);
  }

  .ifg-paywall-sub {
    font-size: 14px;
  }

  .ifg-paywall-points {
    gap: 6px;
    margin-bottom: 14px;
  }

  .ifg-paywall-point {
    font-size: 11px;
    padding: 5px 8px;
  }

  .ifg-paywall-plans {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .ifg-paywall-plan-price {
    font-size: 27px;
  }
}

/* Messages */
.message {
  display: flex;
  gap: 16px;
  max-width: var(--chat-max-width);
  width: 100%;
  margin: 0 auto;
  align-items: flex-start;
}

.message-user,
.message.user {
  flex-direction: row-reverse;
}

.message.assistant,
.message-assistant {
  flex-direction: row;
}

.message-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.message-user .message-avatar,
.message.user .message-avatar {
  background: var(--ifg-gold);
  color: var(--ifg-dark);
}

.message-assistant .message-avatar,
.message.assistant .message-avatar {
  background: var(--ifg-card);
  border: 1px solid var(--border);
}

.message-content {
  background: var(--ifg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 26px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  max-width: 100%;
  width: 100%;
}

.message-user .message-content,
.message.user .message-content {
  background: rgba(197, 165, 114, 0.12);
  border-color: rgba(197, 165, 114, 0.3);
}

.message-content {
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.2);
}

.message-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.message-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.message-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ifg-gold);
}

.message.user .message-role {
  color: rgba(255, 255, 255, 0.75);
}

.message-timestamp {
  font-size: 12px;
  color: var(--text-tertiary);
}

.message-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.message.user .message-actions {
  display: none;
}

.message-action-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 9px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
}

.message-action-btn:hover {
  color: var(--ifg-gold);
  border-color: var(--ifg-gold);
  background: var(--ifg-gold-dim);
}

.message-body {
  font-size: 15px;
  line-height: 1.8;
}

.message-body > :last-child {
  margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  margin: 28px 0 14px;
  color: var(--text-primary);
}

.message-content h1 {
  font-size: 26px;
}

.message-content h2 {
  font-size: 22px;
}

.message-content h3 {
  font-size: 18px;
}

.message-content p {
  margin-bottom: 14px;
}

.message-content ul,
.message-content ol {
  margin: 16px 0;
  padding-left: 28px;
}

.message-content li {
  margin-bottom: 8px;
}

.message-content code {
  background: rgba(0,0,0,0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', monospace;
  font-size: 14px;
}

.message-content pre {
  background: rgba(0,0,0,0.3);
  padding: 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 18px 0;
}

.message-content blockquote {
  border-left: 3px solid var(--ifg-gold);
  padding-left: 18px;
  margin: 18px 0;
  color: var(--text-muted);
}

.answer-body.streaming-content {
  min-height: 24px;
}

.streaming-content.is-streaming::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 1.1em;
  vertical-align: -2px;
  margin-left: 4px;
  background: rgba(197, 165, 114, 0.9);
  animation: streamCaret 0.8s steps(1) infinite;
}

@keyframes streamCaret {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ifg-gold);
  opacity: 0.35;
  animation: loadingPulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes loadingPulse {
  0%, 100% { transform: translateY(0); opacity: 0.35; }
  45% { transform: translateY(-5px); opacity: 1; }
}

.loading-status {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.thinking-stream-box {
  margin-top: 8px;
  border: 1px solid rgba(197, 165, 114, 0.28);
  background: linear-gradient(180deg, rgba(197, 165, 114, 0.08), rgba(26, 41, 66, 0.2));
  border-radius: 12px;
  padding: 12px;
}

.thinking-stream-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.thinking-label {
  color: var(--ifg-gold);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.thinking-timer {
  color: var(--text-muted);
}

.search-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(197, 165, 114, 0.35);
  color: var(--ifg-gold);
  font-size: 11px;
  font-weight: 700;
}

.thinking-stream-body {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(197, 165, 114, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
}

.thinking-stream-text {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  line-height: 1.55;
}

.thinking-search-log {
  margin-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thinking-search-item {
  display: grid;
  grid-template-columns: 16px 80px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  background: rgba(17, 24, 39, 0.55);
  border: 1px solid rgba(197, 165, 114, 0.15);
  border-radius: 8px;
  padding: 7px 8px;
}

.thinking-search-item .search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-search-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #60a5fa;
  animation: searchDotPulse 1s infinite;
}

.thinking-search-item.complete .dot {
  background: #4ade80;
  animation: none;
}

.thinking-search-item.error .dot {
  background: #f87171;
  animation: none;
}

@keyframes searchDotPulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}

.search-meta {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
}

.search-query {
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-count {
  color: var(--ifg-gold);
  font-weight: 700;
  font-size: 11px;
  border: 1px solid rgba(197, 165, 114, 0.35);
  border-radius: 999px;
  padding: 1px 6px;
}

.thinking-stream-box.phase-writing {
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.35s ease;
}

/* Sources in messages */
.message-sources {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.message-sources-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ifg-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  font-family: var(--font-sans);
}

.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--text-muted);
}

.source-item i {
  color: var(--ifg-gold);
}

.source-item a {
  color: var(--ifg-gold);
  text-decoration: none;
}

.source-item a:hover {
  text-decoration: underline;
}

/* ============================================================================
   Input Area
   ============================================================================ */
.input-area {
  padding: 12px 24px 18px;
  background: linear-gradient(180deg, rgba(5,10,20,0.82), rgba(5,10,20,0.96));
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 60;
  backdrop-filter: blur(8px);
}

.input-container {
  max-width: var(--chat-max-width);
  margin: 0 auto;
  position: relative;
}

/* Admin Model Toggle */
.admin-model-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid rgba(197, 165, 114, 0.25);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.24);
}

.admin-model-label {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 8px;
  color: var(--ifg-gold);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-sans);
}

.admin-engine-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  min-width: 112px;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
  line-height: 1;
}

.admin-engine-btn:hover {
  border-color: var(--ifg-gold);
  color: var(--ifg-gold);
}

.admin-engine-btn.active {
  background: var(--ifg-gold);
  color: var(--ifg-dark);
  border-color: var(--ifg-gold);
}

/* Input Wrapper */
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--ifg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 14px 12px 12px;
  transition: var(--transition);
  min-height: 88px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}

.input-wrapper:focus-within {
  border-color: var(--ifg-gold);
  box-shadow: 0 0 0 3px rgba(197, 165, 114, 0.1);
}

/* Textarea */
.chat-input,
textarea.chat-input,
#userInput {
  width: 100%;
  background: transparent !important;
  border: none;
  color: var(--text-primary) !important;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  resize: none;
  min-height: 30px;
  max-height: 180px;
  padding: 8px 0;
  margin: 0;
  align-self: flex-end;
}

.chat-input:focus,
#userInput:focus {
  outline: none;
  background: transparent !important;
}

.chat-input::placeholder,
#userInput::placeholder {
  color: var(--text-muted);
}

/* Chat Input Buttons */
.chat-input-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 10px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
}

.chat-input-btn:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
}

.chat-input-btn svg {
  width: 24px;
  height: 24px;
}

.composer-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  padding: 0 4px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: center;
}

.composer-attach,
.composer-voice {
  border: 1px solid transparent;
}

.composer-attach:hover,
.composer-voice:hover {
  border-color: var(--border-strong);
}

/* Send button */
#sendBtn {
  width: 56px;
  height: 56px;
  min-width: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  background: var(--ifg-gold);
  color: var(--ifg-dark);
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(197,165,114,0.32);
  align-self: center;
}

#sendBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(197, 165, 114, 0.42);
}

/* Input Action Buttons (legacy) */
.input-action-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 10px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.input-action-btn:hover {
  background: var(--ifg-gold-dim);
  color: var(--ifg-gold);
}

/* Attached Files */
.attached-files {
  max-width: var(--chat-max-width);
  margin: 0 auto 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Stop Button */
.stop-btn {
  width: 56px;
  height: 56px;
  min-width: 56px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  border-radius: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 18px;
}

.stop-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ============================================================================
   Typing Indicator
   ============================================================================ */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 10px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--ifg-gold);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ============================================================================
   Language Bottom Sheet (Mobile)
   ============================================================================ */
.lang-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.lang-overlay.open {
  opacity: 1;
  visibility: visible;
}

.lang-bottom-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ifg-card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-bottom-sheet.open {
  display: block;
  transform: translateY(0);
}

.lang-bottom-sheet-title {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 20px;
  font-family: var(--font-sans);
}

.lang-bottom-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lang-bottom-sheet-grid a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--ifg-dark);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.lang-bottom-sheet-grid a:hover {
  background: var(--ifg-gold-dim);
  border-color: var(--ifg-gold);
  color: var(--ifg-gold);
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
    height: 60px;
  }
  
  .header-nav-desktop {
    display: none;
  }
  
  .burger-btn {
    display: flex;
  }
  
  .messages-area,
  .chat-messages {
    padding: 16px 12px 190px;
  }
  
  .input-area {
    padding: 10px 10px calc(10px + var(--safe-bottom));
  }

  .admin-model-toggle {
    padding: 7px 8px;
    gap: 6px;
    border-radius: 10px;
    width: 100%;
    justify-content: center;
  }

  .admin-model-label {
    height: 30px;
    padding: 0 6px;
  }

  .admin-engine-btn {
    min-width: 92px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 10px;
  }

  .welcome-title {
    font-size: 28px;
  }
  
  .welcome-subtitle {
    font-size: 15px;
  }

  .welcome-trial-badge {
    font-size: 11px;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 12px;
  }
  
  .message {
    gap: 12px;
  }
  
  .message-content {
    padding: 16px 20px;
    font-size: 14px;
  }

  .input-wrapper {
    min-height: 78px;
    border-radius: 20px;
    padding: 8px;
    gap: 8px;
  }

  #userInput {
    min-height: 28px;
    font-size: 15px;
  }

  .chat-input-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .chat-input-btn svg {
    width: 22px;
    height: 22px;
  }

  #sendBtn,
  .stop-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 15px;
  }

  #sendBtn {
    font-size: 20px;
  }

  .message-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
  }

  .message-actions {
    width: 100%;
    gap: 6px;
  }

  .message-action-btn {
    font-size: 11px;
    padding: 5px 8px;
  }

  .thinking-search-item {
    grid-template-columns: 14px 70px 1fr;
  }

  .search-result-count {
    display: none;
  }
  
  .history-panel {
    width: 100%;
    right: -100%;
  }
  
  .history-panel:not(.hidden) {
    right: 0;
  }
  
  .suggested-question-btn {
    padding: 16px 18px;
    font-size: 14px;
  }
}
