* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --topnav-primary: #3b82f6;
    --topnav-primary-dark: #1d4ed8;
    --topnav-text: #475569;
    --topnav-text-secondary: #64748b;
    --topnav-bg: #f8fafc;
    --topnav-bg-secondary: #c9d0d7;
    --topnav-border: #e2e8f0;
    --topnav-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --topnav-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --color-one: #008080;
    /* Color for 1s */
    --color-zero: #0a5aaa;
    /* Color for 0s */
    --bg-control: #f4f4f4;
    --flash-success: #4d94ff;
    /* Flash color for successful actions */
    --flash-error: #ff6b6b;
    /* Flash color for failed actions */
    --shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    --main-font-size: clamp(0.8rem, 2.5vw, 3rem);
    --box-padding: 0.75rem;
    --font-mono: "IBM Plex Mono", "Source Code Pro", -apple-system, BlinkMacSystemFont, "Courier New", monospace;
    --font-nomono: "IBM Plex Sans", "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    font-family: var(--font-nomono);
    background: #e2e8f0;
    overflow-x: hidden;
}

/* Top Navigation Bar */
.topnav-container {
    background: var(--topnav-bg);
    box-shadow: var(--topnav-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.topnav-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.topnav-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--topnav-primary);
    font-variant: small-caps;
    margin: 0;
    color: #2374ff;
}

/* Desktop Menu */
.topnav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.topnav-item {
    position: relative;
}

.topnav-link {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--topnav-text);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 700;
}

.topnav-link:hover {
    background: var(--topnav-bg-secondary);
}

.topnav-link.topnav-active {
    color: var(--topnav-primary);
    background: rgba(37, 99, 235, 0.1);
}

button.topnav-link {
    cursor: pointer;
}

div.topnav-link {
    cursor: context-menu;
}

button.topnav-link:hover {
    color: var(--topnav-primary);
}

/* Dropdown */
.topnav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: var(--topnav-bg);
    border-radius: 0.5rem;
    box-shadow: var(--topnav-shadow-lg);
    border: 1px solid var(--topnav-border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    margin-top: 0.25rem;
}

.topnav-item:hover .topnav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.topnav-dropdown-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--topnav-text);
    text-decoration: none;
    transition: all 0.2s ease;
}

.topnav-dropdown-link:hover {
    background: var(--topnav-bg-secondary);
    color: var(--topnav-primary);
    padding-left: 1.25rem;
}

.topnav-dropdown-link:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.topnav-dropdown-link:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Dropdown Sections */
.topnav-section-header {
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--topnav-text-secondary);
    font-size: 0.875rem;
    border-top: 1px solid var(--topnav-border);
}

.topnav-section-header:first-child {
    border-top: none;
}

/* Learning Item (Repeatable) */
.topnav-learning-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--topnav-text);
    text-decoration: none;
    transition: all 0.2s ease;
}

.topnav-learning-item:hover {
    background: var(--topnav-bg-secondary);
    color: var(--topnav-primary);
    padding-left: 1.25rem;
}

/* Mobile Toggle */
.topnav-mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.topnav-hamburger {
    display: block;
    width: 24px;
    height: 24px;
    position: relative;
}

.topnav-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--topnav-text);
    position: absolute;
    left: 0;
    transition: all 0.3s ease;
}

.topnav-hamburger span:nth-child(1) {
    top: 6px;
}

.topnav-hamburger span:nth-child(2) {
    top: 11px;
}

.topnav-hamburger span:nth-child(3) {
    top: 16px;
}

.topnav-mobile-toggle.topnav-active .topnav-hamburger span:nth-child(1) {
    transform: rotate(45deg);
    top: 11px;
}

.topnav-mobile-toggle.topnav-active .topnav-hamburger span:nth-child(2) {
    opacity: 0;
}

.topnav-mobile-toggle.topnav-active .topnav-hamburger span:nth-child(3) {
    transform: rotate(-45deg);
    top: 11px;
}

/* Mobile Sidebar - UPDATED FOR SCROLLING */
.topnav-mobile-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;

    /* Use a combination of height properties for better mobile compatibility */
    height: 100%;
    height: 100vh;
    /* Standard approach */
    height: -webkit-fill-available;
    /* For iOS Safari */
    height: stretch;
    /* Future-proofing - newer standard */
    overflow: hidden;

    background: var(--topnav-bg);
    box-shadow: var(--topnav-shadow-lg);
    transition: right 0.3s ease;
    z-index: 1001;
    display: flex;
    /* Add flex display */
    flex-direction: column;
    /* Stack children vertically */
}

