/* ==========================================================================
   AiSearch by Tessa – v2.0
   Inspired by Linear, Perplexity, and Vercel. Refined micro-interactions,
   tight typographic scale, and depth through subtle layering.
   BEM with .tessa- prefix. Mobile-first.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens
   -------------------------------------------------------------------------- */

.tessa-search {
    /* Palette */
    --t-accent: #4f46e5;
    --t-accent-hover: #4338ca;
    --t-accent-soft: #eef2ff;
    --t-accent-glow: rgba(79, 70, 229, 0.12);
    --t-accent-glow-strong: rgba(79, 70, 229, 0.22);

    /* Neutrals – slightly blue-shifted for cooler tone */
    --t-gray-950: #0f172a;
    --t-gray-800: #1e293b;
    --t-gray-700: #334155;
    --t-gray-500: #64748b;
    --t-gray-400: #94a3b8;
    --t-gray-300: #cbd5e1;
    --t-gray-200: #e2e8f0;
    --t-gray-100: #f1f5f9;
    --t-gray-50:  #f8fafc;
    --t-white:    #ffffff;

    /* Surfaces */
    --t-bg: var(--t-white);
    --t-bg-subtle: var(--t-gray-50);
    --t-border: var(--t-gray-200);
    --t-border-hover: var(--t-gray-300);

    /* Type */
    --t-text: var(--t-gray-800);
    --t-text-secondary: var(--t-gray-500);
    --t-text-muted: var(--t-gray-400);

    /* Radii */
    --t-radius: 10px;
    --t-radius-lg: 14px;
    --t-radius-full: 9999px;

    /* Shadows – layered for realism */
    --t-shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --t-shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --t-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --t-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --t-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --t-ring: 0 0 0 3px var(--t-accent-glow);

    /* Motion */
    --t-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --t-ease-out: cubic-bezier(0, 0, 0.2, 1);
    --t-duration: 0.2s;
    --t-duration-slow: 0.35s;

    /* Layout */
    max-width: 780px;
    /* margin: 0 auto; */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    color: var(--t-text);
}

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

/* --------------------------------------------------------------------------
   Search Bar – Command palette feel
   -------------------------------------------------------------------------- */

.tessa-search-bar {
    position: relative;
    z-index: 10;
}

.tessa-search-form {
    display: flex;
    position: relative;
}

.tessa-search-input {
    flex: 1;
    height: 52px;
    padding: 0 52px 0 44px;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: -0.01em;
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius-lg);
    outline: none;
    background: var(--t-bg);
    box-shadow: var(--t-shadow-sm);
    transition: border-color var(--t-duration) var(--t-ease-out),
                box-shadow var(--t-duration) var(--t-ease-out);
    color: var(--t-text);
    appearance: none;
    -webkit-appearance: none;
}

.tessa-search-input::placeholder {
    color: var(--t-text-muted);
    font-weight: 400;
}

.tessa-search-input:focus {
    border-color: var(--t-accent);
    box-shadow: var(--t-ring), var(--t-shadow-sm);
}

/* Search icon (left) */
.tessa-search-form::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 1;
    pointer-events: none;
}

/* Submit button */
.tessa-search-submit {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--t-accent);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--t-duration) var(--t-ease-out),
                transform var(--t-duration) var(--t-ease);
}

.tessa-search-submit svg {
    width: 16px;
    height: 16px;
}

.tessa-search-submit:hover {
    background: var(--t-accent-hover);
}

.tessa-search-submit:active {
    transform: translateY(-50%) scale(0.95);
}

/* Keyboard shortcut hint */
.tessa-search-form::after {
    content: '⌘K';
    position: absolute;
    right: 54px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 500;
    color: var(--t-text-muted);
    background: var(--t-gray-100);
    border: 1px solid var(--t-border);
    padding: 2px 6px;
    border-radius: 5px;
    pointer-events: none;
    opacity: 0.7;
    line-height: 1.4;
    letter-spacing: 0.02em;
    font-family: inherit;
}

.tessa-search-input:focus ~ .tessa-search-form::after,
.tessa-search-form:focus-within::after {
    opacity: 0;
}

/* --------------------------------------------------------------------------
   AI Answer – Perplexity-style answer card
   -------------------------------------------------------------------------- */

.tessa-ai-answer {
    position: relative;
    background: var(--t-bg);
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius-lg);
    padding: 0;
    margin: 20px 0;
    box-shadow: var(--t-shadow-sm);
    overflow: hidden;
    animation: tessa-slide-up 0.4s var(--t-ease) both;
}

