/* Main Styles */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f5f5;
    --text-color: #333;
    --border-color: #ddd;

    --fh-duration-fast: 0.18s;
    --fh-duration-med: 0.28s;
    --fh-ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    --fh-shadow-tab: 0 2px 8px rgba(15, 23, 42, 0.12);
    --fh-shadow-tab-md: 0 3px 12px rgba(15, 23, 42, 0.14);

    --fh-shadow-raised:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 4px 14px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
    --fh-shadow-lift:
        0 4px 8px rgba(15, 23, 42, 0.08),
        0 12px 28px rgba(15, 23, 42, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);

    --fh-primary: #4a90e2;
    --fh-primary-hover: #3e79be;
    --fh-primary-active: #3567a2;
    --fh-primary-subtle: #edf4fc;
    --fh-primary-border: #c6dcf6;
    --fh-primary-text: #ffffff;
    --fh-primary-subtle-text: #1f2a37;

    --fh-secondary: #dce9f8;
    --fh-secondary-hover: #cfdff2;
    --fh-secondary-active: #c0d3ea;
    --fh-secondary-border: #b4c9e3;
    --fh-secondary-text: #1f2a37;

    --fh-tertiary: #f4f8fd;
    --fh-tertiary-hover: #e5eef9;
    --fh-tertiary-active: #d6e5f5;
    --fh-tertiary-border: #c6d8ee;
    --fh-tertiary-text: #1f2a37;
    --fh-focus-ring: #89b6eb;
    --fh-surface-tint: #f7fafe;
    --fh-header-gradient-end: #2c5282;

    --fh-success: #198754;
    --fh-success-hover: #157347;
    --fh-success-active: #146c43;
    --fh-success-subtle: #d1e7dd;
    --fh-success-border: #a3cfbb;
    --fh-success-text: #ffffff;
    --fh-success-subtle-text: #0f5132;

    --fh-warning: #f59e0b;
    --fh-warning-hover: #d97706;
    --fh-warning-active: #b45309;
    --fh-warning-subtle: #fff3cd;
    --fh-warning-border: #ffe69c;
    --fh-warning-text: #111827;
    --fh-warning-subtle-text: #664d03;

    --fh-danger: #dc3545;
    --fh-danger-hover: #bb2d3b;
    --fh-danger-active: #b02a37;
    --fh-danger-subtle: #f8d7da;
    --fh-danger-border: #f1aeb5;
    --fh-danger-text: #ffffff;
    --fh-danger-subtle-text: #842029;

    --fh-info: #0ea5e9;
    --fh-info-hover: #0b84bd;
    --fh-info-active: #0a6f9f;
    --fh-info-subtle: #cff4fc;
    --fh-info-border: #9eeaf9;
    --fh-info-text: #ffffff;
    --fh-info-subtle-text: #055160;
}

/* Opacity only — do not animate transform on #dashboardContentArea: it would trap
   position:fixed Bootstrap modals (backdrops on body would cover the dialog). */
@keyframes fh-content-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

body.family-hub-body {
    font-family: "Figtree", system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    color: var(--text-color);
}

main {
    min-height: 100vh;
}

.app-header {
    background: linear-gradient(135deg, var(--fh-primary, var(--person-accent, #4a90e2)) 0%, var(--fh-header-gradient-end, #2c5282) 100%);
}

/* Header top: title (left) · balance + persona (right from md up); mobile: second row = persona menu */
.app-header-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.75rem;
    row-gap: 0.5rem;
    align-items: center;
}

.app-header-brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.app-header-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: min(66vw, 240px);
    border-radius: 0.7rem;
    padding: 0.22rem 0.45rem;
    text-decoration: none;
    transition:
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        border-color var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-med) var(--fh-ease-out);
}

.app-header-logo {
    display: block;
    width: 100%;
    height: auto;
    max-height: 62px;
}

