:root {
    --sidebar-width: 280px;
    --primary-blue: #0969da;
    --bg-gray: #f6f8fa;
    --border-color: #d0d7de;
    --text-main: #24292f;
    --hover-bg: rgba(9, 105, 218, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--text-main);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    height: 90px; /* Allow height to grow based on two rows */
    flex-direction: column; 
    padding: 0 1rem; /* Remove header padding so rows span full width */
    display: flex;
    justify-content: space-between; /* Separates title and nav */
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
}

.header-main-row {
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 2rem 0 2rem; /* Added 4px at the top */
}

/* THE NEW NAV BAR STRIP */
.nav-bar-strip {
    width: 100%;
    background: var(--bg-gray);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color); /* Added for clear separation */
    padding: 0 3rem;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.horizontal-nav-list {
    display: flex;
    list-style: none;
    gap: 0.5rem; /* Tighter gap because buttons have internal padding */
    margin: 0;
    padding: 0;
    height: 100%; /* Take full height of parent to allow internal centering */
    align-items: center; /* Vertically centers the LI items */
}

/* The Parent Dropdown Container */
.nav-group {
    position: relative;
    display: flex;
    align-items: center; /* Centers the button inside the LI */
    height: 100%;
}

/* The Trigger Button */
.nav-dropbtn {
    background: none;
    border: none;
    padding: 0 15px;
    height: 32px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.nav-dropbtn:hover {
    background: var(--hover-bg);
    color: var(--primary-blue);
}

/* The Hidden Menu */
.dropdown-content {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 180px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    border-radius: 0 0 6px 6px;
    z-index: 2000;
    padding: 0.5rem 0;
}

/* Show menu on hover */
.nav-group:hover .dropdown-content {
    display: block;
}

/* Style for the links in the new bar */
.nav-bar-link {
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-bar-link:hover {
    background: var(--hover-bg);
    color: var(--primary-blue);
}

.nav-bar-link.active {
    color: var(--primary-blue);
    font-weight: 700;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
}

/* --- REVISE CONTAINER HEIGHT --- */
/* Adjust the math: 50px (Header Top) + 40px (Nav Strip) + 35px (Footer) = 125px */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 125px);
    flex-direction: row;
}

/* Sidebar Split Layout */
nav {
    width: var(--sidebar-width);
    background: var(--bg-gray);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.nav-section {
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

/* ToC Panel (Bottom Half) */
#toc-panel {
    height: 60%;
}

nav h4 {
    font-size: 0.7rem;
    color: #57606a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.75rem 0.5rem;
}

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

/* Nav Items */
.nav-item {
    position: relative;
    margin-bottom: 2px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--hover-bg);
    color: var(--primary-blue);
}

.nav-link.active {
    background: #fff;
    color: var(--primary-blue);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Collapse/Expand Logic Styles */
.toc-node {
    display: flex;
    align-items: center;
    width: 100%;
}

.toggle-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 3px;
    margin-right: 2px;
    color: #57606a;
}

.toggle-btn:hover {
    background: rgba(0,0,0,0.05);
}

.toggle-btn svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s;
}

/* State: Collapsed */
.collapsed .toggle-btn svg {
    transform: rotate(-90deg);
}

.collapsed .sub-nav {
    display: none;
}

.sub-nav {
    list-style: none;
    padding-left: 1rem;
    margin: 0;
}

.md-container, .pure-html-section {
    line-height: 1.6;
    max-width: 99%;
    text-align: justify;
    hyphens: auto;
}

.md-container code, .pure-html-section code {
    background: rgba(175, 184, 193, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    font-size: 85%;
}

.pure-html-section h1, 
.pure-html-section h2, 
.pure-html-section h3, 
.pure-html-section h4 {
    text-align: left;
}

.pure-html-section pre, 
.pure-html-section code {
    text-align: left;
    white-space: pre-wrap; /* Ensures long code lines wrap within the 1100px */
}

.pure-html-section img, 
.pure-html-section table {
    width: 100%;
    max-width: 1100px;
    height: auto;
}

@media (max-width: 900px) {
    .container { flex-direction: column; }
    nav { width: 100%; height: auto; border-right: none; }
    #master-panel, #toc-panel { height: auto; border-bottom: 1px solid var(--border-color); }
}

.site-logo {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary-blue);
    cursor: pointer;
    letter-spacing: -0.5px;
}

