:root {
    /* Light Theme (Default) */
    --bg-color: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --surface-white: rgba(255, 255, 255, 0.7);
    --surface-glass: rgba(255, 255, 255, 0.4);
    --border-light: rgba(255, 255, 255, 0.5);
    --accent-glow: rgba(56, 189, 248, 0.15);
    --accent-color: #3b82f6;
    --font-main: 'Outfit', sans-serif;
    --font-nepali: 'Mukta', sans-serif;

    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition-speed: 0.5s;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --surface-white: rgba(30, 41, 59, 0.7);
    --surface-glass: rgba(30, 41, 59, 0.4);
    --border-light: rgba(255, 255, 255, 0.1);
    --accent-glow: rgba(56, 189, 248, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color var(--transition-speed) var(--ease-out),
        color var(--transition-speed) var(--ease-out),
        border-color var(--transition-speed) var(--ease-out),
        box-shadow var(--transition-speed) var(--ease-out);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    position: relative;
    padding-top: 2rem;
}

/* --- Ambient Background --- */
.background-ambient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #e0f2fe 0%, transparent 70%);
    top: -10%;
    left: -10%;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #fae8ff 0%, transparent 70%);
    bottom: -10%;
    right: -5%;
    animation-delay: -5s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #f0f9ff 0%, transparent 70%);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

/* Floating Letters Logic (Grammar Background) */
.floating-letter {
    position: absolute;
    font-family: var(--font-nepali);
    font-size: 8rem;
    font-weight: 800;
    color: rgba(0, 0, 0, 0.03);
    user-select: none;
    animation: floatLetter 15s infinite linear;
}

[data-theme="dark"] .floating-letter {
    color: rgba(255, 255, 255, 0.03);
    /* Fix: White opacity for dark mode */
}

.letter-1 {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.letter-2 {
    top: 60%;
    right: 15%;
    animation-delay: -5s;
    font-size: 12rem;
}

.letter-3 {
    bottom: 10%;
    left: 30%;
    animation-delay: -8s;
    font-size: 6rem;
}

.letter-4 {
    top: 15%;
    right: 10%;
    animation-delay: -3s;
    font-size: 10rem;
    transform: rotate(-15deg);
}

.letter-5 {
    bottom: 20%;
    right: 20%;
    animation-delay: -12s;
    font-size: 7rem;
}

.letter-6 {
    top: 45%;
    left: 5%;
    animation-delay: -10s;
    font-size: 5rem;
}

@keyframes floatLetter {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-50px) rotate(10deg);
    }

    100% {
        transform: translateY(0) rotate(0deg);
    }
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 50px) scale(1.1);
    }
}

/* --- App Container --- */
.app-container {
    width: 100%;
    max-width: 1300px;
    padding: 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* --- Navbar --- */
.navbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Nepali Flag Gradient: Crimson Red to Blue */
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.15), rgba(0, 56, 147, 0.15));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    padding: 2rem 4rem;
    /* Even larger padding */
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.nav-brand {
    font-weight: 800;
    font-size: 1.8rem;
    /* Larger */
    text-decoration: none;
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    gap: 3rem;
    /* Larger gap */
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 1.1rem;
    /* Adjusted for better fit */
    transition: color 0.3s var(--ease-out);
    position: relative;
    padding: 0.5rem 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s var(--ease-out);
    border-radius: 2px;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.nav-brand {
    font-weight: 800;
    font-size: 1.8rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.3s var(--ease-out);
}

.nav-brand:hover {
    transform: scale(1.05);
}

/* --- Theme Toggle --- */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
}

