
/* =========================================================================
   DESIGN TOKENS
   ========================================================================= */
:root {
    color-scheme: light;

    --primary-color: #6366f1;
    --primary-color-rgb: 99, 102, 241;
    --primary-hover: #4f46e5;
    --primary-soft: rgba(99, 102, 241, 0.1);
    --accent-color: #a855f7;
    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);

    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-soft: rgba(16, 185, 129, 0.12);
    --warning-color: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.14);
    --error-color: #ef4444;
    --error-soft: rgba(239, 68, 68, 0.12);

    --background-color: #f5f6fb;
    --surface-color: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef1f7;
    --text-primary: #1e1b4b; /* the dark blue of the panda in the icon */
    --text-secondary: #5f6b80;
    --text-muted: #94a3b8;
    --border-color: #e5e8f0;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 2px 6px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.14);

    --border-radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --radius-pill: 999px;

    /* SF Pro Rounded on iPhone, iPad and Mac (rounded like the icon, native on iOS); Nunito elsewhere
       (Android, Windows): one style for the site and the iPhone app */
    --font-family: ui-rounded, 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --header-h: 60px;
    --nav-h: 68px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --ease: cubic-bezier(.2, .8, .2, 1);

    /* Bristol scale */
    --bristol-bg: var(--surface-2);
    --bristol-fg: var(--text-primary);
    --bristol-border: var(--border-color);
    --bristol-icon-bg: rgba(124, 58, 237, .08);
    --bristol-icon-stroke: #8b5e3c;
}

[data-theme="dark"] {
    color-scheme: dark;

    --primary-color: #818cf8;
    --primary-color-rgb: 129, 140, 248;
    --primary-hover: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, 0.16);
    --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #9333ea 100%);

    --success-soft: rgba(16, 185, 129, 0.18);
    --warning-soft: rgba(245, 158, 11, 0.18);
    --error-soft: rgba(239, 68, 68, 0.18);

    --background-color: #0b1120;
    --surface-color: #151c2e;
    --surface-2: #1b2338;
    --surface-3: #232c44;
    --text-primary: #f1f5f9;
    --text-secondary: #a3b0c5;
    --text-muted: #6b7a93;
    --border-color: #29334b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);

    --bristol-icon-bg: rgba(167, 139, 250, .16);
    --bristol-icon-stroke: #d4a373;
}

/* =========================================================================
   BASE
   ========================================================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    background-image:
        radial-gradient(1200px 400px at 10% -10%, rgba(var(--primary-color-rgb), 0.10), transparent 60%),
        radial-gradient(900px 400px at 110% 0%, rgba(168, 85, 247, 0.08), transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h2 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

h3,
h4 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    line-height: 1.25;
    font-weight: 700;
}

h3:first-child,
h4:first-child {
    margin-top: 0;
}

p {
    margin-bottom: 1rem;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--primary-color);
}

button,
input,
select,
textarea {
    font-family: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid rgba(var(--primary-color-rgb), 0.45);
    outline-offset: 2px;
}

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    padding: calc(0.75rem + var(--safe-top)) 1.25rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .app-header {
    background: rgba(11, 17, 32, 0.78);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.app-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.app-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    border-radius: 12px;
    background: var(--gradient-brand);
    box-shadow: 0 6px 16px rgba(var(--primary-color-rgb), 0.35);
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem calc(var(--nav-h) + 2rem + var(--safe-bottom));
}

.section {
    display: none;
}

.section--active {
    display: block;
    animation: sectionIn .35s var(--ease);
}

@keyframes sectionIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Bottom navigation */
.app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem calc(0.4rem + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .app-nav {
    background: rgba(21, 28, 46, 0.86);
    border-top-color: rgba(255, 255, 255, 0.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 52px;
    padding: 0.35rem 0.25rem;
    background: none;
    border: none;
    border-radius: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color .2s, background-color .2s, transform .15s;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: grid;
    place-items: center;
    width: 52px;
    height: 30px;
    border-radius: var(--radius-pill);
    transition: background-color .25s var(--ease), transform .25s var(--ease);
    filter: grayscale(0.6);
    opacity: 0.85;
}

.nav-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.nav-item--active {
    color: var(--primary-color);
}

.nav-item--active .nav-icon {
    background: var(--primary-soft);
    filter: none;
    opacity: 1;
}

@media (min-width: 768px) {
    .app-nav {
        left: 50%;
        right: auto;
        bottom: calc(1rem + var(--safe-bottom));
        transform: translateX(-50%);
        width: min(560px, calc(100% - 2rem));
        padding: 0.4rem;
        border-radius: 22px;
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
    }

    .nav-item {
        flex-direction: row;
        gap: 0.4rem;
        min-height: 48px;
    }

    .nav-item .nav-icon {
        width: auto;
        height: auto;
        background: none !important;
    }

    .nav-item--active {
        background: var(--primary-soft);
    }

    .nav-label {
        font-size: 0.85rem;
    }
}

/* Floating "add event" button */
.fab {
    position: fixed;
    right: 1.25rem;
    bottom: calc(var(--nav-h) + 1rem + var(--safe-bottom));
    z-index: 250;
    width: 58px;
    height: 58px;
    border-radius: 20px;
    border: none;
    background: var(--gradient-brand);
    color: #fff;
    font-size: 1.9rem;
    font-weight: 400;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(var(--primary-color-rgb), 0.45);
    transition: transform .2s var(--ease), box-shadow .2s;
}

.fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(var(--primary-color-rgb), 0.5);
}

.fab:active {
    transform: scale(0.94);
}

.fab[hidden] {
    display: none;
}

@media (min-width: 768px) {
    .fab {
        right: max(1.5rem, calc((100vw - 1120px) / 2));
        bottom: calc(1.5rem + var(--safe-bottom));
    }
}

/* =========================================================================
   BUTTONS & CHIPS
   ========================================================================= */
.btn {
    padding: 0.7rem 1.25rem;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    transition: background-color .2s, border-color .2s, color .2s, transform .1s, box-shadow .2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 14px rgba(var(--primary-color-rgb), 0.3);
}

[data-theme="dark"] .btn--primary {
    background: #6366f1;
}

.btn--primary:hover {
    background: var(--primary-hover);
}

[data-theme="dark"] .btn--primary:hover {
    background: #4f46e5;
}

.btn--secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn--secondary:hover {
    background: var(--surface-2);
    border-color: rgba(var(--primary-color-rgb), 0.35);
}

.btn--danger {
    background: var(--error-color);
    color: #fff;
}

.btn--danger:hover {
    background: #dc2626;
}

.btn--sm {
    padding: 0.4rem 0.85rem;
    min-height: 36px;
    font-size: 0.85rem;
    border-radius: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.chip--accent {
    background: var(--primary-soft);
    color: var(--primary-color);
}

.chip--success {
    background: var(--success-soft);
    color: #059669;
}

[data-theme="dark"] .chip--success {
    color: #34d399;
}

.chip--warning {
    background: var(--warning-soft);
    color: #b45309;
}

[data-theme="dark"] .chip--warning {
    color: #fbbf24;
}

.chip--danger {
    background: var(--error-soft);
    color: #dc2626;
}

[data-theme="dark"] .chip--danger {
    color: #f87171;
}

/* =========================================================================
   HOME
   ========================================================================= */
.reminders {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.reminders:empty {
    display: none;
}

.reminder {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--warning-soft);
    color: var(--text-primary);
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 0.9rem 1rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.95rem;
}

.reminder::before {
    content: '⏰';
    font-size: 1.2rem;
    line-height: 1.3;
}

.children-list {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (max-width: 600px) {
    .kpi {
        padding: 0.7rem 0.8rem;
    }

    .kpi-value {
        font-size: 1.3rem;
    }
}

@media (min-width: 720px) {
    .children-list {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 1.25rem;
    }
}

.child-card {
    --child-color: var(--primary-color);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}

.child-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 96px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--child-color) 16%, transparent), transparent);
    pointer-events: none;
}

.child-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--child-color) 40%, var(--border-color));
}

.child-card:focus-visible {
    outline-offset: 3px;
}

.child-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.child-avatar {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    background: var(--child-color);
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.08));
    box-shadow: 0 6px 16px color-mix(in srgb, var(--child-color) 40%, transparent);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.child-heading {
    flex: 1;
    min-width: 0;
}

.child-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.child-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.child-color-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--surface-color);
    box-shadow: 0 0 0 1px var(--border-color);
    flex-shrink: 0;
    display: inline-block;
}

.child-card-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.add-event-btn {
    flex: 1;
    min-height: 48px;
    padding: 0.75rem 1rem;
    background: var(--child-color, var(--primary-color));
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.12));
    color: #fff;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.98rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--child-color, var(--primary-color)) 35%, transparent);
    transition: transform .15s, filter .2s;
}

.add-event-btn:hover {
    filter: brightness(1.05);
}

.add-event-btn:active {
    transform: scale(0.97);
}

.stats-link {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 48px;
    padding: 0 1rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color .2s, border-color .2s;
}

.stats-link:hover {
    background: var(--surface-2);
    border-color: color-mix(in srgb, var(--child-color) 45%, var(--border-color));
}

/* Empty state */
.no-children-message {
    text-align: center;
    padding: 1rem 0;
}

.empty-state {
    max-width: 560px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    color: var(--text-secondary);
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 1.35rem;
    font-weight: 800;
}

.empty-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto 1.25rem;
    display: grid;
    place-items: center;
    font-size: 2.6rem;
    border-radius: 28px;
    background: var(--primary-soft);
}

.empty-state .btn {
    margin-top: 0.5rem;
}

.empty-benefits {
    margin-top: 1.75rem;
    text-align: left;
    display: grid;
    gap: 0.5rem;
    font-size: 0.92rem;
    line-height: 1.55;
}