/* Accent bar – top edge */
.tessa-ai-answer::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--t-accent), #818cf8, #a78bfa);
}

.tessa-ai-answer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px 0;
}

.tessa-ai-icon {
    color: var(--t-accent);
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.tessa-ai-label {
    font-weight: 600;
    font-size: 11px;
    color: var(--t-accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tessa-ai-answer-content {
    padding: 12px 20px 20px;
    line-height: 1.7;
    color: var(--t-text);
    font-size: 14.5px;
    letter-spacing: -0.005em;
    animation: tessa-fade-in 0.5s var(--t-ease) 0.1s both;
}

.tessa-ai-answer-content p {
    margin: 0 0 10px;
}

.tessa-ai-answer-content p:last-child {
    margin-bottom: 0;
}

.tessa-ai-answer-content strong {
    color: var(--t-gray-950);
    font-weight: 600;
}

.tessa-ai-answer-content ul,
.tessa-ai-answer-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.tessa-ai-answer-content li {
    margin-bottom: 4px;
    line-height: 1.65;
}

.tessa-ai-answer-content code {
    font-size: 13px;
    background: var(--t-gray-100);
    border: 1px solid var(--t-border);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.tessa-ai-answer-disclaimer {
    padding: 12px 20px;
    background: var(--t-gray-50);
    border-top: 1px solid var(--t-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tessa-ai-answer-disclaimer small {
    color: var(--t-text-muted);
    font-size: 11.5px;
    letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   Source Citations
   -------------------------------------------------------------------------- */

.tessa-citation {
    color: var(--t-accent);
    text-decoration: none;
    font-size: 0.7em;
    font-weight: 600;
    padding: 0 1px;
    transition: color 0.15s ease;
}

.tessa-citation:hover {
    color: var(--t-accent-hover);
    text-decoration: underline;
}

.tessa-sources {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--t-border);
}

.tessa-sources__header {
    font-size: 12px;
    font-weight: 600;
    color: var(--t-text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Collapsible variant — hidden by default, toggled via .is-open.
   Uses a grid-row trick for a smooth rubber-band expand without knowing
   the content height in advance. */
.tessa-sources--collapsible {
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.22, 1.5, 0.36, 1);
}

.tessa-sources--collapsible > .tessa-sources__inner {
    overflow: hidden;
    min-height: 0;
}

.tessa-sources--collapsible.is-open {
    grid-template-rows: 1fr;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--t-border);
}

.tessa-sources ol {
    padding-left: 20px;
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
}

.tessa-sources li {
    color: var(--t-text-secondary);
}

.tessa-sources a {
    color: var(--t-accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

.tessa-sources a:hover {
    color: var(--t-accent-hover);
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Skeleton Loader – pulse shimmer
   -------------------------------------------------------------------------- */

.tessa-skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, var(--t-gray-100) 25%, var(--t-gray-200) 50%, var(--t-gray-100) 75%);
    background-size: 250% 100%;
    border-radius: 6px;
    margin-bottom: 10px;
    animation: tessa-shimmer 2s ease-in-out infinite;
}

.tessa-skeleton-line--short { width: 50%; }
.tessa-skeleton-line--medium { width: 72%; }

@keyframes tessa-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   Results Section
   -------------------------------------------------------------------------- */

.tessa-results-heading {
    font-size: 13px;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--t-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tessa-results-count {
    font-weight: 500;
    color: var(--t-text-muted);
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
}

.tessa-results-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --------------------------------------------------------------------------
   Result Card – Clean, dense, Linear-style row
   -------------------------------------------------------------------------- */

.tessa-result-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--t-bg);
    border: 1px solid transparent;
    border-radius: var(--t-radius);
    padding: 14px 16px;
    transition: background var(--t-duration) var(--t-ease-out),
                border-color var(--t-duration) var(--t-ease-out),
                box-shadow var(--t-duration) var(--t-ease-out);
    position: relative;
    cursor: pointer;
    text-decoration: none;
    opacity: 0;
    transform: translateY(6px);
    animation: tessa-card-in 0.3s var(--t-ease) forwards;
}

/* Staggered entrance */
.tessa-result-card:nth-child(1)  { animation-delay: 0.02s; }
.tessa-result-card:nth-child(2)  { animation-delay: 0.04s; }
.tessa-result-card:nth-child(3)  { animation-delay: 0.06s; }
.tessa-result-card:nth-child(4)  { animation-delay: 0.08s; }
.tessa-result-card:nth-child(5)  { animation-delay: 0.10s; }
.tessa-result-card:nth-child(6)  { animation-delay: 0.12s; }
.tessa-result-card:nth-child(7)  { animation-delay: 0.14s; }
.tessa-result-card:nth-child(8)  { animation-delay: 0.16s; }
.tessa-result-card:nth-child(9)  { animation-delay: 0.18s; }
.tessa-result-card:nth-child(10) { animation-delay: 0.20s; }

@keyframes tessa-card-in {
    to { opacity: 1; transform: translateY(0); }
}

.tessa-result-card:hover {
    background: var(--t-gray-50);
    border-color: var(--t-border);
    box-shadow: var(--t-shadow-xs);
}

/* Focus ring for keyboard nav */
.tessa-result-card--focused,
.tessa-result-card:focus-visible {
    background: var(--t-accent-soft);
    border-color: var(--t-accent);
    box-shadow: var(--t-ring);
    outline: none;
}

/* Thumbnail */
.tessa-result-thumb {
    flex-shrink: 0;
    width: 100px;
    /* height: 72px; */
    /* border-radius: 8px; */
    overflow: hidden;
    /* background: var(--t-gray-100); */
    /* border: 1px solid var(--t-border); */
}

.tessa-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s var(--t-ease);
}

.tessa-result-card:hover .tessa-result-thumb img {
    transform: scale(1.06);
}

/* Body */
.tessa-result-body {
    flex: 1;
    min-width: 0;
}

/* Has-thumbnail modifier (no special styling needed; flex handles it) */
.tessa-result-card--has-thumb {
    /* flex by default */
}

/* Meta row */
.tessa-result-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.tessa-result-type {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--t-accent);
    background: var(--t-accent-soft);
    padding: 2px 7px;
    border-radius: var(--t-radius-full);
    line-height: 1.5;
}

.tessa-result-separator {
    color: var(--t-gray-300);
    font-size: 10px;
    line-height: 1;
}

.tessa-result-date {
    font-size: 12px;
    color: var(--t-text-muted);
}

.tessa-result-url {
    font-size: 11.5px;
    color: var(--t-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

/* Title */
.tessa-result-title {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.tessa-result-title a {
    color: var(--t-text);
    text-decoration: none;
}

.tessa-result-card:hover .tessa-result-title a {
    color: var(--t-accent);
}

/* Excerpt */
.tessa-result-excerpt {
    margin: 0;
    color: var(--t-text-secondary);
    line-height: 1.55;
    font-size: 13.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tessa-result-excerpt mark {
    background: var(--t-accent-glow-strong);
    color: var(--t-accent-hover);
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 500;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Bottom meta: source URL + relevance */
.tessa-result-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
}

/* Relevance tag */
.tessa-result-relevance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--t-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.tessa-result-relevance__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--t-accent);
    opacity: 0.6;
    flex-shrink: 0;
}

.tessa-result-relevance--high .tessa-result-relevance__dot { opacity: 1; background: #22c55e; }
.tessa-result-relevance--medium .tessa-result-relevance__dot { opacity: 0.8; background: #f59e0b; }
.tessa-result-relevance--low .tessa-result-relevance__dot { opacity: 0.6; background: var(--t-gray-400); }

/* Arrow indicator on hover */
.tessa-result-card .tessa-result-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    opacity: 0;
    color: var(--t-accent);
    transition: opacity var(--t-duration) var(--t-ease-out),
                transform var(--t-duration) var(--t-ease-out);
    display: flex;
    align-items: center;
}

.tessa-result-card:hover .tessa-result-arrow {
    opacity: 0.5;
    transform: translateY(-50%) translateX(0);
}

/* Skeleton placeholder card */
.tessa-result-card--skeleton {
    pointer-events: none;
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    cursor: default;
    border: 1px solid var(--t-border);
    background: var(--t-bg);
}

/* --------------------------------------------------------------------------
   CTA Section – gradient card
   -------------------------------------------------------------------------- */

.tessa-cta {
    position: relative;
    background: linear-gradient(135deg, var(--t-accent-soft) 0%, var(--t-gray-50) 100%);
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius-lg);
    padding: 28px 24px;
    margin-top: 28px;
    text-align: center;
    overflow: hidden;
    animation: tessa-fade-in 0.4s var(--t-ease) both;
}

.tessa-cta__content {
    margin-bottom: 16px;
}

.tessa-cta__heading {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: var(--t-gray-950);
    letter-spacing: -0.02em;
}

.tessa-cta__subheading {
    margin: 0;
    color: var(--t-text-secondary);
    font-size: 14px;
}

.tessa-cta__button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--t-accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--t-duration) var(--t-ease-out),
                transform var(--t-duration) var(--t-ease),
                box-shadow var(--t-duration) var(--t-ease-out);
    letter-spacing: -0.01em;
}

.tessa-cta__button:hover {
    background: var(--t-accent-hover);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--t-shadow-md);
}

.tessa-cta__button:active {
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Empty / Error / Loading States
   -------------------------------------------------------------------------- */

.tessa-no-results {
    text-align: center;
    padding: 48px 20px;
    animation: tessa-fade-in 0.4s var(--t-ease) both;
}

.tessa-no-results__icon {
    display: block;
    margin: 0 auto 12px;
    color: var(--t-gray-300);
}

.tessa-no-results p {
    margin: 0 0 4px;
    font-size: 15px;
    color: var(--t-text-secondary);
    font-weight: 500;
}

.tessa-no-results__hint {
    font-size: 13px !important;
    color: var(--t-text-muted) !important;
    font-weight: 400 !important;
}

.tessa-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--t-text-secondary);
}

.tessa-error {
    padding: 14px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--t-radius);
    color: #991b1b;
    margin: 16px 0;
    font-size: 13.5px;
    animation: tessa-fade-in 0.3s var(--t-ease) both;
}

/* --------------------------------------------------------------------------
   Search History Dropdown
   -------------------------------------------------------------------------- */

.tessa-search-history {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--t-bg);
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius);
    box-shadow: var(--t-shadow-lg);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
    animation: tessa-dropdown-in 0.15s var(--t-ease) both;
}

