/* --- Colors --- */
:root {---start-of-color-variables: "Start of color variables";}
:root {
    --primary-color: #343a40;
    --primary-color-darker: #212529;
    --text-dark: #212529;
    --text-medium: #495057;
    --text-light: #6c757d;
    --text-dob: #6c757d; /* Age Calc theme value */
    --text-age: #212529; /* Age Calc theme value */
    --text-age-strong: #333; /* Age Calc theme value */
    --text-placeholder: #888;
    --fab-text-color: #ffffff;
    --toast-text-color: #ffffff;
    --input-text-color: #495057; /* Age Calc theme value */
    --confetti-text-color: #ffffff; /* Kept for potential future use */
    --bg-light: #f8f9fa; /* Age Calc theme value */
    --bg-white: #ffffff;
    --bg-subtle: #f1f3f5; /* Age Calc theme value */
    --bg-placeholder: #e9ecef;
    --modal-overlay-bg: rgba(0, 0, 0, 0.5);
    --toast-bg: #343a40;
    --hover-bg-light: #e9ecef;
    --input-bg-color: #ffffff;
    --border-light: #dee2e6;
    --border-medium: #ced4da;
    --border-subtle: #e9ecef; /* Age Calc theme value */
    --hover-border-medium: #adb5bd;
    --input-border-color: var(--border-medium); /* Uses Age Calc's border-medium */
    --focus-ring-color: rgba(52, 58, 64, 0.25);
    --emoji-color: var(--primary-color); /* Uses Age Calc's primary-color */
    --panel-icon-color: var(--primary-color);
    --firestore-modal-overlay-bg: rgba(0, 0, 0, 0.6);
    --firestore-modal-content-bg: #fefefe;
    --firestore-modal-border-color: #888;
    --firestore-modal-text-color: #555;
    --firestore-loader-track-color: #f3f3f3;
    --firestore-loader-spinner-color: var(--primary-color);

}
:root {---end-of-color-variables: "End of color variables";}

/* --- Typography --- */
:root {
    --font-family-base: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    /* --font-weight-light: 300; */ /* Removed */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --person-name-font-weight: var(--font-weight-semibold);
    --person-age-strong-font-weight: var(--font-weight-semibold);
    --stats-grid-value-font-weight: var(--font-weight-bold);
    --label-font-weight: var(--font-weight-bold);
    --confetti-text-font-weight: var(--font-weight-bold); /* Kept */
    --modal-close-font-weight: var(--font-weight-bold);
    --heading-h1-font-size: 2em; /* Used for single profile name */
    --person-name-font-size: 1.1em; /* Used for couple names */
    --profile-placeholder-font-size: 0.8em;
    --person-dob-font-size: 0.95em;
    --person-age-font-size: 1em;
    --heart-emoji-font-size: 2em; /* Kept */
    --date-range-font-size: 1em;
    --heading-h2-font-size: 1.5em;
    --duration-text-font-size: 1.1em;
    --stats-grid-font-size: 1.1em;
    --note-font-size: 0.9em;
    --fab-icon-font-size: 24px;
    --fab-option-font-size: 0.9em;
    --modal-close-font-size: 28px;
    --input-font-size: 1em;
    --modal-result-font-size: 1em;
    --confetti-text-font-size: 14px; /* Kept */
    --toast-font-size: 0.95em;
    --profile-selector-font-size: 0.9em;
    --line-height-base: 1.5;
    --line-height-heading: 1.2;
    /* --line-height-tight: 1.1; */ /* Removed */
    --person-name-line-height: 1.3;
    --modal-result-line-height: 1.6;
    --modal-close-line-height: 1;
    --heart-emoji-line-height: 1; /* Kept */
    --confetti-text-line-height: 1; /* Kept */
    --link-text-decoration: none;
    --link-hover-text-decoration: underline;
    --firestore-modal-text-font-size: 16px;
}