body.header-tone-dark .app-header-logo-link {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

body.header-tone-light .app-header-logo-link {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(31, 42, 55, 0.28);
    box-shadow:
        0 2px 8px rgba(15, 23, 42, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@media (hover: hover) and (pointer: fine) {
    .app-header-logo-link:hover,
    .app-header-logo-link:focus-visible {
        box-shadow: var(--fh-shadow-tab-md);
    }
}

.app-header-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    max-width: 100%;
}

.app-header-persona-mobile {
    grid-column: 1 / -1;
    grid-row: 2;
}

@media (min-width: 768px) {
    .app-header-persona-mobile {
        display: none;
    }

    .app-header-top {
        row-gap: 0.35rem;
    }
}

.persona-chip {
    min-height: 2.75rem;
    touch-action: manipulation;
    transition:
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        border-color var(--fh-duration-fast) var(--fh-ease-out),
        color var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-med) var(--fh-ease-out),
        transform var(--fh-duration-med) var(--fh-ease-out);
}

.persona-chip i {
    display: inline-block;
    transition: transform var(--fh-duration-med) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .persona-chip:not(:disabled):hover,
    .persona-chip:not(:disabled):focus-visible {
        transform: translateY(-1px);
        box-shadow: var(--fh-shadow-tab);
    }

    .persona-chip:not(:disabled):hover i,
    .persona-chip:not(:disabled):focus-visible i {
        transform: scale(1.08);
    }

    .persona-chip.btn-light.active:hover,
    .persona-chip.btn-light.active:focus-visible {
        transform: translateY(-1px);
        box-shadow: var(--fh-shadow-tab-md);
    }
}

.persona-chip.active {
    font-weight: 600;
    box-shadow: 0 0 0 0.15rem rgba(255, 255, 255, 0.35);
}

.persona-chip-mobile {
    transition:
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        transform var(--fh-duration-med) var(--fh-ease-out);
}

.persona-chip-mobile i {
    display: inline-block;
    transition: transform var(--fh-duration-med) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .persona-chip-mobile:hover i,
    .persona-chip-mobile:focus-visible i {
        transform: scale(1.06);
    }
}

.persona-chip-mobile.active {
    font-weight: 600;
    background-color: var(--fh-primary-subtle, rgba(74, 144, 226, 0.14));
}

.app-header .app-header-actions .dropdown-toggle {
    transition:
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-med) var(--fh-ease-out),
        transform var(--fh-duration-med) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .app-header .app-header-actions .dropdown-toggle:hover,
    .app-header .app-header-actions .dropdown-toggle:focus-visible {
        transform: translateY(-1px);
        box-shadow: var(--fh-shadow-tab);
    }
}

.app-header-balance {
    transition:
        box-shadow var(--fh-duration-med) var(--fh-ease-out),
        transform var(--fh-duration-med) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .app-header-balance:hover {
        transform: translateY(-1px);
        box-shadow: var(--fh-shadow-tab);
    }
}

.chore-thumb {
    max-height: 180px;
    object-fit: cover;
}

.meal-hero {
    max-height: 320px;
    width: 100%;
    object-fit: cover;
}

.chore-card .card-body {
    display: flex;
    flex-direction: column;
}

.grocery-store-nav .nav-link {
    text-align: left;
    touch-action: manipulation;
    border-radius: 0.45rem;
    transition:
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        color var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-med) var(--fh-ease-out),
        transform var(--fh-duration-med) var(--fh-ease-out),
        border-color var(--fh-duration-fast) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .grocery-store-nav .nav-link:hover,
    .grocery-store-nav .nav-link:focus-visible {
        transform: translateX(2px);
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    }
}

.grocery-line-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Main area: cards depth & accent border */
.family-hub-body main .card {
    border-radius: 0.55rem;
    border-color: var(--border-color);
    box-shadow: var(--fh-shadow-raised);
    transition:
        transform var(--fh-duration-med) var(--fh-ease-out),
        box-shadow var(--fh-duration-med) var(--fh-ease-out),
        border-color var(--fh-duration-fast) var(--fh-ease-out);
}

@supports (color: color-mix(in srgb, #fff 50%, #000)) {
    .family-hub-body main .card {
        border-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 14%, var(--border-color));
    }
}

/* No translateY on card hover: transform creates a containing block and traps
   position:fixed descendants (e.g. Bootstrap modals inside the card). */
@media (hover: hover) and (pointer: fine) {
    .family-hub-body main .card:hover {
        box-shadow: var(--fh-shadow-lift);
    }
}

