:root {
    color-scheme: light dark;
    --mode: light-dark(light, dark);
    --light-bg: #ebebeb;
    --light-foreground: #dfdede;
    --light-text: #222222;
    --light-border: #b1b1b1;

    --dark-bg: #272729;
    --dark-foreground: #1a1a1b;
    --dark-text: #f0f0f0;
    --dark-border: #272729;
}

html,
body {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0 6px;

    background-color: light-dark(var(--light-bg), var(--dark-bg));
    color: light-dark(var(--light-text), var(--dark-text));
    font-family: "Century Gothic", CenturyGothic, AppleGothic, sans-serif;
}

header {
    width: 100%;
    padding: 1px 4px;
    align-items: center;
    display: flex;
    flex-direction: row;
    gap: 8px;
}

header h1 {
    font-size: 1.5rem;
}

header img {
    width: 1.8rem;
    height: 1.8rem;
}

header .extended {
    display: flex;
    flex-direction: row;
    gap: 16px;
    margin: 0 8px 0 auto;
}

@media (prefers-color-scheme: dark) {
    img {
        filter: invert(1);
    }
}

.calendar-wrapper {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow: none;
}

.weeks {
    display: grid;
    grid-auto-columns: 110px;
    grid-auto-rows: 26px;
    text-align: right;
    padding: 4px 0;
}

.calendar {
    width: 100%;
    min-width: 900px;
    overflow-x: scroll;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-auto-rows: 26px;

    background-color: light-dark(var(--light-foreground), var(--dark-foreground));
    border-radius: 14px;
    padding: 4px 8px;
}

.item {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 97%;
    padding: 4px;
    
    z-index: 10; 
    
    white-space: nowrap;
    box-sizing: border-box;
    text-wrap: wrap;
    text-align: center;
    overflow: hidden;
    user-select: none;

    cursor: pointer;

    opacity: 85%;

    border-radius: 4px;
}
.item.selected {
    border-width: 4px;
    border-style: solid;
    opacity: 100%;
    padding: 0;
}
.item img {
    position: absolute;
    bottom: 9px;
    right: 4px;
    width: 1rem;
    height: 1rem;
    display: none;
}
.item.selected img {
    display: block;
}

ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.calendar li {
    position: relative;
    border-right: 1px solid light-dark(var(--light-border), var(--dark-border));
    border-bottom: 1px solid light-dark(var(--light-border), var(--dark-border));
}
.calendar li.title {
    border-right: none;
    font-weight: bold;
}
.item.duplicate,
.calendar li.week-item {
    display: none;
}

.popup-container {
    position: fixed;
    display: flex;
    align-items: center;
    top: 0;
    left:0;
    width:100%;
    height: 100%;
    backdrop-filter: blur(2px);
    z-index: 20;
}

.popup-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    max-width: 90%;
    margin: auto;
    border-radius: 14px;
    background-color: light-dark(var(--light-bg), var(--dark-bg));
    z-index: 25;
    overflow: hidden;
    padding-bottom: 6px;
}

.popup-content img {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0 6px;
}

.popup-content a {
    text-decoration: none;
    text-align: center;
    color: inherit;
    padding: 6px;
    border: 1px solid light-dark(var(--light-text), var(--dark-text));
    border-radius: 8px;
}

.popup-content button {
    text-decoration: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    padding: 6px;
    border-radius: 8px;
    border-width: 1px;
    border-style: solid;
    cursor: pointer;
}

.popup-content input {
    width: 100%;
    text-decoration: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    padding: 6px;
    border-radius: 8px;
    border-width: 1px;
    border-style: solid;
}

.popup-content .content {
    box-sizing: border-box;
    margin: 4px 16px;
}

.popup-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
}

.popup-header img {
    width: 1.7rem !important;
    height: 1.7rem !important;
    cursor: pointer;
}

@media (max-width: 800px) {
    .weeks {
        display: none;
    }
    .calendar {
        grid-template-columns: auto;
        grid-auto-columns: 1fr;
        grid-auto-rows: 40px;
        min-width: 100px;
        row-gap: 4px;
    }
    .calendar li {
        border: none;
    }
    .calendar li.empty {
        display: none;
    }
    .item.duplicate,
    .calendar li.week-item,
    .calendar li.duplicate {
        display: inline-block;
    }
    .calendar li.title {
        display: none;
        border-right: none;
        font-weight: bold;
    }
    .item {
        height: 100% !important;
    }
    header .extended {
        right: 8px;
        position: fixed;
        bottom: 8px;
        z-index: 25;
        background-color: light-dark(var(--light-bg), var(--dark-bg));
        padding: 8px 24px;
        border-radius: 16px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }
    body {
        font-size: 0.8rem;
    }
    header {
        display: none;
    }
    .item:not(.selected) {
        display: none;
    }
    .item img {
        display: none !important;
    }
    .popup-container {
        display: none;
    }
}


.green {
    background-color: light-dark(#75d469, #46943c);
    border-color: light-dark(#91ee85, #62bb57);
}
.orange {
    background-color: light-dark(#da8563, #b86241);
    border-color: light-dark(#f09977, #d37a56);
}
.yellow {
    background-color: light-dark(#eee594, #a59e63);
    border-color: light-dark(#fdf5a7, #c9c288);
}
.blue {
    background-color: light-dark(#6a9ecf, #3c6994);
    border-color: light-dark(#84b9eb, #598dbe);
}
.purple {
    background-color: light-dark(#cf5bb2, #943c7e);
    border-color: light-dark(#e06cc3, #bd54a3);
}
.red {
    background-color: light-dark(#bb5952, #94423c);
    border-color: light-dark(#db736b, #c4665f);
}