.empty-benefits h4 {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.empty-benefits p {
    margin: 0;
    padding: 0.6rem 0.8rem;
    background: var(--surface-2);
    border-radius: 12px;
}

/* Wide screens: the welcome uses the whole width, actions on the left and reasons on the right */
@media (min-width: 900px) {
    .no-children-message {
        grid-column: 1 / -1;
    }

    .empty-state {
        max-width: 1000px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 2.5rem;
        align-items: start;
        padding: 2.5rem;
    }

    .empty-state > :not(.empty-benefits) {
        grid-column: 1;
    }

    .empty-benefits {
        grid-column: 2;
        grid-row: 1 / span 4;
        margin-top: 0;
    }
}

/* =========================================================================
   CALENDAR
   ========================================================================= */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.3rem;
    box-shadow: var(--shadow-sm);
}

.calendar-nav h2 {
    min-width: 170px;
    text-align: center;
    font-size: 1.1rem;
    text-transform: capitalize;
    white-space: nowrap;
}

.calendar-nav .btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 12px;
    border: none;
    background: var(--surface-2);
}

.calendar-nav .btn:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
}

.calendar-filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-width: 220px;
    max-width: 640px;
}

.calendar-filter select {
    min-width: 180px;
}

.sub-filters {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.filter-group {
    margin-bottom: 0.9rem;
}

.filter-group>label {
    display: block;
    font-weight: 800;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* Filter checkboxes rendered as toggle chips */
.filter-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600 !important;
    margin-bottom: 0 !important;
    padding: 0.35rem 0.75rem 0.35rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    color: var(--text-primary);
    user-select: none;
    transition: background-color .2s, border-color .2s, color .2s;
}

.filter-checkbox:hover {
    border-color: rgba(var(--primary-color-rgb), 0.45);
}

.filter-checkbox:has(input:checked) {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-checkbox:has(input:focus-visible) {
    outline: 3px solid rgba(var(--primary-color-rgb), 0.45);
    outline-offset: 2px;
}

.checkbox-custom-mini {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    position: relative;
    transition: all .2s;
    background: var(--surface-color);
    display: inline-block;
    flex-shrink: 0;
}

.filter-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.filter-checkbox input[type="checkbox"]:checked+.checkbox-custom-mini {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-checkbox input[type="checkbox"]:checked+.checkbox-custom-mini::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.filter-count {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    box-shadow: var(--shadow);
}

.calendar-day-header {
    padding: 0.35rem 0 0.5rem;
    font-weight: 800;
    text-align: center;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.calendar-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    min-height: 84px;
    padding: 0.45rem 0.25rem;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: background-color .2s, border-color .2s, transform .15s;
}

.calendar-day:not(.calendar-day--other-month):hover {
    background: var(--primary-soft);
    border-color: rgba(var(--primary-color-rgb), 0.3);
}

.calendar-day:not(.calendar-day--other-month):active {
    transform: scale(0.96);
}

.calendar-day--other-month {
    background: transparent;
    opacity: 0.65;
    cursor: default;
}

.calendar-day--has-events {
    background: color-mix(in srgb, var(--primary-color) 6%, var(--surface-2));
}

.day-number {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.88rem;
}

.calendar-day--today {
    border-color: var(--primary-color);
}

.calendar-day--today .day-number {
    /* Darker indigo than the main color: white numbers stay readable (contrast 6:1) */
    background: #4f46e5;
    color: #fff;
}

.day-events {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    max-width: 100%;
}

.event-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    box-shadow: 0 0 0 1.5px var(--surface-color);
}

@media (max-width: 600px) {
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-nav {
        justify-content: space-between;
    }

    .calendar-nav h2 {
        min-width: 0;
        flex: 1;
    }

    .calendar-filters {
        max-width: none;
    }

    .calendar-grid {
        gap: 3px;
        padding: 0.45rem;
        border-radius: 18px;
    }

    .calendar-day {
        min-height: 58px;
        padding: 0.3rem 0.1rem;
        border-radius: 10px;
        gap: 0.2rem;
    }

    .day-number {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }

    .event-dot {
        width: 6px;
        height: 6px;
    }

    .calendar-day-header {
        font-size: 0.65rem;
        letter-spacing: 0.02em;
    }
}

/* =========================================================================
   FORMS
   ========================================================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text-primary);
    /* 16px avoids iOS zoom on focus */
    font-size: 16px;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
    -webkit-appearance: none;
    appearance: none;
}

select.form-control {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 12px 8px;
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

input[type="date"].form-control,
input[type="time"].form-control {
    display: block;
    min-width: 0;
}

.form-control:hover {
    border-color: rgba(var(--primary-color-rgb), 0.35);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--surface-color);
    box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb), 0.15);
}

/* Event form layout: two columns on wider screens */
@media (min-width: 560px) {
    #eventForm {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 0.85rem;
    }

    #eventForm>* {
        grid-column: 1 / -1;
    }

    #eventForm>.form-group--half {
        grid-column: auto;
    }

    #eventForm>.form-group--flag {
        grid-column: auto;
    }
}

.form-section-title {
    grid-column: 1 / -1;
    margin: 0.5rem 0 0.6rem;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.form-group--flag {
    margin-bottom: 0.5rem;
}

/* Checkbox rows rendered as switches */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    line-height: 1.35;
    margin-bottom: 0 !important;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    transition: border-color .2s, background-color .2s;
    min-height: 48px;
}

.checkbox-label:hover {
    border-color: rgba(var(--primary-color-rgb), 0.35);
}

.checkbox-label:has(input:checked) {
    border-color: rgba(var(--primary-color-rgb), 0.55);
    background: var(--primary-soft);
}

.checkbox-label:has(input:focus-visible) {
    outline: 3px solid rgba(var(--primary-color-rgb), 0.45);
    outline-offset: 2px;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.checkbox-custom {
    order: 2;
    margin-left: auto;
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: 42px;
    height: 24px;
    border-radius: var(--radius-pill);
    background: var(--text-muted);
    opacity: 0.6;
    transition: background-color .25s var(--ease), opacity .25s;
}

.checkbox-custom::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform .25s var(--ease);
}

.checkbox-label input[type="checkbox"]:checked+.checkbox-custom {
    background: var(--primary-color);
    opacity: 1;
}

[data-theme="dark"] .checkbox-label input[type="checkbox"]:checked+.checkbox-custom {
    background: #6366f1;
}

.checkbox-label input[type="checkbox"]:checked+.checkbox-custom::after {
    transform: translateX(18px);
}

.checkbox-label input[type="checkbox"]:disabled+.checkbox-custom {
    opacity: 0.45;
}

.checkbox-label>span:last-child {
    order: 1;
}

/* Color warning in the event form */
.alert-banner {
    grid-column: 1 / -1;
    background-color: var(--warning-soft);
    color: var(--text-primary);
    border: 1px solid rgba(245, 158, 11, 0.45);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.alert-banner.danger {
    background-color: var(--error-soft);
    border-color: rgba(239, 68, 68, 0.5);
}

/* =========================================================================
   MODALS  (bottom sheet on phones, centered dialog on larger screens)
   ========================================================================= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn .2s ease;
}

.modal.modal--active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp .3s var(--ease);
}

@keyframes slideUp {
    from {
        transform: translateY(24px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

.modal-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.modal-close {
    /* iOS style: small round grey button */
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: rgba(120, 120, 128, 0.16);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color .2s, color .2s;
}

.modal-close:hover {
    background: rgba(120, 120, 128, 0.24);
    color: var(--text-primary);
}

/* Bigger touch area than the visible circle (44px, as Apple recommends) */
.modal-close {
    position: relative;
}
.modal-close::after {
    content: '';
    position: absolute;
    inset: -6px;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.25rem;
}

.modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem calc(0.9rem + var(--safe-bottom));
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    flex-wrap: wrap;
}

.modal-footer>div {
    display: flex;
    gap: 0.75rem;
}

.modal .modal-body ul {
    margin: 0.5rem 0 0.75rem 1.25rem;
    padding: 0;
}

.modal .modal-body li {
    margin: 0.25rem 0;
}

.modal .modal-body p {
    margin: 0.5rem 0 0;
}

.modal-body h3 {
    margin-top: 1rem;
}

@media (max-width: 600px) {
    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        max-width: 100% !important;
        max-height: 94vh;
        max-height: 94dvh;
        border-radius: 24px 24px 0 0;
        border-bottom: none;
        animation: sheetUp .35s var(--ease);
    }

    .modal-header {
        padding-top: 1.35rem;
    }

    .modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: var(--border-color);
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .modal-footer .btn {
        flex: 1;
    }

    .modal-footer>div {
        flex: 1;
        margin-left: 0 !important;
    }

    .modal-footer>div:empty,
    .modal-footer>div:not(:has(> :not([hidden]))) {
        display: none;
    }

    /* Sheets follow the finger when dragged down from the top (js/sheets.js) */
    .modal-content.is-dragging {
        animation: none;
        transition: none;
    }
    .modal-content.is-releasing {
        transition: transform .25s var(--ease);
    }

    #eventDeleteSection {
        flex-basis: 100%;
    }

    #eventDeleteSection .btn {
        width: 100%;
    }
}

@keyframes sheetUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: none;
    }
}

/* Daily events list */
.event-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: border-color .2s, background-color .2s, transform .15s;
}

.event-item:hover {
    border-color: rgba(var(--primary-color-rgb), 0.45);
    background: var(--primary-soft);
}

.event-item-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.event-item-text {
    min-width: 0;
}

.event-item-title {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.event-item-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 700;
}

.event-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.event-item-tags .chip {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
}

.empty-hint {
    text-align: center;
    color: var(--text-secondary);
    padding: 1.5rem 1rem;
    background: var(--surface-2);
    border-radius: 14px;
    border: 1px dashed var(--border-color);
}

/* =========================================================================
   SETTINGS
   ========================================================================= */
.settings-container {
    max-width: 760px;
    margin: 0 auto;
}

.settings-section {
    margin-bottom: 1.75rem;
}

.settings-section>h3 {
    margin: 0 0 0.6rem 0.25rem;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
}

