﻿/* Google Fonts — must be first rule in CSS file */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&display=swap');

#holidayListContainer,
#addSubHolidayListContainer {
    border: none !important;
    box-shadow: none !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    border-radius: 0 !important;
    text-align: left !important;
}

#holidayListContainer .age-checkbox,
#addSubHolidayListContainer .age-checkbox {
    justify-content: flex-start !important;
    text-align: left !important;
}

#holidayOptionsDropdown,
#holidayOptionsDropdown *,
#addSubBusinessOptionsDropdown,
#addSubBusinessOptionsDropdown * {
    background: #f8fafc !important;
    box-shadow: none !important;
}

/* Make radio options in holiday dropdown match holiday list background */
#holidayOptionsDropdown .age-radio,
#addSubBusinessOptionsDropdown .age-radio {
    background: #f8fafc !important;
    border-radius: 6px;
    box-shadow: none !important;
}

/* Mobile-specific: left-align holiday checkboxes in the holiday list */
@media (max-width: 600px) {

    #holidayListContainer>div,
    #addSubHolidayListContainer>div {
        justify-items: start !important;
        text-align: left !important;
    }

    #holidayListContainer label.age-checkbox,
    #addSubHolidayListContainer label.age-checkbox {
        justify-content: flex-start !important;
        text-align: left !important;
        align-items: flex-start !important;
        width: 100%;
        display: flex;
        gap: 8px;
    }
}

/* Mobile-specific: left-align holiday dropdown radio labels */
@media (max-width: 767px) {

    #holidayOptionsDropdown label.age-radio,
    #addSubBusinessOptionsDropdown label.age-radio {
        text-align: left !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        width: 100%;
        display: flex;
        gap: 8px;
    }

    #holidayListContainer>p,
    #addSubHolidayListContainer>p {
        text-align: left !important;
        width: 100%;
        margin-left: 0 !important;
    }

    #holidayOptionsDropdown,
    #addSubBusinessOptionsDropdown {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%);
        width: max-content;
        min-width: max-content;
        max-width: 92vw;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {

    #holidayOptionsDropdown label.age-radio,
    #addSubBusinessOptionsDropdown label.age-radio {
        text-align: left !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        width: 100%;
        display: flex;
        gap: 8px;
    }

    #holidayListContainer>div,
    #addSubHolidayListContainer>div {
        justify-items: start !important;
        text-align: left !important;
    }

    #holidayListContainer label.age-checkbox,
    #addSubHolidayListContainer label.age-checkbox {
        justify-content: flex-start !important;
        text-align: left !important;
        align-items: flex-start !important;
        width: 100%;
        display: flex;
        gap: 8px;
    }

    #holidayListContainer>p,
    #addSubHolidayListContainer>p {
        text-align: left !important;
    }
}

#holidayListContainer .custom-holiday-section,
#addSubHolidayListContainer .custom-holiday-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

#holidayListContainer .custom-holiday-heading,
#addSubHolidayListContainer .custom-holiday-heading {
    font-size: 13px;
    color: #4b5563;
    margin: 0 0 8px 0;
    font-weight: 600;
}

#holidayListContainer .custom-holiday-rows,
#addSubHolidayListContainer .custom-holiday-rows {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

#holidayListContainer .custom-holiday-row,
#addSubHolidayListContainer .custom-holiday-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 0.9fr);
    gap: 8px;
    align-items: center;
}

#holidayListContainer .custom-holiday-name,
#holidayListContainer .custom-holiday-month,
#holidayListContainer .custom-holiday-day,
#addSubHolidayListContainer .custom-holiday-name,
#addSubHolidayListContainer .custom-holiday-month,
#addSubHolidayListContainer .custom-holiday-day {
    width: 100%;
    font-size: 12px;
    color: #1f2937;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 7px 9px;
    line-height: 1.2;
    background: #ffffff !important;
}

#holidayListContainer .custom-holiday-month,
#holidayListContainer .custom-holiday-day,
#addSubHolidayListContainer .custom-holiday-month,
#addSubHolidayListContainer .custom-holiday-day {
    appearance: none;
    -webkit-appearance: none;
}

#holidayListContainer .custom-holiday-name::placeholder,
#addSubHolidayListContainer .custom-holiday-name::placeholder {
    color: #9ca3af;
}

#holidayListContainer .custom-holiday-name:hover,
#holidayListContainer .custom-holiday-month:hover,
#holidayListContainer .custom-holiday-day:hover,
#addSubHolidayListContainer .custom-holiday-name:hover,
#addSubHolidayListContainer .custom-holiday-month:hover,
#addSubHolidayListContainer .custom-holiday-day:hover {
    border-color: #b6c2cf;
}

#holidayListContainer .custom-holiday-name:focus,
#holidayListContainer .custom-holiday-month:focus,
#holidayListContainer .custom-holiday-day:focus,
#addSubHolidayListContainer .custom-holiday-name:focus,
#addSubHolidayListContainer .custom-holiday-month:focus,
#addSubHolidayListContainer .custom-holiday-day:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.15) !important;
}

#holidayListContainer .custom-holiday-actions,
#addSubHolidayListContainer .custom-holiday-actions {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#holidayListContainer .custom-holiday-link-btn,
#addSubHolidayListContainer .custom-holiday-link-btn {
    border: none;
    background: transparent !important;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: #1e4d6b;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

#holidayListContainer .custom-holiday-link-btn:hover,
#addSubHolidayListContainer .custom-holiday-link-btn:hover {
    color: #163a52;
}

#holidayListContainer .custom-holiday-clear-btn,
#addSubHolidayListContainer .custom-holiday-clear-btn {
    margin-left: auto;
}

@media (max-width: 767px) {

    #holidayListContainer .custom-holiday-rows,
    #addSubHolidayListContainer .custom-holiday-rows {
        overflow-x: auto;
    }

    #holidayListContainer .custom-holiday-row,
    #addSubHolidayListContainer .custom-holiday-row {
        grid-template-columns: minmax(0, 2fr) minmax(88px, 1fr) minmax(72px, 0.9fr);
        min-width: 320px;
    }

    #holidayListContainer .custom-holiday-actions,
    #addSubHolidayListContainer .custom-holiday-actions {
        align-items: center;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    margin: 0 !important;
    padding: 0 !important;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f8f9fa;
    color: #444;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    margin: 0 !important;
    padding: 0 !important;
}

/* Age Calculator Page */
.age-page {
    padding: 30px 0 50px 0;
}

.age-layout {
    display: flex;
    align-items: flex-start;
}

.age-side {
    flex: 0 0 30%;
}

@media (min-width: 768px) {
    .age-page {
        max-width: 70%;
        margin-left: 0;
        margin-right: 0;
        padding-right: 20px;
    }

    .age-page .age-card:first-of-type {
        max-width: 70%;
        width: 70%;
    }
}

@media (max-width: 767px) {
    .age-layout {
        flex-direction: column;
    }

    .age-side {
        display: none;
    }
}

.age-hero {
    margin: 1px 0 20px 0;
    padding: 0 22px;
}

.age-hero h1 {
    font-size: 28px;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.age-hero p {
    font-size: 16px;
    color: #4b5563;
    max-width: 780px;
}

/* =========================================
   Layout: Calculator & History & Hero
========================================= */

.calc-section {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
}

.calc-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 2rem;
}

.right-panel-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.hero-section {
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e4e8;
    text-align: left;
}

.hero-section h1 {
    font-size: 22px;
    line-height: 1.3;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0;
}

.history-panel {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e4e8;
    min-height: 300px;
    flex: 1;
}

/* DESKTOP LAYOUT (768px+) */
@media (min-width: 768px) {
    .calc-wrapper {
        flex-direction: row;
        align-items: stretch;
    }

    .calculator {
        flex: 0 0 400px;
    }

    .right-panel-wrapper {
        flex: 1;
        min-width: 300px;
    }
}

.age-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 16px 22px 22px 22px;
    box-shadow: 0 10px 30px rgba(28, 63, 124, 0.08);
    border: 1px solid #eef1f5;
    margin-bottom: 18px;
}

.age-card h2 {
    font-size: 20px;
    color: #1a1a2e;
    margin-top: 0;
    margin-bottom: 14px;
}

.age-card h3 {
    font-size: 17px;
    color: #1a1a2e;
    margin: 12px 0 10px 0;
}

.age-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1f2937;
}

#endLabel {
    margin-right: 1px;
    margin-left: 6px;
}

.age-input-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.age-at-row {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-operation-row {
    gap: 4px;
}

.age-at-row input[type="date"],
.age-at-row select {
    padding: 8px 10px;
    border: 1px solid #c5d1da;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #1a1a2e;
    max-width: 180px;
}

.age-at-row input[type="date"]:focus,
.age-at-row select:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.age-input-row input[type="date"],
.age-input-row select {
    padding: 8px 10px;
    border: 1px solid #c5d1da;
    border-radius: 10px;
    font-size: 14px;
    min-width: 120px;
    background: #fff;
    color: #1a1a2e;
    text-align: center;
}

.age-input-row input[type="number"] {
    padding: 8px 10px;
    border: 1px solid #c5d1da;
    border-radius: 10px;
    font-size: 14px;
    min-width: 120px;
    background: #fff;
    color: #1a1a2e;
}

.date-add-inputs input[type="number"] {
    width: 120px;
    max-width: 120px;
}

.date-add-inputs select#addSubtractOperator {
    width: auto;
    min-width: 40px;
    max-width: none;
    height: 33px;
    padding: 0 8px;
    text-align: left;
    margin-left: 26px;
    border-color: #1e4d6b;
    background: #eef5fb;
    font-weight: 700;
}

.age-input-row input[type="date"]:focus,
.age-input-row select:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.age-input-row input[type="number"]:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.age-option-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

.date-operation-row .age-option-row {
    margin-top: 0;
    gap: 8px;
}

.age-checkbox,
.age-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #1f2937;
}


.date-inline-label {
    margin: 0;
    font-weight: 600;
    color: #1f2937;
    display: inline-flex;
    align-items: center;
}

#dobLabel {
    margin-left: 40px;
}

.date-title-line {
    position: relative;
    display: inline-block;
    padding: 6px 14px 8px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(30, 77, 107, 0.12), rgba(30, 77, 107, 0.04));
    color: #14334a;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.date-title-line::after {
    content: '';
    display: block;
    height: 2px;
    width: 100%;
    background: #1e4d6b;
    margin-top: 6px;
    border-radius: 999px;
}

.date-calculator-page .age-input-row select,
.date-calculator-page .age-input-row input[type="number"] {
    text-align: center;
}

.date-calculator-page .date-end-checkbox {
    margin-left: 0;
}

.date-calculator-page .date-end-option {
    margin-left: 83px;
}

