/* =========================
   Variables globales
   ========================= */

   :root {
    --radius-xl: 24px;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-pill: 999px;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.8);
  }
  
  /* Respect global de l'attribut [hidden] */
  [hidden] {
    display: none !important;
  }
  
  /* =========================
     Thèmes
     ========================= */
  
  /* Thème sombre (par défaut) – couleurs Côte d'Ivoire */
  body.theme-dark {
    --bg-main: #020617;
    --bg-elevated: rgba(10, 16, 30, 0.96);
    --bg-elevated-soft: rgba(9, 12, 23, 0.95);
    --border-subtle: rgba(148, 163, 184, 0.32);
  
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
  
    /* Orange Côte d'Ivoire */
    --accent-orange: #f47a24;
    --accent-orange-soft: rgba(244, 122, 36, 0.15);
  
    /* Vert Côte d'Ivoire */
    --accent-green: #009e60;
    --accent-green-soft: rgba(0, 158, 96, 0.16);
  
    /* Blanc comme highlight */
    --accent-ivory: #fefcef;
  
    --danger: #f97373;
  }
  
  /* Thème clair – fond blanc, accent orange/vert */
  body.theme-light {
    --bg-main: #f3f4f6;
    --bg-elevated: #ffffff;
    --bg-elevated-soft: #ffffff;
    --border-subtle: rgba(148, 163, 184, 0.35);
  
    --text-main: #0f172a;
    --text-muted: #6b7280;
  
    --accent-orange: #f47a24;
    --accent-orange-soft: rgba(244, 122, 36, 0.09);
    --accent-green: #009e60;
    --accent-green-soft: rgba(0, 158, 96, 0.1);
    --accent-ivory: #f97316;
  
    --danger: #ef4444;
  }
  
  /* =========================
     Fond global
     ========================= */
  
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  
  html,
  body {
    height: 100%;
  }
  
  body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    color: var(--text-main);
    background: var(--bg-main);
    -webkit-font-smoothing: antialiased;
  }
  
  .global-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
  }
  
  /* Gradient différent selon le thème */
  body.theme-dark .global-bg {
    background:
      radial-gradient(circle at top left, rgba(244, 122, 36, 0.3) 0, transparent 55%),
      radial-gradient(circle at bottom right, rgba(0, 158, 96, 0.35) 0, transparent 60%),
      #020617;
  }
  
  body.theme-light .global-bg {
    background:
      radial-gradient(circle at top left, rgba(244, 122, 36, 0.2) 0, transparent 55%),
      radial-gradient(circle at bottom right, rgba(0, 158, 96, 0.25) 0, transparent 60%),
      #f3f4f6;
  }
  
  /* =========================
     Topbar
     ========================= */
  
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 2rem;
    backdrop-filter: blur(18px);
    background: linear-gradient(
      to right,
      rgba(3, 7, 18, 0.96),
      rgba(3, 7, 18, 0.9)
    );
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  }
  
  body.theme-light .topbar {
    background: linear-gradient(
      to right,
      rgba(255, 255, 255, 0.9),
      rgba(249, 250, 251, 0.95)
    );
  }
  
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
  }
  
  .brand-mark {
    display: flex;
    align-items: center;
    gap: 0.7rem;
  }
  
  .brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 16px;
    background: linear-gradient(135deg, #f47a24, #009e60);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #0b1120;
    box-shadow:
      0 0 0 1px rgba(248, 250, 252, 0.2),
      0 10px 25px rgba(15, 23, 42, 0.8);
  }
  
  .brand-text {
    display: flex;
    flex-direction: column;
  }
  
  .brand-name {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  
  .brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  .topbar-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
  }
  
  .topbar-link {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.18s ease-out;
  }
  
  .topbar-link:hover {
    color: var(--accent-ivory);
    border-color: rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.7);
  }
  
  .topbar-user {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }
  
  .badge-editor {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.7rem;
    background: rgba(34, 197, 94, 0.18);
    color: #bbf7d0;
  }
  
  .sidebar-card-disabled {
    opacity: 0.65;
  }
  
  .contrib-disabled-hint {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-muted);
  }
  
  body.theme-light .topbar-link:hover {
    background: rgba(243, 244, 246, 0.9);
  }
  
  .topbar-link-active {
    color: #0b1120;
    background: linear-gradient(135deg, #f47a24, #facc15);
    border-color: transparent;
  }
  
  /* Bouton thème */
  
  .theme-toggle {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.9);
    padding: 0.25rem 0.45rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease-out;
  }
  
  body.theme-light .theme-toggle {
    background: #ffffff;
  }
  
  .theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.5);
  }
  
  .theme-toggle-icon {
    font-size: 1.05rem;
  }
  
  /* =========================
     Layout principal (fullwidth)
     ========================= */
  
  .main-shell {
    width: 100%;
    max-width: 1440px;
    margin: 1.75rem auto 2.5rem;
    padding: 0 2rem;
  }
  
  .app-shell {
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: stretch;
  }
  
  /* =========================
     Sidebar
     ========================= */
  
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
  }
  
  .sidebar-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 1.25rem 1.3rem;
    backdrop-filter: blur(18px);
  }
  
  .app-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
  }
  
  .app-tagline {
    margin: 0.45rem 0 0.85rem;
    font-size: 0.9rem;
    color: var(--text-muted);
  }
  
  .chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  
  .chip {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    border: 1px solid transparent;
  }
  
  .chip-orange {
    background: var(--accent-orange-soft);
    border-color: rgba(244, 122, 36, 0.7);
    color: var(--accent-ivory);
  }
  
  .chip-green {
    background: var(--accent-green-soft);
    border-color: rgba(0, 158, 96, 0.7);
    color: #bbf7d0;
  }
  
  .chip-outline {
    background: transparent;
    border-color: rgba(148, 163, 184, 0.6);
    color: var(--text-main);
  }
  
  .inline-metric {
    margin-top: 0.9rem;
    padding-top: 0.85rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.45);
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
  }
  
  .metric-label {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  .metric-value {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
    font-weight: 500;
  }
  
  /* prompts */
  
  .card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
  }
  
  .card-subtitle {
    margin: 0.4rem 0 0.8rem;
    font-size: 0.85rem;
    color: var(--text-muted);
  }
  
  .prompt-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 1rem;
  }
  
  .prompt-chip {
    border-radius: 14px;
    padding: 0.45rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    font-size: 0.8rem;
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: all 0.16s ease-out;
  }
  
  body.theme-light .prompt-chip {
    background: #f9fafb;
  }
  
  .prompt-chip:hover {
    border-color: rgba(244, 122, 36, 0.8);
    background:
      radial-gradient(circle at top left, rgba(244, 122, 36, 0.14), transparent 55%);
  }
  
  .language-select {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }
  
  .language-select label {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  .language-select select {
    width: 100%;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
  }
  
  body.theme-light .language-select select {
    background: #ffffff;
  }
  
  /* suggestions */
  
  .suggestion-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.4rem;
  }
  
  .suggestion-form textarea {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    padding: 0.6rem 0.75rem;
    min-height: 90px;
    font-size: 0.85rem;
    resize: vertical;
  }
  
  body.theme-light .suggestion-form textarea {
    background: #ffffff;
  }
  
  .suggestion-form textarea::placeholder {
    color: rgba(148, 163, 184, 0.95);
  }
  
  .suggestion-footer {
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }
  
  .suggestion-footer select {
    flex: 1;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
  }
  
  body.theme-light .suggestion-footer select {
    background: #ffffff;
  }
  
  .suggestion-status {
    min-height: 1rem;
    font-size: 0.78rem;
    color: #bbf7d0;
  }
  
  /* =========================
     Boutons
     ========================= */
  
  .btn {
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.45rem 0.95rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition:
      transform 0.12s ease-out,
      box-shadow 0.12s ease-out,
      background 0.12s ease-out;
  }
  
  .btn-primary {
    background: linear-gradient(135deg, #f47a24, #facc15);
    color: #0b1120;
    box-shadow: 0 11px 30px rgba(244, 122, 36, 0.4);
    font-weight: 600;
  }
  
  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 35px rgba(244, 122, 36, 0.45);
  }
  
  .btn-ghost {
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    border: 1px solid rgba(148, 163, 184, 0.6);
  }
  
  body.theme-light .btn-ghost {
    background: #ffffff;
  }
  
  .btn-ghost:hover {
    background: rgba(15, 23, 42, 1);
    border-color: rgba(244, 122, 36, 0.9);
  }
  
  body.theme-light .btn-ghost:hover {
    background: #f9fafb;
  }
  
  .btn-icon {
    font-size: 0.9rem;
  }
  
  /* =========================
     Chat panel + onglets
     ========================= */
  
  .chat-panel {
    background: var(--bg-elevated-soft);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 1.1rem 1.1rem 1rem;
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    min-height: 540px;
    max-height: calc(100vh - 160px);
  }
  
  body.theme-light .chat-panel {
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
  }
  
  .chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.1rem 0.15rem 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  }
  
  .chat-header-main {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }
  
  .chat-header-main p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
  }
  
  .chat-header-right {
    display: flex;
    align-items: center;
  }
  
  /* Tabs */
  
  .chat-tabs {
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.96);
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    padding: 0.12rem;
  }
  
  body.theme-light .chat-tabs {
    background: #f9fafb;
  }
  
  .chat-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.25rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease-out;
  }
  
  .chat-tab-active {
    background: linear-gradient(135deg, #f47a24, #facc15);
    color: #111827;
  }
  
  /* status */
  
  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    background: rgba(0, 158, 96, 0.15);
    border: 1px solid rgba(0, 158, 96, 0.55);
    font-size: 0.78rem;
    color: #bbf7d0;
  }
  
  .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
  }
  
  /* =========================
     Vues Chat & Historique
     ========================= */
  
  .chat-views {
    margin-top: 0.75rem;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  
  .chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  
  .chat-window {
    flex: 1;
    margin-bottom: 0.8rem;
    padding: 0.75rem 0.3rem 0.75rem 0.1rem;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  
  /* scroll custom */
  .chat-window::-webkit-scrollbar {
    width: 6px;
  }
  .chat-window::-webkit-scrollbar-track {
    background: transparent;
  }
  .chat-window::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
  }
  
  /* messages */
  
  .message-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.65rem;
  }
  
  .message-row.assistant .avatar {
    background: linear-gradient(135deg, #f47a24, #009e60);
    color: #0b1120;
  }
  
  .message-row.user {
    flex-direction: row-reverse;
  }
  
  .message-row.user .avatar {
    background: rgba(255, 255, 255, 0.1);
    color: #f97316;
  }
  
  .message-row.user .bubble {
    background: linear-gradient(135deg, #f47a24, #f97316);
    color: #fff7ed;
    border-top-right-radius: 6px;
    border-top-left-radius: var(--radius-md);
  }
  
  .message-row.assistant .bubble {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(31, 41, 55, 0.9);
    border-top-left-radius: 6px;
  }
  
  body.theme-light .message-row.assistant .bubble {
    background: #f9fafb;
    border-color: rgba(209, 213, 219, 0.9);
  }
  
  .avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
  }
  
  .bubble {
    max-width: min(100%, 680px);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.75rem 0.55rem;
    font-size: 0.88rem;
    line-height: 1.45;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.7);
    position: relative;
  }
  
  body.theme-light .bubble {
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  }
  
  .message-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.15rem;
    font-size: 0.75rem;
    opacity: 0.85;
  }
  
  .message-author {
    font-weight: 500;
  }
  
  .message-time {
    font-variant-numeric: tabular-nums;
  }
  
  .message-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  
  /* typing */
  
  .typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
  }
  
  .typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.8);
    animation: typing 1.2s infinite ease-in-out;
  }
  
  .typing-dot:nth-child(2) {
    animation-delay: 0.16s;
  }
  .typing-dot:nth-child(3) {
    animation-delay: 0.32s;
  }
  
  @keyframes typing {
    0%,
    80%,
    100% {
      transform: translateY(0);
      opacity: 0.5;
    }
    40% {
      transform: translateY(-3px);
      opacity: 1;
    }
  }
  
  /* input */
  
  .chat-input-row {
    display: flex;
    gap: 0.65rem;
    align-items: flex-end;
    margin-top: auto;
  }
  
  .input-shell {
    flex: 1;
    background: rgba(15, 23, 42, 0.96);
    border-radius: 15px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    padding: 0.35rem 0.8rem;
    display: flex;
  }
  
  body.theme-light .input-shell {
    background: #ffffff;
  }
  
  .input-shell textarea {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.9rem;
    resize: none;
    width: 100%;
    max-height: 120px;
  }
  
  .input-shell textarea::placeholder {
    color: rgba(148, 163, 184, 0.9);
  }
  
  /* Historique */
  
  .history-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0;
  }
  
  .history-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr);
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
  }
  
  .history-sidebar {
    min-width: 0;
    overflow: hidden;
  }
  
  .history-conversation {
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.9);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  
  body.theme-light .history-conversation {
    background: #ffffff;
  }
  
  .history-conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  .history-conversation-messages {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    padding: 0.25rem;
    scrollbar-width: thin;
  }
  
  .history-conversation-messages::-webkit-scrollbar {
    width: 6px;
  }
  .history-conversation-messages::-webkit-scrollbar-track {
    background: transparent;
  }
  .history-conversation-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
  }
  
  .history-message-row {
    display: flex;
    margin-bottom: 0.5rem;
  }
  
  .history-bubble {
    width: 100%;
    max-width: 100%;
    border-radius: 0.6rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
    line-height: 1.4;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(30, 64, 175, 0.35);
    overflow-wrap: anywhere;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.6);
  }
  
  body.theme-light .history-bubble {
    background: #f9fafb;
    border-color: rgba(209, 213, 219, 0.9);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  }
  
  .history-message-row.assistant .history-bubble {
    border-left: 3px solid #f97316;
  }
  
  .history-message-row.user .history-bubble {
    border-left: 3px solid #22c55e;
  }
  
  .history-message-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.15rem;
    font-size: 0.75rem;
    color: var(--text-muted);
  }
  
  .history-message-author {
    font-weight: 500;
  }
  
  .history-message-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  
  @media (max-width: 1024px) {
    .history-layout {
      grid-template-columns: 1fr;
    }
  
    .history-conversation {
      margin-top: 0.75rem;
    }
  }
  
  /* =========================
     Responsive global
     ========================= */
  
  @media (max-width: 1024px) {
    .main-shell {
      padding: 0 1.25rem;
    }
  }
  
  @media (max-width: 900px) {
    .app-shell {
      grid-template-columns: minmax(0, 1fr);
    }
  
    .chat-panel {
      min-height: 480px;
      max-height: none;
    }
  
    .topbar {
      padding-inline: 1.25rem;
    }
  
    .main-shell {
      margin-top: 1.25rem;
    }
  }
  
  @media (max-width: 640px) {
    .sidebar-header-card {
      display: none;
    }
  
    .sidebar-card {
      padding: 1rem;
    }
  
    .brand-subtitle {
      display: none;
    }
  
    .theme-toggle {
      display: none;
    }
  
    .chat-panel {
      padding: 0.9rem 0.85rem 0.85rem;
    }
  
    .topbar {
      padding-inline: 1rem;
    }
  
    .main-shell {
      padding-inline: 1rem;
    }
  }
  
  /* =========================
     Mise en page spécifique pour la page de chat
     ========================= */
  
  .page-chat {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  
  /* Topbar en haut, zone principale qui occupe le reste */
  .page-chat .topbar {
    flex-shrink: 0;
  }
  
  .page-chat .main-shell {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1rem 2rem 1.5rem;
    display: flex;
    flex-direction: column;
  }
  
  /* Grille sidebar + chat sur toute la hauteur dispo */
  .page-chat .app-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: stretch;
  }
  
  /* Sidebar : colonne indépendante avec son propre scroll */
  .page-chat .sidebar {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    padding-right: 0.3rem;
  }
  
  /* Zone de chat : colonne flex qui occupe la hauteur restante */
  .page-chat .chat-panel {
    min-height: 0;
    max-height: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  /* Entête de chat fixe en haut du panel */
  .page-chat .chat-header {
    flex-shrink: 0;
  }
  
  /* Vue de chat : entre le header et la zone de saisie */
  .page-chat .chat-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  
  /* Messages scrollables, indépendants */
  .page-chat .chat-window {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 0.75rem;
  }
  
  /* Barre de saisie collée en bas de la zone de chat, pleine largeur */
  .page-chat .chat-input-row {
    flex-shrink: 0;
    width: 100%;
  }
  
  /* Agrandir confortablement la zone de saisie (hauteur par défaut plus grande) */
  .page-chat .input-shell textarea {
    min-height: 72px;
    max-height: 220px;
    line-height: 1.4;
  }
  
  /* Scrollbars pro pour la zone de chat */
  .page-chat .chat-window {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.7) transparent;
  }
  
  .page-chat .chat-window::-webkit-scrollbar {
    width: 8px;
  }
  
  .page-chat .chat-window::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 999px;
  }
  
  .page-chat .chat-window::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.85);
    border-radius: 999px;
  }
  
  .page-chat .chat-window::-webkit-scrollbar-thumb:hover {
    background: rgba(226, 232, 240, 0.95);
  }
  
  /* Scrollbars pro pour la sidebar */
  .page-chat .sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.7) transparent;
  }
  
  .page-chat .sidebar::-webkit-scrollbar {
    width: 8px;
  }
  
  .page-chat .sidebar::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .page-chat .sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.75);
    border-radius: 999px;
  }
  
  .page-chat .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(226, 232, 240, 0.95);
  }
  
  /* Sur mobile, on revient à un flux plus classique */
  @media (max-width: 900px) {
    .page-chat {
      display: block;
    }
  
    .page-chat .main-shell {
      margin: 1.75rem auto 2.5rem;
      padding: 0 1.25rem;
    }
  
    .page-chat .app-shell {
      display: block;
    }
  
    .page-chat .sidebar {
      max-height: none;
      overflow: visible;
      padding-right: 0;
      margin-bottom: 1.5rem;
    }
  
    .page-chat .chat-panel {
      height: auto;
    }
  
    .page-chat .chat-window {
      max-height: 60vh;
    }
  }
  
  /* Actions sous chaque message (copier / modifier & relancer) */
  .message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
  }
  
  .message-action-btn {
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition:
      background 0.15s ease,
      border-color 0.15s ease,
      transform 0.1s ease;
  }
  
  body.theme-light .message-action-btn {
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
  }
  
  .message-action-btn:hover {
    transform: translateY(-1px);
    background: rgba(148, 163, 184, 0.15);
    border-color: rgba(226, 232, 240, 0.9);
  }
  
  /* Logo dans la topbar */
  .brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
  }
  
  /* Logo dans le header de la sidebar */
  .sidebar-logo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 0.6rem;
  }
  
  .sidebar-logo {
    width: 64px;
    height: auto;
    border-radius: 20px;
    box-shadow:
      0 0 0 1px rgba(148, 163, 184, 0.4),
      0 12px 30px rgba(15, 23, 42, 0.75);
  }
  
  /* Centrage du texte dans la barre de saisie sur la page de chat */
  .page-chat .input-shell textarea {
    text-align: center;
  }
  
  .page-chat .input-shell textarea::placeholder {
    text-align: center;
  }
  
  /* Feedback visuel lors de la copie d'une réponse */
  .copy-feedback {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.7rem;
    color: rgba(148, 163, 184, 0.9);
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  
  .message-action-btn.copied {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.8);
    color: #bbf7d0;
  }
  
  body.theme-light .message-action-btn.copied {
    background: rgba(22, 163, 74, 0.08);
    border-color: rgba(22, 163, 74, 0.8);
    color: #166534;
  }
  
  /* État "IA en train de réfléchir" */
  .thinking-banner {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    display: none;
    align-items: center;
    gap: 0.75rem;
    background-color: #fef3c7;
    color: #92400e;
  }
  
  .thinking-banner .thinking-text {
    flex: 1;
  }
  
  .thinking-banner .thinking-stop-btn {
    border: none;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    cursor: pointer;
    background: #fee2e2;
    color: #7f1d1d;
  }
  
  textarea#message-input.is-thinking {
    opacity: 0.7;
    pointer-events: none;
  }
  
  /* === RESPONSIVE & UX MOBILE AVANCÉE === */
  
  /* Bouton hamburger (3 traits verticaux) pour la barre latérale sur mobile */
  .sidebar-toggle-mobile {
    display: none;
    position: fixed;
    top: 4rem;
    left: 1rem;
    z-index: 40;
    border: none;
    outline: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.3rem 0.45rem;
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.8);
    align-items: center;
    justify-content: center;
    gap: 3px;
  }
  
  body.theme-light .sidebar-toggle-mobile {
    background: rgba(248, 250, 252, 0.98);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.18);
  }
  
  .sidebar-toggle-mobile span {
    width: 3px;
    height: 14px;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.85);
  }
  
  body.theme-light .sidebar-toggle-mobile span {
    background: rgba(15, 23, 42, 0.85);
  }
  
  /* Overlay sombre quand la sidebar est ouverte sur mobile */
  .page-chat .sidebar-backdrop {
    display: none;
  }
  
  /* Layout mobile pour la sidebar : panneau coulissant */
  @media (max-width: 900px) {
    .page-chat .app-shell {
      position: relative;
    }
  
    .sidebar-toggle-mobile {
      display: inline-flex;
    }
  
    .page-chat .sidebar {
      position: fixed;
      top: 3.5rem;
      bottom: 0;
      left: 0;
      width: min(320px, 82vw);
      max-width: 82vw;
      background: rgba(15, 23, 42, 0.98);
      backdrop-filter: blur(18px);
      box-shadow: 0 18px 45px rgba(15, 23, 42, 0.9);
      padding-right: 0.85rem;
      padding-left: 1rem;
      transform: translateX(-105%);
      transition: transform 0.22s ease-out;
      z-index: 24;
      overflow-y: auto;
    }
  
    body.theme-light.page-chat .sidebar {
      background: rgba(248, 250, 252, 0.98);
      box-shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
    }
  
    .page-chat.sidebar-open .sidebar {
      transform: translateX(0);
    }
  
    .page-chat .sidebar-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.55);
      backdrop-filter: blur(2px);
      z-index: 20;
    }
  
    .page-chat.sidebar-open .sidebar-backdrop {
      display: block;
    }
  
    .page-chat .chat-panel {
      padding-inline: 0.9rem;
      padding-bottom: 5.2rem; /* espace pour la barre fixe */
    }
  }
  
  /* Boutons compacts et zone de saisie pleine largeur */
  .btn.icon-only {
    padding: 0.25rem;
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .btn.btn-sm {
    padding: 0.28rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 999px;
  }
  
  /* Layout vertical pour la barre de saisie */
  .page-chat .chat-input-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: stretch;
  }
  
  /* Ligne d'actions (envoyer + micro) au-dessus du textarea */
  .page-chat .chat-input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
  }
  
  /* Barre de saisie fixée en bas sur mobile, full width */
  @media (max-width: 640px) {
    .page-chat .chat-panel {
      padding-bottom: 5.2rem;
    }
  
    .page-chat .chat-window {
      max-height: none;
      height: calc(100vh - 6rem - 5.2rem);
    }
  
    .page-chat .chat-input-row {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      padding: 0.45rem 0.9rem 0.75rem;
      background: rgba(15, 23, 42, 0.98);
      border-top: 1px solid rgba(15, 23, 42, 0.9);
      z-index: 30;
    }
  
    body.theme-light.page-chat .chat-input-row {
      background: rgba(248, 250, 252, 0.99);
      border-top-color: rgba(148, 163, 184, 0.5);
    }
  }
  
  /* Boutons de conversation + nouveau chat */
  
  .btn-secondary {
    background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.98),
      rgba(15, 23, 42, 0.9)
    );
    color: var(--text-main);
    border: 1px solid rgba(148, 163, 184, 0.6);
  }
  
  body.theme-light .btn-secondary {
    background: #ffffff;
    color: #0f172a;
    border-color: rgba(148, 163, 184, 0.7);
  }
  
  .new-conversation-btn {
    width: 100%;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 0.6rem 1rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.75);
    margin-right: 5px;
  }
  
  .new-conversation-btn .new-conversation-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.96);
    font-size: 0.9rem;
  }
  
  .btn-secondary:hover {
    transform: translateY(-1px);
    background: rgb(241, 127, 34);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.85);
  }
  
  body.theme-light .new-conversation-btn .new-conversation-icon {
    background: rgba(15, 23, 42, 0.06);
  }
  
  /* Sidebar contribution */
  
  .contrib-divider {
    margin: 1rem 0 0.75rem;
    border: none;
    border-top: 1px dashed rgba(148, 163, 184, 0.35);
  }
  
  .contrib-upload-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 0.5rem;
  }
  
  .contrib-upload-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
  }
  
  .upload-dropzone {
    position: relative;
    border-radius: var(--radius-md);
    border: 1px dashed rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.9);
    padding: 0.7rem 0.8rem;
    cursor: pointer;
  }
  
  body.theme-light .upload-dropzone {
    background: #f8fafc;
  }
  
  .upload-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
  }
  
  .upload-dropzone-inner {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
  }
  
  .upload-icon {
    font-size: 1.1rem;
  }
  
  .upload-text {
    font-size: 0.8rem;
  }
  
  .upload-link {
    text-decoration: underline;
    font-weight: 500;
  }
  
  .upload-hint {
    font-size: 0.7rem;
    opacity: 0.75;
  }
  
  .contrib-label {
    font-size: 0.75rem;
    opacity: 0.85;
  }
  
  .contrib-input {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid rgba(51, 65, 85, 0.8);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-main);
    font-size: 0.8rem;
    padding: 0.4rem 0.55rem;
  }
  
  body.theme-light .contrib-input {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.5);
  }
  
  .btn-full-width {
    width: 100%;
    justify-content: center;
    margin-top: 0.4rem;
  }
  
  /* Auth */
  
  .auth-shell {
    max-width: 420px;
    margin: 2rem auto;
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.95);
  }
  
  body.theme-light .auth-shell {
    background: #ffffff;
  }
  
  .auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
  }
  
  .auth-field span {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
  }
  
  .auth-field input {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.7);
    padding: 0.45rem 0.65rem;
    background: transparent;
    color: inherit;
  }
  
  .auth-error {
    margin-top: 0.75rem;
    color: #fecaca;
    font-size: 0.9rem;
  }
  
  .auth-footer {
    margin-top: 1rem;
    font-size: 0.85rem;
    text-align: center;
  }
  
  .auth-divider {
    margin: 1.25rem 0 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    position: relative;
  }
  
  .auth-divider span {
    background: inherit;
    padding: 0 0.5rem;
    position: relative;
    z-index: 1;
  }
  
  .auth-divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(148, 163, 184, 0.4);
    z-index: 0;
  }
  
  .auth-social {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-social {
    display: block;
    width: 100%;
    text-align: center;
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.7);
    font-size: 0.9rem;
  }
  
  /* Liste des conversations – Historique */
  
  .history-header {
    margin-bottom: 0.5rem;
  }
  
  .history-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
  }
  
  .history-header p {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  .history-empty {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.55rem 0.6rem;
    border-radius: 0.75rem;
    border: 1px dashed rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.6);
  }
  
  body.theme-light .history-empty {
    background: #f9fafb;
  }
  
  .history-list {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: calc(100vh - 270px);
    overflow-y: auto;
    padding-right: 0.2rem;
    scrollbar-width: thin;
  }
  
  .history-list::-webkit-scrollbar {
    width: 5px;
  }
  
  .history-list::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .history-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
  }
  
  .history-item {
    position: relative;
    width: 100%;
    text-align: left;
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-main);
    font-size: 0.8rem;
    padding: 0.45rem 0.7rem 0.45rem 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition:
      background 0.16s ease-out,
      border-color 0.16s ease-out,
      box-shadow 0.16s ease-out,
      transform 0.1s ease-out;
  }
  
  .history-item::before {
    content: "";
    width: 4px;
    height: 70%;
    border-radius: 999px;
    background: rgba(244, 122, 36, 0.7);
    flex-shrink: 0;
  }
  
  .history-item:hover {
    border-color: rgba(244, 122, 36, 0.95);
    background: rgba(15, 23, 42, 0.98);
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.85);
  }
  
  .history-item.is-active {
    border-color: rgba(244, 122, 36, 0.95);
    background: radial-gradient(
      circle at top left,
      rgba(244, 122, 36, 0.22),
      rgba(15, 23, 42, 0.98)
    );
    box-shadow: 0 12px 30px rgba(244, 122, 36, 0.35);
  }
  
  .history-item.is-active::before {
    background: linear-gradient(135deg, #f47a24, #009e60);
  }
  
  body.theme-light .history-item {
    background: #ffffff;
    border-color: rgba(209, 213, 219, 0.9);
  }
  
  body.theme-light .history-item:hover {
    background: #fef3c7;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  }
  
  body.theme-light .history-item.is-active {
    background: linear-gradient(135deg, rgba(244, 122, 36, 0.1), #ffffff);
    border-color: rgba(244, 122, 36, 0.9);
  }
  
  /* Petit plus responsive : sur mobile, on laisse la liste prendre la hauteur nécessaire */
  @media (max-width: 900px) {
    .history-list {
      max-height: none;
    }
  }
  

  .auth-social {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  /* Bouton social – base */
  .btn-social {
    width: 100%;
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    text-decoration: none;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.96);
    color: var(--text-main);
    transition:
      transform 0.12s ease-out,
      box-shadow 0.12s ease-out,
      background 0.12s ease-out,
      border-color 0.12s ease-out;
  }
  
  body.theme-light .btn-social {
    background: #ffffff;
    color: #0f172a;
  }
  
  .btn-social:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.5);
  }
  
  /* Zone logo circulaire à gauche */
  .social-icon {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
  }
  
  /* Texte à droite du logo */
  .social-label {
    flex: 1;
    text-align: left;
  }
  
  /* ==============
     Google
     ============== */
  .btn-social-google {
    border-color: rgba(234, 67, 53, 0.8);
    background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.98),
      rgba(23, 37, 84, 0.95)
    );
  }
  
  body.theme-light .btn-social-google {
    background: #ffffff;
  }
  
  .btn-social-google:hover {
    border-color: #ea4335;
    box-shadow: 0 10px 26px rgba(234, 67, 53, 0.45);
  }
  
  .social-icon-google {
    background: #ffffff;
    color: #ea4335;
  }
  
  /* ==============
     Microsoft
     ============== */
  .btn-social-microsoft {
    border-color: rgba(38, 115, 219, 0.8);
    background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.98),
      rgba(30, 64, 175, 0.95)
    );
  }
  
  body.theme-light .btn-social-microsoft {
    background: #ffffff;
  }
  
  .btn-social-microsoft:hover {
    border-color: #2673db;
    box-shadow: 0 10px 26px rgba(38, 115, 219, 0.45);
  }
  
  .social-icon-microsoft {
    background: #ffffff;
    font-size: 0.8rem;
    color: #2563eb;
  }
  
  /* ==============
     Yahoo
     ============== */
  .btn-social-yahoo {
    border-color: rgba(94, 45, 189, 0.8);
    background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.98),
      rgba(76, 29, 149, 0.96)
    );
  }
  
  body.theme-light .btn-social-yahoo {
    background: #ffffff;
  }
  
  .btn-social-yahoo:hover {
    border-color: #5e2dbd;
    box-shadow: 0 10px 26px rgba(94, 45, 189, 0.45);
  }
  
  .social-icon-yahoo {
    background: #ffffff;
    color: #5e2dbd;
    font-size: 0.78rem;
  }
  
  /* ==============
     Apple
     ============== */
  .btn-social-apple {
    border-color: rgba(148, 163, 184, 0.9);
    background: #0f172a;
  }
  
  body.theme-light .btn-social-apple {
    background: #000000;
    color: #f9fafb;
    border-color: #000000;
  }
  
  .btn-social-apple:hover {
    border-color: #000000;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.65);
  }
  
  .social-icon-apple {
    background: #ffffff;
    color: #000000;
  }
  
  /* ==============
     Facebook
     ============== */
  .btn-social-facebook {
    border-color: rgba(24, 119, 242, 0.9);
    background: linear-gradient(
      135deg,
      #1877f2,
      #0f5edb
    );
    color: #f9fafb;
  }
  
  body.theme-light .btn-social-facebook {
    background: #1877f2;
    color: #f9fafb;
  }
  
  .btn-social-facebook:hover {
    border-color: #0f5edb;
    box-shadow: 0 10px 26px rgba(24, 119, 242, 0.55);
  }
  
  .social-icon-facebook {
    background: #ffffff;
    color: #1877f2;
    font-weight: 800;
    font-size: 0.85rem;
  }
  
  /* Responsive : sur mobile, on garde full-width mais on resserre un peu */
  @media (max-width: 480px) {
    .btn-social {
      padding: 0.4rem 0.6rem;
      font-size: 0.85rem;
    }
  
    .social-label {
      font-size: 0.82rem;
    }
  }
  

  .history-item-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .history-item-main {
    flex: 1;
    min-width: 0;
  }

  .history-item-title {
    font-weight: 600;
    font-size: 0.78rem;
    margin-bottom: 0.05rem;
  }

  .history-item-preview {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .history-item-delete {
    flex-shrink: 0;
    border-radius: 999px;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: rgba(148, 163, 184, 0.8);
    transition:
      background 0.12s ease-out,
      color 0.12s ease-out,
      transform 0.12s ease-out;
  }

  .history-item-delete:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #fecaca;
    transform: translateY(-1px);
  }

  body.theme-light .history-item-delete {
    color: #9ca3af;
  }

  body.theme-light .history-item-delete:hover {
    background: #fee2e2;
    color: #b91c1c;
  }


  .history-item-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .history-item-checkbox {
    flex-shrink: 0;
    width: 0.9rem;
    height: 0.9rem;
    accent-color: #f97316;
  }

  .history-item-main {
    flex: 1;
    min-width: 0;
  }

  .history-item-title {
    font-weight: 600;
    font-size: 0.78rem;
    margin-bottom: 0.05rem;
  }

  .history-item-preview {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .history-expiry-badge {
    margin-top: 0.25rem;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
  }

  .history-expiry-badge.danger {
    background: rgba(248, 113, 113, 0.15);
    color: #fecaca;
  }

  .history-expiry-badge.flagged {
    border: 1px solid rgba(244, 122, 36, 0.7);
  }

  .history-export-btn {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
  }


  .generated-image-wrapper {
    margin-top: 0.5rem;
    border-radius: 0.75rem;
    overflow: hidden;
    max-width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.4);
  }
  
  .generated-image {
    display: block;
    width: 100%;
    height: auto;
  }
  
  .image-caption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
  }
  
  .image-actions {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
  }
  
  .image-modify-label {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  .image-modify-input {
    flex: 1 1 auto;
    min-width: 140px;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: var(--bg-elevated);
    color: var(--text-primary);
  }
  
  .image-status {
    font-size: 0.75rem;
    color: var(--accent-warning, #f97316);
  }
  

  /* Page de chat en mode "layout flex" */
body.page-chat {
    min-height: 100vh;
  }
  
  /* La vue chat sera une colonne (messages + formulaire) */
  #chat-view {
    display: flex;
    flex-direction: column;
  }
/* Fenêtre de messages : prend la hauteur dispo et est scrollable */
#chat-window {
    flex: 1 1 auto;
    min-height: 0; /* important en flex pour que le scroll fonctionne bien */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* scroll fluide sur mobile */
  }
  
  /* Le formulaire en bas ne se réduit pas */
  #chat-form {
    flex-shrink: 0;
  }
