html, body {
    font-family: 'MS Sans Serif', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #372559; /* Background color */
    overflow: auto; /* Ensure scrolling is enabled */
}

body {
    position: relative;
    min-height: 100vh;
    box-sizing: border-box; /* Ensure padding and border are included in height calculations */
}

body::before {
    content: '';
    position: fixed; /* Keep the background fixed */
    top: 0;
    left: 50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
            to right,
            #ff00ff,
            #ff00ff 3px,
            transparent 3px,
            transparent 100px
        ),
        repeating-linear-gradient(
            to bottom,
            #ff00ff,
            #ff00ff 3px,
            transparent 3px,
            transparent 100px
        );
    background-size: 100px 100px; /* Grid cell size */
    transform: translateX(-50%) translateY(-10%) perspective(600px) rotateX(45deg); /* Center horizontally and add perspective */
    z-index: 0;
}

.window {
    width: 80%;
    max-width: 800px;
    margin: 50px auto;
    box-sizing: border-box;
    border: 2px solid #000;
    box-shadow: 5px 5px 0px #555;
    background-color: rgba(255, 255, 255, 0.8); /* Slight transparency to show grid */
    position: relative;
    z-index: 1;
}

.title-bar {
    background: #000080;
    color: #fff;
    padding: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-bar-text {
    font-weight: bold;
    padding-left: 5px;
}

.title-bar-controls button {
    background: #c0c0c0;
    border: 1px solid #fff;
    width: 16px;
    height: 16px;
    margin: 0 1px;
    font-weight: bold;
    padding: 0;
    cursor: pointer;
}

.title-bar-controls button:active {
    border-style: inset;
}

.menu-bar {
    background: #c0c0c0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px;
    border-bottom: 2px solid #000;
}

.menu-bar .menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}

.menu-bar .menu > li {
    position: relative;
}

.menu-bar .menu > li > a {
    text-decoration: none;
    color: #000;
    padding: 3px 10px;
    display: block;
}

.menu-bar .menu > li > a:hover {
    background: #000080;
    color: #fff;
}

.home-auth {
    min-height: 32px;
    display: flex;
    align-items: center;
    margin-left: auto;
}

.home-auth [hidden] {
    display: none;
}

.home-auth-loading {
    padding: 4px 8px;
    color: #555;
    font-size: 12px;
}

.home-auth-signin,
.home-auth-profile {
    color: #000;
    text-decoration: none;
}

.home-auth-signin {
    padding: 5px 10px;
    border: 2px outset #fff;
    background: #c0c0c0;
}

.home-auth-signin:hover,
.home-auth-profile:hover {
    background: #000080;
    color: #fff;
}

.home-auth-user {
    display: flex;
    align-items: center;
    gap: 6px;
}

.home-auth-profile {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 2px 7px 2px 3px;
}

.home-avatar,
.home-avatar-fallback {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    box-sizing: border-box;
    border: 1px solid #000;
}

.home-avatar {
    display: block;
    margin: 0;
    object-fit: cover;
    background: #fff;
}

.home-avatar-fallback {
    display: grid;
    place-items: center;
    background: #000080;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
}

.home-user-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
}

.home-signout {
    min-height: 28px;
    padding: 3px 8px;
    border: 2px outset #fff;
    background: #c0c0c0;
    color: #000;
    font: inherit;
    cursor: pointer;
}

.home-signout:hover {
    background: #000080;
    color: #fff;
}

.home-signout:active {
    border-style: inset;
}

.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #c0c0c0;
    border: 1px solid #000;
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: 120px;
}

.menu-bar .menu > li:hover .submenu {
    display: block;
}

.submenu li a {
    text-decoration: none;
    color: #000;
    padding: 5px 10px;
    display: block;
}

.submenu li a:hover {
    background: #000080;
    color: #fff;
}

main {
    padding: 10px;
    background: #fff;
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    box-sizing: border-box; /* Ensure padding and border are included in height calculations */
}

main h2 {
    font-size: 1.5em;
    margin: 10px 0;
}

main p {
    font-size: 1em;
    margin: 10px 0;
}

.access-note {
    padding: 7px 9px;
    border: 1px solid #808080;
    background: #ffffd8;
}

.tools {
    text-align: left;
    margin: 20px 0;
}

.tools h3 {
    font-size: 1.2em;
    margin-bottom: 10px;
}

.tools ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tools ul li {
    margin: 5px 20px 5px 0;  /* Adjust right margin to create space */
}

.tools ul li a {
    text-decoration: none;
    color: #000080;
    background: #c0c0c0;
    padding: 5px;
    display: inline-block;
    border: 2px outset #fff;
    width: 100%;
    box-sizing: border-box;
    overflow-wrap: anywhere;
}

.tools ul li a:hover {
    background: #000080;
    color: #fff;
    border: 2px inset #fff;
}

footer {
    background: #c0c0c0;
    padding: 5px;
    border-top: 2px solid #000;
    text-align: center;
}

img {
    max-width: 99%;
    height: auto;
    border: 2px solid #000;
    margin-top: 10px;
}

.tools ul li a.disabled {
    color: #a0a0a0; /* Grey text color */
    background: #e0e0e0; /* Light grey background */
    border: 2px solid #d0d0d0; /* Grey border */
    cursor: not-allowed; /* Change cursor to indicate it's not clickable */
    pointer-events: none; /* Disable clicking */
}

.disabled:hover {
    background-color: #d3d3d3; /* Ensure no change on hover */
    color: #a0a0a0; /* Ensure no change on hover */
}

@media (max-width: 640px) {
    .window {
        width: calc(100% - 24px);
        margin: 12px;
    }

    .menu-bar {
        align-items: stretch;
        flex-direction: column;
        gap: 2px;
    }

    .home-auth {
        width: 100%;
        margin-left: 0;
        border-top: 1px solid #888;
        padding-top: 2px;
    }

    .home-auth-user {
        width: 100%;
    }

    .home-auth-profile {
        flex: 1;
    }

    .home-user-name {
        max-width: calc(100vw - 180px);
    }

    .tools ul li {
        margin-right: 0;
    }
}
