
  body { font-family: Arial, sans-serif; background-color: #f0f2f5; margin:5px; }
  .chat-container {
    max-width: 96%; margin: 0 auto;
    background: #fff; border-radius: 4px; display: flex; flex-direction: column;
    height: 85vh; position: relative;
    border: 1.5px solid rgba(39,133,201,0.5);
  }
  @media (min-width: 992px) {.chat-container {height: 90vh;}}
  .login_button { display:flex; flex-direction:row;justify-content: space-between; width: 98%; margin-bottom: 5px; margin: 2px auto;}
   @media (min-width: 992px) {.login_button  {width: 100%;}}
   @media (max-width: 420px) {.login_button  {font-size: 14px;}}   
  #chat-box { flex: 1; overflow-y: auto; padding: 20px; border-bottom: 1px solid #ddd; }
  .input-container { display: flex; flex-direction: column; align-items: center; padding: 5px; background: rgba(39,133,201,0.15); border-top: 1.5px solid rgba(39,133,201,0.5); }

  /* Presearch block (search + load + matching) */
  .presearch-controls { width: 100%; max-width: 800px; display:flex; flex-direction:column; align-items:center; }
  .input { width: 99%; display: flex; flex-direction: row; align-items: center; margin-bottom: 30px;}
  .presearch-actions { display:flex; flex-direction: column; gap:8px; align-items:center; justify-content:center; flex-wrap: wrap;}

  /* Source switch */
  .source-switch { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 6px; background: #fff; width: 300px; max-width: 98%; justify-content: center; }
   @media (max-width: 420px) {.source-switch  {width: 220px;}}

  .source-switch .opt { display: flex; flex-direction: column; align-items: center; font-weight:600; color:#006798; font-size:14px; }
  .source-switch .opt-count { display: block; font-size: 10px; font-weight: 600; opacity: 0.75; margin-top: 2px; }
  .source-switch .opt.muted { opacity:.8; }
  .source-switch .paywall-hint { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:#006798; opacity:.6; }
  .source-switch .paywall-hint svg{ width:16px; height:16px; }
  .switcher { position:relative; width:48px; height:24px; cursor: pointer; }
  .switcher input { position:absolute; opacity:0; width:0; height:0; }
  .switcher .slider {
    position:absolute; inset:0; border:1.5px solid rgba(39,133,201,0.6); border-radius:999px;
    background:rgba(39,133,201,0.12); transition:all .2s;
  }
  .switcher .slider:before {
    content:""; position:absolute; height:18px; width:18px; left:0px; top:50%; transform:translateY(-50%);
    background:#fff; border:1.5px solid rgba(39,133,201,0.6); border-radius:50%; transition:all .2s;
  }
  .switcher input:checked + .slider { background:rgba(39,133,201,0.36); }
  .switcher input:checked + .slider:before { transform:translate(24px, -50%); }
  .source-switch[aria-disabled="true"] { opacity:.9; cursor:not-allowed; }

  /* Postsearch controls */
  .toggle-container { display: flex; flex-direction: column; width: 96%; max-width: 800px; }
  .toggle1 { display: flex; flex-direction: row; align-items: stretch; justify-content: center; margin-bottom: 8px;margin-top: 8px; gap:8px; }
  .toggle2 { display: flex; flex-direction: row; align-items: stretch; justify-content: center; gap:8px; flex-wrap: wrap;}

  #user-input { flex: 2; padding: 12px; border: 1.5px solid rgba(39,133,201,0.5); border-radius: 4px; font-size:16px; background: rgba(39,133,201,0.15); color:#006798; width:150px; }
  @media (max-width: 380px) {#user-input  {font-size: 14px;}}  
  #user-input::placeholder { color: #006798; opacity: 0.75; }

  #send-btn { display:inline-flex; align-items:center; gap:3px; padding: 13px 13px 13px 9px; background: rgba(39,133,201,0.1); border: 1.5px solid rgba(39,133,201,0.4); border-radius: 4px; color: #006798; cursor: pointer; font-weight: bold; font-size:16px; box-shadow: inset 0 -1em 1em rgba(39,133,201,0.5);overflow: hidden;}
  @media (max-width: 380px) {#send-btn {font-size: 14px;}}  
  #send-btn:hover { opacity: 0.8; }
  #send-btn svg {width: 18px; height: 18px; fill: currentColor;}

  #end-session { padding: 8px 8px; background: #ffd4d4; border: 1.5px solid #ff8787; border-radius: 4px; color: #b30000; cursor: pointer; font-weight: bold; font-size:14px; }
  #end-session:hover { opacity: 0.8; }

  #next-page-btn { padding: 8px 8px; background: #e7f7ec; border: 1.5px solid #34a853; border-radius: 4px; color: #1e7a3b; cursor: pointer; font-weight: bold; font-size:14px; display:none; }
  #next-page-btn:hover { background:#d8f2e0; }

  #craft-paper-btn { padding: 8px 8px; background: rgba(39, 133, 201, 0.3); border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #006798; cursor: pointer; font-weight: bold; font-size:14px; display:none; }
  #craft-paper-btn:hover { background: rgba(39,133,201,0.4); }

  #save-file-btn, #verify-pin-btn, #send-magic-btn { padding: 8px 8px;  background: rgba(39,133,201,0.1); border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #006798; cursor: pointer; font-weight: bold; font-size:14px; }
  #load-file-btn  { padding: 8px 8px;  background: white; border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #006798; cursor: pointer;font-size:14px; margin: 5px; }
  @media (max-width: 728px) {#load-file-btn {margin: 15px;}}
  
  #save-file-btn:hover, #load-file-btn:hover, #verify-pin-btn:hover, #send-magic-btn:hover { background: rgba(39,133,201,0.2); }


  #pwa-install  { padding: 3px 5px;  background: white; border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #006798; cursor: pointer;font-size:14px; position: absolute; right: 60px; top: 12px;}
  @media (max-width: 420px) {#pwa-install {right: 45px;}}
  @media (max-width: 380px) {#pwa-install {right: 38px; font-size:90%;}}  
  #pwa-install:hover { background: rgba(39,133,201,0.2); }


  #send-offline-btn {background:#a4f7d5;  border:1.5px solid #0c7d4e;color:#0c7d4e; font-weight: bold;}

  #auto-run-btn{
    padding:8px 8px;
    background:#d7ffef;
    border:1.5px solid #0c7d4e;
    border-radius:4px;
    color:#0c7d4e;
    cursor:pointer;
    font-weight:bold;
    font-size:14px;
    display:none;
  }
  #auto-run-btn:hover{ background:#d6efe6; }
  #auto-run-btn.active{
    background:#0c7d4e;
    border-color:#0c7d4e;
    color:#fff;
  }

  .toggle-btn { background: transparent; border: 1.5px solid rgba(39,133,201,0.6); border-radius: 4px; cursor: pointer; font-size: 14px; transition: background-color 0.3s; display: inline-flex; align-items: center; color: rgb(0 103 152 / 100%);}
  .toggle-btn:hover { opacity: 0.8; }
  .toggle-btn.active { background: rgba(39,133,201,0.4); border: 1.5px solid rgba(39,133,201,0.6); color: #006798; font-weight: bold; }

  .toggle-btn .lock { width:20px; height:20px; margin-right:8px; display:inline-block; }
  .toggle-btn .lock svg { width:20px; height:20px; display:block; }
  .toggle-btn .lock.unlocked { display:none; }
  #crossref-toggle.premium-active .lock.locked { display:none; }
  #crossref-toggle.premium-active .lock.unlocked { display:inline-block; }
  #crossref-toggle.info-only { cursor: default; }

  .bot-message { margin: 10px 0; padding: 12px 16px; border-radius: 20px; max-width:70%; word-wrap: break-word; }
  .user-message { display: none; }
  .bot-message  { background: #f1f0f0; color: #333; text-align: left; }
  .bot-message.error { background: #ffe6e6; color: #cc0000; }

  .pubmed-snippet { background-color: #e9f9ff; color: #005875; padding:10px; border-left:5px solid #0a8ec6; border-radius:8px; margin-bottom: 5px; }
  #spinner { display: none; position: absolute; bottom:50%; left:50%; transform: translateX(-50%); font-size:18px; font-weight: bold; color:#007bff; animation:blink 1.5s infinite; background: rgba(39,133,201,0.4); padding: 75px 15px 75px 15px; border-radius: 50px; text-align: center;}
  @keyframes blink { 0% { opacity:1; } 50% { opacity:0.5; } 100% { opacity:1; }}

  /* Focus ring */
  #next-page-btn, #craft-paper-btn, #auto-run-btn, #save-file-btn, #load-file-btn, #end-session, #send-offline-btn, #send-btn { outline: none; }
  #next-page-btn:focus, #craft-paper-btn:focus, #auto-run-btn:focus, #save-file-btn:focus, #load-file-btn:focus, #end-session:focus, #send-offline-btn:focus, #send-btn:focus { box-shadow: 0 0 0 3px rgba(11, 87, 208, .25); }

  #load-file-input {display: none!important;}
  a { color: #63a4ff; } a:hover { text-decoration: underline; color: #337ab7; }
  .modal-card { color:#006798; }

  /* Hero */
  .chat-container.presearch { position: relative; height: auto;}
  .chat-container.presearch #chat-box { display: none; }
  .chat-container.presearch .input-container { background: transparent; border-top: none; box-shadow: none; min-height:85vh; display:flex; justify-content : center;}
  @media (max-width: 920px) {.chat-container.presearch .presearch-controls  {margin-top: 20%;}}  
  .chat-container.presearch .toggle-container { display: none; }
  .chat-container.presearch .presearch-controls { display:flex; }
  @media (min-width: 920px) {.chat-container.presearch .presearch-controls {overflow-y: scroll; scrollbar-width: none;}}  
  .chat-container.postsearch .presearch-controls { display:none; }
  .chat-container.postsearch .toggle-container { display:flex; }
  .hero { display:none; text-align:center; color:#006798; padding:18px 12px 8px; }
  .presearch .hero { display:block; }
  @media (max-width: 640px) {.presearch .hero  {font-size: 95%;}} 
  @media (max-width: 380px) {.presearch .hero  {font-size: 90%;}} 
  .hero h2 { margin:0 0 6px; font-size:20px; font-weight:700; letter-spacing:.2px; }
  .hero .sub { margin:0 0 10px; opacity:.9; font-size: 80%;}

  /* Link Card (DOI unfurl) */
  .link-card { display:flex; gap:10px; align-items:flex-start; border:1px solid rgba(39,133,201,.35); border-radius:10px; padding:10px; margin:8px 0; background:#f8fcff; color:#0b3a53; }
  .link-card .thumb { flex:0 0 72px; width:72px; height:72px; border-radius:8px; overflow:hidden; background:#e6f3fb; }
  .link-card .thumb img { width:100%; height:100%; object-fit:cover; display:block; }
  .link-card .meta { flex:1 1 auto; min-width:0; }
  .link-card .meta .t { font-weight:700; font-size:14px; margin:0 0 4px; }
  .link-card .meta .d { font-size:13px; opacity:.9; margin:0 0 6px; }
  .link-card .meta .f { font-size:12px; opacity:.8; display:flex; gap:8px; flex-wrap:wrap; }
  .link-card .meta a { color:#006798; text-decoration:none; }
  .link-card .meta a:hover { text-decoration:underline; }
  .link-card.skeleton { animation:pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 0%{opacity:.6} 50%{opacity:1} 100%{opacity:.6} }

  /* Sticky query banner */
  #chat-box .query-banner {
    position: sticky; top: -20px; z-index: 5;
    margin: -20px -20px 10px -20px; padding: 10px 10px;
    background: #e9f6ff; border-bottom: 1px solid rgba(39,133,201,.35);
    color: #006798; font-weight: 600; display: none; text-align: left; border-radius: 9px 9px 0 0;
  }
  #chat-box .query-banner .qb-row { display:flex; align-items:center; gap:8px; flex-wrap: nowrap; }
  #chat-box .query-banner .label{ opacity:.8; margin-right:2px; font-weight:700; font-size: 13px; }
  #chat-box .query-banner .q{ font-weight:700; max-width: 60ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #chat-box .query-banner .clear{ margin-left:auto; font-weight:600; cursor:pointer; opacity:.7; border: 1px solid rgba(39,133,201,.35); padding:2px 6px; border-radius:999px; }
  #chat-box .query-banner .clear:hover{ opacity:1; }
  #chat-box .query-banner .bar { margin-top:6px; height:6px; border-radius:999px; background: rgba(39,133,201,.2); overflow:hidden; }
  #chat-box .query-banner .bar > span{ display:block; height:100%; width:0%; background: linear-gradient(90deg, rgba(39,133,201,.85), rgba(39,133,201,.55)); transition: width .3s ease; }
  #chat-box .query-banner .snippet{ margin-top:8px; font-weight:500; font-size: 12px; color:#0b4b6d; }
  #chat-box .query-banner .snippet details summary { cursor:pointer; }

  .query-banner .qb-stats span { font-weight: 600; font-size: 12px; opacity: 0.95; }
  @media (max-width: 768px) { .query-banner .qb-stats span { font-size: 10px !important; font-weight: 500 !important; } }
  .query-banner .q { max-width: calc(100% - 120px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .query-banner .clear { cursor: pointer; font-weight: bold; }
  .qb-scope { font-size: 10px; }

  .looks-disabled { opacity:.45; filter:grayscale(30%); }
  .looks-disabled:hover { opacity:.6; }

  /* Modal (moved out of inline) */
/* was: .modal-backdrop / .modal-card */
#craft-confirm-modal { /* backdrop */
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#craft-confirm-modal .ccm-card {
  background: #fff;
  color: #111;
  max-width: 460px;
  width: 92%;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  overflow: hidden;
  font-family: inherit;
}
#craft-confirm-modal .ccm-header { padding:16px 18px; border-bottom:1px solid #e5e7eb; font-weight:700; font-size:16px; display:flex; justify-content:space-between; align-items:center; }
#craft-confirm-modal .ccm-body   { padding:16px 18px; line-height:1.45; }
#craft-confirm-modal .ccm-body .msg { margin-bottom:8px; }
#craft-confirm-modal .ccm-body .hint { font-size:13px; color:#555; }
#craft-confirm-modal .ccm-footer { padding:12px 18px; display:flex; gap:8px; justify-content:flex-end; border-top:1px solid #e5e7eb; }

/* Buttons */
#ccm-continue { padding: 8px 8px;  background: rgba(39,133,201,0.4); border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #006798; font-weight: bold; cursor: pointer;font-size:14px;}
#ccm-craft    { padding: 8px 8px;  background: #111827;              border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #fff;     cursor: pointer;font-size:14px;}
#ccm-cancel   { padding: 8px 8px;  background: #fff;                  border: 1.5px solid rgba(39, 133, 201, 0.6); border-radius: 4px; color: #006798; cursor: pointer;font-size:14px;}
.bot-message.plan-notice { border-left: 4px solid #f59e0b; background: #fff7ed; }
.plan-notice .pn-cta { margin-top: 8px; }
.upgrade-cta.btn.btn-primary {display:inline-block; text-decoration:none; font-weight:600; color:#fff;}
.upgrade-cta.btn.btn-primary:hover {opacity: 0.8;}
a.btn.btn-primary:hover {opacity: 0.8;color:#fff;}

        #matching-panel[hidden] { display: none; }
        .chat-container.postsearch #toggle-matching { display: none; }

        .matching-pop { position: relative; width: fit-content; margin: 15px auto; }
        #toggle-matching { padding:6px 14px; border-radius:4px; width: 140px; justify-content: center; }

        #matching-panel {
          position: absolute;
          width: 130px;
          z-index: 1000;
          max-height: 60vh;
          overflow: auto;
          background: #fff;
          box-shadow: 0 10px 30px rgba(0,0,0,.15);
          border: 1.5px solid rgba(39,133,201,0.6);
          border-radius: 4px;
          padding: 3px;
          display: block;
          color: #006798;
          font-size: 14px;
        }
        #matching-panel label { display:flex; align-items:center; gap:6px; padding:6px 8px; border-radius:6px; cursor:pointer; }
        #matching-panel label:hover { background: rgba(39,133,201,.08); }
        #matching-panel .badge { padding:2px 8px;border-radius:999px;border: 1px solid rgba(39,133,201,.35); font-size: 12px;line-height: 1.6; }

        /* Advanced settings container */
        .advanced-settings{
          width: fit-content;
          max-width: min(980px, calc(100vw - 24px));
          margin: 8px auto 0;
          padding: 10px 12px;
          border-radius: 14px;
          border: 1px solid rgba(11, 95, 255, .22);
          background: rgba(255,255,255,.75);
          backdrop-filter: blur(6px);
          margin-top: 0px;
        }

#advanced-settings{
  transition: opacity .12s ease;
}

#advanced-settings[hidden]{
  display: block !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}


        /* Hide in postsearch */
        .chat-container.postsearch #advanced-toggle,
        .chat-container.postsearch #advanced-settings{
          display:none !important;
        }




/*---------------------description-------------------*/
  .description {
    color: #006798;
    font-size: 12px;
    margin: 1px auto;
    text-align: center;
  }
  @media (min-width: 920px) { .description {position: absolute;top: -40px;
    right: 30%;} }
  @media (max-width: 380px) { .description { font-size: 11px;} }
  /* Shared modal styles */
  .modal {
    display: none;
    z-index: 1000;
    inset: 0;
    color: #333;
  }

  .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 16px;
    border-radius: 10px;
    max-width: 96%;
    width: 720px;
    text-align: left;
    box-shadow: 0px 0px 4px 22224px rgba(0, 0, 0, 0.5);
    border: 1.5px solid rgba(39, 133, 201, 0.5);
  }
  @media (min-width: 1200px) {
    .modal-content { padding: 36px; }
  }
  /* Make the About modal vertically scrollable */
  #about-modal .modal-content,
  #guide-modal .modal-content,
  #changes-modal .modal-content,
  #contact-modal .modal-content {
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #contact-modal .modal-content {
    top: 40%;
  }


  .modal-content h3 {
    margin: 18px 0px 3px 0px;
    font-size: 18px;
    color: #0b5cab;
  }
  .modal-content p { margin: 8px 0; color: #333; line-height: 1.3; }
  .modal-content ul, .modal-content ol { margin: 8px 0 8px 18px; }
  .modal-content li { margin: 6px 0; }
  .modal-content small { color: #555; }

  /* Optional: consistent image presentation */
  .guide-step { margin-top: 20px !important; padding: 6px 10px; border-radius: 4px; border: 1px solid rgba(39, 133, 201, 0.25); background: rgba(39, 133, 201, 0.08); }
  .guide-step figure { margin: 8px 0; }
  .guide-step img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.08);
  }
  .guide-step figcaption {
    font-size: 12px;
    color: #555;
    margin-top: 4px;
  }

  .close {
    color: #fff;
    background: #006798;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    text-align: center;
    line-height: 28px;
    font-size: 20px;
    font-weight: bold;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    outline: none;
  }
  .close:hover { background: #ff0000; }

  @media (max-width: 480px) {
    .modal-content {
      width: 92%;
      max-width: 92%;
    }
  }

  body.modal-open {
    overflow: hidden;
    touch-action: auto;
  }

  @media (min-width: 920px) {
    .version { font-size: 10px; }
  }

  /* Social icons */
  .social-links a {
    margin: 0 6px;
    font-size: 22px;
    color: #006798;
    transition: color 0.2s ease-in-out;
  }
  .social-links a:hover { color: #ff6600; }
  

#contact-modal  {
    top: -40%;
    max-width: 98%;
}
  @media (max-width: 920px) {
    #contact-modal { top: -60%; }
  }
  
/* Contact form inside modal */
#contact-modal form {
  margin-top: 10px;
}

#contact-modal .form-group {
  margin-bottom: 15px;
}

#contact-modal label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  font-size: 14px;
}

#contact-modal input[type="email"],
#contact-modal textarea {
  width: 100%;
  padding: 10px;
  border: 1.5px solid rgba(39, 133, 201, 0.5);
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 14px;
  background-color: rgba(39, 133, 201, 0.1);
  color: #006798;
}

#contact-modal input[type="email"]::placeholder,
#contact-modal textarea::placeholder {
  color: rgba(39, 133, 201, 0.6);
}

#contact-modal textarea {
  resize: vertical;
  min-height: 120px;
}

#contact-modal .submit-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background-color: rgba(39, 133, 201, 0.3);
  border: 1.5px solid rgba(39, 133, 201, 0.5);
  border-radius: 5px;
  color: #006798;
  font-size: 15px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

#contact-modal .submit-btn:hover {
  opacity: 0.8;
}

#contact-modal #feedback {
  margin-top: 12px;
  text-align: center;
  font-weight: bold;
  color: #006798;
}
.sessions-toolbar {
  display:flex;
  gap:8px;
  align-items:center;
  margin:8px 0 10px;
}
.sessions-toolbar .btn {
  padding:6px 10px;
  border:1px solid #ccc;
  border-radius:8px;
  background:#fff;
  color:#333;
  cursor:pointer;
  text-decoration:none;
  font-size:14px;
}
.sessions-toolbar .btn:hover {
  border-color:#2785c9;
  color:#2785c9;
}
#cb {
  color:#006798;
}

.auth-badge.auth-badge-expired,
#auth-badge.auth-badge-expired{
    background: rgba(198, 40, 40, 0.14) !important;
    border-color: #c62828 !important;
    color: #c62828 !important;
}

#auth-manage-sub{
    background: rgba(39, 133, 201, 0.06);
}

/* About video */
#about .about-video-wrap{
  margin: 12px 0 18px;
  border: 1px solid rgba(39,133,201,0.25);
  background: rgba(39,133,201,0.05);
  border-radius: 10px;
  padding: 10px;
}
#about .about-video{
  width: 100%;
  height: auto;
  max-height: 52vh;
  display: block;
  border-radius: 8px;
  background: #000;
}
#about .about-video-cap{
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.8;
  color: #006798;
  text-align: center;
  font-weight: 600;
}
#about .about-video-links{
  text-align:center;
  margin-top: 6px;
  font-weight: 700;
}