@keyframes tessa-dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tessa-search-history__header {
    padding: 10px 14px;
    font-size: 11px;
    color: var(--t-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--t-border);
}

.tessa-search-history__clear {
    background: none;
    border: none;
    color: var(--t-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    line-height: 1;
    border-radius: 4px;
    transition: color var(--t-duration), background var(--t-duration);
}

.tessa-search-history__clear:hover {
    color: #ef4444;
    background: #fef2f2;
}

.tessa-search-history__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--t-text);
    transition: background var(--t-duration);
    border-radius: 0;
}

.tessa-search-history__item:hover {
    background: var(--t-gray-50);
}

.tessa-search-history__item::before {
    content: '';
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='12 8 12 12 14 14'/%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* --------------------------------------------------------------------------
   Autocomplete / Search Suggestions
   -------------------------------------------------------------------------- */

.tessa-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--t-bg);
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius);
    box-shadow: var(--t-shadow-lg);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
    animation: tessa-dropdown-in 0.15s var(--t-ease) both;
}

.tessa-suggestions__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--t-text);
    transition: background var(--t-duration);
}

.tessa-suggestions__item:hover {
    background: var(--t-gray-50);
}

.tessa-suggestions__item::before {
    content: '';
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* --------------------------------------------------------------------------
   Load More
   -------------------------------------------------------------------------- */

.tessa-load-more {
    text-align: center;
    margin: 20px 0;
    animation: tessa-fade-in 0.3s var(--t-ease) both;
}

.tessa-load-more__button {
    padding: 8px 24px;
    background: var(--t-bg);
    border: 1px solid var(--t-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--t-text-secondary);
    transition: all var(--t-duration) var(--t-ease-out);
}

.tessa-load-more__button:hover {
    border-color: var(--t-accent);
    color: var(--t-accent);
    box-shadow: var(--t-ring);
}

/* --------------------------------------------------------------------------
   Regenerate Button
   -------------------------------------------------------------------------- */

.tessa-ai-regenerate,
.tessa-ai-sources-toggle {
    background: none;
    border: 1px solid var(--t-border);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11.5px;
    color: var(--t-text-muted);
    cursor: pointer;
    transition: all var(--t-duration) var(--t-ease-out);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.tessa-ai-regenerate {
    margin-left: auto;
}

.tessa-ai-sources-toggle {
    margin-left: auto;
}

.tessa-ai-sources-toggle + .tessa-ai-regenerate {
    margin-left: 6px;
}

.tessa-ai-regenerate:hover,
.tessa-ai-sources-toggle:hover,
.tessa-ai-sources-toggle.is-open {
    border-color: var(--t-accent);
    color: var(--t-accent);
    background: var(--t-accent-soft);
}

/* --------------------------------------------------------------------------
   Search Filters
   -------------------------------------------------------------------------- */

.tessa-filter-bar {
    margin: 10px 0 18px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Force the filter panel onto its own row below the button + count row. */
.tessa-filter-bar > .tessa-filter-panel {
    flex-basis: 100%;
    order: 3;
}

.tessa-filter-bar__count {
    margin-left: auto;
    order: 2;
    font-size: 13px;
    font-weight: 600;
    color: var(--t-text-secondary);
}

.tessa-filter-bar > .tessa-filter-toggle {
    order: 1;
}

.tessa-filter-bar__count .tessa-results-count {
    font-weight: 400;
    color: var(--t-text-muted);
    margin-left: 4px;
}

.tessa-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--t-bg);
    border: 1px solid var(--t-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--t-text-secondary);
    transition: all var(--t-duration) var(--t-ease-out);
}

.tessa-filter-toggle svg {
    width: 13px;
    height: 13px;
}

.tessa-filter-toggle:hover {
    border-color: var(--t-accent);
    color: var(--t-accent);
}

.tessa-filter-toggle[aria-expanded="true"] {
    border-color: var(--t-accent);
    color: var(--t-accent);
    background: var(--t-accent-soft);
}

.tessa-filter-badge {
    background: var(--t-accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
}

.tessa-filter-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-top: 10px;
    padding: 14px;
    background: var(--t-gray-50);
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius);
    animation: tessa-dropdown-in 0.15s var(--t-ease) both;
}

