.calendar-dialog {
    box-sizing: border-box;
    width: min(1060px, calc(100% - 32px));
    max-width: none;
    max-height: 90dvh;
    margin: auto;
    padding: 24px;
    overflow-y: auto;
    border: 1px solid #fed4bf;
    border-radius: 16px;
    background: #fff;
    color: #292524;
    box-shadow: 0 24px 80px #0004;
}
.calendar-dialog[hidden], .calendar-preview [hidden] { display: none; }
.calendar-dialog::backdrop { background: #1c1917aa; }
.calendar-dialog-close {
    display: block;
    margin-left: auto;
    padding: 8px 14px;
    border: 1px solid #d6d3d1;
    border-radius: 8px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}
.calendar-dialog button:focus-visible, .calendar-event summary:focus-visible {
    outline: 3px solid #c2410c;
    outline-offset: 2px;
}
.calendar-preview { margin: 0 0 28px; }
.calendar-preview h2 { margin: 0 0 12px; font-size: 24px; font-weight: 700; }
.calendar-preview-status { margin: 0 0 20px; padding: 12px 16px; border-radius: 8px; }
.calendar-preview-loading { background: #fff7ed; color: #9a3412; }
.calendar-preview-loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 10px;
    border: 2px solid #fed7aa;
    border-top-color: #c2410c;
    border-radius: 50%;
    vertical-align: -2px;
    animation: calendar-spin 1s linear infinite;
}
.calendar-preview-ready { background: #f0fdf4; color: #166534; }
.calendar-preview-ready::before { content: '✓ '; font-weight: 700; }
.calendar-preview-empty, .calendar-preview-timeout { background: #fff7ed; color: #9a3412; }
.calendar-preview-navigation { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-preview-navigation h3 { font-size: 20px; font-weight: 600; }
.calendar-preview-navigation button {
    width: 44px;
    height: 44px;
    border: 1px solid #d6d3d1;
    border-radius: 8px;
    background: white;
    font-size: 28px;
    cursor: pointer;
}
.calendar-preview-navigation button:hover, .calendar-dialog-close:hover { background: #fff7ed; }
.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    border: 1px solid #e7e5e4;
    border-radius: 10px;
    overflow: hidden;
    background: #e7e5e4;
}
.calendar-weekday { background: #fafaf9; padding: 10px 4px; text-align: center; font-size: 12px; font-weight: 600; }
.calendar-day { min-width: 0; min-height: 112px; padding: 8px; background: white; }
.calendar-day time { display: inline-block; margin-bottom: 6px; font-size: 13px; }
.calendar-day-outside { background: #fafaf9; color: #78716c; }
.calendar-day-today time { border-radius: 50%; background: #c2410c; color: white; padding: 0 5px; }
.calendar-event { margin-bottom: 4px; padding: 4px 6px; border-radius: 4px; background: #ffedd5; color: #7c2d12; font-size: 12px; }
.calendar-event summary { overflow-wrap: anywhere; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.calendar-event summary span { font-weight: 600; }
.calendar-event p { overflow-wrap: anywhere; margin-top: 6px; }
.calendar-preview-timezone { margin-top: 10px; color: #57534e; font-size: 12px; text-align: right; }
@keyframes calendar-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .calendar-preview-loading::before { animation: none; } }
@media (max-width: 600px) {
    .calendar-dialog { width: calc(100% - 16px); padding: 12px; max-height: 94dvh; }
    .calendar-preview { position: relative; }
    .calendar-preview h2 { font-size: 20px; }
    .calendar-day { padding: 4px 2px; min-height: 88px; }
    .calendar-event { padding: 3px 2px; font-size: 10px; }
    .calendar-event summary { -webkit-line-clamp: 5; }
    .calendar-event[open] p {
        position: absolute;
        left: 0;
        right: 0;
        z-index: 1;
        padding: 12px;
        border: 1px solid #fdba74;
        border-radius: 6px;
        background: #fff7ed;
        box-shadow: 0 4px 12px #0002;
        font-size: 14px;
    }
    .calendar-dialog .calendar-link-tray { padding: 16px 4px; }
}
