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

    :root {
      --blue:        #2A7FFF;
      --blue-dark:   #1a6be8;
      --blue-light:  #dceeff;
      --blue-glow:   rgba(42,127,255,.18);
      --surface:     #f4f7fb;
      --white:       #ffffff;
      --border:      #e2eaf4;
      --text:       #0D1B2E;
      --text-mid:   #4A5C72;
      --text-soft:  #8A9AB0;
      --text-main:   #1a2540;
      --text-muted:  #7a8eaa;
      --bubble-bot:  #ffffff;
      --bubble-user: #2A7FFF;
      --radius-lg:   18px;
      --radius-sm:   10px;
      --shadow-card: 0 8px 32px rgba(42,127,255,.10), 0 2px 8px rgba(0,0,0,.06);
      --shadow-btn:  0 4px 14px rgba(42,127,255,.38);
      --tr:         0.3s cubic-bezier(0.4,0,0.2,1);
    }

    html, body {
      height: 100%;
      font-family: 'Poppins', sans-serif;
      background: var(--surface);
      color: var(--text-main);
      overflow: hidden;
    }

    body::before {
      content: '';
      position: fixed; inset: 0;
      background:
        radial-gradient(ellipse 60% 40% at 10% 20%, rgba(42,127,255,.07) 0%, transparent 70%),
        radial-gradient(ellipse 50% 50% at 90% 80%, rgba(42,127,255,.05) 0%, transparent 70%);
      pointer-events: none;
      z-index: 0;
    }

    nav {
      position: fixed; top: 0; left: 0; right: 0;
      z-index: 100;
      height: 56px;
      background: rgba(255,255,255,.92);
      backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      box-shadow: 0 2px 16px rgba(42,127,255,.07);
    }

    .nav-logo {
      font-family:'Syne',sans-serif;
      font-size: 1.1rem;
      font-weight: 800;
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .nav-logo img {
      width: 32px;
      height: 32px;
      border-radius: 50%;
    }

    .nav-logo span { display: none; }

    .btn-home {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      border-radius: 50px;
      border: 1.5px solid var(--blue);
      background: transparent;
      color: var(--blue);
      font-family: 'Poppins', sans-serif;
      font-size: .75rem;
      font-weight: 600;
      cursor: pointer;
      text-decoration: none;
      transition: all .2s;
    }

    .btn-home:hover {
      background: var(--blue);
      color: #fff;
      box-shadow: var(--shadow-btn);
    }

    .page-shell {
      position: fixed;
      top: 56px;
      bottom: 0;
      left: 0;
      right: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 12px;
      z-index: 1;
    }

    .chat-card {
      width: 100%;
      max-width: 800px;
      height: calc(100vh - 84px);
      max-height: 700px;
      display: flex;
      flex-direction: column;
      background: var(--white);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-card);
      border: 1px solid var(--border);
      overflow: hidden;
    }

    .chat-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      background: linear-gradient(90deg, #f7faff, #fff);
      flex-shrink: 0;
    }

    .chat-header-left {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .avatar {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: linear-gradient(135deg, #2A7FFF, #6db8ff);
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      box-shadow: 0 3px 10px rgba(42,127,255,.25);
      position: relative;
      flex-shrink: 0;
    }

    .avatar img {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      object-fit: cover;
    }

    .avatar::after {
      content: '';
      position: absolute;
      bottom: 0;
      right: 0;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #22c55e;
      border: 2px solid #fff;
    }

    .chat-header-info h2 {
      font-size: .9rem;
      font-weight: 700;
      color: var(--text-main);
      line-height: 1.2;
    }

    .chat-header-info p {
      font-size: .65rem;
      color: var(--text-muted);
      font-weight: 400;
    }

    .btn-clear {
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 6px 12px;
      border-radius: 50px;
      border: 1.5px solid #f0d5d5;
      background: #fff5f5;
      color: #d95b5b;
      font-family: 'Poppins', sans-serif;
      font-size: .7rem;
      font-weight: 600;
      cursor: pointer;
      transition: all .2s;
    }

    .btn-clear:hover { background: #ffe5e5; }

    .messages {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      scroll-behavior: smooth;
    }

    .messages::-webkit-scrollbar { width: 4px; }
    .messages::-webkit-scrollbar-track { background: transparent; }
    .messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

    .msg-row {
      display: flex;
      align-items: flex-end;
      gap: 8px;
      animation: fadeUp .35s ease both;
    }

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

    .msg-row.user { flex-direction: row-reverse; }

    .msg-avatar {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .msg-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .avatar-img.bot {
      object-fit: cover;
    }

    .avatar-img.user {
      object-fit: cover;
      transform: scale(1.6);
    }
    .msg-row.bot .msg-avatar  { background: linear-gradient(135deg,#2A7FFF,#6db8ff); }
    .msg-row.user .msg-avatar { background: linear-gradient(135deg,#1a2540,#2d3f66); }
    .msg-row.user .msg-avatar img { width: 28px; height: 28px; border-radius: 50%; }

    .bubble {
      max-width: 75%;
      padding: 10px 14px;
      border-radius: 16px;
      font-size: .85rem;
      line-height: 1.6;
      word-break: break-word;
    }

    .bubble pre {
      background: #f0f0f0;
      padding: 8px;
      border-radius: 8px;
      overflow-x: auto;
      font-size: .75rem;
      margin: 6px 0;
    }

    .bubble code {
      background: #f0f0f0;
      padding: 2px 4px;
      border-radius: 4px;
      font-size: .85em;
    }

    .bubble ul, .bubble ol { margin: 6px 0 6px 18px; }
    .bubble strong { color: #1a2540; }

    .msg-row.bot .bubble {
      background: var(--bubble-bot);
      border: 1px solid var(--border);
      border-bottom-left-radius: 4px;
      color: var(--text-main);
      box-shadow: 0 2px 8px rgba(0,0,0,.06);
    }

    .msg-row.user .bubble {
      background: var(--bubble-user);
      border-bottom-right-radius: 4px;
      color: #fff;
      box-shadow: 0 4px 14px rgba(42,127,255,.3);
    }

    .timestamp {
      font-size: .6rem;
      margin-top: 4px;
      opacity: .55;
      text-align: right;
    }

    .msg-row.bot .timestamp  { text-align: left; color: var(--text-muted); }
    .msg-row.user .timestamp { color: rgba(255,255,255,.75); }

    .sources-badge {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--border);
    }

    .source-tag {
      padding: 2px 6px;
      border-radius: 20px;
      background: #e8f0ff;
      color: #2A7FFF;
      font-size: .6rem;
      font-weight: 500;
    }

    .typing-row {
      display: flex;
      align-items: flex-end;
      gap: 8px;
      animation: fadeUp .3s ease both;
    }

    .typing-avatar {
      width: 28px;
      height: 28px;
      flex-shrink: 0;
      border-radius: 50%;
      background: linear-gradient(135deg,#2A7FFF,#6db8ff);
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    .typing-avatar img { width: 28px; height: 28px; border-radius: 50%; }

    .typing-bubble {
      background: var(--white);
      border: 1px solid var(--border);
      border-radius: 16px;
      border-bottom-left-radius: 4px;
      padding: 10px 14px;
      display: flex;
      gap: 4px;
      align-items: center;
      box-shadow: 0 2px 8px rgba(0,0,0,.06);
    }

    .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--blue);
      animation: bounce 1.2s ease-in-out infinite;
    }

    .dot:nth-child(2) { animation-delay: .18s; }
    .dot:nth-child(3) { animation-delay: .36s; }

    @keyframes bounce {
      0%, 80%, 100% { transform: translateY(0); opacity: .5; }
      40%           { transform: translateY(-6px); opacity: 1; }
    }

    .disclaimer {
      text-align: center;
      font-size: .62rem;
      color: var(--text-muted);
      padding: 6px 16px;
      flex-shrink: 0;
      background: #fafcff;
      border-top: 1px solid var(--border);
    }

    .disclaimer span {
      background: #fff8e6;
      color: #a0620a;
      font-weight: 600;
      padding: 1px 5px;
      border-radius: 4px;
      margin-right: 4px;
      font-size: .6rem;
    }

    .input-area {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 14px;
      border-top: 1px solid var(--border);
      background: var(--white);
      flex-shrink: 0;
    }

    #msg-input {
      flex: 1;
      padding: 10px 16px;
      border: 1.5px solid var(--border);
      border-radius: 50px;
      font-family: 'Poppins', sans-serif;
      font-size: .82rem;
      color: var(--text-main);
      background: var(--surface);
      outline: none;
      transition: all .2s;
    }

    #msg-input::placeholder { color: var(--text-muted); }
    #msg-input:focus {
      border-color: var(--blue);
      box-shadow: 0 0 0 3px var(--blue-glow);
      background: #fff;
    }

    .btn-send {
      width: 40px;
      height: 40px;
      flex-shrink: 0;
      border: none;
      border-radius: 50%;
      background: linear-gradient(135deg, #2A7FFF, #1a6be8);
      color: #fff;
      font-size: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-btn);
      transition: all .18s;
    }

    .btn-send.stop-mode {
      background: linear-gradient(135deg, #d95b5b, #c53030);
      box-shadow: 0 4px 14px rgba(217,91,91,.38);
    }

    .btn-send:hover { transform: scale(1.07); box-shadow: 0 6px 20px rgba(42,127,255,.45); }
    .btn-send.stop-mode:hover { box-shadow: 0 6px 20px rgba(217,91,91,.45); }
    .btn-send:active { transform: scale(.95); }

    .status-bar {
      font-size: .65rem;
      color: var(--text-muted);
      padding: 5px 16px;
      border-bottom: 1px solid var(--border);
      background: #fafcff;
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }

    .status-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #ccc;
    }

    .status-dot.online { background: #22c55e; }

    .suggestions {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      padding: 0 16px 10px;
      flex-shrink: 0;
    }

    .pill {
      padding: 5px 12px;
      border-radius: 50px;
      border: 1.5px solid var(--blue);
      background: var(--blue-light);
      color: var(--blue);
      font-size: .7rem;
      font-weight: 600;
      cursor: pointer;
      font-family: 'Poppins', sans-serif;
      transition: all .18s;
    }

    .pill:hover {
      background: var(--blue);
      color: #fff;
      transform: translateY(-1px);
    }

    @media (max-width: 600px) {
      nav { padding: 0 12px; height: 52px; }
      .page-shell { padding: 8px; }
      .chat-card { max-height: none; height: calc(100vh - 68px); border-radius: 12px; }
      .nav-logo { font-size: .95rem; }
      .nav-logo img { width: 28px; height: 28px; }
      .btn-home span { display: none; }
      .btn-home { padding: 6px 10px; }
      .bubble { max-width: 85%; font-size: .82rem; }
      .chat-header { padding: 10px 12px; }
      .chat-header-info h2 { font-size: .82rem; }
      .avatar { width: 32px; height: 32px; }
      .avatar img { width: 32px; height: 32px; }
      .msg-avatar { width: 26px; height: 26px; }
      .msg-avatar img { width: 26px; height: 26px; }
      .typing-avatar { width: 26px; height: 26px; }
      .typing-avatar img { width: 26px; height: 26px; }
      .input-area { padding: 10px 12px; }
      .btn-clear { padding: 5px 10px; font-size: .65rem; }
      .suggestions { padding: 0 12px 8px; }
      .pill { padding: 4px 10px; font-size: .65rem; }
    }

    @media (max-width: 400px) {
      .chat-header-left { gap: 6px; }
      .avatar { width: 28px; height: 28px; }
      .avatar img { width: 28px; height: 28px; }
      .chat-header-info h2 { font-size: .78rem; }
      .chat-header-info p { font-size: .6rem; }
    }