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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fff;
    overflow-x: hidden;
    width: 100%;
}

.wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
    width: 100%;
}

.header {
    background: white;
    padding: 15px 0;
    text-align: left;
}

.logo-link {
    display: inline-block;
    background: white;
    padding: 10px 20px;
}



.logo {
    display: block;
    height: 40px;
    max-height: 60px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.main-content {
    flex: 1;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.main-content > h1 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.toc-sidebar.toc-mobile {
    display: none;
}

.toc-sidebar.toc-desktop {
    width: 300px;
    position: sticky;
    top: 20px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.toc-sidebar h2 {
    font-size: 1.2em;
    margin-bottom: 15px;
    border-left: none;
    padding-left: 0;
}

.toc-sidebar ul {
    list-style: none;
    padding-left: 0;
}

.toc-sidebar li {
    padding: 10px 0;
    border-bottom: 1px solid #f1f3f4;
}

.toc-sidebar li:last-child {
    border-bottom: none;
}

.toc-sidebar a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
    display: block;
}

.toc-sidebar a:hover {
    color: #0056b3;
}

.toc-description {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 4px;
    font-weight: normal;
}

h1 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 2.2em;
}

h2 {
    color: #34495e;
    margin: 35px 0 15px 0;
    font-size: 1.5em;
    border-left: 4px solid #007bff;
    padding-left: 15px;
    scroll-margin-top: 20px;
}

h3 {
    color: #495057;
    margin: 20px 0 10px 0;
    font-size: 1.2em;
}

h4 {
    color: #5a6268;
    margin: 15px 0 8px 0;
    font-size: 1.1em;
}

.summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin: 20px 0;
}

.subtopic-section {
    margin: 30px 0;
}

.subtopic-content {
    line-height: 1.8;
    color: #444;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.subtopic-content p {
    margin: 15px 0;
    max-width: 100%;
    overflow-wrap: break-word;
}

.subtopic-content ul,
.subtopic-content ol {
    margin: 15px 0;
    padding-left: 30px;
}

.subtopic-content li {
    margin: 8px 0;
}

.subtopic-content h3 {
    margin-top: 25px;
    margin-bottom: 12px;
}

.subtopic-content h4 {
    margin-top: 20px;
    margin-bottom: 10px;
}

.faq-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin: 15px 0;
    overflow: hidden;
}

.faq-question {
    background: #e9ecef;
    padding: 15px;
    font-weight: 600;
    color: #495057;
}

.faq-answer {
    padding: 15px;
}

.care-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
}

.red-flags {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0;
}

.red-flags h2 {
    color: #721c24;
    border-left-color: #dc3545;
}

ul, ol {
    padding-left: 30px;
    margin: 15px 0;
}

li {
    margin: 8px 0;
}

/* Definition lists and cards */
dl {
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

dt {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

dd {
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

/* Ensure divs (cards) don't overflow */
.subtopic-content > div,
.subtopic-content div[style] {
    max-width: 100% !important;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 0.9em;
}

@media (max-width: 1024px) {
    .layout {
        flex-direction: column;
    }
    
    .toc-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        order: -1;
    }
}

@media (max-width: 768px) {
    .wrapper {
        padding: 10px;
        max-width: 100vw;
        overflow-x: clip;
    }
    
    .layout {
        display: flex;
        flex-direction: column;
        width: 100%;
        overflow: visible;
    }
    
    .main-content {
        padding: 15px;
        order: 1;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    h1 {
        font-size: 1.8em;
        word-wrap: break-word;
    }
    
    h2 {
        font-size: 1.3em;
        word-wrap: break-word;
    }
    
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .main-content {
        padding: 15px;
        box-shadow: none;
        border-radius: 4px;
    }
    
    .toc-sidebar.toc-desktop {
        display: none;
    }
    
    .toc-sidebar.toc-mobile {
        display: block;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 100;
        background: #e3f2fd;
        border: none;
        border-top: 1px solid #90caf9;
        border-bottom: 1px solid #90caf9;
        border-radius: 0;
        padding: 10px 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 20px;
        margin-left: -15px;
        margin-right: -15px;
        padding-left: 0;
        padding-right: 0;
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .toc-sidebar.toc-mobile::-webkit-scrollbar {
        display: none;
    }
    
    .toc-sidebar.toc-mobile h2 {
        display: none;
    }
    
    .toc-sidebar.toc-mobile ul {
        display: flex;
        flex-direction: row;
        gap: 0;
        margin: 0;
        padding: 0 20px;
        list-style: none;
    }
    
    .toc-sidebar.toc-mobile li {
        display: inline-block;
        margin: 0;
    }
    
    .toc-sidebar.toc-mobile li:not(:last-child) {
        border-right: 1px solid #90caf9;
    }
    
    .toc-sidebar.toc-mobile a {
        display: block;
        padding: 8px 16px;
        white-space: nowrap;
        font-size: 0.9em;
        color: #1565c0;
        font-weight: 500;
        text-decoration: none;
    }
    
    .toc-sidebar.toc-mobile a:hover {
        background: rgba(255, 255, 255, 0.5);
    }
    
    .toc-sidebar.toc-mobile .toc-description {
        display: none;
    }
    
    /* Additional mobile overflow fixes */
    .summary {
        padding: 15px;
        margin: 15px 0;
    }
    
    .care-section,
    .red-flags,
    .faqs {
        padding: 15px;
        margin: 15px 0;
    }
    
    .faq-question,
    .faq-answer {
        padding: 12px;
    }
    
    /* Ensure all text content wraps */
    p, li, span, div {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
}