table.calendar {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.calendar-scrollport,
.week-scrollport {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid rgba(48, 42, 30, 0.5);
    border-radius: 14px;
}

table.calendar th,
table.calendar td.exists {
    width: 14%;
    border: 1px solid;
    background-color: lightblue;
}

table.calendar tr > :first-child {
    border-left: 0;
}

table.calendar tr > :last-child {
    border-right: 0;
}

.calendar td.exists {
    position: relative;
    overflow: hidden;
    padding: 7px;
    vertical-align: top;
}

.calendar-week td.exists {
    min-height: 0;
    height: auto;
    overflow: visible;
}

.calendar-month td.exists {
    min-height: 140px;
    height: 140px;
}

.calendar td.exists.today {
    border: 3px solid;
    background-color: lightskyblue;
}

.calendar td.exists span.day {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    font-weight: 700;
}

table.calendar th.weekend {
    color: wheat;
    background-color: gray;
    font-weight: lighter;
}

.calendar-week .schedule-frame {
    margin-top: 8px;
    overflow: visible;
}

.calendar-week .schedule-canvas {
    position: relative;
    width: 100%;
    height: calc(var(--hour-count) * var(--week-hour-size));
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(70, 98, 112, 0.14) 0,
            rgba(70, 98, 112, 0.14) 1px,
            transparent 1px,
            transparent var(--week-hour-size)
        );
}

.calendar-week .schedule-bubble {
    --bubble-inset: 4%;
    --bubble-gap: 3%;
    --bubble-width: max(
        18%,
        calc(
            (
                100% - (2 * var(--bubble-inset)) -
                ((var(--bubble-lane-count) - 1) * var(--bubble-gap))
            ) / var(--bubble-lane-count)
        )
    );
    position: absolute;
    left: calc(
        var(--bubble-inset) +
        (var(--bubble-lane) * (var(--bubble-width) + var(--bubble-gap)))
    );
    width: var(--bubble-width);
    min-height: 14px;
    box-sizing: border-box;
    overflow: hidden;
    padding: 5px 7px;
    border: 1px solid rgba(48, 42, 30, 0.18);
    border-radius: 10px;
    background: #fff6d8;
    box-shadow: 0 6px 10px rgba(75, 58, 35, 0.12);
}

.calendar-week .schedule-now {
    position: absolute;
    left: calc(-1 * (var(--calendar-cell-padding) + (var(--calendar-cell-border) / 2)));
    right: calc(-1 * (var(--calendar-cell-padding) + (var(--calendar-cell-border) / 2)));
    height: 0;
    transform: translateY(var(--week-hour-size));
    border-top: 3px solid rgba(162, 76, 76, 0.72);
    z-index: 2;
    pointer-events: none;
}

.calendar-week .schedule-now::before,
.calendar-week .schedule-now::after {
    content: "";
    position: absolute;
    top: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(162, 76, 76, 0.9);
}

.calendar-week .schedule-now::before {
    left: -6px;
}

.calendar-week .schedule-now::after {
    right: -6px;
}

.calendar-week .schedule-bubble .time {
    display: block;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.calendar-week .schedule-bubble .label {
    display: block;
    margin-top: 2px;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.calendar-week .schedule-midpoint {
    position: absolute;
    top: calc(50% + var(--week-hour-size));
}

.week-scrollport {
    --calendar-cell-padding: 7px;
    --calendar-cell-border: 1px;
    --week-visible-hours: 11;
    --week-view-height: min(
        calc(44px * 10),
        calc((80vh / 14) * 10),
        calc((90vw / 24) * 10)
    );
    --week-hour-size: calc(var(--week-view-height) / var(--week-visible-hours));
    width: min(90%, 72rem);
    margin: 0 auto;
    height: var(--week-view-height);
    scrollbar-width: auto;
    scrollbar-color: rgba(130, 130, 130, 0.95) rgba(190, 190, 190, 0.95);
}

.week-scrollport::-webkit-scrollbar {
    width: 16px;
    background-color: rgba(190, 190, 190, 0.95);
}

.week-scrollport::-webkit-scrollbar-thumb {
    border: 2px solid rgba(190, 190, 190, 0.95);
    border-radius: 999px;
    background: rgba(130, 130, 130, 0.95);
}

.week-scrollport::-webkit-scrollbar-track {
    border-radius: 999px;
    background: rgba(190, 190, 190, 0.95);
}

.calendar-week th {
    position: sticky;
    top: 0;
    z-index: 1;
    box-shadow: inset 0 -1px 0 rgba(48, 42, 30, 0.9);
}

.month-events {
    margin: 2pt 0 0;
    padding-left: 0;
    font-size: 0.8em;
    list-style-type: square;
    list-style-position: inside;
}

.month-events li {
    margin: 0 0 1pt;
    white-space: nowrap;
}

.month-events .month-event-text {
    display: inline-block;
    max-width: calc(100% - 1.6em);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}

.month-events .time {
    font-weight: 700;
}

table.calendarnav,
table.calendarnav td {
    width: 100%;
    padding: 0;
    border-collapse: collapse;
}

table.calendarnav td {
    width: 34%;
}

table.calendarnav td.left {
    text-align: left;
}

table.calendarnav td.middle {
    text-align: center;
}

table.calendarnav td.right {
    text-align: right;
}

.calendarintro,
.errorbox,
.infobox {
    width: 100%;
    text-align: center;
}

.calendarintro {
    margin-bottom: 0.75rem;
}

.calendarintro div + div {
    margin-bottom: 3ex;
}

.errorbox {
    color: white;
    background-color: rgb(130, 73, 73);
}

.infobox {
    color: #333;
    background-color: #e6eef8;
}

@media (max-width: 700px) {
    .calendar-month td.exists {
        height: 7rem;
        min-height: 7rem;
        padding: 0.3rem;
    }

    .calendar-month {
        font-size: 0.8em;
    }

    .calendar-month th {
        font-size: 0.75em;
        white-space: nowrap;
    }

    .month-events li {
        white-space: normal;
    }

    .month-events .month-event-text {
        display: inline;
        max-width: none;
        overflow: visible;
        text-overflow: clip;
    }

    .calendar-week {
        min-width: 42rem;
        font-size: 0.85em;
    }

    .calendar-week .schedule-bubble {
        padding: 0.2rem 0.3rem;
    }

    .week-scrollport {
        --week-view-height: min(
            calc(28px * 10),
            calc((70vh / 14) * 10),
            calc((100vw / 14) * 10)
        );
        width: 100%;
    }
}