/* ===== Desktop layout: sidebar auth-menu (>=920px) ===== */
@media (min-width: 920px){
  body.logged-in{
    /* JS will set --topbar-h and --auth-sidebar-w; these are fallbacks */
    --topbar-h: 58px;
    --auth-sidebar-w: 400px;
    --auth-sidebar-gap: 16px;
  }

  /* Make the opened auth-menu a fixed left sidebar */
  body.logged-in .auth-menu{
    position: fixed !important;
    left: 5px;                 /* matches body margin:5px */
    right: auto !important;
    top: calc(var(--topbar-h) + 6px);
    width: var(--auth-sidebar-w) !important;
    height: calc(100vh - var(--topbar-h) - 12px);
    z-index: 9600;
  }

  /* Chat takes the remaining width to the right of the sidebar */
  body.logged-in .chat-container{
    max-width: none !important;
    width: calc(100% - var(--auth-sidebar-w) - var(--auth-sidebar-gap) - 10px) !important; /* -10px = body margins */
    margin-left: calc(var(--auth-sidebar-w) + var(--auth-sidebar-gap)) !important;
    margin-right: 0 !important;
    height: calc(100vh - var(--topbar-h) - 12px) !important;
  }

  /* Your presearch overrides set height:auto; re-pin it on desktop */
  body.logged-in .chat-container.presearch{
    height: calc(100vh - var(--topbar-h) - 12px) !important;
  }
  body.logged-in .chat-container.presearch .input-container{
    min-height: calc(100vh - var(--topbar-h) - 12px) !important;
  }

  /* Optional: since it’s always open, hide the caret */
  body.logged-in .auth-badge .caret{ display:none; }
}



