.cal {
    --cal-ink: #2b2b33;
    --cal-muted: #8a8a96;
    --cal-line: rgba(43, 43, 51, .12);
    --cal-sun: #c8453f;
    --cal-sat: #3b6fb6;
    --cal-accent: #3a3f7a;
    --cal-hover: rgba(58, 63, 122, .07);
    --cal-cover: .78;

    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 900px;
    max-width: 100%;
    height: 600px;
    border-radius: 4px;
    background: #fff;
    color: var(--cal-ink);
    overflow: hidden;
    text-align: left;
    font-family: inherit;
}
.cal *, .cal *::before, .cal *::after { box-sizing: border-box; }

.cal-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-color: #fff;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.cal-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgb(255 255 255 / var(--cal-cover));
}

.cal-head,
.cal-week,
.cal-grid {
    position: relative;
    z-index: 1;
}

.cal-head {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid var(--cal-line);
    flex: none;
}
.cal-title {
    position: relative;
    margin-right: auto;
    display: flex;
    align-items: center;
}
.cal-title-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1;
    pointer-events: none;
}
.cal-select {
    position: absolute;
    inset: -8px -10px;
    width: calc(100% + 20px);
    height: calc(100% + 16px);
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
}
.cal-title:hover .cal-title-text { color: var(--cal-accent); }
.cal-title:has(.cal-select:focus-visible) {
    outline: 2px solid var(--cal-accent);
    outline-offset: 6px;
    border-radius: 4px;
}

.cal-btn {
    appearance: none;
    border: 1px solid var(--cal-line);
    background: rgba(255, 255, 255, .85);
    color: var(--cal-ink);
    height: 34px;
    min-width: 34px;
    padding: 0 12px;
    border-radius: 4px;
    font: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cal-btn:hover:not(:disabled) { background: #fff; }
.cal-btn:focus-visible { outline: 2px solid var(--cal-accent); outline-offset: 2px; }
.cal-btn:disabled { color: var(--cal-muted); cursor: default; opacity: .5; }
.cal-btn svg { width: 16px; height: 16px; display: block; }

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    flex: none;
    height: 32px;
    border-bottom: 1px solid var(--cal-line);
}
.cal-week div {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--cal-muted);
}
.cal-week div:first-child { color: var(--cal-sun); }
.cal-week div:last-child { color: var(--cal-sat); }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    flex: 1;
    min-height: 0;
}
.cal-cell {
    min-width: 0;
    min-height: 0;
    padding: 6px 6px 4px;
    border-right: 1px solid var(--cal-line);
    border-bottom: 1px solid var(--cal-line);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:nth-child(n+36):nth-child(-n+42) { border-bottom: 0; }
.cal-cell:hover { background: var(--cal-hover); }

.cal-num {
    align-self: flex-start;
    min-width: 26px;
    height: 26px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.cal-cell.is-sun .cal-num { color: var(--cal-sun); }
.cal-cell.is-sat .cal-num { color: var(--cal-sat); }
.cal-cell.is-out { background: rgba(255, 255, 255, .45); }
.cal-cell.is-out:hover { background: var(--cal-hover); }
.cal-cell.is-out .cal-num { color: var(--cal-muted); font-weight: 400; }
.cal-num.has-more { cursor: pointer; }
.cal-num.has-more:focus-visible { outline: 2px solid var(--cal-accent); outline-offset: 1px; }
.cal-cell.is-today .cal-num {
    background: var(--cal-accent);
    color: #fff;
}

.cal-events {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.cal-bday {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1px 2px;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 600;
}
.cal-bday-icon {
    width: 22px;
    height: 22px;
    border-radius: 2px;
    object-fit: cover;
    flex: none;
}
.cal-bday-label { white-space: nowrap; }
.cal-cell.has-appear .cal-bday-icon { width: 12px; height: 12px; }

.cal-appear {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 9px;
    line-height: 1.2;
    font-weight: 600;
}
.cal-appear-item { display: flex; align-items: center; gap: 3px; min-width: 0; white-space: nowrap; cursor: default; }
.cal-appear-dot {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .28);
}
.cal-appear-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.cal-pop {
    position: absolute;
    z-index: 5;
    width: max-content;
    max-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--cal-line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
}
.cal-pop[hidden] { display: none; }
.cal-pop-sec + .cal-pop-sec { margin-top: 6px; }
.cal-pop-head { display: flex; align-items: center; gap: 4px; font-weight: 700; }
.cal-pop-lines { margin-top: 3px; }
.cal-pop-icons { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.cal-pop-icon { display: block; width: 28px; height: 28px; max-width: none; border-radius: 3px; object-fit: cover; }

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    margin-top: 8px;
    font-size: 13px;
}
.cal-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }

@media (max-width: 600px) {
    .cal-head { padding: 0 10px; gap: 6px; }
    .cal-title-text { font-size: 18px; }
    .cal-btn { padding: 0 8px; }
    .cal-cell { padding: 3px 2px 2px; }
    .cal-num { font-size: 12px; min-width: 22px; height: 22px; }
    .cal-week div { font-size: 11px; }
    .cal-bday { font-size: 9px; }
    .cal-appear { font-size: 8px; }
    .cal-pop { max-width: 180px; font-size: 11px; }
    .cal-pop-icon { width: 24px; height: 24px; }
    .cal-appear-dot { width: 6px; height: 6px; }
    .cal-bday-icon { width: 16px; height: 16px; }
    .cal-cell.has-appear .cal-bday-icon { width: 10px; height: 10px; }
}

.embed-scale {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 8px 0;
    text-align: left;
}
.embed-scale input {
    width: 4.5em;
    text-align: right;
    font: inherit;
    cursor: ns-resize;
}
.embed-scale button { font: inherit; cursor: pointer; }
.embed-scale small { flex-basis: 100%; opacity: .7; }