:root {
            --text-primary: #5f5858;
            --text-2grade: #2511e7;
            --text-3grade: #eb152b;
            --text-4grade: #de25ca; capitalize;
            --sidebar-bg: #ddf6fa;
            --selection-color: #f35e31;
        }
        body { font-family: 'Merriweather', serif; line-height: 1.6; margin: 0; padding: 0; background-color: #ffffff; border-left: 10px solid #e0e0e0; }
        .highlight { background-color: #ffeb3b; padding: 2px; border-radius: 2px; }
        .symptom-container.has-match { border-left: 3px solid #4CAF50; margin-left: -3px; }
        .page-container { max-width: 1000px; margin: 0 auto; padding: 70px 20px 20px; position: relative; z-index: 1; }
        .header { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 1000; background: white; display: flex; align-items: center; justify-content: space-between; padding: 15px 30px; border-bottom: 2px solid #e0e0e0; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 100%; max-width: 1000px; box-sizing: border-box; }
        .header::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 100%; background: white; z-index: -1; }
        .logo { height: 40px; }
        .header-text { flex: 1; margin-right: 20px; }
        .header h1 { font-family: 'Merriweather', serif; color: #2c3e50; font-weight: 700; font-size: 1.8rem; margin: 0;background: linear-gradient(45deg, #2b6cb0, #4299e1);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); }
        .selected-symptoms-count { background: var(--selection-color); color: white; padding: 8px 20px; border-radius: 20px; font-size: 0.9rem; cursor: pointer; transition: all 0.3s; display: inline-flex; align-items: center; justify-content: center; min-width: 100px; height: 36px; box-sizing: border-box; margin-right: 20px; border: none; font-family: 'Open Sans', sans-serif; }
        .selected-symptoms-count:hover { background: #3e8e41; }
        .content-wrapper { display: flex; background: white; border-radius: 8px; box-shadow: 0 2px 15px rgba(0,0,0,0.08); overflow: visible; margin-top: 20px; }
        .sidebar { width: 220px; background: var(--sidebar-bg); padding: 20px; height: calc(100vh - 90px); position: sticky; top: 90px; overflow-y: auto; transition: width 0.3s ease; }
        .sidebar h2 { font-family: 'Open Sans', sans-serif; font-size: 1.2rem; color: #2c3e50; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #e0e0e0; }
        .repertory-list { list-style: none; padding: 0; margin: 0; }
        .repertory-item { margin-bottom: 6px; }
        .repertory-link { display: block; padding: 8px 12px; color: #2c3e50; text-decoration: none; border-radius: 4px; transition: all 0.2s; font-family: 'Open Sans', sans-serif; font-size: 0.9rem; }
        .repertory-link:hover, .repertory-link.active { background: #e3f2fd; color: #1565c0; }
        .main-content { flex: 1; padding: 25px; transition: margin-left 0.3s ease; }
        .search-container { margin-bottom: 25px; padding: 0 10px; display: flex; align-items: center; }
        .search-input { width: 100%; padding: 10px 15px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 15px; font-family: 'Open Sans', sans-serif; transition: all 0.3s; }
        .search-input:focus { outline: none; border-color: #64b5f6; box-shadow: 0 0 0 2px rgba(100,181,246,0.2); }
        .chapter-header-container { display: flex; justify-content: space-between; align-items: center; margin: 25px 0 15px; }
        .chapter-header { font-size: 1.3rem; font-weight: 700; color: #2c3e50; padding-bottom: 5px; border-bottom: 2px solid #e0e0e0; margin: 0; }
        .symptom-container { position: relative; display: flex; align-items: flex-start; margin-bottom: 8px; scroll-margin-top: 10px; scroll-behavior: smooth; }
        .symptom-content { flex: 1; line-height: 1.7; padding: 0 10px; }
        .select-symptom { width: 24px; height: 24px; border: none; border-radius: 4px; background: transparent; color: transparent; font-size: 18px; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; margin-right: 12px;    margin-left: -36px; transition: all 0.2s; flex-shrink: 0; position: relative; opacity: 0; }
        .symptom-container:hover .select-symptom { background: var(--selection-color); color: white; opacity: 1; }
        .select-symptom::before { content: '+'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
        .select-symptom.selected { background: var(--selection-color); color: white; opacity: 1; }
        .select-symptom.selected::before { content: '✓'; }
        .main-symptom { 
            font-weight: bold; 
            color: var(--main-symptom-color); 
        }
        .sub-symptom { 
            margin-left: 30px; 
            color: var(--sub-symptom-color);
            font-weight: bold; 
            position: relative;
            text-indent: -20px; 
        }
        .sub-symptom::before { 
            content: "├── "; 
            position: absolute; 
            left: -10px; 
            color: #999; 
        }
        .sub-sub-symptom { 
            margin-left: 90px; 
            color: var(--sub-sub-symptom-color); 
            text-indent: -30px;
            font-style: normal; 
            position: relative; 
        }
        .sub-sub-symptom::before { 
            content: "└── "; 
            position: absolute; 
            left: -0px; 
            color: #aca9a9; 
        }
        .sub-sub-symptom-deep { 
            margin-left: 90px; 
            color: var(--sub-sub-symptom-deep-color); 
            position: relative; 
        } /* Deeper level */
        .sub-sub-symptom-deep::before { 
            content: "└── "; 
            position: absolute; 
            left: -60px; 
            color: #b3abab; 
        } /* Deeper level */
        .sub-sub-sub-symptom { 
            margin-left: 160px; 
            color: var(--sub-sub-sub-symptom-color); 
            text-indent: -38px; 
            font-style: normal; 
            position: relative; 
        } /* Added for 3rd sub-level */
        .symptoms-explanation { color: #666; font-style: italic; margin: 10px 0 20px 0; padding: 10px; background-color: #f8f9fa; border-left: 3px solid #4CAF50; border-radius: 4px; font-size: 0.95rem; }
        
        .loading{display:inline-flex;align-items:center;font-weight:600;font-family:'Open Sans',sans-serif;color:#1565c0;background:linear-gradient(90deg,#1a6fba 0%,#00f2fe 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;position:relative;font-size:1rem;}
.loading::after{content:'';width:18px;height:18px;margin-left:10px;border:3px solid rgba(0,0,0,0.1);border-top-color:#00c6ff;border-radius:50%;animation:spin 1s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}

/* Keywords section styling */
        .main-keywords {
            margin: 20px 0;
            padding: 15px;
            background-color: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 6px;
        }
        
        .main-keywords h2 {
            color: #333;
            margin-bottom: 10px;
            font-size: 1.2em;
        }
        
        .keywords-explanation {
            color: #666;
            font-style: italic;
            margin: 10px 0;
            font-size: 0.9em;
        }
        
        .keywords-container {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 10px;
        }
        
        .keyword-tag {
            display: inline-block;
            background-color: #007bff;
            color: white;
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 0.85em;
            font-weight: 500;
            text-transform: lowercase;
        }
        
        .keyword-tag:hover {
            background-color: #0056b3;
            cursor: default;
        }
        
        .no-keywords {
            color: #999;
            font-style: italic;
            margin: 0;
        }
        .sub-sub-sub-symptom::before { content: "└── "; position: absolute; left: -0px; color: #a5a0a0; } /* Added for 3rd sub-level */
        .sub-sub-sub-sub-symptom { margin-left: 220px; color: #4682b4; text-indent: -48px; font-style: normal; position: relative; } /* Added for 4th sub-level */
        .sub-sub-sub-sub-symptom::before { content: "└── "; position: absolute; left: -0px; color: #b7aeae; } /* Added for 4th sub-level */
        .sub-symptom .select-symptom, .sub-sub-symptom .select-symptom, .sub-sub-symptom-deep .select-symptom { margin-top: 2px; }
        .remedy-list { display: inline; }
        .remedy { white-space: nowrap; text-decoration: none; position: relative; }
        .remedy:hover { text-decoration: none; }
        .grade-1 { color: var(--text-primary); font-weight: normal; }
        .grade-2 { font-style: italic; color: var(--text-2grade); font-weight: 100; }
        .grade-3 { font-weight: 700; color: var(--text-3grade); }
        .grade-4 { font-weight: 700; color: var(--text-4grade); text-transform: uppercase; }
        /* Disabled custom tooltip styling for remedies to remove black background */
/* .remedy[title]:hover::after { content: attr(title); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.8); color: white; padding: 4px 8px; border-radius: 4px; font-size: 0.9em; white-space: nowrap; z-index: 1000; pointer-events: none; text-indent: 0px; } */
        .selected-symptoms-page { padding: 20px; }
        .selected-symptoms-list { margin-top: 20px; }
        .selected-symptom-item { padding: 10px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
        .remove-symptom { color: #eb152b; cursor: pointer; background: none; border: none; font-size: 1.2rem; font-weight: bold; padding: 0 8px; }
        .action-buttons { margin-top: 20px; display: flex; gap: 10px; }
        .btn { padding: 8px 15px; border-radius: 4px; border: none; cursor: pointer; font-family: 'Open Sans', sans-serif; transition: all 0.2s; }
        .btn-primary { background: #1565c0; color: white; } .btn-success { background: #659d46; color: white; }
        .btn-primary:hover { background: #0d47a1; } .btn-danger { background: #eb152b; color: white; }
        .btn-danger:hover { background: #c62828; }
        .footer { text-align: center; margin-top: 30px; padding-top: 15px; border-top: 1px solid #e0e0e0; color: #6c757d; font-size: 0.9rem; }
        .user-profile { position: relative; margin-left: 20px; }
        .profile-trigger { display: flex; align-items: center; cursor: pointer; padding: 5px 10px; border-radius: 20px; transition: background-color 0.2s; }
        .profile-trigger:hover { background-color: rgba(0,0,0,0.05); }
        .profile-picture { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; margin-right: 10px; }
        .username { font-size: 0.9rem; color: #2c3e50; margin-right: 5px; }
        .dropdown-arrow { font-size: 0.8rem; color: #666; }
        .profile-menu { position: absolute; top: 100%; right: 0; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.1); border-radius: 4px; padding: 10px; display: none; z-index: 1000; min-width: 300px; box-sizing: border-box; }
        .profile-menu.active { display: block; }
        .profile-menu-columns { display: flex; }
        .profile-menu-column { flex: 1; padding: 0 10px; width: 33.33%; }
        .profile-menu a { display: flex; align-items: center; padding: 8px 15px; color: #2c3e50; text-decoration: none; transition: background-color 0.2s; border-radius: 4px; margin-bottom: 5px; }
        .profile-menu a:hover { background-color: #f5f5f5; }
        .profile-menu a i { margin-right: 8px; width: 20px; text-align: center; color: #666; }
        .profile-menu-picture { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; margin-right: 10px; }
        .repertory-header { display: flex; align-items: center; cursor: pointer; }
        .toggle-icon { font-size: 12px; margin-right: 5px; transition: transform 0.2s; color: #666; }
        .toggle-icon.active { transform: rotate(90deg); }
        .chapter-list { list-style: none; padding-left: 20px; margin: 0; display: none; }
        .chapter-list.active { display: block; } /* Added to ensure active lists are shown by default if JS sets class */
        .chapter-item { margin: 4px 0; }
        /* Add chapter icons */
        .chapter-icon {
            margin-right: 8px;
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
        }
        
        /* Default icon for chapters without specific icons */
        .chapter-icon::before {
            content: '\f02d'; /* Default book icon */
            color: #666;
        }
        .chapter-icon.generalities::before { content: ''; background-image: url('../assets/images/chapters/generalities.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* generalities */
        .chapter-header .chapter-icon.generalities::before { content: ''; background-image: url('../assets/images/chapters/generalities.png'); background-size: 34px 34px; width: 34px; height: 34px; }  /* generalities */
        .chapter-icon.mind::before { content: ''; background-image: url('../assets/images/chapters/mind.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 40px; height: 40px; vertical-align: middle; margin-right: 5px; }  /* brain */
        
        /* Make the mind chapter icon larger in the body section */
        .chapter-header .chapter-icon.mind::before { width: 32px; height: 32px; }
        .chapter-icon.vertigo::before { content: ''; background-image: url('../assets/images/chapters/vertigo.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 40px; height: 40px; vertical-align: middle; margin-right: 5px; }  /* vertigo icon */
/* Larger icon when displayed in chapter header */
.chapter-header .chapter-icon.vertigo::before { width: 28px; height: 28px; }
        .chapter-icon.head::before { content: ''; background-image: url('../assets/images/chapters/head.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 40px; height: 40px; vertical-align: middle; margin-right: 5px; }  /* head icon */
.chapter-header .chapter-icon.head::before { width: 34px; height: 34px; }
        .chapter-icon.eye::before, .chapter-icon.eyes::before { content: ''; background-image: url('../assets/images/chapters/eye.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 40px; height: 40px; vertical-align: middle; margin-right: 5px; }  /* eye icon */
.chapter-header .chapter-icon.eye::before, .chapter-header .chapter-icon.eyes::before { width: 32px; height: 32px; }
        .chapter-icon.vision::before, .chapter-icon.visions::before {
    background-image: url('../assets/images/chapters/vision.png');
    background-size: 24px 24px;
    width: 24px;
    height: 24px;
    content: '';
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}

.chapter-icon.vision.chapter-header::before, .chapter-icon.visions.chapter-header::before {
    background-image: url('../assets/images/chapters/vision.png');
    background-size: 38px 38px;
    width: 34px;
    height: 34px;
    content: '';
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}
        .chapter-icon.ear::before, .chapter-icon.ears::before { content: ''; background-image: url('../assets/images/chapters/ear.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* ear icon */
.chapter-header .chapter-icon.ear::before, .chapter-header .chapter-icon.ears::before { width: 28px; height: 28px; }
        .chapter-icon.hearing::before, .chapter-icon.hearings::before { content: ''; background-image: url('../assets/images/chapters/hearing.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* hearing icon */
.chapter-header .chapter-icon.hearing::before, .chapter-header .chapter-icon.hearings::before { width: 28px; height: 28px; }
        .chapter-icon.nose::before, .chapter-icon.noses::before { content: ''; background-image: url('../assets/images/chapters/nose.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* nose icon */
.chapter-header .chapter-icon.nose::before, .chapter-header .chapter-icon.noses::before { width: 28px; height: 28px; }
        .chapter-icon.face::before, .chapter-icon.faces::before { content: ''; background-image: url('../assets/images/chapters/face.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 28px; height: 28px; vertical-align: middle; margin-right: 5px; }  /* face icon */
.chapter-header .chapter-icon.face::before, .chapter-header .chapter-icon.faces::before { width: 36px; height: 36px; }
        .chapter-icon.mouth::before, .chapter-icon.mouths::before { content: ''; background-image: url('../assets/images/chapters/mouth.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* mouth icon */
.chapter-header .chapter-icon.mouth::before, .chapter-header .chapter-icon.mouths::before { width: 28px; height: 28px; }
        .chapter-icon.teeth::before, .chapter-icon.teeths::before { content: ''; background-image: url('../assets/images/chapters/teeth.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* teeth icon */
.chapter-header .chapter-icon.teeth::before, .chapter-header .chapter-icon.teeths::before { width: 28px; height: 28px; }
        .chapter-icon.throat::before, .chapter-icon.throats::before { content: ''; background-image: url('../assets/images/chapters/throat.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* throat icon */
.chapter-header .chapter-icon.throat::before, .chapter-header .chapter-icon.throats::before { width: 34px; height: 34px; }
        .chapter-icon.externalthroat::before, .chapter-icon.externalthroats::before { content: ''; background-image: url('../assets/images/chapters/externalthroat.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }
.chapter-header .chapter-icon.externalthroat::before, .chapter-header .chapter-icon.externalthroats::before { width: 28px; height: 28px; }
        .chapter-icon.stomach::before, .chapter-icon.stomachs::before { content: ''; background-image: url('../assets/images/chapters/stomach.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* stomach */
        .chapter-header .chapter-icon.stomach::before, .chapter-header .chapter-icon.stomachs::before { width: 34px; height: 34px; }
        .chapter-icon.abdomen::before, .chapter-icon.abdomens::before { content: ''; background-image: url('../assets/images/chapters/abdomen.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* abdomen */
        .chapter-header .chapter-icon.abdomen::before, .chapter-header .chapter-icon.abdomens::before { width: 34px; height: 34px; }  /* abdomen */
        .chapter-icon.rectum::before, .chapter-icon.rectums::before { content: ''; background-image: url('../assets/images/chapters/rectum.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* rectum */
        .chapter-header .chapter-icon.rectum::before, .chapter-header .chapter-icon.rectums::before { width: 30px; height: 30px; }  /* rectum */
        .chapter-icon.stool::before, .chapter-icon.stools::before { content: ''; background-image: url('../assets/images/chapters/stool.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* stool */
        .chapter-header .chapter-icon.stool::before, .chapter-header .chapter-icon.stools::before { width: 30px; height: 30px; }  /* stool */
        .chapter-icon.urinary::before { content: '\f7f5'; color: #F1C40F; }  /* urinary */
        .chapter-icon.urine::before, .chapter-icon.urines::before { content: ''; background-image: url('../assets/images/chapters/urine.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* urine icon */
.chapter-header .chapter-icon.urine::before, .chapter-header .chapter-icon.urines::before { width: 28px; height: 28px; }
        .chapter-icon.male::before, .chapter-icon.males::before, .chapter-icon.genitaliamale::before, .chapter-icon.genitaliamales::before, .chapter-icon.malesexualsystem::before, .chapter-icon.malesexualsystems::before { content: ''; background-image: url('../assets/images/chapters/male genitalia.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* male icon */
.chapter-header .chapter-icon.male::before, .chapter-header .chapter-icon.males::before, .chapter-header .chapter-icon.genitaliamale::before, .chapter-header .chapter-icon.genitaliamales::before, .chapter-header .chapter-icon.malesexualsystem::before, .chapter-header .chapter-icon.malesexualsystems::before { width: 34px; height: 34px; }
        .chapter-icon.female::before, .chapter-icon.females::before, .chapter-icon.femalegenitalia::before, .chapter-icon.femalegenitalias::before, .chapter-icon.genitaliafemal::before, .chapter-icon.genitaliafemale::before, .chapter-icon.genitaliafemales::before, .chapter-icon.femalesexualsystem::before, .chapter-icon.femalesexualsystems::before { content: ''; background-image: url('../assets/images/chapters/femalegenitalia.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }
.chapter-header .chapter-icon.female::before, .chapter-header .chapter-icon.females::before, .chapter-header .chapter-icon.femalegenitalia::before, .chapter-header .chapter-icon.femalegenitalias::before, .chapter-header .chapter-icon.genitaliafemal::before, .chapter-header .chapter-icon.genitaliafemale::before, .chapter-header .chapter-icon.genitaliafemales::before, .chapter-header .chapter-icon.femalesexualsystem::before, .chapter-header .chapter-icon.femalesexualsystems::before { width: 34px; height: 34px; }  /* female */
        .chapter-icon.larynx::before, .chapter-icon.larynxandtrachea::before, .chapter-icon.larynxtrachea::before { content: ''; background-image: url('../assets/images/chapters/larynxtrachea.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* larynx and trachea */
.chapter-header .chapter-icon.larynx::before, .chapter-header .chapter-icon.larynxandtrachea::before, .chapter-header .chapter-icon.larynxtrachea::before { width: 34px; height: 34px; }
        .chapter-icon.respiration::before, .chapter-icon.respirations::before, .chapter-icon.respiratorysystem::before, .chapter-icon.respiratorysystems::before { content: ''; background-image: url('../assets/images/chapters/respiration.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* respiration */
.chapter-header .chapter-icon.respiration::before, .chapter-header .chapter-icon.respirations::before, .chapter-header .chapter-icon.respiratorysystem::before, .chapter-header .chapter-icon.respiratorysystems::before { width: 34px; height: 34px; }
        .chapter-icon.cough::before, .chapter-icon.coughs::before { content: ''; background-image: url('../assets/images/chapters/cough.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* cough */
.chapter-header .chapter-icon.cough::before, .chapter-header .chapter-icon.coughs::before { width: 34px; height: 34px; }
        .chapter-icon.expectoration::before, .chapter-icon.expectorations::before { content: ''; background-image: url('../assets/images/chapters/expectoration.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* expectoration */
.chapter-header .chapter-icon.expectoration::before, .chapter-header .chapter-icon.expectorations::before { width: 34px; height: 34px; }
        .chapter-icon.chest::before, .chapter-icon.chests::before { content: ''; background-image: url('../assets/images/chapters/chest.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* chest */
.chapter-header .chapter-icon.chest::before, .chapter-header .chapter-icon.chests::before { width: 34px; height: 34px; }
        .chapter-icon.back::before, .chapter-icon.backs::before { content: ''; background-image: url('../assets/images/chapters/back.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 22px; height: 22px; vertical-align: middle; margin-right: 5px; }  /* back */
.chapter-header .chapter-icon.back::before, .chapter-header .chapter-icon.backs::before { width: 34px; height: 34px; }
        .chapter-icon.extremities::before, .chapter-icon.extremitiess::before, .chapter-icon.locomotorsystem::before, .chapter-icon.locomotorsystems::before { content: ''; background-image: url('../assets/images/chapters/exstremities.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* extremities and locomotor system */
.chapter-header .chapter-icon.extremities::before, .chapter-header .chapter-icon.extremitiess::before, .chapter-header .chapter-icon.locomotorsystem::before, .chapter-header .chapter-icon.locomotorsystems::before { width: 38px; height: 38px; }
        .chapter-icon.sleep::before, .chapter-icon.sleeps::before { content: ''; background-image: url('../assets/images/chapters/sleep.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* sleep */
.chapter-header .chapter-icon.sleep::before, .chapter-header .chapter-icon.sleeps::before { width: 38px; height: 38px; }
        .chapter-icon.chill::before, .chapter-icon.chills::before { content: ''; background-image: url('../assets/images/chapters/chill.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* chill */
.chapter-header .chapter-icon.chill::before, .chapter-header .chapter-icon.chills::before { width: 34px; height: 34px; }
        .chapter-icon.fever::before, .chapter-icon.fevers::before { content: ''; background-image: url('../assets/images/chapters/fever.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* fever */
.chapter-header .chapter-icon.fever::before, .chapter-header .chapter-icon.fevers::before { width: 34px; height: 34px; }
        .chapter-icon.perspiration::before, .chapter-icon.perspirations::before { content: ''; background-image: url('../assets/images/chapters/perspiration.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* perspiration */
.chapter-header .chapter-icon.perspiration::before, .chapter-header .chapter-icon.perspirations::before { width: 38px; height: 38px; }
        .chapter-icon.skin::before, .chapter-icon.skins::before { content: ''; background-image: url('../assets/images/chapters/skin.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* skin */
.chapter-header .chapter-icon.skin::before, .chapter-header .chapter-icon.skins::before { width: 34px; height: 34px; }
        .chapter-icon.abdomen::before, .chapter-icon.abdomens::before { content: ''; background-image: url('../assets/images/chapters/abdomen.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 24px; height: 24px; vertical-align: middle; margin-right: 5px; }  /* abdomen */
.chapter-header .chapter-icon.abdomen::before, .chapter-header .chapter-icon.abdomens::before { width: 34px; height: 34px; }
        /* nervous system icon */
        .chapter-icon.nervoussystem::before, .chapter-icon.nervoussystems::before {
            content: '';
            background-image: url('../assets/images/chapters/nervoussystem.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-header .chapter-icon.nervoussystem::before, .chapter-header .chapter-icon.nervoussystems::before {
            width: 34px;
            height: 34px;
        }
        /* Additional selectors without hyphens for urinary chapters */
        .chapter-icon.urinaryorgans::before, .chapter-icon.urinaryorganss::before {
            background-image: url('../assets/images/chapters/urinary organs.png');
            background-size: 24px 24px;
            width: 24px;
            height: 24px;
            content: '';
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
        }
        
        .chapter-icon.urinaryorgans.chapter-header::before, .chapter-icon.urinaryorganss.chapter-header::before {
            background-image: url('../assets/images/chapters/urinary organs.png');
            background-size: 38px 38px;
            width: 38px;
            height: 38px;
            content: '';
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
        }
        
        .chapter-icon.urinarysystem::before, .chapter-icon.urinarysystems::before {
            background-image: url('../assets/images/chapters/urinary organs.png');
            background-size: 24px 24px;
            width: 24px;
            height: 24px;
            content: '';
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
        }
        
        .chapter-icon.urinarysystem.chapter-header::before, .chapter-icon.urinarysystems.chapter-header::before {
            background-image: url('../assets/images/chapters/urinary organs.png');
            background-size: 34px 34px;
            width: 38px;
            height: 38px;
            content: '';
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-icon.thirst::before { content: '\f6c1'; color: #3498DB; }  /* glass-water */
        .chapter-icon.appetite::before { content: '\f2e7'; color: #E67E22; }  /* utensils */
        .chapter-icon.nausea::before { content: '\f7f2'; color: #8E44AD; }  /* head-side-mask */
        .chapter-icon.vomiting::before { content: '\f54c'; color: #C0392B; }  /* sink */
        .chapter-icon.epigastrium::before { content: '\f5e4'; color: #D35400; }  /* stomach */
        .chapter-icon.hypochondria::before { content: '\f604'; color: #27AE60; }  /* users-medical */
        .chapter-icon.kidney::before, .chapter-icon.kidneys::before { content: ''; background-image: url('../assets/images/chapters/kidney.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* kidney */
        .chapter-header .chapter-icon.kidney::before, .chapter-header .chapter-icon.kidneys::before { width: 34px; height: 34px; }  /* kidney */
        .chapter-icon.bladder::before, .chapter-icon.bladders::before { content: ''; background-image: url('../assets/images/chapters/bladder.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* bladder */
        .chapter-header .chapter-icon.bladder::before, .chapter-header .chapter-icon.bladders::before { width: 34px; height: 34px; }  /* bladder */
         .chapter-icon.prostate::before, .chapter-icon.prostates::before, .chapter-icon.prostategland::before, .chapter-icon.prostateglands::before { content: ''; background-image: url('../assets/images/chapters/prostate.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* prostate */
        .chapter-header .chapter-icon.prostate::before, .chapter-header .chapter-icon.prostates::before { width: 34px; height: 34px; }  /* prostate */
         .chapter-icon.urethra::before, .chapter-icon.urethras::before { content: ''; background-image: url('../assets/images/chapters/urethra.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* urethra icon */
 .chapter-header .chapter-icon.urethra::before, .chapter-header .chapter-icon.urethras::before { width: 28px; height: 28px; }  /* urethra */
        
        /* tongue icon */
        .chapter-icon.tongue::before, .chapter-icon.tongues::before {
            content: '';
            background-image: url('../assets/images/chapters/tongue.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-header .chapter-icon.tongue::before, .chapter-header .chapter-icon.tongues::before {
            width: 28px;
            height: 28px;
        }
        /* taste icon */
        .chapter-icon.taste::before, .chapter-icon.tastes::before {
            content: '';
            background-image: url('../assets/images/chapters/taste.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-header .chapter-icon.taste::before, .chapter-header .chapter-icon.tastes::before {
            width: 28px;
            height: 28px;
        }
        /* gums icon */
        .chapter-icon.gum::before, .chapter-icon.gums::before {
            content: '';
            background-image: url('../assets/images/chapters/gums.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-header .chapter-icon.gum::before, .chapter-header .chapter-icon.gums::before {
            width: 28px;
            height: 28px;
        }
        /* modalities icon */
        .chapter-icon.modality::before, .chapter-icon.modalities::before {
            content: '';
            background-image: url('../assets/images/chapters/modalities.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-header .chapter-icon.modality::before, .chapter-header .chapter-icon.modalities::before {
            width: 28px;
            height: 28px;
        }
        /* Boericke repertory icon (repertory id assumed 2) */
        .sidebar .repertory-link[href*="repertory=2"] i {
            display: none; /* hide default fontawesome icon */
        }
        .sidebar .repertory-link[href*="repertory=2"]::before {
            content: '';
            background-image: url('../assets/images/chapters/boericke.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 45px;
            height: 45px;
            vertical-align: middle;
            margin-right: 5px;
        }
        /* Kent repertory icon (repertory id assumed 1) */
        .sidebar .repertory-link[href*="repertory=1"] i {
            display: none;
        }
        .sidebar .repertory-link[href*="repertory=1"]::before {
            content: '';
            background-image: url('../assets/images/chapters/kent.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 45px;
            height: 45px;
            vertical-align: middle;
            margin-right: 5px;
        }
        /* Pathak repertory icon (repertory id assumed 3) */
        .sidebar .repertory-link[href*="repertory=3"] i {
            display: none;
        }
        .sidebar .repertory-link[href*="repertory=4"] i {
            display: none;
        }
        .sidebar .repertory-link[href*="repertory=4"]::before {
            content: '';
            background-image: url('../assets/images/chapters/pathak.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 45px;
            height: 45px;
            vertical-align: middle;
            margin-right: 5px;
        }
        /* Boeger's Key repertory icon */
        .sidebar .repertory-link.boeger-repertory i {
            display: none;
        }
        .sidebar .repertory-link.boeger-repertory::before {
            content: '';
            background-image: url('../assets/images/chapters/cmboger.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 45px;
            height: 45px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-icon.thirst::before { content: '\f6c1'; color: #3498DB; }  /* glass-water */
        .chapter-icon.appetite::before { content: '\f2e7'; color: #E67E22; }  /* utensils */
        .chapter-icon.nausea::before { content: '\f7f2'; color: #8E44AD; }  /* head-side-mask */
        .chapter-icon.vomiting::before { content: '\f54c'; color: #C0392B; }  /* sink */
        .chapter-icon.epigastrium::before { content: '\f5e4'; color: #D35400; }  /* stomach */
        .chapter-icon.hypochondria::before { content: '\f604'; color: #27AE60; }  /* users-medical */
        .chapter-icon.kidney::before, .chapter-icon.kidneys::before { content: ''; background-image: url('../assets/images/chapters/kidney.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* kidney */
        .chapter-header .chapter-icon.kidney::before, .chapter-header .chapter-icon.kidneys::before { width: 34px; height: 34px; }  /* kidney */
        .chapter-icon.bladder::before, .chapter-icon.bladders::before { content: ''; background-image: url('../assets/images/chapters/bladder.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* bladder */
        .chapter-header .chapter-icon.bladder::before, .chapter-header .chapter-icon.bladders::before { width: 34px; height: 34px; }  /* bladder */
         .chapter-icon.prostate::before, .chapter-icon.prostates::before, .chapter-icon.prostategland::before, .chapter-icon.prostateglands::before { content: ''; background-image: url('../assets/images/chapters/prostate.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* prostate */
        .chapter-header .chapter-icon.prostate::before, .chapter-header .chapter-icon.prostates::before { width: 34px; height: 34px; }  /* prostate */
         .chapter-icon.urethra::before, .chapter-icon.urethras::before { content: ''; background-image: url('../assets/images/chapters/urethra.png'); background-size: contain; background-repeat: no-repeat; background-position: center; display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 5px; }  /* urethra icon */
 .chapter-header .chapter-icon.urethra::before, .chapter-header .chapter-icon.urethras::before { width: 28px; height: 28px; }  /* urethra */
        
        /* Update chapter link to accommodate icon */
        .chapter-link {
            display: flex;
            align-items: center;
            padding: 6px 12px;
            color: #4a4a4a;
            text-decoration: none;
            border-radius: 4px;
            transition: all 0.2s;
            font-family: 'Open Sans', sans-serif;
            font-size: 0.85rem;
        }
        .chapter-link:hover, .chapter-link.active { background: #e3f2fd; color: #1565c0; }
        .chapter-link .no-symptoms { font-size: 0.8em; color: #999; font-style: italic; margin-left: 5px; }
        .pagination { display: flex; justify-content: center; align-items: center; margin: 20px 0; gap: 10px; }
        .page-link { padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; text-decoration: none; color: #333; }
        .page-link.active { background-color: #007bff; color: white; border-color: #007bff; }
        .page-link:hover:not(.active) { background-color: #f5f5f5; }
        
        .selected-symptoms-count { position: relative; }
        @keyframes popCount { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
        .counter-pop { animation: popCount 0.3s ease-out; }
        .symptom-container { scroll-margin-top: 100px; } /* Ensure symptom container is not hidden by fixed header */
        .highlight-symptom { animation: highlight-fade 3s ease-out; } /* From previous JS */
        @keyframes highlight-fade { 0% { background-color: rgba(255, 255, 0, 0.5); } 100% { background-color: transparent; } } /* From previous JS */
        .loading, .error { text-align: center; padding: 20px; font-size: 1.1em; color: #555; }
        @media (max-width: 768px) {
            .content-wrapper { flex-direction: column; }
            .sidebar { width: 100%; height: auto; position: static; overflow-y: visible; } /* Adjusted for mobile */
            .sub-symptom { margin-left: 20px; } .sub-symptom::before { left: -15px; }
            .sub-sub-symptom { margin-left: 90px; } .sub-sub-symptom::before { left: -30px; }
            .search-container { padding: 0; flex-direction: column; align-items: flex-start; }
            .selected-symptoms-count { margin-left: 0; margin-top: 10px; }
            .header { position: static; left: 0; transform: none; margin: 0 auto; }
            .page-container { padding-top: 0; }
            .logo { height: 35px; }
            .header-text { display: none; }
            .header-text h1 { font-size: 1.4rem; }
        }
        .symptom-container.level-4 { margin-left: 120px; }
.symptom-container.level-5 { margin-left: 150px; }
@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden; /* Ensures it doesn't block hover */
    }
}

/* Ensure all chapter icons in the sidebar are 40x40 */
.sidebar .chapter-icon::before {
    display: inline-block;
    width: 40px;
    height: 40px;
    background-size: contain;
}
        /* circulatory system icon */
        .chapter-icon.circulatorysystem::before, .chapter-icon.circulatorysystems::before {
            content: '';
            background-image: url('../assets/images/chapters/circulation.png');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            display: inline-block;
            width: 40px; /* small icon */
            height: 40px;
            vertical-align: middle;
            margin-right: 5px;
        }
        .chapter-header .chapter-icon.circulatorysystem::before, .chapter-header .chapter-icon.circulatorysystems::before {
            width: 34px; /* larger for header */
            height: 34px;
        }
        @media (max-width: 768px) {
            .sidebar.collapsed {
                height: 60px;               /* slim bar */
                overflow-x: auto;           /* allow horizontal scrolling if many icons */
                overflow-y: hidden;         /* hide expanded list vertically */
                white-space: nowrap;        /* keep links inline */
                padding: 10px;              /* smaller padding */
                width: 100%;                /* take full width */
                position: fixed;            /* float above content */
                margin: 0;                  /* remove margins */
                z-index: 100;               /* ensure it's above other content */
                background: white;          /* ensure background is visible */
                box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* subtle shadow */
                left: 0;                    /* align to left edge */
            }
            .sidebar.collapsed .repertory-list {
                display: flex;              /* lay out icons horizontally */
                gap: 8px;
                justify-content: center;    /* center icons */
            }
            /* Add margin to main content when sidebar is collapsed */
            .sidebar.collapsed + .main-content {
                margin-left: 0 !important;  /* remove left margin */
                width: 100% !important;     /* take full width */
                margin-top: 60px;           /* add space for floating sidebar */
            }
            .sidebar.collapsed .repertory-link {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                padding: 0;                /* remove extra padding */
                width: 50px;               /* square clickable icon area */
                height: 40px;
                font-size: 0;              /* hide text label */
                background: transparent;
            }
            .sidebar.collapsed .repertory-link::before {
                margin: 0;                 /* center icon */
            }
            /* Fix content shifting when sidebar collapses */
            .sidebar.collapsed + .main-content {
                margin-left: 0;
                width: 100%;
            }
        }