.theme-toggle:hover {
    background: var(--surface-glass);
    transform: rotate(15deg);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Homepage Styles --- */
.home-hero {
    text-align: center;
    margin-top: 2rem;
}

.hero-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.logo-icon-large {
    font-family: var(--font-nepali);
    font-weight: 700;
    font-size: 4rem;
    background: var(--text-primary);
    color: var(--bg-color);
    /* Contrast Fix */
    width: 8rem;
    height: 8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.home-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 300;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    width: 100%;
}

.card {
    background: var(--surface-white);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s var(--ease-out);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
}

.card:hover {
    transform: translateY(-5px);
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.card h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.card-arrow {
    margin-top: 1.5rem;
    font-size: 1.5rem;
    align-self: flex-end;
}

/* Fix Card Contrast on Hover - Global Override */
[data-theme="dark"] .card:hover,
[data-theme="dark"] .phrase-card:hover {
    background: white;
    color: #0f172a;
    /* Force dark text */
}

[data-theme="dark"] .card:hover h3,
[data-theme="dark"] .card:hover p,
[data-theme="dark"] .card:hover .card-arrow {
    color: #0f172a;
    /* Ensure all children turn dark */
}

/* Specific fix for Phrase Cards on Learn Page */
[data-theme="dark"] .phrase-card:hover .nepali-text,
[data-theme="dark"] .phrase-card:hover .meaning {
    color: #0f172a;
}

[data-theme="dark"] .phrase-card:hover .pronunciation {
    color: #475569;
    /* Dark gray for secondary text */
}

/* --- Translate Page Styles --- */
.transliteration-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.input-block,
.output-block {
    background: var(--surface-white);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 2.5rem;
    transition: all 0.4s var(--ease-out);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.01);
}

.input-block:focus-within,
.output-block:focus-within {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
}

.connector {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: -1.5rem 0;
    z-index: 10;
    position: relative;
}

.arrow-circle {
    background: white;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    transition: all 0.3s var(--ease-out);
    border: 1px solid var(--border-light);
}

.arrow-circle:hover {
    transform: scale(1.1);
    color: var(--text-primary);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    opacity: 0.7;
}

textarea {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    font-family: var(--font-main);
    color: var(--text-primary);
    resize: none;
    outline: none;
    min-height: 120px;
    line-height: 1.5;
}

#nepaliOutput {
    font-family: var(--font-nepali);
}

textarea::placeholder {
    color: #cbd5e1;
    font-weight: 300;
}

/* --- Dark Mode Contrast Fixes --- */
[data-theme="dark"] .input-block:focus-within,
[data-theme="dark"] .output-block:focus-within {
    background: rgba(30, 41, 59, 0.95);
    /* Dark background on focus */
}

[data-theme="dark"] label {
    color: #e2e8f0;
    /* Lighter text for labels */
    opacity: 1;
}

[data-theme="dark"] textarea::placeholder {
    color: #64748b;
    /* Darker placeholder for better contrast against light text, or lighter? */
    /* Actually Slate 400 is #94a3b8. Let's use that for placeholder */
    color: #94a3b8;
}

/* --- Learn Page Styles --- */
.content-page {
    width: 100%;
}

.content-page h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 300;
    margin-bottom: 2rem;
}

.phrase-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Strict 3 columns */
    gap: 1.5rem;
    width: 100%;
    margin-top: 2rem;
}