/*----ACCOUNT BUTTON-----------------------/
/* ===== Scoped styles ===== */
.btn-login,.btn-logout{
  padding:10px 8px;
  background:rgba(39,133,201,0.1);
  border:1.5px solid rgba(39,133,201,0.6);
  border-radius:4px;
  color:#006798;
  cursor:pointer;
  font-weight:bold;
  font-size:14px;
  text-decoration:none;
  margin-left: 3px;
}
@media (min-width: 768px) {.btn-login {margin-left: 15px;}}
@media (min-width: 992px) {.btn-login {margin-left: 25px;}}
@media (min-width: 1200px) {.btn-login {margin-left: 30px;}}
@media (min-width: 1650px) {.btn-login {margin-left: 35px;}}
@media (min-width: 1800px) {.btn-login {margin-left: 40px;}}
@media (max-width: 380px) {.btn-login {font-size: 90%;}}
.btn-login:hover,.btn-logout:hover{background:rgba(39,133,201,0.2);text-decoration:none;}
.auth-cta{display:flex;gap:10px;align-items:center;justify-content:flex-end;max-width:98%;}

/* Badge as dropdown trigger */
.auth-dropdown{position:relative;display:inline-block;} /* wrapper width == badge width */
.auth-badge{
  font-size:15px;
  color:#006798;
  background:#e9f6ff;
  border:1.5px solid rgba(39,133,201,0.6);
  padding:8px 10px;
  border-radius:4px;
  text-align:center;
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
  max-width:62vw;
  overflow:hidden;
  text-overflow:ellipsis;
  margin-left:3px;
  width: 250px;
}
.auth-badge:focus{outline:2px solid rgba(39,133,201,.35);outline-offset:2px;}
@media (min-width: 768px) {.auth-badge {width: 350px;}}
@media (min-width: 920px) {.auth-badge {width: 400px;}}

