/* --- Base JITL Modal Styles --- */
    
    /* 1. FORCE FONT CONSISTENCY */
    /* Applies Helvetica to the modal, tooltips, buttons, inputs, and text areas */
    .jitl-modal-content-wrapper,
    .jitl-modal-dynamic-content,
    .jitl-explorer-tools-area textarea,
    .tippy-box, 
    .tippy-content,
    button, input, textarea, select {
        font-family: Helvetica, Arial, sans-serif !important;
    }

    /* 2. UPDATE POSITIONING */
    .jitl-modal-overlay {
        display: none; position: fixed; z-index: 1050; left: 0; top: 0; width: 100%; height: 100%;
        overflow: hidden; background-color: rgba(0, 0, 0, 0.6);
        
        /* Align to top instead of center */
        display: flex; 
        justify-content: center; 
        
        /* FORCE top alignment with !important to override any JS inline styles */
        align-items: flex-start !important; 
        
        /* Push it down slightly from the very top edge */
        padding-top: 50px; 
    }

    .jitl-modal-content-wrapper {
        position: relative; background-color: #FFD27F; /* Default to info modal background */
        color: #000; 
        margin: 0 auto; 
        padding: 20px; border: 3px solid black;
        border-radius: 8px; width: 80%; max-width: 960px; /* Default width */
        box-shadow: 0 5px 15px rgba(0,0,0,0.3); animation: animatetop-jitl 0.4s;
        display: flex; flex-direction: column; max-height: 90vh;
    }

    /* Style for term-explorer type modal */
    .jitl-modal-content-wrapper.modal-type-term-explorer,
    .jitl-modal-content-wrapper.modal-type-selection-explorer {
        background-color: #FFD27F; /* Orange background for term/selection explorer */
    }

    @keyframes animatetop-jitl { from {top: -300px; opacity: 0} to {top: 0; opacity: 1} }

    .jitl-modal-close-button {
        position: absolute; top: 10px; right: 15px; color: #fff; background: red !important;
        border: none; font-size: 2em !important; font-weight: bold; line-height: 1;
        cursor: pointer; padding: 5px 10px !important; border-radius: 3px; z-index: 10;
    }
    .jitl-modal-close-button:hover { background: black !important; }

    .jitl-modal-static-title {
        text-align: center; margin-top: 0; margin-bottom: 15px; font-size: 1.6em;
        font-weight: bold; color: #000; padding-right: 40px; /* Space for close button */
        flex-shrink: 0;
    }

    .jitl-answered-question {
        background-color: #f1f1f1; /* A light grey to distinguish it from the white answer area */
        padding: 10px 15px;
        margin: -15px -15px 15px -15px; /* Use negative margins to span the full width of the padded container */
        border-bottom: 1px solid #ddd;
        font-size: 1.05em;
        font-style: italic;
        font-weight: 500;
        color: #222;
        border-radius: 5px 5px 0 0; /* Optional: round the top corners */
    }

    .jitl-modal-dynamic-content {
        font-size: 1.1em; line-height: 1.6; background: #FFF; padding: 15px;
        border-radius: 5px; margin-top: 0; min-height: 50px; word-wrap: break-word;
        flex-grow: 1; max-height: 300px;
        overflow-y: auto;
    }

    .jitl-modal-dynamic-content a { color: #0000EE; text-decoration: underline; }
    .jitl-modal-dynamic-content a:hover { color: #551A8B; }
    .jitl-modal-dynamic-content h2, .jitl-modal-dynamic-content h3, .jitl-modal-dynamic-content h4 {
        margin-top: 1em; margin-bottom: 0.5em; text-align: left;
    }
    .jitl-modal-dynamic-content h2 { font-size: 1.3em; }
    .jitl-modal-dynamic-content h3 { font-size: 1.15em; }
    
    /* Styles for Explorer Tools Area */
    .jitl-explorer-tools-area {
        padding-top: 15px;
        border-top: 1px solid #ccc;
        margin-top: 10px;
    }

    /* --- ADDED: Personalisation & Variable UI --- */
    .jitl-personalisation-container {
        transition: all 0.2s ease-in-out;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    }

    #jitl-pref-context-text, .jitl-var-input {
        box-sizing: border-box;
        margin-top: 5px;
        border: 1px solid #bbb;
        transition: border-color 0.2s, background-color 0.2s, opacity 0.2s;
    }

    #jitl-pref-context-text:focus, .jitl-var-input:focus {
        outline: none;
        border-color: #000;
        background-color: #fff;
    }

    #jitl-pref-context-enabled {
        width: 18px;
        height: 18px;
        cursor: pointer;
    }

    .jitl-explorer-tools-area textarea {
        min-height: 80px !important; width: 100%; padding: 12px; font-size: 1.25em; box-sizing: border-box;
        resize: vertical; overflow-y: auto; margin-bottom: 10px; border-radius: 4px;
        border: 1px solid #000;
    }

    /* Shared links container styles */
    .shared-tooltip-links-container {display: flex; gap: 5px; align-items: center; justify-content: center; flex-wrap: wrap; padding-bottom: 10px;}
    .shared-tooltip-links-container a.ask-ai-link, .shared-tooltip-links-container a, .shared-tooltip-links-container button { text-decoration: none; font-size: 1.0em; display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border: 1px solid #555; border-radius: 3px; background-color: #eee; color: #333; cursor: pointer; }
    .shared-tooltip-links-container a:hover, .shared-tooltip-links-container button:hover { background-color: #ddd; color: #000; }
    
    .extra-google-links { text-align: center; font-size: 0.9em; line-height: 1.5; }
    .extra-google-links a { text-decoration: underline; background: none; border: none; padding: 0; margin: 0 3px; cursor: pointer; }
    .link-separator { margin: 0 3px; color: #555; }
    
    .shared-content-links-container {display: inline-flex; gap: 10px; font-size: 14px; padding-left: 10px;}
    .shared-content-links-container a {text-decoration: none; padding: 0px 8px; border: 1px solid #555; border-radius: 3px; background-color: #eee; color: #333; cursor: pointer;}
    .shared-content-links-container a:hover {background-color: #ddd; color: #000;}

    .loading-indicator, .error-message { text-align: center; padding: 20px; font-style: italic; color: #555; }
    .error-message { color: #D8000C; font-weight: bold; }

    /* --- JITL Trigger Styles --- */
    .jitl-modal-trigger {
        border-bottom: 2px dotted #FFBB3F;
        cursor: pointer;
    }
    .jitl-modal-trigger.no-underline { border-bottom: none; padding: 0 2px; }
    .jitl-modal-trigger:hover { background: #FFBB3F; }

    /* --- Tippy Tooltip Styles --- */
    .tippy-box { max-width: 800px !important; background-color: #FFD27F !important; color: #000 !important; border: 5px solid black; border-radius: 5px; position: relative;}
    [data-tippy-root] {max-width: calc(100vw - 20px);}
    .tippy-box .tippy-content {font-size: 1.1em; padding: 20px 15px;}
    .tippy-box .tooltip-close-button,
    .tippy-box .tippy-convert-to-modal-button {
      position: absolute; top: 10px; border: none; font-size: 1.6em; font-weight: bold; line-height: 1;
      padding: 5px 10px; cursor: pointer; color: #fff; border-radius: 3px; z-index: 10;
    }
    .tippy-box .tooltip-close-button { right: 10px; background-color: red; }
    .tippy-box .tooltip-close-button:hover { background-color: black; }
    .tippy-box .tippy-convert-to-modal-button { left: 10px; background-color: black; }
    .tippy-box .tippy-convert-to-modal-button:hover { background-color: red; }

    /* --- Quick Query Links & Highlighting --- */
    .jitl-quick-query {
        color: #0056b3;
        cursor: pointer;
        border-bottom: 1px dashed #0056b3;
        font-weight: bold;
        transition: background-color 0.2s, color 0.2s;
        padding: 1px 4px;
        border-radius: 3px;
    }

    .jitl-quick-query:hover {
        background-color: #e2e6ea;
        color: #000;
        text-decoration: none;
    }

    /* Highlighted state for selected or active questions */
    .jitl-highlighted-query {
        background-color: #ffff00 !important; /* Bright yellow */
        color: #000 !important;
        border: 1px solid #000 !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    /* Tab styling */
    .tab { overflow: hidden; border-bottom: 1px solid #ccc; background-color: #f1f1f1; text-align: center; margin-bottom: 10px; }
    .tab div.tablinks { display: inline-block; background-color: inherit; border: none; outline: none; cursor: pointer; padding: 10px 16px; font-size: 16px; margin: 0 2px; transition: 0.3s; user-select: none; vertical-align: middle; }
    .tab div.tablinks:hover { background-color: #ddd; }
    .tab div.tablinks.active { background-color: #AF00AF; font-weight: bold; color: #ffffff; }

    /* Mobile Adjustments */
    @media (max-width: 767px) {
        .jitl-modal-content-wrapper { width: 95%; max-width: none; padding: 15px; padding-top: 45px; }
        .jitl-modal-static-title { font-size: 1.4em; }
    }