
    :root {
      --navy: #104996;
      --blue: #326da7;
      --yellow: #f3e500;
      --green: #96c11e;
      --sky: #20b3e7;
      --pink: #de2885;
      --orange: #eb6418;
      --ink: #121826;
      --line: #d8e1ee;
      --soft: #f7f9fc;
      --panel: rgba(255, 255, 255, 0.94);
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      height: 100%;
      overflow: hidden;
    }

    body {
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--ink);
      margin: 0;
      background:
        radial-gradient(circle at 12% 10%, rgba(32, 179, 231, 0.18), transparent 30%),
        radial-gradient(circle at 88% 0%, rgba(243, 229, 0, 0.14), transparent 28%),
        linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%);
    }

    body::after {
      content: none;
    }

    .neo {
      border: 1px solid rgba(216, 225, 238, 0.95);
      box-shadow: 0 24px 70px rgba(16, 73, 150, 0.16);
      border-radius: 22px;
    }

    .neo-sm {
      border: 1px solid rgba(216, 225, 238, 0.95);
      box-shadow: 0 12px 32px rgba(16, 73, 150, 0.10);
      border-radius: 18px;
    }

    .scanline {
      height: 3px;
      border: 0 !important;
      background: linear-gradient(90deg, var(--green), var(--sky), var(--yellow));
    }

    .app-shell {
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      padding: clamp(0.75rem, 1.6vw, 1.5rem);
      display: grid;
      place-items: center;
      transition: filter 0.35s ease, transform 0.35s ease;
    }

    .chat-frame {
      width: min(1320px, 100%);
      height: 100%;
      min-height: 0;
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
      overflow: hidden;
      background: var(--panel);
      border: 1px solid rgba(216, 225, 238, 0.92);
      border-radius: 28px;
      box-shadow: 0 32px 90px rgba(16, 73, 150, 0.18);
      backdrop-filter: blur(18px);
    }

    .chat-header {
      min-height: 0;
      border-bottom: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.88);
      backdrop-filter: blur(14px);
    }

    .header-inner {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: clamp(0.6rem, 1.4vw, 1rem);
      padding: clamp(0.75rem, 1.3vw, 1rem) clamp(1rem, 1.9vw, 1.45rem);
    }

    .brand-wrap {
      min-width: 0;
      display: flex;
      align-items: center;
      gap: clamp(0.65rem, 1.5vw, 1rem);
    }

    .brand-card {
      flex: 0 0 auto;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: white;
      padding: clamp(0.35rem, 0.8vw, 0.5rem) clamp(0.45rem, 0.9vw, 0.7rem);
      box-shadow: 0 10px 28px rgba(16, 73, 150, 0.10);
    }

    .brand-logo {
      display: block;
      width: auto;
      height: clamp(2rem, 4.2vw, 3.15rem);
    }

    .brand-title {
      margin: 0;
      color: var(--navy);
      font-size: clamp(1.05rem, 2.25vw, 1.7rem);
      line-height: 1.05;
      font-weight: 850;
      letter-spacing: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .brand-subtitle {
      margin-top: 0.35rem;
      color: #64748b;
      font-size: clamp(0.68rem, 1.25vw, 0.95rem);
      line-height: 1.05;
      font-weight: 780;
      text-transform: uppercase;
      letter-spacing: 0;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 0.55rem;
    }

    .status-pill,
    .source-pill,
    .user-pill,
    .logout-button {
      min-height: 2.25rem;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: #fff;
      padding: 0.35rem 0.9rem;
      color: var(--ink);
      font-size: clamp(0.68rem, 0.95vw, 0.8rem);
      font-weight: 800;
      text-transform: uppercase;
      white-space: nowrap;
    }

    .logout-button {
      background: #f1f5f9;
      color: var(--navy);
      cursor: pointer;
      transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
    }

    .logout-button:hover {
      transform: translateY(-1px);
      background: var(--navy);
      color: #fff;
      box-shadow: 0 12px 24px rgba(16, 73, 150, 0.18);
    }

    #adminButton {
      background: #fff;
    }

    .source-pill {
      display: none;
    }

    .user-pill {
      max-width: 18rem;
      overflow: hidden;
      text-overflow: ellipsis;
      text-transform: none;
    }

    .chat-main {
      min-height: 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      border-bottom: 1px solid var(--line);
      background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.94), rgba(241, 245, 249, 0.98)),
        radial-gradient(circle at top right, rgba(32, 179, 231, 0.10), transparent 38%);
    }

    .message {
      max-width: min(930px, 92%);
      white-space: pre-wrap;
      overflow-wrap: anywhere;
    }

    .messages {
      min-height: 0;
      overflow-y: auto;
      scroll-behavior: auto;
    }

    .welcome-card {
      max-width: min(1120px, 92%);
      width: min(1120px, 100%);
      min-height: clamp(9rem, 24vh, 13rem);
      margin-inline: auto;
      display: flex;
      flex-direction: column;
      justify-content: center;
      background:
        linear-gradient(135deg, #fff 0 74%, rgba(32, 179, 231, 0.08)),
        #fff;
    }

    .welcome-card p {
      margin: 0;
    }

    .welcome-kicker {
      display: inline-flex;
      width: fit-content;
      border: 1px solid rgba(16, 73, 150, 0.14);
      border-radius: 999px;
      background: rgba(243, 229, 0, 0.22);
      padding: 0.28rem 0.7rem;
      color: var(--navy);
      font-size: 0.72rem;
      font-weight: 850;
      text-transform: uppercase;
    }

    .composer {
      min-height: 0;
      background: rgba(255, 255, 255, 0.92);
      padding: clamp(0.65rem, 1.2vw, 0.95rem) clamp(0.8rem, 1.7vw, 1.25rem);
    }

    .composer-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 7.4rem;
      gap: 0.65rem;
      align-items: stretch;
    }

    .composer textarea {
      height: clamp(3.15rem, 7vh, 4.05rem);
      min-height: 3rem;
      max-height: 5.8rem;
      resize: none;
      border: 1px solid #cbd5e1 !important;
      border-radius: 18px !important;
      background: #fff !important;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 8px 24px rgba(15, 23, 42, 0.05);
      font-weight: 650;
    }

    .composer textarea:focus,
    #loginForm input:focus {
      border-color: rgba(16, 73, 150, 0.38) !important;
      box-shadow: 0 0 0 4px rgba(16, 73, 150, 0.08), 0 10px 28px rgba(16, 73, 150, 0.08) !important;
      background: #fff !important;
    }

    .composer button {
      height: auto;
      min-height: 3rem;
      border: 0 !important;
      border-radius: 18px !important;
      box-shadow: 0 16px 30px rgba(16, 73, 150, 0.24) !important;
      font-weight: 850;
    }

    body.locked .app-shell {
      filter: blur(8px);
      pointer-events: none;
      transform: scale(0.985);
      user-select: none;
    }

    body.unlocked #loginOverlay {
      opacity: 0;
      pointer-events: none;
      transform: translateY(-8px);
    }

    #loginOverlay {
      background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.66), rgba(226, 232, 240, 0.70)) !important;
      backdrop-filter: blur(18px);
    }

    #loginForm {
      overflow: hidden;
      border: 1px solid rgba(216, 225, 238, 0.95) !important;
      border-radius: 26px !important;
      background: rgba(255, 255, 255, 0.96) !important;
      box-shadow: 0 34px 90px rgba(16, 73, 150, 0.22) !important;
    }

    #loginForm > div:first-child {
      background: #fff !important;
      border-bottom: 1px solid var(--line) !important;
    }

    #loginForm > div:first-child > div {
      width: fit-content;
      border: 1px solid var(--line) !important;
      border-radius: 16px !important;
      box-shadow: 0 12px 30px rgba(16, 73, 150, 0.10) !important;
    }

    #loginForm h2 {
      font-size: 2rem !important;
      font-weight: 850 !important;
    }

    #loginForm input {
      border: 1px solid #cbd5e1 !important;
      border-radius: 16px !important;
      background: #fff !important;
      font-weight: 650 !important;
    }

    #loginForm button[type="submit"] {
      border: 0 !important;
      border-radius: 16px !important;
      box-shadow: 0 18px 36px rgba(16, 73, 150, 0.22) !important;
      font-weight: 850 !important;
    }

    .messages::-webkit-scrollbar {
      width: 8px;
    }

    .messages::-webkit-scrollbar-track {
      background: transparent;
    }

    .messages::-webkit-scrollbar-thumb {
      background: rgba(50, 109, 167, 0.34);
      border: 2px solid transparent;
      border-radius: 999px;
    }

    .messages article.message:not(.welcome-card) {
      border: 1px solid var(--line) !important;
      border-radius: 18px !important;
      box-shadow: 0 14px 36px rgba(16, 73, 150, 0.10) !important;
    }

    .messages article.message.ml-auto {
      border: 0 !important;
      border-radius: 20px 20px 6px 20px !important;
      box-shadow: 0 16px 34px rgba(16, 73, 150, 0.22) !important;
      background: linear-gradient(135deg, var(--navy), var(--blue)) !important;
    }

    .messages article.message:not(.ml-auto):not(.welcome-card) {
      background: #fff !important;
      border-radius: 20px 20px 20px 6px !important;
    }

    .message a {
      color: var(--navy);
      font-weight: 750;
      text-decoration: underline;
      text-decoration-thickness: 2px;
      text-underline-offset: 3px;
      word-break: break-word;
    }

    .message strong {
      color: #0f172a;
      font-weight: 850;
    }

    .source-details {
      margin-top: 0.85rem;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: #f8fafc;
      overflow: hidden;
    }

    .source-details summary {
      cursor: pointer;
      list-style: none;
      padding: 0.85rem 1rem;
      color: var(--navy);
      font-size: 0.82rem;
      font-weight: 850;
      text-transform: uppercase;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
    }

    .source-details summary::-webkit-details-marker {
      display: none;
    }

    .source-details summary::after {
      content: "Afficher";
      color: #64748b;
      font-size: 0.72rem;
      font-weight: 750;
      text-transform: none;
    }

    .source-details[open] summary {
      border-bottom: 1px solid var(--line);
      background: #fff;
    }

    .source-details[open] summary::after {
      content: "Masquer";
    }

    .source-content {
      padding: 0.65rem 1rem 0.9rem;
    }

    .admin-panel {
      display: none;
      min-height: 0;
      height: 100%;
      overflow-y: auto;
      padding: clamp(0.8rem, 1.6vw, 1.4rem);
    }

    body.admin-mode #messages {
      display: none;
    }

    body.admin-mode #adminPanel {
      display: block;
    }

    body.admin-mode #chatForm {
      display: none;
    }

    .admin-hero,
    .admin-card,
    .admin-table-card {
      border: 1px solid var(--line);
      border-radius: 20px;
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 16px 38px rgba(16, 73, 150, 0.10);
    }

    .admin-hero {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 1rem;
      align-items: center;
      padding: clamp(1rem, 2vw, 1.35rem);
    }

    .admin-grid {
      display: grid;
      gap: 0.85rem;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      margin-top: 0.9rem;
    }

    .admin-card {
      padding: 1rem;
      min-height: 8rem;
    }

    .admin-card-label {
      color: #64748b;
      font-size: 0.72rem;
      font-weight: 850;
      text-transform: uppercase;
    }

    .admin-card-value {
      margin-top: 0.45rem;
      color: var(--navy);
      font-size: clamp(1.55rem, 3vw, 2.25rem);
      font-weight: 900;
      line-height: 1;
    }

    .admin-card-foot {
      margin-top: 0.55rem;
      color: #475569;
      font-size: 0.78rem;
      font-weight: 700;
      line-height: 1.35;
    }

    .admin-sections {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.9rem;
      margin-top: 0.9rem;
    }

    .admin-table-card {
      min-height: 18rem;
      overflow: hidden;
    }

    .admin-table-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      border-bottom: 1px solid var(--line);
      padding: 0.85rem 1rem;
      color: var(--navy);
      font-size: 0.84rem;
      font-weight: 900;
      text-transform: uppercase;
    }

    .admin-list {
      display: grid;
      gap: 0;
    }

    .admin-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 0.8rem;
      align-items: center;
      border-bottom: 1px solid #edf2f7;
      padding: 0.75rem 1rem;
    }

    .admin-row:last-child {
      border-bottom: 0;
    }

    .admin-row-main {
      min-width: 0;
      color: #1e293b;
      font-size: 0.88rem;
      font-weight: 750;
      line-height: 1.4;
      overflow-wrap: anywhere;
    }

    .admin-row-meta {
      margin-top: 0.18rem;
      color: #64748b;
      font-size: 0.72rem;
      font-weight: 700;
    }

    .admin-count {
      min-width: 2.25rem;
      border-radius: 999px;
      background: rgba(16, 73, 150, 0.10);
      color: var(--navy);
      padding: 0.3rem 0.55rem;
      text-align: center;
      font-size: 0.78rem;
      font-weight: 900;
    }

    .admin-bars {
      padding: 0.85rem 1rem 1rem;
    }

    .admin-bar-row {
      margin-bottom: 0.75rem;
    }

    .admin-bar-label {
      display: flex;
      justify-content: space-between;
      gap: 0.75rem;
      color: #334155;
      font-size: 0.78rem;
      font-weight: 800;
    }

    .admin-bar-track {
      height: 0.56rem;
      margin-top: 0.32rem;
      overflow: hidden;
      border-radius: 999px;
      background: #e2e8f0;
    }

    .admin-bar-fill {
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, var(--navy), var(--sky));
    }

    .admin-empty {
      padding: 1rem;
      color: #64748b;
      font-size: 0.86rem;
      font-weight: 750;
    }

    .typing span {
      animation: blink 1s infinite;
    }

    .typing span:nth-child(2) {
      animation-delay: 0.15s;
    }

    .typing span:nth-child(3) {
      animation-delay: 0.3s;
    }

    @keyframes blink {
      0%, 80%, 100% { opacity: 0.25; }
      40% { opacity: 1; }
    }

    @media (max-width: 900px) {
      .app-shell {
        padding: 0;
      }

      .chat-frame {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
      }

      .header-inner {
        grid-template-columns: minmax(0, 1fr);
      }

      .header-actions {
        justify-content: space-between;
      }

      .source-pill,
      .user-pill {
        display: none;
      }

      .status-pill,
      .logout-button {
        flex: 1 1 0;
        min-width: 0;
      }

      .admin-grid,
      .admin-sections {
        grid-template-columns: minmax(0, 1fr);
      }

      .admin-hero {
        grid-template-columns: minmax(0, 1fr);
      }
    }

    @media (max-width: 760px) {
      body {
        background-attachment: scroll;
      }

      .neo {
        box-shadow: none;
        border-radius: 0;
      }

      .message {
        max-width: 100%;
      }

      .composer-grid {
        grid-template-columns: minmax(0, 1fr) 5.9rem;
        gap: 0.45rem;
      }

      .composer button {
        min-height: 3rem;
        padding-inline: 0.65rem;
      }
    }

    @media (max-width: 480px) {
      .header-inner {
        gap: 0.45rem;
        padding: 0.45rem 0.6rem;
      }

      .brand-logo {
        height: 1.8rem;
      }

      .brand-title {
        font-size: 0.96rem;
        line-height: 1.1;
      }

      .brand-subtitle {
        font-size: 0.64rem;
        line-height: 1.15;
      }

      .status-pill,
      .user-pill,
      .logout-button {
        min-height: 2rem;
        padding: 0.28rem 0.62rem;
        font-size: 0.66rem;
      }

      .messages {
        padding: 0.65rem;
      }

      .welcome-card {
        padding: 0.75rem;
        min-height: 0;
      }

      .welcome-card .leading-7 {
        line-height: 1.45;
      }

      .welcome-kicker {
        display: none;
      }

      .composer {
        padding: 0.35rem 0.45rem calc(0.35rem + env(safe-area-inset-bottom));
      }

      .composer textarea {
        height: 3rem;
        min-height: 3rem;
        padding-block: 0.7rem;
      }
    }
  