.calendar-page {
    --calendar-blue: #1f4e79;
    --calendar-blue-dark: #173a5a;
    display: grid;
    gap: 28px;
}

.calendar-cover,
.calendar-month {
    background: var(--tp-card);
    border: 1px solid var(--tp-border);
    border-radius: 16px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.calendar-cover {
    padding: 0 24px 26px;
}

.calendar-title-block {
    margin: 0 -24px 24px;
    padding: 34px 24px;
    color: #fff;
    text-align: center;
    background: linear-gradient(
        rgba(23, 58, 90, 0.92),
        rgba(31, 78, 121, 0.94)
    );
}

.calendar-eyebrow {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.calendar-title-block h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(2rem, 5vw, 3.5rem);
}

.calendar-intro {
    max-width: 700px;
    margin: 10px auto 0;
    color: rgba(255, 255, 255, 0.9);
}

.calendar-form {
    display: flex;
    gap: 16px;
    align-items: end;
    justify-content: center;
    flex-wrap: wrap;
    padding: 18px;
    background: #f4f7fb;
    border: 1px solid var(--tp-border);
    border-radius: 12px;
}

.form-field {
    display: grid;
    gap: 6px;
    min-width: min(100%, 320px);
}

.form-field label {
    font-weight: 700;
}

.form-field select {
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--tp-border);
    border-radius: 8px;
    background: var(--tp-card);
    color: inherit;
    font: inherit;
}

.calendar-form button {
    min-height: 44px;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--calendar-blue);
    font-weight: 700;
    cursor: pointer;
}

.calendar-form button:hover,
.calendar-form button:focus-visible {
    background: var(--calendar-blue-dark);
}

.calendar-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin: 22px 0;
}

.summary-card {
    display: grid;
    gap: 4px;
    padding: 16px;
    text-align: center;
    background: #f6f8fb;
    border: 1px solid var(--tp-border);
    border-radius: 12px;
}

.summary-card span {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.75;
}

.summary-card strong {
    color: var(--calendar-blue);
    font-size: 1.15rem;
}

.summary-card-primary {
    background: #e2efda;
}

.calendar-information {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 22px;
}

.calendar-information h2 {
    margin-bottom: 10px;
    color: var(--calendar-blue);
    font-size: 1.15rem;
}

.calendar-rules {
    margin: 0;
    padding-left: 1.2rem;
}

.calendar-rules li + li {
    margin-top: 7px;
}

.calendar-legend {
    display: grid;
    gap: 10px;
}

.calendar-legend span {
    display: flex;
    align-items: center;
    gap: 9px;
}

.legend-swatch {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}

.today-swatch {
    background: #fff200;
    border: 3px solid #b8860b;
}

.shabbat-swatch {
    background: #fff2cc;
}

.moed-swatch {
    background: #fce4d6;
}

.intercalary-swatch {
    background: #eaf1dd;
}

.omer-swatch {
    background: #eaf2ff;
}

.month-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

.month-jump a {
    padding: 6px 10px;
    color: var(--calendar-blue);
    text-decoration: none;
    background: #f4f7fb;
    border: 1px solid var(--tp-border);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
}

.month-jump a:hover,
.month-jump a:focus-visible {
    color: #fff;
    background: var(--calendar-blue);
}

.calendar-month {
    scroll-margin-top: 20px;
}

.month-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 18px 22px;
    color: #fff;
    background: var(--calendar-blue);
}

.month-heading p,
.month-heading h2 {
    margin: 0;
    color: #fff;
}

.month-heading p {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.78;
}

.month-heading h2 {
    font-size: 1.8rem;
}

.month-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.month-meta span {
    padding: 5px 9px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    font-size: 0.8rem;
}

.calendar-scroll {
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(118px, 1fr));
    min-width: 826px;
}

.calendar-header div {
    padding: 9px 6px;
    text-align: center;
    background: #d9e1f2;
    border-right: 1px solid #aeb8c6;
    border-bottom: 1px solid #aeb8c6;
    font-size: 0.8rem;
    font-weight: 800;
}

.calendar-cell {
    position: relative;
    min-height: 128px;
    padding: 9px;
    background: #fff;
    border-right: 1px solid #c5cbd3;
    border-bottom: 1px solid #c5cbd3;
    font-size: 0.82rem;
}

