:root {
    --bg: #eef3f9;
    --bg-soft: #e5edf8;
    --surface: rgba(255, 255, 255, 0.95);
    --surface-strong: #ffffff;
    --surface-muted: #ecf2fb;
    --text: #0f172a;
    --text-muted: #475569;
    --accent: #1d4ed8;
    --accent-2: #f59e0b;
    --danger: #ef4444;
    --border: rgba(15, 23, 42, 0.12);
    --radius: 14px;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --font-main: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-display: 'Sora', 'Segoe UI', sans-serif;
}

body.lightmode {
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --surface: rgba(255, 255, 255, 0.98);
    --surface-strong: #ffffff;
    --surface-muted: #eef2ff;
    --text: #0f2230;
    --text-muted: #365267;
    --accent: #1e40af;
    --accent-2: #b45309;
    --border: rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    color: #0b2742;
    background: radial-gradient(circle at 10% 0%, #dbe8fb, var(--bg) 55%);
    min-height: 100%;
}

body {
    position: relative;
    overflow-x: hidden;
}

.main-page-bg-video {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
    filter: saturate(0.9) brightness(1.06);
    opacity: 0.16;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(120deg, rgba(237, 244, 252, 0.86), rgba(248, 250, 252, 0.92));
    z-index: -1;
}

header,
main,
.site-footer {
    width: min(1160px, calc(100% - 2rem));
    margin-inline: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.75rem 0 1rem;
}

.header-content h1 {
    margin: 0;
    font-family: var(--font-display);
    letter-spacing: 0.02em;
    font-size: clamp(1.6rem, 2.3vw, 2.4rem);
    color: #0b2742;
}

.header-content p {
    margin: 0.45rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.profile-pic {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.7);
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.profile-pic:hover {
    transform: scale(1.06);
}

main {
    padding: 0.7rem 0 2.2rem;
}

/* Semester selector = first step for students */
.semester-selector {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 1.5rem 1.5rem 1.6rem;
}

.semester-selector.semester-hero {
    background: linear-gradient(145deg, var(--surface) 0%, var(--surface-strong) 100%);
    border-color: rgba(37, 99, 235, 0.25);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(37, 99, 235, 0.08);
}

body.lightmode .semester-selector.semester-hero {
    border-color: rgba(37, 99, 235, 0.26);
    box-shadow: 0 12px 32px rgba(9, 66, 89, 0.08);
}

.semester-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.28);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    margin-bottom: 0.6rem;
}

.semester-selector h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 1.8vw, 1.45rem);
}

.semester-selector p,
.semester-hint {
    margin: 0.4rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

.semester-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.semester-option {
    border: 1px solid var(--border);
    background: #eef2f7;
    color: #0b2742;
    font: inherit;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.6rem 1.15rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.semester-option:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.14);
}

.semester-option.active {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 5px 14px rgba(37, 99, 235, 0.28);
}

.semester-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.search-and-tabs {
    display: grid;
    gap: 1.1rem;
    margin-top: 1.4rem;
}

.search-box {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: #0b2742;
    padding: 0.9rem 1rem 0.9rem 2.75rem;
    font: inherit;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:hover {
    border-color: rgba(178, 228, 235, 0.35);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.search-input::placeholder {
    color: color-mix(in oklab, var(--text-muted) 80%, white 20%);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.advanced-filters {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    padding: 0.5rem 0.75rem;
}

.advanced-filters summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text-muted);
}

.filter-grid {
    margin-top: 0.7rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}

.filter-grid select {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-strong);
    color: #0b2742;
    font: inherit;
    padding: 0.55rem 0.6rem;
}