/* --- Sizing & Spacing --- */
:root {
    --container-max-width: 480px;
    --profile-picture-size: 100px; /* Couple view image size */
    --profile-header-image-size: 120px; /* Single view image size */
    --profile-header-image-margin-bottom: 15px; /* For single view image */
    --fab-size: 56px;
    --modal-max-width: 450px;
    --modal-result-min-height: 50px;
    --confetti-size: 10px; /* Kept */
    --focus-ring-width: 2px;
    --profile-selector-img-size: 30px;
    --profile-item-icon-size: 22px;
    --body-padding-vertical: 15px;
    --body-padding-horizontal: 15px;
    --container-padding: 30px;
    --section-margin-bottom: 25px;
    --person-section-gap: 15px;
    --person-name-margin-bottom: 8px;
    --profile-picture-margin-bottom: 8px;
    --person-dob-margin-bottom: 5px;
    --section-padding-vertical: 25px;
    --section-padding-horizontal: 5px;
    --date-range-margin-bottom: 25px;
    --heading-margin-bottom: 15px;
    --duration-text-margin: 10px 0 20px 0;
    --stats-grid-gap-vertical: 5px;
    --stats-grid-gap-horizontal: 10px;
    --stats-grid-margin-top: 15px;
    --stats-grid-label-padding-right: 5px;
    --stats-grid-value-padding-left: 5px;
    --note-section-margin-top: 20px;
    --note-padding: 15px;
    --fab-container-position-offset: 20px;
    --fab-margin-left: 10px;
    --fab-option-padding-vertical: 8px;
    --fab-option-padding-horizontal: 15px;
    --fab-option-margin-left: 10px;
    --modal-padding: 15px;
    --modal-content-padding-vertical: 25px;
    --modal-content-padding-horizontal: 30px;
    --modal-close-position-offset-top: 10px;
    --modal-close-position-offset-right: 15px;
    --modal-close-padding-horizontal: 5px;
    --modal-heading-margin-bottom: 20px;
    --label-margin-bottom: 8px;
    --input-padding-vertical: 10px;
    --input-padding-horizontal: 10px;
    --input-margin-bottom: 15px;
    --modal-result-margin-top: 20px;
    --modal-result-padding: 15px;
    --list-padding-left: 20px;
    --list-item-margin-bottom: 5px;
    --toast-initial-bottom-offset: 30px;
    --toast-shown-bottom-offset: 50px;
    --toast-padding-vertical: 12px;
    --toast-padding-horizontal: 25px;
    --input-picker-margin-left: -25px;
    --input-picker-padding: 5px;
    --profile-selector-padding-vertical: 10px;
    --profile-selector-padding-horizontal: 0;
    --profile-item-padding-vertical: 5px;
    --profile-item-padding-horizontal: 10px;
    --profile-item-margin-right: 8px;
    --profile-item-gap: 8px;
    --firestore-modal-content-padding-v: 25px; /* Vertical padding */
    --firestore-modal-content-padding-h: 40px; /* Horizontal padding */
    --firestore-loader-size: 40px;
    --firestore-loader-margin-bottom: 20px;
}

/* --- Borders & Radius --- */
:root {
    --container-border-radius: 15px;
    --section-border-radius: 10px;
    --border-radius-round: 50%;
    --fab-option-border-radius: 20px;
    --input-border-radius: 5px;
    --modal-result-border-radius: 8px;
    --toast-border-radius: 25px;
    --profile-item-border-radius: 20px;
    --profile-picture-border-width: 2px;
    --standard-border-width: 1px;
    --profile-item-border-width: 1px;
    --border-style: solid;
    --firestore-modal-border-radius: 8px;
    --firestore-loader-border-width: 5px;
}

/* --- Shadows --- */
:root {
    --container-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --fab-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    --fab-option-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    --modal-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    --toast-box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    --confetti-text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); /* Kept */
    --profile-item-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --firestore-modal-box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* --- Transitions & Animations --- */
:root {
    --transition-duration-fast: 0.2s;
    --transition-duration-medium: 0.3s;
    --transition-duration-toast: 0.4s;
    /* --confetti-base-anim-duration: 4s; */ /* Removed */
    /* --confetti-base-anim-delay: 5s; */ /* Removed */
    --transition-timing-standard: ease;
    --transition-timing-snap: ease-in-out;
    --fab-hover-scale: 1.05;
    --fab-option-initial-offset-x: 20px;
    --fab-option-initial-scale: 0.9;
    --input-picker-opacity: 0.6;
    --input-picker-filter: none; /* Age Calc theme value */
    --confetti-piece-opacity: 0.7; /* Kept */
    --confetti-text-opacity: 0.9; /* Kept */
    --confetti-initial-top: -20px; /* Kept */
}

