/* Theme for mother: softer overall tint */
.bp-theme-mother .fc .fc-toolbar-title { color: #6a1b9a; }
.bp-theme-mother .fc-theme-standard .fc-button-primary,
.bp-theme-mother .fc .fc-button-primary {
    background: #ab47bc !important;
    border-color: #ab47bc !important;
}
.bp-theme-mother .fc-theme-standard .fc-button-primary:hover,
.bp-theme-mother .fc .fc-button-primary:hover {
    background: #9c27b0 !important;
    border-color: #9c27b0 !important;
}
/* Active state (selected view) should be a darker purple */
.bp-theme-mother .fc-theme-standard .fc-button-primary:not(:disabled).fc-button-active,
.bp-theme-mother .fc .fc-button-primary:not(:disabled).fc-button-active,
.bp-theme-mother .fc .fc-button-primary:active {
    background: #6a1b9a !important; /* darker violet */
    border-color: #6a1b9a !important;
    color: #fff !important;
}

/* Profile button color by active profile */
.bp-theme-father #open-profile {
    background: #4caf50 !important;
    border-color: #4caf50 !important;
    color: #fff !important;
}
.bp-theme-father #open-profile:hover {
    background: #45a049 !important;
    border-color: #45a049 !important;
}
.bp-theme-mother #open-profile {
    background: #ab47bc !important;
    border-color: #ab47bc !important;
    color: #fff !important;
}
.bp-theme-mother #open-profile:hover {
    background: #9c27b0 !important;
    border-color: #9c27b0 !important;
}

/* Page navigation buttons (desktop top menu) */
.bp-theme-father .page-nav-button.active {
    background: #4caf50 !important;
    border-color: #4caf50 !important;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3) !important;
}
.bp-theme-father .page-nav-button.active:hover {
    background: #45a049 !important;
}
.bp-theme-mother .page-nav-button.active {
    background: #ab47bc !important;
    border-color: #ab47bc !important;
    box-shadow: 0 2px 8px rgba(171, 71, 188, 0.3) !important;
}
.bp-theme-mother .page-nav-button.active:hover {
    background: #9c27b0 !important;
}

/* Long-press progress on profile button */
#open-profile, #mobile-profile-btn {
    position: relative;
    overflow: hidden;
}
#open-profile.long-pressing::after,
#mobile-profile-btn.long-pressing::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0%;
    background: rgba(0,0,0,0.35);
    animation: bpLongPress 1.05s linear forwards;
}
@keyframes bpLongPress {
    from { width: 0%; }
    to   { width: 100%; }
}
.bp-theme-mother .fc .fc-daygrid-day.fc-day-today {
    background: #f3e5f5 !important; /* soft lilac */
}

/* Mother theme modal styling */
.bp-theme-mother .modal-content {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18) !important;
}
.bp-theme-mother .modal-header {
    background: #9c27b0 !important;
}
.bp-theme-mother .modal-header span {
    color: #fff !important;
}
.bp-theme-mother .close-btn {
    color: #fff !important;
}
.bp-theme-mother .btn-primary {
    background: #9c27b0 !important;
}
.bp-theme-mother .btn-primary:hover {
    background: #6a1b9a !important;
}
.bp-theme-mother .modal-body textarea:focus {
    border-color: #9c27b0 !important;
}
.bp-theme-mother #bp-modal .source-info input:focus,
.bp-theme-mother #bp-modal .source-info select:focus,
.bp-theme-mother #bp-modal .source-info textarea:focus,
.bp-theme-mother body:has(.tp-ui-modal.show) .bp-time-row input[type="time"],
.bp-theme-mother body:has(.tp-ui-modal.show) .bp-time-row input[type="text"] {
    border-color: #9c27b0 !important;
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.15) !important;
}
.bp-theme-mother #profile-modal .source-info input:focus,
.bp-theme-mother #profile-modal .source-info select:focus,
.bp-theme-mother #profile-modal .source-info textarea:focus {
    border-color: #9c27b0 !important;
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.15) !important;
}
.bp-theme-mother .profile-note-input:focus {
    border-color: #9c27b0 !important;
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.1) !important;
}
.bp-theme-mother .profile-note-edit-input {
    border-color: #9c27b0 !important;
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.1) !important;
}
.bp-theme-mother .profile-note-edit:hover {
    color: #9c27b0 !important;
    background: #f8f0fa !important;
}
.bp-theme-mother .profile-note-edit.profile-note-save {
    color: #9c27b0 !important;
}
.bp-theme-mother .profile-note-edit.profile-note-save:hover {
    color: #7b1fa2 !important;
    background: #f3e5f5 !important;
}
.bp-theme-mother .edit-note-textarea:focus {
    border-color: #9c27b0;
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.1);
}
.bp-theme-mother .edit-note-btn-save {
    background: #9c27b0;
}
.bp-theme-mother .edit-note-btn-save:hover {
    background: #7b1fa2;
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.4);
}
.bp-theme-mother .add-note-btn {
    background: #9c27b0 !important;
}
.bp-theme-mother .add-note-btn:hover {
    background: #6a1b9a !important;
}


/* Timepicker-UI z-index override (above our modal at 9999) */
.tp-ui-modal { z-index: 10100 !important; }
.tp-ui-wrapper { z-index: 10101 !important; }

/* Fast CSS fade for timepicker (higher specificity overrides library's transition:none!important) */
html .tp-ui-modal {
    opacity: 0;
    transition: opacity 0.3s ease !important;
    pointer-events: none;
}
html .tp-ui-modal.show {
    opacity: 1;
    pointer-events: auto;
}

/* MCDatepicker z-index override (above our modal at 9999) */
.mc-calendar { z-index: 10100 !important; }

/* Remove theme background that bleeds through rounded corners when display panel is hidden */
.mc-calendar--modal {
    background-color: transparent !important;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0s linear 0.2s, top 0s linear 0.2s !important;
}

/* Full-screen backdrop for MCDatepicker (library has no built-in overlay) */
.mc-datepicker-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10099;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.mc-datepicker-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Center datepicker on mobile (library default is top-aligned) */
.mc-calendar--modal.mc-calendar--opened {
    top: 50vh !important;
    transform: translate(-50%, -50%) !important;
}

/* Hide calendar display panel on all devices (showCalendarDisplay only works on desktop) */
.mc-display { display: none !important; }

/* Prevent timepicker from shifting page layout when it toggles body overflow */
html {
    overflow-y: scroll;
}

/* Timepicker-UI -- OK/Cancel: keep original pill shape, apply site colors & hover */
.tp-ui-cancel-btn:after,
.tp-ui-ok-btn:after {
    display: none !important;
}

.tp-ui-ok-btn {
    background: #4caf50 !important;
    color: #fff !important;
    transition: all 0.3s !important;
}
.tp-ui-ok-btn:hover {
    background: #45a049 !important;
    transform: translateY(-1px) !important;
}
.tp-ui-ok-btn:active {
    transform: translateY(0) !important;
}

.tp-ui-cancel-btn {
    background: #e0e0e0 !important;
    color: #666 !important;
    transition: all 0.3s !important;
}
.tp-ui-cancel-btn:hover {
    background: #d5d5d5 !important;
    transform: translateY(-1px) !important;
}
.tp-ui-cancel-btn:active {
    transform: translateY(0) !important;
}

html.bp-theme-mother .tp-ui-ok-btn {
    background: #9c27b0 !important;
}
html.bp-theme-mother .tp-ui-ok-btn:hover {
    background: #6a1b9a !important;
}

/* Timepicker-UI -- father (green) theme */
.tp-ui-wrapper {
    --tp-bg: #ffffff;
    --tp-surface: #e8f5e9;
    --tp-surface-hover: #c8e6c9;
    --tp-input-bg: #e8f5e9;
    --tp-text: #1b5e20;
    --tp-text-secondary: #388e3c;
    --tp-text-type-time: #2e7d32;
    --tp-primary: #4caf50;
    --tp-on-primary: #fff;
    --tp-primary-container: #c8e6c9;
    --tp-on-primary-container: #1b5e20;
    --tp-tertiary-container: #e8f5e9;
    --tp-on-tertiary-container: #1b5e20;
    --tp-am-pm-active: #c8e6c9;
    --tp-am-pm-text-selected: #1b5e20;
    --tp-am-pm-text-unselected: #388e3c;
    --tp-border: #a5d6a7;
    --tp-outline: #4caf50;
    --tp-on-surface: #1b5e20;
    --tp-hover-bg: #e0f2e1;
    --tp-duration-fast: 40ms;
    --tp-duration-base: 60ms;
    --tp-duration-slow: 80ms;
    --tp-duration-slower: 100ms;
    --tp-duration-slowest: 120ms;
    --tp-duration-animation: 80ms;
}
/* Timepicker-UI -- mother (purple) theme */
html.bp-theme-mother .tp-ui-wrapper {
    --tp-bg: #ffffff;
    --tp-surface: #f3e5f5;
    --tp-surface-hover: #e1bee7;
    --tp-input-bg: #f3e5f5;
    --tp-text: #4a148c;
    --tp-text-secondary: #7b1fa2;
    --tp-text-type-time: #6a1b9a;
    --tp-primary: #9c27b0;
    --tp-on-primary: #fff;
    --tp-primary-container: #e1bee7;
    --tp-on-primary-container: #4a148c;
    --tp-tertiary-container: #f3e5f5;
    --tp-on-tertiary-container: #4a148c;
    --tp-am-pm-active: #e1bee7;
    --tp-am-pm-text-selected: #4a148c;
    --tp-am-pm-text-unselected: #7b1fa2;
    --tp-border: #ce93d8;
    --tp-outline: #9c27b0;
    --tp-on-surface: #4a148c;
    --tp-hover-bg: #f0e0f3;
}

/* OCR weak visibility warning - orange border for uncertain fields */
.ocr-weak-visibility {
    border-color: #ff9800 !important;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.3) !important;
}
.ocr-weak-visibility:focus {
    border-color: #f57c00 !important;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.4) !important;
}

/* BP calendar tweaks */
.bp-container h2 {
    font-size: 1.6rem;
    font-weight: 600;
}
.bp-event { position: relative; }
.bp-pulse-chip {
    position: absolute;
    top: 8px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border-radius: 0;
    font-size: 11px;
    font-weight: 800;
    background: transparent;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.5);
    box-shadow: none;
    border: 0;
    line-height: 1;
}
.bp-pulse-chip .icon { 
    font-size: 10px; 
    line-height: 1;
    display: inline-block;
    transition: transform 0.1s ease;
}

