@media only screen and (max-width:799px) {
    .sidetoc {
        display: none !important;
    }
    .mobilesponsor {
        margin-top: 25px;
        max-height: 40%;
        height: 40%;
        background-color: var(--bg);
        border: 1px solid var(--table-border-color);
        border-radius: 8px;
        padding: 5px;
        display: none; /*changed via JS once ad is loaded*/
        flex-direction: column;
        text-decoration: none !important;
    }
    .mobilesponsor img {
        height: auto;
        width: 40%;
        padding: 10px;        
        transition-property: all;
        transition-timing-function: cubic-bezier(.4,0,.2,1);
        transition-duration: .3s;
    }
    /* .mobilesponsor:hover img{
       width: 30%;
    } */
    .mobilesponsor .mobilesponsor-title{
        margin-top: 5px;
        margin-bottom: 5px;
        margin-left: 15px;
        margin-right: 15px;
        font-weight: 800;
        font-size: 2rem;
        color: var(--sponsor-fg);
    }
    .mobilesponsor .mobilesponsor-description{
        display:block;
        margin-top: 5px;
        margin-bottom: 15px;
        margin-left: 15px;
        margin-right: 15px;
        color: var(--sponsor-fg);        
        transition-property: all;
        transition-timing-function: cubic-bezier(.4,0,.2,1);
        transition-duration: .3s;
    }
    /* .mobilesponsor:hover .mobilesponsor-description{
        display:block;
    } */
    .mobilesponsor .mobilesponsor-cta{
        margin-top: auto;
        margin-bottom: 10px;
        margin-left: 20px;
        margin-right: 20px;
        text-align: center;
        padding: 7px;
        border-radius: 8px;
        background-color: var(--fg);
        color: var(--bg);
    }
}

@media only screen and (min-width:800px) {
    main {
        position: relative;
    }
    .sidetoc {
        width: 250px;
        margin-top: 25px;
        background-color: transparent;
        position: relative;
    }
    .sidetoc-wrapper {
        position: fixed;
        width: 250px;
        height: calc(100vh - var(--menu-bar-height)  - 50px * 2);
        overflow: auto;
        display: flex;
        flex-direction: column;
        gap:20px;
        background-color: transparent;
    }
    .pagetoc {
        max-height: 60%;
        overflow: auto;
        border-left: 1px solid color-mix(in srgb, var(--table-border-color) 70%, transparent);
        border-radius: 12px;
        background: transparent;
        box-shadow: none;
        padding: 4px 4px;
    }
    .sidesponsor {
        max-height: 40%;
        height: 40%;
        background-color: transparent;
        border: 1px solid color-mix(in srgb, var(--table-border-color) 70%, transparent);
        border-radius: 8px;
        padding: 5px;
        display: none; /*changed via JS once ad is loaded*/
        flex-direction: column;
        text-decoration: none !important;
        backdrop-filter: blur(6px);
    }
    .sidesponsor img {
        height: auto;
        width: 60%;
        padding: 10px;        
        transition-property: all;
        transition-timing-function: cubic-bezier(.4,0,.2,1);
        transition-duration: .3s;
    }
    .sidesponsor:hover img{
       width: 30%;
    }
    .sidesponsor .sponsor-title{
        margin-top: 5px;
        margin-bottom: 5px;
        margin-left: 15px;
        margin-right: 15px;
        font-weight: 800;
        font-size: 2rem;
        color: var(--sponsor-fg);
    }
    .sidesponsor .sponsor-description{
        display:none;
        margin-top: 5px;
        margin-bottom: 15px;
        margin-left: 15px;
        margin-right: 15px;
        color: var(--sponsor-fg);        
        transition-property: all;
        transition-timing-function: cubic-bezier(.4,0,.2,1);
        transition-duration: .3s;
        overflow: scroll;
    }
    .sidesponsor:hover .sponsor-description{
        display:block;

    }
    .sidesponsor .sponsor-cta{
        margin-top: auto;
        margin-bottom: 10px;
        margin-left: 20px;
        margin-right: 20px;
        text-align: center;
        padding: 7px;
        border-radius: 8px;
        background-color: var(--fg);
        color: var(--bg);
    }
    .mobilesponsor-wrapper {
        display: none !important;
    }

    .sidetoc-toggle {
        position: fixed;
        top: calc(var(--menu-bar-height) + 90px);
        width: 28px;
        height: 28px;
        border-radius: 9999px;
        border: 1px solid color-mix(in srgb, var(--sidebar-active) 50%, var(--table-border-color));
        background: color-mix(in srgb, var(--bg) 60%, transparent);
        color: var(--sidebar-active);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 12;
        transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    }
    .sidetoc-toggle .toggle-chevron {
        font-size: 12px;
        font-weight: 700;
        letter-spacing: -0.08em;
        text-shadow: 0 0 8px color-mix(in srgb, var(--sidebar-active) 60%, transparent);
    }

    .sidetoc-toggle:hover {
        background-color: color-mix(in srgb, var(--sidebar-active) 12%, transparent);
        color: var(--sidebar-active);
        transform: translateX(-2px);
    }

    html.sidetoc-hidden .sidetoc {
        width: 0;
        margin-top: 0;
    }

    html.sidetoc-hidden .sidetoc-wrapper {
        display: none;
    }

    html.sidetoc-hidden .sidetoc-toggle {
        transform: rotate(180deg);
    }

    .pagetoc a {
        border-left: none;
        color: color-mix(in srgb, var(--fg) 70%, var(--links)) !important;
        display: block;
        padding-bottom: 5px;
        padding-top: 5px;
        padding-left: 12px;
        padding-right: 12px;
        text-align: left;
        text-decoration: none;
        text-overflow: ellipsis;
        line-clamp: 2;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        border-radius: 10px;
        font-size: 1.35rem;
        transition: color 0.2s ease, background-color 0.2s ease;
    }
    .pagetoc a:hover {
        background: linear-gradient(90deg, color-mix(in srgb, var(--links) 16%, transparent), transparent);
        color: color-mix(in srgb, var(--sidebar-active) 85%, var(--fg)) !important;
    }
    .pagetoc a.active {
        background: linear-gradient(90deg, color-mix(in srgb, var(--links) 24%, transparent), transparent);
        color: var(--sidebar-active) !important;
    }
    .pagetoc .pagetoc-H2 {
        padding-left: 20px;
    }
    .pagetoc .pagetoc-H3 {
        padding-left: 40px;
    }
    .pagetoc .pagetoc-H4 {
        padding-left: 60px;
    }
    .pagetoc .pagetoc-H5 {
        display: none;
    }
    .pagetoc .pagetoc-H6 {
        display: none;
    }
}
