/* --- Theme Variables --- */
:root {
    touch-action: pan-y;
    /* Disables pinch-zoom and double-tap zoom, allows vertical scroll */
    /* Primary - 60% */
    --primary-terracotta: #E07A5F;
    --primary-beige: #F4F1EA;
    /* Warm beige background */
    --bg-cream: #FDFBF7;
    /* Lighter cream for cards/main */

    /* Secondary - 30% */
    --secondary-royal: #2C2C54;
    /* Wisdom/Divinity */
    --secondary-olive: #556B2F;
    /* Nature/Balance */

    /* Accent - 10% */
    --accent-saffron: #F2CC8F;
    --accent-ruby: #C62828;

    /* Neutrals */
    --text-dark: #3D405B;
    --text-muted: #524f5a;
    /* Slightly darker for better contrast (was #6D6875) */
    --white: #ffffff;
    --border-soft: #EAE2D6;

    /* Shadows & Radius */
    --card-shadow: 0 10px 30px rgba(44, 44, 84, 0.08);
    /* Soft/Dreamy */
    --radius-card: 24px;
    --radius-btn: 50px;

    /* Fonts */
    --font-heading: 'Noto Serif Telugu', 'Poppins', serif;
    --font-body: 'Noto Sans Telugu', 'Poppins', sans-serif;
    --font-serif: 'Noto Serif Telugu', serif;

    /* Missing Variables Repair */
    --secondary-navy: #1f1f3a;
    --primary-gold: #c59d5f;
    --accent-gold: #e6b870;
    --success: #2e7d32;
    --danger: #c62828;
    --warning: #f9a825;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--primary-beige);
    color: var(--text-dark);
    line-height: 1.7;
    font-size: 16px;
    padding: 0;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(224, 122, 95, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(44, 44, 84, 0.03) 0%, transparent 40%);
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent horizontal scroll/zoom triggers */
    width: 100%;
}

html {
    overflow-x: hidden;
    width: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6,
.section-title,
.table th {
    font-family: var(--font-serif) !important;
    color: var(--secondary-royal);
    font-weight: 700;
    letter-spacing: normal !important;
    text-transform: none !important;
}

/* --- Layout --- */
.main-container {
    max-width: 100vw;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    touch-action: pan-y;
}

/* --- Layout Wrapper --- */
.content-wrapper {
    width: 100%;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: inherit;
    flex-direction: inherit;
    justify-content: inherit;
    align-items: inherit;
    gap: inherit;
    height: inherit;
}

@media (min-width: 1024px) {
    .content-wrapper {
        max-width: 1200px;
        padding: 0 2rem;
    }
}

/* --- Component: App Header --- */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    /* Crisper white bg */
    backdrop-filter: blur(10px);
    padding: 1.25rem 2rem;
    /* Increased side padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    /* Sticky header */
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
}