@supports (color: color-mix(in srgb, #fff 50%, #000)) {
    .family-hub-body main .card:focus-within {
        border-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 28%, var(--border-color));
        box-shadow:
            var(--fh-shadow-lift),
            0 0 0 3px color-mix(in srgb, var(--fh-primary, #4a90e2) 32%, transparent);
        outline: none;
    }
}

@supports not (color: color-mix(in srgb, #fff 50%, #000)) {
    .family-hub-body main .card:focus-within {
        box-shadow: var(--fh-shadow-lift);
        outline: 2px solid var(--fh-primary, #4a90e2);
        outline-offset: 2px;
    }
}

/* Solid (non-subtle) colored card headers: drop inset highlight */
.family-hub-body main .card:has(> .card-header.bg-dark),
.family-hub-body main .card:has(> .card-header[class*="bg-"]:not(.bg-light):not(.bg-white):not([class*="-subtle"])) {
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 4px 14px rgba(15, 23, 42, 0.07);
}

@media (hover: hover) and (pointer: fine) {
    .family-hub-body main .card:has(> .card-header.bg-dark):hover,
    .family-hub-body main .card:has(> .card-header[class*="bg-"]:not(.bg-light):not(.bg-white):not([class*="-subtle"])):hover {
        box-shadow:
            0 4px 8px rgba(15, 23, 42, 0.12),
            0 12px 24px rgba(15, 23, 42, 0.1);
    }
}

/* Tab panel entrance */
@media (prefers-reduced-motion: no-preference) {
    #dashboardContentArea.tab-content {
        animation: fh-content-in 0.3s var(--fh-ease-out) both;
    }
}

/* Buttons (main only); flatten in button groups */
.family-hub-body main .btn {
    transition:
        transform var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-fast) var(--fh-ease-out),
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        border-color var(--fh-duration-fast) var(--fh-ease-out),
        color var(--fh-duration-fast) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .family-hub-body main .btn:hover:not(:disabled):not(.disabled) {
        transform: translateY(-1px);
        box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12);
    }
}

.family-hub-body main .btn:focus-visible:not(:disabled):not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--fh-focus-ring, #89b6eb) 38%, transparent);
}

.family-hub-body main .btn:active:not(:disabled):not(.disabled) {
    transform: scale(0.98);
    box-shadow: none;
}

.family-hub-body main .btn-group .btn,
.family-hub-body main .btn-group-vertical .btn {
    box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
    .family-hub-body main .btn-group .btn:hover:not(:disabled),
    .family-hub-body main .btn-group .btn:focus-visible:not(:disabled),
    .family-hub-body main .btn-group-vertical .btn:hover:not(:disabled),
    .family-hub-body main .btn-group-vertical .btn:focus-visible:not(:disabled) {
        transform: none;
        z-index: 2;
    }
}

.family-hub-body main .btn-group .btn:active:not(:disabled),
.family-hub-body main .btn-group-vertical .btn:active:not(:disabled) {
    transform: scale(0.98);
}

.family-hub-body main .badge {
    transition:
        transform var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-fast) var(--fh-ease-out);
}

.family-hub-body .btn-primary {
    --bs-btn-bg: var(--fh-primary);
    --bs-btn-border-color: var(--fh-primary);
    --bs-btn-color: var(--fh-primary-text);
    --bs-btn-hover-bg: var(--fh-primary-hover);
    --bs-btn-hover-border-color: var(--fh-primary-hover);
    --bs-btn-hover-color: var(--fh-primary-text);
    --bs-btn-active-bg: var(--fh-primary-active);
    --bs-btn-active-border-color: var(--fh-primary-active);
    --bs-btn-active-color: var(--fh-primary-text);
    --bs-btn-disabled-bg: var(--fh-primary);
    --bs-btn-disabled-border-color: var(--fh-primary);
    --bs-btn-disabled-color: var(--fh-primary-text);
}

.family-hub-body .btn-outline-primary {
    --bs-btn-color: var(--fh-primary);
    --bs-btn-border-color: var(--fh-primary-border);
    --bs-btn-hover-color: var(--fh-primary-text);
    --bs-btn-hover-bg: var(--fh-primary);
    --bs-btn-hover-border-color: var(--fh-primary);
    --bs-btn-active-color: var(--fh-primary-text);
    --bs-btn-active-bg: var(--fh-primary-active);
    --bs-btn-active-border-color: var(--fh-primary-active);
}

