*, *::before, *::after {
    box-sizing: border-box;
}
/* Base Styles (Recreating Tailwind Base) */
body {
    height: 100%;
    margin: 0;
    background-color: #f3f4f6; /* bg-gray-100 */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    min-height: 100vh; /* Ensure body covers full viewport height */
}

html {
    font-family: 'Roboto', sans-serif;
}

/* Core Utility Class for JavaScript Control */
.hidden {
    display: none !important; 
}

/* Container and Card Styling */
.main-container {
    width: 100%;
    max-width: 48rem; /* max-w-2xl */
}

.card-container {
    background-color: white;
    padding: 2rem; /* p-8 */
    border-radius: 1rem; /* rounded-2xl */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
}

/* Headings and Typography */
.h1-title {
    font-size: 1.875rem; /* text-3xl */
    font-weight: 700; /* font-bold */
    text-align: center;
    color: #1f2937; /* text-gray-900 */
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: #6b7280; /* text-gray-600 */
    margin-bottom: 1.5rem;
}

/* Search Type Buttons */
.search-type-container {
    display: flex;
    justify-content: center;
    gap: 1rem; /* space-x-4 */
    margin-bottom: 1.5rem;
}

.search-type-label {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: center;
    color: #4b5563; /* text-gray-600 */
    background-color: white;
    border: 1px solid #d1d5db; /* border-gray-300 */
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    font-weight: 500;
}

.search-type-label:hover {
    background-color: #f9fafb; /* hover:bg-gray-50 */
}

.search-type-input:checked + .search-type-label {
    background-color: #2563eb; /* peer-checked:bg-blue-600 */
    color: white;
    border-color: #2563eb;
}
.search-type-container > div {
    flex: 1; /* Forces equal width for all 3 buttons */
}
/* --- Search Input & Button --- */
#search-container {
    position: relative;
    margin-bottom: 1rem;
    display: flex; /* Use flexbox to align input and button naturally if needed, but absolute is fine if we fix padding */
    width: 100%;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 6rem; /* INCREASED: Make room for the 'Search' button */
    font-size: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    outline: none;
    transition: box-shadow 0.15s, border-color 0.15s, border-radius 0.15s;
    height: 3rem; /* Enforce height */
}

#search-button {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0; /* Stretch top to bottom */
    margin: 0.25rem; /* Tiny margin so it doesn't touch edges */
    padding: 0 1.5rem;
    font-weight: 600;
    color: white;
    background-color: #2563eb;
    border-radius: 0.375rem; /* Slightly smaller radius to fit inside */
    border: none;
    cursor: pointer;
    transition: background-color 0.15s;
    z-index: 5; /* Ensure it sits above input text */
}


/* Focus state matching Tailwind's focus:ring-2 focus:ring-blue-500 */
#search-input:focus {
    border-color: #3b82f6; 
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); 
}

#search-button:hover {
    background-color: #1d4ed8; 
}

#search-button:disabled {
    background-color: #9ca3af; 
    cursor: not-allowed;
}

/* --- Autocomplete Styles --- */
#autocomplete-list {
    position: absolute;
    top: 100%; /* Push it exactly below the input */
    left: 0;
    width: 100%;
    border: 1px solid #d1d5db;
    border-top: none;
    max-height: 20rem;
    overflow-y: auto;
    z-index: 50; /* High z-index to float above everything */
    background-color: white;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); /* Stronger shadow for floating effect */
}
#autocomplete-list div {
    padding: 0.75rem 1rem; 
    cursor: pointer;
    font-size: 0.95rem;
}
#autocomplete-list div:hover,
#autocomplete-list div.active {
    background-color: #eff6ff; /* blue-50 */
    color: #1d4ed8; /* blue-700 */
}
/* Ensure input stays square when autocomplete is open (JS adds the class) */
#search-input.focus\:border-bottom-left-radius-0 { border-bottom-left-radius: 0; }
#search-input.focus\:border-bottom-right-radius-0 { border-bottom-right-radius: 0; }

