/* ===========================
   GENERAL STYLES & VARIABLES
   =========================== */

:root {
    /* Color Palette (WCAG Compliant) */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #1e1b4b;
    --accent-color: #f59e0b;

    /* Backgrounds */
    --background-color: #f8fafc;
    /* Alias for light-bg context */
    --light-bg: #ffffff;
    --dark-bg: #0f172a;
    --card-bg: #ffffff;

    /* Text */
    --text-dark: #0f172a;
    --text-light: #64748b;
    --text-muted: #64748b;

    /* Status Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Global Settings */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --transition: all 0.3s ease;

    /* Mapped Variables for Compatibility */
    --bg-color: var(--light-bg);
    --text-main: var(--text-dark);
}

/* CLS Optimization: Reserve space for Ads */
.ad-space {
    min-height: 280px;
    /* Typical rectangle ad height */
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
    /* Skeleton placeholder */
    margin: 2rem 0;
}


.ad-banner {
    min-height: 90px;
}



@media (min-width: 768px) {
    .ad-space {
        min-height: 90px;
        /* Horizontal banner on desktop */
    }
}

/* Core Variables & Styles */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #1e1b4b;
    --accent-color: #f59e0b;
    --background-color: #f8fafc;
    --light-bg: #ffffff;
    --dark-bg: #0f172a;
    --card-bg: #fff;
    --text-dark: #0f172a;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0/0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0/0.1), 0 2px 4px -2px rgb(0 0 0/0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0/0.1), 0 4px 6px -4px rgb(0 0 0/0.1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --transition: all .3s ease
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent double-tap zoom on standard clickable elements */
    touch-action: manipulation;
}

html {
    scroll-behavior: smooth
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
    transition: background-color .3s, color .3s
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: #fff;
    padding: 8px;
    z-index: 9999;
    transition: top .3s
}

.skip-link:focus {
    top: 0
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #fff;
    padding: .8rem 0;
    position: relative;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg)
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    gap: 1rem
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -.5px;
    color: #fff;
    margin: 0
}

.tagline {
    font-size: .9rem;
    opacity: .9;
    margin: 0
}

.nav-menu ul {
    display: flex;
    list-style: none;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0;
    padding: 0
}

.nav-menu a,
.nav-menu button {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: .35rem .7rem;
    border-radius: .375rem;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: transparent;
    display: inline-block;
    font-family: inherit
}

.nav-menu a:hover,
.nav-menu button:hover,
.nav-menu .nav-btn.active,
.nav-menu .nav-cta {
    background: rgba(255, 255, 255, 0.15)
}

.burger-menu {
    display: none;
    font-size: 1.5rem;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer
}

.mobile-menu-header {
    display: none
}

.hero {
    background: linear-gradient(135deg, #4f46e5 0%, #1e1b4b 100%);
    color: #fff;
    padding: 4rem 2rem;
    text-align: center;
    min-height: 400px;
    contain: content;
    position: relative
}

.hero-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 2
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    animation: slideInDown .4s ease-out;
    will-change: transform, opacity
}

@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0
    }

    to {
        transform: translateY(0);
        opacity: 1
    }
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.95;
    animation: slideInUp 0.8s ease-out;
}

.hero-features {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
    animation: fadeIn 1s ease-out 0.3s both;
}

.feature-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.feature-badge:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.feature-badge i {
    font-size: 1.2rem;
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.hero-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.floating-icon {
    position: absolute;
    font-size: 2rem;
    opacity: 0.1;
    animation: float 6s ease-in-out infinite;
    animation-delay: var(--delay);
}

.floating-icon:nth-child(1) {
    top: 20%;
    left: 10%;
}

.floating-icon:nth-child(2) {
    top: 60%;
    right: 15%;
}

.floating-icon:nth-child(3) {
    bottom: 25%;
    left: 20%;
}

.floating-icon:nth-child(4) {
    top: 30%;
    right: 25%;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }

    100% {
        transform: translateY(0px);
    }
}

@media (max-width:768px) {
    .burger-menu {
        display: block
    }

    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0 1rem;
        margin-bottom: 1rem;
    }

    .mobile-menu-title {
        font-size: 1.2rem;
        font-weight: 700;
        color: #fff;
    }

    .mobile-close-btn {
        background: none;
        border: none;
        color: #fff;
        font-size: 1.2rem;
        cursor: pointer;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(30, 27, 75, .98);
        flex-direction: column;
        align-items: center;
        padding: 1rem 0;
        clip-path: circle(0% at 100% 0);
        transition: clip-path .4s ease-in-out;
        backdrop-filter: blur(10px)
    }

    .nav-menu.active {
        clip-path: circle(150% at 100% 0)
    }

    .nav-menu ul {
        flex-direction: column;
        gap: 1rem;
        width: 100%
    }

    .nav-menu li {
        width: 100%;
        text-align: center
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        background: rgba(255, 255, 255, .05);
        transform: none;
        opacity: 1;
        pointer-events: all;
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease
    }

    .dropdown.active .dropdown-content {
        max-height: 500px
    }

    .hero-title {
        font-size: 2rem
    }
}

.calculator-section {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: none;
    animation: fadeIn .5s ease-in-out
}

.calculator-section.active {
    display: block
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.calculator-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 3fr 1fr
}

.calculator-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color)
}

.input-group {
    margin-bottom: 1.5rem
}