.tab-link {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.tab-link:hover {
    color: #0b2742;
    border-color: rgba(37, 99, 235, 0.3);
}

.tab-link.active {
    color: #ffffff;
    background: linear-gradient(130deg, #1d4ed8, #1e3a8a);
    border-color: transparent;
}

.tab-link:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

.tab-content {
    margin-top: 1.2rem;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.file-card {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.file-card:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.26);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}

body.lightmode .file-card:hover {
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.file-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.file-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.file-details {
    min-width: 0;
    flex: 1;
}

.file-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    margin-top: 0.2rem;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.file-meta span {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.18rem 0.5rem;
    font-size: 0.76rem;
}

.file-meta span:first-of-type {
    color: var(--accent);
    border-color: rgba(37, 99, 235, 0.35);
    background: rgba(37, 99, 235, 0.1);
}

.contributor-credit {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.contributor-credit a {
    color: #1d4ed8;
    text-decoration: none;
}

.file-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.preview-button,
.download-button {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0.5rem 0.8rem;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.preview-button:hover,
.download-button:hover {
    transform: scale(1.02);
}

.preview-button:focus-visible,
.download-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.preview-button {
    background: var(--surface-muted);
    color: #0b2742;
}

.download-button {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #ffffff;
    border: none;
}

.site-footer {
    margin-top: 1.8rem;
    margin-bottom: 1.2rem;
    padding: 1.1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
}

.footer-section h4 {
    margin: 0;
    font-family: var(--font-display);
}

.footer-section p {
    margin: 0.4rem 0;
    color: var(--text-muted);
}

.qr-code {
    border-radius: 9px;
    background: #fff;
    padding: 5px;
}

.feedback-button,
.action-button {
    display: inline-block;
    border: none;
    border-radius: 9px;
    padding: 0.56rem 0.95rem;
    text-decoration: none;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.feedback-button,
.action-button.primary {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #1f2937;
}

.footer-bottom {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.86rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(5, 14, 20, 0.72);
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content,
.pdf-modal-content {
    width: min(720px, 100%);
    background: #041722;
    color: #f4feff;
    border: 1px solid rgba(180, 234, 238, 0.25);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.modal-content {
    max-height: 92vh;
    overflow-y: auto;
}

.profile-bg-video-full {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    filter: brightness(0.45);
}

.close-modal-btn {
    position: absolute;
    right: 0.7rem;
    top: 0.7rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    cursor: pointer;
    z-index: 2;
    font-size: 1.4rem;
}

.profile-modal-header,
.modal-tabs,
.modal-tab-content {
    position: relative;
    z-index: 1;
}

.profile-modal-header {
    text-align: center;
    padding: 1.1rem 1rem 0.4rem;
}

.modal-profile-pic-wrapper {
    width: 110px;
    height: 110px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.85);
    position: relative;
    cursor: pointer;
}

.modal-profile-pic {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-pic-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.52);
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.78rem;
    text-align: center;
}

.modal-profile-pic-wrapper:hover .modal-pic-overlay {
    opacity: 1;
}

#modal-profile-name {
    margin: 0.7rem 0 0;
    font-family: var(--font-display);
}

.modal-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
}

.modal-tab-link {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    padding: 0.55rem;
    background: rgba(0, 0, 0, 0.32);
    color: #f1fdff;
    cursor: pointer;
    font-weight: 700;
}

.modal-tab-link.active {
    background: linear-gradient(135deg, var(--accent), #0891b2);
    color: #03242f;
    border-color: transparent;
}

.modal-tab-content {
    padding: 0.9rem 1rem 1.2rem;
}

.setting-item {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.setting-item input {
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    padding: 0.65rem 0.7rem;
    font: inherit;
}

.theme-toggle {
    display: flex;
    align-items: center;
}

#modeBtn {
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

#user-contributions-list {
    min-height: 90px;
    max-height: 210px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 10px;
    padding: 0.6rem;
    background: rgba(0, 0, 0, 0.3);
    text-align: left;
}

#user-contributions-list li {
    margin: 0 0 0.38rem;
    font-size: 0.88rem;
}

.contributions-empty-state {
    color: #bcd8df;
}

.contribute-link {
    margin-top: 0.9rem;
}

.pdf-preview-modal .pdf-modal-content {
    width: min(980px, 100%);
    height: min(90vh, 860px);
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 1rem;
}

#pdf-modal-title {
    margin: 0;
    padding: 0 2.2rem 0.7rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-family: var(--font-display);
    font-size: 1rem;
}

#pdf-viewer-container {
    position: relative;
    overflow: auto;
    text-align: center;
    padding: 0.9rem 0;
}

#pdf-canvas {
    max-width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#loader {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fcd34d;
    transform: translate(-50%, -50%);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Contribution page */
body.contribution-page {
    background: linear-gradient(145deg, #081b27, #0f2e3f);
}

.contribution-container {
    width: min(860px, calc(100% - 2rem));
    margin: 2rem auto;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.contribution-container h1,
.contribution-container h2 {
    font-family: var(--font-display);
}

.contribution-step {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    background: rgba(6, 32, 44, 0.55);
}

#drop-zone {
    border: 2px dashed rgba(166, 228, 239, 0.5);
    border-radius: 10px;
    padding: 1.4rem;
    text-align: center;
    cursor: pointer;
}

#drop-zone.dragging {
    border-color: #1d4ed8;
    background: rgba(37, 99, 235, 0.12);
}

#share-link-input,
#text-preview {
    width: 100%;
    border-radius: 9px;
    border: 1px solid var(--border);
    padding: 0.66rem;
    font: inherit;
    color: #0b2742;
    background: rgba(0, 0, 0, 0.28);
}

#pdf-preview-canvas,
#image-preview {
    max-width: 100%;
    margin-top: 0.8rem;
    border-radius: 10px;
}

.success-message {
    color: #1d4ed8;
    font-weight: 700;
}

.hidden {
    display: none !important;
}

.no-results-message {
    margin-top: 1.5rem;
    padding: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.no-results-message:not(.hidden) {
    display: block;
}

@media (max-width: 720px) {
    header {
        align-items: flex-start;
        flex-direction: column;
    }

    .file-card {
        align-items: flex-start;
    }

    .file-actions {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
    }

    .preview-button,
    .download-button {
        flex: 1;
    }

    .modal-tabs {
        flex-direction: column;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }
}

