* {
    box-sizing: border-box;
}

.md-callout {
    background: #f97316;
    border: 2px solid #000;
    padding: 14px 18px;
    margin: 16px 0;
    text-align: center;
    font-size: 2em;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f4f4;
    color: #222;
}

.page {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    min-height: 100vh;
}

.sidebar {
    background: #e9e9e9;
    padding: 20px;
    overflow-y: auto;
}

.sidebar h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

.content {
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 0;
}

.content-header,
.content-footer {
    background: #ddd;
    padding: 20px;
}

.content-main {
    flex: 1;
    padding: 30px 20px;
}

nav ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

nav li {
    margin: 8px 0;
}

nav li ul {
    padding-left: 20px;
    margin-top: 6px;
}

nav a,
nav button.linklike {
    color: inherit;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

nav a:hover,
nav button.linklike:hover {
    text-decoration: underline;
    opacity: 0.75;
}

nav li span {
    cursor: default;
    color: #c62828;
}

.mobile-topbar {
    display: none;
    flex-wrap: wrap;
    background: #333;
    color: white;
    padding: 12px 8px;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.mobile-topbar-logo-wrap {
    width: 100%;
    order: -1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mobile-topbar-logo {
    display: block;
    width: 100%;
    height: auto;
}

.hamburger {
    background: #555;
    color: white;
    border: none;
    padding: 10px 14px;
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
}

/* Logo visibility */
.content-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
    background: #0071bc;
}

.content-logo img {
    display: block;
    width: 100%;
    max-width: 1000px;
    height: auto;
}

/* Desktop: show wide logo, hide mobile-specific logo */
.desktop-logo {
    display: flex;
}

.mobile-logo {
    display: none;
}

@media (max-width: 900px) {
    .page {
        grid-template-columns: 1fr;
    }

    /* Keep mobile menu panels directly under the top bar when opened. */
    .content-menu {
        order: 1;
    }

    .settings-menu {
        order: 2;
    }

    .content {
        order: 3;
    }

    .mobile-topbar {
        display: flex;
    }

    .sidebar {
        display: none;
        padding-top: 10px;
    }

    .sidebar.open {
        display: block;
    }

    .content-menu {
        border-bottom: 1px solid #ccc;
    }

    .settings-menu {
        border-top: 1px solid #ccc;
        text-align: right;
    }

    .settings-menu nav ul {
        text-align: right;
    }

    .settings-menu nav li ul {
        padding-left: 0;
        padding-right: 20px;
    }

    .desktop-logo {
        display: none;
    }
}

.mermaid-hide-until-processed{
    visibility: hidden;
}
.mermaid-hide-until-processed[data-processed="true"] {
    visibility: visible;
}

/* Canon-style page layout and responsive menu behavior for page-begin.php IDs. */
#page {
    position: relative;
    display: grid;
    gap: 8px;
    grid-template-columns: 240px 1fr 240px;
    grid-template-areas:
        "topbar topbar topbar"
        "primary content secondary"
        "bottombar bottombar bottombar";
    min-height: 100vh;
}

#top-bar {
    grid-area: topbar;
}

#top-bar .desktop-logo {
    display: flex;
}

#top-bar .mobile-logo {
    display: none;
}

#primary-menu {
    grid-area: primary;
}

#content {
    grid-area: content;
}

#secondary-menu {
    grid-area: secondary;
}

#bottom-bar {
    grid-area: bottombar;
}

#menu-toggle-bar {
    display: none;
    gap: 8px;
}

#primary-menu-toggle,
#secondary-menu-toggle {
    display: none;
    width: 100%;
    cursor: pointer;
}

@media (max-width: 767px) {
    #page {
        display: flex;
        flex-direction: column;
    }

    #top-bar .desktop-logo {
        display: none;
    }

    #top-bar .mobile-logo {
        display: flex;
    }

    #menu-toggle-bar {
        display: flex;
    }

    #primary-menu-toggle,
    #secondary-menu-toggle {
        display: inline-block;
    }

    #primary-menu,
    #secondary-menu {
        display: none;
    }

    #primary-menu.is-active,
    #secondary-menu.is-active {
        display: block;
        position: fixed;
        top: var(--mobile-menu-top, 64px);
        z-index: 1000;
        width: min(92vw, 360px);
        max-height: calc(100vh - var(--mobile-menu-top, 64px) - 12px);
        overflow: auto;
        background: #fff;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
    }

    #primary-menu.is-active {
        left: 8px;
    }

    #secondary-menu.is-active {
        right: 8px;
    }
}