.input-group label {
    display: block;
    margin-bottom: .5rem;
    font-weight: 600;
    color: var(--text-dark)
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: .75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color .3s;
    background-color: var(--light-bg);
    color: var(--text-dark)
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1)
}

.btn {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    padding: .75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform .2s, background-color .2s;
    text-align: center;
    text-decoration: none
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px)
}

.btn:active {
    transform: translateY(0)
}

.result-box {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    margin-top: 2rem;
    display: none
}

.result-box.visible {
    display: block;
    animation: scaleIn .3s ease
}

.matrix-input {
    display: grid;
    gap: .5rem;
    margin: 1rem 0;
    justify-content: center
}

.matrix-row {
    display: flex;
    gap: .5rem
}

.matrix-cell {
    width: 60px;
    padding: .5rem;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm)
}

.ad-space {
    margin: 2rem auto;
    text-align: center;
    width: 100%;
    /* CLS Fix: Force rigid box model */
    min-height: 280px !important;
    height: 280px !important;
    overflow: hidden;
    display: block;
    background: #f1f5f9;
    /* Visual placeholder */
}

.ad-container,
ins.adsbygoogle {
    min-height: 280px !important;
    width: 100%;
    display: block !important;
}



.ad-banner {
    min-height: 280px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: .9rem;
    border-radius: var(--radius-md)
}

body.dark-mode {
    --background-color: #0f172a;
    --light-bg: #1e293b;
    --text-dark: #f8fafc;
    --text-light: #cbd5e1;
    --card-bg: #1e293b;
    --border-color: #334155
}

body.dark-mode .ad-banner {
    background: #334155;
    color: #94a3b8
}

.footer {
    background: var(--dark-bg);
    color: #fff;
    padding: 4rem 2rem 2rem;
    margin-top: 4rem
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem
}

.footer h3 {
    margin-bottom: 1.5rem;
    color: var(--accent-color)
}

.footer ul {
    list-style: none
}

.footer li {
    margin-bottom: .8rem
}

.footer a {
    color: #cbd5e1;
    text-decoration: none;
    transition: color .3s
}

.footer a:hover {
    color: var(--accent-color)
}

.social-links {
    display: flex;
    gap: 1rem
}

.social-links a {
    font-size: 1.5rem
}

.footer-bottom {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #334155
}

#backToTop {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-color);
    color: white;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity .3s, transform .3s;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90
}

#backToTop.visible {
    opacity: 1;
    transform: translateY(0)
}

#backToTop:hover {
    transform: translateY(-3px)
}