/* Caret bigger + rotation */
.auth-badge .caret{
  display:inline-block;
  margin-left:8px;
  opacity:.85;
  font-size:16px;
  line-height:1;
  transform-origin:center;
  transition:transform .15s ease;
  transform:scale(1.8);
}
.auth-dropdown.open .auth-badge .caret{transform:scale(1.8) rotate(180deg);}

/* Expired (index.php toggles .auth-badge-expired) */
.auth-badge-expired{
  background:#ffe9e9 !important;
  border-color:#f1a3a3 !important;
  color:#b00020 !important;
}

/* Dropdown menu (same width as badge) */
.auth-menu{
  position:absolute;
  right:0;
  top:calc(100% + 4px);
  width:100%;
  box-sizing:border-box;
  background:#fff;
  border:1px solid rgba(39,133,201,.35);
  border-radius:4px;
  box-shadow:0 12px 40px rgba(0,0,0,.18);
  padding:10px;
  display:none;
  z-index:9500;

  /* fill to bottom, scroll inside */
  flex-direction:column;
  overflow:hidden;
  gap:8px;
}
.auth-menu.open{display:flex;}

.auth-menu .row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:6px 4px;
}
.auth-menu .label{font-size:12px;opacity:.75}
.auth-menu .value{font-size:12px;font-weight:700; opacity:0.5;}