/* Ensure header content is centered via wrapper */
.app-header .content-wrapper {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container {
    height: 52px;
    width: 52px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: 2px solid var(--primary-gold);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.app-logo {
    height: 100%;
    width: 100%;
    object-fit: contain;
    display: block;
}

.app-info h1 {
    font-size: 1.5rem;
    margin: 0;
    line-height: 1.1;
    color: var(--primary-gold);
    /* Saffron/Gold */
    font-weight: 900;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.app-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin: 0;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.icon-btn,
.profile-btn {
    background: var(--white);
    border: 1px solid var(--border-soft);
    height: 40px;
    width: 40px;
    border-radius: 50%;
    color: var(--secondary-royal);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.icon-btn:hover,
.profile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    color: var(--primary-terracotta);
}

/* --- View Management --- */
.view-section {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.view-section.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--secondary-royal);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* --- Component: Hero Section --- */
.hero-section {
    margin-bottom: 2.5rem;
    text-align: left;
}

.hero-section h2 {
    font-size: 2rem;
    color: var(--secondary-royal);
    margin-bottom: 0.5rem;
}

.hero-section p {
    font-size: 1rem;
    color: var(--text-muted);
}

/* --- Component: Action Grid --- */
.action-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .action-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.action-card {
    background: var(--white);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(44, 44, 84, 0.12);
    border-color: var(--accent-saffron);
}

.action-card.primary {
    background: linear-gradient(225deg, var(--white), #fffbf0);
    color: var(--secondary-royal);
}

.action-card .icon-box {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: var(--primary-beige);
    color: var(--primary-terracotta);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.action-card.primary .icon-box {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.action-card .card-text h3 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
    color: var(--secondary-royal);
}

.action-card.primary .card-text h3 {
    color: var(--white);
}

.action-card .card-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.action-card.primary .card-text p {
    color: rgba(255, 255, 255, 0.9);
}

.action-card .arrow {
    margin-left: auto;
    color: var(--primary-terracotta);
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.action-card.primary .arrow {
    color: var(--white);
}

.action-card:hover .arrow {
    opacity: 1;
    transform: translateX(0);
}

/* --- Library Grid --- */
.library-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.library-card {
    background: linear-gradient(225deg, var(--white), #fffbf0);
    padding: 1.25rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.library-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-terracotta);
    box-shadow: 0 10px 25px rgba(224, 122, 95, 0.15);
}

.library-card i {
    font-size: 2rem;
    color: var(--primary-terracotta);
    margin-bottom: 0.75rem;
}

.library-card h4 {
    font-size: 0.95rem;
    color: var(--secondary-royal);
    margin: 0;
}

/* --- Content --- */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel {
    background: linear-gradient(225deg, var(--white), #fffbf0);
    padding: 1.5rem;
    border-radius: var(--radius-card);
    border: var(--border-gold);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

.panel h3 {
    font-size: 1.25rem;
    color: var(--primary-gold);
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 1.5rem;
}

.calc-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .calc-layout {
        grid-template-columns: 2fr 3fr;
    }
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-navy);
    margin-bottom: 0.5rem;
}

input,
select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background-color: #FAFAFA;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-dark);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-gold);
    background-color: var(--white);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(to right, var(--primary-gold), var(--accent-gold));
    color: var(--white);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-transform: uppercase;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: scale(1.02);
}

/* --- Output Box (Input preview) --- */
.area-preview {
    margin-top: 1rem;
    font-weight: 600;
    color: var(--secondary-navy);
    font-size: 0.95rem;
}

.area-preview .text-muted {
    color: #888;
    font-weight: 400;
    font-size: 0.85rem;
}

.output-box {
    background: var(--bg-cream);
    border: 1px dashed var(--primary-gold);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.output-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(140, 106, 41, 0.2);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.output-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.font-bold {
    font-weight: 700;
    color: var(--secondary-navy);
}

/* --- Results Area --- */
#results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    text-align: center;
    color: var(--text-muted);
    border: 2px dashed #e0e0e0;
    border-radius: 12px;
    background: #fafafa;
}

.hidden {
    display: none !important;
}

/* --- Bar --- */
.gradient-bar-container {
    position: relative;
    margin: 25px 0 10px 0;
    width: 100%;
}

.gradient-bar {
    height: 12px;
    width: 100%;
    background: linear-gradient(to right, #F44336 0%, #FF9800 25%, #FFeb3B 50%, #8BC34A 75%, #0F9D58 100%);
    border-radius: 10px;
}

.bar-pointer {
    position: absolute;
    top: -14px;
    /* left will be set dynamically via JS */
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid #000;
    transition: left 0.5s ease-out;
}

.bar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
}

/* --- Table --- */
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
}

.results-table th {
    background: var(--secondary-navy);
    color: var(--white);
    padding: 12px 15px;
    text-align: left;
}

.results-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    background: var(--white);
}

.text-good {
    color: var(--success);
    font-weight: 400;
}

.text-bad {
    color: var(--danger);
    font-weight: 400;
}

.text-avg {
    color: var(--warning);
    font-weight: 400;
}

/* --- Result Summary Blocks --- */
.result-summary-block h4 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.result-summary-block p {
    margin: 0;
    line-height: 1.5;
}

/* --- Prose --- */
.prose h3,
.prose h4 {
    color: var(--primary-gold);
    text-align: center;
    margin: 1.5rem 0 1rem;
}

.prose p {
    margin-bottom: 1rem;
    color: #444;
    text-align: justify;
}

.table-responsive {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border-radius: 12px;
}

.custom-table th,
.custom-table td {
    padding: 10px;
    border: 1px solid #eee;
}

.custom-table th {
    background: var(--secondary-navy);
    color: white;
}

.col-green {
    background: #E8F5E9;
    color: #1B5E20;
}

.col-orange {
    color: #E65100;
}


/* --- Table Colors for Vastu Tables --- */
.bg-red-light {
    background-color: #ffcdd2;
}

.bg-green-light {
    background-color: #c8e6c9;
}

.bg-orange-light {
    background-color: #ffe0b2;
}

.bg-gray-light {
    background-color: #f5f5f5;
}

.col-blue-light {
    background-color: #e3f2fd;
    color: var(--secondary-navy);
    font-weight: 600;
}

.header-gray {
    background-color: #eceff1;
    color: var(--text-dark);
}

/* --- Responsive Images --- */
.tab-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

/* --- Responsive Images (Global) --- */
img {
    max-width: 100%;
    height: auto;
}

/* Specific Content Images */
.prose img,
.panel img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    margin: 1.5rem auto;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.prose img:hover,
.panel img:hover {
    transform: scale(1.02);
}

/* --- Utility Classes (for injected content) --- */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.my-4 {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.mr-2 {
    margin-right: 0.5rem;
}


/* --- Contact Section --- */
.contact-title {
    text-align: center;
    font-size: 28px;
    margin-bottom: 10px;
}

.contact-subtitle {
    text-align: center;
    font-size: 18px;
    color: #555;
    margin-bottom: 40px;
}

.contact-card-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.contact-text {
    margin: 0;
    font-size: 18px;
    text-align: center;
    color: var(--text-muted);
}

/* --- Responsive Navigation & Layout System --- */

/* Mobile & Tablet Default (Bottom Nav, No Footer) */
body {
    padding-bottom: 80px;
    /* Space for bottom nav */
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    border-top: 1px solid var(--border-soft);
    transition: transform 0.3s ease;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    gap: 4px;
    flex: 1;
    padding: 8px 4px;
    transition: all 0.3s;
    border-radius: 12px;
    min-width: 0;
}

.bottom-nav .nav-item i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 1.4rem;
    margin-bottom: 2px;
    transition: transform 0.2s;
}

.bottom-nav .nav-item span {
    display: block;
    width: 100%;
    line-height: 1.2;
    word-wrap: break-word;
}

.bottom-nav .nav-item.active {
    color: var(--primary-terracotta);
    font-weight: 600;
}

.bottom-nav .nav-item.active i {
    transform: translateY(-2px);
}

/* Desktop Overrides (>= 1024px) */
@media (min-width: 1024px) {

    /* Desktop header - sticky to keep at top */
    .app-header {
        position: sticky;
        top: 0;
        margin-bottom: 2rem;
    }

    /* Reset body padding for desktop */
    body {
        padding-top: 0;
        padding-bottom: 0;
    }

    /* Hide Bottom Nav & Reset Body Padding */
    .bottom-nav,
    .hidden-desktop {
        display: none !important;
    }

    /* Show Footer */
    footer {
        display: block;
    }

    /* Desktop Header Nav */
    .desktop-nav {
        display: flex !important;
        /* Override hidden-mobile */
        align-items: center;
        gap: 1.5rem;
        margin-left: 3rem;
        flex-grow: 1;
    }

    .desktop-nav .nav-item {
        text-decoration: none;
        color: var(--secondary-royal);
        font-weight: 500;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        border-radius: 50px;
        transition: all 0.2s;
    }

    .desktop-nav .nav-item:hover {
        background: rgba(0, 0, 0, 0.04);
        color: var(--primary-terracotta);
    }

    .desktop-nav .nav-item.active {
        background: rgba(224, 122, 95, 0.1);
        color: var(--primary-terracotta);
        font-weight: 600;
    }

    /* Hide Hamburger on Desktop if desired, but user didn't explicitly ask to remove it. 
       Use .hidden-desktop-menu if we wanted to hide it.
       For now, we keep it as it has other items.
    */
}

/* Helper to hide desktop nav on mobile */
.hidden-mobile {
    display: none;
}



.contact-footer {
    text-align: center;
    margin-top: 40px;
    font-size: 18px;
    color: #444;
}

ul,
ol {
    padding-left: 20px;
    margin-left: 0;
}

/* --- Dropdown Menus --- */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    max-width: 90vw;
    /* Prevent overflow on small screens */
    z-index: 1002;
    /* Above header */
    margin-top: 10px;
    display: block;
    background: transparent;
    border: 1px solid transparent;
}

.dropdown-menu.hidden {
    display: none;
}

/* Active State Styling Only */
.dropdown-menu.active {
    background: var(--white);
    border-radius: 20px;
    /* Proper border-radius */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    /* Premium shadow */
    padding: 0.75rem 0.5rem;
    /* Proper padding */
    border: 1px solid rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.2s ease;
    overflow: hidden;
    /* No clipping (overflow issues) */
}

.dropdown-menu.dropdown-right {
    left: auto;
    right: 0;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 12px;
    margin-bottom: 2px;
}

.dropdown-menu a:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.dropdown-menu a:hover {
    background: var(--bg-cream);
    /* Soft hover */
    color: var(--primary-terracotta);
}

.dropdown-menu a i {
    width: 24px;
    text-align: center;
    color: var(--primary-gold);
    margin-right: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Carousel Styles --- */
.hero-slider::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar for clean look */
}

.hero-slider {
    -ms-overflow-style: none;
    scrollbar-width: none;
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.carousel-slide {
    flex: 0 0 100%;
    /* Full width per slide */
    width: 100%;
    height: 220px;
    /* Fixed height for carousel */
    object-fit: cover;
    scroll-snap-align: center;
}


/* --- Supporting Home Image Section --- */
.supporting-image-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
    margin-bottom: 3rem;
    display: flex;
    justify-content: center;
    width: 100%;
}

.supporting-banner-img {
    width: 100%;
    max-width: 1200px;
    height: auto;
    display: block;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .supporting-image-section {
        padding: 0 1rem;
        margin-top: 1.5rem;
    }

    .supporting-banner-img {
        border-radius: 24px;
        box-shadow: none;
    }
}

@media (min-width: 769px) and (max-width: 1023px) {
    .supporting-image-section {
        padding: 0 1.5rem;
        margin-top: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .supporting-image-section {
        padding: 0 2rem;
        margin-top: 2.5rem;
    }

    .supporting-banner-img:hover {
        transform: translateY(-5px);
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    }
}

/* --- Responsive Design --- */
html {
    font-size: 16px;
    /* Default */
}

@media (max-width: 1024px) {

    /* Tablet Portrait / Landscape */
    html {
        font-size: 15px;
    }

    .app-header {
        padding: 0.85rem 1rem;
    }

    .logo-container {
        height: 44px;
        width: 44px;
        aspect-ratio: 1 / 1;
        padding: 0;
    }

    .app-info h1 {
        font-size: 1.25rem;
    }
}

/* Tablet-specific sticky positioning */
@media (min-width: 769px) and (max-width: 1024px) {
    .app-header {
        position: sticky;
        top: 0;
        margin-bottom: 2rem;
    }

    body {
        padding-top: 0;
        padding-bottom: 70px;
        /* Bottom nav height */
    }
}

@media (max-width: 768px) {

    /* Mobile */
    html {
        font-size: 14px;
        /* Mobile base font */
    }

    /* Fixed header for mobile/WebView */
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        margin-bottom: 0;
        z-index: 1000;
    }

    /* Remove body padding to prevent overflow */
    body {
        padding-top: 0;
        padding-bottom: 0;
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    /* Content area should fit available space without forcing extra height */
    #app-content {
        min-height: auto;
        /* Remove fixed min-height */
        flex: 1;
        /* Grow to fill available space */
    }

    /* .app-header and .app-logo removed to inherit Tablet styles (max-width: 1024px) */

    .app-info h1 {
        font-size: 1.3rem;
    }

    /* English specific reduction to prevent overflow/ovaling on small screens */
    html[lang="en"] .app-info h1 {
        font-size: 1.15rem;
    }

    .app-info p {
        display: none;
        /* Hide subtitle on small screens to save space */
    }

    /* Ensure clear touch targets - Excluding localized UI controls to prevent bloat */
    .icon-btn,
    .footer-link,
    button,
    a:not(.lang-toggle-link) {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Layout Adjustments */
    .main-container {
        padding: 0;
        padding-top: 70px;
        /* Space for fixed header */
        padding-bottom: 70px;
        /* Space for bottom nav */
    }

    /* Dashboard layout - prevent extra height */
    .dashboard-layout {
        padding: 1rem 1.5rem;
        min-height: auto;
    }

    .hero-slider {
        margin-left: -5px;
        margin-right: -5px;
        width: calc(100% + 10px);
    }

    .carousel-slide {
        height: 180px;
        /* Smaller hero on mobile */
    }

    /* Action Grid - 1 column already default, but ensures gap */
    .action-grid {
        gap: 1rem;
    }
}

/* --- Language Dropdown --- */
.lang-option.active {
    font-weight: 700;
    color: var(--primary-terracotta);
    background: var(--bg-cream);
}


/* --- Dashboard UI System --- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 768px) {
    .dashboard-layout {
        grid-template-columns: repeat(12, 1fr);
        padding: 1rem 2rem;
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
    }
}

/* --- Header Language Switcher --- */
.header-lang-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-serif);
    color: var(--text-dark);
    background: rgba(44, 44, 84, 0.04);
    padding: 6px 14px;
    /* Slightly more substantial */
    border-radius: 50px;
    border: 1px solid var(--border-soft);
}

.header-lang-switcher i {
    color: var(--primary-gold);
    font-size: 0.9rem;
    margin-right: 2px;
}

.lang-toggle-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    /* Fixed pixel size for UI consistency across devices */
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: auto;
    min-height: auto;
}