.family-hub-body .btn-secondary,
.family-hub-body .btn-outline-secondary:hover,
.family-hub-body .btn-outline-secondary:focus-visible {
    --bs-btn-bg: var(--fh-secondary);
    --bs-btn-border-color: var(--fh-secondary-border);
    --bs-btn-color: var(--fh-secondary-text);
    --bs-btn-hover-bg: var(--fh-secondary-hover);
    --bs-btn-hover-border-color: var(--fh-secondary-border);
    --bs-btn-hover-color: var(--fh-secondary-text);
    --bs-btn-active-bg: var(--fh-secondary-active);
    --bs-btn-active-border-color: var(--fh-secondary-border);
    --bs-btn-active-color: var(--fh-secondary-text);
}

.family-hub-body .btn-outline-secondary {
    --bs-btn-color: var(--fh-secondary-text);
    --bs-btn-border-color: var(--fh-secondary-border);
}

.family-hub-body .btn-tertiary {
    --bs-btn-bg: var(--fh-tertiary);
    --bs-btn-border-color: var(--fh-tertiary-border);
    --bs-btn-color: var(--fh-tertiary-text);
    --bs-btn-hover-bg: var(--fh-tertiary-hover);
    --bs-btn-hover-border-color: var(--fh-tertiary-border);
    --bs-btn-hover-color: var(--fh-tertiary-text);
    --bs-btn-active-bg: var(--fh-tertiary-active);
    --bs-btn-active-border-color: var(--fh-tertiary-border);
    --bs-btn-active-color: var(--fh-tertiary-text);
}

.family-hub-body .btn-success {
    --bs-btn-bg: var(--fh-success);
    --bs-btn-border-color: var(--fh-success);
    --bs-btn-color: var(--fh-success-text);
    --bs-btn-hover-bg: var(--fh-success-hover);
    --bs-btn-hover-border-color: var(--fh-success-hover);
    --bs-btn-active-bg: var(--fh-success-active);
    --bs-btn-active-border-color: var(--fh-success-active);
}

.family-hub-body .btn-warning {
    --bs-btn-bg: var(--fh-warning);
    --bs-btn-border-color: var(--fh-warning);
    --bs-btn-color: var(--fh-warning-text);
    --bs-btn-hover-bg: var(--fh-warning-hover);
    --bs-btn-hover-border-color: var(--fh-warning-hover);
    --bs-btn-hover-color: var(--fh-warning-text);
    --bs-btn-active-bg: var(--fh-warning-active);
    --bs-btn-active-border-color: var(--fh-warning-active);
    --bs-btn-active-color: var(--fh-warning-text);
}

.family-hub-body .btn-danger {
    --bs-btn-bg: var(--fh-danger);
    --bs-btn-border-color: var(--fh-danger);
    --bs-btn-color: var(--fh-danger-text);
    --bs-btn-hover-bg: var(--fh-danger-hover);
    --bs-btn-hover-border-color: var(--fh-danger-hover);
    --bs-btn-active-bg: var(--fh-danger-active);
    --bs-btn-active-border-color: var(--fh-danger-active);
}

.family-hub-body .btn-info {
    --bs-btn-bg: var(--fh-info);
    --bs-btn-border-color: var(--fh-info);
    --bs-btn-color: var(--fh-info-text);
    --bs-btn-hover-bg: var(--fh-info-hover);
    --bs-btn-hover-border-color: var(--fh-info-hover);
    --bs-btn-active-bg: var(--fh-info-active);
    --bs-btn-active-border-color: var(--fh-info-active);
}

.family-hub-body .nav-pills .nav-link.active,
.family-hub-body .nav-pills .show > .nav-link {
    background-color: var(--fh-primary);
    color: var(--fh-primary-text);
}

.family-hub-body .nav-pills .nav-link:not(.active) {
    color: var(--fh-primary);
}

.family-hub-body .progress-bar {
    background-color: var(--fh-primary);
}