/* --- Stacking Order (Z-index) --- */
:root {
    --z-index-fab-container: 1000;
    --z-index-modal: 1001;
    --z-index-confetti: 999; /* Kept */
    --z-index-toast: 1010;
    --z-index-firestore-modal: 1050;
}

            /*-------------------------------------*
         * Body & Base Layout
         *-------------------------------------*/
            body {
                -webkit-user-select: none;
                -moz-user-select: none;
                -ms-user-select: none;
                user-select: none;
                
                font-family: var(--font-family-base);
                background: var(--bg-light);
                color: var(--text-dark);
                font-weight: var(--font-weight-normal);
                line-height: var(--line-height-base);
                display: flex;
                flex-direction: column;
                justify-content: flex-start;
                align-items: center;
                min-height: 100vh;
                margin: 0;
                /* Padding: Top, L/R, Bottom(0) */
                padding: var(--body-padding-vertical) var(--body-padding-horizontal) 0;
                box-sizing: border-box;
                overflow-x: hidden;
                position: relative;
            }

            /*-------------------------------------*
         * Main Content Container (.container)
         *-------------------------------------*/
            .container {
                background-color: var(--bg-white);
                border-radius: var(--container-border-radius);
                box-shadow: var(--container-box-shadow);
                padding: var(--container-padding);
                max-width: var(--container-max-width);
                width: 100%;
                border: var(--standard-border-width) solid var(--border-light);
                position: relative;
                z-index: 1;
                box-sizing: border-box;
                margin-top: 0;
                margin-bottom: 0; /* No space above profile selector */
            }

            /*-------------------------------------*
         * Utility Class
         *-------------------------------------*/
            .hidden {
                display: none !important;
            } /* Utility to hide elements */

            /*-------------------------------------*
         * Couple Display Section
         *-------------------------------------*/
            .two-person-section {
                display: flex;
                justify-content: space-around;
                align-items: flex-start;
                margin-bottom: var(--section-margin-bottom);
                gap: var(--person-section-gap);
                text-align: center;
            }
            .person-display {
                display: flex;
                flex-direction: column;
                align-items: center;
                flex: 1;
                min-width: 0;
            }
            .person-name {
                font-size: var(--person-name-font-size);
                color: var(--primary-color);
                margin-top: 0;
                margin-bottom: var(--person-name-margin-bottom);
                font-weight: var(--person-name-font-weight);
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                width: 100%;
                min-height: calc(var(--person-name-font-size) * var(--person-name-line-height));
                line-height: var(--person-name-line-height);
            }
            .profile-picture {
                width: var(--profile-picture-size);
                height: var(--profile-picture-size);
                border-radius: var(--border-radius-round);
                border: var(--profile-picture-border-width) solid var(--border-subtle);
                display: flex;
                justify-content: center;
                align-items: center;
                overflow: hidden;
                background-color: var(--bg-placeholder);
                text-align: center;
                font-size: var(--profile-placeholder-font-size);
                color: var(--text-placeholder);
                flex-shrink: 0;
                margin-bottom: var(--profile-picture-margin-bottom);
            }
            .profile-picture img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
            .profile-picture .placeholder-text {
                padding: 10px;
            }
            .heart-emoji {
                font-size: var(--heart-emoji-font-size);
                color: var(--emoji-color);
                line-height: var(--heart-emoji-line-height);
                flex-shrink: 0;
                margin-top: calc(1.1em * 1.3 + 8px); /* Align roughly below names */
            }
            .person-display .dob {
                font-size: var(--person-dob-font-size);
                color: var(--text-dob);
                margin-top: 0;
                margin-bottom: var(--person-dob-margin-bottom);
                min-height: 1.2em;
            }
            .person-display .age {
                font-size: var(--person-age-font-size);
                color: var(--text-age);
                margin-top: 0;
                margin-bottom: 0;
                min-height: 1.2em;
            }
            .person-display .age strong {
                font-weight: var(--person-age-strong-font-weight);
                color: var(--text-age-strong);
            }

            /*-------------------------------------*
         * Single Profile Display Section
         *-------------------------------------*/
            #single-profile-display {
                text-align: center;
                margin-bottom: var(--section-margin-bottom);
            }
            /* Specific style for larger image in single view */
            #single-profile-display .profile-picture {
                margin-left: auto;
                margin-right: auto;
                width: var(--profile-header-image-size);
                height: var(--profile-header-image-size);
                margin-bottom: var(--profile-header-image-margin-bottom);
            }
            /* Specific style for larger name in single view */
            #single-profile-display #singlePersonNameDisplay {
                font-size: var(--heading-h1-font-size);
                font-weight: var(--person-name-font-weight);
                color: var(--text-dark);
                margin-bottom: var(--profile-heading-margin-bottom);
            }
            #single-profile-display #singlePersonDobDisplay {
                font-size: var(--person-dob-font-size);
                color: var(--text-dob);
                margin-top: 0;
                margin-bottom: 0;
            }

            /*-------------------------------------*
         * Calculation Section (Shared)
         *-------------------------------------*/
            .calculation-section {
                background-color: var(--bg-subtle);
                border-radius: var(--section-border-radius);
                padding: var(--section-padding-vertical) var(--section-padding-horizontal);
                text-align: center;
                margin-top: 0;
            }
            .date-range {
                display: flex;
                justify-content: space-around;
                margin-bottom: var(--date-range-margin-bottom);
                font-size: var(--date-range-font-size);
                color: var(--text-light);
            }
            .age-details h2 {
                /* Title: "Relationship Duration" or "Age Details" */
                font-size: var(--heading-h2-font-size);
                line-height: var(--line-height-heading);
                margin-bottom: var(--heading-margin-bottom);
                color: var(--text-dark);
                font-weight: var(--font-weight-semibold);
            }
            .age-details > p:first-of-type {
                /* Y M D display */
                margin: var(--duration-text-margin);
                font-size: var(--duration-text-font-size);
                color: var(--text-dark);
            }
            .age-details strong {
                color: var(--primary-color);
            }
            .age-stats-grid {
                /* Grid for Total units */
                display: grid;
                grid-template-columns: 1fr 1fr;
                justify-content: center;
                gap: var(--stats-grid-gap-vertical) var(--stats-grid-gap-horizontal);
                margin-top: var(--stats-grid-margin-top);
                font-size: var(--stats-grid-font-size);
                color: var(--text-medium);
            }
            .age-stats-grid span:nth-child(odd) {
                /* Labels */
                text-align: right;
                color: var(--text-dark);
                padding-right: var(--stats-grid-label-padding-right);
            }
            .age-stats-grid span:nth-child(even) {
                /* Values */
                text-align: left;
                font-weight: var(--stats-grid-value-font-weight);
                color: var(--primary-color);
                padding-left: var(--stats-grid-value-padding-left);
                overflow-wrap: break-word; /* Wrap long numbers */
                min-width: 0;
            }

            /*-------------------------------------*
         * Note Section (Shared)
         *-------------------------------------*/
            .note-section {
                margin-top: var(--note-section-margin-top);
                text-align: left;
                font-size: var(--note-font-size);
                color: var(--text-light);
                background-color: var(--bg-subtle);
                padding: var(--note-padding);
                border-radius: var(--section-border-radius);
                word-wrap: break-word;
            }
            .note-section a {
                color: var(--primary-color);
                text-decoration: var(--link-text-decoration);
                font-weight: var(--font-weight-medium);
            }
            .note-section a:hover {
                text-decoration: var(--link-hover-text-decoration);
                color: var(--primary-color-darker);
            }

            /*-------------------------------------*
         * Profile Selector ("Family & Friend")
         *-------------------------------------*/
            .profile-selector-container {
                width: 95%;
                max-width: var(--container-max-width);
                overflow-x: auto; /* Horizontal scroll */
                padding: var(--profile-selector-padding-vertical) var(--profile-selector-padding-horizontal);
                margin-top: 0; /* No space between container and selector */
                margin-bottom: 0;
                -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
                -ms-overflow-style: none;
                scrollbar-width: none; /* Hide scrollbar */
            }
            .profile-selector-container::-webkit-scrollbar {
                display: none;
                height: 0;
                width: 0;
            } /* Hide scrollbar */
            .profile-selector-list {
                display: flex;
                flex-wrap: nowrap;
                padding-bottom: 5px; /* Prevent items touching bottom */
            }
            .profile-item {
                display: flex;
                align-items: center;
                gap: var(--profile-item-gap);
                padding: var(--profile-item-padding-vertical) var(--profile-item-padding-horizontal);
                border: var(--profile-item-border-width) solid var(--border-medium);
                border-style: var(--border-style);
                border-radius: var(--profile-item-border-radius);
                margin-right: var(--profile-item-margin-right);
                background-color: var(--bg-white);
                cursor: pointer;
                transition: background-color var(--transition-duration-fast), border-color var(--transition-duration-fast);
                white-space: nowrap;
                font-size: var(--profile-selector-font-size);
                color: var(--text-medium);
                box-shadow: var(--profile-item-box-shadow);
                flex-shrink: 0;
            }
            .profile-item:last-child {
                margin-right: 0;
            }
            .profile-item:hover {
                background-color: var(--hover-bg-light);
                border-color: var(--hover-border-medium);
            }
            .profile-item.active {
                background-color: var(--primary-color);
                border-color: var(--primary-color-darker);
                color: var(--fab-text-color);
                font-weight: var(--font-weight-medium);
            }
            .profile-item.active:hover {
                background-color: var(--primary-color-darker);
            }
            .profile-item-img {
                width: var(--profile-selector-img-size);
                height: var(--profile-selector-img-size);
                border-radius: var(--border-radius-round);
                object-fit: cover;
                border: var(--standard-border-width) solid var(--border-subtle);
                border-style: var(--border-style);
            }

            /*-------------------------------------*
         * Modal Dialogs
         *-------------------------------------*/
            .modal {
                display: none;
                position: fixed;
                z-index: var(--z-index-modal);
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                overflow: auto;
                background-color: var(--modal-overlay-bg);
                justify-content: center;
                align-items: center;
                padding: var(--modal-padding);
                box-sizing: border-box;
            }
            .modal-content {
                background-color: var(--bg-white);
                margin: auto;
                padding: var(--modal-content-padding-vertical) var(--modal-content-padding-horizontal);
                border: none;
                border-radius: var(--section-border-radius);
                width: 100%;
                max-width: var(--modal-max-width);
                color: var(--text-dark);
                box-shadow: var(--modal-box-shadow);
                position: relative;
                box-sizing: border-box;
            }
            .close-button {
                color: var(--text-light);
                position: absolute;
                top: var(--modal-close-position-offset-top);
                right: var(--modal-close-position-offset-right);
                font-size: var(--modal-close-font-size);
                font-weight: var(--modal-close-font-weight);
                cursor: pointer;
                line-height: var(--modal-close-line-height);
                padding: 0 var(--modal-close-padding-horizontal);
            }
            .close-button:hover,
            .close-button:focus {
                color: var(--text-dark);
                text-decoration: none;
            }
            .modal h2 {
                margin-top: 0;
                margin-bottom: var(--modal-heading-margin-bottom);
                color: var(--text-dark);
                text-align: center;
                font-weight: var(--font-weight-semibold);
                line-height: var(--line-height-heading);
            }
            .modal label {
                display: block;
                margin-bottom: var(--label-margin-bottom);
                font-weight: var(--label-font-weight);
                color: var(--text-medium);
            }
            .modal input[type="date"] {
                width: 100%;
                padding: var(--input-padding-vertical) var(--input-padding-horizontal);
                margin-bottom: var(--input-margin-bottom);
                border: var(--standard-border-width) solid var(--input-border-color);
                border-radius: var(--input-border-radius);
                background-color: var(--input-bg-color);
                color: var(--input-text-color);
                font-size: var(--input-font-size);
                box-sizing: border-box;
                -webkit-appearance: none;
                -moz-appearance: none;
                appearance: none;
            }
            .modal input[type="date"]:focus {
                outline: none;
                border-color: var(--primary-color);
                box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
            }
            .modal input[type="date"]::-webkit-calendar-picker-indicator {
                opacity: var(--input-picker-opacity);
                cursor: pointer;
                margin-left: var(--input-picker-margin-left);
                padding: var(--input-picker-padding);
                filter: var(--input-picker-filter);
            }
            .modal input[type="date"]::after {
                content: none;
            }
            .modal-result {
                margin-top: var(--modal-result-margin-top);
                padding: var(--modal-result-padding);
                background-color: var(--bg-subtle);
                border-radius: var(--modal-result-border-radius);
                min-height: var(--modal-result-min-height);
                color: var(--text-dark);
                font-size: var(--modal-result-font-size);
                line-height: var(--modal-result-line-height);
            }
            .modal-result strong {
                color: var(--primary-color);
                font-weight: var(--font-weight-medium);
            }
            .modal-result ul {
                padding-left: var(--list-padding-left);
                margin: 0;
            }
            .modal-result li {
                margin-bottom: var(--list-item-margin-bottom);
            }

            /*-------------------------------------*
         * Animations (Confetti)
         *-------------------------------------*/
            #animation-container {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                overflow: hidden;
                pointer-events: none;
                z-index: var(--z-index-confetti);
            }
            .confetti {
                position: absolute;
                width: var(--confetti-size);
                height: var(--confetti-size);
                opacity: var(--confetti-piece-opacity);
                animation: fall linear infinite;
                top: var(--confetti-initial-top);
            }
            @keyframes fall {
                0% {
                    transform: translateY(0) rotate(0deg);
                    opacity: var(--confetti-piece-opacity);
                }
                100% {
                    transform: translateY(105vh) rotate(720deg);
                    opacity: 0;
                }
            }
            .confetti-text {
                background-color: transparent !important;
                width: auto !important;
                height: auto !important;
                border-radius: 0 !important;
                font-size: var(--confetti-text-font-size);
                font-weight: var(--confetti-text-font-weight);
                color: var(--confetti-text-color);
                text-shadow: var(--confetti-text-shadow);
                line-height: var(--confetti-text-line-height);
                position: absolute;
                opacity: var(--confetti-text-opacity);
                animation: fall linear infinite;
                top: var(--confetti-initial-top);
            }

            /*-------------------------------------*
         * Toast Notifications
         *-------------------------------------*/
            .toast-message {
                position: fixed;
                bottom: var(--toast-initial-bottom-offset);
                left: 50%;
                transform: translateX(-50%);
                background-color: var(--toast-bg);
                color: var(--toast-text-color);
                padding: var(--toast-padding-vertical) var(--toast-padding-horizontal);
                border-radius: var(--toast-border-radius);
                font-size: var(--toast-font-size);
                z-index: var(--z-index-toast);
                box-shadow: var(--toast-box-shadow);
                opacity: 0;
                transition: opacity var(--transition-duration-toast) var(--transition-timing-snap), bottom var(--transition-duration-toast) var(--transition-timing-snap);
                pointer-events: none;
            }
            .toast-message.show {
                opacity: 1;
                bottom: var(--toast-shown-bottom-offset);
            }
            
                .edge-handle {
        position: fixed;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        width: 15px;
        height: 100px;
        background-color: #ffffff;
        border: 1px solid #dee2e6;
        border-right: none;
        border-radius: 10px 0 0 10px;
        box-shadow: -1px 0 3px rgba(0, 0, 0, 0.05);
        cursor: pointer;
        z-index: 1021; /* MODIFIED for your calculator */
        transition: right 0.3s ease-in-out, background-color 0.3s, border-color 0.3s;
    }
    .edge-panel.open + .edge-handle {
        right: 120px; /* Adjusted to panel width */
        background-color: #f1f3f5;
        border-color: #ced4da;
    }

    .edge-panel {
        position: fixed;
        top: 10%;
        width: 120px; /* Panel width */
        right: -120px; /* Initially hidden */
        height: 80%;
        font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
        background-color: #ffffff;
        border-left: 1px solid #dee2e6;
        border-top: 1px solid #dee2e6;
        border-bottom: 1px solid #dee2e6;
        border-right: none;
        border-radius: 15px 0 0 15px;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.08);
        padding: 10px 8px 15px; /* top/bottom, left/right, bottom */
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        transition: right 0.3s ease-in-out;
        z-index: 1020; /* MODIFIED for your calculator */
        overflow-y: auto;
    }
    .edge-panel.open {
        right: 0;
    }

    .panel-title {
        color: #212529;
        font-size: 0.9em;
        font-weight: 600;
        margin-bottom: 0;
        text-align: center;
        width: 100%;
        padding: 0 5px;
        box-sizing: border-box;
        position: relative;
    }

    .panel-title::after {
        content: '';
        display: block;
        width: 80%;
        height: 1px;
        background-color: #e9ecef;
        margin: 8px auto 15px auto;
    }

    .panel-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        cursor: pointer;
        transition: background-color 0.2s ease;
        width: 100%;
        padding: 5px 0;
        border-radius: 8px;
        background-color: transparent;
    }

    @media (hover: hover) and (pointer: fine) {
        .panel-item:hover {
            background-color: #f1f3f5;
        }
    }

    .panel-item:active,
    .panel-item:focus,
    .panel-item:focus-visible {
        outline: none !important;
        background-color: transparent !important;
    }