@media (min-width: 768px) {
    .date-calculator-page .date-end-option #holidayDropdownWrapper {
        order: 1;
    }

    .date-calculator-page .date-end-option .date-end-checkbox {
        order: 2;
    }

    .date-calculator-page #addSubBusinessOptionRow {
        margin-left: 85px;
        justify-content: flex-start;
    }
}

.age-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.date-calculator-page .age-actions {
    padding-left: 85px;
}

.age-calculator-page .age-actions {
    padding-left: 200px;
}

.age-btn {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #c5d1da;
    background: #ffffff;
    color: #1a1a2e;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.age-btn.primary {
    background: linear-gradient(135deg, #1a3a52 0%, #1e4d6b 100%);
    color: #ffffff;
    border-color: #1e4d6b;
}

.age-btn:hover {
    box-shadow: 0 6px 16px rgba(30, 77, 107, 0.2);
}

.age-help {
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
}

.age-example-note {
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
}

.age-error {
    margin-top: 10px;
    color: #b91c1c;
    font-weight: 600;
}

.age-results {
    margin-top: 18px;
    display: none;
}

.age-results.show {
    display: block;
}

.age-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

#dateResults .age-results-header {
    justify-content: flex-start;
}

#dateResults .age-results-header .print-btn {
    margin-left: auto;
}

.age-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.age-item {
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    text-align: center;
}

.age-value {
    font-size: 22px;
    font-weight: 700;
    color: #1e3a5f;
}

.age-label {
    font-size: 13px;
    color: #6b7280;
}

.age-details {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    background: #ffffff;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 2px;
    border-bottom: 1px dashed #e5e7eb;
    color: #1f2937;
}

.detail-row:last-child {
    border-bottom: none;
}

.age-steps {
    padding-left: 18px;
    color: #374151;
}

.age-steps li {
    margin-bottom: 8px;
}

.age-list {
    padding-left: 18px;
    color: #374151;
}

.age-list li {
    margin-bottom: 6px;
}

.age-callout {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-top: 12px;
}

.age-callout h3 {
    margin-top: 0;
}

.age-example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.age-example-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
}

.age-example-card h3 {
    margin-top: 0;
}

.age-faq {
    display: grid;
    gap: 10px;
}

.age-faq-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    background: #ffffff;
}

.age-faq-item summary {
    cursor: pointer;
    font-weight: 600;
    color: #1a1a2e;
}

.age-faq-item summary::-webkit-details-marker {
    display: none;
}

.age-faq-item summary::before {
    content: '+';
    display: inline-block;
    width: 18px;
    margin-right: 8px;
    color: #4a90e2;
    font-weight: 700;
}

.age-faq-item[open] summary::before {
    content: '-';
}

@media (max-width: 767px) {
    .age-page {
        padding: 20px 12px 30px 12px;
    }

    .age-hero {
        padding: 0 18px;
    }

    .age-card {
        padding: 18px;
        border-radius: 14px;
    }

    .age-hero h1 {
        font-size: 24px;
    }

    .age-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .age-at-row input[type="date"],
    .age-at-row select {
        max-width: 100%;
    }

    .age-actions {
        width: 100%;
    }

    .age-btn {
        width: 100%;
        justify-content: center;
    }

    .date-calculator-page .age-input-row {
        flex-direction: row;
        justify-content: center;
    }

    .date-calculator-page .age-input-row select,
    .date-calculator-page .age-input-row input[type="number"] {
        min-width: 88px;
        max-width: 88px;
    }


    .date-calculator-page .age-actions {
        justify-content: center;
        padding-left: 0;
    }

    .date-calculator-page .age-btn {
        width: auto;
        padding: 9px 12px;
    }

    .date-calculator-page .date-center-card {
        text-align: center;
    }

    .date-calculator-page .date-center-card .age-results-header {
        justify-content: center;
    }

    .date-calculator-page .age-results {
        text-align: center;
    }

    .date-calculator-page #dateResults>h3 {
        text-align: left;
    }

    .date-calculator-page .age-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .date-calculator-page .age-item {
        padding: 10px;
    }

    .date-calculator-page .age-value {
        font-size: 18px;
    }

    .date-calculator-page .date-center-card .age-details .detail-row {
        justify-content: center;
        text-align: center;
        flex-direction: column;
        gap: 4px;
    }

    .date-calculator-page .date-end-option {
        justify-content: center;
        align-items: center;
        flex-direction: column;
        gap: 8px !important;
        margin-left: 0;
        width: 100%;
    }

    .date-calculator-page .date-end-checkbox {
        font-size: 15px;
        margin-left: 0;
    }

    .date-calculator-page .date-end-checkbox input {
        width: 16px;
        height: 16px;
    }

    .age-calculator-page .age-input-row {
        flex-direction: row;
        justify-content: flex-start;
    }

    .age-calculator-page .age-input-row select {
        min-width: 80px;
        max-width: 80px;
        text-align: center;
    }

    .age-calculator-page .age-actions {
        justify-content: center;
        padding-left: 110px;
    }

    .age-calculator-page .age-btn {
        width: auto;
        padding: 9px 12px;
    }

    .age-calculator-page .age-results-header {
        justify-content: flex-start;
        text-align: left;
    }

    .age-calculator-page .age-results-header .print-btn {
        margin-left: auto;
    }

    .age-calculator-page .age-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        justify-items: stretch;
    }

    .age-calculator-page .age-item {
        padding: 10px;
        text-align: center;
    }

    .age-calculator-page .age-value {
        font-size: 18px;
    }

    .age-calculator-page #age-calculator-title {
        display: table;
        margin: 0 auto 14px;
        text-align: center;
    }

    .age-calculator-page .age-details .detail-row {
        justify-content: center;
        text-align: center;
        flex-direction: column;
        gap: 4px;
    }

    .date-calculator-page .date-operation-row .age-option-row {
        justify-content: center;
    }

    .date-calculator-page .date-operation-row .age-radio {
        font-size: 15px;
    }

    .date-calculator-page .date-operation-row .age-radio input {
        width: 16px;
        height: 16px;
    }
}

.container,
.about-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

.main-content {
    padding-top: 0;
}

/* Breadcrumbs */
.breadcrumb-bar {
    background: transparent;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 22px;
    font-size: 13px;
    color: #6b7280;
}

.breadcrumb-bar+.main-content {
    margin-top: 12px;
}

.breadcrumb a {
    color: #1a1a2e;
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #9ca3af;
}

@media (max-width: 767px) {
    .breadcrumb {
        padding: 4px 12px;
    }

    .breadcrumb-bar+.main-content {
        margin-top: 6px;
    }
}

/* Mobile-specific container improvements */
@media (max-width: 767px) {

    /* Hide desktop header on mobile */
    .desktop-header {
        display: none !important;
    }

    /* Show mobile header on mobile */
    .mobile-header {
        display: block !important;
    }

    .container,
    .about-shell {
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    .main-content {
        padding: 0;
    }


    .calc-section {
        padding: 0;
        margin: 0;
        background: none;
        border-radius: 0;
        box-shadow: none;
    }

    .category {
        padding: 8px 4px;
        margin: 6px auto;
    }

    .calc-wrapper {
        gap: 0;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        padding: 0;
        background: none;
    }

    /* Reorder: Calculator first, Hero second, History third on mobile */
    .right-panel-wrapper {
        display: contents;
    }

    .hero-section {
        order: 2;
        margin-bottom: 0px;
    }

    .scientific-calculator,
    .basic-calculator {
        order: 1;
    }

    .history-panel {
        order: 3;
    }

    .calculator {
        max-width: 100%;
        width: 100%;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
    }

    .history-panel {
        max-width: 100%;
        width: 100%;
        max-height: 240px;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
    }

    .basic-calculator {
        max-width: 100%;
        margin: 0;
    }

    /* Mobile-only memory buttons box - below display, above calculator buttons */
    .basic-calculator .memory-btns,
    .scientific-calculator .memory-btns {
        padding: 6px 4px;
        gap: 4px;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        background: linear-gradient(135deg, #1a3a52 0%, #1e4d6b 100%);
        border: none;
        border-radius: 0;
        margin: 0;
        box-shadow: none;
    }

    /* Mobile-only button spacing optimization */
    .buttons {
        padding: 8px;
        gap: 4px;
    }

    .memory-btns {
        padding: 10px 8px;
        gap: 4px;
    }

    /* Mobile-only calculator button size optimization */
    .btn {
        padding: 18px 10px;
        font-size: 22px;
        min-height: 56px;
        border-radius: 18px;
    }

    /* Operator buttons and equals in basic calculator - larger font for mobile */
    .basic-calculator .btn.sci,
    .basic-calculator .btn.equals {
        font-size: 22px !important;
    }

    .memory-btn {
        font-size: 13px;
        padding: 10px 4px;
        min-height: 42px;
    }

    .display-val {
        font-size: 40px;
    }

    .live-expr {
        font-size: 14px;
    }

    .history-item {
        padding: 16px 18px;
        min-height: 60px;
    }

    .history-result {
        font-size: 22px;
    }

    .calc-item {
        padding: 20px 18px;
        min-height: 96px;
    }

    .calc-item h3 {
        font-size: 20px;
    }

    .calc-item p {
        font-size: 16px;
    }

    .history-header {
        padding: 16px;
    }

    .history-content {
        padding: 8px;
    }

    .display {
        padding: 20px 16px;
        height: 110px;
        min-height: 110px;
        max-height: 110px;
    }
}

/* Desktop Header Base Styles */
header {
    position: relative;
    z-index: 1001;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    display: block;
}

.desktop-header {
    background: linear-gradient(135deg, #2c4a6e 0%, #1e3a5f 100%);
    color: #fff;
    padding: 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 100%;
    margin: 0 !important;
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    flex: 0 0 auto;
    font-family: 'Space Grotesk', 'Segoe UI', Roboto, Arial, sans-serif;
    letter-spacing: 0.4px;
}

.logo-text,
.logo-last-text {
    color: #fff;
}

.logo-last {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.logo-pro {
    color: #fff;
    font-weight: inherit;
}

.navbar {
    display: flex;
    gap: 25px;
    align-items: center;
    flex: 1 1 auto;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-left: auto;
}

.nav-link {
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #4a90e2;
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* ===================================
   MOBILE NAVBAR - NEW DESIGN
   =================================== */

/* Mobile Header Container */
.mobile-header {
    display: block;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a5a8a 100%);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Mobile Header Bar */
.mobile-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a5a8a 100%);
}

/* Mobile Hamburger Icon */
.mobile-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    transition: all 0.3s ease;
    margin-left: auto;
    order: 2;
}

.mobile-hamburger span {
    width: 100%;
    height: 3px;
    background-color: #fff;
    border-radius: 3px;
    transition: all 0.3s ease;
    display: block;
    transform-origin: center;
}

.mobile-hamburger.active span:nth-child(1) {
    transform: translateY(9.5px) rotate(45deg);
}

.mobile-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.mobile-hamburger.active span:nth-child(3) {
    transform: translateY(-9.5px) rotate(-45deg);
}

/* Mobile Logo */
.mobile-logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    text-align: left;
    order: 1;
    font-family: 'Space Grotesk', 'Segoe UI', Roboto, Arial, sans-serif;
    letter-spacing: 0.4px;
}

/* Mobile Search Panel - at bottom of drawer */
.mobile-search-panel {
    padding: 16px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a5a8a 100%);
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 1002;
}

