:root {
    --bg-dark: #0b0c15;
    --card-bg: rgba(22, 24, 47, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.2);
    
    --sidebar-width: 420px;
    --border-radius: 16px;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background decorative glows */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.bg-glow-1 {
    background: radial-gradient(circle, #6366f1 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.bg-glow-2 {
    background: radial-gradient(circle, #ec4899 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
}

/* Loading Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(7, 8, 15, 0.95);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.loader-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #a5b4fc);
    border-radius: 3px;
    transition: width 0.1s linear;
}

#loading-status {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: monospace;
}

/* App Container */
.app-container {
    position: relative;
    z-index: 1;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

/* Sidebar styling */
.search-sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(13, 14, 28, 0.4);
}

.app-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 2px;
}

.app-header h1 span {
    color: var(--primary);
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

.search-box {
    margin: 20px 24px 12px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s ease;
}

.search-box input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px 14px 48px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.search-box input:focus + .search-icon {
    color: var(--primary);
}

.clear-button {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.clear-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.clear-button svg {
    width: 16px;
    height: 16px;
}

.results-meta {
    padding: 0 24px;
    margin-bottom: 12px;
}

#results-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Suggestions List */
.suggestions-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.suggestions-container::-webkit-scrollbar {
    width: 6px;
}

.suggestions-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.suggestions-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
}

.suggestion-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.suggestion-item.active {
    background-color: var(--primary-glow);
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

.suggestion-item.selected {
    background-color: rgba(99, 102, 241, 0.25);
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

.word-text {
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.score-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.suggestion-item:hover .score-badge {
    color: var(--accent);
    background-color: var(--accent-glow);
}

/* Detail Area styling */
.detail-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
    position: relative;
    background: rgba(10, 11, 22, 0.2);
}

/* Welcome state */
.details-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.welcome-card {
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 24px;
    border: 1px solid var(--border-focus);
}

.icon-circle svg {
    width: 36px;
    height: 36px;
}

.welcome-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.welcome-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Definition card */
.definition-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.definition-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
    margin-bottom: 24px;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

#def-word {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.points-badge {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    background-color: var(--accent-glow);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.word-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.definition-body h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 700;
}

#def-text {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    body {
        overflow: auto;
    }
    
    .app-container {
        height: auto;
        min-height: 95vh;
        flex-direction: column;
    }
    
    .search-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 500px;
    }
    
    .detail-container {
        padding: 24px;
        min-height: 300px;
    }
}
