:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --error: #ef4444;
}

[data-theme="dark"] {
    --bg-body: #111827;
    --bg-card: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border: #374151;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding-bottom: 3rem;
    transition: background-color 0.3s;
}

/* --- Navbar --- */
.navbar {
    background: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-main);
}
.logo span { color: var(--primary); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    transition: 0.2s;
}

.nav-links a.active, .nav-links a:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1rem;
}

/* --- Layout --- */
.app-content {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.page { display: none; animation: fadeIn 0.3s; }
.page.active { display: block; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Inputs & Buttons --- */
.control-panel {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

input[type="text"] {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    border-radius: 8px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.full-width { width: 100%; margin-top: 1rem; }

/* --- Status Bar --- */
.status-bar {
    text-align: center;
    padding: 0.5rem;
    background: #e0e7ff;
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.status-bar.ready { display: none; } /* Hide when ready */
.loader {
    display: inline-block;
    width: 10px; height: 10px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s infinite linear;
}
@keyframes spin { to {transform: rotate(360deg);} }

/* --- Results Grid --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 1rem;
}

.word-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    font-weight: 600;
}

.word-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Anagram Page --- */
.anagram-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.input-group { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.result-banner {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    display: none;
}
.result-banner.success { background: #dcfce7; color: #166534; display: block; }
.result-banner.fail { background: #fee2e2; color: #991b1b; display: block; }

/* --- Modal --- */
.modal {
    display: none; 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center; justify-content: center;
}
.modal.open { display: flex; }

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.close-modal {
    position: absolute; right: 20px; top: 15px;
    font-size: 1.5rem; cursor: pointer;
}
.def-item { margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.def-part { font-style: italic; color: var(--primary); font-size: 0.85rem; }