.family-hub-body .table-primary {
    --bs-table-bg: var(--fh-primary-subtle);
    --bs-table-striped-bg: color-mix(in srgb, var(--fh-primary-subtle) 88%, #ffffff);
    --bs-table-hover-bg: color-mix(in srgb, var(--fh-primary-subtle) 82%, #ffffff);
    color: var(--fh-primary-subtle-text);
}

.family-hub-body .text-bg-info {
    background-color: var(--fh-info-subtle) !important;
    color: var(--fh-info-subtle-text) !important;
}

.family-hub-body .alert-success {
    background-color: var(--fh-success-subtle);
    border-color: var(--fh-success-border);
    color: var(--fh-success-subtle-text);
}

.family-hub-body .alert-warning {
    background-color: var(--fh-warning-subtle);
    border-color: var(--fh-warning-border);
    color: var(--fh-warning-subtle-text);
}

.family-hub-body .alert-danger {
    background-color: var(--fh-danger-subtle);
    border-color: var(--fh-danger-border);
    color: var(--fh-danger-subtle-text);
}

.family-hub-body .alert-info {
    background-color: var(--fh-info-subtle);
    border-color: var(--fh-info-border);
    color: var(--fh-info-subtle-text);
}

.family-hub-body .form-control:focus,
.family-hub-body .form-select:focus,
.family-hub-body .form-check-input:focus,
.family-hub-body .btn:focus-visible {
    border-color: var(--fh-primary-border);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--fh-focus-ring, #89b6eb) 42%, transparent);
}

@media (hover: hover) and (pointer: fine) {
    .family-hub-body main a.badge:hover,
    .family-hub-body main a.badge:focus-visible {
        transform: scale(1.03);
    }
}

/* Header tab nav */
.app-header.app-header-with-tabs .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .app-header.app-header-with-tabs .app-header-top {
        margin-bottom: 0.35rem;
    }

    .app-header.app-header-with-tabs .tabs {
        margin-top: 1.1rem;
    }
}

.app-header .tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 500;
    transition:
        background-color var(--fh-duration-fast) var(--fh-ease-out),
        color var(--fh-duration-fast) var(--fh-ease-out),
        border-color var(--fh-duration-fast) var(--fh-ease-out),
        box-shadow var(--fh-duration-med) var(--fh-ease-out),
        transform var(--fh-duration-med) var(--fh-ease-out);
}

.app-header .tab i {
    display: inline-block;
    transition: transform var(--fh-duration-med) var(--fh-ease-out);
}

@media (hover: hover) and (pointer: fine) {
    body.header-tone-dark .app-header .tab:hover,
    body.header-tone-dark .app-header .tab:focus-visible {
        transform: translateY(-1px);
        box-shadow: var(--fh-shadow-tab);
    }

    body.header-tone-light .app-header .tab:hover,
    body.header-tone-light .app-header .tab:focus-visible {
        transform: translateY(-1px);
        box-shadow: var(--fh-shadow-tab);
    }

    .app-header .tab:hover i,
    .app-header .tab:focus-visible i {
        transform: scale(1.08);
    }
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
    .app-header .tab:hover,
    .app-header .tab:focus-visible {
        transform: translateY(-1px) scale(1.02);
    }
}

body.header-tone-dark .app-header .tab {
    color: rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.28);
}

body.header-tone-dark .app-header .tab:hover,
body.header-tone-dark .app-header .tab:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.45);
}

body.header-tone-dark .app-header .tab.active {
    color: #1f2a37;
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(255, 255, 255, 0.96);
}

body.header-tone-light .app-header .tab {
    color: #1f2a37;
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(31, 42, 55, 0.25);
}

body.header-tone-light .app-header .tab:hover,
body.header-tone-light .app-header .tab:focus-visible {
    color: #111827;
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(31, 42, 55, 0.4);
}

body.header-tone-light .app-header .tab.active {
    color: #fff;
    background: #1f2a37;
    border-color: #1f2a37;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .app-header h1.h3 {
        font-size: 1.3rem;
    }

    .app-header-logo-link {
        max-width: min(72vw, 210px);
        padding: 0.18rem 0.35rem;
    }

    .app-header-logo {
        max-height: 52px;
    }

    .user-balance {
        max-width: 58vw;
    }

    .app-header .tabs {
        gap: 0.4rem;
    }

    .app-header .tab {
        padding: 0.4rem 0.8rem;
        min-height: 2.3rem;
    }
}

.calendar-agenda-list .calendar-agenda-day:first-child .list-group-item.border-top {
    border-top: none !important;
}

.calendar-agenda-today {
    background-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 8%, #ffffff);
}

/* Calendar tab: Google column first; side-by-side 70% / 30% from xl up when embed is configured */
@media (min-width: 1200px) {
    .calendar-tab-layout-split > .calendar-tab-google {
        flex: 0 0 70%;
        max-width: 70%;
        width: 70%;
    }

    .calendar-tab-layout-split > .calendar-tab-agenda {
        flex: 0 0 30%;
        max-width: 30%;
        width: 30%;
    }
}