/* Vector Consent Card */
#vector-consent-card {
    background-color: #fffbeb; 
    border: 1px solid #fcd34d; 
    border-radius: 0.75rem; 
    padding: 1.5rem; 
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Fix for the large beaker SVG */
#vector-consent-card svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem auto;
    display: block;
    color: #f59e0b; /* amber-500 */
}

#download-vector-btn {
    padding: 0.5rem 1.5rem; 
    background-color: #d97706; 
    color: white;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: background-color 0.15s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); 
    border: none;
    cursor: pointer;
}

#download-vector-btn:hover {
    background-color: #b45309; 
}

#download-progress {
    margin-top: 1rem; 
}

#download-progress-bar {
    width: 100%;
    background-color: #fde68a; 
    border-radius: 9999px; 
    height: 0.625rem; 
    overflow: hidden;
}

#download-bar {
    background-color: #d97706; 
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

#download-status {
    font-size: 0.75rem; 
    color: #b45309; 
    margin-top: 0.5rem; 
    font-weight: 500;
}

/* Results Container */
.results-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem; 
}

.result-card {
    background-color: white;
    padding: 1rem; 
    border-radius: 1rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); 
    transition: box-shadow 0.2s; /* Added subtle hover effect */
}
.result-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Score Bar */
.score-bar-bg {
    background-color: #e5e7eb; 
    border-radius: 9999px;
    height: 0.625rem;
    width: 100%;
    overflow: hidden;
}

.score-bar-fill {
    background-color: #3b82f6; 
    height: 100%;
    border-radius: 9999px;
}

.score-text {
    font-size: 0.875rem; 
    color: #1d4ed8; 
    font-weight: 500;
    margin-top: 0.375rem; 
}

/* Neighbor Styles */
.neighbor-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb; 
    display: flex;
    flex-direction: column;
    gap: 0.75rem; 
}

.neighbor-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563; 
}

.neighbor-card {
    padding-left: 0.75rem; /* Increased padding */
    border-left: 3px solid #e5e7eb; /* Thicker border */
    font-size: 0.9rem;
}

.neighbor-score-bar-bg {
    background-color: #eff6ff; 
    border-radius: 9999px;
    height: 0.375rem;
    width: 100%;
    overflow: hidden;
}

.neighbor-score-bar-fill {
    background-color: #60a5fa; 
    height: 100%;
    border-radius: 9999px;
}

.neighbor-score-text {
    font-size: 0.75rem; 
    color: #2563eb; 
    font-weight: 500;
    margin-top: 0.25rem; 
}

/* Other UI elements */
.status-text {
    text-align: center;
    color: #6b7280;
    margin-top: 1rem;
    height: 1.5rem; 
    font-weight: 500;
}

/* --- Modal Styling --- */
#help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 32rem; 
    background-color: white;
    padding: 2rem;
    border-radius: 1.5rem; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); 
}

/* Shared Button Styles */
.close-modal-btn {
    z-index: 50;
    color: #6b7280;
    background-color: white;
    border: 1px solid #e5e7eb; /* Subtle border for definition */
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    
    /* Typography for the "?" */
    font-family: sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.close-modal-btn:hover {
    background-color: #f9fafb;
    color: #111827;
    border-color: #d1d5db;
    transform: translateY(-1px); /* Tiny lift effect */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* 1. Main Help Button (Fixed to Screen) */
#help-button {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    color: #2563eb; /* Blue ? */
    border-color: #eff6ff;
}

/* 2. Modal Close Button (Absolute to Card) */
#close-modal-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
}
#close-modal-button:hover {
    background-color: #f3f4f6;
}

.modal-body {
    color: #4b5563; 
    display: flex;
    flex-direction: column;
    gap: 1rem; 
    line-height: 1.5; /* Added line height for readability */
}

.modal-list {
    list-style-type: disc;
    list-style-position: inside;
    margin-top: 0.5rem; 
    display: flex;
    flex-direction: column;
    gap: 0.5rem; 
}