.settings-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.settings-card>p {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.settings-card h4 {
    font-size: 1rem;
}

.settings-card h4+p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.child-settings {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.child-settings:first-child {
    padding-top: 0;
}

.child-settings:last-of-type {
    border-bottom: none;
}

.child-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    min-width: 0;
}

.child-info .child-color-indicator {
    width: 18px;
    height: 18px;
}

.child-actions {
    display: flex;
    gap: 0.5rem;
}

.child-actions .btn {
    min-height: 38px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
}

.add-child-btn {
    width: 100%;
}

.backup-section,
.import-section,
.pdf-section,
.reset-section {
    padding: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.reset-section {
    background: var(--error-soft);
    border-color: rgba(239, 68, 68, 0.3);
}

.backup-actions,
.import-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem 1rem;
    flex-wrap: wrap;
}

.backup-actions .btn,
.import-actions .btn {
    margin-right: 0 !important;
}

.backup-actions small,
.import-actions small {
    color: var(--text-secondary);
}

@media (max-width: 480px) {

    .backup-actions,
    .import-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .backup-actions small,
    .import-actions small {
        white-space: normal;
    }

    .child-actions {
        width: 100%;
    }

    .child-actions .btn {
        flex: 1;
    }
}

.pdf-section p {
    margin: 0 0 .5rem;
}

.pdf-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .6rem;
    align-items: end;
}

.pdf-controls .form-control {
    width: 100%;
    max-width: 100%;
}

.pdf-date-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pdf-date-group label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 .3rem;
}

.export-pdf-btn {
    grid-column: 1 / -1;
    justify-self: start;
}

@media (max-width: 640px) {
    .pdf-controls {
        grid-template-columns: 1fr;
    }

    .export-pdf-btn {
        justify-self: stretch;
    }
}

.app-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    color: var(--text-primary);
    line-height: 1.5;
}

.info-item strong {
    font-weight: 700;
}

.info-item.copyright {
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-style: italic;
}

.info-item.disclaimer {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.info-item a:hover {
    text-decoration: underline !important;
}

/* =========================================================================
   INFO SECTION
   ========================================================================= */
.info-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 820px) {
    .info-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #stoolGuide {
        grid-column: 1 / -1;
    }
}

.info-box {
    --info-accent: var(--primary-color);
    position: relative;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 1.25rem 1.25rem 1.25rem 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.info-box::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--info-accent);
}