.horizontal-nav {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.horizontal-nav .nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
}

/* --- Tightening the Gutters --- */
.nav-section {
    padding: 0.75rem 0.5rem; /* Reduced from 1.5rem */
}

main { 
    flex: 1; 
    padding: 1.5rem 1rem; /* Reduced from 2.5rem 4rem */
    overflow-y: auto; 
    scroll-behavior: smooth;
    width: 100%;
    flex-grow: 1;
}

.md-container h1 {
    margin-top: 0;
    font-size: 1.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Ensure sidebar width remains consistent */
nav {
    width: 240px;
} /* Slightly narrower sidebar */

/* --- New Top Nav & Search Styles --- */
.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.dropdown-item {
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    display: block;
    color: var(--text-main);
    text-decoration: none;
}

.dropdown-item:hover {
    background: var(--hover-bg);
    color: var(--primary-blue);
}

.dropdown-item.active {
    font-weight: 700;
    color: var(--primary-blue);
}

.arrow {
    font-size: 0.6rem;
    opacity: 0.6;
}

.search-bar {
    position: relative;
}

#site-search { 
    background: var(--bg-gray);
    border: 1px solid var(--border-color); 
    padding: 6px 12px;
    border-radius: 6px;
    width: 220px;
    font-size: 0.85rem;
}

.search-results-popup {
    position: absolute;
    top: 110%; right: 0;
    background: white;
    width: 220px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 2000;
}

/* --- Repurposed Sidebar Stats --- */
.status-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.75rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    color: var(--text-main);
}

.tag-green {
    color: #1a7f37;
    background: #dafbe1;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.dynamic-title {
    margin-bottom: 0px;
    font-size: 1.75rem;
    line-height: 1.2;
    max-width: none;
}

.subtitle {
    margin-top: 5px; /* Adjust this value until the gap looks right to you */
    color: var(--text-light);
    font-size: 0.9rem;
    max-width: none;
}

/* --- Footer Styles --- */
.site-footer {
    height: 35px; /* Fixed height for the bottom bar */
    background: var(--bg-gray);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    flex-shrink: 0; /* Prevents the footer from squishing */
    z-index: 1000;
}

.footer-content {
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-credits, .footer-text {
    font-size: 0.75rem;
    color: var(--text-light);
    letter-spacing: 0.02em;
}

/* Animation for the blinking effect */
@keyframes highlight-blink {
    0% { background-color: transparent; }
    50% { background-color: #ffdf5d; } /* Highlight yellow */
    100% { background-color: transparent; }
}

/* Target the element that matches the ID in the URL */
:target {
    animation: highlight-blink 0.5s ease-in-out 3; /* Blinks 3 times */
    padding: 2px 5px;
    border-radius: 4px;
    display: inline-block;
}

.two-color-cell {
  /* Use --color1 and --color2 variables. If not provided, it defaults to gray/white */
  background: linear-gradient(
    to right, 
    var(--color1, #ccc) 0%, 
    var(--color1, #ccc) 50%, 
    var(--color2, #eee) 50%, 
    var(--color2, #eee) 100%
  );
  height: 50px; 
  width: 200px;
}

.coming-soon {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
    padding: 5px 0;
    list-style: none;
}

/* Sidebar Header/Navigation Link */
.back-nav-container {
    list-style: none; /* Removes the bullet point */
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color); /* Separates it from the sub-files */
}

.back-link {
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--primary-blue);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}

.back-link:hover {
    transform: translateX(-4px); /* Subtle nudge to the left on hover */
    color: var(--text-main);
}

#sub-library-links {
    padding-left: 0; /* Align everything to the left */
}

#sub-library-links li:not(.back-nav-container) {
    /* Keep bullets only for the actual file links if desired */
    list-style-type: disc; 
    margin-left: 1.5rem;
}

.home-btn {
    background-color: var(--primary-blue, #007bff);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
}

.home-btn:hover {
    background-color: #0056b3;
}

.home-btn:active {
    transform: scale(0.95);
}

.home-btn span {
    font-size: 1.1rem;
}