body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background-color: #e6ece8;
    background-image: url('background image.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
    overflow-x: hidden;
}

header {
    background: #043617;
    color: rgb(239, 238, 243);
    text-align: center;
    padding: 20px;
}

header h1 {
    font-size: 1.8rem;
    margin: 10px 0;
}

#userInfo {
    font-size: 0.9rem;
    margin-top: 8px;
}

nav {
    background: #026440;
    text-align: center;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
}

nav button {
    background: white;
    border: 2px solid #b60f0f;
    margin: 5px;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
}

section {
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - 200px);
}

.hidden {
    display: none !important;
}

.active {
    display: flex;
}

.card {
    background: rgb(143, 94, 199);
    width: 100%;
    max-width: 900px;
    padding: 30px;
    border: 2px solid #b60f0f;
    border-radius: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.library-card {
    background: #8e62c7;
    border: 2px solid #5a1fa6;
    box-shadow: 0 10px 30px rgba(64, 20, 120, 0.25);
    border-radius: 16px;
    padding: 24px;
}

.library-title {
    color: #1d0f2f;
    font-size: 1.6rem;
    margin: 0 0 6px 0;
    text-align: center;
}

.library-subtitle {
    color: #e9dcff;
    margin: 8px 0 16px 0;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
}

.library-codes-list {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px;
}

.library-card .code-card {
    background: #f1f2f4;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0;
    box-shadow: inset 0 0 0 1px rgba(2, 100, 64, 0.1);
}

.library-card .code-card strong {
    color: #104f36;
}


.library-card .code-card button {
    background: #0b6b52 !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
    border: none !important;
}

.library-card .code-card button:hover {
    background: #0a5a46;
    opacity: 1;
}

.library-card .code-card .explanation-btn {
    background: #5fc087 !important;
    color: #ffffff !important;
}

.card h2, .card p {
    text-align: center;
}

.card h2 {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.sub-body {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.feature-box {
    background: #5fc087;
    padding: 20px;
    border-radius: 8px;
    flex: 1 1 calc(25% - 10px);
    min-width: 120px;
    text-align: center;
    font-weight: bold;
    box-sizing: border-box;
}

input, select {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border-radius: 5px;
    border: 1px solid #ccc;
    box-sizing: border-box;
    font-size: 1rem;
}

textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-family: 'Segoe UI', sans-serif;
    resize: vertical;
    box-sizing: border-box;
    font-size: 1rem;
}

button {
    background: #f1f7f3;
    color: rgb(24, 3, 3);
    padding: 10px 15px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

button:hover {
    opacity: 0.9;
}

.code-card {
    background: #f9f9f9;
    padding: 15px;
    margin-top: 10px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.code-card.code-openable {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.code-card.code-openable:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(4, 54, 23, 0.12);
}

.chapters-list {
    background: #ffffff;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #026440;
    margin-top: 10px;
}

.chapters-list ul {
    list-style-type: disc;
    color: #333;
}

.chapters-list li {
    padding: 5px 0;
    color: #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapters-list li span {
    flex: 1;
    cursor: pointer;
    color: #026440;
}

.chapters-list li span:hover {
    color: #043617;
    text-decoration: underline;
}

.explanation-btn {
    background: #5fc087 !important;
    color: white !important;
    padding: 5px 10px !important;
    font-size: 0.85rem !important;
    border-radius: 4px !important;
    border: none !important;
    cursor: pointer !important;
    white-space: nowrap;
    margin-left: 10px;
}

.explanation-btn:hover {
    background: #026440 !important;
    opacity: 1 !important;
}

/* Prevent copying and selection */
.explanation-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.explanation-container * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.pdf-viewer-wrapper {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Prevent right-click copy on explanation modal */
#explanationModal {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Clickable chapter styles */
.clickable-chapter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

/* Hierarchical Section Styles */
.section-title {
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.section-title:hover {
    background: linear-gradient(90deg, #e8f5e9 0%, transparent 100%) !important;
    color: #043617 !important;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(4, 54, 23, 0.1);
}

.expand-btn {
    transition: all 0.2s ease;
    font-weight: bold;
}

.expand-btn:hover {
    color: #043617 !important;
    transform: scale(1.15);
}

/* Section list scrolling */
.chapters-list ul {
    position: relative;
}

.chapters-list ul::-webkit-scrollbar {
    width: 8px;
}

.chapters-list ul::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chapters-list ul::-webkit-scrollbar-thumb {
    background: #5fc087;
    border-radius: 10px;
}

.chapters-list ul::-webkit-scrollbar-thumb:hover {
    background: #026440;
}

/* Section Content in Modal */
.section-content {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Code card with hierarchy */
.code-card {
    background: linear-gradient(135deg, #f9f9f9 0%, #ffffff 100%);
    border-left: 4px solid #026440;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.code-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #ffffff;
    margin: 20px;
    padding: 30px;
    border: 2px solid #026440;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.close-btn {
    color: #b60f0f;
    float: right;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close-btn:hover {
    color: #043617;
}

.loading {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #026440;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.explanation-header {
    color: #043617;
    border-bottom: 3px solid #026440;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.explanation-section {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid #5fc087;
}

.explanation-section h3 {
    color: #026440;
    margin-top: 0;
}

.explanation-image {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 8px;
    margin: 15px auto;
    display: block;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.key-points {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.key-points ul {
    margin: 10px 0;
    padding-left: 25px;
}

.key-points li {
    margin: 8px 0;
    color: #2c5f2d;
}

.clickable-chapter {
    cursor: pointer;
    transition: all 0.2s;
}

.clickable-chapter:hover {
    color: #026440;
    text-decoration: underline;
    font-weight: bold;
}


/* Home Page Attractive Design */
.home-container {
    width: 100%;
    max-width: 1200px;
}

.search-banner {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.search-input {
    width: 100%;
    max-width: 600px;
    padding: 15px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 50px;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 6px 20px rgba(95, 192, 135, 0.3);
    transform: translateY(-2px);
}

.search-button {
    padding: 15px 30px;
    background: #5fc087;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.search-button:hover {
    background: #026440;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.welcome-banner {
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 50%, #1565c0 100%);
    padding: 50px 40px;
    border-radius: 15px;
    margin-bottom: 40px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(25, 118, 210, 0.3);
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 250px;
    height: 250px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.feature-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
    border-left: 5px solid;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.feature-icon {
    font-size: 3rem;
    min-width: 60px;
    text-align: center;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.feature-card.green-building {
    border-left-color: #66BB6A;
    background: linear-gradient(135deg, #F1F8E9 0%, #fff 100%);
}

.feature-card.green-building .feature-icon {
    animation-delay: 0s;
}

.feature-card.energy-conservation {
    border-left-color: #1976D2;
    background: linear-gradient(135deg, #E3F2FD 0%, #fff 100%);
}

.feature-card.energy-conservation .feature-icon {
    animation-delay: 0.2s;
}

.feature-card.rainwater-harvesting {
    border-left-color: #00ACC1;
    background: linear-gradient(135deg, #E0F2F1 0%, #fff 100%);
}

.feature-card.rainwater-harvesting .feature-icon {
    animation-delay: 0.4s;
}

.feature-card.sustainable-design {
    border-left-color: #558B2F;
    background: linear-gradient(135deg, #E8F5E9 0%, #fff 100%);
}

.feature-card.sustainable-design .feature-icon {
    animation-delay: 0.6s;
}

.feature-content h3 {
    margin: 0 0 8px 0;
    color: #043617;
    font-size: 1.1rem;
    font-weight: 600;
}

.feature-content p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}


/* Two-Panel Code Browser Layout */
.code-browser-container {
    display: flex;
    height: 85vh;
    max-height: 85vh;
    gap: 0;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.browser-sidebar {
    width: 300px;
    background: linear-gradient(135deg, #2c4a52 0%, #3d5a64 100%);
    border-right: 3px solid #026440;
    overflow-y: auto;
    padding: 20px;
    color: white;
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.sidebar-header h3 {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    line-height: 1.3;
    font-weight: bold;
    color: #a0d4c4;
}

.search-box {
    width: 100% !important;
    padding: 10px 12px !important;
    border: 1px solid #5fc087 !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    font-size: 0.9rem !important;
    margin: 0 !important;
}

.search-box:focus {
    outline: none;
    background: white !important;
    border-color: #5fc087 !important;
    box-shadow: 0 0 8px rgba(95, 192, 135, 0.3);
}

.search-box::placeholder {
    color: #999;
}

.chapters-sidebar {
    max-height: calc(85vh - 180px);
    overflow-y: auto;
}

.chapters-sidebar::-webkit-scrollbar {
    width: 6px;
}

.chapters-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.chapters-sidebar::-webkit-scrollbar-thumb {
    background: #5fc087;
    border-radius: 3px;
}

.chapters-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a0d4c4;
}

.sidebar-chapter-item {
    padding: 10px 12px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.08);
    border-left: 3px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: #d4e0dd;
}

.sidebar-chapter-item:hover {
    background: rgba(95, 192, 135, 0.2);
    border-left-color: #5fc087;
    transform: translateX(3px);
    color: white;
}

.sidebar-chapter-item.active {
    background: #5fc087;
    color: white;
    border-left-color: #043617;
    font-weight: bold;
}

.sidebar-subsection-item {
    padding: 8px 12px;
    margin: 3px 0 3px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: #a0d4c4;
    border-left: 2px solid transparent;
}

.sidebar-subsection-item:hover {
    background: rgba(95, 192, 135, 0.15);
    color: white;
    border-left-color: #5fc087;
    padding-left: 16px;
}

.sidebar-subsection-item.active {
    background: rgba(95, 192, 135, 0.3);
    color: white;
    border-left-color: #5fc087;
    font-weight: 600;
}

.browser-main {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
    background: #fafafa;
}

.browser-content-area {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #026440;
}

.browser-content-area h3 {
    color: #043617;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.browser-content-area p {
    color: #555;
    line-height: 1.6;
    margin: 0 0 10px 0;
}

.browser-content-area ul {
    margin: 10px 0;
    padding-left: 20px;
}

.browser-content-area li {
    color: #666;
    margin: 5px 0;
    line-height: 1.5;
}

.content-button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.content-button-group a {
    text-decoration: none;
}

.content-button-group button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.content-button-group button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.viewer-page {
    align-items: stretch;
}

#codeBrowserSection.active {
    display: block !important;
}


/* Responsive Design */

/* Tablets (768px and below) */
@media screen and (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    nav {
        padding: 8px 5px;
    }
    
    nav button {
        padding: 8px 12px;
        font-size: 0.85rem;
        margin: 3px;
    }
    
    section {
        padding: 20px 15px;
    }
    
    .card {
        width: 95%;
        padding: 20px;
        border-radius: 20px;
    }
    
    .card h2 {
        font-size: 1.5rem;
    }
    
    .sub-body {
        flex-direction: row;
        gap: 10px;
    }
    
    .feature-box {
        flex: 1 1 calc(50% - 10px);
        min-width: 140px;
    }
    
    .code-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .code-card > div {
        width: 100%;
        display: flex;
        gap: 5px;
        flex-wrap: wrap;
    }
    
    .code-card button {
        flex: 1;
        min-width: 120px;
    }
    
    /* Modal responsiveness */
    .modal-content {
        width: 90%;
        padding: 25px;
    }
}

/* Mobile Phones (480px and below) */
@media screen and (max-width: 480px) {
    header h1 {
        font-size: 1.2rem;
        padding: 5px;
    }
    
    #userInfo {
        font-size: 0.8rem;
    }
    
    nav {
        padding: 5px;
        gap: 3px;
    }
    
    nav button {
        padding: 6px 10px;
        font-size: 0.75rem;
        margin: 2px;
    }
    
    section {
        padding: 15px 10px;
    }
    
    .card {
        width: 100%;
        padding: 15px;
        border-radius: 15px;
    }
    
    .card h2 {
        font-size: 1.3rem;
    }
    
    .card p {
        font-size: 0.9rem;
    }
    
    .sub-body {
        flex-direction: column;
        gap: 10px;
    }
    
    .feature-box {
        flex: 1 1 100%;
        width: 100%;
        min-width: unset;
    }
    
    input, select, textarea {
        font-size: 0.9rem;
        padding: 8px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .chapters-list {
        padding: 10px;
    }
    
    .chapters-list h4 {
        font-size: 1rem;
    }
    
    .chapters-list li {
        font-size: 0.85rem;
    }
    
    /* Modal responsiveness */
    .modal-content {
        width: 95%;
        margin: 10px;
        padding: 20px;
        max-height: 90vh;
    }
    
    .close-btn {
        font-size: 28px;
    }
    
    .explanation-header h2 {
        font-size: 1.3rem;
    }
    
    .explanation-header h3 {
        font-size: 1.1rem;
    }
    
    .explanation-section h3 {
        font-size: 1rem;
    }
}

/* Extra Small Devices (360px and below) */
@media screen and (max-width: 360px) {
    header h1 {
        font-size: 1rem;
    }
    
    nav button {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
    
    .card {
        padding: 12px;
    }
    
    .card h2 {
        font-size: 1.1rem;
    }
    
    .feature-box {
        padding: 15px;
        font-size: 0.9rem;
    }
}

/* Login Page Redesign */
.portal-header {
    background: linear-gradient(90deg, #043a2a 0%, #0b5c3d 50%, #0c6a44 100%);
    border-bottom: 2px solid rgba(255, 255, 255, 0.25);
    padding: 14px 20px 10px;
    position: relative;
    overflow: hidden;
}

.portal-header::before,
.portal-header::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(93, 197, 137, 0.32) 0%, rgba(93, 197, 137, 0) 70%);
    z-index: 0;
}

.portal-header::before {
    left: -60px;
    top: -90px;
}

.portal-header::after {
    right: -45px;
    bottom: -130px;
}

.header-strip {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: relative;
    z-index: 1;
}

.header-logo-wrap {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.header-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-title-wrap {
    text-align: center;
    flex: 1;
}

.header-title-wrap h1 {
    margin: 0;
    color: #f4fff7;
    font-size: clamp(1.6rem, 3vw, 2.85rem);
    font-weight: 700;
    letter-spacing: 0.2px;
}

.header-title-wrap p {
    margin: 7px 0 0;
    color: #d6f0df;
    font-size: clamp(0.85rem, 1.2vw, 1.25rem);
}

#userInfo {
    position: relative;
    z-index: 1;
    color: #d8f5e4;
    text-align: center;
    margin-top: 6px;
}

.portal-nav {
    background: linear-gradient(90deg, #0d2f3c 0%, #123f4d 45%, #1c5360 100%);
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.portal-nav button {
    background: rgba(3, 27, 38, 0.6);
    color: #f2fffc;
    border: 1px solid rgba(164, 216, 198, 0.28);
    border-radius: 10px;
    padding: 10px 22px;
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0;
}

.portal-nav button:hover {
    opacity: 1;
    background: rgba(8, 67, 58, 0.92);
}

.portal-nav button.active-tab {
    background: linear-gradient(135deg, #0a8a4e 0%, #17aa63 100%);
    border-color: #66d09a;
    color: #ffffff;
}

.portal-main {
    position: relative;
    min-height: calc(100vh - 205px);
    background: linear-gradient(180deg, rgba(242, 244, 246, 0.8) 0%, rgba(231, 237, 240, 0.8) 100%);
    overflow: hidden;
}

.portal-main::before,
.portal-main::after {
    content: '';
    position: absolute;
    inset: auto;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(94, 187, 135, 0.19) 0%, rgba(94, 187, 135, 0) 70%);
    pointer-events: none;
}

.portal-main::before {
    left: -160px;
    bottom: -90px;
}

.portal-main::after {
    right: -120px;
    top: 90px;
}

.auth-page {
    min-height: calc(100vh - 240px);
    align-items: center;
    justify-content: center;
    padding: 30px 16px;
    position: relative;
}

.auth-bg-left,
.auth-bg-right {
    position: absolute;
    width: 290px;
    height: 190px;
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(33, 164, 99, 0.3), rgba(23, 142, 84, 0.09));
    filter: blur(0.2px);
    z-index: 0;
}

.auth-bg-left {
    left: 8%;
    bottom: 11%;
    transform: rotate(-9deg);
}

.auth-bg-right {
    right: 8%;
    top: 15%;
    transform: rotate(9deg);
}

.auth-card {
    width: min(100%, 470px);
    background: rgba(255, 255, 255, 0.93);
    border: 1px solid #cfe0d8;
    border-top: 7px solid #1b8e59;
    border-radius: 24px;
    padding: 26px 30px 22px;
    box-shadow: 0 18px 46px rgba(27, 52, 63, 0.2);
    position: relative;
    z-index: 1;
}

.auth-card h2 {
    text-align: center;
    margin: 0;
    color: #0c5f3d;
    font-size: 2.2rem;
    font-weight: 700;
}

.auth-subtitle {
    margin: 6px 0 14px;
    text-align: center;
    color: #334651;
    font-size: 1.05rem;
}

.auth-label {
    display: block;
    margin: 12px 0 7px;
    color: #1f323b;
    font-size: 1rem;
    font-weight: 600;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-wrap .input-icon {
    position: absolute;
    left: 12px;
    color: #4b7d67;
    font-size: 0.95rem;
    pointer-events: none;
}

.auth-input-wrap input,
.auth-input-wrap select {
    width: 100%;
    margin: 0;
    border-radius: 8px;
    border: 1px solid #c7d3d9;
    background: #fbfdff;
    padding: 12px 14px 12px 38px;
    font-size: 1.03rem;
    color: #1f333d;
}

.auth-input-wrap input:focus,
.auth-input-wrap select:focus {
    outline: none;
    border-color: #35a16e;
    box-shadow: 0 0 0 3px rgba(53, 161, 110, 0.15);
}

.password-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.password-row .auth-label {
    margin: 0;
}

.forgot-link {
    color: #237c5a;
    font-weight: 600;
    text-decoration: underline;
}

.password-toggle {
    position: absolute;
    right: 11px;
    background: transparent;
    border: none;
    color: #355562;
    font-size: 1rem;
    padding: 0;
    width: 24px;
    height: 24px;
}

.auth-btn {
    width: 100%;
    margin-top: 18px;
    border-radius: 8px;
    border: none;
    color: #fff;
    font-size: 1.88rem;
    font-weight: 700;
    padding: 11px 18px;
    background: linear-gradient(90deg, #0d7e4d 0%, #14aa63 100%);
    box-shadow: 0 9px 18px rgba(11, 129, 78, 0.2);
}

.auth-btn:hover {
    opacity: 1;
    filter: brightness(0.95);
}

.auth-link-line {
    margin: 12px 0 0;
    text-align: center;
    color: #2f3f4d;
    font-size: 1.03rem;
}

.auth-link-line a {
    color: #157d54;
    font-weight: 700;
}

.admin-switch-btn {
    width: 100%;
    margin-top: 14px;
    border: 1px solid #c8dad3;
    border-radius: 9px;
    background: #e4ede8;
    color: #1e6b4c;
    font-size: 1.5rem;
    font-weight: 600;
    padding: 9px 14px;
}

.admin-switch-btn:hover {
    opacity: 1;
    background: #d9e5df;
}

.alt-card {
    background: rgba(255, 255, 255, 0.95);
}

.alt-card input,
.alt-card select {
    margin: 8px 0;
}

.alt-card .auth-btn {
    font-size: 1.15rem;
}

@media screen and (max-width: 900px) {
    .portal-nav {
        flex-wrap: wrap;
    }

    .portal-nav button {
        padding: 8px 14px;
        font-size: 0.95rem;
    }

    .auth-bg-left,
    .auth-bg-right {
        display: none;
    }

    .auth-card h2 {
        font-size: 1.9rem;
    }

    .auth-btn {
        font-size: 1.6rem;
    }

    .admin-switch-btn {
        font-size: 1.2rem;
    }
}

@media screen and (max-width: 540px) {
    .portal-header {
        padding: 10px 12px 8px;
    }

    .header-logo-wrap {
        width: 48px;
        height: 48px;
    }

    .header-title-wrap h1 {
        font-size: 1.15rem;
    }

    .header-title-wrap p {
        font-size: 0.76rem;
    }

    .portal-main {
        min-height: calc(100vh - 180px);
    }

    .auth-page {
        min-height: calc(100vh - 210px);
        padding: 20px 10px;
    }

    .auth-card {
        padding: 18px 16px;
        border-radius: 18px;
    }

    .auth-card h2 {
        font-size: 1.45rem;
    }

    .auth-subtitle,
    .auth-link-line,
    .auth-label {
        font-size: 0.95rem;
    }

    .auth-btn {
        font-size: 1.35rem;
        padding: 10px 14px;
    }

    .admin-switch-btn {
        font-size: 1rem;
    }
}

/* Global responsive hardening for all pages */
@media screen and (max-width: 1100px) {
    .code-browser-container {
        height: auto;
        max-height: none;
        min-height: 70vh;
    }

    .browser-main {
        padding: 20px 22px;
    }

    .chapters-sidebar {
        max-height: calc(75vh - 170px);
    }
}

@media screen and (max-width: 900px) {
    .header-strip {
        gap: 10px;
    }

    .header-title-wrap p {
        margin-top: 4px;
    }

    nav,
    .portal-nav {
        padding: 8px;
        gap: 6px;
        justify-content: center;
    }

    nav button,
    .portal-nav button {
        padding: 8px 12px;
        font-size: 0.86rem;
    }

    .search-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .search-input,
    .search-button {
        max-width: none;
        width: 100%;
    }

    .welcome-banner {
        padding: 26px 18px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .feature-card {
        padding: 16px;
        gap: 12px;
    }

    .feature-icon {
        font-size: 2rem;
        min-width: 42px;
    }

    .library-card {
        padding: 14px;
    }

    .library-card .code-card {
        padding: 10px;
    }
}

@media screen and (max-width: 768px) {
    .viewer-page {
        padding: 14px 10px;
    }

    .code-browser-container {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: 0;
        border-radius: 8px;
    }

    .browser-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid #026440;
        padding: 12px;
        max-height: 42vh;
    }

    .chapters-sidebar {
        max-height: 28vh;
    }

    .browser-main {
        padding: 14px 12px;
    }

    .browser-content-area {
        padding: 14px;
    }

    .content-button-group {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .content-button-group a,
    .content-button-group button {
        width: 100%;
    }

    .sidebar-subsection-item {
        margin-left: 8px;
    }
}

@media screen and (max-width: 560px) {
    .portal-header {
        padding: 8px 8px 6px;
    }

    header {
        padding: 10px 8px;
    }

    .header-logo-wrap {
        width: 40px;
        height: 40px;
    }

    .header-title-wrap h1 {
        font-size: 1rem;
    }

    .header-title-wrap p {
        display: none;
    }

    #userInfo {
        font-size: 0.78rem;
        margin-top: 4px;
    }

    section {
        padding: 12px 8px;
        min-height: auto;
    }

    .auth-card,
    .alt-card {
        border-radius: 14px;
        padding: 14px 12px;
    }

    .auth-btn {
        font-size: 1.08rem;
    }
}