.lang-toggle-link:hover {
    color: var(--primary-terracotta);
}

.lang-toggle-link.active {
    color: var(--secondary-royal);
    position: relative;
}

.lang-toggle-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 6px;
    right: 6px;
    height: 2px;
    background: var(--primary-gold);
    border-radius: 2px;
}

.lang-separator {
    color: var(--border-soft);
    font-weight: 300;
    font-size: 0.8rem;
}

.dashboard-card {
    background: linear-gradient(225deg, var(--white), #fffbf0);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(44, 44, 84, 0.04);
    border: 1px solid rgba(224, 122, 95, 0.05);
    /* Subtle Terracotta tint */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(44, 44, 84, 0.08);
}


.welcome-title {
    font-size: 2rem;
    color: var(--secondary-royal);
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* --- Header Redesign --- */
/* Dashboard layout handles spacing */


/* On desktop, the grid moves to the wrapper */
@media (min-width: 769px) {
    .app-header {
        display: block;
        padding: 0;
    }

    .app-header .content-wrapper {
        padding: 1rem 2rem;
    }
}

/* Medium Desktop Responsiveness */
@media (min-width: 1024px) and (max-width: 1280px) {
    .app-header {
        padding: 0.75rem 1.25rem;
        gap: 0.75rem;
    }

    .header-tabs {
        margin-right: 0.75rem;
        gap: 0.25rem;
    }

    .header-tab {
        padding: 0.5rem 0.85rem;
        font-size: 0.9rem;
    }
}

/* Center Title Area in Header */
.header-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.current-section-title {
    display: none;
    /* Feature removed as per user request (hidden on all screens) */
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary-navy);
    background: rgba(224, 122, 95, 0.08);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
}

/* Right Actions Area */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Header Tabs (Desktop Only) */
.header-tabs {
    display: none;
    /* Hidden by default (Mobile/Tablet) */
    gap: 0.5rem;
    background: rgba(44, 44, 84, 0.04);
    padding: 5px;
    border-radius: 50px;
    margin-right: 1.5rem;
    flex-wrap: nowrap;
}

.header-tab {
    padding: 0.5rem 1.25rem;
    border-radius: 40px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.header-tab:hover {
    color: var(--secondary-royal);
    background: rgba(255, 255, 255, 0.5);
}

.header-tab.active {
    background: var(--white);
    color: var(--secondary-royal);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-weight: 700;
}

@media (min-width: 1024px) {
    .header-tabs {
        display: flex;
        /* Show Tabs on Desktop */
    }

    .current-section-title {
        display: none;
        /* Hide Title Pill on Desktop */
    }
}

/* Intermediate screens optimization (1024px - 1200px) */
@media (min-width: 1024px) and (max-width: 1200px) {
    .header-tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .header-tabs {
        gap: 0.25rem;
        margin-right: 1rem;
    }

    .app-header {
        gap: 1rem;
        padding: 1rem;
    }
}

/* Responsive adjustments for header */
@media (max-width: 768px) {
    .app-header {
        grid-template-columns: 1fr auto;
        /* Logo/Title left, Actions right. Center title might hide or move */
        padding: 0.75rem 1rem;
    }

    .header-center {
        display: none;
        /* Hide center title on mobile to save space */
    }
}

/* Calculator Grid Styles */
.calc-input-card {
    grid-column: 1 / -1;
}

.calc-result-card {
    grid-column: 1 / -1;
}

@media (min-width: 1024px) {
    .calc-input-card {
        grid-column: span 5;
    }

    .calc-result-card {
        grid-column: span 7;
    }
}

/* Library Grid Styles */
.library-dashboard-card {
    grid-column: span 12;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 180px;
    background: linear-gradient(225deg, var(--white), #fffbf0);
}

.library-dashboard-card i {
    font-size: 2rem;
    color: var(--primary-terracotta);
    margin-bottom: 1rem;
    width: 64px;
    height: 64px;
    background: var(--bg-cream);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.library-dashboard-card h4 {
    font-size: 1.1rem;
    color: var(--secondary-navy);
    font-weight: 600;
}

@media (max-width: 767px) {
    .library-dashboard-card {
        grid-column: 1 / -1 !important;
        /* Mobile: Full Width */
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .library-dashboard-card {
        grid-column: span 6 !important;
        /* Tablet: 2 Columns */
    }
}

@media (min-width: 1024px) {
    .library-dashboard-card {
        grid-column: span 4;
        /* Desktop: 3 Columns (Unchanged) */
    }
}

/* --- Main Footer Styles --- */

.main-footer {
    background-color: var(--secondary-royal);
    color: var(--white);
    padding: 0;
    /* Removing padding to control height via flex/height props */
    height: 80px;
    /* Matching body padding / bottom nav approx height */
    margin-top: auto;
    border-top: 4px solid var(--primary-gold);
    display: none;
    /* Hidden on mobile/tablet */
}

.main-footer .content-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 1024px) {
    .main-footer {
        display: flex;
        /* Visible on desktop */
    }
}

.footer-grid {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-wrap: nowrap;
    /* Prevent wrapping for slim look */
    justify-content: space-between;
    gap: 2rem;
    align-items: center;
    width: 100%;
    padding: 0 1.5rem;
}

.footer-copyright-text {
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer-links-row {
    display: flex;
    gap: 1.5rem;
}

.footer-simple-link {
    background: none;
    border: none;
    color: var(--white);
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: all 0.3s ease;
}

.footer-simple-link:hover {
    opacity: 1;
    text-decoration-color: var(--primary-terracotta);
}

/* --- Modal Styles --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 44, 84, 0.4);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal-window {
    background: var(--bg-cream);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 28px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(224, 122, 95, 0.1);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-body {
    padding: 2rem;
    line-height: 1.8;
    color: var(--text-dark);
    overflow-y: auto;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: var(--primary-terracotta);
}

/* --- Security Overrides --- */
/* Functionality preservation for forms */
input,
textarea,
select,
[contenteditable="true"] {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    pointer-events: auto !important;
}

/* Disable drag on images explicitly */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    pointer-events: none;
    /* Prevents right click and drag on mobile mostly */
}

/* --- Compass Feature Styles --- */
.compass-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.compass-container {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 20px auto;
}

.compass-dial {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), inset 0 0 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.1s linear;
    border: 8px solid var(--secondary-royal);
}

.compass-face {
    position: relative;
    width: 100%;
    height: 100%;
}

.compass-mark {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    padding-top: 15px;
    font-weight: 700;
    color: var(--secondary-royal);
}

.compass-mark span {
    font-size: 1.2rem;
}

.mark-n {
    color: var(--primary-terracotta);
    padding-top: 10px;
    font-size: 1.5rem;
}

.mark-sub span {
    font-size: 0.9rem;
    padding-top: 18px;
    color: var(--text-muted);
}

.mark-mini span {
    font-size: 0.65rem;
    padding-top: 22px;
    color: #bbb;
}

.degree-ticks {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.compass-dial::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 15px solid var(--primary-terracotta);
    z-index: 10;
}

.compass-center-disc {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border: 4px solid var(--bg-cream);
}

.degrees-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary-royal);
}

.direction-val {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Mandalam Feature Styles --- */
.mandalam-svg-container {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

#mandalam-svg {
    max-width: 100%;
    height: auto;
}

/* Responsive adjustments for new features */
@media (max-width: 768px) {
    .compass-container {
        width: 280px;
        height: 280px;
    }

    .compass-center-disc {
        width: 100px;
        height: 100px;
    }

    .degrees-val {
        font-size: 1.25rem;
    }
}

/* --- Digital Compass Component --- */
.digital-compass-container {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 60px auto;
    /* 60px vertical margin for maximum breathing room */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.08);
    /* Professional premium look */
}

.compass-dial-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    will-change: transform;
    transition: transform 0.1s ease-out;
}