.date-line {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    padding-bottom: 7px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.calendar-day {
    color: var(--calendar-blue);
    font-size: 1.15rem;
}

.date-line time {
    opacity: 0.68;
    font-size: 0.76rem;
}

.callout-list {
    display: grid;
    gap: 5px;
    margin-top: 8px;
}

.calendar-callout {
    font-weight: 750;
    line-height: 1.25;
}

.omer-count {
    display: block;
    margin-top: 7px;
    color: #345d91;
    font-size: 0.76rem;
    font-weight: 700;
}

.today-label {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 8px;
    color: #3d3000;
    background: #ffd700;
    border: 1px solid #8a6d00;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.calendar-cell.shabbat {
    background: #fff2cc;
}

.calendar-cell.omer {
    background: #eaf2ff;
}

.calendar-cell.moed {
    background: #fce4d6;
    box-shadow: inset 4px 0 0 #cf6f3e;
}

.calendar-cell.intercalary {
    background: #eaf1dd;
    box-shadow: inset 4px 0 0 #7d9b4f;
}

/*
Today is intentionally declared after all other day styles and uses
!important so it remains unmistakable even when today is also Shabbat,
a Mo'ed, an Omer day, or an intercalary day.
*/
.calendar-cell.today {
    background: #fff200 !important;
    outline: 5px solid #b8860b;
    outline-offset: -5px;
    box-shadow:
        inset 0 0 0 3px rgba(255, 255, 255, 0.85),
        0 0 16px rgba(255, 215, 0, 0.9) !important;
    z-index: 2;
}

.calendar-cell.today .calendar-day {
    color: #2d2500;
    font-size: 1.35rem;
}

.calendar-cell.today .date-line time {
    color: #2d2500;
    font-weight: 800;
    opacity: 1;
}

.calendar-cell.empty {
    background: repeating-linear-gradient(
        135deg,
        #f7f7f7,
        #f7f7f7 10px,
        #f1f1f1 10px,
        #f1f1f1 20px
    );
}

.back-to-top {
    display: block;
    padding: 10px 18px;
    text-align: right;
    color: var(--calendar-blue);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
}

@media (max-width: 900px) {
    .calendar-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .calendar-information {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .calendar-cover {
        padding-inline: 14px;
    }

    .calendar-title-block {
        margin-inline: -14px;
    }

    .calendar-summary-grid {
        grid-template-columns: 1fr;
    }

    .month-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .month-meta {
        justify-content: flex-start;
    }
}

@media print {
    .calendar-form,
    .month-jump,
    .back-to-top {
        display: none !important;
    }

    .calendar-cover,
    .calendar-month {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        break-after: page;
    }

    .calendar-scroll {
        overflow: visible;
    }

    .calendar-grid {
        min-width: 0;
        grid-template-columns: repeat(7, 1fr);
    }

    .calendar-cell {
        min-height: 105px;
    }
}


/* Moon phases */

.moon-summary-card {
    background:
        radial-gradient(
            circle at 20% 20%,
            rgba(255, 226, 125, 0.35),
            transparent 35%
        ),
        #f8f5eb;
}

.moon-summary-card strong {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.moon-summary-card strong b {
    font-size: 1.45rem;
}

.legend-moon-symbol {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    font-size: 1.05rem;
    font-style: normal;
}

.moon-phase-note {
    margin: 14px 0 0;
    color: #66717c;
    font-size: 0.76rem;
    line-height: 1.45;
}

.month-heading-right {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.month-moon-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.month-moon-summary span {
    padding: 4px 7px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.16);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

.moon-phase {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    padding: 6px 7px;
    border: 1px solid #d8dee5;
    border-radius: 8px;
    background: rgba(247, 249, 251, 0.9);
}

.moon-phase.major-moon-phase {
    border-color: #c6a34f;
    background:
        linear-gradient(
            135deg,
            rgba(255, 248, 218, 0.96),
            rgba(244, 237, 213, 0.96)
        );
    box-shadow: inset 3px 0 0 #b8860b;
}

.moon-symbol {
    flex: 0 0 auto;
    font-size: 1.35rem;
    line-height: 1;
}

.moon-details {
    display: grid;
    min-width: 0;
    line-height: 1.15;
}

.moon-details strong {
    overflow: hidden;
    color: #2f4d67;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.moon-details small {
    margin-top: 2px;
    color: #6d7780;
    font-size: 0.64rem;
}

.calendar-cell {
    min-height: 168px;
}

@media (max-width: 1100px) {
    .calendar-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .month-heading-right {
        justify-items: start;
    }

    .month-moon-summary {
        justify-content: flex-start;
    }
}

@media print {
    .moon-phase {
        padding: 3px 4px;
    }

    .moon-details small {
        display: none;
    }
}

/* =========================================================
   Calendar makeover: useful dashboard tiles + collapsible months
   ========================================================= */

.calendar-summary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.feast-summary-card {
    background: #fff4df;
}

.countdown-summary-card {
    background: #edf5ff;
}

.calendar-month-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
}

.calendar-month-controls button {
    padding: 8px 12px;
    border: 1px solid var(--tp-border);
    border-radius: 999px;
    background: #f4f7fb;
    color: var(--calendar-blue);
    font: inherit;
    font-size: .82rem;
    font-weight: 800;
    cursor: pointer;
}

.calendar-month-controls button:hover,
.calendar-month-controls button:focus-visible {
    color: #fff;
    background: var(--calendar-blue);
}

.calendar-month {
    overflow: hidden;
}

.calendar-month > summary {
    list-style: none;
    cursor: pointer;
}

.calendar-month > summary::-webkit-details-marker {
    display: none;
}

.month-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-toggle-icon {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    font-size: 1.7rem;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform .18s ease;
}

.calendar-month[open] .month-toggle-icon {
    transform: rotate(90deg);
}

.calendar-month-content {
    background: var(--tp-card);
}

.month-feast-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.month-feast-summary span {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 241, 194, .18);
    border: 1px solid rgba(255, 255, 255, .24);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
}

.calendar-month.season-spring .month-heading {
    background: linear-gradient(135deg, #426d3b, #5f8c52);
}

.calendar-month.season-summer .month-heading {
    background: linear-gradient(135deg, #8b6918, #b28a2c);
}

.calendar-month.season-fall .month-heading {
    background: linear-gradient(135deg, #85481f, #ad6531);
}

.calendar-month.season-winter .month-heading {
    background: linear-gradient(135deg, #274e70, #386b91);
}

.calendar-month:not([open]) .month-heading {
    border-radius: 15px;
}

.calendar-month[open] .month-heading {
    border-radius: 15px 15px 0 0;
}

@media (max-width: 1100px) {
    .calendar-summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

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

    .month-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .month-heading-right,
    .month-feast-summary,
    .month-moon-summary {
        justify-items: start;
        justify-content: flex-start;
    }
}

@media (max-width: 520px) {
    .calendar-summary-grid {
        grid-template-columns: 1fr;
    }

    .calendar-month-controls button {
        flex: 1 1 100%;
    }
}

@media print {
    .calendar-month {
        display: block;
    }

    .calendar-month > summary {
        break-after: avoid;
    }

    .calendar-month-content {
        display: block !important;
    }

    .calendar-month-controls {
        display: none !important;
    }
}

/* =========================================================
   Larger, more readable calendar text on phones
   ========================================================= */

@media (max-width: 760px) {
    .calendar-page {
        font-size: 18px;
        gap: 20px;
    }

    .calendar-title-block h1 {
        font-size: 2.5rem;
        line-height: 1.1;
    }

    .calendar-intro {
        font-size: 1.05rem;
        line-height: 1.5;
    }

    .calendar-eyebrow {
        font-size: 0.85rem;
    }

    .calendar-form label {
        font-size: 1rem;
    }

    .calendar-form small {
        font-size: 0.88rem;
        line-height: 1.4;
    }

    .form-field select,
    .calendar-form button {
        min-height: 50px;
        font-size: 1rem;
    }

    .summary-card {
        min-height: 125px;
        padding: 18px 16px;
        align-content: center;
    }

    .summary-card span {
        font-size: 0.88rem;
        line-height: 1.3;
    }

    .summary-card strong {
        font-size: 1.35rem;
        line-height: 1.25;
    }

    .summary-card small {
        font-size: 0.92rem;
        line-height: 1.35;
    }

    .calendar-information h2 {
        font-size: 1.35rem;
    }

    .calendar-rules,
    .calendar-legend {
        font-size: 1rem;
        line-height: 1.5;
    }

    .moon-phase-note {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .calendar-month-controls button,
    .month-jump a {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    .month-heading {
        padding: 18px;
    }

    .month-heading p {
        font-size: 0.86rem;
    }

    .month-heading h2 {
        font-size: 1.65rem;
    }

    .month-meta span,
    .month-feast-summary span,
    .month-moon-summary span {
        font-size: 0.86rem;
        line-height: 1.3;
    }

    .calendar-header div {
        padding: 11px 7px;
        font-size: 0.9rem;
    }

    .calendar-cell {
        min-height: 190px;
        padding: 11px;
        font-size: 0.96rem;
    }

    .calendar-day {
        font-size: 1.35rem;
    }

    .date-line time {
        font-size: 0.88rem;
    }

    .moon-details strong {
        font-size: 0.86rem;
    }

    .moon-details small {
        font-size: 0.78rem;
    }

    .calendar-callout {
        font-size: 0.94rem;
        line-height: 1.35;
    }

    .omer-count {
        font-size: 0.88rem;
    }

    .today-label {
        font-size: 0.78rem;
    }

    .back-to-top {
        padding: 14px 18px;
        font-size: 0.92rem;
    }
}

@media (max-width: 480px) {
    .calendar-page {
        font-size: 19px;
    }

    .calendar-title-block h1 {
        font-size: 2.25rem;
    }

    .calendar-summary-grid {
        gap: 14px;
    }

    .summary-card strong {
        font-size: 1.45rem;
    }

    /*
    The calendar remains horizontally scrollable so each day cell
    can stay large enough to read instead of being squeezed.
    */
    .calendar-grid {
        grid-template-columns: repeat(7, minmax(155px, 1fr));
        min-width: 1085px;
    }

    .calendar-cell {
        min-height: 205px;
        font-size: 1rem;
    }

    .calendar-header div {
        font-size: 0.95rem;
    }
}