.info-box h4 {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.info-box p {
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.65;
}

.info-box--yellow { --info-accent: #facc15; }
.info-box--green { --info-accent: #10b981; }
.info-box--blue { --info-accent: #3b82f6; }
.info-box--pink { --info-accent: #ec4899; }
.info-box--purple { --info-accent: #7c3aed; }
.info-box--orange { --info-accent: #f97316; }
.info-box--teal { --info-accent: #14b8a6; }
.info-box--red { --info-accent: #ef4444; }
.info-box--indigo { --info-accent: #6366f1; }
.info-box--brown { --info-accent: #8b5e3c; }
.info-box--violet { --info-accent: #7c3aed; }

/* Bristol scale */
.bristol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.bristol-item {
    background: var(--bristol-bg);
    color: var(--bristol-fg);
    border: 1px solid var(--bristol-border);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color .25s, box-shadow .25s;
}

.bristol-item>summary {
    list-style: none;
    cursor: pointer;
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 0.6rem;
    align-items: center;
    padding: 0.6rem 0.7rem;
}

.bristol-item>summary::-webkit-details-marker {
    display: none;
}

.bristol-title {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--bristol-fg);
}

.bristol-title span {
    opacity: .8;
    font-weight: 500;
}

.bristol-desc {
    padding: 0 0.8rem 0.8rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.bristol-svg {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--bristol-icon-bg);
}

.bristol-svg svg {
    width: 40px;
    height: 40px;
    fill: currentColor;
    color: var(--bristol-icon-stroke);
    stroke: currentColor;
    stroke-width: 2;
}

.bristol-item[open] {
    border-color: rgba(124, 58, 237, 0.45);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

/* =========================================================================
   COLORS (child colors + stool colors)
   ========================================================================= */
.color-pink { background-color: #ec4899; }
.color-blue { background-color: #3b82f6; }
.color-green { background-color: #10b981; }
.color-orange { background-color: #f59e0b; }
.color-purple { background-color: #8b5cf6; }
.color-teal { background-color: #14b8a6; }

.color-rosa { background-color: #f472b6; }
.color-azzurro { background-color: #38bdf8; }
.color-blu { background-color: #2563eb; }
.color-verde { background-color: #16a34a; }
.color-arancione { background-color: #f97316; }
.color-giallo { background-color: #eab308; }
.color-rosso { background-color: #ef4444; }
.color-viola { background-color: #9333ea; }
.color-marrone { background-color: #92400e; }
.color-bianco-grigio { background-color: #d1d5db; }

.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.event-color-option {
    display: flex;
    align-items: center;
}

/* =========================================================================
   CHILD STATISTICS MODAL
   ========================================================================= */
#childStatsModal .modal-content {
    max-width: 960px;
}

#childStatsModal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--background-color);
}

.stats-hero {
    --child-color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.stats-hero .child-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 1.15rem;
}

.stats-hero-text {
    min-width: 0;
}

.stats-hero-text h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-hero-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.segmented {
    display: inline-flex;
    padding: 4px;
    gap: 2px;
    background: var(--surface-3);
    border-radius: 14px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
    display: none;
}

.segmented button {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    min-height: 36px;
    transition: background-color .2s, color .2s, box-shadow .2s;
}

.segmented button[aria-pressed="true"] {
    background: var(--surface-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.stats-range-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stats-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

@media (min-width: 640px) {
    .stats-kpis {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.kpi {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.85rem 0.95rem;
    min-width: 0;
}

.kpi-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.3;
}

.kpi-value {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value--text {
    font-size: 1.15rem;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

.kpi-value small {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-left: 0.15rem;
}

.kpi-sub {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.kpi-delta {
    font-weight: 800;
}

.kpi-delta--up {
    color: #059669;
}

.kpi-delta--down {
    color: #dc2626;
}

[data-theme="dark"] .kpi-delta--up {
    color: #34d399;
}

[data-theme="dark"] .kpi-delta--down {
    color: #f87171;
}

.stats-alert {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    background: var(--error-soft);
    border: 1px solid rgba(239, 68, 68, 0.35);
    font-size: 0.9rem;
    font-weight: 600;
}

.stats-alert::before {
    content: '⚠️';
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 760px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-card--wide {
        grid-column: 1 / -1;
    }
}

.stats-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 1rem 1.1rem 1.1rem;
    min-width: 0;
}

.stats-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.stats-card h4 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
}

.stats-legend {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    font-size: 0.76rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stats-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.legend-line {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    display: inline-block;
}

.chart-box {
    position: relative;
    width: 100%;
    height: 230px;
}

.chart-box--sm {
    height: 190px;
}

.chart-box canvas {
    display: block;
}

/* Horizontal distribution bars */
.dist-list {
    display: grid;
    gap: 0.6rem;
}

.dist-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.75rem;
    align-items: center;
}

.dist-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    font-weight: 600;
    min-width: 0;
}

.dist-label span:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dist-value {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dist-value strong {
    color: var(--text-primary);
}

.dist-bar {
    grid-column: 1 / -1;
    height: 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    overflow: hidden;
}

.dist-bar>span {
    display: block;
    height: 100%;
    min-width: 0;
    border-radius: var(--radius-pill);
    background: var(--primary-color);
    transition: width .6s var(--ease);
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.stats-insights {
    list-style: none;
    display: grid;
    gap: 0.5rem;
    margin: 0 !important;
}

.stats-insights li {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-size: 0.9rem;
    line-height: 1.45;
    margin: 0 !important;
}

.stats-insights li::before {
    content: '';
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    margin-top: 0.45rem;
    border-radius: 50%;
    background: var(--primary-color);
}

.recent-list {
    display: grid;
    gap: 0.5rem;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: inherit;
    font: inherit;
    transition: border-color .2s, background-color .2s;
}

.recent-item:hover {
    border-color: rgba(var(--primary-color-rgb), 0.45);
}

.recent-item .swatch {
    width: 22px;
    height: 22px;
}

.recent-item-main {
    flex: 1;
    min-width: 0;
}

.recent-item-date {
    font-weight: 700;
    font-size: 0.88rem;
}

.recent-item-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item-chevron {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.stats-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 1rem;
    background: var(--surface-color);
    border: 1px dashed var(--border-color);
    border-radius: 18px;
}

/* Legacy containers kept for compatibility */
.stats-charts {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-chart {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

/* =========================================================================
   PRIVACY MODAL
   ========================================================================= */
#privacyModal .settings-card {
    box-shadow: none;
    border: none;
    padding: 0;
}

#privacyModal .settings-card h4 {
    margin-top: 1.25rem !important;
    margin-bottom: .35rem;
}

#privacyModal .settings-card h4:first-of-type {
    margin-top: .25rem !important;
}

#privacyModal .settings-card div[data-i18n$="_body"] {
    color: var(--text-secondary);
    font-size: 0.93rem;
}

#privacyModal .settings-card div[data-i18n$="_body"] p,
#privacyModal .settings-card div[data-i18n$="_body"] ul {
    margin-bottom: .75rem;
}

#consentModal .settings-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

/* =========================================================================
   CONSENT BANNER
   ========================================================================= */
.consent-banner {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(var(--nav-h) + 0.75rem + var(--safe-bottom));
    z-index: 1100;
    display: none;
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.1rem;
    animation: slideUp .35s var(--ease);
}

@media (min-width: 768px) {
    .consent-banner {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(860px, calc(100% - 2rem));
        bottom: calc(var(--nav-h) + 2rem + var(--safe-bottom));
        animation: fadeIn .35s ease;
    }
}

.consent-banner__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    flex-wrap: wrap;
}

.consent-banner__text {
    flex: 1 1 320px;
    font-size: .9rem;
    display: flex;
    gap: .35rem .6rem;
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-secondary);
}

.consent-banner__text strong {
    color: var(--text-primary);
    width: 100%;
}

.consent-banner__actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .consent-banner__actions {
        width: 100%;
    }

    .consent-banner__actions .btn {
        flex: 1;
    }
}

.consent-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

/* =========================================================================
   NOTIFICATIONS (toasts)
   ========================================================================= */
@keyframes slideIn {
    from {
        transform: translateY(16px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: none;
        opacity: 1;
    }

    to {
        transform: translateY(16px);
        opacity: 0;
    }
}

.notification-container {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-h) + 1rem + var(--safe-bottom));
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    width: min(440px, calc(100% - 2rem));
    pointer-events: none;
}

.notification {
    width: 100%;
    padding: 0.85rem 1.1rem 0.85rem 1rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    color: #fff;
    font-weight: 700;
    font-size: 0.93rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: slideIn .3s var(--ease) forwards;
    pointer-events: auto;
}

.notification::before {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.85rem;
}

.notification--success {
    background-color: #059669;
}

.notification--success::before {
    content: '✓';
}

.notification--error {
    background-color: #dc2626;
}

.notification--error::before {
    content: '!';
}

/* =========================================================================
   MOTION PREFERENCES
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

#childStatsSummary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* =========================================================================
   CALENDAR: VIEW SWITCH + AGENDA
   ========================================================================= */
.calendar-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.85rem;
}

.calendar-toolbar .segmented button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
}

@media (max-width: 600px) {
    .calendar-toolbar .segmented {
        width: 100%;
    }

    .calendar-toolbar .segmented button {
        flex: 1;
        justify-content: center;
    }
}

.agenda {
    max-width: 860px;
}

.agenda-month {
    position: sticky;
    top: calc(var(--header-h) + var(--safe-top));
    z-index: 5;
    margin: 1.25rem 0 0.6rem !important;
    padding: 0.45rem 0.25rem;
    font-size: 1.05rem;
    font-weight: 800;
    text-transform: capitalize;
    background: var(--background-color);
}

.agenda-month:first-child {
    margin-top: 0 !important;
}

.agenda-day {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.agenda-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0.15rem;
    line-height: 1.1;
}

.agenda-weekday,
.agenda-monthshort {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.agenda-daynum {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0.15rem 0;
    border-radius: 50%;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.agenda-day--today .agenda-daynum {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 6px 16px rgba(var(--primary-color-rgb), 0.35);
}

[data-theme="dark"] .agenda-day--today .agenda-daynum {
    background: #6366f1;
}

.agenda-day--today .agenda-weekday,
.agenda-day--today .agenda-monthshort {
    color: var(--primary-color);
}

.agenda-events {
    display: grid;
    gap: 0.5rem;
    min-width: 0;
}

.agenda-day-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 34px;
}

.agenda-day-label {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-add {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background-color .2s, border-color .2s;
}

.agenda-add:hover {
    background: var(--primary-soft);
    border-color: rgba(var(--primary-color-rgb), 0.4);
}

.agenda-event {
    --child-color: var(--primary-color);
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    width: 100%;
    padding: 0.75rem 0.9rem 0.75rem 1.1rem;
    text-align: left;
    font: inherit;
    color: inherit;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    overflow: hidden;
    transition: border-color .2s, transform .15s, box-shadow .2s;
}

.agenda-event::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--child-color);
}

.agenda-event:hover {
    border-color: color-mix(in srgb, var(--child-color) 45%, var(--border-color));
    box-shadow: var(--shadow);
}

.agenda-event:active {
    transform: scale(0.99);
}

.agenda-time {
    flex-shrink: 0;
    min-width: 3.1rem;
    padding-top: 0.1rem;
    font-weight: 800;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.agenda-event-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.agenda-event-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.agenda-avatar {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    background: var(--child-color);
}

.agenda-child {
    font-weight: 800;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-flags {
    margin-left: auto;
    display: inline-flex;
    gap: 0.15rem;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.agenda-event-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.agenda-event-tags .chip {
    font-size: 0.74rem;
    padding: 0.15rem 0.55rem;
}

.agenda-event-extra,
.agenda-event-notes {
    font-size: 0.82rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.agenda-event-notes {
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agenda-chevron {
    align-self: center;
    color: var(--text-muted);
    font-size: 1.3rem;
}

.agenda-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0 0.5rem;
}

.agenda-count {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

@media (max-width: 600px) {
    .agenda-day {
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 0.5rem;
    }

    .agenda-daynum {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }

    .agenda-event {
        gap: 0.6rem;
        padding: 0.7rem 0.75rem 0.7rem 0.95rem;
    }

    .agenda-chevron {
        display: none;
    }
}

/* =========================================================================
   IN-APP DIALOG (confirmations) + ERROR BOX
   ========================================================================= */
.modal--dialog {
    z-index: 1200;
}

.modal--dialog .modal-content {
    max-width: 420px;
}

.modal--dialog .modal-body {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
}

.dialog-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 1.3rem;
    background: var(--primary-soft);
}

.dialog-icon--danger {
    background: var(--error-soft);
}

.dialog-message {
    margin: 0 !important;
    white-space: pre-line;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
}

.modal--dialog .modal-footer {
    justify-content: flex-end;
}

.modal--dialog .modal-footer>div:empty {
    display: none;
}

@media (min-width: 601px) {
    .modal--dialog {
        align-items: center;
    }
}

.error-display {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-h) + 1rem + var(--safe-bottom));
    z-index: 9999;
    width: min(440px, calc(100% - 2rem));
    padding: 0.85rem 1.1rem;
    border-radius: 16px;
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid rgba(239, 68, 68, 0.45);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Toasts move to the top while a window is open, so they never cover its buttons */
body:has(.modal.modal--active) .notification-container {
    top: calc(1rem + var(--safe-top));
    bottom: auto;
}

/* =========================================================================
   SECTION TITLES (same header on every tab)
   ========================================================================= */
.section-title {
    margin: 0.25rem 0 1rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.section-title::first-letter {
    text-transform: uppercase;
}

#settings .section-title {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 600px) {
    .section-title {
        font-size: 1.3rem;
        margin-bottom: 0.85rem;
    }
}

/* =========================================================================
   UNIFIED CARD SYSTEM
   Every section uses the same card as the home page: rounded 24px surface,
   soft shadow, accent tint on top, coloured icon tile + bold title.
   ========================================================================= */
.settings-card,
.info-box,
.calendar-panel {
    --card-accent: var(--primary-color);
    position: relative;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .25s var(--ease), border-color .25s;
}

.settings-card::before,
.info-box::before,
.calendar-panel::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: auto;
    height: 96px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--card-accent) 16%, transparent), transparent);
    pointer-events: none;
}

.settings-card>*,
.info-box>*,
.calendar-panel>* {
    position: relative;
}

.info-box {
    --card-accent: var(--info-accent, var(--primary-color));
}

.info-box:hover,
.settings-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--card-accent) 30%, var(--border-color));
}

/* Card header: icon tile (like the child avatar) + title */
.card-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.card-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 16px;
    font-size: 1.35rem;
    line-height: 1;
    background: var(--card-accent);
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.08));
    box-shadow: 0 6px 16px color-mix(in srgb, var(--card-accent) 40%, transparent);
}

.card-heading {
    min-width: 0;
    flex: 1;
}

.card-title,
.info-box .card-head h4 {
    margin: 0 !important;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--text-primary);
}

.card-sub {
    margin: 0.15rem 0 0 !important;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Inner tiles (same as the home metric / stats tiles) */
.settings-tile,
.backup-section,
.import-section,
.pdf-section,
.reset-section {
    padding: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin: 0 !important;
}

.reset-section {
    background: var(--error-soft);
    border-color: rgba(239, 68, 68, 0.3);
}

.settings-tiles {
    display: grid;
    gap: 0.75rem;
}

@media (min-width: 760px) {
    .settings-tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-tile--wide {
        grid-column: 1 / -1;
    }
}

.tile-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.4rem;
}

.tile-head h4 {
    margin: 0 !important;
    font-size: 1rem;
    font-weight: 800;
}

.tile-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 0.95rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.settings-tile p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
}

.settings-tile small {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Settings layout: card grid like the home page */
.settings-container {
    max-width: 1120px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

.settings-section {
    margin: 0;
    min-width: 0;
}

.settings-section .settings-card {
    margin: 0;
}

@media (min-width: 900px) {
    .settings-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }

    .settings-section--wide {
        grid-column: 1 / -1;
    }
}

#settings .section-title {
    max-width: 1120px;
}

/* Child rows in settings: same avatar as the home cards */
.child-settings-list {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.child-settings {
    --child-color: var(--primary-color);
    padding: 0.75rem;
    margin: 0;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.child-settings:first-child {
    padding-top: 0.75rem;
}

.child-settings:last-of-type {
    border-bottom: 1px solid var(--border-color);
}

.child-avatar--sm {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    font-size: 1.05rem;
}

.child-settings-name {
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.settings-card .form-control {
    margin-top: 0.25rem;
}

.settings-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.settings-note {
    margin: 0.85rem 0 0 !important;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.app-info .info-item a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
}

/* Info section: cards in a grid exactly like the home cards */
.info-container {
    gap: 1rem;
}

@media (min-width: 820px) {
    .info-container {
        gap: 1.25rem;
    }
}

.info-box {
    padding: 1.25rem;
}

.info-box .card-head {
    margin-bottom: 0.75rem;
}

.info-box p {
    padding: 0.85rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin: 0;
}

/* Calendar: controls live in a card like everything else */
.calendar-panel {
    margin-bottom: 1rem;
    padding: 1rem;
}

.calendar-panel .calendar-toolbar {
    margin-bottom: 0.75rem;
}

.calendar-panel .calendar-header {
    margin-bottom: 0;
}

.calendar-panel .calendar-nav {
    background: var(--surface-2);
    box-shadow: none;
}

.calendar-panel .sub-filters {
    background: var(--surface-2);
    box-shadow: none;
    border-radius: 14px;
}

.calendar-grid {
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.agenda-event {
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.agenda-month {
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Buttons: same treatment as the home "Aggiungi evento" button */
.btn {
    border-radius: 14px;
}

.btn--primary,
[data-theme="dark"] .btn--primary {
    background: var(--gradient-brand);
    color: #fff;
    border: none;
    box-shadow: 0 6px 16px rgba(var(--primary-color-rgb), 0.3);
}

.btn--primary:hover,
[data-theme="dark"] .btn--primary:hover {
    background: var(--gradient-brand);
    filter: brightness(1.06);
}

.btn--danger {
    background: linear-gradient(135deg, #f87171, #dc2626);
    border: none;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.28);
}

.btn--danger:hover {
    background: linear-gradient(135deg, #f87171, #dc2626);
    filter: brightness(1.06);
}

.btn--danger-soft {
    background: var(--error-soft);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .btn--danger-soft {
    color: #f87171;
}

.btn--danger-soft:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn--block {
    width: 100%;
    min-height: 48px;
}

.segmented button[aria-pressed="true"] {
    color: var(--primary-color);
}

.settings-stack {
    display: grid;
    gap: 1rem;
}

@media (min-width: 900px) {
    .settings-stack {
        gap: 1.25rem;
    }
}

.bristol-grid {
    align-items: start;
}

/* =========================================================================
   EVENT PREVIEW DETAILS (agenda + day list): factors, feeding, full notes
   ========================================================================= */
.event-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.35rem;
}

.chip--flag {
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    background: rgba(139, 92, 246, 0.12);
    color: var(--text-primary);
    white-space: normal;
}

.event-extra {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

/* Notes are always shown in full: no truncation, line breaks preserved */
.event-notes {
    display: block;
    margin-top: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--child-color, var(--primary-color));
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-line;
    overflow-wrap: anywhere;
    text-align: left;
}

.event-notes-label {
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    white-space: normal;
}

.agenda-event .event-notes {
    background: var(--surface-2);
}

.event-item {
    align-items: flex-start;
}

.event-item-main {
    flex: 1;
    min-width: 0;
    align-items: flex-start;
}

.event-item-main .child-color-indicator {
    margin-top: 0.35rem;
}

.event-item-text {
    flex: 1;
}

.event-item .btn {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .event-item {
        position: relative;
    }

    .event-item .btn {
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        min-height: 32px;
        padding: 0.3rem 0.7rem;
        font-size: 0.78rem;
    }

    .event-item-title {
        padding-right: 5.5rem;
    }
}

/* Header logo uses the real app icon */
img.app-icon {
    /* The full square icon, rounded here like an iOS app icon (22% of the side) */
    display: block;
    width: 38px;
    height: 38px;
    padding: 0;
    background: none;
    border-radius: 22.4%;
    box-shadow: 0 6px 16px rgba(var(--primary-color-rgb), 0.35);
}

/* Full JSON backup tile */
.settings-tile--accent {
    background: color-mix(in srgb, var(--card-accent) 8%, var(--surface-2));
    border-color: color-mix(in srgb, var(--card-accent) 35%, var(--border-color));
}

.backup-status {
    font-weight: 700;
}

/* Storage unavailable: hide navigation and quick actions */
body.app--unavailable .app-nav,
body.app--unavailable .fab {
    display: none !important;
}

/* Informational reminder (e.g. install on iPhone to protect data) */
.reminder--info {
    background: var(--primary-soft);
    border-color: rgba(var(--primary-color-rgb), 0.35);
    font-weight: 500;
}

.reminder--info::before {
    content: '📲';
}

.reminder-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.reminder-body .btn {
    margin-top: 0.25rem;
}

/* =========================================================================
   ACCESSIBLE CONTRAST (WCAG AA 4.5:1 for text)
   ========================================================================= */
:root:not([data-theme="dark"]) {
    --primary-color: #4f46e5;
    --primary-color-rgb: 79, 70, 229;
    --primary-hover: #4338ca;
    --text-muted: #5b6b82;
    --gradient-button: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
    --success-text: #047857;
    --danger-text: #b91c1c;
    --warning-text: #92400e;
}

[data-theme="dark"] {
    --text-muted: #8b9ab3;
    --gradient-button: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
    --success-text: #34d399;
    --danger-text: #f87171;
    --warning-text: #fbbf24;
}

/* Child-coloured elements: readable ink chosen per colour in JS (--child-solid / --child-ink) */
.child-avatar,
.agenda-avatar {
    background: var(--child-solid, var(--child-color));
    color: var(--child-ink, #fff);
    text-shadow: none;
}

.add-event-btn {
    background: var(--child-solid, var(--child-color, var(--primary-color)));
    color: var(--child-ink, #fff);
    text-shadow: none;
}

/* Text on brand gradient buttons */
.btn--primary,
[data-theme="dark"] .btn--primary,
.btn--primary:hover,
[data-theme="dark"] .btn--primary:hover {
    background: var(--gradient-button);
}

.btn--danger,
.btn--danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn--danger-soft {
    color: var(--danger-text);
}

.chip {
    color: #475569;
}

[data-theme="dark"] .chip {
    color: var(--text-secondary);
}

.chip--accent {
    color: var(--primary-color);
}

.chip--success,
[data-theme="dark"] .chip--success {
    color: var(--success-text);
}

.chip--warning,
[data-theme="dark"] .chip--warning {
    color: var(--warning-text);
}

.chip--danger,
[data-theme="dark"] .chip--danger {
    color: var(--danger-text);
}

.kpi-delta--up,
[data-theme="dark"] .kpi-delta--up {
    color: var(--success-text);
}

.kpi-delta--down,
[data-theme="dark"] .kpi-delta--down {
    color: var(--danger-text);
}

.notification--success {
    background-color: #047857;
}

.notification--error {
    background-color: #b91c1c;
}

/* Hide the UI until texts are translated (removed by script.js; boot.js has a 4s safety net) */
html.booting .app {
    opacity: 0;
}

.app {
    transition: opacity .15s ease;
}

.skeleton-card {
    min-height: 260px;
    background: linear-gradient(100deg, var(--surface-color) 30%, var(--surface-2) 50%, var(--surface-color) 70%);
    background-size: 200% 100%;
    animation: skeleton 1.2s ease-in-out infinite;
    cursor: default;
}

@keyframes skeleton {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

/* Floating button visible: leave room so it never covers the last card or its buttons */
body.has-fab .app-main {
    padding-bottom: calc(var(--nav-h) + 1rem + 58px + 1.25rem + var(--safe-bottom));
}

@media (min-width: 768px) {
    body.has-fab .app-main {
        padding-bottom: calc(var(--nav-h) + 2.5rem + var(--safe-bottom));
    }
}

/* =========================================================================
   RIGHT-TO-LEFT (Arabic): mirror the side accents, spacing and floating button
   ========================================================================= */
[dir="rtl"] select.form-control {
    padding-right: 0.85rem;
    padding-left: 2.25rem;
    background-position: left 0.85rem center;
}
[dir="rtl"] .checkbox-custom,
[dir="rtl"] .agenda-flags {
    margin-left: 0;
    margin-right: auto;
}
[dir="rtl"] .checkbox-custom::after {
    left: auto;
    right: 3px;
}
[dir="rtl"] .checkbox-label input[type="checkbox"]:checked+.checkbox-custom::after {
    transform: translateX(-18px);
}
[dir="rtl"] .agenda-event::before {
    left: auto;
    right: 0;
}
[dir="rtl"] .event-notes {
    border-left: 1px solid var(--border-color);
    border-right: 3px solid var(--child-color, var(--primary-color));
}
[dir="rtl"] .color-dot {
    margin-right: 0;
    margin-left: 8px;
}
[dir="rtl"] .kpi-value small {
    margin-left: 0;
    margin-right: 0.15rem;
}
[dir="rtl"] .fab {
    right: auto;
    left: 1.25rem;
}
@media (min-width: 768px) {
    [dir="rtl"] .fab {
        left: max(1.5rem, calc((100vw - 1120px) / 2));
    }
}
@media (max-width: 600px) {
    [dir="rtl"] .event-item .btn {
        right: auto;
        left: 0.6rem;
    }
    [dir="rtl"] .event-item-title {
        padding-right: 0;
        padding-left: 5.5rem;
    }
}

/* Calendar: collapsible filters, always available */
.filters-details {
    border-radius: 14px;
}
.filters-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface-color);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.filters-summary::-webkit-details-marker {
    display: none;
}
.filters-summary::before {
    content: '▸';
    font-size: 0.8rem;
    transition: transform .2s var(--ease);
}
.filters-details[open] > .filters-summary::before {
    transform: rotate(90deg);
}
[dir="rtl"] .filters-summary::before {
    transform: scaleX(-1);
}
[dir="rtl"] .filters-details[open] > .filters-summary::before {
    transform: rotate(90deg);
}
.filters-badge {
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.75rem;
    display: inline-grid;
    place-items: center;
}
.filters-badge[hidden] {
    display: none;
}
.filters-details[open] > .sub-filters {
    margin-top: 0.75rem;
}
.calendar-count {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.calendar-count:empty {
    display: none;
}

/* Friendly error message with a reload button (details only in the console) */
.error-display__reload {
    margin-inline-start: 0.5rem;
    padding: 0.35rem 0.8rem;
    min-height: 36px;
    border: none;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

/* Text for screen readers and search engines only */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================================
   DISCOVER FEED ("Scopri"): curiosities, Bristol guide, articles, sponsored
   ========================================================================= */
.feed {
    align-items: start;
}
.feed-intro {
    margin: -0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
}
.feed-intro,
.feed-filters,
.feed-disclaimer {
    grid-column: 1 / -1;
}
.feed-filters {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.1rem 0.1rem 0.25rem;
    scrollbar-width: none;
}
.feed-filters::-webkit-scrollbar {
    display: none;
}
/* On phones the topics row scrolls up to the edges of the screen */
@media (max-width: 819px) {
    .feed-filters {
        margin-inline: -1.25rem;
        padding-inline: 1.25rem;
        scroll-padding-inline: 1.25rem;
    }
}
.feed-filter {
    min-height: 40px;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s;
}
.feed-filter:hover {
    border-color: rgba(var(--primary-color-rgb), 0.4);
}
.feed-filter.is-active {
    /* Darker indigo in both themes: white text stays readable */
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.feed-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    grid-column: 1 / -1;
}
@media (min-width: 820px) {
    .feed-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
    .feed-guide,
    .feed-collab {
        grid-column: 1 / -1;
    }
}
.feed-card {
    display: flex;
    flex-direction: column;
}
/* Parts of "All": title, then cards (two columns on wide screens) */
.feed-section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    min-width: 0;
}
.feed-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.feed-section-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}
@media (min-width: 820px) {
    .feed-section {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
    .feed-section-head,
    .feed-section > .feed-carousel,
    .feed-section > .feed-more {
        grid-column: 1 / -1;
    }
}
/* Curiosities: a row of cards that scrolls sideways (swipe; arrows with a mouse) */
.feed-carousel {
    display: flex;
    gap: 0.85rem;
    margin: 0 -1.25rem;
    /* Room for the shadow of the cards, which the scrolling row would cut */
    padding: 0.15rem 1.25rem 1.1rem;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 1.25rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.feed-carousel::-webkit-scrollbar {
    display: none;
}
.feed-carousel:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 12px;
}
.feed-carousel-item {
    flex: 0 0 82%;
    max-width: 320px;
    display: flex;
    scroll-snap-align: start;
}
.feed-carousel-item > .feed-card {
    flex: 1;
    margin: 0;
}
.feed-carousel-nav {
    display: none;
    gap: 0.4rem;
}
@media (hover: hover) and (pointer: fine) {
    .feed-carousel-nav {
        display: flex;
    }
}
/* On wide screens the row stays inside the page margins */
@media (min-width: 820px) {
    .feed-carousel {
        margin: 0 0 -0.6rem;
        padding-inline: 0.15rem;
        scroll-padding-inline: 0;
    }
}
.feed-carousel-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
.feed-carousel-btn:hover {
    border-color: rgba(var(--primary-color-rgb), 0.4);
}
[dir="rtl"] .feed-carousel-btn span {
    display: inline-block;
    transform: scaleX(-1);
}
.feed-more {
    justify-self: center;
}
.feed-kicker {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.6rem !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    font-size: 0.72rem !important;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--card-accent) 70%, var(--text-primary)) !important;
}
.feed-new {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    letter-spacing: 0.02em;
}
/* "Sources: AAP ↗ · WHO ↗" at the bottom of a card */
.feed-sources {
    margin: auto 0 0 !important;
    padding: 0.75rem 0 0 !important;
    background: none !important;
    border: 0 !important;
    font-size: 0.8rem !important;
    line-height: 1.5;
    color: var(--text-secondary) !important;
}
.feed-sources-label {
    font-weight: 700;
}
.feed-source {
    display: inline-block;
    padding: 0.1rem 0;
    color: color-mix(in srgb, var(--card-accent, var(--primary-color)) 55%, var(--text-primary));
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.feed-source:hover {
    text-decoration-thickness: 2px;
}
.feed-sources--article {
    margin: 0 0 0.75rem !important;
    padding: 0 !important;
}
.feed-guide .feed-sources {
    margin-top: 0.5rem !important;
    padding-top: 0 !important;
}
.feed-meta {
    margin: -0.35rem 0 0.75rem !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    font-size: 0.82rem !important;
    color: var(--text-muted) !important;
}
.feed-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 0.9rem;
    background: var(--surface-2);
}
.feed-link {
    align-self: flex-start;
    margin-top: 0.9rem;
    text-decoration: none;
}
.feed-card--sponsored {
    border-style: dashed;
}
.feed-disclaimer {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: center;
}

/* Dot on the navigation item when new articles are available */
.nav-item--new .nav-icon {
    position: relative;
}
.nav-item--new .nav-icon::after {
    content: '';
    position: absolute;
    top: -2px;
    inset-inline-end: -6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px var(--surface-color);
}

/* Bristol guide: new illustrations, type number and meaning */
:root {
    --bs-fill: #8b5a33;
    --bs-dark: #5c3a1f;
    --bs-light: #c08a5c;
    --bs-hard: #d97706;
    --bs-normal: #059669;
    --bs-soft: #ca8a04;
    --bs-liquid: #dc2626;
}
[data-theme="dark"] {
    --bs-fill: #a8784f;
    --bs-dark: #6b4426;
    --bs-light: #d6ad84;
    --bs-hard: #fbbf24;
    --bs-normal: #34d399;
    --bs-soft: #facc15;
    --bs-liquid: #f87171;
}
.bristol-scale {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 2fr;
    gap: 3px;
    height: 6px;
    margin: 0.9rem 0 0.25rem;
    border-radius: 999px;
    overflow: hidden;
}
.bristol-scale__hard { background: var(--bs-hard); }
.bristol-scale__normal { background: var(--bs-normal); }
.bristol-scale__soft { background: var(--bs-soft); }
.bristol-scale__liquid { background: var(--bs-liquid); }
.bristol-item {
    --bs-zone: var(--bs-normal);
}
.bristol-item--hard { --bs-zone: var(--bs-hard); }
.bristol-item--soft { --bs-zone: var(--bs-soft); }
.bristol-item--liquid { --bs-zone: var(--bs-liquid); }
.bristol-item>summary {
    grid-template-columns: 76px 1fr;
    gap: 0.75rem;
}
.bristol-svg {
    width: 76px;
    height: 54px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--bs-fill) 12%, var(--surface-color));
}
.bristol-svg svg {
    width: 66px;
    height: 44px;
    fill: none;
    stroke: none;
    color: inherit;
}
.bristol-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.bristol-type {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-secondary);
}
.bristol-zone {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    color: color-mix(in srgb, var(--bs-zone) 75%, var(--text-primary));
    background: color-mix(in srgb, var(--bs-zone) 14%, transparent);
}
.bristol-item[open] {
    border-color: color-mix(in srgb, var(--bs-zone) 55%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bs-zone) 12%, transparent);
}

/* =========================================================================
   BOTTOM NAVIGATION: floating rounded capsule (iOS inspired) built with the
   same surface, border and shadow as the app cards; the active tab shows its
   icon in a brand-gradient tile, like the card icons and the "+" button.
   Line icons: Lucide (ISC licence).
   ========================================================================= */
:root {
    --nav-h: 80px;
}
.app-nav {
    left: 12px;
    right: 12px;
    bottom: max(12px, calc(var(--safe-bottom) - 4px));
    height: 66px;
    padding: 6px;
    gap: 2px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--surface-color) 84%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .app-nav {
    background: color-mix(in srgb, var(--surface-color) 86%, transparent);
    border-color: var(--border-color);
}
.nav-item {
    min-height: 0;
    height: 100%;
    gap: 3px;
    padding: 3px 2px;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    -webkit-tap-highlight-color: transparent;
}
.nav-item--active {
    color: var(--primary-color);
    background: none;
}
.nav-icon,
.nav-item--active .nav-icon {
    width: 46px;
    height: 30px;
    border-radius: var(--radius-pill);
    background: none;
    filter: none;
    opacity: 1;
    transition: background-color .25s var(--ease), box-shadow .25s var(--ease), color .2s;
}
.nav-item--active .nav-icon {
    color: #fff;
    background: var(--gradient-brand);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.35);
}
.nav-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-icon svg .f {
    fill: currentColor;
    fill-opacity: 0;
    transition: fill-opacity .2s var(--ease);
}
.nav-item--active .nav-icon svg .f {
    fill-opacity: 0.22;
}
.nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0;
}
.nav-item--active .nav-label {
    font-weight: 800;
}
.nav-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}
@media (min-width: 768px) {
    .app-nav {
        left: 50%;
        right: auto;
        bottom: calc(1rem + var(--safe-bottom));
        width: min(680px, calc(100% - 2rem));
        height: 62px;
    }
    .nav-item {
        /* Width from the label: long words (Налаштування, Einstellungen) get more room */
        flex: 1 1 auto;
        flex-direction: row;
        gap: 0.45rem;
        min-width: 0;
        padding: 3px 14px 3px 4px;
    }
    .nav-item--active {
        background: var(--primary-soft);
    }
    .nav-item .nav-icon,
    .nav-item--active .nav-icon {
        width: 38px;
        height: 30px;
    }
    .nav-item--active .nav-icon {
        background: var(--gradient-brand) !important;
    }
    .nav-label {
        font-size: 0.88rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .app-nav { background: var(--surface-color); }
}

/* Quick-add menu ("+" button): bottom sheet with one large button per record type */
.modal--sheet {
    align-items: flex-end;
}
.modal--sheet .modal-content {
    width: min(480px, 100%);
    margin: 0 auto calc(var(--nav-h) + var(--safe-bottom));
    border-radius: var(--radius-lg);
}
@media (min-width: 768px) {
    .modal--sheet {
        align-items: center;
    }
    .modal--sheet .modal-content {
        margin-bottom: auto;
        margin-top: auto;
    }
}
.quick-add-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.quick-add-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 96px;
    padding: 1rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .2s, transform .15s, box-shadow .2s;
}
.quick-add-item:hover {
    border-color: rgba(var(--primary-color-rgb), 0.45);
    box-shadow: var(--shadow);
}
.quick-add-item:active {
    transform: scale(0.97);
}
.quick-add-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    font-size: 1.5rem;
    background: var(--gradient-brand);
    box-shadow: 0 6px 16px rgba(var(--primary-color-rgb), 0.3);
}

/* Bristol type picker in the event form (optional) */
.bristol-field .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.form-optional {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.bristol-picker {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}
.bristol-option {
    --bs-zone: var(--bs-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-height: 64px;
    padding: 0.4rem 0.15rem 0.3rem;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font: inherit;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background-color .2s, transform .15s;
}
.bristol-option.bristol-item--hard { --bs-zone: var(--bs-hard); }
.bristol-option.bristol-item--soft { --bs-zone: var(--bs-soft); }
.bristol-option.bristol-item--liquid { --bs-zone: var(--bs-liquid); }
.bristol-option:active {
    transform: scale(0.95);
}
.bristol-option__icon svg {
    width: 100%;
    max-width: 44px;
    height: auto;
    display: block;
}
.bristol-option__num {
    font-size: 0.78rem;
    font-weight: 800;
}
.bristol-option.is-selected {
    border-color: var(--bs-zone);
    background: color-mix(in srgb, var(--bs-zone) 12%, var(--surface-color));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bs-zone) 18%, transparent);
    color: var(--text-primary);
}
.bristol-option:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
.form-hint {
    margin: 0.45rem 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
}
.chip--bristol {
    gap: 0.3rem;
    color: color-mix(in srgb, var(--bs-zone, var(--bs-normal)) 75%, var(--text-primary));
    background: color-mix(in srgb, var(--bs-zone, var(--bs-normal)) 14%, transparent);
}
.chip--bristol.bristol-item--normal { --bs-zone: var(--bs-normal); }
.chip--bristol.bristol-item--hard { --bs-zone: var(--bs-hard); }
.chip--bristol.bristol-item--soft { --bs-zone: var(--bs-soft); }
.chip--bristol.bristol-item--liquid { --bs-zone: var(--bs-liquid); }
.chip-bristol-icon svg,
.dist-bristol-icon svg {
    width: 24px;
    height: 16px;
    display: block;
}
.dist-bristol-icon {
    display: inline-flex;
    margin-inline-end: 0.35rem;
    vertical-align: middle;
}

/* Book card in the Discover feed: cover beside the text */
.feed-card--book {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto auto;
    column-gap: 1rem;
    align-items: start;
}
.feed-card--book > * {
    grid-column: 2;
}
.feed-card--book > .feed-kicker {
    grid-column: 1 / -1;
}
.feed-card--book > .feed-body,
.feed-card--book > .feed-link {
    grid-column: 1 / -1;
}
.feed-card--book > .feed-body {
    margin-top: 0.9rem;
}
.feed-card--book > .feed-image {
    grid-column: 1;
    grid-row: 2 / span 2;
    width: 104px;
    aspect-ratio: 2 / 3;
    margin: 0;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}
.feed-card--book > .feed-link {
    margin-top: 0.9rem;
    justify-self: start;
}
@media (max-width: 380px) {
    .feed-card--book {
        grid-template-columns: 84px minmax(0, 1fr);
        column-gap: 0.8rem;
    }
    .feed-card--book > .feed-image {
        width: 84px;
    }
}

/* First 1000 days counter on the child card */
.days1000 {
    margin: 0.25rem 0 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    background: color-mix(in srgb, var(--child-color, var(--primary-color)) 10%, var(--surface-2));
    border: 1px solid color-mix(in srgb, var(--child-color, var(--primary-color)) 22%, var(--border-color));
}
.days1000-text {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-primary);
}
.days1000-bar {
    height: 6px;
    margin-top: 0.5rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--child-color, var(--primary-color)) 18%, transparent);
    overflow: hidden;
}
.days1000-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--child-solid, var(--primary-color));
}
.days1000--done {
    padding: 0.5rem 0.9rem;
}

/* Child page: tabs (overview, evacuations, and future record types) */
.child-tabs {
    display: flex;
    flex-shrink: 0;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.4rem 0.2rem 0.7rem;
    margin: -0.2rem 0 0.4rem;
    scrollbar-width: none;
}
.child-tabs::-webkit-scrollbar {
    display: none;
}
.child-tab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 40px;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface-color);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s;
}
.child-tab.is-active {
    color: #fff;
    border-color: transparent;
    background: var(--gradient-brand);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.3);
}
.child-tab:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
.child-tab-panel .days1000 {
    margin: 0 0 1rem;
}
.overview-card {
    margin-bottom: 1rem;
}
.overview-card .stats-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.overview-list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
}
.overview-list > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border-color);
}
.overview-list > div:last-child {
    border-bottom: 0;
}
.overview-list dt {
    color: var(--text-secondary);
    font-size: 0.88rem;
}
.overview-list dd {
    margin: 0;
    font-weight: 700;
    text-align: end;
}
.overview-lines {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
    font-size: 0.92rem;
}

/* App name with the visible motto underneath */
.app-title-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}
.app-tagline {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (min-width: 768px) {
    .app-tagline {
        font-size: 0.8rem;
    }
}

/* =========================================================================
   FEEDS AND MEALS (steps 2-4)
   ========================================================================= */
/* Choice buttons (radio-like) used in the record forms */
.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.choice-group > button {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .2s, background-color .2s, color .2s;
}
.choice-group > button.is-selected {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, var(--surface-color));
    color: var(--text-primary);
}
.choice-group > button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
.form-label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.feed-timer-start {
    display: flex;
    align-items: flex-end;
}
.feed-timer-start .btn {
    width: 100%;
    min-height: 46px;
}

/* Running breastfeeding timer on the home page */
.feed-timer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--child-color, var(--primary-color)) 14%, var(--surface-color));
    border: 1px solid color-mix(in srgb, var(--child-color, var(--primary-color)) 35%, var(--border-color));
    box-shadow: var(--shadow);
}
.feed-timer[hidden] {
    display: none;
}
.feed-timer-main {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}
.feed-timer-icon {
    font-size: 1.6rem;
}
.feed-timer-text {
    display: flex;
    flex-direction: column;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.feed-timer-text strong {
    color: var(--text-primary);
}
.feed-timer-clock {
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.feed-timer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.feed-timer-cancel {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
}

/* Lines on the child card: last time and today for each kind of entry; each opens its tab */
.record-lines {
    display: grid;
    gap: 0.4rem;
}
.record-line {
    display: block;
    width: 100%;
    text-align: start;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.55rem 2rem 0.55rem 0.8rem;
    position: relative;
    cursor: pointer;
}
.record-line::after {
    content: '›';
    position: absolute;
    inset-inline-end: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
}
[dir="rtl"] .record-line::after { content: '‹'; }
.record-line:hover { border-color: var(--child-color, var(--primary-color)); }
.record-line:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.record-line-sub {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.record-lines-empty {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Tabs of the child page */
.tab-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.day-bars {
    display: grid;
    gap: 0.45rem;
}
.day-bar {
    display: grid;
    grid-template-columns: 4.5rem 1fr auto;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}
.day-bar-label {
    color: var(--text-secondary);
}
.day-bar-track {
    height: 10px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}
.day-bar-track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #ec4899;
}
.day-bar-value {
    min-width: 2.5rem;
    text-align: end;
}

/* Meal form: food picker */
.meal-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
    min-height: 1.5rem;
}
.meal-selected-chip {
    border: 0;
    cursor: pointer;
    background: color-mix(in srgb, var(--primary-color) 14%, var(--surface-color));
    color: var(--text-primary);
}
.meal-selected-chip.is-new,
.chip--new {
    background: color-mix(in srgb, #f59e0b 22%, var(--surface-color));
    color: var(--text-primary);
}
.chip--warn {
    background: color-mix(in srgb, #ef4444 16%, var(--surface-color));
    color: var(--text-primary);
}
.meal-categories {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.6rem 0.1rem;
    scrollbar-width: none;
}
.meal-categories::-webkit-scrollbar {
    display: none;
}
.meal-cat {
    border: 1px solid var(--border-color);
    cursor: pointer;
    min-height: 34px;
    background: var(--surface-color);
}
.meal-cat.is-active {
    /* Darker indigo in both themes: white text stays readable */
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.meal-food-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.4rem;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.1rem;
}
.meal-food {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-height: 56px;
    padding: 0.5rem 0.6rem;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.85rem;
    text-align: start;
    cursor: pointer;
}
.meal-food.is-selected {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, var(--surface-color));
}
.meal-food-emoji {
    font-size: 1.1rem;
}
.meal-food-name {
    font-weight: 700;
    line-height: 1.2;
}
.meal-food-allergen,
.meal-food-new {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.meal-food-new {
    color: #b45309;
}
[data-theme="dark"] .meal-food-new {
    color: #fbbf24;
}
.meal-custom {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}
.meal-custom .form-control {
    flex: 1;
}
.meal-reactions {
    border: 0;
    padding: 0;
    margin: 0 0 1rem;
}
.meal-reaction-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem;
}
.checkbox-label--compact {
    min-height: 44px;
    padding: 0.45rem 0.7rem;
    font-size: 0.88rem;
}
.meal-emergency {
    margin: 0.6rem 0 0;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    background: color-mix(in srgb, #ef4444 15%, var(--surface-color));
    border: 1px solid color-mix(in srgb, #ef4444 45%, transparent);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.88rem;
}
.meal-emergency[hidden] {
    display: none;
}

/* Meals tab: introduced foods, allergens, food and stool */
.intro-group h5 {
    margin: 0.6rem 0 0.35rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.intro-list,
.allergen-list,
.link-list,
.link-signals {
    list-style: none;
    margin: 0;
    padding: 0;
}
.intro-list li,
.allergen-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.intro-list li:last-child,
.allergen-list li:last-child {
    border-bottom: 0;
}
.intro-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}
.allergen-list li {
    justify-content: flex-start;
    align-items: center;
    color: var(--text-secondary);
}
.allergen-list li.is-done {
    color: var(--text-primary);
    font-weight: 600;
}
.allergen-list li .intro-meta {
    margin-inline-start: auto;
}
.link-item {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border-color);
}
.link-item:last-child {
    border-bottom: 0;
}
.link-signals {
    margin-top: 0.35rem;
    display: grid;
    gap: 0.25rem;
    font-size: 0.88rem;
}
.link-signals li::before {
    content: '• ';
    color: #f59e0b;
}
.link-others,
.link-disclaimer {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.link-disclaimer {
    margin-top: 0.8rem;
    font-style: italic;
}

/* Diary rows of other record types */
.agenda-kind {
    margin-inline-start: auto;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.day-records {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.day-records .agenda-event {
    width: 100%;
}
.quick-add-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 360px) {
    .quick-add-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Calendar filters: one section per kind of entry */
.filter-section-title {
    margin: 0 0 0.55rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--text-primary);
}

.filter-group--kinds .filter-checkbox {
    font-size: 0.9rem;
}

/* Feeds, meals... in the month grid: one small icon per kind */
.day-kinds {
    display: flex;
    justify-content: center;
    gap: 1px;
    margin-top: 2px;
    font-size: 0.62rem;
    line-height: 1;
}

/* ---- Steps 5-6: diapers, growth, development ---- */
/* Reminder at the bottom of every tab of the child page: a diary, not medical advice */
.tab-disclaimer {
    margin: 1rem 0 0.25rem;
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.info-note p {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.info-note p:last-child {
    margin-bottom: 0;
}

.info-note .btn {
    margin-top: 0.25rem;
}

.tab-note {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* Growth */
#growthForm {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 0.6rem;
}

#growthForm>* {
    grid-column: 1 / -1;
}

#growthForm>.form-group--third {
    grid-column: auto;
}

.growth-measures {
    margin-bottom: 0.75rem;
    max-width: 100%;
    overflow-x: auto;
}

.chart-box--growth {
    height: 280px;
}

.pct {
    display: inline-block;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-color);
    font-size: 0.78rem;
    font-weight: 700;
}

/* Teeth: dental arch with 20 milk teeth */
.teeth-chart {
    max-width: 340px;
    margin: 0 auto;
}

.teeth-chart svg {
    display: block;
    width: 100%;
    height: auto;
}

.tooth {
    cursor: pointer;
}

.tooth rect {
    fill: var(--surface-2);
    stroke: var(--text-muted);
    stroke-width: 1.5;
    transition: fill .15s, stroke .15s;
}

.tooth.is-in rect {
    fill: #c7d2fe;
    stroke: var(--primary-color);
    stroke-width: 2.5;
}

[data-theme="dark"] .tooth.is-in rect {
    fill: #818cf8;
}

.tooth:hover rect,
.tooth:focus-visible rect {
    stroke: var(--primary-color);
}

.tooth:focus {
    outline: none;
}

.tooth:focus-visible rect {
    stroke-width: 3.5;
}

.teeth-jaw-label,
.teeth-side-label {
    font-size: 10px;
    fill: var(--text-muted);
    font-family: inherit;
}

.teeth-list {
    margin-top: 0.75rem;
}

/* Milestones */
.modal .modal-body .milestone-list,
.stats-card .milestone-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.milestone-btn {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 14px;
    border: 1px dashed var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.milestone-item.is-done .milestone-btn {
    border-style: solid;
    background: var(--success-soft);
    border-color: transparent;
}

.milestone-icon {
    font-size: 1.3rem;
    width: 1.8rem;
    text-align: center;
    flex-shrink: 0;
}

.milestone-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.milestone-name {
    font-weight: 700;
}

.milestone-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.recent-item-desc--wrap {
    white-space: normal;
    line-height: 1.6;
}

.teeth-chart {
    margin-top: 0.5rem;
}

.modal .modal-body .milestone-list li {
    margin: 0;
}

/* Agenda day header: with many kinds of entries the counters wrap instead of widening the page */
.agenda-day-head {
    flex-wrap: wrap;
    row-gap: 0.3rem;
}

.agenda-day-counts {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.3rem;
    min-width: 0;
}

.agenda-events {
    min-width: 0;
}

.agenda-kind {
    flex-shrink: 0;
    white-space: nowrap;
}

.agenda-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.teeth-chart svg {
    direction: ltr;
}

/* ---- Baby on the way ---- */
.child-avatar--fruit {
    font-size: 1.7rem;
    background: color-mix(in srgb, var(--child-color) 18%, var(--surface-color));
    background-image: none;
    border: 2px dashed color-mix(in srgb, var(--child-color) 60%, transparent);
    box-shadow: none;
}

.child-card--expected {
    background-image: linear-gradient(180deg, color-mix(in srgb, var(--child-color) 9%, transparent), transparent 55%);
}

.name-tag {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.expected-chip {
    white-space: nowrap;
}

.pregnancy {
    margin: 0.25rem 0 0.75rem;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    background: color-mix(in srgb, var(--child-color, var(--primary-color)) 10%, var(--surface-2));
    border: 1px solid color-mix(in srgb, var(--child-color, var(--primary-color)) 22%, var(--border-color));
}

.pregnancy-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    font-size: 0.9rem;
}

.pregnancy-row span {
    color: var(--text-secondary);
    font-weight: 600;
}

.pregnancy-bar {
    height: 8px;
    margin: 0.55rem 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--child-color, var(--primary-color)) 18%, var(--surface-color));
    overflow: hidden;
}

.pregnancy-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--child-solid, var(--primary-color));
}

.pregnancy-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.expected-info {
    margin: 0 0 0.4rem;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.expected-note {
    margin: 0 0 0.9rem;
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.name-fruit {
    margin-top: 0.5rem;
}

.name-fruit .form-hint {
    margin-top: 0.35rem;
}

.empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
}

/* Settings: open data export and report sections */
.export-records {
    flex-direction: column;
    align-items: stretch;
}

.export-records-label {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.export-records-row {
    display: flex;
    gap: 0.5rem;
}

.export-records-row .form-control {
    flex: 1;
    min-width: 0;
}

.pdf-sections {
    grid-column: 1 / -1;
    border: 0;
    margin: 0.25rem 0 0.5rem;
    padding: 0;
    min-width: 0;
}

.pdf-sections legend {
    padding: 0;
    margin-bottom: 0.45rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Welcome screen: the two choices have the same size */
.empty-actions {
    flex-direction: column;
    align-items: center;
}

.empty-actions .btn {
    width: 100%;
    max-width: 320px;
    justify-content: center;
}

/* Old evacuation CSV backups: a small link under the JSON backup */
.legacy-csv {
    margin-top: 0.6rem;
    text-align: center;
}

.link-btn {
    padding: 0.25rem 0.4rem;
    border: 0;
    background: none;
    color: var(--primary-color);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* Demo with sample data */
.demo-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    margin: 0 auto;
    padding: 0.65rem 1rem;
    background: #fef3c7;
    color: #78350f;
    border-bottom: 1px solid #fcd34d;
    font-size: 0.85rem;
    line-height: 1.4;
}

[data-theme="dark"] .demo-banner {
    background: #422006;
    color: #fde68a;
    border-bottom-color: #92400e;
}

.demo-banner[hidden] {
    display: none;
}

.demo-banner-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Stool guide (Brussels scale) in Discover: note under the four types */
#stoolGuide .bristol-scale { grid-template-columns: repeat(4, 1fr); }
#stoolGuide .stool-guide-note { margin-top: 0.75rem !important; }

/* Health tab: vitamin D of today */
.vitd-status { font-weight: 700; margin: 0 0 0.75rem; color: var(--text-primary); }
.vitd-status.is-done { color: var(--success-text); }
.reminder-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* iPhone app (native/, class set by boot.js): behave like a native app, not a web page.
   On the site none of these rules applies. */
html.native-app,
.native-app body {
    /* No bounce of the whole page (lists inside keep theirs) */
    overscroll-behavior-y: none;
}
.native-app body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.native-app input,
.native-app textarea,
.native-app [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Site on iPhone, once the app is on the App Store: bring the diary into the app (Settings) */
.to-ios-app {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.to-ios-app h4 {
    margin: 0 0 0.25rem;
}

/* Night mode (js/night.js): dark and warm, no blue light, big buttons. Same on site and app. */
.night-toggle {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--surface-color);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.night-toggle[hidden] { display: none; }
.night-mode {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
    overflow-y: auto;
    background: #0d0906;
    color: #f0c48a;
    font-family: var(--font-family);
}
.night-mode[hidden] { display: none; }
html.night-open, html.night-open body { overflow: hidden; }
.night-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.night-head h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #c99a62;
}
.night-clock {
    text-align: center;
    font-size: clamp(3rem, 16vw, 5.5rem);
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.night-kid-name {
    margin: 0;
    text-align: center;
    font-weight: 700;
    color: #c99a62;
}
.night-kids {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.night-kid {
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid #3a2a1d;
    border-radius: 999px;
    background: transparent;
    color: #c99a62;
    font: inherit;
    font-weight: 700;
}
.night-kid.is-active {
    background: #3a2414;
    border-color: #a8612c;
    color: #f0c48a;
}
.night-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}
.night-tile {
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    border: 1px solid #3a2a1d;
    border-radius: 24px;
    background: #1c130c;
    color: #f0c48a;
    font: inherit;
    text-align: center;
}
.night-tile--button { cursor: pointer; }
.night-tile--button:active, .night-btn:active { transform: scale(0.97); }
.night-tile:disabled { opacity: 0.4; }
.night-tile--running {
    border-color: #a8612c;
    background: #2a1a0e;
}
.night-tile-icon { font-size: 2.2rem; line-height: 1; filter: saturate(0.6); }
.night-tile-label { font-size: 1.05rem; font-weight: 700; }
.night-tile-clock { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.night-tile-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
}
.night-btn {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 0.5rem 0.8rem;
    border: 1px solid #3a2a1d;
    border-radius: 14px;
    background: #2a1a0e;
    color: #f0c48a;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.night-btn--main {
    background: #6b3a16;
    border-color: #a8612c;
}
.night-btn:disabled { opacity: 0.4; }
.night-exit { flex: 0 0 auto; }
.night-status {
    margin: 0 auto;
    min-height: 2.6rem;
    text-align: center;
    color: #c99a62;
}
.night-undo {
    margin-left: 0.5rem;
    min-height: 44px;
    padding: 0 0.75rem;
    border: none;
    background: none;
    color: #f0c48a;
    font: inherit;
    font-weight: 800;
    text-decoration: underline;
    cursor: pointer;
}
.night-mode :focus-visible { outline: 2px solid #f0c48a; outline-offset: 2px; }