/* Heart beating animation on event hover */
@keyframes heartbeat {
    0%, 100% { 
        transform: scale(1); 
    }
    10% { 
        transform: scale(1.15); 
    }
    20% { 
        transform: scale(1); 
    }
    30% { 
        transform: scale(1.15); 
    }
    40% { 
        transform: scale(1); 
    }
}

.fc-event:hover .bp-pulse-chip .icon {
    animation: heartbeat 1.2s ease-in-out infinite;
}

.bp-actions .btn { height: 36px; }
        .bp-container { max-width: 1600px; width: 96vw; margin: 24px auto; }
        .bp-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
        .bp-header h2 { user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; }
        .bp-actions { display: flex; gap: 10px; align-items: center; }
        
        /* Delete Confirmation Modal */
        .delete-confirm-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 10001;
            align-items: center;
            justify-content: center;
            padding: 20px;
            overflow-y: auto;
        }
        
        .delete-confirm-modal.show {
            display: flex;
        }
        
        .delete-confirm-content {
            background: white;
            border-radius: 12px;
            padding: 24px;
            max-width: 400px;
            width: 100%;
            max-height: calc(100vh - 40px);
            overflow-y: auto;
            box-shadow: 0 10px 40px rgba(0,0,0,0.3);
            animation: modalFadeIn 0.2s ease;
        }
        
        @keyframes modalFadeIn {
            from { opacity: 0; transform: scale(0.95); }
            to { opacity: 1; transform: scale(1); }
        }
        
        .delete-confirm-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }
        
        .delete-confirm-icon {
            font-size: 32px;
        }
        
        .delete-confirm-title {
            font-size: 20px;
            font-weight: 600;
            color: #333;
            margin: 0;
        }
        
        .delete-confirm-message {
            color: #666;
            margin-bottom: 24px;
            line-height: 1.5;
        }
        
        .delete-confirm-details {
            background: #f5f5f5;
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 24px;
            font-size: 14px;
        }
        
        .delete-confirm-details strong {
            color: #333;
        }
        
        .delete-confirm-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
        }
        
        .delete-confirm-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .delete-confirm-btn-cancel {
            background: #f0f0f0;
            color: #333;
        }
        
        .delete-confirm-btn-cancel:hover {
            background: #e0e0e0;
        }
        
        .delete-confirm-btn-delete {
            background: #dc3545;
            color: white;
        }
        
        .delete-confirm-btn-delete:hover {
            background: #c82333;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
        }
        
        .unsub-confirm-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 10001;
            align-items: center;
            justify-content: center;
            padding: 20px;
            overflow-y: auto;
        }

        .unsub-confirm-modal.show {
            display: flex;
        }

        .unsub-confirm-content {
            background: white;
            border-radius: 12px;
            padding: 24px;
            max-width: 400px;
            width: 100%;
            max-height: calc(100vh - 40px);
            overflow-y: auto;
            box-shadow: 0 10px 40px rgba(0,0,0,0.3);
            animation: modalFadeIn 0.2s ease;
        }

        .unsub-confirm-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .unsub-confirm-title {
            font-size: 18px;
            font-weight: 600;
            color: #333;
            margin: 0;
        }

        .unsub-confirm-message {
            color: #555;
            margin-bottom: 24px;
            line-height: 1.6;
            font-size: 14px;
        }

        .unsub-confirm-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
        }

        .unsub-confirm-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .unsub-confirm-btn-cancel {
            background: #f0f0f0;
            color: #333;
        }

        .unsub-confirm-btn-cancel:hover {
            background: #e0e0e0;
        }

        .unsub-confirm-btn-confirm {
            background: #dc3545;
            color: white;
        }

        .unsub-confirm-btn-confirm:hover {
            background: #c82333;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
        }

        .notif-denied-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 10001;
            align-items: center;
            justify-content: center;
            padding: 20px;
            overflow-y: auto;
        }

        .notif-denied-modal.show {
            display: flex;
        }

        .notif-denied-content {
            background: white;
            border-radius: 12px;
            padding: 24px;
            max-width: 420px;
            width: 100%;
            max-height: calc(100vh - 40px);
            overflow-y: auto;
            box-shadow: 0 10px 40px rgba(0,0,0,0.3);
            animation: modalFadeIn 0.2s ease;
        }

        .notif-denied-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .notif-denied-title {
            font-size: 18px;
            font-weight: 600;
            color: #333;
            margin: 0;
        }

        .notif-denied-message {
            color: #555;
            margin-bottom: 24px;
            line-height: 1.6;
            font-size: 14px;
        }

        .notif-denied-message ol {
            margin: 10px 0 0 0;
            padding-left: 20px;
        }

        .notif-denied-message ol li {
            margin-bottom: 6px;
        }

        .notif-denied-message strong {
            color: #333;
        }

        .notif-denied-actions {
            display: flex;
            justify-content: flex-end;
        }

        .notif-denied-btn-ok {
            padding: 10px 28px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            background: #4caf50;
            color: white;
        }

        .notif-denied-btn-ok:hover {
            filter: brightness(0.9);
            transform: translateY(-1px);
        }

        #calendar { background: white; border: 2px solid #e0e0e0; border-radius: 12px; padding: 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.06); }
        .fc { --fc-border-color: #eaeaea; --fc-page-bg-color: #fff; --fc-neutral-bg-color: #fafafa; --fc-today-bg-color: #f1faf1; }
        /* Prevent text selection on double-click */
        .fc,
        .fc *,
        .fc .fc-col-header-cell,
        .fc .fc-daygrid-day,
        .fc .fc-daygrid-day-number,
        .fc .fc-toolbar-title,
        .fc .fc-button {
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
        }
        .fc .fc-toolbar-title { font-weight: 700; color: #2f3b2f; }
        /* Strong override for FC buttons to avoid black active state */
        .fc-theme-standard .fc-button-primary,
        .fc .fc-button-primary {
            background: #4caf50 !important;
            border-color: #4caf50 !important;
            color: #fff !important;
        }
        .fc-theme-standard .fc-button-primary:hover,
        .fc .fc-button-primary:hover {
            background: #45a049 !important;
            border-color: #45a049 !important;
            color: #fff !important;
        }
        .fc-theme-standard .fc-button-primary:focus,
        .fc .fc-button-primary:focus,
        .fc .fc-button-primary:focus-visible {
            box-shadow: none !important;
            outline: none !important;
        }
        .fc-theme-standard .fc-button-primary:not(:disabled).fc-button-active,
        .fc .fc-button-primary:not(:disabled).fc-button-active,
        .fc .fc-button-primary:active {
            background: #1b5e20 !important; /* darker dark green */
            border-color: #1b5e20 !important;
            color: #fff !important;
        }
        .fc .fc-daygrid-day-number { color: #444; font-weight: 600; }
        /* Highlight for today without border */
        .fc .fc-daygrid-day.fc-day-today {
            background: #d4f1da !important; /* more saturated green */
            position: relative;
        }
        /* Triangle marker in the top-right corner for today */
        .fc .fc-daygrid-day.fc-day-today::after {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 0;
            height: 0;
            border-top: 14px solid #1b5e20; /* dark green */
            border-left: 14px solid transparent;
            pointer-events: none;
            z-index: 100; /* above any hover layers */
        }
        .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number { color: #1b5e20; font-weight: 700; }
        /* 15s pulse after pressing "Сегодня" (see pulseTodayCell() in
           bp.js) — a real element the pulse fully owns, inserted as a child
           of the day cell, NOT a ::before/::after on .fc-daygrid-day: this
           file already layers a large, actively-used ::before/::after
           system on that exact selector for hover effects and today's own
           triangle marker (multiple rules, some !important, z-index up to
           2000) — reusing either pseudo-element here kept losing to that
           existing cascade in some views/rows and not others, depending on
           which of the many pre-existing rules happened to match. A fresh
           class with no legacy rules avoids the conflict entirely. */
        .today-jump-pulse-ring {
            position: absolute;
            inset: 0;
            pointer-events: none;
            z-index: 9999;
            animation: todayJumpPulse 1.2s ease-in-out infinite;
        }
        @keyframes todayJumpPulse {
            0%, 100% { box-shadow: inset 0 0 0 2px rgba(76, 175, 80, 0.75), inset 0 0 12px rgba(76, 175, 80, 0.3); }
            50% { box-shadow: inset 0 0 0 2px rgba(76, 175, 80, 0.4), inset 0 0 6px rgba(76, 175, 80, 0.15); }
        }
        @keyframes todayJumpPulseMother {
            0%, 100% { box-shadow: inset 0 0 0 2px rgba(171, 71, 188, 0.75), inset 0 0 12px rgba(171, 71, 188, 0.3); }
            50% { box-shadow: inset 0 0 0 2px rgba(171, 71, 188, 0.4), inset 0 0 6px rgba(171, 71, 188, 0.15); }
        }
        .bp-theme-mother .today-jump-pulse-ring {
            animation-name: todayJumpPulseMother;
        }
        .fc-event { 
            cursor: pointer; 
            border-radius: 8px; 
            border: none; 
            box-shadow: 0 2px 8px rgba(0,0,0,0.08);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            -webkit-tap-highlight-color: transparent;
            outline: none;
            touch-action: manipulation;
        }
        .fc-event:focus,
        .fc-event:active,
        .fc-event:focus-visible,
        .fc-event:focus-within,
        a.fc-event:focus,
        a.fc-event:focus-visible,
        a.fc-event:focus-within,
        a.fc-event:active,
        .fc .fc-event:focus,
        .fc .fc-event:focus-visible,
        .fc .fc-event:focus-within,
        .fc-event .fc-event-main:focus,
        .fc-daygrid-event-harness:focus,
        .fc-daygrid-event-harness:focus-visible,
        .fc-daygrid-event-harness:focus-within {
            outline: 0 !important;
            outline: none !important;
            outline-width: 0 !important;
            outline-style: none !important;
            border-color: inherit !important;
            -webkit-tap-highlight-color: transparent !important;
        }
        .fc-daygrid-event-harness,
        .fc-event,
        a.fc-event {
            -webkit-tap-highlight-color: transparent !important;
            -webkit-focus-ring-color: transparent;
        }
        
        /* Magnetism effect on hover - only for devices with real pointer (not touch) */
        @media (hover: hover) and (pointer: fine) {
            .fc-event:hover {
                transform: scale(1.08) translateY(-2px);
                box-shadow: 0 6px 16px rgba(0,0,0,0.2);
                z-index: 200 !important;
            }
            .fc-event.bp-selected:hover {
                transform: translateX(var(--bp-selected-shift-x, 0px)) scale(1.28);
                box-shadow: 0 3px 12px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.85) !important;
                z-index: 300 !important;
            }
        }
        
        /* Reduced hover effect for Day view - only for real pointer */
        @media (hover: hover) and (pointer: fine) {
            .fc-dayGridDay-view .fc-event:hover {
                transform: scale(1.01) translateY(-1px);
                overflow: visible !important;
            }
        }
        
        .fc .fc-daygrid-event { margin: 3px 6px; padding: 4px 6px; font-weight: 700; display: flex; justify-content: center; align-items: center; }

        /* Prevent selected/highlighted events from being clipped by cell boundaries */
        .fc .fc-daygrid-body,
        .fc .fc-daygrid-day,
        .fc .fc-daygrid-day-frame,
        .fc .fc-daygrid-day-events,
        .fc .fc-daygrid-event-harness,
        .fc .fc-scrollgrid,
        .fc .fc-scrollgrid-sync-table,
        .fc .fc-scrollgrid-section-body,
        .fc .fc-scrollgrid-section-body > td,
        .fc .fc-scroller,
        .fc .fc-scroller-harness,
        .fc .fc-scroller-harness-liquid {
            overflow: visible !important;
        }
        
        /* Elevate the entire day cell when it contains a selected/highlighted event.
           Without this, the cell's stacking context puts content under neighboring cells. */
        .fc .fc-daygrid-day:has(.bp-selected) {
            z-index: 400 !important;
            position: relative;
        }
        .fc .fc-daygrid-day:has(.newly-added) {
            z-index: 250 !important;
            position: relative;
        }
        .fc .fc-daygrid-event-harness:has(.bp-selected),
        .fc .fc-daygrid-event-harness:has(.newly-added) {
            z-index: 200 !important;
        }
        .fc .fc-daygrid-event-harness:has(.bp-selected) {
            z-index: 300 !important;
        }

        /* Selected event highlight (all views) */
        .fc-event.bp-selected {
            transform: translateX(var(--bp-selected-shift-x, 0px)) scale(1.28);
            box-shadow: 0 3px 12px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.85) !important;
            z-index: 300 !important;
            position: relative;
        }
        
        /* Highlight for newly added events - soft pulsing animation */
        .fc-event.newly-added {
            position: relative;
            z-index: 200 !important;
            will-change: transform;
            animation: newEventPulse 1.5s ease-in-out infinite !important;
            overflow: visible !important;
        }
        
        /* When hovering newly added event, pause animation - only for real pointer */
        @media (hover: hover) and (pointer: fine) {
            .fc-event.newly-added:hover {
                animation: none !important;
                transform: scale(1.15) translateY(-2px) !important;
                box-shadow: inset 0 0 0 2px rgba(255,255,255,0.95), 0 0 0 4px rgba(var(--glow-color, 255,255,255), 0.5), 0 10px 20px rgba(0,0,0,0.25) !important;
            }
        }
        
        @keyframes newEventPulse {
            0%, 100% {
                transform: scale(1);
                box-shadow: inset 0 0 0 2px rgba(255,255,255,0.9),
                            0 0 0 3px rgba(var(--glow-color, 255,255,255), 0.3),
                            0 4px 10px rgba(0,0,0,0.15);
            }
            50% {
                transform: scale(1.12);
                box-shadow: inset 0 0 0 2px rgba(255,255,255,0.95),
                            0 0 0 5px rgba(var(--glow-color, 255,255,255), 0.55),
                            0 8px 22px rgba(0,0,0,0.25);
            }
        }
        .fc .fc-daygrid-event .fc-event-title { width: 100%; text-align: center; letter-spacing: 0.2px; }
        /* Hover highlight for day cells with subtle zoom */
        .fc .fc-daygrid-day { position: relative; }
        .fc .fc-daygrid-day:hover { z-index: 60; }
        .fc .fc-daygrid-day .fc-daygrid-day-frame {
            transition: transform 80ms ease, box-shadow 80ms ease, background-color 80ms ease;
            position: relative;
            overflow: visible;
        }
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame {
            background: #f3faf5;
            transform: scale(1.02);
            box-shadow: 0 2px 8px rgba(46,125,50,0.12), inset 0 0 0 2px rgba(76,175,80,0.22);
            position: relative;
        }
        /* Inner outline to ensure visible top edge under header */
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::before {
            content: '';
            position: absolute;
            inset: 2px;
            border: 2px solid rgba(76,175,80,0.28);
            border-top: 0; /* avoid double-thick top; handled by top strip */
            border-radius: 8px;
            pointer-events: none;
            z-index: 80;
        }
        /* Top overlay strip to overpaint header bottom line */
        .fc .fc-daygrid-day:not(.fc-day-today):hover::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0; height: 2px;
            background: rgba(76,175,80,0.28);
            z-index: 90;
            pointer-events: none;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame {
            background: #cfead5 !important;
            transform: scale(1.02);
            box-shadow: 0 2px 8px rgba(46,125,50,0.12), inset 0 0 0 2px rgba(76,175,80,0.22);
            position: relative;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before {
            content: '';
            position: absolute;
            inset: 2px;
            border: 2px solid rgba(46,125,50,0.35);
            border-top: 0; /* avoid double-thick top; handled by top strip */
            border-radius: 8px;
            pointer-events: none;
            z-index: 80;
        }
        .fc .fc-daygrid-day.fc-day-today:hover::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0; height: 2px;
            background: rgba(46,125,50,0.45);
            z-index: 90;
            pointer-events: none;
        }
        /* Soft weekend highlight (Sat/Sun) except for today */
        .fc .fc-daygrid-day.fc-day-sat:not(.fc-day-today) .fc-daygrid-day-frame,
        .fc .fc-daygrid-day.fc-day-sun:not(.fc-day-today) .fc-daygrid-day-frame {
            background: #f5f6f7;
        }
        /* Header mild highlight + weekend tint */
        .fc .fc-col-header { background: #f8fafc; position: sticky; top: 0; z-index: 1000 !important; }
        .fc .fc-col-header-cell { background: #f8fafc; z-index: 1000 !important; }
        .fc .fc-col-header-cell.fc-day-sat,
        .fc .fc-col-header-cell.fc-day-sun {
            background: #f8fafc;
            z-index: 1000 !important;
        }
        /* Make events fill the column width on week/day views */
        .fc .fc-dayGridWeek-view .fc-daygrid-event,
        .fc .fc-dayGridDay-view .fc-daygrid-event {
            width: calc(100% - 12px);
            margin-left: 6px;
            margin-right: 6px;
            padding: 8px 12px;
            font-size: 14px;
            line-height: 1.2;
        }
        .bp-legend { display:flex; justify-content: space-between; gap: 20px; margin: 14px 0; font-size: 15px; color:#444; align-items:center; flex-wrap: wrap; }
        .legend-left { display:flex; gap: 16px; flex-wrap: wrap; align-items:center; }
        .legend-right { display:flex; gap: 10px; align-items:center; }
        .legend-right .legend-caption { font-weight: 600; color:#2f3b2f; margin-right: 6px; }
        .legend-item { display:flex; align-items:center; gap:8px; }
        .legend-dot { width:18px; height:18px; display:inline-block; border: none; }
        .legend-icon { font-size: 15px; display: inline-block; width: 18px; text-align: center; }
        .legend-cat { cursor: pointer; user-select: none; padding: 6px 10px; border-radius: 8px; transition: background-color 120ms ease, color 120ms ease, max-width 200ms ease; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
        .legend-cat.active { background: rgba(21,101,192,0.12); color: #0d47a1; font-weight: 700; }
        .legend-center { display: flex; gap: 10px; align-items: center; }
        .legend-filter { -webkit-tap-highlight-color: transparent; outline: none; -webkit-touch-callout: none; user-select: none; }
        .legend-text-short { display: none; }
        .legend-text-full { display: inline; }
        /* Highlight/dim effects when filtering by time-of-day */
        .fc .fc-event.dimmed { opacity: 0.35 !important; filter: saturate(70%); }
        .fc .fc-event.highlight-type { box-shadow: 0 0 0 2px rgba(21,101,192,0.6) !important; transform: translateZ(0); }
        .dot-morning { background:#42a5f5; }
        .dot-afternoon { background:#66bb6a; }
        .dot-evening { background:#ffa726; }
        .dot-night { background:#ab47bc; }

        /* Compact profile modal */
        #profile-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 9999;
            align-items: center;
            justify-content: center;
            padding: 20px;
            overflow-y: auto;
        }
        
        #profile-modal.show {
            display: flex;
        }
        
        /* Prevent text selection on double-click in profile modal */
        #profile-modal label,
        #profile-modal .source-info > strong,
        #profile-modal h5,
        #profile-modal h6 {
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
        }
        
        #profile-modal .modal-content { 
            position: relative;
            width: 640px; 
            max-width: calc(100vw - 40px);
            max-height: calc(100vh - 40px);
            overflow-y: auto;
            margin: auto;
        }
        
        /* Responsive adjustments for Profile modal */
        @media (max-width: 768px) {
            #profile-modal {
                padding: 10px;
            }
            #profile-modal .modal-content {
                width: 100%;
                max-width: calc(100vw - 20px);
                max-height: calc(100vh - 20px);
            }
            .profile-grid {
                grid-template-columns: 1fr !important;
                gap: 6px 10px !important;
            }
            #profile-modal .modal-body {
                padding: 10px 12px !important;
            }
        }
        
        @media (max-width: 480px) {
            #profile-modal {
                padding: 5px;
            }
            #profile-modal .modal-content {
                width: 100%;
                max-width: calc(100vw - 10px);
                max-height: calc(100vh - 10px);
            }
            #profile-modal .modal-body {
                padding: 8px 10px !important;
            }
            .profile-grid .source-info {
                padding: 6px !important;
                margin-bottom: 6px !important;
            }
            #profile-modal .source-info input,
            #profile-modal .source-info select,
            #profile-modal .source-info textarea {
                padding: 6px 8px !important;
                font-size: 14px !important;
            }
        }
        #profile-modal .modal-body { padding: 12px 14px; }
        .profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
        .profile-grid .source-info {
            margin-bottom: 0;
            padding: 8px;
            border: 1px solid #e6e6e6;
            border-radius: 10px;
            background: #fafafa;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        }
        .profile-grid .full-span { grid-column: 1 / -1; }
        #pf-comorbidities, #pf-medications { min-height: 64px; }
        
        /* Profile Notes Section */
        .profile-notes-section {
            margin-top: 12px;
        }
        .profile-notes-list {
            max-height: 300px;
            overflow-y: auto;
            margin-bottom: 12px;
            border: 1px solid #e0e0e0;
            border-radius: 6px;
            background: white;
        }
        
        .profile-note-item {
            border-bottom: 1px solid #e0e0e0;
            padding: 10px 12px;
        }
        
        .profile-note-item:last-child {
            border-bottom: none;
        }
        
        .profile-note-item.profile-note-highlight {
            animation: noteHighlight 6s ease-out forwards;
        }
        
        @keyframes noteHighlight {
            0% { background: rgba(76, 175, 80, 0.18); }
            70% { background: rgba(76, 175, 80, 0.10); }
            100% { background: transparent; }
        }
        
        .profile-note-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 6px;
        }
        
        .profile-note-datetime {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 8px;
        }
        
        .profile-note-date {
            font-size: 12px;
            font-weight: 600;
            color: #333;
        }
        
        .profile-note-time {
            font-size: 11px;
            color: #666;
        }
        
        .profile-note-actions {
            display: flex;
            gap: 4px;
            flex-shrink: 0;
        }
        
        .profile-note-edit,
        .profile-note-delete {
            background: transparent;
            border: none;
            color: #999;
            cursor: pointer;
            padding: 6px 8px;
            font-size: 18px;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            border-radius: 4px;
        }
        
        .profile-note-edit:hover {
            color: #2196f3;
            background: #f0f7ff;
        }
        
        .profile-note-edit.profile-note-save {
            color: #4caf50;
        }
        
        .profile-note-edit.profile-note-save:hover {
            color: #388e3c;
            background: #f1f8f4;
        }
        
        .profile-note-delete:hover {
            color: #e53935;
            background: #fef5f5;
        }
        
        .profile-note-delete.profile-note-cancel {
            color: #ff9800;
        }
        
        .profile-note-delete.profile-note-cancel:hover {
            color: #f57c00;
            background: #fff8f0;
        }
        
        .profile-note-content {
            color: #333;
            font-size: 13px;
            line-height: 1.5;
            word-wrap: break-word;
            padding-left: 2px;
        }
        
        .profile-note-edit-input {
            width: 100%;
            border: 2px solid #4caf50;
            border-radius: 4px;
            padding: 6px 8px;
            font-size: 13px;
            font-family: inherit;
            outline: none;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
        }
        .profile-notes-input-wrapper {
            display: flex;
            gap: 8px;
            align-items: center;
        }
        .profile-note-input {
            flex: 1;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            padding: 10px 12px;
            font-size: 14px;
            transition: border-color 0.2s, box-shadow 0.2s;
            background: white;
        }
        .profile-note-input:focus {
            outline: none;
            border-color: #4caf50;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
        }
        .add-note-btn {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            border: none;
            background: #4caf50;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.2s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .add-note-btn:hover:not(:disabled) {
            background: #45a049;
            transform: scale(1.05);
            box-shadow: 0 3px 6px rgba(0,0,0,0.15);
        }
        .add-note-btn:active:not(:disabled) {
            transform: scale(0.95);
        }
        .add-note-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
            opacity: 0.5;
        }
        
        /* Edit Note Modal (for mobile editing) */
        .edit-note-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 10000;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .edit-note-modal.show {
            display: flex;
        }

        .edit-note-content {
            background: white;
            border-radius: 12px;
            padding: 20px;
            max-width: 400px;
            width: 100%;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
            animation: modalFadeIn 0.2s ease;
        }

        .edit-note-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .edit-note-icon {
            font-size: 24px;
        }

        .edit-note-title {
            margin: 0;
            font-size: 18px;
            font-weight: 600;
            color: #333;
        }

        .edit-note-body {
            margin-bottom: 20px;
        }

        .edit-note-textarea {
            width: 100%;
            min-height: 100px;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            padding: 12px;
            font-size: 14px;
            font-family: inherit;
            resize: vertical;
            transition: border-color 0.2s, box-shadow 0.2s;
        }

        .edit-note-textarea:focus {
            outline: none;
            border-color: #4caf50;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
        }

        .edit-note-actions {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
        }

        .edit-note-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
        }

        .edit-note-btn-cancel {
            background: #f5f5f5;
            color: #666;
        }

        .edit-note-btn-cancel:hover {
            background: #e0e0e0;
        }

        .edit-note-btn-save {
            background: #4caf50;
            color: white;
        }

        .edit-note-btn-save:hover {
            background: #388e3c;
            box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
        }
        
        /* Delete Note Confirmation Modal */
        .delete-note-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            z-index: 10001;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        
        .delete-note-modal.show {
            display: flex;
        }
        
        .delete-note-content {
            background: white;
            border-radius: 12px;
            padding: 24px;
            max-width: 400px;
            width: 100%;
            box-shadow: 0 10px 40px rgba(0,0,0,0.3);
            animation: modalFadeIn 0.2s ease;
        }
        
        .delete-note-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }
        
        .delete-note-icon {
            font-size: 32px;
        }
        
        .delete-note-title {
            font-size: 20px;
            font-weight: 600;
            color: #333;
            margin: 0;
        }
        
        .delete-note-message {
            color: #666;
            margin-bottom: 24px;
            line-height: 1.5;
            font-size: 15px;
        }
        
        .delete-note-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
        }
        
        .delete-note-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .delete-note-btn-cancel {
            background: #f0f0f0;
            color: #333;
        }
        
        .delete-note-btn-cancel:hover {
            background: #e0e0e0;
        }
        
        .delete-note-btn-delete {
            background: #dc3545;
            color: white;
        }
        
        .delete-note-btn-delete:hover {
            background: #c82333;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
        }
        
        #profile-modal .source-info input,
        #profile-modal .source-info select,
        #profile-modal .source-info textarea {
            width: 100%;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            padding: 8px 10px;
            font-size: 13px;
            transition: border-color 0.2s, box-shadow 0.2s;
            background: white;
        }
        #profile-modal .source-info input:focus,
        #profile-modal .source-info select:focus,
        #profile-modal .source-info textarea:focus {
            outline: none;
            border-color: #4caf50;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
            background: #fff;
        }
        #profile-modal h4 {
            margin: 12px 0 8px 0 !important;
            color: #2f3b2f;
            font-weight: 700;
        }

        /* Apply same expressive style to Add/Edit Measurement modal */
        #bp-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 9999;
            align-items: center;
            justify-content: center;
            padding: 20px;
            overflow-y: auto;
        }
        
        #bp-modal.show {
            display: flex;
        }
        
        #bp-modal .modal-content {
            position: relative;
            width: 672px;
            max-width: calc(100vw - 40px);
            max-height: calc(100vh - 40px);
            overflow-y: auto;
            margin: auto;
            /* Prevent text selection on double-click across entire modal */
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
        }
        /* Allow text selection only inside actual input/textarea fields when user focuses them */
        #bp-modal input,
        #bp-modal textarea {
            user-select: text;
            -webkit-user-select: text;
            -moz-user-select: text;
            -ms-user-select: text;
        }
        
        /* Responsive adjustments for BP modal */
        @media (max-width: 768px) {
            #bp-modal {
                padding: 10px;
            }
            #bp-modal .modal-content {
                width: 100%;
                max-width: calc(100vw - 20px);
                max-height: calc(100vh - 20px);
            }
            #bp-modal .modal-body {
                padding: 10px 12px !important;
            }
        }
        
        @media (max-width: 480px) {
            #bp-modal {
                padding: 5px;
            }
            #bp-modal .modal-content {
                width: 100%;
                max-width: calc(100vw - 10px);
                max-height: calc(100vh - 10px);
            }
            #bp-modal .modal-body {
                padding: 8px 10px !important;
            }
            #bp-modal .source-info {
                padding: 6px !important;
                margin-bottom: 6px !important;
            }
            #bp-modal .source-info input,
            #bp-modal .source-info select,
            #bp-modal .source-info textarea {
                padding: 6px 8px !important;
                font-size: 14px !important;
            }
        }
        #bp-modal .modal-body { padding: 12px 14px; }
        /* Compact two-line grid for BP numeric fields */
        #bp-modal .bp-fields-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; margin-bottom: 8px; }
        #bp-modal .bp-fields-grid .source-info {
            margin: 0;
            padding: 8px;
            border: 1px solid #e6e6e6;
            border-radius: 10px;
            background: #fafafa;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06);
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 6px;
        }
        #bp-modal .bp-fields-grid .source-info strong { margin: 0; display: block; }
        #bp-modal .bp-fields-grid .source-info input { width: 100%; }
        @media (max-width: 768px) {
            #bp-modal .bp-fields-grid { grid-template-columns: 1fr 1fr; }
        }
        /* Pulse centered across the full row */
        #bp-modal .bp-fields-grid .source-info.pulse {
            grid-column: 1 / -1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        #bp-modal .bp-fields-grid .source-info.pulse input { max-width: 160px; }
        @media (max-width: 480px) {
            #bp-modal .bp-fields-grid { grid-template-columns: 1fr; }
        }
        #bp-modal .source-info {
            margin-bottom: 8px;
            padding: 8px;
            border: 1px solid #e6e6e6;
            border-radius: 10px;
            background: #fafafa;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        }
        #bp-modal .source-info input,
        #bp-modal .source-info select,
        #bp-modal .source-info textarea {
            width: 100%;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            padding: 8px 10px;
            font-size: 13px;
            transition: border-color 0.2s, box-shadow 0.2s;
            background: white;
        }
        #bp-modal .source-info input:focus,
        #bp-modal .source-info select:focus,
        #bp-modal .source-info textarea:focus {
            outline: none;
            border-color: #4caf50;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
            background: #fff;
        }

        /* Time row: input + period badge */
        .bp-time-row {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 8px;
            min-height: 40px;
        }

        .bp-time-row input[type="time"],
        .bp-time-row input[type="text"] {
            width: 160px;
            max-width: 160px;
            padding: 8px 12px;
            border: 2px solid #4caf50;
            border-radius: 6px;
            font-size: 14px;
            font-family: inherit;
            outline: none;
        }

        .bp-time-row input[type="time"]:focus,
        .bp-time-row input[type="text"]:focus {
            border-color: #45a049;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
        }

        /* Keep focus style while timepicker is open */
        body:has(.tp-ui-modal.show) .bp-time-row input[type="time"],
        body:has(.tp-ui-modal.show) .bp-time-row input[type="text"] {
            border-color: #45a049;
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
        }


        /* Period badge (auto-derived from time) */
        .bp-time-badge {
            display: inline-flex;
            align-items: center;
            padding: 5px 12px;
            border-radius: 14px;
            font-size: 13px;
            line-height: 1.2;
            font-weight: 600;
            white-space: nowrap;
            user-select: none;
            transition: opacity 0.15s ease;
            letter-spacing: 0.02em;
            flex-shrink: 0;
        }

        .bp-time-badge--morning {
            background: #fff3e0;
            color: #bf360c;
            border: 1.5px solid #ffcc80;
        }

        .bp-time-badge--afternoon {
            background: #fff8e1;
            color: #e65100;
            border: 1.5px solid #ffe082;
        }

        .bp-time-badge--evening {
            background: #fbe9e7;
            color: #b71c1c;
            border: 1.5px solid #ef9a9a;
        }

        .bp-time-badge--night {
            background: #e3f2fd;
            color: #0d47a1;
            border: 1.5px solid #90caf9;
        }

        @media (min-width: 769px) {
            .bp-time-badge {
                font-size: 14px;
                padding: 6px 14px;
                border-radius: 16px;
            }
        }

        @media (max-width: 768px) {
            .bp-time-row input[type="time"],
            .bp-time-row input[type="text"] {
                flex: 1;
                width: auto;
                max-width: none;
            }
        }

        /* --- Uniform hover border (override previous) --- */
        /* Remove earlier overlays */
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::before { content: none !important; }
        .fc .fc-daygrid-day:not(.fc-day-today):hover::before { content: none !important; }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before { content: none !important; }
        .fc .fc-daygrid-day.fc-day-today:hover::before { content: none !important; }
        /* Draw a single uniform 1px inner border on hover */
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::after {
            content: '';
            position: absolute;
            inset: 3px;
            border: 1px solid rgba(76,175,80,0.35);
            border-radius: 0; /* remove corner dot artifact */
            pointer-events: none;
            z-index: 80;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::after {
            content: '';
            position: absolute;
            inset: 3px;
            border: 1px solid rgba(46,125,50,0.5);
            border-radius: 0; /* remove corner dot artifact */
            pointer-events: none;
            z-index: 80;
        }
        /* Add a 1px top line for the first row to match other sides */
        .fc .fc-daygrid-row:first-child .fc-daygrid-day:not(.fc-day-today):hover::after {
            content: '';
            position: absolute;
            top: 0; left: 3px; right: 3px; height: 1px;
            background: rgba(76,175,80,0.35);
            z-index: 95;
            pointer-events: none;
        }
        .fc .fc-daygrid-row:first-child .fc-daygrid-day.fc-day-today:hover::after {
            content: '';
            position: absolute;
            top: 0; left: 3px; right: 3px; height: 1px;
            background: rgba(46,125,50,0.5);
            z-index: 95;
            pointer-events: none;
        }
        /* Keep today's triangle above */
        .fc .fc-daygrid-day.fc-day-today::after { z-index: 100; }

        /* Final uniform hover highlight: full width, all rows */
        .fc .fc-daygrid-day .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day .fc-daygrid-day-frame::after,
        .fc .fc-daygrid-day::before,
        .fc .fc-daygrid-day::after { content: none !important; }
        .fc .fc-col-header { position: sticky; top: 0; z-index: 1000 !important; }
        .fc .fc-col-header-cell { z-index: 1000 !important; }
        .fc .fc-daygrid-day { position: relative; z-index: 0; }
        .fc .fc-daygrid-day:hover { z-index: 5; }
        .fc .fc-daygrid-day .fc-daygrid-day-frame { position: relative; }
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame {
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
        }
        .fc .fc-daygrid-day.fc-day-today::after { z-index: 100; }

        /* Disable hover zoom so highlight fills entire cell */
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame { transform: none !important; }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame { transform: none !important; }

        /* First-row top border fix (1px, same color as sides) */
        .fc .fc-daygrid-row:first-child .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::before {
            content: '' !important;
            position: absolute;
            top: 0; left: 0; right: 0; height: 1px;
            background: rgba(76,175,80,0.35);
            z-index: 2;
            pointer-events: none;
        }
        .fc .fc-daygrid-row:first-child .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before {
            content: '' !important;
            position: absolute;
            top: 0; left: 0; right: 0; height: 1px;
            background: rgba(46,125,50,0.5);
            z-index: 2;
            pointer-events: none;
        }
        /* Ensure header bottom border doesn't obscure first-row top highlight */
        .fc-theme-standard thead,
        .fc .fc-scrollgrid thead {
            position: sticky;
            top: 0;
            z-index: 1000 !important;
            background: #f8fafc;
        }
        .fc-theme-standard thead .fc-col-header-cell,
        .fc-theme-standard .fc-col-header-cell,
        .fc .fc-col-header-cell,
        .fc .fc-scrollgrid thead th {
            border-bottom: 0 !important;
            background: #f8fafc;
            z-index: 1000 !important;
        }
        /* Put body above header so first-row hover can draw over the header line */
        .fc .fc-scrollgrid-section-header { position: sticky; top: 0; z-index: 1000 !important; background: #f8fafc; }
        .fc .fc-scrollgrid-section-body { position: relative; z-index: 5; }
        /* First row top overlay explicitly above header */
        .fc .fc-daygrid-row:first-child .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::before {
            content: '';
            position: absolute;
            top: -1px; left: 0; right: 0; height: 1px;
            background: rgba(76,175,80,0.35);
            z-index: 10;
            pointer-events: none;
        }
        .fc .fc-daygrid-row:first-child .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before {
            content: '';
            position: absolute;
            top: -1px; left: 0; right: 0; height: 1px;
            background: rgba(46,125,50,0.5);
            z-index: 10;
            pointer-events: none;
        }
        /* First row: force top border above header via outer shadow */
        .fc .fc-daygrid-row:first-child .fc-daygrid-day { position: relative; }
        .fc .fc-daygrid-row:first-child .fc-daygrid-day:hover { z-index: 60; }
        .fc .fc-daygrid-row:first-child .fc-daygrid-day:not(.fc-day-today):hover {
            box-shadow: 0 -1px 0 0 rgba(76,175,80,0.35) !important;
        }
        .fc .fc-daygrid-row:first-child .fc-daygrid-day.fc-day-today:hover {
            box-shadow: 0 -1px 0 0 rgba(46,125,50,0.5) !important;
        }
        /* Full-cell overlay on hover (works even when cell has no events) */
        .fc .fc-daygrid-day { position: relative; }
        .fc .fc-daygrid-day:hover::after {
            content: '';
            position: absolute;
            inset: 0;
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
            background: rgba(76,175,80,0.04);
            border-radius: 0;
            pointer-events: none;
            z-index: 8;
        }
        .fc .fc-daygrid-day.fc-day-today:hover::after {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
            background: rgba(46,125,50,0.06);
        }
        /* Final fix: full-cell border via frame::before on hover (all rows) */
        .fc .fc-daygrid-day .fc-daygrid-day-frame { position: relative; }
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::before {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
            background: transparent !important;
            pointer-events: none !important;
            z-index: 3 !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
            background: transparent !important;
            pointer-events: none !important;
            z-index: 3 !important;
        }
        /* Remove inner padding to eliminate hover border gaps */
        .fc .fc-daygrid-day-frame { padding: 0 !important; }
        /* Keep spacing for day numbers after removing frame padding */
        .fc .fc-daygrid-day-top { padding: 4px 6px 2px 6px !important; }

        /* Ultimate full-cell hover overlay (parent-based) */
        .fc .fc-daygrid-day { position: relative; }
        .fc .fc-daygrid-day:hover::after {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
            background: rgba(76,175,80,0.04) !important;
            z-index: 60 !important; /* above frame/events */
            pointer-events: none !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover::after {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
            background: rgba(46,125,50,0.06) !important;
        }
        /* Hide internal day separator that cut the hover border */
        .fc .fc-daygrid-day-bottom { border-top: 0 !important; height: 0 !important; margin: 0 !important; padding: 0 !important; }
        /* Put hover overlay above any inner content */
        .fc .fc-daygrid-day .fc-daygrid-day-frame { position: relative; }
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::after {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
            background: rgba(76,175,80,0.04) !important;
            z-index: 1000 !important;
            pointer-events: none !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::after {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
            background: rgba(46,125,50,0.06) !important;
        }
        /* Completely remove internal day separator (caused inner line) */
        .fc-theme-standard .fc-daygrid-day-bottom,
        .fc .fc-daygrid-day-bottom,
        .fc-daygrid-day-bottom,
        .fc-daygrid-day-bottom::before,
        .fc-daygrid-day-bottom::after {
            display: none !important;
            border: 0 !important;
            height: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            content: none !important;
        }
        /* Remove only the inner separator line, keep spacing */
        .fc .fc-daygrid-day-bottom {
            border-top: 0 !important;
            background: transparent !important;
            box-shadow: none !important;
            height: 8px !important; /* keep gap */
        }
        /* Final override: draw hover on the whole day (includes spacer), disable frame overlays */
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::after { content: none !important; }
        .fc .fc-daygrid-day:hover::after {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important; /* cover entire cell incl. spacer */
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
            background: rgba(76,175,80,0.04) !important;
            z-index: 1000 !important;
            pointer-events: none !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover::after {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
            background: rgba(46,125,50,0.06) !important;
        }
        /* Final: remove inner separator, keep spacing via padding */
        .fc .fc-daygrid-day-bottom { display: none !important; height: 0 !important; border: 0 !important; }
        .fc .fc-daygrid-day .fc-daygrid-day-frame { padding-bottom: 8px !important; }
        /* Force today's corner triangle to the top-right corner */
        .fc .fc-daygrid-day.fc-day-today::after {
            left: auto !important;
            right: 0 !important;
            top: 0 !important;
            border-top: 14px solid #1b5e20 !important;
            border-left: 14px solid transparent !important;
            border-right: 0 !important;
            border-bottom: 0 !important;
        }
        /* Always show today's triangle (reserve ::after for triangle only) */
        .fc .fc-daygrid-day.fc-day-today::after {
            content: '' !important;
            position: absolute !important;
            top: 0 !important;
            right: 0 !important;
            width: 0; height: 0;
            border-top: 14px solid #1b5e20 !important;
            border-left: 14px solid transparent !important;
            pointer-events: none;
            z-index: 2000 !important;
        }
        /* Do not use ::after for hover overlay */
        .fc .fc-daygrid-day:hover::after { box-shadow: none !important; background: none !important; }
        .fc .fc-daygrid-day.fc-day-today:hover::after { box-shadow: none !important; background: none !important; }
        /* Use ::before for hover overlay */
        .fc .fc-daygrid-day:hover::before {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35) !important;
            background: rgba(76,175,80,0.04) !important;
            z-index: 1500 !important;
            pointer-events: none !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover::before {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5) !important;
            background: rgba(46,125,50,0.06) !important;
        }
        /* Subtle hover animation: scale 1.02 with soft shadow (triangle preserved) */
        .fc .fc-daygrid-day { position: relative; overflow: visible; }
        .fc .fc-daygrid-day:hover { z-index: 300; }
        .fc .fc-daygrid-day::before {
            content: '';
            position: absolute;
            inset: 0;
            background: transparent;
            box-shadow: none;
            transform-origin: center center;
            transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
            pointer-events: none;
            z-index: 1500; /* below triangle (::after), above content */
        }
        .fc .fc-daygrid-day:hover::before {
            transform: scale(1.02);
            box-shadow: inset 0 0 0 1px rgba(76,175,80,0.35), 0 6px 12px rgba(46,125,50,0.12);
            background: rgba(76,175,80,0.04);
        }
        .fc .fc-daygrid-day.fc-day-today:hover::before {
            box-shadow: inset 0 0 0 1px rgba(46,125,50,0.5), 0 8px 16px rgba(46,125,50,0.18);
            background: rgba(46,125,50,0.06);
        }
        /* Adjust TODAY styles to blue to avoid conflict with green categories */
        .fc .fc-daygrid-day.fc-day-today {
            background: #e3f2fd !important; /* light blue */
        }
        .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number { color: #0d47a1; font-weight: 700; }
        /* Today's triangle in top-right (blue) */
        .fc .fc-daygrid-day.fc-day-today::after {
            content: '' !important;
            position: absolute !important;
            top: 0 !important;
            right: 0 !important;
            width: 0; height: 0;
            border-top: 14px solid #1565c0 !important; /* blue */
            border-left: 14px solid transparent !important;
            pointer-events: none;
            z-index: 2000 !important;
        }
        /* Hover overlay uses subtle blue instead of green */
        .fc .fc-daygrid-day { position: relative; overflow: visible; }
        .fc .fc-daygrid-day:hover { z-index: 300; }
        .fc .fc-daygrid-day::before {
            content: '';
            position: absolute;
            inset: 0;
            background: transparent;
            box-shadow: none;
            transform-origin: center center;
            transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
            pointer-events: none;
            z-index: 1500;
        }
        .fc .fc-daygrid-day:hover::before {
            transform: scale(1.02);
            box-shadow: inset 0 0 0 1px rgba(21,101,192,0.35), 0 6px 12px rgba(21,101,192,0.12);
            background: rgba(21,101,192,0.06);
        }
        .fc .fc-daygrid-day.fc-day-today:hover::before {
            box-shadow: inset 0 0 0 1px rgba(21,101,192,0.55), 0 8px 16px rgba(21,101,192,0.18);
            background: rgba(21,101,192,0.08);
        }
        /* BLUE HOVER ENFORCER: override any previous green hover styles */
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame,
        .fc .fc-daygrid-day:hover::before,
        .fc .fc-daygrid-day:hover::after,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::after {
            box-shadow: inset 0 0 0 1px rgba(21,101,192,0.35) !important;
            background: rgba(21,101,192,0.06) !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame,
        .fc .fc-daygrid-day.fc-day-today:hover::before,
        .fc .fc-daygrid-day.fc-day-today:hover::after,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::after {
            box-shadow: inset 0 0 0 1px rgba(21,101,192,0.55) !important;
            background: rgba(21,101,192,0.08) !important;
        }
        /* Border-only hover (no background) */
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame,
        .fc .fc-daygrid-day:hover::before,
        .fc .fc-daygrid-day:hover::after,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::after {
            background: transparent !important;
            box-shadow: inset 0 0 0 2px rgba(21,101,192,0.5) !important;
            transform: none !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame,
        .fc .fc-daygrid-day.fc-day-today:hover::before,
        .fc .fc-daygrid-day.fc-day-today:hover::after,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::after {
            background: transparent !important;
            box-shadow: inset 0 0 0 2px rgba(21,101,192,0.65) !important;
            transform: none !important;
        }
        /* Day-name header styling */
        .fc .fc-col-header { background: #f8fafc; box-shadow: inset 0 -1px 0 #e5e7eb; position: sticky; top: 0; z-index: 1000 !important; }
        .fc .fc-col-header-cell { background: #f8fafc; z-index: 1000 !important; }
        .fc .fc-col-header-cell-cushion { color: #374151; font-weight: 700; padding: 8px 0; position: relative; z-index: 1000 !important; background: #f8fafc; }
        /* Weekend header tint */
        .fc .fc-col-header-cell.fc-day-sat,
        .fc .fc-col-header-cell.fc-day-sun {
            background: #f8fafc;
        }
        /* Neutralize weekend header tint (make same as others) */
        .fc .fc-col-header-cell.fc-day-sat,
        .fc .fc-col-header-cell.fc-day-sun { background: #f8fafc !important; z-index: 1000 !important; }
        .fc .fc-col-header-cell.fc-day-sat .fc-col-header-cell-cushion,
        .fc .fc-col-header-cell.fc-day-sun .fc-col-header-cell-cushion { color: #374151 !important; z-index: 1000 !important; }
        /* Hover: background fill (no border) */
        .fc .fc-daygrid-day:hover::before,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day:hover .fc-daygrid-day-frame::after,
        .fc .fc-daygrid-day:hover::after {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            background: rgba(21,101,192,0.10) !important; /* soft blue fill */
            box-shadow: none !important;
            transform: none !important;
            pointer-events: none !important;
            z-index: 1200 !important;
        }
        .fc .fc-daygrid-day.fc-day-today:hover::before,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::after,
        .fc .fc-daygrid-day.fc-day-today:hover::after {
            background: rgba(21,101,192,0.14) !important; /* a bit stronger on today */
        }
        /* Disable hover highlight for all cells except today */
        .fc .fc-daygrid-day:not(.fc-day-today):hover::before,
        .fc .fc-daygrid-day:not(.fc-day-today):hover::after,
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame::after,
        .fc .fc-daygrid-day:not(.fc-day-today):hover .fc-daygrid-day-frame {
            background: transparent !important;
            box-shadow: none !important;
            transform: none !important;
        }
        /* FINAL FIXES for today cell: no hover borders, triangle locked to top-right */
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame,
        .fc .fc-daygrid-day.fc-day-today:hover::before,
        .fc .fc-daygrid-day.fc-day-today:hover::after,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame::after {
            box-shadow: none !important;
            background: transparent !important;
            content: none !important;
            transform: none !important;
        }
        .fc .fc-daygrid-day.fc-day-today::after {
            content: '' !important;
            position: absolute !important;
            top: 0 !important;
            right: 0 !important;
            left: auto !important;
            width: 0 !important; height: 0 !important;
            border-top: 14px solid #1565c0 !important;
            border-left: 14px solid transparent !important;
            border-right: 0 !important; border-bottom: 0 !important;
            pointer-events: none !important;
            z-index: 2000 !important;
        }
        /* Ensure today's triangle remains visible on hover */
        .fc .fc-daygrid-day.fc-day-today:hover::after {
            content: '' !important;
            position: absolute !important;
            top: 0 !important;
            right: 0 !important;
            left: auto !important;
            width: 0 !important; height: 0 !important;
            border-top: 14px solid #1565c0 !important;
            border-left: 14px solid transparent !important;
            border-right: 0 !important; border-bottom: 0 !important;
            pointer-events: none !important;
            z-index: 3000 !important;
        }
        /* Preserve weekend background on hover (non-today) */
        .fc .fc-daygrid-day.fc-day-sat:not(.fc-day-today):hover .fc-daygrid-day-frame,
        .fc .fc-daygrid-day.fc-day-sun:not(.fc-day-today):hover .fc-daygrid-day-frame {
            background: #f5f6f7 !important;
        }
        .fc .fc-daygrid-day.fc-day-sat:not(.fc-day-today):hover::before,
        .fc .fc-daygrid-day.fc-day-sun:not(.fc-day-today):hover::before,
        .fc .fc-daygrid-day.fc-day-sat:not(.fc-day-today):hover::after,
        .fc .fc-daygrid-day.fc-day-sun:not(.fc-day-today):hover::after,
        .fc .fc-daygrid-day.fc-day-sat:not(.fc-day-today):hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day.fc-day-sun:not(.fc-day-today):hover .fc-daygrid-day-frame::before,
        .fc .fc-daygrid-day.fc-day-sat:not(.fc-day-today):hover .fc-daygrid-day-frame::after,
        .fc .fc-daygrid-day.fc-day-sun:not(.fc-day-today):hover .fc-daygrid-day-frame::after {
            background: transparent !important;
            box-shadow: none !important;
        }
        /* Prevent today's background from bleeding into header */
        .fc .fc-daygrid-day.fc-day-today { background: transparent !important; }
        .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-frame { background: #e3f2fd !important; }
        .fc .fc-daygrid-day.fc-day-today:hover .fc-daygrid-day-frame { background: #e3f2fd !important; }
        /* Legend buttons (time + category + filter) unified size */
        .legend-time, .legend-cat, .legend-filter {
            cursor: pointer; user-select: none;
            display: inline-flex; align-items: center; gap: 6px;
            padding: 6px 10px; min-height: 28px; line-height: 18px;
            border-radius: 8px; font-size: 14px;
            transition: background-color 120ms ease, color 120ms ease;
            -webkit-tap-highlight-color: transparent;
        }
        @media (hover: hover) and (pointer: fine) {
            .legend-time:hover, .legend-cat:hover, .legend-filter:hover { background: rgba(21,101,192,0.12); }
        }
        .legend-time.active, .legend-cat.active, .legend-filter.active { background: rgba(21,101,192,0.12); color: #0d47a1; font-weight: 700; }
        /* Slightly taller cells in Day view */
        .fc .fc-dayGridDay-view .fc-daygrid-day-frame { min-height: 200px; }
        /* Same height for Week view */
        .fc .fc-dayGridWeek-view .fc-daygrid-day-frame { min-height: 200px; }
        @media (max-width: 768px) {
            .fc .fc-dayGridDay-view .fc-daygrid-day-frame { min-height: 160px; }
            .fc .fc-dayGridWeek-view .fc-daygrid-day-frame { min-height: 160px; }
        }
        /* Custom compact tooltip for events */
        .bp-tooltip {
            position: fixed;
            background: #ffffff;
            color: #1f2937;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            padding: 8px 10px;
            font-size: 12px;
            line-height: 1.3;
            box-shadow: 0 8px 20px rgba(0,0,0,0.12);
            z-index: 4000;
            pointer-events: none;
            max-width: 280px;
            display: none;
        }
        .bp-tooltip.visible { display: flex; flex-direction: column; gap: 2px; }
        .bp-tooltip .bp-tooltip-value { color: #111827; word-break: break-word; overflow-wrap: break-word; }
        /* Compact cell heights for Day and Week views (match system calendar) */
        .fc .fc-dayGridDay-view .fc-daygrid-day-frame { min-height: 140px !important; }
        .fc .fc-dayGridWeek-view .fc-daygrid-day-frame { min-height: 140px !important; }
        @media (max-width: 768px) {
            .fc .fc-dayGridDay-view .fc-daygrid-day-frame { min-height: 120px !important; }
            .fc .fc-dayGridWeek-view .fc-daygrid-day-frame { min-height: 120px !important; }
        }
        /* Week/Day: dim cells that are not in the reference month (added via JS as .bp-outmonth) */
        .fc .fc-dayGridWeek-view .bp-outmonth,
        .fc .fc-dayGridDay-view  .bp-outmonth {
            background: #fafafa !important;
        }
        .fc .fc-dayGridWeek-view .bp-outmonth .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .bp-outmonth .fc-daygrid-day-number,
        .bp-outmonth .bp-daynum {
            color: #9aa0a6 !important;
            font-weight: 600 !important;
        }
        .fc .fc-dayGridWeek-view .bp-outmonth .fc-daygrid-day-frame,
        .fc .fc-dayGridDay-view  .bp-outmonth .fc-daygrid-day-frame {
            background: transparent !important;
        }
        /* Week/Day: force same date number layout/padding as Month (top-right) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day-top,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-top {
            display: flex !important;
            align-items: flex-start !important;
            justify-content: flex-end !important;
            padding: 6px 8px !important; /* like Month */
        }
        .fc .fc-dayGridWeek-view .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-number,
        .fc .fc-daygrid-day .fc-daygrid-day-number {
            position: relative !important;
            z-index: 500 !important; /* above any hover/tooltip overlays */
            color: #374151 !important;
            font-weight: 700 !important;
        }
        /* FORCE: show date number in Week/Day like Month (top-right, above overlays) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day-top,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-top { display: flex !important; align-items: flex-start !important; justify-content: flex-end !important; padding: 6px 8px !important; }
        .fc .fc-dayGridWeek-view .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-number { position: relative !important; z-index: 500 !important; color: #374151 !important; font-weight: 700 !important; }
        /* Always-visible date badge for Week/Day views */
        .bp-daynum {
            position: absolute;
            top: 6px; right: 8px;
            font-weight: 700; color: #374151;
            font-size: 14px; line-height: 1;
            z-index: 500; /* above any overlays */
            pointer-events: none;
        }
        /* Week/Day: add top spacing like Month (space between date and events) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day-top,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-top {
            padding: 6px 8px !important; /* match Month */
            min-height: 24px !important;
        }
        .fc .fc-dayGridWeek-view .fc-daygrid-day-events,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-events {
            margin-top: 4px !important; /* small gap under date */
        }
        /* Week/Day: force top spacing like Month (strong override) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-top,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-top {
            padding: 6px 8px !important; /* same as Month */
            min-height: 28px !important;
        }
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-events,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-events {
            margin-top: 8px !important; /* gap under date */
        }
        /* Mirror Month layout for Week/Day: reserve top space and place date top-right */
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-frame,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-frame { position: relative !important; padding-top: 34px !important; }
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-top,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-top {
            position: absolute !important; top: 0 !important; left: 0 !important; right: 0 !important;
            display: flex !important; align-items: flex-start !important; justify-content: flex-end !important;
            padding: 6px 8px !important; pointer-events: none !important;
        }
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-number { color: #374151 !important; font-weight: 700 !important; z-index: 500 !important; }
        /* Slight gap below date row like Month */
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-events,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-events { margin-top: 6px !important; }
        /* Week/Day: fill entire cell for TODAY (blue) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day.fc-day-today,
        .fc .fc-dayGridDay-view  .fc-daygrid-day.fc-day-today {
            background: #e3f2fd !important;
        }
        .fc .fc-dayGridWeek-view .fc-daygrid-day.fc-day-today .fc-daygrid-day-frame,
        .fc .fc-dayGridDay-view  .fc-daygrid-day.fc-day-today .fc-daygrid-day-frame {
            background: transparent !important;
        }
        /* Week/Day: fill entire cell for WEEKENDS (grey) when not today */
        .fc .fc-dayGridWeek-view .fc-daygrid-day.fc-day-sat:not(.fc-day-today),
        .fc .fc-dayGridWeek-view .fc-daygrid-day.fc-day-sun:not(.fc-day-today),
        .fc .fc-dayGridDay-view  .fc-daygrid-day.fc-day-sat:not(.fc-day-today),
        .fc .fc-dayGridDay-view  .fc-daygrid-day.fc-day-sun:not(.fc-day-today) {
            background: #f5f6f7 !important;
        }
        .fc .fc-dayGridWeek-view .fc-daygrid-day.fc-day-sat .fc-daygrid-day-frame,
        .fc .fc-dayGridWeek-view .fc-daygrid-day.fc-day-sun .fc-daygrid-day-frame,
        .fc .fc-dayGridDay-view  .fc-daygrid-day.fc-day-sat .fc-daygrid-day-frame,
        .fc .fc-dayGridDay-view  .fc-daygrid-day.fc-day-sun .fc-daygrid-day-frame {
            background: transparent !important;
        }
        /* Remove any hover overlays on Week/Day that could obscure these backgrounds */
        .fc .fc-dayGridWeek-view .fc-daygrid-day:hover::before,
        .fc .fc-dayGridWeek-view .fc-daygrid-day:hover::after,
        .fc .fc-dayGridDay-view  .fc-daygrid-day:hover::before,
        .fc .fc-dayGridDay-view  .fc-daygrid-day:hover::after {
            background: transparent !important;
            box-shadow: none !important;
        }
        /* Legend category markers as squares */
        .legend-dot { border-radius: 3px !important; }
        /* Unify event pill size across Month/Week/Day */
        .fc .fc-daygrid-event {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            min-height: 38px !important; /* same pill height */
            padding: 6px 10px !important;
            border-radius: 10px !important;
            font-size: 14px !important;
            width: calc(100% - 12px) !important;
            margin-left: auto !important;
            margin-right: auto !important;
            /* removed static white inner stroke */
        }
        .fc .fc-daygrid-event .fc-event-main { overflow: visible !important; }
        /* Subtle outer shadow for dark categories */
        .bp-event.bp-cat-htn2,
        .bp-event.bp-cat-htn3 {
            filter: drop-shadow(0 1px 2px rgba(0,0,0,0.18));
        }
        /* Hover: thin white overlay outline + pointer - ONLY for non-touch devices */
        @media (hover: hover) and (pointer: fine) {
            .bp-event:hover {
                /* elevation + white inner outline on hover */
                box-shadow: 0 4px 10px rgba(0,0,0,0.18), inset 0 0 0 2px rgba(255,255,255,0.9) !important;
                cursor: pointer !important;
            }
        }

        /* Force bold date numbers in Week/Day like Month */
        .fc .fc-dayGridWeek-view .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .fc-daygrid-day-number,
        .bp-daynum { font-weight: 700 !important; color: #374151 !important; }
        /* Final: Week/Day date numbers match Month (top-right style, same weight/size) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-number {
            font-weight: 700 !important;
            font-size: 14px !important;
            line-height: 1 !important;
            color: #111827 !important; /* same as Month */
            z-index: 500 !important;
        }
        /* Today: ensure number is visible over blue background */
        .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
            color: #0d47a1 !important;
            text-shadow: 0 1px 0 rgba(255,255,255,0.7) !important;
        }
        /* Match Month date number size in Week/Day (use 1rem) */
        .fc .fc-dayGridWeek-view .fc-daygrid-day .fc-daygrid-day-number,
        .fc .fc-dayGridDay-view  .fc-daygrid-day .fc-daygrid-day-number,
        .bp-daynum { font-size: 1rem !important; font-weight: 700 !important; }

/* ==========================================
   PWA Mobile Optimizations
   ========================================== */

/* Mobile-first responsive improvements */
@media (max-width: 768px) {
    body {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Container adjustments */
    .bp-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        margin-top: 0; /* Header is in flow on mobile */
        padding: 4px;
        padding-top: 0;
        padding-bottom: 70px; /* Space for FAB */
    }
    
    /* Header adjustments */
    .bp-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .bp-header h2 {
        font-size: 1.3rem;
        text-align: center;
        display: none; /* Hide in favor of mobile header */
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    
    /* Actions in mobile mode */
    .bp-actions {
        display: none; /* Use FAB and mobile header instead */
    }
    
    /* Legend Toggle Button (Mobile only) - CRITICAL: hidden by default on desktop */
    .legend-toggle-container {
        display: none;
        visibility: hidden;
        padding: 0 10px;
        margin-top: 8px;
        margin-bottom: 10px; /* Ensure space between filter button and calendar */
    }
    
    .legend-toggle-btn {
        display: none;
        visibility: hidden;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 8px 16px;
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        font-size: 14px;
        color: #666;
        position: relative;
    }
    
    /* Show only on mobile - max-width 768px */
    @media (max-width: 768px) {
        .legend-toggle-container {
            display: block !important;
            visibility: visible !important;
        }
        
        .legend-toggle-btn {
            display: flex !important;
            visibility: visible !important;
        }
    }
    
    .legend-toggle-btn:active {
        transform: scale(0.98);
        background: #f5f5f5;
    }
    
    .legend-badge {
        background: #f44336;
        color: white;
        font-size: 11px;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: 10px;
        min-width: 18px;
        text-align: center;
    }
    
    .legend-active-icons {
        display: flex;
        gap: 6px;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        flex: 1;
    }
    
    .legend-toggle-btn.expanded .legend-active-icons {
        display: none;
    }
    
    .legend-chevron {
        transition: transform 0.2s;
        margin-left: auto;
    }
    
    .legend-toggle-btn.expanded .legend-chevron {
        transform: rotate(180deg);
    }
    
    /* Legend - horizontal scrollable */
    .bp-legend {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        margin-top: 0; /* Remove top margin on mobile */
        margin-bottom: 10px;
        border-radius: 10px;
        background: #f8f9fa;
        overflow: hidden;
        transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    }
    
    @media (max-width: 768px) {
        .bp-legend {
            max-height: 0;
            opacity: 0;
            margin: 0;
            padding: 0;
        }
        
        .bp-legend.expanded {
            max-height: 500px;
            opacity: 1;
            margin-top: 8px;
            margin-bottom: 10px;
            padding: 10px;
        }
    }
    
    .legend-left, .legend-right, .legend-center {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .legend-item {
        font-size: 14px;
        padding: 6px 10px;
        min-height: 32px;
    }
    
    .legend-dot {
        width: 12px;
        height: 12px;
    }
    
    /* Mobile: show short text, hide full */
    .legend-text-short { display: inline; }
    .legend-text-full { display: none; }
    
    /* When expanded on mobile, show full text */
    .legend-cat.expanded .legend-text-short { display: none; }
    .legend-cat.expanded .legend-text-full { display: inline; }
    
    
    .legend-icon {
        font-size: 14px;
        width: 16px;
    }
    
    /* Calendar optimizations */
    #calendar {
        padding: 4px;
        border-radius: 10px;
        border-width: 1px;
    }
    
    /* Disable sticky header on calendar for mobile - conflicts with fixed header */
    .fc .fc-col-header,
    .fc .fc-scrollgrid-section-header {
        position: static !important;
    }
    
    /* FullCalendar toolbar */
    .fc .fc-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 0 4px;
    }
    
    .fc .fc-toolbar-title {
        font-size: 1.1rem !important;
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }
    
    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
    
    /* Smaller buttons */
    .fc .fc-button {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    .fc .fc-button-group {
        gap: 2px;
    }
    
    /* Show week button on mobile too */
    .fc .fc-dayGridWeek-button {
        display: inline-block !important;
    }
    
    /* Calendar cells */
    .fc .fc-daygrid-day {
        min-height: 60px;
    }
    
    .fc .fc-daygrid-day-number {
        font-size: 12px !important;
        padding: 4px !important;
    }
    
    /* Event pills - more compact */
    .fc .fc-daygrid-event {
        min-height: 20px !important;
        padding: 2px 2px !important;
        font-size: 12px !important;
        border-radius: 4px !important;
        margin: 1px 1px !important;
        width: calc(100% - 2px) !important;
        overflow: hidden !important;
    }
    
    /* Ensure event content fits */
    .fc .fc-daygrid-event .fc-event-main,
    .fc .fc-daygrid-event .fc-event-title,
    .fc .fc-daygrid-event .fc-event-main-frame {
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }
    
    /* BP reading - only show pressure numbers on mobile */
    /* Show pulse chip below BP numbers on mobile */
    .bp-pulse-chip {
        display: inline-flex !important;
        position: relative !important;
        top: auto !important;
        right: auto !important;
        margin-top: 2px;
        font-size: 9px !important;
        gap: 2px !important;
        justify-content: center;
    }
    
    /* BP event vertical layout for mobile - bigger events */
    .bp-event {
        min-height: 28px !important;
        padding: 3px 4px !important;
    }
    
    .bp-event .fc-event-main {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
        line-height: 1.2 !important;
        font-weight: 700 !important;
        font-size: 12px !important;
        padding: 2px 0 !important;
    }
    
    /* Event title centered - bigger font */
    .fc .fc-daygrid-event .fc-event-title {
        text-align: center;
        font-size: 12px !important;
        white-space: nowrap;
    }
    
    /* Selected/highlighted events must overflow cell boundaries on mobile */
    .fc .fc-daygrid-event.newly-added,
    .fc .fc-daygrid-event.bp-selected {
        overflow: visible !important;
    }
    
    /* Selected event highlight */
    .fc .fc-daygrid-event.bp-selected,
    .fc-event.bp-selected {
        /* Force hardware acceleration and high z-index */
        transform: translateX(var(--bp-selected-shift-x, 0px)) scale(1.28) translateZ(0);
        /* Use a softer shadow that fits the rounded shape */
        box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
        z-index: 500 !important;
        min-width: 50px !important;
        position: relative;
        outline: none !important;
        -webkit-tap-highlight-color: transparent;
        border-radius: 8px !important;
        /* Ensure background fills the rounded shape */
        overflow: hidden !important; 
    }
    
    /* Ensure the inner content doesn't overflow or create square corners */
    .fc-event.bp-selected .fc-event-main {
        border-radius: 8px !important;
        overflow: hidden !important;
    }
    
    .fc-event.bp-selected .fc-event-title {
        overflow: visible !important;
        white-space: nowrap !important;
    }
    
    /* Tooltip adjustments */
    .bp-tooltip {
        max-width: calc(100vw - 20px);
        font-size: 12px;
        padding: 12px;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .bp-container {
        padding: 4px;
        padding-top: 0;
        margin-top: 0; /* Header is in flow on mobile */
        padding-bottom: 60px;
    }
    
    .bp-legend {
        padding: 8px;
    }
    
    .legend-item {
        font-size: 12px;
        padding: 3px 6px;
    }
    
    .fc .fc-toolbar-title {
        font-size: 1rem !important;
    }
    
    .fc .fc-button {
        padding: 5px 8px !important;
        font-size: 11px !important;
    }
    
    .fc .fc-daygrid-day-number {
        font-size: 12px !important;
    }
    
    .fc .fc-daygrid-event {
        min-height: 24px !important;
        font-size: 11px !important;
    }
}

/* PWA standalone mode specific */
@media (display-mode: standalone) {
    .bp-container {
        margin-top: 0; /* Header is in flow on mobile */
        padding-top: 0;
    }
    
    .bp-header h2 {
        display: none;
    }
    
    .bp-actions {
        display: none;
    }
    
    .page-navigation {
        display: none !important;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .bp-legend {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .legend-left, .legend-right, .legend-center {
        flex: 1;
    }
    
    .fc .fc-dayGridWeek-button {
        display: inline-block;
    }
    
    .mobile-header-top {
        padding-top: 6px;
        padding-bottom: 6px;
    }
    
    .mobile-header-tabs {
        display: none; /* More space in landscape */
    }
}

/* Modal improvements for mobile - FULLSCREEN */
@media (max-width: 768px) {
    #bp-modal,
    #profile-modal {
        padding: 0 !important;
    }
    
    #bp-modal .modal-content,
    #profile-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        border-radius: 14px 14px 0 0 !important;
    }
    
    .modal-header {
        position: relative;
        z-index: 110;
        background: #4caf50;
        color: white;
        padding: 10px 12px !important;
        padding-top: calc(10px + env(safe-area-inset-top)) !important;
        font-size: 14px;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        border-radius: 0 !important;
    }
    
    .modal-header span:first-child {
        font-size: 14px;
        font-weight: 600;
        flex: 1;
    }
    
    .modal-header .close-btn {
        color: white !important;
        font-size: 22px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.2);
        border-radius: 50%;
        line-height: 1;
        order: -1;
    }
    
    .modal-body {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 16px !important;
        padding-bottom: 16px !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        background: white !important;
    }
    
    .modal-footer {
        flex-shrink: 0 !important;
        position: relative !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        padding: 10px 16px !important;
        padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
        background: white !important;
        border-top: 1px solid #eee;
        display: flex !important;
        gap: 8px;
        box-shadow: none !important;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 80px;
        padding: 14px 16px !important;
        font-size: 15px !important;
        border-radius: 10px;
    }
    
    /* Fields grid - single column on mobile */
    .bp-fields-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .bp-fields-grid .source-info {
        padding: 12px !important;
    }
    
    .bp-fields-grid .source-info input {
        font-size: 20px !important;
        padding: 14px !important;
        text-align: center;
        font-weight: 600;
    }
    
    /* Date input */
    #bp-date {
        font-size: 16px !important;
        padding: 12px !important;
    }
    
    /* Notes textarea */
    #bp-notes {
        font-size: 15px !important;
        padding: 12px !important;
        min-height: 80px;
    }
    
    /* Source info labels */
    .source-info strong {
        font-size: 13px;
        margin-bottom: 6px;
        display: block;
    }
    
    /* Profile modal fields */
    #profile-modal .source-info input,
    #profile-modal .source-info select,
    #profile-modal .source-info textarea {
        font-size: 16px !important;
        padding: 12px !important;
    }
    
    #profile-modal h4 {
        font-size: 15px !important;
        margin: 16px 0 10px 0 !important;
    }
    
    /* Delete button red and visible */
    #bp-delete {
        background: #dc3545 !important;
        border-color: #dc3545 !important;
    }
}

/* Very small screens - even more compact */
@media (max-width: 375px) {
    #bp-modal .modal-content,
    #profile-modal .modal-content {
        width: calc(100vw - 10px) !important;
        margin: 5px !important;
        max-height: calc(100vh - 10px) !important;
    }
    
    .modal-body {
        padding: 10px !important;
    }
    
    .bp-fields-grid .source-info input {
        font-size: 18px !important;
        padding: 12px !important;
    }
    
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .fc .fc-daygrid-day {
        min-height: 50px;
    }
    
    .legend-item {
        min-height: 32px;
        padding: 6px 10px;
    }
    
    .fc .fc-button {
        min-height: 40px;
        min-width: 40px;
    }
    
    /* Disable hover effects on touch */
    .bp-event:hover {
        box-shadow: none !important;
    }
    
    /* Active state instead */
    .bp-event:active {
        transform: scale(0.98);
        box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
    }
}

/* Safe area adjustments for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .pwa-install-banner {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    
    .bp-container {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
    
    .fab-add {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* Dark mode support (for future) */
@media (prefers-color-scheme: dark) {
    /* TODO: Add dark mode styles if needed */
}
