body {
    box-sizing : border-box;
    font-family: 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    margin     : 0;
    padding    : 20px;
    background : linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height : 100vh;
    position   : relative;
}

body::before {
    content       : '';
    position      : fixed;
    top           : 0;
    left          : 0;
    width         : 100%;
    height        : 100%;
    background    : url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="80" r="1.5" fill="rgba(255,255,255,0.1)"/></svg>');
    pointer-events: none;
    z-index       : 0;
}

.calendar-container {
    /* 預設A4比例，可由JavaScript動態調整 */
    margin             : 0 auto;
    background         : rgba(255, 255, 255, 0.95);
    backdrop-filter    : blur(20px);
    /* border-radius   : 30px; */
    box-shadow         : 0 30px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2);
    overflow           : hidden;
    position           : relative;
    z-index            : 1;
    display            : flex;
    flex-direction     : column;
    background         : #ffffff;
    background         : linear-gradient(180deg, rgba(255, 255, 255, 1) 66%, rgba(255, 235, 243, 1) 100%);
    /* 底部背景圖片 */
    background-image   : url('bg/footer.png');
    background-repeat  : no-repeat;
    background-position: bottom center;
    background-size    : contain;
    transition         : all 0.5s ease;
    /* 平滑過渡效果 */

}

.calendar-header {
    background: url('bg/PhotoshopExtension_Image.png') center/cover,
        linear-gradient(135deg, rgba(255, 107, 107, 0.8) 0%, rgba(238, 90, 36, 0.8) 50%, rgba(255, 159, 243, 0.8) 100%);
    color      : white;
    text-align : center;
    position   : relative;
    overflow   : hidden;
    flex-shrink: 0;
    min-height : 10%;
    width      : 100%;
    padding-top: 2%;
    padding-bottom: 2%;
}

.calendar-header::before {
    content   : '';
    position  : absolute;
    top       : -50%;
    left      : -50%;
    width     : 100%;
    height    : 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation : float 6s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-30%, -30%) scale(1.1);
    }
}

.header-content {
    display        : flex;
    flex-direction : column;
    align-items    : center;
    justify-content: center;
    gap            : 5px;
    position       : relative;
    z-index        : 2;
    height         : 100%;
}

.calendar-header h1 {
    margin                 : 0;
    font-size              : 2cqw;
    font-weight            : 1000;
    background             : linear-gradient(45deg, #fff, #ffeb3b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip        : text;
    animation              : shine 3s ease-in-out infinite;
}

@keyframes shine {

    0%,
    100% {
        filter: brightness(1) hue-rotate(0deg);
    }

    50% {
        filter: brightness(1.2) hue-rotate(10deg);
    }
}

.header-image {
    width        : 120px;
    height       : 120px;
    object-fit   : cover;
    border-radius: 50%;
    border       : 4px solid rgba(255, 255, 255, 0.9);
    box-shadow   : 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.1);
    transition   : transform 0.3s ease, box-shadow 0.3s ease;
    position     : relative;
    z-index      : 2;
    margin       : 5px;
}

.header-image:hover {
    transform : scale(1.1) rotate(3deg);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 0 5px rgba(255, 255, 255, 0.2);
}

.images-gallery {
    display        : flex;
    flex-wrap      : wrap;
    justify-content: center;
    align-items    : center;
    gap            : 0.6rem;
    width          : 90%;
    min-height     : 45%;
    margin         : 0 auto;
}

.gallery-image {
    width        : 7.4%;
    aspect-ratio : 1 / 1;
    object-fit   : cover;
    border-radius: 50%;
    border       : 3px solid rgba(255, 255, 255, 0.8);
    box-shadow   : 0 8px 25px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.2);
    transition   : all 0.3s ease;
    cursor       : pointer;
    opacity      : 0;
    animation    : fadeInUp 0.6s ease forwards;
}

/* gallery item wrapper and controls */
.gallery-item {
    position: relative;
    display : inline-block;
}

.gallery-controls {
    position: absolute;
    top     : 6px;
    right   : 6px;
    display : flex;
    gap     : 6px;
    z-index : 3;
}

.gallery-control-btn {
    width          : 28px;
    height         : 28px;
    border-radius  : 50%;
    background     : rgba(0, 0, 0, 0.6);
    color          : white;
    display        : flex;
    align-items    : center;
    justify-content: center;
    font-size      : 14px;
    cursor         : pointer;
    border         : none;
}