.topnav-mobile-sidebar.topnav-active {
    right: 0;
}

/* Make the mobile header sticky */
.topnav-mobile-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--topnav-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    /* Make header sticky */
    top: 0;
    /* Stick to the top */
    background: var(--topnav-bg);
    /* Ensure background color */
    z-index: 10;
    /* Keep above scrolling content */
    flex-shrink: 0;
}

.topnav-mobile-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--topnav-text);
}

.topnav-mobile-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 15;
    /* Ensure it's above other elements */
}

/* Allow the navigation content to scroll */
.topnav-mobile-nav {
    padding: 1rem;
    overflow-y: auto;
    /* Enable vertical scrolling */

    -webkit-overflow-scrolling: touch;
    /* Improve scrolling on iOS */
    flex: 1 1 auto;
    /* Ensure the container doesn't overflow its parent */
    max-height: calc(100% - 70px);
    /* Adjust based on your header height */
}

.topnav-mobile-item {
    margin-bottom: 0.25rem;
}

.topnav-mobile-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--topnav-text);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-weight: 700;
}

.topnav-mobile-link:hover {}

div.topnav-mobile-link:hover {
    cursor: context-menu;
    background: #e6e9eb;
}

a.topnav-mobile-link:hover {
    background: var(--topnav-bg-secondary);
    color: var(--topnav-primary);

}

.topnav-mobile-submenu {
    padding-left: 1.5rem;
    margin-top: 0.25rem;
}

.topnav-mobile-submenu-label {
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: #64748b;
    font-size: 0.875rem;
    cursor: context-menu;
}

.topnav-mobile-submenu-label:hover {
    background: #e6e9eb;

}

.topnav-mobile-sublink {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--topnav-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border-radius: 0.375rem;
}

.topnav-mobile-sublink:hover {
    color: var(--topnav-primary);
    background: var(--topnav-bg-secondary);
}

/* Info Overlay */
.topnav-info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.topnav-info-overlay.topnav-show {
    display: flex;
    opacity: 1;
}

.topnav-info-box {
    background: var(--topnav-bg);
    border-radius: 0.75rem;
    box-shadow: var(--topnav-shadow-lg);
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.topnav-info-overlay.topnav-show .topnav-info-box {
    transform: scale(1);
}

.topnav-info-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--topnav-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topnav-info-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--topnav-text);
}

.topnav-info-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--topnav-text-secondary);
}

.topnav-info-close:hover {
    color: var(--topnav-text);
}

.topnav-info-content {
    padding: 1.5rem;
    color: var(--topnav-text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
    text-align: left;
}

.topnav-info-content h3 {
    padding: 1rem 0rem 0.5rem 0rem;
}

.topnav-info-content p {
    padding: 0.5rem 0rem;
}

.topnav-info-content ul {
    padding-left: 3.5rem;
}

.topnav-info-content li {
    margin-bottom: 0.5rem;
}

.monotext {
    font-family: var(--font-mono);
    background-color: var(--topnav-bg-secondary);
}

.topnav-info-content .key {
    font-family: var(--font-mono);
    background-color: var(--topnav-bg-secondary);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    display: inline-block;
    min-width: 6ch;
    text-align: center;
}

.topnav-info-content a {
    color: var(--topnav-primary);
    text-decoration: none;
}

.topnav-info-content a:hover {
    text-decoration: underline;
}



/* Main Content Placeholder */
.main-content-placeholder {
    max-width: 1280px;
    margin: 1rem auto;
    /*padding: 0 1.5rem;*/
}

.content-placeholder {
    background: white;
    border-radius: 0.75rem;
    padding: 3rem;
    box-shadow: var(--topnav-shadow);
    text-align: center;
    color: var(--topnav-text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .topnav-wrapper {
        padding: 0.5rem 1.5rem;
    }

    .topnav-menu {
        display: none;
    }

    .topnav-mobile-toggle {
        display: block;
    }

    .topnav-title {
        font-size: 1.5rem;
    }

    .topnav-info-header,
    .topnav-info-content {
        padding: 0.75rem;
    }

    .topnav-info-content h3 {
        padding: 1rem 0rem 0.3rem 0rem;
    }

    .topnav-info-content p {
        padding: 0.3rem 0rem;
    }

    .topnav-info-content ul {
        padding-left: 1.5rem;
    }

    .topnav-info-content li {
        margin-bottom: 0.5rem;
    }

}