:root {
    --bg-color: #050507;
    --text-color: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --accent-glow: 0 0 80px rgba(124, 58, 237, 0.15);
    /* Improved Gradient for "State of the Art" look */
    --primary-gradient: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
    --secondary-gradient: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    /* Modern System Font Stack - No Google Fonts needed */
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Dynamic Background */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.12) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: pulse 10s ease-in-out infinite alternate;
}

body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: pulse 12s ease-in-out infinite alternate-reverse;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.1);
        opacity: 0.6;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
    padding-top: 4rem;
}

.logo-area {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: #64748b;
    margin-bottom: 1rem;
    font-weight: 700;
}

h1 {
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, #fff 20%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.subtitle {
    font-size: 1.25rem;
    color: #94a3b8;
    max-width: 600px;
    margin: 0 auto;
    font-weight: 300;
}

/* Advanced Search */
.search-wrapper {
    position: sticky;
    top: 20px;
    z-index: 100;
    margin-bottom: 4rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.search-container {
    position: relative;
    border-radius: 24px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.search-container:focus-within {
    transform: scale(1.02);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.1), 0 10px 40px rgba(0, 0, 0, 0.5);
}

#search-input {
    width: 100%;
    padding: 1.4rem 3.5rem;
    font-size: 1.1rem;
    background: rgba(15, 23, 42, 0.6);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-family: var(--font-sans);
}

#search-input:focus {
    outline: none;
}

#search-input::placeholder {
    color: #475569;
}

.search-icon {
    position: absolute;
    left: 1.4rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
    transition: color 0.3s;
}

.search-container:focus-within .search-icon {
    color: #a855f7;
}

#search-clear {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s;
}

#search-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.search-stats {
    text-align: center;
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.8rem;
    height: 1.2em;
    /* Reserve space */
    opacity: 0;
    transition: opacity 0.3s;
}

.search-stats.visible {
    opacity: 1;
}

/* Grid */
.terms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    perspective: 1000px;
    /* For 3D effects */
}

/* Card Micro-interactions */
.term-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
    transform-style: preserve-3d;
}

.term-card:hover {
    transform: translateY(-8px) scale(1.01);
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
}

.card-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: radial-gradient(circle at 50% 0%, rgba(124, 58, 237, 0.15), transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.term-card:hover .card-glow {
    opacity: 1;
}

.term-category {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #a855f7;
    margin-bottom: 1rem;
    font-weight: 700;
}

.term-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #f1f5f9;
    line-height: 1.2;
    transition: color 0.3s;
}

.term-card:hover .term-title {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.term-preview {
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

/* Highlight */
.highlight {
    background: rgba(168, 85, 247, 0.3);
    color: #fff;
    padding: 0 2px;
    border-radius: 2px;
}

/* No Results */
#no-results {
    text-align: center;
    display: none;
    margin-top: 6rem;
    color: #94a3b8;
}

#reset-search {
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s;
}

#reset-search:hover {
    background: #fff;
    color: #000;
}

/* Detail View */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    text-decoration: none;
    margin-bottom: 2rem;
    font-weight: 500;
    transition: all 0.2s;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.03);
}

.back-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-5px);
}

.term-detail {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-header {
    margin-bottom: 3rem;
    text-align: center;
}

.detail-category {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    background: rgba(168, 85, 247, 0.1);
    color: #c084fc;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(168, 85, 247, 0.2);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.1);
}

.detail-title {
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1.1;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.detail-content {
    font-size: 1.35rem;
    color: #cbd5e1;
    line-height: 1.8;
}

.tags {
    margin-top: 4rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 2rem;
}

.tag {
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    font-size: 0.95rem;
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
}

.tag:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateY(-2px);
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #a855f7;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto;
}

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

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    .detail-title {
        font-size: 2.5rem;
    }

    .container {
        padding: 1.5rem;
    }

    .terms-grid {
        grid-template-columns: 1fr;
    }

    header {
        padding-top: 2rem;
    }
}