.gallery-filename {
    min-width    : 140px;
    max-width    : 320px;
    display      : inline-block;
    white-space  : nowrap;
    overflow     : hidden;
    text-overflow: ellipsis;
    text-align   : left;
    font-size    : 0.95rem;
    color        : #333;
    padding      : 8px 12px;
    background   : rgba(0, 0, 0, 0.03);
    border-radius: 8px;
}

.gallery-image:hover {
    transform   : scale(1.15) rotate(5deg);
    box-shadow  : 0 15px 40px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 1);
}

/* 模態窗口樣式 */
.modal-overlay {
    position       : fixed;
    top            : 0;
    left           : 0;
    width          : 100%;
    height         : 100%;
    background     : rgba(0, 0, 0, 0.4);
    display        : flex;
    align-items    : center;
    justify-content: center;
    z-index        : 10000;
    backdrop-filter: blur(3px);
}

.modal-content {
    background   : white;
    padding      : 40px;
    border-radius: 20px;
    box-shadow   : 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width    : 600px;
    width        : 90%;
    text-align   : center;
    font-family  : 'Microsoft JhengHei', sans-serif;
    animation    : modalSlideIn 0.3s ease-out;
    height       : calc(100% - 400px);
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8);
        opacity  : 0;
    }

    to {
        transform: scale(1);
        opacity  : 1;
    }
}

.modal-title {
    color        : #667eea;
    font-size    : 1.8rem;
    margin-bottom: 20px;
    font-weight  : bold;
}

.modal-description {
    color        : #666;
    font-size    : 1rem;
    margin-bottom: 30px;
    line-height  : 1.6;
}

.export-options {
    display              : grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap                  : 15px;
    margin-bottom        : 30px;
}

.export-option {
    background   : linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color        : white;
    border       : none;
    padding      : 20px;
    border-radius: 12px;
    cursor       : pointer;
    transition   : all 0.3s ease;
    font-size    : 1rem;
    font-weight  : 600;
    box-shadow   : 0 4px 15px rgba(102, 126, 234, 0.3);
}