.mobile-search-box {
    display: flex;
    gap: 8px;
    width: 100%;
}

.mobile-search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    transition: all 0.3s ease;
}

.mobile-search-input:focus {
    outline: none;
    background: #ffffff;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.mobile-search-input::placeholder {
    color: #999;
}

.mobile-search-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.mobile-search-btn:hover {
    background: linear-gradient(135deg, #357abd 0%, #2a5f99 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.mobile-search-btn:active {
    transform: translateY(0);
}

/* Mobile Drawer Menu */
.mobile-drawer {
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a5a8a 100%);
    width: 100%;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s ease-out;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-drawer.active {
    max-height: 600px;
    overflow: visible;
}

.mobile-drawer-link {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a5a8a 100%);
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
}

.mobile-drawer-link:last-child {
    border-bottom: none;
}

.mobile-drawer-link:hover,
.mobile-drawer-link:active {
    background: linear-gradient(135deg, #2a5a8a 0%, #346ba0 100%);
}

/* Mobile autocomplete positioning - inside drawer */
.mobile-search-panel .autocomplete-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    bottom: auto;
    margin-top: 0;
    background: #ffffff;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    max-height: min(50dvh, 320px);
    overflow-y: auto;
    z-index: 1003;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: none;
}

.mobile-search-panel .autocomplete-suggestions.show {
    display: block;
}


/* Main Content */
.main-content {
    padding: 0 0 20px 0;
    width: 100%;
}

/* Calculator Section */
.calc-section {
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
    border-radius: 16px;
    padding: 20px 15px;
    margin: 20px auto;
    max-width: 1200px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    width: 100%;
}

.calc-section h2 {
    color: #1a1a2e;
    font-size: 22px;
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.3;
    font-weight: 700;
}

.calc-wrapper {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
    width: 100%;
    padding-top: 20px;
}


.calculator {
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(28, 63, 124, 0.12),
        0 5px 15px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Memory Section - Horizontal Bar at Top */
.memory-btns {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: linear-gradient(135deg, #1a3a52 0%, #1e4d6b 100%);
    padding: 12px 8px;
    gap: 6px;
    border-bottom: none;
    overflow-x: auto;
}

.memory-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 13px;
    padding: 10px 8px;
    cursor: pointer;
    border-radius: 10px;
    white-space: nowrap;
    font-weight: 700;
    transition: all 0.3s ease;
    flex-shrink: 0;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.memory-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 58, 82, 0.3);
}

.memory-btn:active {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(0);
}

