:root {
    /* Dark Theme (Default) - Royal/Premium */
    --primary-color: #1a237e;
    --secondary-color: #b71c1c;
    --accent-color: #ffd700;
    /* Gold */
    --text-light: #f5f5f5;
    --text-muted: #bdbdbd;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 215, 0, 0.2);
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --hero-overlay: rgba(0, 0, 0, 0.3);
    --font-heading: 'Rozha One', serif;
    --font-body: 'Hind', sans-serif;
    --highlight-glow: rgba(255, 215, 0, 0.15);
    --tree-line-color: rgba(255, 215, 0, 0.5);
}

[data-theme="light"] {
    /* Light Theme - Heritage/Royal */
    --primary-color: #2c3e50;
    --secondary-color: #800000;
    /* Maroon */
    --accent-color: #bfa36c;
    /* Antique Gold */
    --text-light: #2c3e50;
    /* Dark Blue for text */
    --text-muted: #546e7a;
    --bg-gradient-start: #fdfbf7;
    /* Cream/Off-white */
    --bg-gradient-end: #f5f0e1;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(191, 163, 108, 0.4);
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    --hero-overlay: rgba(255, 255, 255, 0.5);
    --highlight-glow: rgba(191, 163, 108, 0.15);
    --tree-line-color: rgba(183, 28, 28, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Subtle Pattern */
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23bfa36c' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--card-shadow);
    z-index: 100;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 80px 20px 40px;
    position: relative;
}

.om {
    font-size: 2.5rem;
    color: var(--accent-color);
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

h1 {
    font-family: var(--font-heading);
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

[data-theme="light"] h1 {
    color: var(--secondary-color);
    text-shadow: none;
}

.subtitle {
    font-size: 1.3rem;
    color: var(--text-light);
    opacity: 0.9;
    margin-bottom: 25px;
}

.hero-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
}

.hero-divider::before,
.hero-divider::after {
    content: "";
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    width: 120px;
    margin: 0 15px;
}

.diamond {
    color: var(--accent-color);
    font-size: 1.4rem;
}

.intro-text {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.15rem;
    padding: 30px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(5px);
    box-shadow: var(--card-shadow);
    color: var(--text-light);
}

[data-theme="light"] .intro-text {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(183, 28, 28, 0.1);
}

/* === TREE SECTION === */
.tree-section {
    margin-bottom: 60px;
    text-align: center;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .section-title {
    color: var(--secondary-color);
    text-shadow: none;
}

.tree-container {
    overflow-x: auto;
    padding-bottom: 20px;
    /* Custom Scrollbar for better UX */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--card-bg);
}

.tree-container::-webkit-scrollbar {
    height: 8px;
}

.tree-container::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

.tree {
    display: inline-block;
    min-width: 100%;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
}

.tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
}

/* We will use ::before and ::after to draw the connectors */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid var(--tree-line-color);
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid var(--tree-line-color);
}

/* We need to remove left-right connectors from elements without 
any siblings */
.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

/* Remove space from the top of single children */
.tree li:only-child {
    padding-top: 0;
}

/* Remove left connector from first child and 
right connector from last child */
.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

/* Adding back the vertical connector to the last nodes */
.tree li:last-child::before {
    border-right: 2px solid var(--tree-line-color);
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* Time to add downward connectors from parents */
.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid var(--tree-line-color);
    width: 0;
    height: 20px;
}

.tree-node {
    border: 1px solid var(--card-border);
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-light);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-block;
    border-radius: 5px;
    transition: all 0.5s;
    background: var(--card-bg);
    cursor: default;
    white-space: nowrap;
    position: relative;
    z-index: 2;
}

.tree-node:hover,
.tree-node:hover+ul li .tree-node {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--accent-color);
}

.tree-node.highlight-node {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--highlight-glow);
    font-weight: 700;
    color: var(--accent-color);
}

[data-theme="light"] .tree-node.highlight-node {
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}


/* Branches Grid */
.branches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    padding: 40px 0;
}

.branch-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 30px;
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.branch-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    border-color: var(--accent-color);
}

.branch-number {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 4rem;
    font-weight: 700;
    color: var(--accent-color);
    opacity: 0.1;
    font-family: var(--font-heading);
    line-height: 1;
    z-index: 0;
}

.branch-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--accent-color);
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

[data-theme="light"] .branch-title {
    color: var(--secondary-color);
}

.branch-desc {
    font-size: 1rem;
    margin-bottom: 20px;
    color: var(--text-muted);
    font-style: italic;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 15px;
    position: relative;
    z-index: 1;
}

.thikana-list {
    list-style: none;
    position: relative;
    z-index: 1;
}

.thikana-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    font-size: 1rem;
}

.thikana-bullet {
    color: var(--accent-color);
    margin-right: 12px;
    font-size: 0.9rem;
    margin-top: 4px;
}

[data-theme="light"] .thikana-bullet {
    color: var(--secondary-color);
}

.thikana-name {
    color: var(--text-light);
}

.patvi-tag {
    background: var(--secondary-color);
    color: white;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
    /* Pill shape */
    margin-left: 10px;
    vertical-align: middle;
    display: inline-block;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* === BHEDAWAT HIGHLIGHT STYLES === */
.highlight-card {
    grid-column: 1 / -1;
    /* Scan full width if possible, or usually takes precedence in layout */
    border: 2px solid var(--accent-color);
    background: linear-gradient(135deg, var(--card-bg), var(--highlight-glow));
    box-shadow: 0 0 20px var(--highlight-glow);
}

[data-theme="light"] .highlight-card {
    background: linear-gradient(135deg, #fffcf5, #fff8e1);
    border-color: var(--secondary-color);
}

.highlight-card .branch-title {
    font-size: 2.2rem;
    text-decoration: underline;
    text-underline-offset: 8px;
    text-decoration-color: var(--accent-color);
}

.highlight-card .branch-number {
    opacity: 0.15;
    color: var(--secondary-color);
}


/* Notes Section */
.notes-section {
    margin-top: 60px;
    display: grid;
    gap: 25px;
}

.note-card {
    background: rgba(183, 28, 28, 0.05);
    border-left: 5px solid var(--secondary-color);
    padding: 25px;
    border-radius: 8px;
}

[data-theme="light"] .note-card {
    background: rgba(183, 28, 28, 0.03);
    border: 1px solid rgba(183, 28, 28, 0.1);
    border-left: 5px solid var(--secondary-color);
}

.note-card h3 {
    color: var(--secondary-color);
    margin-bottom: 12px;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-card h3::before {
    content: "ℹ";
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
}

.note-card p {
    color: var(--text-light);
}


/* Footer */
.footer {
    text-align: center;
    padding: 60px 20px;
    margin-top: 80px;
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
}

.footer-divider {
    margin-bottom: 30px;
    opacity: 0.5;
}

.contact {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-color);
    margin: 15px 0;
    letter-spacing: 1px;
}

[data-theme="light"] .contact {
    color: var(--secondary-color);
}

.disclaimer {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 25px auto 0;
    line-height: 1.6;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: translateY(-5px);
    background: var(--accent-color);
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2.8rem;
    }

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

    .highlight-card .branch-title {
        font-size: 1.8rem;
    }

    .tree-container {
        padding-bottom: 40px;
    }
}