.export-option:hover {
    transform : translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.export-option:active {
    transform: translateY(0);
}

.export-option .option-title {
    display      : block;
    font-size    : 1.1rem;
    margin-bottom: 8px;
}

.export-option .option-description {
    display    : block;
    font-size  : 0.85rem;
    opacity    : 0.9;
    line-height: 1.4;
}

.modal-close {
    background   : #e74c3c;
    color        : white;
    border       : none;
    padding      : 12px 30px;
    border-radius: 8px;
    cursor       : pointer;
    font-size    : 1rem;
    transition   : all 0.3s ease;
}

.modal-close:hover {
    background: #c0392b;
    transform : translateY(-1px);
}



@keyframes fadeInUp {
    from {
        opacity  : 0;
        transform: translateY(30px) scale(0.8);
    }

    to {
        opacity  : 1;
        transform: translateY(0) scale(1);
    }
}

.export-buttons {
    display        : flex;
    gap            : 15px;
    margin         : 20px auto 30px auto;
    flex-wrap      : wrap;
    justify-content: center;
    max-width      : 1400px;
    padding        : 0 20px;
}

.export-btn {
    background     : rgba(255, 255, 255, 0.9);
    border         : 2px solid rgba(102, 126, 234, 0.3);
    color          : #667eea;
    padding        : 12px 20px;
    border-radius  : 25px;
    font-size      : 0.9rem;
    font-weight    : 600;
    cursor         : pointer;
    transition     : all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow     : 0 4px 15px rgba(0, 0, 0, 0.1);
}

.export-btn:hover {
    background  : #667eea;
    border-color: #667eea;
    color       : white;
    transform   : translateY(-2px);
    box-shadow  : 0 6px 20px rgba(102, 126, 234, 0.3);
}

.export-btn:active {
    transform: translateY(0);
}

/* 印刷尺寸選擇器樣式 */
.print-size-selector,
.bg-selector {
    display        : flex;
    align-items    : center;
    gap            : 10px;
    background     : rgba(255, 255, 255, 0.95);
    border         : 2px solid rgba(102, 126, 234, 0.3);
    border-radius  : 25px;
    padding        : 8px 15px;
    backdrop-filter: blur(10px);
    box-shadow     : 0 4px 15px rgba(0, 0, 0, 0.1);
    transition     : all 0.3s ease;
}

.print-size-selector:hover {
    border-color: #667eea;
    box-shadow  : 0 6px 20px rgba(102, 126, 234, 0.3);
}

.print-size-label,
.bg-label {
    font-size  : 0.9rem;
    font-weight: 600;
    color      : #667eea;
    white-space: nowrap;
}

.print-size-dropdown,
.bg-dropdown {
    background : transparent;
    border     : none;
    font-size  : 0.9rem;
    font-weight: 600;
    color      : #667eea;
    cursor     : pointer;
    outline    : none;
    min-width  : 60px;
}

.print-size-dropdown option {
    background: white;
    color     : #333;
    padding   : 5px;
}

/* 動態容器尺寸 */
.calendar-container {
    width : 1440px;
    height: calc(1440px * 297 / 210);
}

/*.calendar-container.size-A3 {
            width: 2040px;
            height: calc(2040px * 420 / 297);
        }

            .calendar-container.size-A2 {
            width: 2880px;
            height: calc(2880px * 594 / 420); 
        }*/

.months-grid {
    display              : grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows   : repeat(4, auto);
    gap                  : 1.1rem;
    flex                 : 1;

    /* 確保12個月分4行排列，每個卡片保持4:3比例 */
    align-content: start;
}

.month-card {
    /*background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);*/
    border-radius      : 0.8cqw;
    padding            : 0.8cqw;
    box-shadow         : 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    transition         : all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position           : relative;
    overflow           : hidden;
    display            : flex;
    flex-direction     : column;
    /* 月份卡片 4          :3 比例 */
    aspect-ratio       : 1 / 1;
    /*width            : 100%;*/
    background-size    : cover;
    background-position: center;
    background-repeat  : no-repeat;
    /* 動畫相關 */
    opacity            : 0;
    transform          : translateY(50px);
    animation-fill-mode: forwards;
}

/* 淡入動畫 */
@keyframes fadeInUp {
    from {
        opacity  : 0;
        transform: translateY(50px);
    }

    to {
        opacity  : 1;
        transform: translateY(0);
    }
}

.month-card.fade-in {
    animation: fadeInUp 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.month-card::after {
    content   : '';
    position  : absolute;
    top       : 0;
    left      : 0;
    right     : 0;
    bottom    : 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(248, 249, 255, 0.85) 100%);
    z-index   : 1;
}

.month-card>* {
    position: relative;
    z-index : 2;
}

.month-card::before {
    content   : '';
    position  : absolute;
    top       : 0;
    left      : -100%;
    width     : 100%;
    height    : 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.month-card:hover {
    transform : translateY(-12px) scale(2);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    scale     : 1.05;
}

.month-card:hover::before {
    left: 100%;
}

.month-title {
    display        : flex;
    align-items    : center;
    justify-content: center;
    font-size      : 1.4rem;
    font-weight    : 700;
    color          : white;
    margin-bottom  : 6px;
    padding        : 5px;
    background     : linear-gradient(135deg, #ff740087 0%, #ff5900 100%);
    border-radius  : 6px;
    position       : relative;
    text-shadow    : 0 1px 2px rgba(0, 0, 0, 0.3);
    flex-shrink    : 0;
}

.weekdays {
    display              : grid;
    grid-template-columns: repeat(7, 1fr);
    gap                  : 1px;
    margin-bottom        : 3px;
    flex-shrink          : 0;
}

.weekday {
    text-align : center;
    font-size  : 1rem;
    font-weight: bold;
    color      : #7f8c8d;
    padding    : 3px 2px;
}

.days-grid {
    display              : grid;
    grid-template-columns: repeat(7, 1fr);
    gap                  : 0.1rem;
    flex                 : 1;
}

.day {
    /*min-height: 30px;*/
    display        : flex;
    flex-direction : column;
    align-items    : center;
    justify-content: flex-start;
    /*font-size      : 1cqw;*/
    font-weight    : 600;
    border-radius  : 4px;
    cursor         : pointer;
    transition     : all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding        : 3px 2px;
    position       : relative;
    background     : rgb(255 255 255 / 65%);
    backdrop-filter: blur(5px);
    opacity        : 0.7;
}

.day::before {
    content      : '';
    position     : absolute;
    top          : 0;
    left         : 0;
    right        : 0;
    bottom       : 0;
    border-radius: 8px;
    background   : linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    opacity      : 0;
    transition   : opacity 0.3s ease;
}

.day:hover {
    background: rgba(255, 255, 255, 0.6);
    transform : translateY(-2px) scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    opacity   : 0.9;
}

.day:hover::before {
    opacity: 1;
}

.day.other-month {
    color  : #bdc3c7;
    opacity: 0.4;
}

.day.holiday {
    background : rgba(255, 235, 238, 0.6);
    color      : #c62828;
    font-weight: bold;
    opacity    : 0.8;
}

.holiday-name {
    font-size  : 0.6rem;
    line-height: 1.1;
    text-align : center;
    margin-top : 1px;
    word-break : break-all;
    max-width  : 100%;
}

.day.sunday {
    color: #e74c3c;
}

.day.saturday {
    color: #3498db;
}

.day.empty {
    visibility: hidden;
}

.legend {
    display        : flex;
    justify-content: center;
    gap            : 30px;
    padding        : 20px;
    background     : #f8f9fa;
    border-top     : 1px solid #dee2e6;
}

.legend-item {
    display    : flex;
    align-items: center;
    gap        : 8px;
    font-size  : 0.9rem;
}

.legend-color {
    width        : 16px;
    height       : 16px;
    border-radius: 3px;
}

/* 大屏幕適配 */

.months-grid {
    grid-template-columns: repeat(3, 1fr);
    gap                  : 1cqw;
    width                : 78%;
    padding-top          : 30px;
    margin               : auto;
}

.calendar-header h1 {
    font-size: 3.5cqw;
}

.month-title {
    font-size: 1.2rem;
}

/* 列印樣式 - 300 DPI 高解析度 */
@media print {

    /* 設置300 DPI高解析度頁面 */
    @page {
        margin                    : 0;
        /* 300 DPI 設定 */
        -webkit-print-color-adjust: exact;
        print-color-adjust        : exact;
    }

    /* 隱藏不需要列印的元素 */
    .export-buttons {
        display: none !important;
    }

    /* 確保整個日曆容器適合頁面 - 300 DPI */
    body {
        background                : white !important;
        padding                   : 0 !important;
        margin                    : 0 !important;
        /* 高解析度設定 */
        -webkit-print-color-adjust: exact;
        print-color-adjust        : exact;
        image-rendering           : -webkit-optimize-contrast;
        image-rendering           : crisp-edges;
    }

    .calendar-container {
        /* 列印時使用毫米單位，響應不同尺寸 */
        transform                 : scale(1);
        transform-origin          : top left;
        image-rendering           : -webkit-optimize-contrast;
        image-rendering           : crisp-edges;
        -webkit-print-color-adjust: exact;
        print-color-adjust        : exact;
        page-break-after          : avoid;
        page-break-before         : avoid;
        orphans                   : 1;
        widows                    : 1;
    }

    .calendar-container.size-A4 {
        width : 210mm !important;
        height: 297mm !important;
    }

    .calendar-container.size-A3 {
        width : 297mm !important;
        height: 420mm !important;
    }

    .calendar-container.size-A2 {
        width : 420mm !important;
        height: 594mm !important;
    }

    /* 高解析度文字渲染 */

    .month-title {
        font-size: 1.2cqw;
    }
    
    .month-title {
        -webkit-font-smoothing : antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering         : optimizeLegibility;
    }

    .day {
        -webkit-font-smoothing : antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering         : optimizeLegibility;
        padding-top            : 0.3rem;
        font-size: 1cqw;
    }

    .weekday {
    font-size  : 1cqw;
}

    .holiday-name {
        font-size: 0.75cqw;
    }

    /* 確保圖片高解析度列印 */
    .gallery-image,
    .header-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
        image-rendering: pixelated;
        max-width      : 100%;
        height         : auto;
    }

    /* 避免分頁 */
    .content,
    .month-card,
    .months-grid {
        break-inside     : avoid;
        page-break-inside: avoid;
    }

    /* 確保背景和邊框列印 */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust        : exact;
    }
}