/* --- Layout spécial mobile / petits écrans --- */
@media (max-width: 768px) {
    /* Le body de la page chat occupe toute la hauteur de l'écran */
    body.page-chat {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      background-color: var(--chat-bg, #020617);
    }
  
    /* Si ton contenu chat est dans un main, on le fait remplir l'écran */
    body.page-chat main {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
  
    /* La vue chat : colonne hauteur complète */
    #chat-view {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
  
    /* Fenêtre de messages : scrolle à l’intérieur, pas la page entière */
    #chat-window {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding-inline: 1rem;
      padding-top: 0.75rem;
      padding-bottom: 0.75rem; /* petit espace au-dessus du formulaire */
    }
  
    /* Formulaire collé visuellement au bas, avec fond et bordure */
    #chat-form {
      flex-shrink: 0;
      padding-inline: 1rem;
      padding-top: 0.5rem;
      padding-bottom: 0.75rem;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      background-color: var(--chat-bg, #020617);
    }
  }

  
  

  /* === PATCH AKWABA – Chat mobile 100vh & input fixé en bas === */
@media (max-width: 768px) {
    /* Le body de la page chat occupe tout le viewport */
    body.page-chat {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }
  
    /* Le container principal remplit l'espace entre la topbar et le bas */
    body.page-chat .main-shell {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
  
    /* L'app-shell devient une seule colonne sur mobile */
    body.page-chat .app-shell {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
  
    /* Le panel de chat occupe tout l'espace disponible */
    body.page-chat .chat-panel {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
      padding-bottom: 4.75rem; /* réserve pour la barre de saisie fixe */
    }
  
    /* La zone des vues (chat / historique) remplit le panel */
    body.page-chat .chat-views {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }
  
    /* Vue chat = messages + formulaire */
    body.page-chat #chat-view {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }
  
    /* Fenêtre de messages scrollable à l'intérieur */
    body.page-chat #chat-window {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
  
    /* Barre de saisie collée en bas de l'écran */
    body.page-chat #chat-form {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 50;
      padding: 0.45rem 0.9rem 0.75rem;
      background: rgba(15, 23, 42, 0.98);
      border-top: 1px solid rgba(15, 23, 42, 0.9);
    }
  
    body.theme-light.page-chat #chat-form {
      background: rgba(248, 250, 252, 0.99);
      border-top-color: rgba(148, 163, 184, 0.5);
    }
  }
  

  /* === PATCH FINAL AKWABA – UX mobile & chat 100vh === */

/* 1) Fixer la zone de saisie en bas + gérer le scroll proprement */
@media (max-width: 768px) {
    /* Le body de la page chat occupe tout le viewport */
    body.page-chat {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }
  
    /* Le container principal prend tout l'espace sous la topbar */
    body.page-chat .main-shell {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
      margin: 0 auto;
      padding: 0 1rem 0.75rem;
    }
  
    /* L'app-shell devient une colonne : sidebar (mobile) + chat */
    body.page-chat .app-shell {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
      gap: 0.75rem;
    }
  
    /* Panel de chat = tout l'espace restant */
    body.page-chat .chat-panel {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
      padding: 0.85rem 0.85rem 0; /* pas de padding bas : c'est le form fixe qui le gère */
      max-height: none;
    }
  
    /* Conteneur des vues */
    body.page-chat .chat-views {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
  
    /* Vue chat = messages + formulaire */
    body.page-chat #chat-view {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
  
    /* Fenêtre de messages scrollable, avec marge en bas pour ne pas passer sous le form fixe */
    body.page-chat #chat-window {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding: 0.75rem 0.1rem 5.2rem; /* 5.2rem ≈ hauteur du formulaire fixé */
    }
  
    /* Formulaire fixé en bas du viewport, plein écran */
    body.page-chat #chat-form {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 50;
      padding: 0.45rem 0.9rem 0.75rem;
      background: rgba(15, 23, 42, 0.98);
      border-top: 1px solid rgba(15, 23, 42, 0.9);
    }
  
    body.theme-light.page-chat #chat-form {
      background: rgba(248, 250, 252, 0.99);
      border-top-color: rgba(148, 163, 184, 0.5);
    }
  
    /* On garde la barre de saisie en mode colonne (que tu avais déjà) */
    body.page-chat .chat-input-row {
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      align-items: stretch;
      margin-top: 0;
    }
  
    body.page-chat .chat-input-actions {
      display: flex;
      justify-content: flex-end;
      gap: 0.35rem;
    }
  }
  
  /* 2) Allègement du header / topbar sur mobile */
  @media (max-width: 768px) {
    /* Topbar plus compacte */
    .topbar {
      padding: 0.5rem 0.75rem;
    }
  
    /* On garde uniquement le logo, on cache le texte "AKWABA IA" */
    .topbar-left .brand-text {
      display: none;
    }
  
    .topbar-left .brand-logo {
      width: 30px;
      height: 30px;
    }
  
    /* On enlève la pill "Actif" pour aérer */
    .status-pill {
      display: none;
    }
  }
  
  /* 3) Sidebar / header AKWABA allégée sur mobile */
  @media (max-width: 768px) {
    /* On peut garder le logo mais cacher le gros titre et la tagline pour ne pas surcharger */
    .sidebar-header-card .app-title,
    .sidebar-header-card .app-tagline {
      display: none;
    }
  
    .sidebar-logo-wrapper {
      margin-bottom: 0.25rem;
    }
  }
  /* Cacher le bouton de changement de thème sur mobile */