.tessa-filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 150px;
    flex: 1;
}

.tessa-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--t-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tessa-filter-select {
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid var(--t-border);
    border-radius: 7px;
    background: var(--t-bg);
    color: var(--t-text);
    cursor: pointer;
    outline: none;
    transition: border-color var(--t-duration);
}

.tessa-filter-select:focus {
    border-color: var(--t-accent);
    box-shadow: var(--t-ring);
}

.tessa-filter-clear {
    padding: 7px 12px;
    background: none;
    border: 1px solid var(--t-border);
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--t-text-muted);
    transition: all var(--t-duration);
    align-self: flex-end;
}

.tessa-filter-clear:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes tessa-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes tessa-slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Powered-by badge (shown at bottom of results)
   -------------------------------------------------------------------------- */

.tessa-pagination-info {
    text-align: center;
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--t-text-muted);
    letter-spacing: 0.01em;
}

.tessa-powered-by {
    text-align: center;
    margin: 24px 0 8px;
    font-size: 11px;
    color: var(--t-text-muted);
    letter-spacing: 0.01em;
}

.tessa-powered-by a {
    color: var(--t-accent);
    text-decoration: none;
    font-weight: 500;
}

.tessa-powered-by a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
    .tessa-search {
        padding: 0 12px;
    }

    .tessa-search-input {
        height: 48px;
        padding: 0 48px 0 40px;
        font-size: 14px;
    }

    .tessa-search-form::before {
        left: 12px;
        width: 16px;
        height: 16px;
    }

    .tessa-search-submit {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    /* Hide keyboard shortcut on mobile */
    .tessa-search-form::after {
        display: none;
    }

    .tessa-ai-answer-content {
        padding: 12px 16px 16px;
    }

    .tessa-ai-answer-header {
        padding: 14px 16px 0;
    }

    .tessa-ai-answer-disclaimer {
        padding: 10px 16px;
    }

    .tessa-result-card {
        padding: 12px 14px;
    }

    .tessa-result-thumb {
        width: 56px;
        height: 56px;
    }

    .tessa-result-title {
        font-size: 14px;
    }

    .tessa-result-excerpt {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }

    .tessa-result-arrow {
        display: none !important;
    }

    .tessa-cta {
        padding: 22px 18px;
    }

    .tessa-filter-panel {
        flex-direction: column;
    }

    .tessa-filter-group {
        min-width: 100%;
    }
}

/* Small screen: stack thumbnail below */
@media (max-width: 480px) {
    .tessa-result-card--has-thumb {
        flex-direction: column;
        gap: 10px;
    }

    .tessa-result-thumb {
        width: 100%;
        height: 120px;
        order: -1;
    }
}

/* Legacy compat */
.tessa-result-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--t-border);
}

.tessa-result-item:last-child {
    border-bottom: none;
}

.tessa-result-item--focused {
    background: var(--t-accent-soft);
    border-radius: 8px;
    padding: 14px 12px;
}
