* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

body {
    background: linear-gradient(to right, #eef2f3, #e0ecff);
}

/* ================= CALCULATOR ================= */
.calculator {
    width: 400px;
    height: 560px;
    background: rgb(52, 25, 204);
    padding: 22px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgb(52, 25, 204);
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}



/* ================= DISPLAY CONTAINER ================= */
.display-container {
    position: relative;
    width: 100%;
}

/* THE TICKING CURSOR (The vertical line) */
.display-container::after {
    content: "";
    position: absolute;
    /* Uses JS calculation to stay at the end of Segoe UI text */
    left: calc(10px + var(--cursor-pos, 0px)); 
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background-color: rgb(7, 24, 255);
    animation: blink-cursor 1s step-end infinite;
    pointer-events: none;
    display: block;
}

/* Hide cursor when showing answer */
.display-container:has(#display.show-result)::after {
    display: none !important;
}

@keyframes blink-cursor {
    50% { opacity: 0; }
}

/* ================= DISPLAY INPUT ================= */
#display {
    width: 100%;
    height: 80px;
    font-size: 30px;
    padding: 10px;
    border: 3px solid #00008b;
    margin-bottom: 12px;
    background: rgba(233, 233, 233, 0.945);
    border-radius: 8px;
    text-align: left;
    overflow: hidden;
    text-overflow: clip;
    /* Block real cursor to prevent mobile keyboard */
    caret-color: transparent !important;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    line-height: 54px; /* Adjusting for the 10px padding + 3px border */
}

/* ================= HISTORY BUTTON ================= */
#historyBtn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 14px;
    border-radius: 10px;
    border: none;
    background: rgb(238, 255, 0);
    cursor: pointer;
}

/* ================= HISTORY BOX ================= */
#historyBox {
    background: lightgreen;
    border: 2px solid #00008b;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 14px;
    max-height: 130px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
}

#historyBox div {
    padding: 8px;
    border-bottom: 1px solid #00008b;
    font-size: 14px;
    word-break: break-word;
    cursor: pointer;
}

#historyBox div:last-child { border-bottom: none; }

#historyBox div:hover,
#historyBox div:active {
    background: rgba(0,0,0,0.1);
}

#historyBox button {
    width: auto;
    padding: 4px 8px;
    font-size: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
}

/* ================= BUTTON GRID ================= */
.buttons {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    overflow: hidden;
}