.plan-active{color:#006798;}
.plan-expired{color:#b00020;}
.plan-unknown{opacity:.75}

.auth-menu a{
  display:block;
  padding:8px 10px;
  border-radius:10px;
  text-decoration:none;
  font-weight:700;
  font-size:13px;
  color:#006798;
}
.auth-menu a:hover{opacity:0.85;}

/* "danger" style (used for Subscribe ONLY when expired) */
.auth-menu a.danger{
  color:#b00020;
  background:rgba(176,0,32,0.06);
  border-color:rgba(176,0,32,0.18);
}

/* ===== Runs list (My papers) ===== */
.runs-box{
  margin-top:8px;
  padding-top:8px;
  border-top:1px solid rgba(39,133,201,.18);
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  min-height:140px;
}
.runs-title{font-size:12px;opacity:.75;margin:2px 0 6px; color: #006798;}
.runs-list{
  flex:1 1 auto;
  max-height:none;
  overflow:auto;
}
.runs-empty{font-size:12px;opacity:.75;padding:6px 4px;}

/* ✅ runs search bar */
.runs-search{
  display:flex;
  align-items:center;
  margin:6px 0 8px;
}
.runs-search-input{
  flex:1;
  min-width:0;
  height:32px;
  padding:6px 10px;
  border-radius:10px 3px 3px 10px;
  border:1px solid rgba(39,133,201,0.25);
  background:#fff;
  color:#006798;
  font-size:12px;
  outline:none;
}
.runs-search-input:focus{
  border-color:rgba(39,133,201,0.55);
  box-shadow:0 0 0 2px rgba(39,133,201,0.18);
}
.runs-search-input::placeholder { color: #006798; opacity: 0.75; }

.runs-search-btn{
  width:42px;
  height:45px;
  border-radius:3px 10px 10px 3px;
  border:1px solid rgba(39,133,201,0.25);
  background:rgba(39,133,201,0.06);
  color:#006798;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.runs-search-btn:hover{
  background:rgba(39,133,201,0.12);
}

/* ONE container per row: blue for crafted, grey for in-progress */
.run-row{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:6px;
  padding:6px 10px;
  border-radius:12px;
  background:rgba(39,133,201,0.06);
  border:1px solid rgba(39,133,201,0.18);
}
.run-row:hover{background:rgba(39,133,201,0.12);}

.run-row.run-inprogress{
  background:rgba(17,24,39,0.04);
  border-color:rgba(17,24,39,0.10);
}
.run-row.run-inprogress:hover{background:rgba(17,24,39,0.06);}

/* link is just text (no inner pill) */
.run-link{
  flex:1;
  min-width:0;
  display:block;
  text-decoration:none;
  font-weight:800;
  font-size:12px;
  color:#006798;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.run-row.run-inprogress .run-link{color:#6b7280;}

/* small status badge */
.run-status{
  font-size:11px;
  font-weight:900;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid rgba(17,24,39,0.12);
  background:rgba(255,255,255,0.55);
  color:#6b7280;
  white-space:nowrap;
}

/* "…" button */
.run-more{
  width:28px;height:28px;
  border-radius:8px;
  border:0;
  background:transparent;
  color:#006798;
  cursor:pointer;
  font-weight:900;
  line-height:1;
  flex:0 0 auto;
}
.run-row.run-inprogress .run-more{color:#6b7280;}
.run-more:hover{background:rgba(39,133,201,0.12);}
.run-row.run-inprogress .run-more:hover{background:rgba(17,24,39,0.06);}

/* popover */
.run-popover{
  position:absolute;
  right:8px;
  top:38px;
  background:#fff;
  border:1px solid rgba(39,133,201,.35);
  border-radius:12px;
  box-shadow:0 12px 40px rgba(0,0,0,.18);
  padding:6px;
  display:none;
  z-index:9600;
}
.run-popover.open{display:block;}

.run-del{
  display:block;
  width:100%;
  border:1px solid rgba(176,0,32,0.18);
  background:rgba(176,0,32,0.06);
  color:#b00020;
  font-weight:800;
  font-size:12px;
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
  text-align:left;
}
.run-del:hover{background:rgba(176,0,32,0.10);}

/* ✅ publish button shares same base style as share/copy */
.run-share,.run-copy,.run-publish{
  display:block;
  width:100%;
  border:1px solid rgba(39,133,201,0.18);
  background:rgba(39,133,201,0.06);
  color:#006798;
  font-weight:800;
  font-size:12px;
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
  text-align:left;
  margin-bottom:6px;
}
.run-share:hover,.run-copy:hover,.run-publish:hover{background:rgba(39,133,201,0.12);}

/* ✅ published state */
.run-publish.is-on{
  border-color:rgba(10,127,63,0.22);
  background:rgba(10,127,63,0.06);
  color:#0a7f3f;
}

/* ✅ fail-safe: never show Publish on in-progress rows */
.run-row.run-inprogress .run-publish{ display:none !important; }

/* ✅ published crafted row = green */
.run-row.run-crafted.is-published{
  background:rgba(10,127,63,0.08);
  border-color:rgba(10,127,63,0.25);
}
.run-row.run-crafted.is-published:hover{
  background:rgba(10,127,63,0.14);
}
.run-row.run-crafted.is-published .run-link{
  color:#0a7f3f;
}
.run-row.run-crafted.is-published .run-more{
  color:#0a7f3f;
}
.run-row.run-crafted.is-published .run-more:hover{
  background:rgba(10,127,63,0.10);
}

/* ===== Existing login modal styles ===== */
#loginModal{position:fixed;inset:0;display:none;z-index:9000;}
#loginModal.active{display:block;}
#loginModal .modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.45);}
#loginModal .modal-card{position:relative;max-width:460px;margin:7vh auto;background:#fff;border-radius:14px;box-shadow:0 10px 40px rgba(0,0,0,.2);overflow:hidden;}
#loginModal .modal-head{display:flex;flex-direction:column;align-items:center;gap:6px;padding:14px 16px;border-bottom:1px solid rgba(39,133,201,.6);}
#loginModal .modal-body{padding:16px;}
#loginModal .modal-close{background:#006798;color:#fff;border:0;border-radius:999px;font-size:22px;line-height:1;cursor:pointer;width:32px;height:32px;}
#loginModal .head-row{display:flex;flex-direction:row;align-items:center;width:98%;justify-content:space-between;}
#loginModal .spinner{opacity:.7;}
#loginModal .success{color:#0a7f3f;margin-top:8px;}
#loginModal .error{color:#b00020;margin-top:8px;}
#btnLogout {border: 1.5px solid rgba(39, 133, 201, 0.6);}

  /* ✅ Auth UI gate: prevent “wrong state” flash until session/premium check completes */
  .auth-cta.auth-gated{ opacity:0; pointer-events:none; transition: opacity .12s ease; }
  .auth-cta.auth-gated.auth-ready{ opacity:1; pointer-events:auto; }
  
  
/* RECENT::::::::::::::::::::::::::::::::::::::::*/
/* Widget title */
#kw-title {
  margin: 1px auto;
  font-weight: 600;
  font-size: 12px;
  color: #006798;
  text-align: center;
}

/* Container */
#kw-suggestions {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center; align-items: center;
  min-height: 60px; cursor: pointer;
  border: 1.5px solid rgba(39,133,201,.5);
  border-radius: 8px; font-size: 16px;
  margin: 15px; margin-top: 0; color: #006798;
  padding: 2px 15px; 
  width: 300px;
  max-width: 98%;
}
@media (max-width: 420px) {#kw-suggestions {width: 250px;padding: 2px 5px;}}
@media (max-width: 380px) {#kw-suggestions {font-size: 14px;}}
/* Chip + meta */
#kw-suggestions .kw-chip{
  display:inline-block;
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

#kw-suggestions .kw-actuality {
  position: relative; display: block;
  margin: 4px 0 2px; font-size: 12px; line-height: 1.2;
  color: #006798; opacity: .85; user-select: none;
}

#kw-suggestions .kw-meta-bubble {
  font-size: 11px; user-select: none; color: #006798;
}
#kw-suggestions .kw-meta-bubble:hover { background: #f6fbff; }
#kw-suggestions .kw-meta-bubble .sep { opacity: .55; padding: 0 6px; }

#kw-suggestions a {
  color: #006798;
}

/* ------------3-way source selector (PubMed / PMC / Semantic) */
.source-switch.source-3{
  width: 420px;
  padding: 6px;
  gap: 6px;
}
@media (max-width: 520px){
  .source-switch.source-3{ width: 98%; }
}
.source-switch.source-3 .src-opt{
  flex: 1;
  border: 1.5px solid rgba(39,133,201,0.35);
  background: rgba(39,133,201,0.08);
  color: #006798;
  border-radius: 6px;
  padding: 6px 8px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.source-switch.source-3 .src-opt .src-count{
  font-size: 10px;
  font-weight: 600;
  opacity: 0.75;
  margin-top: 3px;
}
.source-switch.source-3 .src-opt.active{
  background: rgba(39,133,201,0.28);
  border-color: rgba(39,133,201,0.75);
  box-shadow: inset 0 -1em 1em rgba(39,133,201,0.20);
}
.source-switch.source-3 .src-opt:focus{
  outline: 2px solid rgba(39,133,201,0.55);
  outline-offset: 2px;
}