.trig-tools {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.log-tools {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.power-tools {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.sci-calc-main {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.calculator-card {
    background: #2d2d2d;
    padding: 0;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.calc-display {
    background: #1a1a1a;
    padding: 1.5rem;
    text-align: right;
    border-bottom: 1px solid #404040;
    position: relative;
    /* Added for copy button positioning */
}

.copy-btn-overlay {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 1.5rem;
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.3;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn-overlay:hover {
    opacity: 1;
    color: var(--primary-color);
    transform: translateY(-50%) scale(1.1);
}

.expression-display {
    min-height: 1.5rem;
    color: #888;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.display {
    width: 100%;
    border: none;
    text-align: right;
    background: transparent;
    font-size: 3rem;
    font-weight: 300;
    color: white;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: all 0.3s ease;
}

.display.calculating {
    color: var(--success-color);
}

.display:focus {
    outline: none;
}

/* Memory Buttons Row */
.memory-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
}

.mem-btn {
    padding: 0.75rem;
    border: none;
    background: #2d2d2d;
    color: #a0a0a0;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-right: 1px solid #404040;
}

.mem-btn:last-child {
    border-right: none;
}

.mem-btn:hover {
    background: #404040;
}

/* Main Button Grid */
.button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    background: #2d2d2d;
    padding: 0.5rem;
}

.btn {
    padding: 1.2rem;
    border: 1px solid #404040;
    background: #404040;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 0.375rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    background: #505050;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    background: #505050;
    transform: scale(0.98);
}

.btn-function {
    background: #505050;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.btn-function:hover {
    background: #606060;
}

.btn-operator {
    background: #606060;
    color: white;
}

.btn-operator:hover {
    background: #707070;
}

.btn-equals {
    background: #00d084;
    color: white;
    grid-column: span 1;
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-equals:hover {
    background: #00c074;
}

/* ===========================
   OTHER CALCULATORS STYLES
   =========================== */


.matrix-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.matrix-input-group {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.matrix-input-group label {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.dimension-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dimension-inputs input {
    width: 60px;
    padding: 0.5rem;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    background: var(--light-bg);
    color: var(--text-dark);
}

.quick-sizes {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-xs {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.btn-xs:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.matrices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.matrix-section {
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.matrix-section h4 {
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-weight: 600;
}

.matrix-input-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.matrix-row {
    display: flex;
    gap: 0.5rem;
}

.matrix-input-area input {
    width: 60px;
    height: 40px;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.95rem;
    text-align: center;
    background: white;
    transition: border-color 0.2s;
}

.matrix-input-area input:focus {
    border-color: var(--primary-color);
    background: #f8fafc;
}

/* Operations Panel Styling */
.matrix-operations {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    margin: 2rem 0;
    align-items: center;
}

.primary-ops {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.secondary-ops {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: var(--light-bg);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.utility-ops {
    display: flex;
    gap: 1rem;
}

/* Dark Mode Overrides */
[data-theme="dark"] .btn-xs {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .btn-xs:hover {
    background: var(--primary-color);
    color: white;
}

[data-theme="dark"] .matrix-input-area input {
    background: #0f172a;
    border-color: #334155;
    color: white;
}

/* Clean Matrix Result UI */
.matrix-output-grid {
    display: inline-grid;
    gap: 0.5rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    justify-content: center;
    margin: 1rem auto;
}

.matrix-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 40px;
    background: var(--light-bg);
    border-radius: 0.25rem;
    font-weight: 700;
    color: var(--text-dark);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
}

[data-theme="dark"] .matrix-cell {
    background: #1e293b;
    color: var(--accent-color);
}

.matrix-result-area {
    padding: 2rem;
    background-color: var(--light-bg);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

[data-theme="dark"] .matrix-result-area {
    background-color: #0f172a;
    border-color: #334155;
}

.result-display {
    padding: 1.5rem;
    background-color: #f1f5f9;
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary-color);
    font-size: 1.1rem;
    color: var(--text-dark);
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* ===========================
   CALCULUS CALCULATORS
   =========================== */

.calculus-input {
    margin-bottom: 1.5rem;
}

.calculus-input label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.calculus-input input,
.calculus-input textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
}

.calculus-input small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ===========================
   ADVERTISING LAYOUTS
   =========================== */

.ad-space {
    width: 100%;
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    clear: both;
}

.ad-container {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

/* Horizontal Banner (Leaderboard) */
.ad-banner {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    background-color: rgba(0, 0, 0, 0.02);
    /* Subtle placeholder */
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    border-radius: 0.5rem;
}

/* Sidebar Layout for Content Pages */
.page-with-sidebar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Sidebar Vertical Ad (Skyscraper) */
.ad-sidebar-slot {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
    /* Minimum for rectangle, allows 600px too */
    background-color: rgba(0, 0, 0, 0.02);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    border-radius: 0.5rem;
}

/* Sticky Sidebar Support */
.sidebar-sticky {
    position: sticky;
    top: 100px;
    /* Offset for header */
}

/* Desktop Grid */
@media (min-width: 1024px) {
    .page-with-sidebar {
        grid-template-columns: 1fr 320px;
        /* Content + Wide Sidebar */
        align-items: start;
    }

    .ad-sidebar-slot {
        min-height: 600px;
        /* Encourage vertical ads on desktop */
    }
}



.integral-type {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.integral-type label {
    display: flex;
    align-items: center;
    font-weight: 500;
    cursor: pointer;
}

.integral-type input {
    margin-right: 0.5rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.calculus-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.calculus-buttons .btn {
    padding: 0.8rem 1.5rem;
    background: #404040;
}

.table-container {
    background-color: #f8fafc;
    border-radius: 0.5rem;
    padding: 1.5rem;
    overflow-x: auto;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container th,
.table-container td {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.table-container th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.table-container tr:hover {
    background-color: #e8eef5;
}

/* ===========================
   EQUATION SOLVER
   =========================== */

.equation-type-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.equation-type-selector button {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-dark);
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.equation-type-selector button.active {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    color: white;
}

.equation-type-selector button:hover {
    border-color: var(--primary-color);
}

.equation-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* ===========================
   GRAPH PLOTTER
   =========================== */

.graph-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.graph-controls>div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#canvas {
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    display: block;
    margin: 1.5rem 0;
    background-color: white;
    width: 100%;
    height: auto;
}

/* ===========================
   STATISTICS CALCULATOR
   =========================== */

.stats-input-area {
    margin-bottom: 1.5rem;
}

.stats-input-area textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 120px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.stat-card {
    padding: 1.5rem;
    background-color: #f0f9ff;
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary-color);
}

.stat-card h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-card small {
    display: block;
    color: var(--text-light);
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

/* ===========================
   INFO CARDS
   =========================== */

.calculator-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2.5rem;
}

.info-card {
    padding: 2rem;
    background-color: #f0f9ff;
    border-radius: 0.75rem;
    border-left: 4px solid var(--primary-color);
}

.info-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.info-card p {
    color: var(--text-dark);
    line-height: 1.7;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.info-card ul {
    list-style: none;
    padding-left: 1rem;
}

.info-card li {
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    line-height: 1.6;
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.95rem;
}

.info-card li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

/* ===========================
   ADVERTISEMENT SPACE
   =========================== */

.ad-space {
    margin: 2.5rem auto;
    max-width: 1400px;
    padding: 0 2rem;
}

.ad-container {
    background-color: #f0f0f0;
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-light);
    font-size: 1.2rem;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===========================
   EDUCATIONAL RESOURCES
   =========================== */

.educational-section,
.faq-section {
    max-width: 1400px;
    margin: 4rem auto;
    padding: 0 2rem;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.guide-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border-top: 4px solid var(--primary-color);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.guide-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.guide-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.guide-card h3 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.formula-list p {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    color: var(--text-dark);
    line-height: 1.6;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border-color);
}

.formula-list p:last-child {
    border-bottom: none;
}

.formula-list strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.2rem;
}

/* ===========================
   PRO TIPS SECTION
   =========================== */

.tips-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    padding: 2.5rem;
    border-radius: 1rem;
    margin-top: 3rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.tips-section h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
}

.tip-item {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    font-size: 1rem;
    color: var(--text-dark);
}

.tip-item strong {
    color: var(--primary-color);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===========================
   FAQ SECTION
   =========================== */

.faq-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.faq-item {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.faq-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.faq-question {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.faq-answer {
    color: var(--text-dark);
    line-height: 1.7;
}

@media (max-width: 768px) {

    .educational-section,
    .faq-section {
        padding: 0 1.5rem;
        margin: 3rem auto;
    }

    .faq-container {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   FOOTER
   =========================== */

.footer {
    background: linear-gradient(135deg, var(--dark-bg) 0%, #1e3a8a 100%);
    color: white;
    padding: 3rem 2rem;
    margin-top: 3rem;
}

.coming-soon-list {
    list-style: none;
    opacity: 0.7;
}

.coming-soon-list li {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: default;
}

.coming-soon-list li i {
    font-size: 0.8rem;
    color: var(--accent-color);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.75rem;
}

.footer-section a {
    color: #cbd5e1;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.footer-section a:hover {
    color: var(--accent-color);
    padding-left: 0.5rem;
}

.social-links {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: flex-start;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    /* Pill shape */
    transition: var(--transition);
    font-size: 0.9rem;
}

.social-links a:hover {
    background-color: white;
    color: var(--primary-color);
    transform: translateY(-3px);
}

.social-links i {
    font-size: 1.1rem;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-size: 0.95rem;
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 1024px) {
    .sci-calc-wrapper {
        grid-template-columns: 1fr;
    }

    .equation-form-grid,
    .matrices-grid,
    .calculator-info,
    .matrix-controls,
    .footer-content,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .button-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .graph-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav-menu ul {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-menu button {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .section-header h2 {
        font-size: 1.6rem;
    }



    .btn {
        padding: 0.9rem;
        font-size: 0.9rem;
    }

    .display {
        font-size: 2rem;
    }

    .tool-buttons {
        grid-template-columns: 1fr;
    }

    .sci-tools-panel {
        gap: 1rem;
    }

    .tool-group {
        padding: 1rem;
    }

    .tool-btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    .button-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0;
    }


    .btn {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .nav-menu button {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }

    .display {
        font-size: 1.5rem;
    }

    .memory-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===========================
   ANIMATIONS
   =========================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(10deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.calculator-section.active {
    animation: fadeIn 0.3s ease-in-out;
}

.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ===========================
   FOCUS & ACCESSIBILITY
   =========================== */

.btn:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===========================
   NOTIFICATION SYSTEM
   =========================== */

.notification {
    position: fixed;
    top: -100px;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 10000;
    transition: all 0.3s ease;
    min-width: 300px;
    border-left: 4px solid;
}

.notification.show {
    top: 6rem;
    /* Increased from 2rem to clear the header */
}

.notification i {
    font-size: 1.5rem;
}

.notification-success {
    border-left-color: var(--success-color);
    color: var(--success-color);
}

.notification-success i {
    color: var(--success-color);
}

.notification-error {
    border-left-color: var(--danger-color);
    color: var(--danger-color);
}

.notification-error i {
    color: var(--danger-color);
}

.notification-warning {
    border-left-color: var(--warning-color);
    color: var(--warning-color);
}

.notification-warning i {
    color: var(--warning-color);
}

.notification-info {
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.notification-info i {
    color: var(--primary-color);
}

.notification span {
    color: var(--text-dark);
    font-weight: 500;
}

/* ===========================
   SCROLLBAR STYLING
   =========================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ===========================
   DARK MODE COMPATIBILITY
   =========================== */
[data-theme="dark"] .history-panel {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: var(--light-bg);
    color: var(--text-dark);
    border-color: var(--border-color);
}

[data-theme="dark"] .notification {
    background-color: #1e293b;
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .notification span {
    color: #e2e8f0;
}

[data-theme="dark"] .info-card {
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .info-card h3 {
    color: #818cf8;
    /* Light Indigo */
}

[data-theme="dark"] .info-card strong {
    color: #fbbf24;
    /* Amber */
}

[data-theme="dark"] .result-section h4 {
    color: #e2e8f0;
}

[data-theme="dark"] .matrix-row input {
    background: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] table {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

[data-theme="dark"] th {
    background: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] td {
    border-color: #334155;
}

/* ===========================
   MOBILE NAVIGATION
   =========================== */
.mobile-menu-header {
    display: none;
    /* Hide on desktop */
}

.burger-menu {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
}

@media (max-width: 768px) {
    .burger-menu {
        display: block;
        position: relative;
        z-index: 2000;
        /* Above the overlay */
    }

    /* Side Drawer Container */
    .nav-menu {
        position: fixed;
        top: 0;
        right: 0;
        width: min(320px, 85vw);
        /* Responsive width */
        height: 100vh;
        background: var(--card-bg);
        /* Match theme */
        flex-direction: column;
        align-items: flex-start;
        padding: 0;
        /* Header handles spacing now */
        /* Space for top close button/burger */
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        transform: translateX(100%);
        /* Hide off-screen right */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1500;
        overflow-y: auto;
    }

    /* Internal Mobile Header */
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 1.5rem;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
        background: var(--card-bg);
        position: sticky;
        top: 0;
        z-index: 10;
    }

    [data-theme="dark"] .mobile-menu-header {
        background: #1e293b;
    }

    .mobile-menu-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--primary-color);
        font-family: var(--font-heading);
    }

    .mobile-close-btn {
        background: transparent;
        border: none;
        color: var(--text-light);
        /* High contrast */
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-close-btn:hover {
        color: var(--danger-color);
    }

    [data-theme="dark"] .nav-menu {
        background: #1e293b;
        border-left: 1px solid #334155;
    }

    .nav-menu.active {
        transform: translateX(0);
    }

    /* Backdrop Overlay */
    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1400;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .nav-menu ul {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .nav-menu li {
        width: 100%;
        text-align: left;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-btn {
        width: 100%;
        padding: 1.25rem 0.5rem;
        background: transparent;
        color: var(--text-dark);
        border-radius: 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 1.1rem;
        font-weight: 600;
    }

    .nav-btn:hover,
    .nav-btn.active {
        color: var(--primary-color);
        background: transparent;
    }

    /* Mobile Dropdown Styling - GRID FORMAT */
    .dropdown-content {
        position: static;
        /* Flow naturally */
        background: rgba(99, 102, 241, 0.03);
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
        padding: 1rem;
        display: none;
        /* Hidden by default */
        width: 100%;
        border-radius: 0.5rem;
        opacity: 1;
        visibility: visible;
        transform: none;
        margin-bottom: 1rem;
    }

    .dropdown-content.show {
        display: grid;
        /* Changed to Grid */
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        animation: fadeIn 0.3s ease;
    }

    /* Hide category categories titles on mobile to save space, or style them?
       Let's keep them but make them span full width if needed, or hide for cleaner grid.
       Decision: Hide detailed category text for cleaner simple grid, OR style them as headers.
       Current HTML structure divides by Category divs. We need to handle that.
    */
    .dropdown-category {
        margin-bottom: 0;
        display: contents;
        /* Allow children to be part of the main grid */
    }

    .dropdown-category span {
        display: none;
        /* Hide headings for pure icon grid look, or keep? Let's hide for "Clean" */
    }

    .dropdown-content a {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
        border-radius: var(--radius-md);
        background: white;
        border: 1px solid var(--border-color);
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    }

    [data-theme="dark"] .dropdown-content a {
        background: #0f172a;
        border-color: #334155;
    }

    .dropdown-content a i {
        font-size: 1.2rem;
        color: var(--primary-color);
        margin-right: 0;
        /* Center icon */
    }

    .dropdown-content a:hover {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
        transform: translateY(-2px);
    }

    .dropdown-content a:hover i {
        color: white;
    }

    /* Theme Toggle Position */
    .nav-menu .theme-toggle-btn {
        margin-top: 2rem;
        width: 100%;
        justify-content: center;
        padding: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
    }
}


/* Mobile Layout Refinements (Unstructured Fix) */
@media (max-width: 768px) {

    /* Standardize Padding */
    .header-container,
    .footer-container,
    .hero,
    .main-content,
    .blog-grid,
    .page-with-sidebar {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    /* Tighter Hero Section */
    .hero {
        padding-top: 2.5rem;
        padding-bottom: 2rem;
    }

    .hero-title {
        font-size: 2rem;
        /* Was 2.8rem */
        line-height: 1.2;
    }

    /* Better Spacing for Grids */
    /* Better Spacing for Grids */
    .calculator-grid,
    .blog-grid,
    .formula-grid {
        gap: 1.5rem;
        /* Ensure consistent gap */
        grid-template-columns: 1fr;
        /* Force 1 column for clean stack */
    }

    /* Scientific Calculator Stack (Main Calc First) */
    .sci-calc-wrapper {
        display: flex;
        flex-direction: column-reverse;
        /* Keypad on TOP */
        gap: 2rem;
    }

    /* Footer Layout */
    .footer-container {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }

    .footer-section {
        width: 100%;
        max-width: 100%;
        /* Reset max-width */
    }

    .footer-section h3 {
        margin-bottom: 1rem;
    }

    .footer-bottom {
        margin-top: 2rem;
        padding-top: 1.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* ===========================
   LOADING STATES
   =========================== */

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.result-section {
    min-height: 80px;
}

/* ===========================
   ENHANCED CARD EFFECTS
   =========================== */

.info-card,
.stat-card {
    transition: all 0.3s ease;
}

.info-card:hover,
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2);
}

.calculator-card {
    transition: all 0.3s ease;
}

.calculator-card:hover {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
}

/* ===========================
   MODERN TRIGONOMETRY UI
   =========================== */

/* Triangle Solver Container */
.triangle-solver {
    background: var(--card-bg);
    /* Use card background */
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

/* Add a subtle top border gradient */
.triangle-solver::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.triangle-solver h3 {
    margin-bottom: 1.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.triangle-solver h3 i {
    color: var(--primary-color);
}

/* Modern Input Grid */
.triangle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    position: relative;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-color);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* Modern Focus State */
.input-group input:focus {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    outline: none;
    transform: translateY(-2px);
}

/* Buttons */
.calculus-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.calculus-buttons .btn {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.calculus-buttons .btn:first-child {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.calculus-buttons .btn:last-child {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-muted);
}

.calculus-buttons .btn:hover {
    transform: translateY(-2px);
}

/* Result Section */
.result-section {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-color);
}

.result-section h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.triangle-visual {
    background: white;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}

/* 51 Identities Table Styling */
.identities-section {
    margin-top: 3rem;
}

.identities-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.identity-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.identity-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.identity-card h4 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
}

.identity-card p {
    background: rgba(99, 102, 241, 0.05);
    /* Very subtle tint */
    color: var(--text-main);
    border-left: 3px solid rgba(99, 102, 241, 0.2);
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-family: 'Outfit', monospace;
    font-size: 0.95rem;
}

/* ===========================
   EDUCATIONAL CONTENT STYLES
   =========================== */

.educational-guide {
    max-width: 900px;
    width: 100%;
    margin: 4rem auto 2rem;
    padding: 0 1.5rem;
    color: var(--text-dark);
    clear: both;
    position: relative;
    z-index: 10;
}

.content-block {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    text-align: left;
}

.content-block h3 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    text-align: left;
}

.content-block h4 {
    font-size: 1.4rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.content-block h5 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.content-block p {
    line-height: 1.8;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.formula-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.math-display {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 1.1rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
    text-align: center;
}

[data-theme="dark"] .math-display {
    background: rgba(255, 255, 255, 0.1);
}

.formula-box-simple {
    background: var(--card-bg);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    margin: 1rem 0;
    box-shadow: var(--shadow-sm);
}

.small-text {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* ===========================
   SIDEBAR & GRID LAYOUT
   =========================== */
.page-with-sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    max-width: 100%;
    /* Allow full width */
    margin: 3rem auto;
    padding: 0 1rem;
    align-items: flex-start;
}

/* Ensure Grid works inside the flex item */
.page-with-sidebar>main.blog-grid,
.blog-grid {
    flex: 1;
    /* Take remaining space */
    min-width: 0;
    display: grid;
    /* This creates the "5 in a row" look on large screens */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Sidebar Area */
.sidebar {
    width: 300px;
    /* Fixed width for sidebar */
    flex-shrink: 0;
}

.sidebar-sticky {
    position: sticky;
    top: 100px;
}

.ad-sidebar-slot {
    background: var(--card-bg);
    min-height: 250px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 1rem;
}

/* Responsive: Stack on mobile */
@media (max-width: 1100px) {
    .page-with-sidebar {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

/* ===========================
   BLOG ARTICLE CONTENT
   =========================== */

.article-content {
    margin-top: 2rem;
}

.article-content p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-dark);
}

.article-content h3 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.3;
}

.article-content h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
    color: var(--text-dark);
}

.article-content li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.article-content strong {
    color: var(--text-dark);
}

.article-content .formula-box {
    background: var(--card-bg);
    padding: 1.5rem;
    border-left: 4px solid var(--primary-color);
    margin: 2rem 0;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    border-radius: 0 0.5rem 0.5rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===========================
   NAVIGATION DROPDOWNS
   =========================== */

/* Dropdown Container */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Dropdown Content (Hidden by Default) */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--card-bg);
    min-width: 450px;
    /* Wide dropdown for categories */
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* Custom animation to preserve translateX(-50%) for centering */
@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Show Dropdown on Hover */
.dropdown:hover .dropdown-content {
    display: grid;
    animation: fadeInDropdown 0.2s ease-out;
}

/* Dropdown Links */
.dropdown-content a {
    color: var(--text-dark);
    padding: 0.5rem 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-size: 0.95rem;
    border-radius: 0.375rem;
}

.dropdown-content a:hover {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    padding-left: 0.5rem;
}

.dropdown-content i {
    width: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

.dropdown-content a:hover i {
    color: var(--primary-color);
}

/* Dropdown Categories */
.dropdown-category {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.dropdown-category span {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

/* Active Dropdown Parent */
.dropbtn.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.dropbtn i {
    font-size: 0.8rem;
    margin-left: 0.2rem;
    opacity: 0.7;
}

/* Mobile Dropdown Adjustments */
@media (max-width: 768px) {
    .dropdown {
        width: 100%;
        text-align: center;
    }

    .dropdown:hover .dropdown-content {
        display: none;
        /* Disable hover on mobile */
    }

    /* We need JS or a different approach for click-to-open on mobile, 
       but for now let's make it always expanded or stacked if active. 
       Actually, common pattern is to just list them. 
       For this implementation, let's create a mobile-specific view manually or auto-expand. 
       Better approach: Make the dropdown content relative and flat on mobile if active. */

    .dropdown.active .dropdown-content {
        display: flex;
        flex-direction: column;
        position: static;
        box-shadow: none;
        background: transparent;
        border: none;
        transform: none;
        padding: 0.5rem;
        min-width: 100%;
        gap: 1rem;
    }

    .dropdown-content {
        /* On mobile, we might want to hide it initially and use JS to toggle, 
           or just list everything since "Calculators" is clicked. 
           Current solution: Simple stack for now. */
        display: none;
        /* Hidden by default */
        position: static;
        width: 100%;
        min-width: 0;
        transform: none;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.05);
        grid-template-columns: 1fr;
        padding: 1rem;
        text-align: left;
    }

    .dropdown:focus-within .dropdown-content,
    .dropdown:active .dropdown-content {
        /* CSS-only toggle for mobile touch */
        display: flex;
        flex-direction: column;
    }

    /* Ensure category headers are visible */
    .dropdown-category span {
        color: var(--text-dark);
        opacity: 0.8;
    }
}

/* Animation Keyframes */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes float {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(5deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

/* ===========================
   SCIENTIFIC CALCULATOR - WINDOWS STYLE
   =========================== */

.history-panel {
    max-width: 1200px;
    margin: 0 auto 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-header h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-history-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-history-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    background: var(--card-bg);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideInRight 0.3s ease-out;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-md);
}

.history-expression {
    color: var(--text-light);
    font-size: 0.9rem;
}

.history-result {
    color: var(--text-dark);
    font-weight: 700;
    font-size: 1.1rem;
}

.sci-calc-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.sci-tools-panel {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.tool-group {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.tool-group h3 {
    color: white;
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-group i {
    font-size: 1.2rem;
}

.tool-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

.theme-toggle-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.35rem 0.7rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    border-color: white;
}

.tool-btn {
    padding: 0.6rem;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-dark);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
}

.tool-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tool-btn:active {
    transform: scale(0.98);
}

.trig-tools {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.log-tools {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.power-tools {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

}

/* DARK MODE OVERRIDES */
[data-theme="dark"],
body.dark-mode {
    --light-bg: #0f172a;
    --card-bg: #1e293b;
    --text-dark: #f1f5f9;
    --text-light: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ===========================
   FINAL MOBILE OVERRIDES
   =========================== */
@media (max-width: 768px) {

    /* Force Scientific Calculator Stack */
    .sci-calc-wrapper {
        display: flex !important;
        flex-direction: column-reverse !important;
        /* Keypad on TOP */
        gap: 2rem;
        width: 100%;
    }

    /* Additional safety for tool panels */
    .sci-tools-panel {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .sci-calc-main {
        width: 100%;
    }
}

/* ========================================
   More Calculators Section
   ======================================== */
.more-calculators-section {
    max-width: 1200px;
    margin: 4rem auto;
    padding: 3rem 2rem;
    background: linear-gradient(to right, #f8fafc, #edf2f7);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

body.dark-mode .more-calculators-section {
    background: linear-gradient(to right, #1e293b, #0f172a);
}

.more-calculators-section .section-header {
    margin-bottom: 2.5rem;
}

.more-calculators-section h2 {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.more-calculators-section .section-description {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.more-calcs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    text-align: left;
}

.more-calc-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.more-calc-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.more-calc-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.more-calc-card:hover::before {
    opacity: 1;
}

.more-calc-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.more-calc-content {
    flex: 1;
}

.more-calc-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-dark);
}

.more-calc-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.more-calc-arrow {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    opacity: 0.7;
    transition: all 0.3s ease;
}

.more-calc-card:hover .more-calc-arrow {
    opacity: 1;
    background: var(--primary-color);
    color: white;
    transform: translateX(5px);
}

@media (max-width: 768px) {
    .more-calculators-section {
        padding: 2rem 1rem;
        margin: 2rem auto;
    }

    .more-calcs-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Blog Section Styles
   ======================================== */
.blog-header {
    text-align: center;
    padding: 4rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    margin-top: 0;
    margin-bottom: 2rem;
}

.blog-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.blog-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    max-width: 1400px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

.blog-card {
    background: var(--card-bg);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.blog-image {
    height: 180px;
    background: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 3rem;
    overflow: hidden;
}

.blog-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.blog-content {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.blog-tag {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.blog-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    line-height: 1.4;
}

.blog-excerpt {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    flex-grow: 1;
}

.read-more {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.read-more:hover {
    gap: 0.75rem;
}

/* Dark Mode Overrides */
[data-theme="dark"] .blog-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .blog-title {
    color: #f1f5f9;
}

[data-theme="dark"] .blog-image {
    background: #334155;
    color: #94a3b8;
}

/* ========================================
   Share Section Styles
   ======================================== */
.share-section {
    max-width: 1200px;
    margin: 4rem auto;
    padding-top: 2rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.share-section h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--text-dark);
}

.share-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: transform 0.2s, opacity 0.2s;
    font-size: 0.95rem;
}

.share-btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
    color: white;
}

.share-btn.twitter {
    background-color: #1DA1F2;
}

.share-btn.facebook {
    background-color: #4267B2;
}

.share-btn.whatsapp {
    background-color: #25D366;
}

/* ========================================
   Fix Spacing Issues
   ======================================== */
.section-header {
    margin-bottom: 2rem;
}


.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* ========================================
   MOBILE BOTTOM NAVIGATION
   ======================================== */
.mobile-bottom-nav {
    display: none;
    /* Hidden on desktop */
}

.mobile-drawer {
    display: none;
}

.mobile-drawer-overlay {
    display: none;
}

@media (max-width: 768px) {

    /* Hide Old Burger Menu */
    .burger-menu {
        display: none !important;
    }

    /* Hide Desktop Nav (just in case) */
    .nav-menu {
        display: none !important;
    }

    /* Bottom Nav Bar */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        z-index: 2000;
        padding-bottom: env(safe-area-inset-bottom);
        height: 60px;
        align-items: center;
        justify-content: space-around;
    }

    .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-light);
        gap: 4px;
        padding: 8px 0;
        cursor: pointer;
        text-decoration: none;
        font-size: 0.75rem;
    }

    .nav-item i {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .nav-item.active,
    .nav-item:hover {
        color: var(--primary-color);
    }

    /* Drawers */
    .mobile-drawer {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--card-bg);
        z-index: 2001;
        border-radius: 1.5rem 1.5rem 0 0;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
        transform: translateY(110%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        max-height: 80vh;
        overflow-y: auto;
        padding-bottom: 2rem;
    }

    .mobile-drawer.active {
        transform: translateY(0);
    }

    .drawer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        background: var(--card-bg);
    }

    .drawer-header h3 {
        margin: 0;
        font-size: 1.2rem;
    }

    .drawer-header button {
        background: none;
        border: none;
        font-size: 1.2rem;
        color: var(--text-light);
        padding: 0.5rem;
    }

    .drawer-content {
        padding: 1rem;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    /* Full width for menu items */
    #mobile-main-drawer .drawer-content {
        grid-template-columns: 1fr;
    }

    .drawer-link {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem;
        background: var(--background-color);
        border-radius: 0.75rem;
        text-decoration: none;
        color: var(--text-dark);
        font-weight: 500;
        transition: background 0.2s;
    }

    .drawer-link:active {
        background: rgba(79, 70, 229, 0.1);
    }

    .drawer-link i {
        color: var(--primary-color);
        width: 20px;
        text-align: center;
    }

    /* Overlay */
    .mobile-drawer-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 2000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
        backdrop-filter: blur(2px);
    }

    .mobile-drawer-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Ads adjustment for bottom nav */
    body {
        padding-bottom: 70px;
    }

    /* Fix Cookie Banner Overlap with Bottom Nav */
    #cookie-banner {
        bottom: 70px !important;
        /* Clear the 60px bottom nav */
        flex-direction: column !important;
        align-items: stretch !important;
        z-index: 2001 !important;
        /* Above bottom nav */
    }
}

/* ========================================
   MOBILE BLOG COMPACT LAYOUT
   ======================================== */
@media (max-width: 768px) {
    .blog-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        padding: 0 1rem;
    }

    .blog-card {
        flex-direction: row;
        /* Horizontal layout */
        height: 120px;
        /* Fixed compact height */
        align-items: center;
    }

    .blog-image {
        width: 120px;
        /* Fixed square width */
        height: 100%;
        /* Full height of card */
        flex-shrink: 0;
        /* Don't shrink */
        border-radius: 0;
        /* Remove corner radius on inner side if needed */
    }

    .blog-content {
        padding: 0.75rem;
        justify-content: center;
        overflow: hidden;
    }

    .blog-tag {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }

    .blog-title {
        font-size: 1rem;
        margin-bottom: 0.25rem;
        /* Limit to 2 lines */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        line-height: 1.3;
    }

    .blog-excerpt {
        display: none;
        /* Hide excerpt on mobile for compactness */
    }

    .read-more {
        font-size: 0.8rem;
        margin-top: 0;
    }
}

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */
@media (max-width: 768px) {

    /* Scale down main headings */
    h1,
    .hero-title,
    .blog-header h1 {
        font-size: 2rem !important;
        /* Approx 32px */
    }

    h2,
    .section-header h2 {
        font-size: 1.5rem !important;
        /* Approx 24px */
    }

    /* Refine Blog Card Text for Side-by-Side */
    .blog-title {
        font-size: 0.95rem;
        /* Slightly smaller for mobile list */
        line-height: 1.3;
    }

    /* Load More Button Mobile Style */
    #load-more-btn {
        width: 100%;
        padding: 1rem;
        margin-top: 1rem;
        background: var(--card-bg);
        /* Use card style, less obtrusive */
        color: var(--primary-color);
        border: 1px solid var(--border-color);
    }
}

/* ========================================
   ABOUT US PAGE STYLES
   ======================================== */
.about-section {
    max-width: 1000px;
    margin: 4rem auto;
    padding: 0 1.5rem;
}

.about-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.about-header {
    text-align: center;
    margin-bottom: 3rem;
}

.about-title {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.about-intro {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 800px;
    margin: 0 auto 3rem;
    line-height: 1.6;
}

.about-image-container {
    margin: 0 auto;
    max-width: 800px;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.about-image-container img {
    width: 100%;
    height: auto;
    display: block;
}

.about-content h2 {
    color: var(--text-dark);
    font-size: 1.8rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

.about-content p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    color: var(--text-dark);
    font-size: 1.1rem;
}

.about-content ul {
    list-style-type: disc;
    padding-left: 2rem;
    margin-bottom: 1.5rem;
}

.about-content li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Mobile Optimizations for About Us */
@media (max-width: 768px) {
    .about-section {
        margin: 1rem auto;
        /* Reduced from 4rem */
        padding: 0 1rem;
    }

    .about-card {
        padding: 1.5rem;
        /* Reduced from 3rem */
        border: none;
        /* Remove border for cleaner mobile look */
        box-shadow: none;
        /* Remove shadow to reduce visual noise */
        background: transparent;
        /* Seamless blend */
    }

    .about-header {
        margin-bottom: 2rem;
    }

    .about-title {
        font-size: 2rem;
        /* Smaller title */
        margin-bottom: 1rem;
    }

    .about-intro {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .about-content h2 {
        font-size: 1.5rem;
        /* Smaller headers */
        margin-top: 2rem;
        margin-bottom: 1rem;
    }

    .about-content p {
        font-size: 1rem;
        margin-bottom: 1rem;
        text-align: left;
        /* Ensure readability */
    }
}