body.theme-reference {
    background-color: #f3f4f6; /* gray-100 */
}

/* Keyword Mode (Soft Indigo/Purple Tint) */
body.theme-keyword {
    background-color: #e0e7ff; /* indigo-100 */
    transition: background-color 0.5s ease;
}

/* Vector Mode (Soft Amber/Orange Tint) */
body.theme-vector {
    background-color: #fef3c7; /* amber-100 */
    transition: background-color 0.5s ease;
}

/* Optional: Tint the search button to match */
body.theme-keyword #search-button {
    background-color: #4f46e5; /* indigo-600 */
}
body.theme-keyword #search-button:hover {
    background-color: #4338ca; /* indigo-700 */
}

body.theme-vector #search-button {
    background-color: #d97706; /* amber-600 */
}
body.theme-vector #search-button:hover {
    background-color: #b45309; /* amber-700 */
}


/* When body has theme-reference (or default), the checked reference label is blue */
body.theme-reference .search-type-input:checked + .search-type-label {
    background-color: #2563eb; /* blue-600 */
    border-color: #2563eb;
    color: white;
}

/* 2. Keyword Mode (Purple) */
/* When body is purple, the checked keyword label becomes purple */
body.theme-keyword .search-type-input:checked + .search-type-label {
    background-color: #4f46e5; /* indigo-600 */
    border-color: #4f46e5;
    color: white;
}

/* 3. Vector Mode (Amber/Orange) */
/* When body is amber, the checked vector label becomes amber */
body.theme-vector .search-type-input:checked + .search-type-label {
    background-color: #d97706; /* amber-600 */
    border-color: #d97706;
    color: white;
}

/* Optional: Add a subtle hover tint for non-selected buttons based on theme */
body.theme-keyword .search-type-label:hover {
    background-color: #eef2ff; /* indigo-50 */
}
body.theme-vector .search-type-label:hover {
    background-color: #fffbeb; /* amber-50 */
}

/* 1. Reference Button (Always Blue when selected) */
#search-reference:checked + .search-type-label {
    background-color: #2563eb; /* blue-600 */
    border-color: #2563eb;
    color: white;
}

/* 2. Keyword Button (Always Purple when selected) */
#search-keyword:checked + .search-type-label {
    background-color: #7c3aed; /* violet-600 */
    border-color: #7c3aed;
    color: white;
}

/* 3. Vector Button (Always Amber/Orange when selected) */
#search-vector:checked + .search-type-label {
    background-color: #d97706; /* amber-600 */
    border-color: #d97706;
    color: white;
}

/* Optional: Hover states for unselected buttons to hint at their color */
/* These use adjacent sibling combinator to target label based on input ID */
#search-reference:not(:checked) + .search-type-label:hover {
    background-color: #eff6ff; /* blue-50 */
    border-color: #bfdbfe;     /* blue-200 */
    color: #1e40af;            /* blue-800 */
}

#search-keyword:not(:checked) + .search-type-label:hover {
    background-color: #f5f3ff; /* violet-50 */
    border-color: #ddd6fe;     /* violet-200 */
    color: #5b21b6;            /* violet-800 */
}

#search-vector:not(:checked) + .search-type-label:hover {
    background-color: #fffbeb; /* amber-50 */
    border-color: #fde68a;     /* amber-200 */
    color: #92400e;            /* amber-800 */
}


/* Copyright Badge (Bottom Right) */
.copyright-badge {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 100; /* Higher than everything else (Modal is 50) */
    
    font-size: 0.7rem; /* Teeny */
    font-weight: 700;  /* Bold */
    color: black;
    text-decoration: none;
    
    /* Optional: Subtle opacity until hovered to keep it unobtrusive */
    opacity: 0.5; 
    transition: opacity 0.2s, text-decoration 0.2s;
    font-family: sans-serif;
}

.copyright-badge:hover {
    opacity: 1;
    text-decoration: underline;
}