.phrase-card {
    background: var(--surface-white);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.3s var(--ease-out);
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

/* Audio Icon Overlay */
.audio-icon {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.9);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.phrase-card:hover .audio-icon {
    opacity: 1;
    transform: scale(1);
}

/* Mobile responsiveness for grid */
@media (max-width: 900px) {
    .phrase-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .phrase-grid {
        grid-template-columns: 1fr;
    }
}

.phrase-card {
    background: var(--surface-white);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.2s;
}

.phrase-card:hover {
    transform: translateY(-5px);
    background: white;
}

.nepali-text {
    font-family: var(--font-nepali);
    font-size: 1.5rem;
    color: var(--text-primary);
}

.pronunciation {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.meaning {
    font-weight: 600;
    font-size: 1rem;
}

/* --- Grammar Page Specifics --- */
.center-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.center-hero h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.grammar-content {
    width: 100%;
    display: flex;
    gap: 3rem;
    align-items: flex-start;
}

/* Sidebar Navigation */
.grammar-sidebar {
    width: 280px;
    background: var(--surface-white);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    position: sticky;
    top: 2rem;
    flex-shrink: 0;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.grammar-sidebar h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toc-list a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    transition: all 0.2s;
    font-weight: 500;
    display: block;
}

.toc-list a:hover,
.toc-list a.active {
    background: rgba(236, 72, 153, 0.08);
    /* Pink tint */
    color: var(--accent-color);
}

/* Main Content Area */
.grammar-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4rem;
    /* Spacing between chapters */
}

.chapter-block {
    scroll-margin-top: 2rem;
}

.chapter-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chapter-number {
    background: var(--accent-color);
    color: white;
    font-size: 1rem;
    padding: 0.3rem 0.8rem;
    border-radius: 99px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.grammar-section-block {
    margin-bottom: 3rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 2rem;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.section-header {
    margin-bottom: 1.5rem;
    text-align: left;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Mobile Responsive Sidebar */
@media (max-width: 900px) {
    .grammar-content {
        flex-direction: column;
    }

    .grammar-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
}

.nepali-sub {
    font-family: var(--font-nepali);
    color: var(--accent-color);
    margin-left: 0.5rem;
}

.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    perspective: 1000px;
}

.compact-grid {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
}

.letter-card {
    background: var(--surface-white);
    aspect-ratio: 1;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.letter-card:hover {
    transform: scale(1.15) rotate(2deg);
    background: white;
    /* Fix: Force dark text on white card */
    box-shadow: 0 15px 30px rgba(59, 130, 246, 0.15);
    border-color: var(--accent-color);
    z-index: 10;
}

/* Hand Writing Animation Overlay */


.letter-card .l-nepali {
    font-family: var(--font-nepali);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.letter-card:hover .l-nepali {
    color: var(--accent-color);
    text-shadow: 0 0 2px var(--accent-color);
}

.l-roman {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: -5px;
    font-weight: 500;
    opacity: 0.7;
}

.letter-card:hover .l-roman {
    color: var(--accent-color);
    opacity: 1;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.rule-card {
    background: white;
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s ease;
}

.rule-card:hover {
    transform: translateY(-5px);
}

.rule-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 0.5rem;
}

.rule-diagram {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-weight: 600;
}

.rule-tag {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.rule-arrow {
    color: var(--accent-color);
    font-style: italic;
    font-size: 0.9rem;
}

.rule-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.respect-ladder {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.respect-ladder li {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem;
    border-radius: 12px;
    font-family: var(--font-nepali);
    font-size: 1.1rem;
}

.respect-ladder .high {
    background: #ecfdf5;
    color: #047857;
}

.respect-ladder .med {
    background: #eff6ff;
    color: #1d4ed8;
}

.respect-ladder .low {
    background: #fef2f2;
    color: #b91c1c;
}

.respect-ladder small {
    font-family: var(--font-main);
    font-size: 0.8rem;
    opacity: 0.8;
    align-self: center;
}

.gender-split {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.gender-split>div {
    flex: 1;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
}

.gender-split span {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.masc strong {
    color: #3b82f6;
}

.fem strong {
    color: #ec4899;
}

/* --- New Grammar Sections --- */

/* Grammar Tables (Pronouns & Verbs) */
.grammar-table-container {
    overflow-x: auto;
    background: var(--surface-white);
    border-radius: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 1rem;
    border: 1px solid var(--border-light);
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.grammar-table th,
.grammar-table td {
    padding: 1.2rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.grammar-table th {
    background: rgba(236, 72, 153, 0.05);
    /* Very light accent */
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.grammar-table tr:last-child td {
    border-bottom: none;
}

.nepali-cell {
    font-family: var(--font-nepali);
    font-size: 1.4rem;
    color: var(--text-primary);
    font-weight: 600;
}

.roman-sub {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-weight: 400;
    margin-top: 0.2rem;
}

/* Particle Cards */
.particle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.particle-card {
    background: var(--surface-white);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}

.particle-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
}

.particle-main {
    font-family: var(--font-nepali);
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    display: block;
}

.particle-meaning {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: block;
}

.particle-example {
    background: var(--bg-color);
    padding: 0.8rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.example-nepali {
    font-family: var(--font-nepali);
    color: var(--text-primary);
    font-weight: 500;
}

/* Dark Mode fixes for new elements */
[data-theme="dark"] .grammar-table-container,
[data-theme="dark"] .particle-card {
    background: var(--surface-white);
    /* stays slate-800 */
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .particle-card:hover {
    background: var(--surface-white);
    /* No white flash on hover for these info cards */
    border-color: var(--accent-color);
}

[data-theme="dark"] .grammar-table th {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .particle-example {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .grammar-sidebar {
    background: var(--surface-white);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .grammar-section-block {
    background: rgba(30, 41, 59, 0.5);
    /* Slate 800 transparent */
    border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .toc-list a:hover,
[data-theme="dark"] .toc-list a.active {
    background: rgba(236, 72, 153, 0.15);
}

/* --- History / Divyopadesh Page Styles --- */
.history-hero {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
    padding: 3rem 1rem;
}

.royal-title {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #FFD700, #B8860B);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.royal-subtitle {
    font-size: 1.4rem;
    color: var(--text-secondary);
    font-style: italic;
    max-width: 700px;
    margin: 0 auto;
}

.royal-bio {
    max-width: 800px;
    margin: 2.5rem auto 0;
    text-align: center;
    font-size: 1.25rem;
    line-height: 1.8;
    color: var(--text-primary);
    border-top: 1px solid rgba(184, 134, 11, 0.3);
    border-bottom: 1px solid rgba(184, 134, 11, 0.3);
    padding: 2rem 1rem;
    background: linear-gradient(to right, transparent, rgba(184, 134, 11, 0.05), transparent);
}

.section-header-royal {
    text-align: center;
    margin-bottom: 2.5rem;
    border-bottom: 2px solid rgba(184, 134, 11, 0.2);
    padding-bottom: 1rem;
    width: 100%;
}

.section-header-royal h2 {
    font-size: 2rem;
    color: #B8860B;
    font-family: serif;
    margin-bottom: 0.5rem;
}

.section-header-royal span {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --- Teaching Cards (Divyopadesh) --- */
.teaching-card {
    background: var(--surface-white);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.teaching-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-glow);
}

.teaching-quote-nepali {
    font-family: var(--font-nepali);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    border-left: 4px solid #B8860B;
    /* Royal Gold */
    padding-left: 1rem;
}

.teaching-quote-english {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    font-weight: 400;
    opacity: 0.9;
}

.teaching-context {
    margin-top: auto;
    background: rgba(184, 134, 11, 0.08);
    /* Gold Tint */
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #854d0e;
    /* Darker Gold/Brown */
    border: 1px solid rgba(184, 134, 11, 0.15);
}

.teaching-context strong {
    color: #713f12;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.3rem;
}

/* Category Specific Highlights (Optional, subtle borders) */
.teaching-card[data-category="military"]:hover {
    border-color: rgba(220, 38, 38, 0.3);
}

/* Red */
.teaching-card[data-category="economy"]:hover {
    border-color: rgba(22, 163, 74, 0.3);
}

/* Green */
.teaching-card[data-category="diplomacy"]:hover {
    border-color: rgba(37, 99, 235, 0.3);
}

/* Blue */
.teaching-card[data-category="unity"]:hover {
    border-color: rgba(219, 39, 119, 0.3);
}

/* Pink */
.teaching-card[data-category="governance"]:hover {
    border-color: rgba(234, 179, 8, 0.3);
}

/* Yellow */

/* Dark Mode Overrides */
[data-theme="dark"] .teaching-card {
    background: var(--surface-white);
    /* Keep consistent slate-800 */
}

[data-theme="dark"] .teaching-card:hover {
    background: rgba(30, 41, 59, 0.9);
}

[data-theme="dark"] .teaching-context {
    background: rgba(234, 179, 8, 0.1);
    color: #fef08a;
    /* Light yellow text */
    border-color: rgba(253, 224, 71, 0.1);
}

[data-theme="dark"] .teaching-context strong {
    color: #fca5a5;
    /* Light Red/Gold */
}

[data-theme="dark"] .filter-btn.active {
    background: #f8fafc;
    color: #0f172a;
}

/* --- Mobile/Responsive Enhancements --- */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
        gap: 2rem;
    }

    .navbar {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1.5rem;
    }

    .nav-links {
        gap: 1.2rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-links a {
        font-size: 1rem;
    }

    /* Translate Page Mobile */
    .input-block,
    .output-block {
        padding: 1.5rem;
    }

    textarea {
        font-size: 1.2rem;
    }

    /* Home Page Mobile */
    .logo-icon-large {
        width: 5rem;
        height: 5rem;
        font-size: 2.5rem;
        border-radius: 16px;
    }

    .home-hero h1 {
        font-size: 1.8rem;
    }

    .tagline {
        font-size: 1rem;
    }

    /* Royal/History Page Mobile */
    .royal-title {
        font-size: 2.2rem;
    }

    .royal-subtitle {
        font-size: 1.1rem;
    }

    .royal-bio {
        font-size: 1rem;
        padding: 1.5rem;
    }

    .teachings-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Learn Page Mobile */
    .alphabet-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .phrase-grid {
        grid-template-columns: 1fr;
    }

    .l-nepali {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .alphabet-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }

    .nav-links {
        gap: 0.8rem;
    }

    .nav-links a {
        font-size: 0.9rem;
    }
}