/* TV calendar: inset from screen edges (replaces tight container-fluid padding) */
.calendar-tv-shell {
    padding: clamp(1.25rem, 3vw, 2.75rem);
}

/* TV calendar: more space around the Google embed and between columns */
.calendar-tv-view > .calendar-tab-layout.row {
    --bs-gutter-x: clamp(1.25rem, 2.5vw, 2.5rem);
    --bs-gutter-y: clamp(1.25rem, 2.5vw, 2.5rem);
}

.calendar-tv-view .calendar-tab-google .calendar-embed {
    margin-top: 0.75rem;
}

.calendar-tv-clock-time {
    display: block;
    font-size: clamp(5.25rem, 12vw, 8.25rem);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.calendar-tv-view .calendar-embed iframe {
    min-height: 70vh;
}

@media (min-width: 1200px) {
    .calendar-tv-view .calendar-embed iframe {
        min-height: 78vh;
    }
}

/* TV dashboard: dark room mode (wall display) */
body.calendar-tv-dark {
    color-scheme: dark;
    background-color: #0f172a;
    color: #e2e8f0;
    --text-color: #e2e8f0;
    --border-color: #334155;
    --secondary-color: #1e293b;
}

/* Photo collage behind TV calendar (fixed full viewport) */
.calendar-tv-collage-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.calendar-tv-collage-grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: clamp(6px, 1vw, 14px);
    padding: clamp(6px, 1vw, 14px);
    box-sizing: border-box;
}