/* ================= BUTTONS ================= */
button {
    border: none;
    border-radius: 8px;
    background: #00D4FF;
    color: black;
    font-size: 22px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

/* Press effect and highlight */
button:active {
    transform: scale(0.92);
    background-color: rgba(0, 0, 0, 0.15) !important;
}

.operator { background: #00008b; color: white; }
.control { background: #b211da; color: white; }
.equal { background: #06d65d; color: black; }
.ans { background: #ff9800; color: black; }
.special { background: #444; color: white; }

.calculator.history-open button { font-size: 14px; }

/* ================= RESULT & MOBILE ================= */
.show-result {
    text-align: right !important;
    font-weight: bold;
    color: #1a237e;
}

@media (max-width: 768px) {
    .calculator {
        width: 100%;
        max-width: 100%;
        height: 560px;
        margin: 20px auto; /* keep it centered */
    }
}



#suggestions:has(*) ~ .calc-type-header {
    display: none !important;
}
.calc-type-header.hide-on-search {
    display: none !important;
}

/* ==========================================
   DESKTOP / STANDARD FOOTER STYLES
   ========================================== */
.math-footer {
  background: #0d1b2a; 
  color: #e0e1dd;      
  font-family: 'Segoe UI', sans-serif;
  padding: 60px 40px 30px; 
  border-top: 4px solid #1b263b;
  /* FIXED: Safely stretches edge-to-edge on PC without breaking layout or causing scrollbar bugs */
  width: 100%;
  box-sizing: border-box;
  margin-top: 100px; 
}

.footer-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
  gap: 50px; 
  margin-bottom: 40px; 
}

.footer-column h3 {
  color: #ffffff; 
  margin-top: 0; 
  margin-bottom: 20px; 
  font-size: 1.5rem; 
  padding-bottom: 5px;
}

.footer-column p {
  font-size: 0.95rem;
  line-height: 1.6; 
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column ul li {
  margin: 12px 0; 
}

/* Base link setup for PC */
.footer-column ul li a {
  color: #00c3ff;        
  text-decoration: none; 
  font-weight: 500;      
  display: inline-block; 
  transition: color 0.2s ease, transform 0.2s ease;
}

/* HOVER EFFECT: Turns bright teal-green and grows larger */
.footer-column ul li a:hover {
  color: #00ffcc;          
  transform: translateX(5px);  
  text-decoration: none;   
}

.footer-bottom {
  text-align: center;
  font-size: 1.5rem; /* Enlarged copyright text on PC */
  border-top: 1px solid #1b263b;
  padding-top: 25px; 
  color: #d1d5db; /* Brighter off-white/light gray instead of deep grey */
}

/* ==========================================
   RESPONSIVE ADJUSTMENTS FOR MOBILE DEVICES
   ========================================== */
@media (pointer: coarse), (max-width: 900px) {
  .math-footer {
    width: 100%;
    padding: 35px 15px; 
    box-sizing: border-box;
    margin-top: 60px; 
  }

  .footer-column p,
  .footer-column h3,
  .footer-column:nth-child(3) { 
    display: none !important;
  }

  .footer-container {
    display: flex;
    justify-content: center; 
    margin-bottom: 30px; 
    gap: 0;
  }

  .footer-column ul {
    display: grid;
    grid-template-columns: 1fr auto 1fr; 
    align-items: center;
    padding: 0;
    margin: 0;
    width: 100%; 
  }

  .footer-column ul li {
    margin: 0;
    display: flex;
    align-items: center;
    position: relative;
  }

  /* 1. HOME ADJUSTMENT (Left Column) */
  .footer-column ul li:nth-child(1) {
    display: flex;
    justify-content: flex-start; /* Aligns left edge */
    width: 100%;
    margin-left: -5px; /* INCREASE THIS to manually push Home further right */
  }

  /* 2. PRIVACY (Dead-centered Column - Adjustable Shift) */
  .footer-column ul li:nth-child(2) {
    justify-self: center; 
    /* MANUAL CONTROL FOR PRIVACY: */
    /* Use a negative number (-5px) to shift left. Use a positive number (5px) to shift right. */
    transform: translateX(-10px); 
  }


  /* 3. CONTACT US ADJUSTMENT (Right Column) */
  .footer-column ul li:nth-child(3) {
    display: flex;
    justify-content: flex-end; /* Aligns right edge */
    width: 100%;
    margin-right: 50px; /* INCREASE THIS to manually push Contact Us further left */
  }

  .footer-column ul li a {
    font-size: 1rem; 
    color: #00c3ff !important; 
    text-decoration: none !important;
    font-weight: 500; 
    transform: none !important; 
    transition: color 0.1s ease; 
    white-space: nowrap; /* Prevents "Contact Us" from breaking onto two lines when pushed */
  }

  /* GREEN FEEDBACK WHEN PRESSED (MOBILE) */
  .footer-column ul li a:active {
    color: #00ffcc !important; 
  }

  .footer-bottom {
    border-top: 1px solid #1b263b;
    padding-top: 20px;
    display: flex;
    flex-direction: column; 
    gap: 8px;
    font-size: 0.9rem; 
    color: #8d99ae; 
  }

  .footer-bottom p {
    margin: 0;
  }
}
/* ==========================================================================
   FORCE CALCULATOR DISPLAY TO DARK SCREEN WITH PURE WHITE NUMBERS & NO CURSOR
   ========================================================================== */

/* 1. Targets your exact #display input element under dark theme attributes */
:root[data-theme="dark"] #display,
:root[data-theme="dark"] .container #display,
body.grey #display,
body.grey .container #display,
body.dark #display {
    background-color: #010120 !important; /* Forces screen to pitch black */
    background:#010120 !important;
    color: #c8e4fc !important;            /* Forces numbers to pure white */
    
    /* THE FIX: Completely strips out the blue/white blinking text cursor */
    caret-color: transparent !important;  
    
    border: 2px solid #334155 !important; /* Clean dark border framing */
    
    /* Precision alignment: keeps numbers centered */
    letter-spacing: normal !important;
    line-height: normal !important;
    font-size: 2.4rem !important;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
    height: auto !important;
}

/* Extra insurance: Disables user selection/highlight blue outlines on the input box */
:root[data-theme="dark"] #display:focus,
body.grey #display:focus {
    outline: none !important;
    box-shadow: none !important;
    caret-color: transparent !important;
}

/* 2. Forces text strings inside the history panel dropdown to be written in black */
[class*="history"] *,
[id*="history"] *,
.show-history-panel *,
[style*="background-color"] + div[style*="overflow-y"] * {
    color: #000000 !important;
}
/* ==========================================================================
   FORCE REMOVE SIMULATED BLUE CURSOR IN DARK THEME
   ========================================================================== */

/* Completely removes the CSS-generated pseudo-element cursor across dark modes */
:root[data-theme="dark"] .display-container::after,
body.grey .display-container::after,
body.dark .display-container::after {
    display: none !important;
    content: none !important;
}
/* Base container wrapper */
.donation-card-container {
    width: 100%;
    max-width: 1100px; /* Aligns with your main body text block */
    margin: 0 auto;
    padding: 10px 20px 45px 20px; /* Pads nicely right above the footer */
    box-sizing: border-box;
}

/* Light Mode Card Design */
.donation-card {
    background-color: #ffffff; /* Clean pure white background */
    border: 2px solid #e2e8f0; /* Sharp, visible light border boundary */
    border-radius: 10px;
    padding: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); /* Premium, modern lift effect */
}

/* High-Visibility Typography */
.donation-content h3 {
    color: #1e3a8a; /* Deep, authoritative dark blue headline */
    font-family: sans-serif;
    font-size: 1.4rem; /* Prominent size for clarity */
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.donation-content p {
    color: #334155; /* Ultra-clear, dark slate gray for maximum text readability */
    font-family: sans-serif;
    font-size: 1rem; /* Standard comfortable reading size */
    line-height: 1.6; /* Breathing room for easy reading */
    margin: 0;
    max-width: 750px; /* Prevents text lines from stretching too long */
}

/* Eye-Catching Button Design */
.coffee-btn {
    display: inline-block;
    background-color: #f59e0b; /* Bright golden amber to stand out instantly */
    color: #000000; /* High-contrast black text on gold */
    text-decoration: none;
    font-family: sans-serif;
    font-weight: 700;
    font-size: 1rem;
    padding: 14px 28px;
    border-radius: 6px;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.coffee-btn:hover {
    background-color: #d97706; /* Richer gold tone on cursor hover */
    transform: translateY(-1px); /* Subtle premium interaction effect */
}

/* Flawless responsive layout layout for mobile screens */
@media (max-width: 768px) {
    .donation-card {
        flex-direction: column; /* Stacks text and button vertically on phones */
        text-align: center;
        padding: 24px;
        gap: 20px;
    }
    
    .donation-content p {
        font-size: 0.95rem; /* Micro-adjustment for mobile readability */
    }
    
    .coffee-btn {
        width: 100%; /* Stretches button wide for easy thumb tapping */
        box-sizing: border-box;
    }
}
/* =================================================
   DARK THEME DONATION CARD
================================================= */

/* Container adaptation */
:root[data-theme="dark"] .donation-card {
    background-color: #0b1329 !important; /* Deep dark slate to blend with the footer */
    border: 2px solid #1e293b !important; /* Muted dark border line */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6) !important; /* Stronger shadow for dark background depth */
}

/* Heading color */
:root[data-theme="dark"] .donation-content h3 {
    color: #2fbdff !important; /* Uses your signature neon blue heading color */
}

/* Paragraph text color */
:root[data-theme="dark"] .donation-content p {
    color: #94a3b8 !important; /* Soft, accessible gray to reduce eye strain */
}

/* Golden Amber Button Tweaks */
:root[data-theme="dark"] .coffee-btn {
    background-color: #f59e0b !important; /* Keeps the high-visibility gold */
    color: #000000 !important; /* Keeps the deep black text contrast */
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3) !important; /* Gives the gold button a faint glowing lift */
}

:root[data-theme="dark"] .coffee-btn:hover {
    background-color: #fbbf24 !important; /* Slightly brighter gold on hover for responsive dark feedback */
}
/* =================================================
   ANTI-HORIZONTAL SCROLL SAFETY SHIELD
================================================= */
html, body {
    max-width: 100% !important;
    overflow-x: hidden !important;
}
/* =================================================
   TABLET & IPAD VIEWPORT NAV BAR FIX (769px - 1024px)
================================================= */
@media screen and (min-width: 769px) and (max-width: 1024px) {

    /* 🔴 STOP ALL HORIZONTAL SCROLL */
    body {
        overflow-x: hidden !important;
    }

    /* 🔴 FIX NAVBAR SCROLLING & BOUNDARIES */
    .navbar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 10px 10px !important;   
        gap: 5px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important; 
        position: relative !important; 
    }

    /* 🔴 HAMBURGER */
    .hamburger {
        display: block !important;
        margin-right: 5px !important;
        cursor: pointer !important;
    }

    /* 🔴 DROPDOWN CLOSE TO HAMBURGER */
    .dropdown {
        margin-left: 0 !important;
    }

    .dropbtn {
        font-size: 18px !important;   
        padding: 10px 12px !important;
    }

    /* 🔴 FORCE SEARCH TO FIT */
    .search-group {
        margin-left: auto !important;
        display: flex !important;
        align-items: center !important;
        max-width: 45% !important; 
    }

    /* 🔴 SEARCH INPUT FIX */
    .search-wrapper {
        width: 100% !important;
        max-width: 160px !important; 
        position: relative !important;
    }

    .search-wrapper:focus-within {
        width: 100% !important;
        max-width: 190px !important;
    }

    /* 🔴 REMOVE BUTTON */
    .modern-search-btn {
        display: none !important;
    }

    /* 🔴 HIDE DESKTOP LINKS */
    .desktop-only {
        display: none !important;
    }

    /* NAVBAR TEXT SIZES */
    .navbar a,
    .dropbtn {
        font-size: 15px !important;
    }

    /* SEARCH INPUT TEXT */
    #topicSearch {
        font-size: 14px !important;
    }

    /* SEARCH SUGGESTIONS TEXT */
    .suggestions-dropdown a {
        font-size: 14px !important;
    }

    /* =================================================
       🔥 FIXED: HAMBURGER DROP-DOWN MENU (LIGHT & DARK THEMES)
    ================================================= */
    .mobile-menu {
        display: none !important; 
        position: absolute !important;
        top: 100% !important; 
        left: 10px !important;          
        width: 250px !important;        
        flex-direction: column !important;
        padding: 5px 0 !important;
        z-index: 999999 !important; 
        border-radius: 8px !important;
        
        /* Default: Clean Light Mode Look */
        background-color: #ffffff !important; 
        border: 1px solid #ccd6f6 !important;
        box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
    }

    .mobile-menu.show {
        display: flex !important;
    }

    /* Default Light Mode Link Colors */
    .mobile-menu a {
        display: block !important;
        width: 100% !important;
        padding: 12px 20px !important;
        box-sizing: border-box !important;
        text-decoration: none !important;
        text-align: left !important;
        font-size: 15px !important;
        font-weight: bold !important;
        color: #0b192c !important; /* Dark text for crisp light visibility */
        border-bottom: 1px solid #f0f4f8 !important;
    }
    
    .mobile-menu a:hover {
        background-color: #f0f4f8 !important;
    }

    /* 🌓 Dark Mode Overrides for Hamburger Dropdown */
    :root[data-theme="dark"] .mobile-menu {
        background-color: #010120 !important; 
        border: 2px solid rgba(85, 223, 247, 0.4) !important;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5) !important;
    }

    :root[data-theme="dark"] .mobile-menu a {
        color: #c8e4fc !important;
        border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    }
    
    :root[data-theme="dark"] .mobile-menu a:hover {
        background-color: rgba(85, 223, 247, 0.1) !important;
    }

    /* =================================================
       🔥 FIXED: THEME TOGGLE BUTTON CLEAR PLACEMENT & COLORS
    ================================================= */
    .theme-toggle {
        position: absolute !important;
        right: 8px !important;        
        top: -37px !important; /* Safely clears the title header spacing zone completely */
        z-index: 99999 !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        
        /* Crisp High-Visibility Styling for Light Mode */
        padding: 8px 18px !important;
        min-width: 110px !important;
        text-align: center !important;
        border: 2px solid #00008b !important;
        border-radius: 40px !important;
        background: #00008b !important;
        color: #ffffff !important;
        font-weight: 800 !important;
        font-size: 11px !important;
        letter-spacing: 0.8px !important;
        text-transform: uppercase !important;
        box-shadow: 0 4px 12px rgba(0, 0, 139, 0.3) !important;
    }

    /* High-Visibility Styling for Dark Mode */
    :root[data-theme="dark"] .theme-toggle {
        background: linear-gradient(135deg, #00b8ff, #0077ff) !important;
        border: none !important;
        color: #000000 !important;
        font-weight: 900 !important;
        box-shadow: 0 0 15px rgba(0, 184, 255, 0.5) !important;
    }
}
    /* =================================================
       🔥 HIDE TOGGLE BUTTON ONLY WHEN SEARCHING
    ================================================= */
    /* When the search input is focused, hide the theme button so it never overlaps the dropdown suggestions */
    :root:has(#topicSearch:focus) .theme-toggle {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