@media (max-width: 768px) {
    .theme-toggle {
      display: none !important;
    }
  }
  
  /* Mobile : cacher le logo rond dans la topbar et afficher seulement le texte "AKWABA IA" */
@media (max-width: 768px) {
    .topbar .brand-logo {
      display: none;
    }
  
    .topbar .brand-text {
      display: flex;
      flex-direction: column;
    }
  
    .topbar .brand-name {
      font-size: 1rem;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }
  
    /* On peut garder le sous-titre caché si tu veux un header compact */
    .topbar .brand-subtitle {
      display: none;
    }
  }
  
  /* Liens dans les réponses de l'IA */
.akwaba-link {
  color: #60a5fa;
  text-decoration: underline;
  word-break: break-all;
}

body.theme-light .akwaba-link {
  color: #2563eb;
}

/* Wrapper de vignette d'image trouvée sur le web */
.akwaba-image-link {
  display: inline-block;
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.45);
}

/* Thumbnail (vignette) dans la bulle */
.akwaba-image-thumb {
  display: block;
  max-width: 220px;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: cover;
}

/* Survol : léger zoom / highlight */
.akwaba-image-link:hover .akwaba-image-thumb {
  transform: scale(1.02);
}

.akwaba-image-thumb {
  transition: transform 0.15s ease-out;
}


.akwaba-image-block {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.akwaba-image-link {
  display: inline-block;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.akwaba-image-thumb {
  display: block;
  max-width: 220px;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: cover;
  transition: transform 0.15s ease-out;
}

.akwaba-image-link:hover .akwaba-image-thumb {
  transform: scale(1.02);
}

.akwaba-image-caption {
  font-size: 0.8rem;
  margin-top: 0.25rem;
  color: #94a3b8;
}

.akwaba-link {
  color: #60a5fa;
  text-decoration: underline;
  word-break: break-all;
}

body.theme-light .akwaba-link {
  color: #2563eb;
}

.akwaba-image-block.akwaba-image-error .akwaba-image-thumb {
  display: none;
}


.images-section-title {
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb; /* gris clair */
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.web-image-card {
  background-color: #0b1120; /* proche de ton thème sombre */
  border-radius: 0.75rem;
  padding: 0.5rem;
  border: 1px solid #1f2937;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.web-image-card a {
  display: block;
}

.web-image-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 0.5rem;
  display: block;
}

.web-image-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f9fafb;
}

.web-image-source {
  font-size: 0.75rem;
  color: #9ca3af;
}

.web-image-fallback-link {
  text-decoration: underline;
  font-size: 0.8rem;
}