.calendar-tv-collage-grid--mosaic {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(1) {
    grid-column: 1 / 3;
    grid-row: 1 / 3;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(2) {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(3) {
    grid-column: 4 / 5;
    grid-row: 1 / 2;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(4) {
    grid-column: 5 / 6;
    grid-row: 1 / 2;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(5) {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(6) {
    grid-column: 4 / 5;
    grid-row: 2 / 3;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(7) {
    grid-column: 5 / 6;
    grid-row: 2 / 3;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(8) {
    grid-column: 1 / 3;
    grid-row: 3 / 5;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(9) {
    grid-column: 3 / 5;
    grid-row: 3 / 5;
}

.calendar-tv-collage-grid--mosaic .calendar-tv-collage-tile:nth-child(10) {
    grid-column: 5 / 6;
    grid-row: 3 / 5;
}

.calendar-tv-collage-grid--even .calendar-tv-collage-tile {
    min-height: 0;
    min-width: 0;
}

.calendar-tv-collage-tile {
    min-height: 0;
    min-width: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.calendar-tv-collage-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(15, 23, 42, 0.78) 0%,
        rgba(15, 23, 42, 0.62) 45%,
        rgba(15, 23, 42, 0.75) 100%
    );
}

body.calendar-tv-dark main {
    position: relative;
    z-index: 1;
    background-color: transparent;
}

body.calendar-tv-dark .calendar-tv-view h2,
body.calendar-tv-dark .calendar-tv-view h3 {
    color: #f1f5f9;
}

body.calendar-tv-dark .calendar-tv-view .calendar-tv-clock-time {
    color: #f8fafc;
}

body.calendar-tv-dark .calendar-tv-view .text-muted {
    color: #94a3b8 !important;
}

body.calendar-tv-dark .calendar-tv-view .calendar-embed {
    background-color: #1e293b;
    border-color: #334155 !important;
}

body.calendar-tv-dark .calendar-tv-view .calendar-embed.bg-white {
    background-color: #1e293b !important;
}

body.calendar-tv-dark .calendar-tv-view .list-group-item {
    background-color: rgba(30, 41, 59, 0.75);
    color: #e2e8f0;
    border-color: #334155 !important;
}

body.calendar-tv-dark .calendar-tv-view .list-group-item-action:hover,
body.calendar-tv-dark .calendar-tv-view .list-group-item-action:focus {
    background-color: rgba(51, 65, 85, 0.65);
    color: #f8fafc;
}

body.calendar-tv-dark .calendar-tv-view .calendar-agenda-today {
    background-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 24%, #1e293b);
    border-color: var(--fh-primary, #60a5fa) !important;
}

body.calendar-tv-dark .calendar-tv-view .calendar-agenda-today .text-primary {
    color: var(--fh-primary, #93c5fd) !important;
}

body.calendar-tv-dark .calendar-tv-view .text-primary {
    color: var(--fh-primary, #93c5fd) !important;
}

body.calendar-tv-dark .calendar-tv-view .btn-outline-secondary {
    color: #cbd5e1;
    border-color: #64748b;
}

body.calendar-tv-dark .calendar-tv-view .btn-outline-secondary:hover,
body.calendar-tv-dark .calendar-tv-view .btn-outline-secondary:focus {
    background-color: #334155;
    border-color: #94a3b8;
    color: #f8fafc;
}

body.calendar-tv-dark .calendar-tv-view code {
    background-color: #334155;
    color: #e2e8f0;
}

body.calendar-tv-dark .calendar-tv-view .badge.bg-secondary {
    background-color: #475569 !important;
    color: #f1f5f9;
}


/* Meal detail (recipe) page: sections and flow */
.meal-detail-header {
    border-bottom: 1px solid var(--border-color);
}

.meal-detail-intro.card {
    border: 1px solid var(--border-color);
    background-color: var(--secondary-color);
}

@supports (color: color-mix(in srgb, #fff 50%, #000)) {
    .meal-detail-intro.card {
        background-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 8%, #fff);
    }
}

.meal-detail-lead {
    font-size: 1.05rem;
    line-height: 1.65;
}

.meal-detail .meal-detail-section {
    margin-top: 2rem;
}

.meal-detail-intro + .meal-detail-section {
    margin-top: 1.25rem;
}

.meal-detail .meal-detail-section:not(:first-of-type) {
    padding-top: 1.75rem;
    border-top: 1px solid var(--border-color);
}

.meal-detail-section-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.meal-detail-section-heading .fa {
    color: var(--fh-primary, var(--primary-color));
    opacity: 0.9;
}

.meal-detail-section-lead {
    margin-bottom: 1rem;
    max-width: 42rem;
}

.meal-detail-list .list-group-item {
    border-color: var(--border-color);
}

.meal-detail-checklist {
    margin-bottom: 0;
    max-width: 42rem;
}

.meal-detail-checklist li {
    margin-bottom: 0.35rem;
}

.meal-detail-directions {
    line-height: 1.7;
    max-width: 50rem;
}

.meal-editor-page {
    max-width: 52rem;
}

/* Meal plan grid + share/import actions */
.meal-grid-table thead th {
    background-color: color-mix(in srgb, var(--fh-primary, var(--primary-color)) 18%, var(--secondary-color, #f8f9fa));
    font-weight: 600;
    border-color: var(--border-color);
}

.meal-grid-table tbody tr:nth-child(odd) td,
.meal-grid-table tbody tr:nth-child(odd) th[scope="row"] {
    background-color: rgba(0, 0, 0, 0.04);
}

.meal-detail-actions,
.meals-recipe-actions {
    row-gap: 0.5rem;
}

.meal-import-modal-body .form-label {
    font-weight: 600;
}

.banking-hero {
    border-radius: 0.8rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--fh-primary, #4a90e2) 20%, #ffffff), color-mix(in srgb, var(--fh-info, #0ea5e9) 16%, #ffffff));
    border: 1px solid color-mix(in srgb, var(--fh-primary, #4a90e2) 34%, #ffffff);
}

.banking-overview-card {
    overflow: hidden;
    position: relative;
}

@media (prefers-reduced-motion: no-preference) {
    .banking-overview-card {
        animation: banking-card-in 0.55s var(--fh-ease-out) both;
    }

    .banking-overview-card:nth-child(1) { animation-delay: 0.04s; }
    .banking-overview-card:nth-child(2) { animation-delay: 0.1s; }
    .banking-overview-card:nth-child(3) { animation-delay: 0.16s; }
    .banking-overview-card:nth-child(4) { animation-delay: 0.22s; }
}

.banking-overview-card::after {
    content: "";
    position: absolute;
    inset: auto -20% -45% auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    opacity: 0.2;
    pointer-events: none;
}

.banking-overview-checking::after { background: var(--fh-primary, #4a90e2); }
.banking-overview-savings::after { background: var(--fh-success, #2fbf71); }
.banking-overview-charity::after { background: var(--fh-info, #8f65ff); }
.banking-overview-donated::after { background: var(--fh-warning, #f2994a); }

@keyframes banking-card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