.panel-item .panel-item-svg {
    margin-bottom: 6px;
    color: var(--panel-icon-color); /* SVG 'currentColor' will use this */
    width: 32px;   /* Adjust as desired */
    height: 32px;  /* Adjust as desired */
    display: block;
}


    .panel-item span {
        font-size: 0.75em;
        color: #495057;
        word-break: break-word;
        margin-top: 2px;
        line-height: 1.2;
    }

    .edge-panel > .panel-item + .panel-item {
        margin-top: 18px;
    }

    .edge-panel > .panel-item + .panel-title {
        margin-top: 22px;
    }

/* --- Styling for Special Date Calculator Modal --- */

/* Style for the labels in the Special Date Calculator */
#specialDateCalculatorModal label {
    display: block; /* Make each label take its own line */
    margin-top: 15px; /* Add some space above each label */
    margin-bottom: 5px; /* Add a little space below each label, before the input */
    font-weight: var(--label-font-weight, 600); /* Use your variable or a default bold */
    color: var(--text-medium, #495057); /* Use your variable or a default medium text color */
}

/* Ensure the first label doesn't have too much top margin */
#specialDateCalculatorModal label[for="specialStartDate"] {
    margin-top: 5px;
}

/* Style for the input fields (date, number) and the select dropdown */
#specialDateCalculatorModal input[type="date"],
#specialDateCalculatorModal input[type="number"],
#specialDateCalculatorModal select {
    width: 100%; /* Make them take the full width of the modal content area */
    padding: var(--input-padding-vertical, 10px) var(--input-padding-horizontal, 10px); /* Use your input padding variables */
    margin-bottom: var(--input-margin-bottom, 15px); /* Use your input margin variable */
    border: var(--standard-border-width, 1px) solid var(--input-border-color, #ced4da); /* Use your border variables */
    border-radius: var(--input-border-radius, 5px); /* Use your border radius variable */
    background-color: var(--input-bg-color, #ffffff); /* Use your input background variable */
    color: var(--input-text-color, #495057); /* Use your input text color variable */
    font-size: var(--input-font-size, 1em); /* Use your input font size variable */
    box-sizing: border-box; /* Important for width and padding to work well together */
    -webkit-appearance: none; /* Remove default system appearance for date/select where possible */
    -moz-appearance: none;
    appearance: none;
}

/* Specific styling for the number input to prevent spinner arrows if desired, or adjust width */
#specialDateCalculatorModal input[type="number"] {
    /* You can add specific styles here if needed, like removing spinners on some browsers: */
    /* -moz-appearance: textfield; */
}
/* #specialDateCalculatorModal input[type="number"]::-webkit-outer-spin-button,
#specialDateCalculatorModal input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
} */


/* Style for the select dropdown to make it look more like other inputs */
#specialDateCalculatorModal select {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007bff%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'); /* Basic dropdown arrow */
    background-repeat: no-repeat;
    background-position: right .7em top 50%, 0 0;
    background-size: .65em auto, 100%;
    padding-right: 2em; /* Make space for the arrow */
}