/* Display Area */
.display {
    background: linear-gradient(135deg, #0f2847 0%, #1a3a52 100%);
    padding: 20px 18px 22px 18px;
    text-align: right;
    height: 120px;
    min-height: 120px;
    max-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    border-bottom: 2px solid rgba(91, 165, 196, 0.2);
    overflow: hidden;
    position: relative;
}

.live-expr {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin-bottom: 8px;
    min-height: 20px;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.display-val {
    font-size: 44px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.memory-indicator {
    position: absolute;
    top: 8px;
    right: 10px;
    color: #5ba5c4;
    font-size: 12px;
    font-weight: 700;
    background: rgba(91, 165, 196, 0.15);
    border: 1px solid rgba(91, 165, 196, 0.35);
    border-radius: 4px;
    padding: 2px 7px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 2;
}

/* Button Grid */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #ffffff;
    padding: 12px;
}

.btn {
    padding: 12px 8px;
    font-size: 18px;
    border: none;
    cursor: pointer;
    background: #f0f3f7;
    color: #1a1a2e;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid #e0e4e8;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.btn:hover {
    background: #e6ebf2;
    border-color: #c5d1da;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 63, 124, 0.15);
}

.btn:active {
    transform: translateY(0);
    background: #dce2eb;
}



/* Function Buttons (scoped to basic calculator) */
.basic-calculator .buttons .btn:nth-child(1),
.basic-calculator .buttons .btn:nth-child(2),
.basic-calculator .buttons .btn:nth-child(3),
.basic-calculator .buttons .btn:nth-child(4),
.basic-calculator .buttons .btn:nth-child(5),
.basic-calculator .buttons .btn:nth-child(6),
.basic-calculator .buttons .btn:nth-child(7) {
    background: linear-gradient(135deg, #f5f7fa 0%, #eff2f7 100%);
    color: #2c5282;
    font-weight: 700;
    border-color: #d4dae4;
}

.basic-calculator .buttons .btn:nth-child(1):hover,
.basic-calculator .buttons .btn:nth-child(2):hover,
.basic-calculator .buttons .btn:nth-child(3):hover,
.basic-calculator .buttons .btn:nth-child(4):hover,
.basic-calculator .buttons .btn:nth-child(5):hover,
.basic-calculator .buttons .btn:nth-child(6):hover,
.basic-calculator .buttons .btn:nth-child(7):hover {
    background: linear-gradient(135deg, #eff2f7 0%, #e8ecf3 100%);
    box-shadow: 0 4px 12px rgba(44, 82, 130, 0.1);
}

.equals {
    grid-column: span 1;
    grid-row: span 1;
    background: linear-gradient(135deg, #1a3f52 0%, #0f2f42 100%) !important;
    color: #ffffff !important;
    font-size: 16px;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 15px rgba(26, 63, 82, 0.3);
    min-height: 40px;
}

.equals:hover {
    background: linear-gradient(135deg, #0f2f42 0%, #051a28 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 63, 82, 0.4);
}

.equals:active {
    transform: translateY(0);
}

/* Ensure basic calculator's equals button matches scientific calculator */
.basic-calculator .btn.equals {
    background: linear-gradient(135deg, #1a3f52 0%, #0f2f42 100%) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 15px rgba(26, 63, 82, 0.3) !important;
}

.basic-calculator .btn.equals:hover {
    background: linear-gradient(135deg, #0f2f42 0%, #051a28 100%) !important;
    box-shadow: 0 6px 20px rgba(26, 63, 82, 0.4) !important;
}

/* Search Panel */
.search-panel {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
    margin-bottom: 10px;
    padding: 0;
    border: none;
}

.search-header {
    margin-bottom: 15px;
}

.search-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #000000;
    border-radius: 10px;
    font-size: 14px;
    color: #1a1a2e;
    background: linear-gradient(135deg, #f5f7fa 0%, #f0f3f7 100%);
    transition: all 0.3s ease;
    outline: none;
}

.search-input:focus {
    border-color: #4a90e2;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.search-btn {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.25);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.search-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transition: left 0.3s ease;
    z-index: -1;
}

.search-btn:hover {
    background: linear-gradient(135deg, #357abd 0%, #2868a8 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.35);
}

.search-btn:hover::before {
    left: 100%;
}

.search-btn:focus {
    outline: 2px solid rgba(74, 144, 226, 0.5);
    outline-offset: 2px;
}

.search-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.25);
}

/* Autocomplete suggestions container */
.autocomplete-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
}

.autocomplete-suggestions.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    font-size: 13px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: #f5f7fa;
}

.autocomplete-item.active {
    background-color: #eef2f6;
}

.autocomplete-item-name {
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.autocomplete-item-category {
    font-size: 11px;
    color: #555 !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.autocomplete-suggestions {
    color: #1a1a2e;
}

/* Desktop-specific autocomplete styles */
.header-search .search-box {
    position: relative;
}

.header-search .autocomplete-suggestions {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
}

.autocomplete-highlight {
    background-color: #fff3cd;
    color: #1a1a2e;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* Internal Page Layout */
.internal-page {
    padding: 30px 0 50px;
    margin-top: 12px;
}

.internal-layout {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
    gap: 24px;
    align-items: start;
}

.internal-main {
    min-width: 0;
}

.internal-main .calc-section {
    max-width: none;
    width: 100%;
    margin: 20px 0;
    padding: 16px 22px 22px 22px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(28, 63, 124, 0.08);
    border: 1px solid #eef1f5;
    border-radius: 18px;
}

.internal-main .calc-wrapper {
    max-width: none;
    width: 100%;
    padding: 0;
    margin: 0;
}

.internal-main .calculator {
    max-width: 100%;
    width: 100%;
}

.internal-content,
.internal-sidebar {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    min-height: 280px;
}

/* Sidebar Widget Styles */
.sidebar-widget {
    position: sticky;
    top: 20px;
}

.widget-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.widget-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #f0f3f7 100%);
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.widget-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 58, 82, 0.12);
    border-color: #4a90e2;
}

.widget-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

.widget-content {
    flex: 1;
    min-width: 0;
}

.widget-content h4 {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 4px 0;
}

.widget-content p {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.widget-link {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #4a90e2;
    text-decoration: none;
    transition: color 0.2s ease;
}

.widget-link:hover {
    color: #357abd;
    text-decoration: underline;
}

@media (max-width: 991px) {
    .internal-page {
        padding: 20px 0 35px;
    }

    .internal-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

/* History Panel */
.history-panel {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(28, 63, 124, 0.12),
        0 5px 15px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 100%;
    max-height: 350px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.history-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 15px 18px;
    background: linear-gradient(135deg, #f5f7fa 0%, #f0f3f7 100%);
    border-bottom: 2px solid #e0e4e8;
    gap: 10px;
}

.history-header .clear-btn+.clear-btn {
    margin-left: auto;
}

.history-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
}

.clear-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #e85050 100%);
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    transition: all 0.3s ease;
    min-height: 30px;
    display: flex;
    align-items: center;
    font-weight: 600;
}

.clear-btn:hover {
    background: linear-gradient(135deg, #ff5c5c 0%, #dc4343 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 67, 67, 0.3);
}

.print-btn {
    background: linear-gradient(135deg, #1a3a52 0%, #1e4d6b 100%);
}

.print-btn:hover {
    background: linear-gradient(135deg, #173348 0%, #1a4461 100%);
    box-shadow: 0 4px 12px rgba(30, 77, 107, 0.3);
}

.clear-btn:active {
    transform: translateY(0);
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 14px;
    font-weight: 500;
}

.history-item {
    padding: 12px 14px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #f5f7fa 0%, #f0f3f7 100%);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e0e4e8;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.history-item:hover {
    background: linear-gradient(135deg, #e6ebf2 0%, #dce2eb 100%);
    border-color: #5ba5c4;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(91, 165, 196, 0.15);
}

.history-expr {
    color: #666;
    font-size: 13px;
    margin-bottom: 4px;
    font-weight: 500;
}

.history-result {
    color: #1a1a2e;
    font-size: 18px;
    font-weight: 700;
}

/* Category Sections */
.category {
    background: #fff;
    border-radius: 8px;
    padding: 20px 15px;
    margin: 15px auto;
    max-width: 1200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.category h2 {
    color: #5a8fc4;
    font-size: 20px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 3px solid #5ba5c4;
    line-height: 1.3;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 15px;
}

.calc-item {
    padding: 16px 14px;
    background: #f0f4f8;
    border: 1px solid #d0dce6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
    color: inherit;
}

.calc-item:hover {
    background: #dfe8f3;
    border-color: #5ba5c4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(90, 143, 196, 0.12);
}

.calc-item:active {
    transform: translateY(0);
}

.calc-item h3 {
    color: #2d3748;
    font-size: 17px;
    margin-bottom: 6px;
    line-height: 1.3;
    font-weight: 600;
}

.calc-item p {
    color: #718096;
    font-size: 14px;
    line-height: 1.5;
}

/* Under Development Page */
.under-dev-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.under-dev-page .main-content {
    flex: 1;
}

.under-dev-page .breadcrumb {
    padding: 4px 12px;
}

.under-dev-page .breadcrumb-bar+.main-content {
    margin-top: 4px;
}

.under-dev-page footer {
    margin-top: 10px;
    padding: 14px 15px;
}

.under-dev-main {
    padding: 8px 0 12px 0;
}

.under-dev-card {
    background: #ffffff;
    border: 1px solid #d8e5f1;
    border-radius: 16px;
    padding: 16px 14px;
    max-width: 980px;
    margin: 0 auto;
    box-shadow: 0 12px 30px rgba(18, 52, 82, 0.1);
}

.under-dev-code {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: #ffe7e7;
    color: #9f1239;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.under-dev-card h1 {
    color: #1f4566;
    font-size: 24px;
    line-height: 1.26;
    margin-bottom: 10px;
}

.under-dev-message {
    color: #334155;
    font-size: 15px;
    line-height: 1.55;
    margin: 0 0 5px 0;
}

.under-dev-visual-image {
    display: block;
    width: 100%;
    max-height: clamp(350px, 48vh, 490px);
    object-fit: contain;
    margin: 0 0 10px 0;
}

.under-dev-thanks {
    color: #1e3a5f;
    font-size: 14px;
    line-height: 1.45;
    margin-bottom: 12px;
    font-weight: 600;
}

.under-dev-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dev-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.dev-btn:hover {
    transform: translateY(-1px);
}

.dev-btn-primary {
    background: #2f6ea5;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(47, 110, 165, 0.28);
}

.dev-btn-primary:hover {
    background: #255985;
}

.dev-btn-secondary {
    background: #e9f2fb;
    color: #1f4566;
    border: 1px solid #cfe0f0;
}

.dev-btn-secondary:hover {
    background: #dceaf8;
}

@media (min-width: 768px) {
    .under-dev-main {
        padding: 10px 0 16px 0;
    }

    .under-dev-card {
        padding: 20px 22px;
    }

    .under-dev-card h1 {
        font-size: 30px;
    }

    .under-dev-visual-image {
        max-height: clamp(420px, 60vh, 640px);
    }
}

/* About Page */
.about-page {
    padding: 30px 0 50px 0;
}

.about-hero,
.about-section,
.contact-section {
    background: #ffffff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(28, 63, 124, 0.08);
    border: 1px solid #eef1f5;
    margin-bottom: 18px;
}

.about-hero h1 {
    font-size: 28px;
    color: #1a1a2e;
    margin-bottom: 8px;
    font-family: 'Space Grotesk', 'Segoe UI', Roboto, Arial, sans-serif;
    letter-spacing: 0.3px;
}

.about-hero p,
.about-section p,
.contact-section p {
    font-size: 16px;
    color: #4b5563;
    line-height: 1.6;
}

.about-section h2,
.contact-section h2 {
    font-size: 20px;
    color: #1a1a2e;
    margin-bottom: 12px;
}

.about-section ul {
    margin-top: 10px;
    padding-left: 18px;
}

.about-section li {
    margin-bottom: 8px;
    color: #374151;
}

.contact-form {
    margin-top: 16px;
    display: grid;
    gap: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1f2937;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d6dbe3;
    border-radius: 10px;
    font-size: 14px;
    background: #ffffff;
    color: #1a1a2e;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
}

.contact-btn {
    justify-self: start;
    padding: 12px 20px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contact-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.25);
}

.privacy-note {
    font-size: 12px;
    color: #6b7280;
}

@media (max-width: 767px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Footer */
footer {
    background: linear-gradient(135deg, #1e3a5f 0%, #142845 100%);
    color: #fff;
    text-align: center;
    padding: 25px 15px;
    margin-top: 30px;
    width: 100%;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    font-size: 14px;
}

.footer-links a {
    color: #b3d9f2;
    text-decoration: none;
    transition: color 0.3s ease;
    padding: 8px 4px;
}

.footer-links a:hover {
    color: #fff;
}

footer p {
    color: #a0aec0;
    font-size: 14px;
    line-height: 1.5;
}

/* Tablet: 600px and above */
@media (min-width: 600px) {
    .logo {
        font-size: 24px;
    }

    .navbar {
        gap: 15px;
    }

    .nav-link {
        font-size: 14px;
        padding: 8px 12px;
    }

    .display-val {
        font-size: 40px;
    }

    .btn {
        padding: 16px;
        font-size: 18px;
        min-height: 50px;
    }

    .memory-btn {
        font-size: 13px;
        padding: 8px 12px;
        min-height: 40px;
    }

    .calc-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }

    .calc-section h2 {
        font-size: 22px;
    }

    .category h2 {
        font-size: 24px;
    }

    .calc-item p {
        font-size: 14px;
    }

    /* Tablet-specific Scientific Calculator layout optimization */
    .scientific-calculator {
        max-width: 520px;
        min-width: 520px;
        width: 520px;
        margin: 0 auto;
    }

    .sci-buttons {
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        gap: 4px;
        padding: 10px;
        width: 100%;
    }

    .sci-buttons .btn,
    .sci-buttons .btn.sci {
        padding: 12px 8px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .sci-buttons .angle-btn {
        padding: 12px 8px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .sci-buttons .equals {
        padding: 12px 8px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .memory-btns {
        padding: 14px 10px;
        gap: 8px;
    }

    .display {
        padding: 16px 14px 18px 14px;
        min-height: 80px;
    }

    .display-val {
        font-size: 38px;
    }

    .live-expr {
        font-size: 14px;
    }
}

/* Desktop: 768px and above */
@media (min-width: 768px) {

    /* Fixed desktop layout - prevent compression */
    body {
        min-width: 1024px;
        overflow-x: auto;
    }

    html {
        overflow-x: auto;
    }

    /* Hide mobile header on desktop */
    .mobile-header {
        display: none !important;
    }

    /* Show desktop header */
    .desktop-header {
        display: block !important;
    }

    /* Hide Basic Calculator and its tab on desktop */
    .basic-calculator {
        display: none !important;
    }

    .calc-tabs .tab-btn:first-child {
        display: none !important;
    }

    /* Hide Scientific tab button on desktop */
    .calc-tabs .tab-btn:nth-child(2) {
        display: none !important;
    }

    /* Auto-show Scientific Calculator on desktop */
    .scientific-calculator {
        display: block !important;
    }

    header {
        padding: 12px 20px;
        min-width: 1024px;
    }

    .header-content {
        flex-wrap: nowrap;
        gap: 30px;
        position: relative;
        min-width: 1100px;
        max-width: 1200px;
    }

    .navbar {
        margin-right: 350px;
        /* Increased space for search bar */
        margin-left: 30px;
        /* Space from logo */
        gap: 10px;
        flex-wrap: nowrap;
        white-space: nowrap;
        min-width: 400px;
    }

    .logo {
        font-size: 24px;
        flex: 0 0 auto;
        text-align: left;
        min-width: 220px;
        max-width: 220px;
        white-space: nowrap;
    }

    .nav-link {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 8px 12px;
    }

    /* Show header search on desktop */
    .header-search {
        display: block;
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 320px;
        max-width: 320px;
        min-width: 320px;
        margin: 0;
        z-index: 100;
    }

    .header-search .search-box {
        margin-bottom: 0;
        gap: 8px;
    }

    .header-search .search-input {
        padding: 8px 13px;
        font-size: 14px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        background: rgba(255, 255, 255, 0.95);
        min-width: 200px;
        border-radius: 8px;
    }

    .header-search .search-input:focus {
        background: #ffffff;
        border-color: #548fd2;
    }

    .header-search .search-btn {
        padding: 8px 16px;
        font-size: 14px;
        min-width: auto;
        border-radius: 8px;
    }

    .container {
        min-width: 980px;
        padding: 0;
    }

    .main-content {
        padding: 0 15px 20px 15px;
    }

    .display {
        padding: 16px 14px 18px 14px;
        min-height: 80px;
    }

    .live-expr {
        font-size: 14px;
    }

    .display-val {
        font-size: 38px;
    }

    .buttons {
        padding: 9px;
        gap: 6px;
    }

    .btn {
        padding: 12px;
        font-size: 15px;
        min-height: 40px;
    }

    .equals {
        font-size: 16px;
    }

    .memory-btns {
        padding: 8px 8px;
    }

    .memory-btn {
        font-size: 13px;
        padding: 6px 10px;
        min-height: 30px;
    }

    .history-item {
        padding: 10px 12px;
        min-height: 40px;
    }

    .history-expr {
        font-size: 11px;
    }

    .history-result {
        font-size: 15px;
    }

    .calc-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 15px;
    }

    .calc-section {
        padding: 10px 20px 25px 20px;
        margin: 25px auto 20px auto;
        min-width: 900px;
    }

    .calc-wrapper {
        display: grid;
        grid-template-columns: 520px 360px;
        grid-auto-rows: auto;
        gap: 25px;
        align-items: start;
        min-width: 905px;
        width: 905px;
    }

    .calculator {
        grid-column: 1;
        grid-row: 1;
        max-width: 520px;
        min-width: 520px;
        width: 520px;
    }

    .history-panel {
        grid-column: 2;
        grid-row: 1;
        max-width: 360px;
        min-width: 360px;
        width: 360px;
        max-height: 450px;
    }

    .search-box {
        justify-content: flex-start;
    }

    .search-input {
        flex: 0 1 260px;
        max-width: 260px;
    }

    .category {
        padding: 30px 15px;
        margin: 30px auto;
    }

    .calc-item {
        padding: 15px;
        min-height: auto;
    }

    .calc-item h3 {
        font-size: 16px;
    }

    .calc-item p {
        font-size: 13px;
    }

    footer {
        padding: 30px 20px;
    }

    .footer-links {
        gap: 30px;
        font-size: 14px;
    }

    .basic-calculator {
        max-width: 350px;
    }

    .history-panel {
        max-width: 360px;
    }

    .calc-wrapper {
        flex-direction: row;
        justify-content: flex-start;
        gap: 25px;
        align-items: flex-start;
    }

    /* Position Scientific Calculator on left, History on right */
    .scientific-calculator {
        order: 1;
        flex: 0 0 auto;
        align-self: flex-start;
        margin-top: 0;
        max-width: 520px;
        min-width: 520px;
        width: 520px;
    }

    .sci-buttons {
        grid-template-columns: repeat(10, 1fr);
        gap: 4px;
        padding: 10px;
        width: 100%;
    }

    .sci-buttons .btn,
    .sci-buttons .btn.sci,
    .sci-buttons .angle-btn {
        padding: 12px 8px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .sci-buttons .equals {
        padding: 12px 8px !important;
        font-size: 14px !important;
        min-height: 40px !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    /* Reduce MOD button font size */
    .sci-buttons .btn:nth-child(48) {
        font-size: 12px !important;
    }

    .history-panel {
        order: 2;
        flex: 0 0 auto;
    }
}

/* Calculator Tabs */
.calc-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: -8px;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: wrap;
    align-self: flex-start;
}

.tab-btn {
    padding: 4px 10px;
    background: linear-gradient(135deg, #e6ebf2 0%, #dce2eb 100%);
    border: 1.5px solid #c5d1da;
    color: #2c5282;
    font-weight: 700;
    font-size: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tab-btn:hover {
    background: linear-gradient(135deg, #dce2eb 0%, #d2d9e3 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 82, 130, 0.15);
}

.tab-btn.active {
    background: linear-gradient(135deg, #5ba5c4 0%, #4a94b0 100%);
    color: #ffffff;
    border-color: #4a94b0;
    box-shadow: 0 6px 20px rgba(91, 165, 196, 0.3);
}

/* Scientific Calculator Specific Styles */
.scientific-calculator {
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(28, 63, 124, 0.12),
        0 5px 15px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 450px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.sci-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #2c4a6e 0%, #1e3a5f 100%);
    border-bottom: 1px solid rgba(91, 165, 196, 0.3);
    gap: 15px;
    flex-wrap: wrap;
}

.angle-mode,
.constants {
    display: flex;
    gap: 8px;
    align-items: center;
}

.angle-btn,
.constant-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.angle-btn:hover,
.constant-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.angle-btn.active {
    background: linear-gradient(135deg, #5ba5c4 0%, #4a94b0 100%);
    border-color: #4a94b0;
    box-shadow: 0 4px 12px rgba(91, 165, 196, 0.4);
}

/* Angle button styling when in sci-buttons grid */
.sci-buttons .angle-btn {
    background: linear-gradient(135deg, #e8f1f8 0%, #dde8f2 100%);
    color: #1e3a5f;
    border-color: #c5d1da;
    padding: 10px 6px;
    font-size: 11px;
    min-height: 36px;
}

.sci-buttons .angle-btn:hover {
    background: linear-gradient(135deg, #dde8f2 0%, #d2dfe9 100%);
    border-color: #5ba5c4;
    box-shadow: 0 4px 12px rgba(91, 165, 196, 0.15);
}

.sci-buttons .angle-btn.active {
    background: linear-gradient(135deg, #5ba5c4 0%, #4a94b0 100%);
    border-color: #4a94b0;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(91, 165, 196, 0.4);
}

.constant-btn {
    padding: 8px 12px;
    font-size: 14px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scientific buttons grid */
.sci-buttons {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    padding: 10px;
    background: #ffffff;
}

.btn.sci {
    background: linear-gradient(135deg, #e8f1f8 0%, #dde8f2 100%);
    color: #1e3a5f;
    border-color: #c5d1da;
    font-weight: 700;
    font-size: 14px;
    padding: 12px 8px;
    min-height: 40px;
    border-radius: 8px;
}

.btn.sci:hover {
    background: linear-gradient(135deg, #dde8f2 0%, #d2dfe9 100%);
    border-color: #5ba5c4;
    box-shadow: 0 4px 12px rgba(91, 165, 196, 0.15);
}

.sci-buttons .btn {
    padding: 12px 8px !important;
    font-size: 14px !important;
    min-height: 40px;
    border-radius: 8px;
}

.sci-buttons .btn.sci {
    padding: 12px 8px !important;
    font-size: 14px !important;
    min-height: 40px;
}

.sci-buttons .equals {
    min-height: auto;
    font-size: 14px !important;
}

/* Backspace button styling for scientific calculator (desktop and mobile) */
.sci-buttons .btn:nth-child(10) {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff4757 100%) !important;
    color: #ffffff !important;
    border-color: #ff4757 !important;
    font-weight: 800 !important;
    box-shadow: 0 6px 18px rgba(255, 71, 87, 0.35);
}

.sci-buttons .btn:nth-child(10):hover {
    background: linear-gradient(135deg, #ff4757 0%, #ff2f3f 100%) !important;
    border-color: #ff2f3f !important;
    box-shadow: 0 8px 22px rgba(255, 71, 87, 0.45);
}

/* Responsive adjustments for scientific calculator */
@media (max-width: 767px) {
    .calc-tabs {
        gap: 4px;
        margin-bottom: 4px;
    }

    .tab-btn {
        padding: 4.5px 9px;
        font-size: 12px;
        border-width: 1px;
        border-radius: 3px;
        letter-spacing: 0.2px;
    }

    .scientific-calculator {
        max-width: 100%;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .display {
        padding: 16px 14px 14px 14px;
        height: 110px;
        min-height: 110px;
        max-height: 110px;
        justify-content: flex-end;
        overflow: visible;
    }

    .display-val {
        font-size: 40px;
        line-height: 1;
        max-width: 100%;
    }

    .live-expr {
        font-size: 13px;
        line-height: 1.2;
    }

    .sci-header {
        padding: 12px 10px;
        gap: 8px;
    }

    .angle-btn,
    .constant-btn {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 36px;
    }

    .sci-buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 10px;
        display: grid;
    }

    /* Optimized type and padding for mobile scientific buttons to prevent overflow */
    .sci-buttons .btn,
    .sci-buttons .btn.sci,
    .sci-buttons .equals,
    .sci-buttons .angle-btn {
        font-size: 14px !important;
        padding: 12px 4px !important;
    }

    /* Mobile-only highlight for Backspace (⌫) button in basic calculator */
    .basic-calculator .buttons .btn:nth-child(4) {
        background: linear-gradient(135deg, #ff6b6b 0%, #ff4757 100%) !important;
        color: #ffffff !important;
        border-color: #ff4757 !important;
        font-weight: 800 !important;
        box-shadow: 0 6px 18px rgba(255, 71, 87, 0.35);
    }

    .basic-calculator .buttons .btn:nth-child(4):hover {
        background: linear-gradient(135deg, #ff4757 0%, #ff2f3f 100%) !important;
        border-color: #ff2f3f !important;
        box-shadow: 0 8px 22px rgba(255, 71, 87, 0.45);
    }

    /* Mobile button reordering: Scientific functions at top, basic buttons below */
    /* Row 1: DEG, RAD, π, e, (, ) - Top control row */
    .sci-buttons .angle-btn:nth-child(1) {
        order: 0;
    }

    /* DEG */
    .sci-buttons .angle-btn:nth-child(2) {
        order: 1;
    }

    /* RAD */
    .sci-buttons .btn:nth-child(3) {
        order: 2;
    }

    /* π */
    .sci-buttons .btn:nth-child(4) {
        order: 3;
    }

    /* e */
    .sci-buttons .btn:nth-child(5) {
        order: 4;
    }

    /* ( */
    .sci-buttons .btn:nth-child(6) {
        order: 5;
    }

    /* ) */

    /* Row 2: Trig functions */
    .sci-buttons .btn:nth-child(11) {
        order: 6;
    }

    /* sin */
    .sci-buttons .btn:nth-child(12) {
        order: 7;
    }

    /* cos */
    .sci-buttons .btn:nth-child(13) {
        order: 8;
    }

    /* tan */
    .sci-buttons .btn:nth-child(14) {
        order: 9;
    }

    /* log */
    .sci-buttons .btn:nth-child(15) {
        order: 10;
    }

    /* 10ˣ */
    .sci-buttons .btn:nth-child(20) {
        order: 11;
    }

    /* n! */

    /* Row 3: Inverse trig functions */
    .sci-buttons .btn:nth-child(21) {
        order: 12;
    }

    /* sin⁻¹ */
    .sci-buttons .btn:nth-child(22) {
        order: 13;
    }

    /* cos⁻¹ */
    .sci-buttons .btn:nth-child(23) {
        order: 14;
    }

    /* tan⁻¹ */
    .sci-buttons .btn:nth-child(24) {
        order: 15;
    }

    /* ln */
    .sci-buttons .btn:nth-child(25) {
        order: 16;
    }

    /* eˣ */

    /* Row 4: Power and advanced functions */
    .sci-buttons .btn:nth-child(32) {
        order: 17;
    }

    /* x³ */
    .sci-buttons .btn:nth-child(33) {
        order: 18;
    }

    /* xʸ */
    .sci-buttons .btn:nth-child(34) {
        order: 19;
    }

    /* |x| */
    .sci-buttons .btn:nth-child(35) {
        order: 20;
    }

    /* RND */

    /* Row 5: Root and rounding functions */
    .sci-buttons .btn:nth-child(42) {
        order: 21;
    }

    /* ³√x */
    .sci-buttons .btn:nth-child(43) {
        display: none;
    }

    /* CEIL - hidden on mobile */
    .sci-buttons .btn:nth-child(44) {
        display: none;
    }

    /* FLOOR - hidden on mobile */
    .sci-buttons .btn:nth-child(45) {
        order: 22;
    }

    /* Σ */
    .sci-buttons .btn:nth-child(48) {
        order: 23;
    }

    /* MOD */

    /* Basic calculator buttons - appear below scientific functions */
    /* Basic Row 1: ²√x, CE, C, ⌫ */
    .sci-buttons .btn:nth-child(41) {
        order: 24;
    }

    /* ²√x */
    .sci-buttons .btn:nth-child(8) {
        order: 25;
    }

    /* CE */
    .sci-buttons .btn:nth-child(9) {
        order: 26;
    }

    /* C */
    .sci-buttons .btn:nth-child(10) {
        order: 27;
    }

    /* ⌫ */

    /* Basic Row 2: x², %, 1/x, ÷ */
    .sci-buttons .btn:nth-child(31) {
        order: 28;
    }

    /* x² */
    .sci-buttons .btn:nth-child(7) {
        order: 29;
    }

    /* % */
    .sci-buttons .btn:nth-child(30) {
        order: 30;
    }

    /* 1/x */
    .sci-buttons .btn:nth-child(19) {
        order: 31;
    }

    /* ÷ */

    /* Basic Row 3: 7, 8, 9, × */
    .sci-buttons .btn:nth-child(16) {
        order: 32;
    }

    /* 7 */
    .sci-buttons .btn:nth-child(17) {
        order: 33;
    }

    /* 8 */
    .sci-buttons .btn:nth-child(18) {
        order: 34;
    }

    /* 9 */
    .sci-buttons .btn:nth-child(29) {
        order: 35;
    }

    /* × */

    /* Basic Row 4: 4, 5, 6, − */
    .sci-buttons .btn:nth-child(26) {
        order: 36;
    }

    /* 4 */
    .sci-buttons .btn:nth-child(27) {
        order: 37;
    }

    /* 5 */
    .sci-buttons .btn:nth-child(28) {
        order: 38;
    }

    /* 6 */
    .sci-buttons .btn:nth-child(39) {
        order: 39;
    }

    /* − */

    /* Basic Row 5: 1, 2, 3, + */
    .sci-buttons .btn:nth-child(36) {
        order: 40;
    }

    /* 1 */
    .sci-buttons .btn:nth-child(37) {
        order: 41;
    }

    /* 2 */
    .sci-buttons .btn:nth-child(38) {
        order: 42;
    }

    /* 3 */
    .sci-buttons .btn:nth-child(49) {
        order: 43;
    }

    /* + */

    /* Basic Row 6: +/−, 0, ., = */
    .sci-buttons .btn:nth-child(40) {
        order: 44;
    }

    /* +/− */
    .sci-buttons .btn:nth-child(46) {
        order: 45;
    }

    /* 0 */
    .sci-buttons .btn:nth-child(47) {
        order: 46;
    }

    /* . */
    .sci-buttons .equals {
        order: 47;
    }

    /* = */

    /* Mobile-only: Style ( ), n!, MOD to match scientific buttons (tan color) */
    .sci-buttons .btn:nth-child(5),
    /* ( */
    .sci-buttons .btn:nth-child(6),
    /* ) */
    .sci-buttons .btn:nth-child(20),
    /* n! */
    .sci-buttons .btn:nth-child(48) {
        /* MOD */
        background: linear-gradient(135deg, #e8f1f8 0%, #dde8f2 100%) !important;
        color: #1e3a5f !important;
        border-color: #c5d1da !important;
        font-weight: 700 !important;
    }

    .sci-buttons .btn:nth-child(5):hover,
    .sci-buttons .btn:nth-child(6):hover,
    .sci-buttons .btn:nth-child(20):hover,
    .sci-buttons .btn:nth-child(48):hover {
        background: linear-gradient(135deg, #dde8f2 0%, #d2dfe9 100%) !important;
        border-color: #5ba5c4 !important;
        box-shadow: 0 4px 12px rgba(91, 165, 196, 0.15) !important;
    }

    /* Mobile-only: Apply CE button color to sqrt (²√x) and square (x²) buttons */
    .sci-buttons [data-key="sqrt"],
    /* ²√x */
    .sci-buttons [data-key="square"] {
        /* x² */
        background: linear-gradient(135deg, #f5f7fa 0%, #eff2f7 100%) !important;
        color: #000000 !important;
        border-color: #d4dae4 !important;
        font-weight: 700 !important;
    }

    .sci-buttons [data-key="sqrt"]:hover,
    .sci-buttons [data-key="square"]:hover {
        background: linear-gradient(135deg, #eff2f7 0%, #e8ecf3 100%) !important;
        color: #000000 !important;
        box-shadow: 0 4px 12px rgba(44, 82, 130, 0.1) !important;
    }
}

@media (min-width: 600px) and (max-width: 767px) {
    .sci-buttons {
        grid-template-columns: repeat(6, 1fr);
    }

    /* Tablet-only: Match ln (sci) button color for ²√x and x² */
    .sci-buttons [data-key="sqrt"],
    .sci-buttons [data-key="square"] {
        background: linear-gradient(135deg, #e8f1f8 0%, #dde8f2 100%) !important;
        color: #1e3a5f !important;
        border-color: #c5d1da !important;
        font-weight: 700 !important;
    }

    .sci-buttons [data-key="sqrt"]:hover,
    .sci-buttons [data-key="square"]:hover {
        background: linear-gradient(135deg, #dde8f2 0%, #d2dfe9 100%) !important;
        border-color: #5ba5c4 !important;
        box-shadow: 0 4px 12px rgba(91, 165, 196, 0.15) !important;
    }

    /* Tablet-only manual button order map (edit order numbers as needed) */
    .sci-buttons [data-key="deg"] {
        order: 1 !important;
    }

    .sci-buttons [data-key="rad"] {
        order: 2 !important;
    }

    .sci-buttons [data-key="lparen"] {
        order: 3 !important;
    }

    .sci-buttons [data-key="rparen"] {
        order: 4 !important;
    }

    .sci-buttons [data-key="percent"] {
        order: 5 !important;
    }

    .sci-buttons [data-key="back"] {
        order: 6 !important;
    }

    .sci-buttons [data-key="pi"] {
        order: 7 !important;
    }

    .sci-buttons [data-key="e"] {
        order: 8 !important;
    }

    .sci-buttons [data-key="exp"] {
        order: 9 !important;
    }

    .sci-buttons [data-key="tenpow"] {
        order: 10 !important;
    }

    .sci-buttons [data-key="fact"] {
        order: 11 !important;
    }

    .sci-buttons [data-key="c"] {
        order: 12 !important;
    }

    .sci-buttons [data-key="sin"] {
        order: 13 !important;
    }

    .sci-buttons [data-key="cos"] {
        order: 14 !important;
    }

    .sci-buttons [data-key="tan"] {
        order: 15 !important;
    }

    .sci-buttons [data-key="log"] {
        order: 16 !important;
    }

    .sci-buttons [data-key="reciprocal"] {
        order: 17 !important;
    }

    .sci-buttons [data-key="ce"] {
        order: 18 !important;
    }

    .sci-buttons [data-key="asin"] {
        order: 19 !important;
    }

    .sci-buttons [data-key="acos"] {
        order: 20 !important;
    }

    .sci-buttons [data-key="atan"] {
        order: 21 !important;
    }

    .sci-buttons [data-key="ln"] {
        order: 22 !important;
    }

    .sci-buttons [data-key="sum"] {
        order: 23 !important;
    }

    .sci-buttons [data-key="divide"] {
        order: 24 !important;
    }

    .sci-buttons [data-key="square"] {
        order: 25 !important;
    }

    .sci-buttons [data-key="cube"] {
        order: 26 !important;
    }

    .sci-buttons [data-key="seven"] {
        order: 27 !important;
    }

    .sci-buttons [data-key="eight"] {
        order: 28 !important;
    }

    .sci-buttons [data-key="nine"] {
        order: 29 !important;
    }

    .sci-buttons [data-key="multiply"] {
        order: 30 !important;
    }

    .sci-buttons [data-key="sqrt"] {
        order: 31 !important;
    }

    .sci-buttons [data-key="cbrt"] {
        order: 32 !important;
    }

    .sci-buttons [data-key="four"] {
        order: 33 !important;
    }

    .sci-buttons [data-key="five"] {
        order: 34 !important;
    }

    .sci-buttons [data-key="six"] {
        order: 35 !important;
    }

    .sci-buttons [data-key="minus"] {
        order: 36 !important;
    }

    .sci-buttons [data-key="power"] {
        order: 37 !important;
    }

    .sci-buttons [data-key="abs"] {
        order: 38 !important;
    }

    .sci-buttons [data-key="one"] {
        order: 39 !important;
    }

    .sci-buttons [data-key="two"] {
        order: 40 !important;
    }

    .sci-buttons [data-key="three"] {
        order: 41 !important;
    }

    .sci-buttons [data-key="plus"] {
        order: 42 !important;
    }

    .sci-buttons [data-key="ceil"] {
        order: 43 !important;
    }

    .sci-buttons [data-key="floor"] {
        order: 44 !important;
    }

    .sci-buttons [data-key="rnd"] {
        order: 45 !important;
    }

    .sci-buttons [data-key="mod"] {
        order: 46 !important;
    }

    .sci-buttons [data-key="sign"] {
        order: 47 !important;
    }

    .sci-buttons [data-key="zero"] {
        order: 48 !important;
    }

    .sci-buttons [data-key="dot"] {
        order: 49 !important;
    }

    .sci-buttons [data-key="equals"] {
        order: 50 !important;
    }

    /* Tablet-only: Apply log button color (blue shade) to % and 1/x buttons */
    .sci-buttons [data-key="percent"],
    .sci-buttons [data-key="reciprocal"] {
        background: linear-gradient(135deg, #e8f1f8 0%, #dde8f2 100%) !important;
        color: #1e3a5f !important;
        border-color: #c5d1da !important;
        font-weight: 700 !important;
    }

    .sci-buttons [data-key="percent"]:hover,
    .sci-buttons [data-key="reciprocal"]:hover {
        background: linear-gradient(135deg, #dde8f2 0%, #d2dfe9 100%) !important;
        border-color: #5ba5c4 !important;
        box-shadow: 0 4px 12px rgba(91, 165, 196, 0.15) !important;
    }
}

@media (min-width: 768px) {
    .scientific-calculator {
        max-width: 550px;
    }

    .sci-buttons {
        grid-template-columns: repeat(10, 1fr);
    }

    .sci-buttons .equals {
        grid-row: auto;
    }
}

/* BMI Calculator Page */
.bmi-form {
    width: 100%;
}

.bmi-form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 340px);
    gap: 18px;
    align-items: start;
    width: 100%;
}

.bmi-form-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    min-width: 0;
    grid-column: 1;
    grid-row: 1 / span 2;
}

.bmi-form-fields .age-help {
    width: 100%;
    text-align: left;
}

@media (min-width: 992px) {
    .bmi-form-fields .age-help {
        margin-bottom: 24px;
    }
}

.bmi-analog-meter {
    --gauge-size: 300px;
    --gauge-ring: 40px;
    width: min(100%, 340px);
    justify-self: end;
    background: #ffffff;
    grid-column: 2;
    grid-row: 1;
    position: relative;
}

.bmi-meter-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0;
    position: relative;
    z-index: 5;
}

.bmi-meter-print-btn {
    min-height: 30px;
    padding: 6px 10px;
}

.bmi-analog-viewport {
    position: relative;
    height: calc(var(--gauge-size) / 2 + 24px);
    overflow: hidden;
}

.bmi-analog-dial {
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--gauge-size);
    height: var(--gauge-size);
    border-radius: 50%;
    transform: translateX(-50%);
    background: conic-gradient(from -90deg,
            #60a5fa 0deg 51deg,
            #22c55e 51deg 90deg,
            #f59e0b 90deg 120deg,
            #ef4444 120deg 180deg,
            transparent 180deg 360deg);
}

.bmi-analog-dial::after {
    content: '';
    position: absolute;
    inset: var(--gauge-ring);
    border-radius: 50%;
    background: #ffffff;
}

.bmi-analog-labels {
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--gauge-size);
    height: calc(var(--gauge-size) / 2 + 20px);
    transform: translateX(-50%);
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

.bmi-analog-label {
    fill: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
    opacity: 0.82;
    text-shadow: 0 1px 3px rgba(15, 23, 42, 0.55);
    transition: opacity 0.2s ease;
    paint-order: stroke fill;
    stroke: rgba(15, 23, 42, 0.45);
    stroke-width: 0.7px;
}

.bmi-analog-needle {
    position: absolute;
    left: 50%;
    top: calc(var(--gauge-size) / 2);
    bottom: auto;
    width: 4px;
    height: calc(var(--gauge-size) / 2 - var(--gauge-ring) - 16px);
    border-radius: 999px;
    background: linear-gradient(to top,
            rgba(15, 23, 42, 0.45),
            rgba(100, 116, 139, 0.35));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
    transform: translate(-50%, -100%) rotate(-90deg);
    transform-origin: 50% 100%;
    z-index: 2;
    transition: transform 0.35s ease;
}

.bmi-analog-needle::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 12px solid #1f2937;
}

.bmi-analog-pivot {
    position: absolute;
    left: 50%;
    top: calc(var(--gauge-size) / 2 - 7px);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px rgba(31, 41, 55, 0.2);
    z-index: 3;
}

.bmi-analog-center-label {
    position: absolute;
    left: 50%;
    top: calc(var(--gauge-size) / 2 - 30px);
    transform: translate(-50%, -50%);
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: #6b7280;
    letter-spacing: 0.1px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
}

.bmi-analog-percent {
    position: absolute;
    left: 50%;
    top: calc(var(--gauge-size) / 2 - 54px);
    transform: translate(-50%, -50%);
    font-size: 19px;
    line-height: 1;
    font-weight: 700;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: #374151;
    letter-spacing: 0.1px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
    display: none;
}

.bmi-analog-readout {
    position: absolute;
    top: 2px;
    left: 8px;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    z-index: 4;
    padding: 4px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    text-align: left;
}

.bmi-analog-value {
    font-size: 22px;
    line-height: 1;
    font-weight: 800;
    color: #1e3a5f;
}

.bmi-analog-status {
    display: none;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 700;
    color: #6b7280;
}

.bmi-analog-meter.underweight .bmi-analog-label.underweight,
.bmi-analog-meter.normal .bmi-analog-label.normal,
.bmi-analog-meter.overweight .bmi-analog-label.overweight,
.bmi-analog-meter.obese .bmi-analog-label.obese {
    opacity: 1;
    font-weight: 800;
}

.bmi-analog-meter.underweight .bmi-analog-status {
    color: #1d4ed8;
}

.bmi-analog-meter.underweight .bmi-analog-center-label {
    color: #1d4ed8;
}

.bmi-analog-meter.underweight .bmi-analog-percent {
    color: #1d4ed8;
}

.bmi-analog-meter.normal .bmi-analog-status {
    color: #166534;
}

.bmi-analog-meter.normal .bmi-analog-center-label {
    color: #166534;
}

.bmi-analog-meter.normal .bmi-analog-percent {
    color: #166534;
}

.bmi-analog-meter.overweight .bmi-analog-status {
    color: #b45309;
}

.bmi-analog-meter.overweight .bmi-analog-center-label {
    color: #b45309;
}

.bmi-analog-meter.overweight .bmi-analog-percent {
    color: #b45309;
}

.bmi-analog-meter.obese .bmi-analog-status {
    color: #b91c1c;
}

.bmi-analog-meter.obese .bmi-analog-center-label {
    color: #b91c1c;
}

.bmi-analog-meter.obese .bmi-analog-percent {
    color: #b91c1c;
}

.bmi-unit-toggle {
    display: inline-flex;
    gap: 6px;
    background: #f1f5f9;
    border: 1px solid #dbe3eb;
    border-radius: 12px;
    padding: 4px;
    width: fit-content;
}

.bmi-unit-btn {
    border: none;
    background: transparent;
    color: #1f2937;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bmi-unit-btn.active {
    background: #1e4d6b;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(30, 77, 107, 0.25);
}

.bmi-gender-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bmi-gender-label {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
}

.bmi-gender-options {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bmi-gender-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #d6dee7;
    background: #f8fafc;
    color: #1f2937;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.bmi-gender-option input {
    accent-color: #1e4d6b;
}

.bmi-age-row {
    width: 100%;
}

.bmi-age-field {
    max-width: 188px;
}

.bmi-age-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.bmi-age-input-wrap input {
    flex: 1 1 auto;
    min-width: 0;
}

.bmi-age-range {
    font-size: 14px;
    font-weight: 700;
    color: #4b5563;
    white-space: nowrap;
    flex-shrink: 0;
}

.bmi-input-group {
    display: none;
    grid-template-columns: repeat(2, minmax(92px, 128px));
    gap: 10px;
    width: fit-content;
    max-width: 100%;
}

.bmi-input-group#usInputs {
    grid-template-columns: repeat(3, minmax(64px, 92px));
}

.bmi-input-group.active {
    display: grid;
}

.bmi-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 6px;
}

.bmi-field {
    max-width: 128px;
}

.bmi-field.bmi-age-field {
    width: 188px;
    max-width: 188px;
}

.bmi-field input {
    width: 100%;
    border: 1px solid #c5d1da;
    border-radius: 10px;
    background: #ffffff;
    color: #1a1a2e;
    font-size: 14px;
    padding: 8px 10px;
}

.bmi-field input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.bmi-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.bmi-results {
    margin-top: 10px;
    width: min(100%, 340px);
    justify-self: end;
    grid-column: 2;
    grid-row: 2;
    display: none;
}

.bmi-results.show {
    display: block;
}

.bmi-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

/* Adjust layout when meter is hidden on desktop */
@media (min-width: 992px) {
    .bmi-result-grid.meter-hidden {
        position: relative;
        margin-top: -300px;
        /* Pull up further to match heading height */
        margin-bottom: 0;
    }

    .meter-hidden .bmi-score-card {
        padding-top: 22px;
        /* Slight extra padding for absolute print button */
    }

    .bmi-form-layout.meter-hidden .bmi-inline-details {
        width: calc(100% + 358px);
        /* 100% + 18px gap + 340px column */
        max-width: none;
        margin-top: 0;
    }
}

.bmi-score-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
}

.bmi-score-card h3 {
    margin: 0 0 8px 0;
}

.bmi-score-value {
    font-size: 44px;
    line-height: 1;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
}

.bmi-category {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}

.bmi-category.underweight {
    color: #1d4ed8;
}

.bmi-category.normal {
    color: #166534;
}

.bmi-category.overweight {
    color: #b45309;
}

.bmi-category.obese {
    color: #b91c1c;
}

.bmi-advice {
    margin: 0 0 8px 0;
    color: #374151;
}

.bmi-gender-note {
    margin: 0 0 8px 0;
    color: #4b5563;
    font-size: 13px;
}

.bmi-age-note {
    margin: 0 0 8px 0;
    color: #4b5563;
    font-size: 13px;
}

.bmi-summary {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}

.bmi-meter-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.bmi-meter-card h3 {
    margin: 0 0 2px 0;
}

.bmi-meter-scale {
    position: relative;
    display: flex;
    height: 16px;
    border-radius: 999px;
    overflow: visible;
    background: #e5e7eb;
    margin-top: 28px;
}

.bmi-meter-segment {
    height: 100%;
}

.bmi-meter-segment.underweight {
    background: #60a5fa;
    border-radius: 999px 0 0 999px;
}

.bmi-meter-segment.normal {
    background: #22c55e;
}

.bmi-meter-segment.overweight {
    background: #f59e0b;
}

.bmi-meter-segment.obese {
    background: #ef4444;
    border-radius: 0 999px 999px 0;
}

.bmi-meter-pointer {
    position: absolute;
    top: -12px;
    transform: translateX(-50%);
    z-index: 2;
    width: 0;
}

.bmi-pointer-arrow {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 11px solid #1f2937;
}

.bmi-meter-ticks {
    margin-top: 8px;
    position: relative;
    height: 18px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.bmi-meter-ticks span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    line-height: 1;
}

.bmi-meter-ticks span.start {
    transform: none;
}

.bmi-meter-ticks span.end {
    transform: translateX(-100%);
}

.bmi-details .detail-row {
    align-items: flex-start;
}

.bmi-details .detail-row span {
    flex: 1 1 auto;
}

.bmi-details strong {
    text-align: right;
    flex: 0 1 58%;
    overflow-wrap: anywhere;
}

.bmi-details-note {
    margin: 10px 2px 0;
    padding-top: 8px;
    border-top: 1px dashed #e5e7eb;
    font-size: 12px;
    line-height: 1.45;
    color: #6b7280;
}

.bmi-inline-details {
    width: 100%;
    margin-top: 8px;
    display: none;
}

.bmi-inline-details.show {
    display: block;
}

.bmi-mobile-details {
    display: none;
    margin-top: 0;
}

.bmi-mobile-details.show {
    display: block;
}

.bmi-table-wrap {
    overflow-x: auto;
}

.bmi-category-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    min-width: 560px;
}

.bmi-category-table th,
.bmi-category-table td {
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    text-align: left;
    font-size: 14px;
}

.bmi-category-table thead th {
    background: #f8fafc;
    color: #1f2937;
    font-weight: 700;
}

.bmi-category-table tbody tr:nth-child(even) {
    background: #fcfdff;
}

.bmi-standard-chart-wrap {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
}

.bmi-standard-track {
    position: relative;
}

.bmi-standard-bar {
    display: flex;
    height: 34px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.bmi-standard-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.2px;
    text-align: center;
}

.bmi-standard-segment.underweight {
    width: 28.33%;
    background: #60a5fa;
}

.bmi-standard-segment.normal {
    width: 21.67%;
    background: #22c55e;
}

.bmi-standard-segment.overweight {
    width: 16.67%;
    background: #f59e0b;
}

.bmi-standard-segment.obese {
    width: 33.33%;
    background: #ef4444;
}

.bmi-standard-scale {
    margin-top: 8px;
    position: relative;
    height: 18px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.bmi-standard-scale span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    line-height: 1;
}

.bmi-standard-scale span.start {
    transform: none;
}

.bmi-standard-scale span.end {
    transform: translateX(-100%);
}

.bmi-standard-legend {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

@media (min-width: 992px) {
    .bmi-analog-meter {
        margin-top: -20px;
    }
}

.bmi-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    font-weight: 600;
}

.bmi-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(17, 24, 39, 0.16);
}

.bmi-legend-dot.underweight {
    background: #60a5fa;
}

.bmi-legend-dot.normal {
    background: #22c55e;
}

.bmi-legend-dot.overweight {
    background: #f59e0b;
}

.bmi-legend-dot.obese {
    background: #ef4444;
}

@media (min-width: 768px) and (max-width: 991px) {
    #bmi-calculator-title {
        width: 100%;
        text-align: center;
    }

    .bmi-form-layout {
        grid-template-columns: 1fr;
        gap: 16px;
        justify-items: center;
    }

    .bmi-form-fields {
        width: 100%;
        max-width: 430px;
        align-items: center;
        grid-column: auto;
        grid-row: auto;
    }

    .bmi-unit-toggle {
        margin-inline: auto;
    }

    .bmi-gender-row {
        justify-content: center;
    }

    .bmi-age-row {
        display: flex;
        justify-content: center;
    }

    .bmi-age-field {
        width: 188px;
        max-width: 188px;
    }

    .bmi-age-input-wrap {
        justify-content: center;
    }

    .bmi-input-group {
        grid-template-columns: repeat(2, minmax(82px, 108px));
        width: fit-content;
    }

    .bmi-input-group#usInputs {
        grid-template-columns: repeat(3, minmax(58px, 82px));
    }

    .bmi-field {
        max-width: 108px;
    }

    .bmi-field.bmi-age-field {
        width: 188px;
        max-width: 188px;
    }

    .bmi-field label {
        text-align: center;
    }

    .bmi-field input {
        font-size: 13px;
        padding: 7px 8px;
    }

    .bmi-actions {
        justify-content: center;
    }

    .bmi-analog-meter {
        grid-column: auto;
        grid-row: auto;
    }

    .bmi-results {
        grid-column: auto;
        grid-row: auto;
        width: 100%;
        max-width: 430px;
        justify-self: center;
        margin-top: 8px;
    }

    .bmi-inline-details {
        display: none !important;
    }

}

@media (max-width: 767px) {
    #bmi-calculator-title {
        width: fit-content;
        max-width: 100%;
        display: block;
        margin-inline: auto;
        text-align: center;
    }

    .bmi-form-layout {
        grid-template-columns: 1fr;
        gap: 14px;
        justify-items: center;
    }

    .bmi-form-fields {
        width: 100%;
        max-width: 340px;
        align-items: center;
        grid-column: auto;
        grid-row: auto;
    }

    .bmi-analog-meter {
        --gauge-size: 260px;
        --gauge-ring: 34px;
        width: min(100%, 320px);
        justify-self: center;
        grid-column: auto;
        grid-row: auto;
    }

    .bmi-analog-label {
        font-size: 10.5px;
        stroke-width: 0.6px;
    }

    .bmi-unit-toggle {
        width: 100%;
        max-width: 320px;
        justify-content: space-between;
    }

    .bmi-unit-btn {
        width: 50%;
        padding: 8px 10px;
        font-size: 13px;
    }

    .bmi-gender-row {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .bmi-age-row {
        display: flex;
        justify-content: center;
    }

    .bmi-age-field {
        width: 188px;
        max-width: 188px;
        margin-inline: auto;
    }

    .bmi-age-range {
        font-size: 13px;
    }

    .bmi-gender-options {
        width: auto;
        justify-content: center;
    }

    .bmi-gender-option {
        justify-content: center;
    }

    .bmi-input-group,
    .bmi-input-group#usInputs {
        width: fit-content;
        gap: 8px;
    }

    .bmi-input-group {
        grid-template-columns: repeat(2, minmax(74px, 94px));
    }

    .bmi-input-group#usInputs {
        grid-template-columns: repeat(3, minmax(52px, 70px));
    }

    .bmi-field {
        max-width: 94px;
    }

    .bmi-field.bmi-age-field {
        width: 188px;
        max-width: 188px;
    }

    .bmi-field label {
        text-align: center;
        font-size: 13px;
    }

    .bmi-field input {
        font-size: 13px;
        padding: 7px 8px;
    }

    .bmi-actions {
        justify-content: center;
    }

    .bmi-actions .age-btn {
        width: auto;
        min-width: 136px;
    }

    .bmi-results {
        grid-column: auto;
        grid-row: auto;
        width: 100%;
        max-width: 340px;
        justify-self: center;
        margin-top: 8px;
    }

    .bmi-inline-details {
        display: none !important;
    }

    .bmi-score-value {
        font-size: 38px;
    }

    .bmi-meter-pointer {
        top: -11px;
    }

    .bmi-pointer-arrow {
        border-left-width: 6px;
        border-right-width: 6px;
        border-top-width: 10px;
    }

    .bmi-standard-bar {
        height: 30px;
    }

    .bmi-standard-segment {
        font-size: 11px;
    }

    .bmi-standard-segment span {
        display: none;
    }

    .bmi-standard-legend {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .bmi-table-wrap {
        overflow-x: visible;
    }

    .bmi-category-table {
        min-width: 0;
        table-layout: fixed;
    }

    .bmi-category-table th,
    .bmi-category-table td {
        padding: 8px 6px;
        font-size: 12px;
        word-break: break-word;
    }
}

/* Fix for vertical alignment of checkbox/radio inputs and their label text */
.age-checkbox,
.age-radio,
.date-end-checkbox {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 0;
    line-height: 1 !important;
}

.age-checkbox input[type="checkbox"],
.age-checkbox input[type="radio"],
.age-radio input[type="checkbox"],
.age-radio input[type="radio"],
.date-end-checkbox input[type="checkbox"] {
    margin: 0 !important;
    position: relative !important;
    top: -1px !important;
}


/* Custom mobile fixes for Age Calculator specific section */
@media (max-width: 767px) {

    .main-age-calc-section h2.date-title-line,
    .main-date-calc-section h2.date-title-line {
        text-align: left !important;
    }

    .main-age-calc-section .age-input-row,
    .main-date-calc-section .age-input-row {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 8px !important;
        justify-content: space-between !important;
    }

    .main-age-calc-section .date-inline-label,
    .main-date-calc-section .date-inline-label {
        width: 100% !important;
        text-align: left !important;
        margin-bottom: 6px !important;
        margin-left: 0 !important;
        display: block !important;
    }

    .main-age-calc-section .age-input-row select,
    .main-date-calc-section .age-input-row select {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: none !important;
        text-align: center !important;
        padding: 8px 4px !important;
    }

    .main-date-calc-section .age-input-row input[type="number"] {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: none !important;
        text-align: center !important;
        padding: 8px 4px !important;
    }

    .main-date-calc-section .date-add-inputs {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        width: 100% !important;
        gap: 8px !important;
    }

    .main-date-calc-section .date-add-inputs select#addSubtractOperator {
        grid-column: 1 / -1 !important;
        justify-self: center !important;
        flex: none !important;
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
        height: 32px !important;
        margin: 4px auto 12px auto !important;
        text-align: center !important;
        text-align-last: center !important;
    }

    .main-date-calc-section .date-add-inputs input[type="number"] {
        height: auto !important;
        font-size: default !important;
        padding: default !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        box-sizing: border-box !important;
    }

    .main-age-calc-section .age-actions,
    .main-date-calc-section .age-actions {
        justify-content: flex-start !important;
        padding-left: 0 !important;
    }

    .main-age-calc-section .age-btn,
    .main-date-calc-section .age-btn {
        width: auto !important;
    }

    .main-date-calc-section .date-end-option {
        display: flex !important;
        position: relative !important;
        align-items: center !important;
        justify-content: flex-start !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
    }

    .main-date-calc-section .date-end-checkbox {
        text-align: left !important;
        justify-content: flex-start !important;
        width: auto !important;
        order: 2 !important;
    }

    .main-date-calc-section #holidayDropdownWrapper {
        position: static !important;
        text-align: left !important;
        width: auto !important;
        order: 1 !important;
    }

    .main-date-calc-section #holidaySettingsToggle {
        justify-content: flex-start !important;
    }

    .main-date-calc-section #holidayOptionsDropdown {
        position: absolute !important;
        left: 0 !important;
        top: 100% !important;
        transform: none !important;
        width: 90vw !important;
        max-width: 400px !important;
        box-sizing: border-box !important;
        margin-top: 8px !important;
        overflow-y: hidden !important;
        max-height: none !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid #e0e4e8 !important;
    }

    .main-date-calc-section #addSubBusinessOptionsDropdown {
        position: absolute !important;
        left: 50% !important;
        top: 100% !important;
        transform: translateX(-50%) !important;
        width: 90vw !important;
        max-width: 400px !important;
        box-sizing: border-box !important;
        margin-top: 8px !important;
        overflow-y: hidden !important;
        max-height: none !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid #e0e4e8 !important;
    }

    .main-date-calc-section #holidayOptionsDropdown::-webkit-scrollbar,
    .main-date-calc-section #addSubBusinessOptionsDropdown::-webkit-scrollbar {
        display: none !important;
    }

    .main-date-calc-section #addSubBusinessOptionRow {
        align-items: flex-start !important;
    }

    .main-date-calc-section #useBusinessDaysToggle {
        justify-content: flex-start !important;
    }

    .main-date-calc-section .age-help {
        text-align: left !important;
    }

    .main-date-calc-section #calcAddSubtractBtn {
        margin: 0 auto;
        display: block;
    }

    .main-date-calc-section .age-actions:has(#calcAddSubtractBtn) {
        justify-content: center !important;
        width: 100%;
    }
}

/* Print Styles for BMI Meter */
@media print {

    .bmi-analog-dial,
    .bmi-analog-dial::after,
    .bmi-analog-needle,
    .bmi-analog-needle::before,
    .bmi-analog-pivot,
    .bmi-category-dot,
    .bmi-category-item {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Mobile left-alignment overrides for BMI Calculator */
@media (max-width: 767px) {
    .bmi-form-layout {
        text-align: left !important;
        justify-items: stretch !important;
    }

    .bmi-form-fields {
        width: 100%;
        align-items: stretch !important;
    }

    .bmi-gender-row,
    .bmi-gender-options,
    .bmi-gender-option {
        justify-content: flex-start !important;
    }

    .bmi-age-row {
        justify-content: flex-start !important;
    }

    .bmi-field {
        max-width: 100% !important;
        width: 100% !important;
    }

    .bmi-field label {
        text-align: left !important;
        display: block;
    }

    .bmi-field.bmi-age-field {
        margin-inline: 0 !important;
        width: 190px !important;
        max-width: 190px !important;
    }

    #metricInputs {
        grid-template-columns: 137px 137px !important;
        width: 100% !important;
        gap: 10px !important;
        box-sizing: border-box !important;
    }

    #usInputs {
        grid-template-columns: 87px 87px 87px !important;
        width: 100% !important;
        gap: 10px !important;
        box-sizing: border-box !important;
    }

    .bmi-actions {
        justify-content: flex-start !important;
        width: 100%;
        gap: 10px !important;
        box-sizing: border-box !important;
    }

    .bmi-actions .bmi-btn {
        flex: 1;
        /* Make buttons expand equally */
    }
}