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

 body {
     margin: 0;
     padding: 40px 20px;
     font-family: -apple-system, BlinkMacSystemFont, sans-serif;
     background-image:
         linear-gradient(rgba(200, 200, 200, 0.05) 3px, transparent 3px),
         linear-gradient(90deg, rgba(200, 200, 200, 0.05) 3px, transparent 3px);
     background-size: 30px 30px;
     min-height: 100vh;

     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     /* centered before chat starts */
 }

 .container {
     width: 100%;
     max-width: 800px;
     margin-top: 10vh;
 }

 .logo {
     text-align: center;
     margin-bottom: 40px;
 }

 .logo h1 {

     font-size: 48px;
     font-weight: 600;
     margin-bottom: 8px;
 }

 .logoMath {

     color: #ff6b35;
 }

 .logo p {

     font-size: 18px;
 }

 @media (max-width: 768px) {
     body {
         padding: 15px;
     }

     .container {
         margin-top: 5vh;
     }

     .logo h1 {
         font-size: 36px;
     }

     .logo p {
         font-size: 16px;
     }
 }

 @media (max-width: 480px) {
     body {
         padding: 10px;
     }

     .container {
         margin-top: 3vh;
     }

     .logo {
         margin-bottom: 30px;
     }

     .logo h1 {
         font-size: 28px;
     }

     .logo p {
         font-size: 14px;
     }
 }

 .search-container {
     background: white;
     border-radius: 24px;
     padding: 8px;
     /* box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); */
     transition: all 0.3s ease;
     border: 1px solid lightgray;
 }

 .search-container:focus-within {
     box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
     transform: translateY(-2px);
 }

 .search-input-wrapper {
     display: flex;
     align-items: center;
     gap: 12px;
     padding: 8px 16px;
 }

 .search-icon {
     width: 24px;
     height: 24px;
     color: #9ca3af;
 }

 .search-input {
     flex: 1;
     border: none;
     outline: none;
     font-size: 18px;
     padding: 12px 0;
     color: #1f2937;
 }

 .search-input::placeholder {
     color: #9ca3af;
 }

 .image-upload-btn {
     background: #f3f4f6;
     border: none;
     padding: 10px;
     border-radius: 12px;
     cursor: pointer;
     transition: all 0.3s ease;
     display: flex;
     align-items: center;
     justify-content: center;
 }

 .image-upload-btn:hover {
     background: #e5e7eb;
     transform: scale(1.05);
 }

 .image-upload-btn svg {
     width: 20px;
     height: 20px;
     color: #ff6b35;
 }

 .image-preview-container {
     display: none;
     padding: 8px 16px;
     gap: 8px;
     flex-wrap: wrap;
 }

 .image-preview-container.show {
     display: flex;
 }

 .image-preview {
     position: relative;
     width: 80px;
     height: 80px;
     border-radius: 8px;
     overflow: hidden;
     border: 2px solid #e5e7eb;
 }

 .image-preview img {
     width: 100%;
     height: 100%;
     object-fit: cover;
 }

 .remove-image {
     position: absolute;
     top: 4px;
     right: 4px;
     background: rgba(0, 0, 0, 0.7);
     color: white;
     border: none;
     border-radius: 50%;
     width: 20px;
     height: 20px;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 12px;
     transition: all 0.2s ease;
 }

 .remove-image:hover {
     background: rgba(239, 68, 68, 0.9);
     transform: scale(1.1);
 }

 .search-button {
     background: #ff6b35;
     color: white;
     border: none;
     padding: 12px 32px;
     border-radius: 16px;
     font-size: 16px;
     font-weight: 600;
     cursor: pointer;
     transition: all 0.3s ease;
 }

 @media (max-width: 768px) {
     .search-input-wrapper {
         flex-wrap: wrap;
         gap: 8px;
     }

     .search-input {
         font-size: 16px;
         min-width: 100%;
     }

     .search-button {
         padding: 10px 24px;
         font-size: 15px;
     }
 }

 @media (max-width: 480px) {
     .search-container {
         border-radius: 16px;
         padding: 6px;
     }

     .search-input-wrapper {
         padding: 6px 12px;
     }

     /* .search-icon {
         width: 20px;
         height: 20px;
     } */

     .search-input {
         font-size: 15px;
         padding: 10px 0;
     }

     .image-upload-btn {
         padding: 8px;
     }

     .image-upload-btn svg {
         width: 18px;
         height: 18px;
     }

     .image-preview {
         width: 60px;
         height: 60px;
     }

     .search-button {
         width: 100%;
         padding: 10px 20px;
         font-size: 14px;
     }
 }

 .search-button:hover {
     transform: scale(1.05);
     box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
 }

 .search-button:active {
     transform: scale(0.98);
 }

 .filters {
     display: flex;
     gap: 12px;
     margin-top: 20px;
     flex-wrap: wrap;
     justify-content: center;
 }

 .filter-btn {
     background: rgba(255, 255, 255, 0.2);
     backdrop-filter: blur(10px);
     color: white;
     border: 2px solid rgba(255, 255, 255, 0.3);
     padding: 10px 20px;
     border-radius: 20px;
     font-size: 14px;
     cursor: pointer;
     transition: all 0.3s ease;
 }

 .filter-btn:hover {
     background: rgba(255, 255, 255, 0.3);
     transform: translateY(-2px);
 }

 .filter-btn.active {
     background: white;
     color: #667eea;
     border-color: white;
 }

 .category-section {
     margin-top: 30px;
     /* background: white; */
     border-radius: 16px;
     padding: 24px;
     /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); */
     border: 1px solid lightgrey;
 }

 .category-header {
     display: flex;
     align-items: center;
     justify-content: space-between;
     margin-bottom: 20px;
 }

 .category-title {
     font-size: 20px;
     font-weight: 600;
     color: #1f2937;
 }

 .view-toggle {
     display: flex;
     gap: 8px;
 }

 .toggle-btn {
     background: #f3f4f6;
     border: none;
     padding: 8px 16px;
     border-radius: 8px;
     font-size: 14px;
     cursor: pointer;
     transition: all 0.3s ease;
     color: #6b7280;
 }

 .toggle-btn.active {
     background: #ff6b35;
     color: white;
 }

 .category-grid {
     display: grid;
     grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
     gap: 16px;
 }

 .category-card {
     background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
     border-radius: 12px;
     padding: 20px;
     cursor: pointer;
     transition: all 0.3s ease;
     border: 2px solid transparent;
 }

 @media (max-width: 768px) {
     .category-section {
         padding: 20px;
         margin-top: 20px;
     }

     .search-icon {

         display: none;
     }

     .category-header {
         flex-direction: column;
         gap: 16px;
         align-items: flex-start;
     }

     .category-title {
         font-size: 18px;
     }

     .view-toggle {
         width: 100%;
     }

     .toggle-btn {
         flex: 1;
         padding: 10px 12px;
         font-size: 13px;
     }

     .category-grid {
         grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
         gap: 12px;
     }

     .category-card {
         padding: 16px;
     }

     .category-icon {
         font-size: 28px;
         margin-bottom: 10px;
     }

     .category-name {
         font-size: 15px;
     }

     .category-count {
         font-size: 12px;
     }
 }

 @media (max-width: 480px) {
     .category-section {
         padding: 16px;
         margin-top: 15px;
     }

     .category-header {
         gap: 12px;
     }

     .category-title {
         font-size: 16px;
     }

     .toggle-btn {
         padding: 8px 10px;
         font-size: 12px;
         border-radius: 6px;
     }

     .category-grid {
         grid-template-columns: 1fr 1fr;
         gap: 10px;
     }

     .category-card {
         padding: 14px;
     }

     .category-icon {
         font-size: 24px;
         margin-bottom: 8px;
     }

     .category-name {
         font-size: 14px;
     }

     .category-count {
         font-size: 11px;
     }
 }

 .category-card:hover {
     transform: translateY(-4px);
     border-color: #667eea;
     box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
 }

 .category-icon {
     font-size: 32px;
     margin-bottom: 12px;
 }

 .category-name {
     font-size: 16px;
     font-weight: 600;
     color: #1f2937;
     margin-bottom: 4px;
 }

 .category-count {
     font-size: 13px;
     color: #6b7280;
 }

 .question-list {
     display: none;
 }

 .question-list.show {
     display: block;
 }

 .question-item {
     background: #f9fafb;
     border-left: 4px solid #667eea;
     padding: 16px;
     margin-bottom: 12px;
     border-radius: 8px;
     cursor: pointer;
     transition: all 0.3s ease;
 }

 .question-item:hover {
     background: #f3f4f6;
     transform: translateX(4px);
 }

 .question-text {
     font-size: 15px;
     color: #1f2937;
     font-weight: 500;
     margin-bottom: 8px;
 }

 .question-meta {
     font-size: 13px;
     color: #6b7280;
 }

 @media (max-width: 768px) {
     .question-item {
         padding: 14px;
         margin-bottom: 10px;
     }

     .question-text {
         font-size: 14px;
     }

     .question-meta {
         font-size: 12px;
     }
 }

 @media (max-width: 480px) {
     .question-item {
         padding: 12px;
         margin-bottom: 8px;
         border-left-width: 3px;
     }

     .question-text {
         font-size: 13px;
         margin-bottom: 6px;
     }

     .question-meta {
         font-size: 11px;
     }
 }

 .results {
     margin-top: 40px;
     display: none;
 }

 .results.show {
     display: block;
 }

 .result-card {
     /* background: white; */
     border-radius: 16px;
     padding: 24px;
     margin-bottom: 16px;
     /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); */
     transition: all 0.3s ease;
     cursor: pointer;
 }

 .result-card:hover {
     transform: translateX(8px);
     box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
 }

 .result-title {
     font-size: 20px;
     font-weight: 600;
     color: #1f2937;
     margin-bottom: 8px;
 }

 .result-snippet {
     color: #6b7280;
     font-size: 15px;
     line-height: 1.6;
     margin-bottom: 12px;
 }

 .result-meta {
     display: flex;
     gap: 16px;
     font-size: 13px;
     color: #9ca3af;
 }

 .result-tag {
     background: #f3f4f6;
     padding: 4px 12px;
     border-radius: 12px;
     color: #667eea;
     font-weight: 500;
 }

 @media (max-width: 768px) {
     .results {
         margin-top: 30px;
     }

     .result-card {
         padding: 20px;
         margin-bottom: 14px;
     }

     .result-card:hover {
         transform: translateX(4px);
     }

     .result-title {
         font-size: 18px;
     }

     .result-snippet {
         font-size: 14px;
     }

     .result-meta {
         gap: 12px;
         font-size: 12px;
     }
 }

 @media (max-width: 480px) {
     .results {
         margin-top: 20px;
     }

     .result-card {
         padding: 16px;
         margin-bottom: 12px;
         border-radius: 12px;
     }

     .result-card:hover {
         transform: translateX(2px);
     }

     .result-title {
         font-size: 16px;
         margin-bottom: 6px;
     }

     .result-snippet {
         font-size: 13px;
         line-height: 1.5;
         margin-bottom: 10px;
     }

     .result-meta {
         flex-wrap: wrap;
         gap: 8px;
         font-size: 11px;
     }

     .result-tag {
         padding: 3px 10px;
         font-size: 11px;
     }
 }

 /* default layout */
 /* .search-container {
    margin-top: 80px;
} */

 /* when searching, keep search bar at top like Google */
 .search-active .search-container {
     position: sticky;
     top: 0;
     z-index: 100;
     background: #fff;
     padding-bottom: 12px;
     border-bottom: 1px solid #eee;
     margin-top: 0;
     /* <<< add this */
 }

 /* push results down a bit */
 .search-active .results {
     margin-top: 16px;
 }

 .results-section {
     /* border: 1px solid lightgray; */
     border-radius: 16px;
     padding: 16px 20px;
     margin-top: 20px;
     margin-bottom: 16px;
     background: #fff;
 }

 .results-section h2 {
     font-size: 16px;
     font-weight: 600;
     margin-bottom: 10px;
 }



 /* Hide the category section when search results are showing */
 .search-active .category-section,
 .search-active .logo {
     display: none;
 }

 .search-button {
     position: relative;
     min-width: 90px;
 }

 /* When loading, show spinner and hide label */
 .search-button.loading .btn-label {
     opacity: 0;
 }

 .search-button.loading::after {
     content: "";
     position: absolute;
     inset: 0;
     margin: auto;
     width: 18px;
     height: 18px;
     border-radius: 50%;
     border: 2px solid #ccc;
     border-top-color: #333;
     animation: spin 0.8s linear infinite;
 }

 @keyframes spin {
     to {
         transform: rotate(360deg);
     }
 }

 .results-subjects {
     display: flex;
     flex-wrap: wrap;
     gap: 8px;
 }

 .subject-pill {
     display: inline-flex;
     align-items: center;
     gap: 6px;
     padding: 6px 12px;
     border-radius: 999px;
     border: 1px solid #e5e7eb;
     font-size: 13px;
     color: #374151;
     background: #f9fafb;
     text-decoration: none;
     transition: background 0.2s ease, transform 0.2s ease;
 }

 .subject-pill:hover {
     background: #eef2ff;
     transform: translateY(-1px);
 }

 body.search-active {
     justify-content: flex-start;
     align-items: center;
     padding-top: 20px;
 }

 body.search-active .container {
     margin-top: 0;
 }

 .no-results-text {
     font-size: 14px;
     color: #6b7280;
     margin-top: 4px;
 }

 /* Sticky footer note */
 .site-footer {
     position: fixed;
     left: 0;
     right: 0;
     bottom: 0;
     /* default when chat not started */
     /* below your composer (z=100) */
     text-align: center;
     padding: 8px 12px;
     font-size: 12px;
     color: #6b7280;
     pointer-events: auto;
     /* keeps clicks going to page */
     background: transparent;
     height: var(--footer-h);
     line-height: var(--footer-h);
     z-index: 120;
 }

 body.chat-started .site-footer {
     bottom: 0 !important;
 }

 .site-footer a,
 .site-footer a:link,
 .site-footer a:visited {
     color: inherit !important;
     /* or set a hex color you want */
     text-decoration: none !important;
     /* keeps underline off */
 }

 .site-footer a:hover,
 .site-footer a:focus {
     text-decoration: underline;
     /* optional hover style */
 }

 .libLogo {

     text-decoration: none !important;
     color: #ff6b35;
 }