/* Focus styles for inputs and select, using your theme's focus ring */
#specialDateCalculatorModal input[type="date"]:focus,
#specialDateCalculatorModal input[type="number"]:focus,
#specialDateCalculatorModal select:focus {
    outline: none;
    border-color: var(--primary-color, #343a40); /* Use your primary color */
    box-shadow: 0 0 0 var(--focus-ring-width, 2px) var(--focus-ring-color, rgba(52, 58, 64, 0.25)); /* Use your focus variables */
}

/* Style for the "Calculate Target Date" button */
#specialDateCalculatorModal #calculateSpecialDateBtn {
    background-color: var(--primary-color, #343a40); /* Use your primary color */
    color: var(--fab-text-color, #ffffff); /* Use your FAB text color (assuming it's white/light) */
    padding: 12px 15px; /* Slightly more padding for a better feel */
    font-size: 1em;
    font-weight: var(--font-weight-medium, 500);
    border: none;
    border-radius: var(--input-border-radius, 5px); /* Consistent border radius */
    cursor: pointer;
    width: 100%;
    margin-top: 20px; /* Space above the button */
    transition: background-color var(--transition-duration-fast, 0.2s) ease;
}

#specialDateCalculatorModal #calculateSpecialDateBtn:hover {
    background-color: var(--primary-color-darker, #212529); /* Darker shade on hover */
}

/* Style for the result area, ensuring it looks like other modal results */
#specialDateCalculatorModal .modal-result {
    margin-top: 20px; /* Space above the result area */
    padding: var(--modal-result-padding, 15px); /* Use your variable */
    background-color: var(--bg-subtle, #f1f3f5); /* Use your variable */
    border-radius: var(--modal-result-border-radius, 8px); /* Use your variable */
    min-height: var(--modal-result-min-height, 50px); /* Use your variable */
    color: var(--text-dark, #212529); /* Use your variable */
    font-size: var(--modal-result-font-size, 1em); /* Use your variable */
    line-height: var(--modal-result-line-height, 1.6); /* Use your variable */
    text-align: center; /* Center the result text */
}

#specialDateCalculatorModal .modal-result strong {
    color: var(--primary-color, #343a40); /* Make strong text use primary color */
}

/* --- Styles for Add/Edit Profile Modals --- */
#addProfileModal label,
/* We will add IDs for edit modals here later */
#editSingleProfileModal label,
#editCoupleModal label {
    display: block;
    margin-top: 15px; /* More space for modal labels */
    margin-bottom: 5px;
    font-weight: var(--label-font-weight, 600);
    color: var(--text-medium, #495057);
}

#addProfileModal input[type="text"],
#addProfileModal input[type="url"],
#addProfileModal textarea,
/* We will add IDs for edit modals here later */
#editSingleProfileModal input[type="text"],
#editSingleProfileModal input[type="url"],
#editSingleProfileModal textarea,
#editCoupleModal input[type="text"],
#editCoupleModal input[type="url"],
#editCoupleModal textarea {
    width: 100%;
    padding: var(--input-padding-vertical, 10px) var(--input-padding-horizontal, 10px);
    margin-bottom: var(--input-margin-bottom, 15px);
    border: var(--standard-border-width, 1px) solid var(--input-border-color, #ced4da);
    border-radius: var(--input-border-radius, 5px);
    background-color: var(--input-bg-color, #ffffff);
    color: var(--input-text-color, #495057);
    font-size: var(--input-font-size, 1em);
    box-sizing: border-box;
    -webkit-appearance: none; /* May not be needed for text/url but good for consistency */
    -moz-appearance: none;
    appearance: none;
}

#addProfileModal input[type="text"]:focus,
#addProfileModal input[type="url"]:focus,
#addProfileModal textarea:focus,
/* We will add IDs for edit modals here later */
#editSingleProfileModal input[type="text"]:focus,
#editSingleProfileModal input[type="url"]:focus,
#editSingleProfileModal textarea:focus,
#editCoupleModal input[type="text"]:focus,
#editCoupleModal input[type="url"]:focus,
#editCoupleModal textarea:focus {
    outline: none;
    border-color: var(--primary-color, #343a40);
    box-shadow: 0 0 0 var(--focus-ring-width, 2px) var(--focus-ring-color, rgba(52, 58, 64, 0.25));
}

#addProfileModal textarea,
#editSingleProfileModal textarea,
#editCoupleModal textarea {
    resize: vertical; /* Allow vertical resize only */
    min-height: 60px; /* Minimum height for textarea */
    font-family: var(--font-family-base); /* Ensure it uses the same font */
    line-height: var(--line-height-base);
}

.modal-actions {
    margin-top: 25px;
    display: flex;
    /* justify-content: flex-end; */ /* This line is now removed/commented out */
    gap: 10px; /* This creates space BETWEEN buttons if there are multiple */
}


.modal-button {
    padding: 10px 15px;
    border: none;
    border-radius: var(--input-border-radius, 5px);
    font-size: 0.95em;
    font-weight: var(--font-weight-medium, 500);
    cursor: pointer;
    transition: background-color var(--transition-duration-fast, 0.2s) ease, opacity 0.2s ease;
}
.modal-actions > .modal-button {
    flex: 1; /* This allows buttons to grow and share available space equally */
    /* Ensures text inside the button is centered if it's wider */
    text-align: center; 
}

.modal-button.primary {
    background-color: var(--primary-color, #343a40);
    color: var(--fab-text-color, #ffffff);
}
.modal-button.primary:hover {
    background-color: var(--primary-color-darker, #212529);
}

.modal-button.secondary {
    background-color: var(--bg-subtle, #f1f3f5);
    color: var(--text-dark, #212529);
    border: 1px solid var(--border-medium, #ced4da);
}
.modal-button.secondary:hover {
    background-color: var(--hover-bg-light, #e9ecef);
    border-color: var(--hover-border-medium, #adb5bd);
}
/* We will add a danger button style later for delete */

/* --- Styling for Custom Unit Selector --- */

#specialDateCalculatorModal .custom-select-trigger {
    width: 100%;
    padding: var(--input-padding-vertical, 10px) var(--input-padding-horizontal, 10px);
    /* margin-bottom: var(--input-margin-bottom, 15px); */ /* REMOVED or COMMENTED OUT */
    border: var(--standard-border-width, 1px) solid var(--input-border-color, #ced4da);
    border-radius: var(--input-border-radius, 5px);
    background-color: var(--input-bg-color, #ffffff);
    color: var(--input-text-color, #495057);
    font-size: var(--input-font-size, 1em);
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* position: relative; */ /* This is NO LONGER NEEDED here, it's on the container */
    user-select: none;
}


#specialDateCalculatorModal .custom-select-trigger:focus {
    outline: none;
    border-color: var(--primary-color, #343a40);
    box-shadow: 0 0 0 var(--focus-ring-width, 2px) var(--focus-ring-color, rgba(52, 58, 64, 0.25));
}

#specialDateCalculatorModal #customUnitSelectedValue {
    flex-grow: 1; /* Allows text to take available space */
}

#specialDateCalculatorModal .custom-select-arrow {
    font-size: 0.8em;
    margin-left: 10px; /* Space between text and arrow */
    transition: transform 0.2s ease; /* For rotating arrow */
}

#specialDateCalculatorModal .custom-select-trigger.open .custom-select-arrow {
    transform: rotate(180deg); /* Rotate arrow when open */
}

/* --- Styling for Custom Unit Selector --- */

#specialDateCalculatorModal .custom-select-container {
    position: relative; /* This is the crucial part! */
    /* You might want to ensure it doesn't have extra margin if not needed */
    margin-bottom: var(--input-margin-bottom, 15px); /* Move margin here from trigger if trigger doesn't need it separately */
}

/* The Custom Menu (Pop-up) */
#specialDateCalculatorModal #customUnitMenu {
    display: none;
    position: absolute;
    background-color: var(--bg-white, #ffffff);
    border: var(--standard-border-width, 1px) solid var(--border-medium, #ced4da);
    /* border-top: none; */ /* You can uncomment this if you want to remove the top border of the menu */
    border-radius: 0 0 var(--input-border-radius, 5px) var(--input-border-radius, 5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 100%; /* CHANGED from calc(100% - 2px) */
    left: 0;    /* CHANGED from 1px */
    top: 100%;  /* Should position it below the trigger relative to the container */
    z-index: 10;
    max-height: 150px;
    overflow-y: auto;
    box-sizing: border-box; /* Add this for better width calculation with padding/border */
}

#specialDateCalculatorModal #customUnitMenu.visible {
    display: block; /* Show when menu has 'visible' class */
}

#specialDateCalculatorModal .custom-select-option {
    padding: 10px var(--input-padding-horizontal, 10px);
    color: var(--text-dark, #212529);
    cursor: pointer;
    user-select: none;
}

#specialDateCalculatorModal .custom-select-option:hover {
    background-color: var(--hover-bg-light, #e9ecef);
}

/* Style for selected option within the custom menu - optional */
#specialDateCalculatorModal .custom-select-option.selected {
    background-color: var(--primary-color-darker, #212529); /* Example: primary color */
    color: var(--fab-text-color, #ffffff); /* Example: light text color */
    font-weight: var(--font-weight-medium, 500);
}

/*-------------------------------------*
 * Firestore Processing Modal
 *-------------------------------------*/
.firestore-modal-overlay {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: var(--z-index-firestore-modal); /* Use variable */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: var(--firestore-modal-overlay-bg); /* Use variable */
    justify-content: center;
    align-items: center;
    text-align: center;
}

.firestore-modal-content {
    background-color: var(--firestore-modal-content-bg); /* Use variable */
    margin: auto;
    padding: var(--firestore-modal-content-padding-v) var(--firestore-modal-content-padding-h); /* Use variables */
    border: 1px solid var(--firestore-modal-border-color); /* Use variable */
    border-radius: var(--firestore-modal-border-radius); /* Use variable */
    width: auto;
    min-width: 200px; /* Minimum width */
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--firestore-modal-box-shadow); /* Use variable */
}

.firestore-modal-content p {
     margin: 0;
     font-size: var(--firestore-modal-text-font-size); /* Use variable */
     color: var(--firestore-modal-text-color); /* Use variable */
}

.firestore-loader {
    border-width: var(--firestore-loader-border-width); /* Use variable */
    border-style: solid;
    border-color: var(--firestore-loader-track-color); /* Use variable for track */
    border-top-color: var(--firestore-loader-spinner-color); /* Use variable for active part */
    border-radius: 50%;
    width: var(--firestore-loader-size); /* Use variable */
    height: var(--firestore-loader-size); /* Use variable */
    animation: firestore-spin 1s linear infinite;
    margin-bottom: var(--firestore-loader-margin-bottom); /* Use variable */
}

@keyframes firestore-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