.compass-needle {
    position: absolute;
    width: 4px;
    height: 140px;
    background: #c62828;
    bottom: 50%;
    left: 50%;
    z-index: 10;
    border-radius: 4px 4px 0 0;
    transform-origin: bottom center;
    will-change: transform;
    transition: transform 0.1s ease-out;
}

.compass-needle::after {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid #c62828;
}

.compass-center-pin {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #2c2c54;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 20;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

@media (max-width: 480px) {
    .digital-compass-container {
        width: 280px;
        height: 280px;
    }

    .compass-needle {
        height: 120px;
    }
}

/* --- Ayam Calculator Results Typography Refinement --- */
#results-content {
    line-height: 1.5 !important;
}

/* Headings in the results area */
#results-content h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--secondary-navy) !important;
    margin-bottom: 1.25rem !important;
}

#results-content h4 {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--secondary-royal) !important;
    margin-top: 1.5rem !important;
    margin-bottom: 0.75rem !important;
}

/* Headings and bold text in the results area (on light backgrounds) */
#results-content strong,
#results-content b,
#results-content .rec-label {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--secondary-royal) !important;
}

/* Table headers - must be white for contrast against dark background */
#results-content .results-table thead th {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--white) !important;
}

/* Body / Result text (The actual values) */
#results-content td,
#results-content p {
    font-size: 14px !important;
    font-weight: 400 !important;
    color: var(--text-dark) !important;
    line-height: 1.5 !important;
}

/* Status result text - must override general body color */
#results-content .text-good,
#results-content .text-excellent,
#results-content .text-best {
    color: var(--success) !important;
    font-weight: 500 !important;
}

#results-content .text-bad,
#results-content .text-poor,
#results-content .text-worst {
    color: var(--danger) !important;
    font-weight: 500 !important;
}

#results-content .text-avg,
#results-content .text-neutral {
    color: var(--warning) !important;
    font-weight: 500 !important;
}

/* Scale text within tables and boxes */
#results-content .results-table td {
    padding-bottom: 8px !important;
}

/* Specific box text */
#results-content #pdf-summary-section table td {
    font-size: 14px !important;
    line-height: 1.5 !important;
}

#results-content #aayam-vyayam-box p {
    font-size: 14px !important;
}

/* Ensure these UI refinements don't propagate to the PDF export container */
#pdf-export-container * {
    font-size: revert !important;
    line-height: revert !important;
    font-weight: revert !important;
}