:root {
    --explore-ink: #17213d;
    --explore-muted: #69758e;
    --explore-blue: #4361ee;
    --explore-purple: #7757e8;
    --explore-border: #e8ebf3;
    --explore-surface: #f7f8fc;
}

body {
    background: #fff;
    color: var(--explore-ink);
}

body.dialog-open {
    overflow: hidden;
}

.page-header {
    background:
        radial-gradient(ellipse at 86% 22%, rgba(119, 87, 232, .09), transparent 31%),
        radial-gradient(ellipse at 14% 88%, rgba(67, 97, 238, .08), transparent 30%),
        #fff;
    padding: 66px 5% 46px;
}

.page-header::before,
.page-header::after {
    display: none;
}

.ph-label {
    background: #f0efff;
    border: 1px solid #e6e2ff;
    color: #6752d9;
    letter-spacing: .45px;
    text-transform: none;
    padding: 7px 14px;
}

.page-header h1 {
    color: var(--explore-ink);
    font-size: clamp(2.2rem, 5vw, 3.45rem);
    letter-spacing: -1.8px;
    margin-bottom: 12px;
}

.page-header h1 span {
    color: var(--explore-blue);
}

.page-header p {
    color: var(--explore-muted);
    font-size: 1.08rem;
}

.ph-stats {
    gap: 12px;
    margin-top: 30px;
}

.ph-stat {
    background: #fff;
    border: 1px solid var(--explore-border);
    border-radius: 12px;
    box-shadow: 0 5px 18px rgba(27, 38, 78, .045);
    min-width: 122px;
    padding: 12px 19px;
}

.ph-stat-num {
    color: var(--explore-ink);
    font-size: 1.15rem;
}

.ph-stat-label {
    color: var(--explore-muted);
    font-size: .67rem;
    letter-spacing: .3px;
    text-transform: none;
}

.filter-bar {
    position: static;
    border-bottom: 0;
    box-shadow: none;
    padding: 14px 5%;
}

.filter-inner {
    max-width: 1140px;
    padding: 12px;
    border: 1px solid var(--explore-border);
    border-radius: 14px;
    box-shadow: 0 7px 24px rgba(27, 38, 78, .055);
    gap: 10px;
}

.subject-search {
    position: relative;
    flex: 1 1 270px;
    min-width: 190px;
}

.subject-search > i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #8993aa;
    font-size: 1.1rem;
    pointer-events: none;
}

.subject-search input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--explore-border);
    border-radius: 9px;
    outline: none;
    background: #fbfcfe;
    color: var(--explore-ink);
    font: 500 .9rem 'Outfit', sans-serif;
    padding: 0 38px 0 42px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.subject-search input:focus {
    background: #fff;
    border-color: #8c82ec;
    box-shadow: 0 0 0 3px rgba(119, 87, 232, .11);
}

.subject-search input::placeholder {
    color: #98a1b4;
}

.subject-search kbd {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    border: 1px solid #e6e8ef;
    border-radius: 4px;
    color: #939bb0;
    font: 500 .7rem 'Outfit', sans-serif;
    padding: 1px 5px;
}

.filter-select {
    height: 44px;
    min-width: 150px;
    border-color: var(--explore-border);
    border-radius: 9px;
    background-color: #fbfcfe;
    color: #4a5570;
    font-weight: 600;
}

.filter-count {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: .78rem;
}

.manage-subjects-btn {
    display: inline-flex;
    height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 9px;
    background: #202b4d;
    color: #fff;
    cursor: pointer;
    font: 700 .84rem 'Outfit', sans-serif;
    padding: 0 15px;
    transition: background .2s, transform .2s;
}

.manage-subjects-btn:hover {
    background: #34426c;
    transform: translateY(-1px);
}

.main {
    max-width: 1140px;
    padding: 33px 5% 76px;
}

.storage-note {
    margin: 10px 0 0;
    color: #8f97a8;
    font-size: .7rem;
    line-height: 1.5;
}

.filter-count.error-text {
    color: #bb4857;
}

.explore-intro {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 25px;
}

.explore-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #7b6be2;
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: 1.15px;
    margin-bottom: 10px;
}

.explore-eyebrow span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8c79f4;
    box-shadow: 0 0 0 4px #f0edff;
}

.explore-intro h2 {
    color: var(--explore-ink);
    font-size: clamp(1.55rem, 3.4vw, 2rem);
    letter-spacing: -.75px;
}

.explore-intro h2 span {
    color: var(--explore-purple);
}

.explore-intro p {
    margin-top: 8px;
    font-size: .92rem;
}

.free-note {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    border: 1px solid #eeeaff;
    border-radius: 999px;
    background: #fbfaff;
    color: #74718f;
    font-size: .76rem;
    padding: 9px 14px;
    white-space: nowrap;
}

.free-note i,
.free-note b {
    color: #765be5;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 17px;
}

.subject-card {
    position: relative;
    display: flex;
    min-height: 265px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--explore-border);
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(30, 43, 82, .045);
    padding: 20px;
    transition: border-color .25s, box-shadow .25s, transform .25s;
    animation: card-arrive .42s both;
}

.subject-card::before {
    position: absolute;
    top: -48px;
    right: -40px;
    width: 125px;
    height: 125px;
    border-radius: 50%;
    background: var(--card-tint, #f1f3ff);
    content: "";
    opacity: .7;
    transition: transform .3s;
}

.subject-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--card-accent, #6276ef) 35%, white);
    box-shadow: 0 15px 34px rgba(30, 43, 82, .11);
}

.subject-card:hover::before {
    transform: scale(1.2);
}

.subject-card-top,
.subject-card h3,
.subject-card-description,
.subject-card-meta,
.subject-card-bottom {
    position: relative;
    z-index: 1;
}

.subject-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 17px;
}

.subject-icon {
    display: flex;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--card-accent, #6276ef) 12%, white);
    border-radius: 14px;
    background: var(--card-tint, #f1f3ff);
    color: var(--card-accent, #6276ef);
    font-size: 1.45rem;
}

.subject-category {
    max-width: 58%;
    overflow: hidden;
    border: 1px solid #eceaf8;
    border-radius: 999px;
    background: #fff;
    color: #79738f;
    font-size: .66rem;
    font-weight: 700;
    padding: 5px 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subject-card h3 {
    min-height: 2.45em;
    color: #202b49;
    font-size: 1.02rem;
    font-weight: 750;
    letter-spacing: -.18px;
    line-height: 1.3;
    margin-bottom: 8px;
}

.subject-card-description {
    display: -webkit-box;
    min-height: 2.9em;
    overflow: hidden;
    color: #7c879d;
    font-size: .79rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.subject-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.semester-pill,
.material-count {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #6d7890;
    font-size: .72rem;
    font-weight: 650;
}

.semester-pill {
    border-radius: 6px;
    background: #f6f7fb;
    padding: 5px 8px;
}

.material-count i {
    color: #7e6be8;
    font-size: .92rem;
}

.material-count.is-empty i {
    color: #b2b8c5;
}

.subject-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid #f1f2f7;
    margin-top: auto;
    padding-top: 14px;
}

.availability {
    color: #9aa2b3;
    font-size: .69rem;
    font-weight: 650;
}

.availability.has-files {
    color: #159575;
}

.view-materials {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 0;
    background: transparent;
    color: #5368df;
    cursor: pointer;
    font: 750 .8rem 'Outfit', sans-serif;
    padding: 3px 0 3px 8px;
    transition: color .2s, gap .2s;
}

.view-materials:hover {
    gap: 11px;
    color: #704be0;
}

.view-materials i {
    font-size: .94rem;
}

.subject-card-admin {
    display: flex;
    gap: 6px;
}

.subject-card-admin button {
    width: 29px;
    height: 29px;
    border: 1px solid #e8eaf1;
    border-radius: 7px;
    background: white;
    color: #78829a;
    cursor: pointer;
}

.subject-card-admin button:hover {
    border-color: #cec8ff;
    color: #715be3;
}

.subject-card-admin .delete-subject:hover {
    border-color: #ffd2d2;
    color: #d34e5e;
}

.subject-empty {
    padding: 62px 20px;
    text-align: center;
}

.subject-empty[hidden],
.subject-overlay[hidden],
[hidden] {
    display: none !important;
}

.empty-icon {
    display: grid;
    width: 60px;
    height: 60px;
    place-items: center;
    margin: 0 auto 15px;
    border-radius: 18px;
    background: #f1efff;
    color: #7a65e5;
    font-size: 1.6rem;
}

.subject-empty h3 {
    color: var(--explore-ink);
    font-size: 1.15rem;
}

.subject-empty p {
    margin: 7px 0 17px;
    font-size: .88rem;
}

.subject-empty button {
    border: 0;
    border-radius: 8px;
    background: #eeeaff;
    color: #624fd0;
    cursor: pointer;
    font: 700 .82rem 'Outfit', sans-serif;
    padding: 9px 15px;
}

.subject-overlay {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    background: rgba(15, 23, 42, .48);
    padding: 22px;
    backdrop-filter: blur(5px);
    animation: overlay-in .18s ease-out;
}

.subject-dialog {
    position: relative;
    width: min(760px, 100%);
    max-height: min(88vh, 900px);
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 28px 90px rgba(18, 27, 58, .25);
    padding: 30px;
    animation: dialog-in .22s ease-out;
}

.dialog-close {
    position: sticky;
    z-index: 2;
    top: 0;
    float: right;
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    margin: -13px -13px 0 0;
    border: 1px solid #eaecf2;
    border-radius: 50%;
    background: #fff;
    color: #6f7890;
    cursor: pointer;
    font-size: 1.25rem;
}

.dialog-close:hover {
    background: #f5f4ff;
    color: #6e5ae0;
}

.detail-hero {
    display: flex;
    align-items: center;
    gap: 17px;
    padding: 4px 28px 22px 0;
}

.detail-icon {
    display: grid;
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    place-items: center;
    border-radius: 17px;
    background: var(--card-tint, #f1f3ff);
    color: var(--card-accent, #6276ef);
    font-size: 1.65rem;
}

.detail-title-wrap {
    min-width: 0;
}

.detail-kicker {
    color: #796ce0;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .95px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.detail-hero h2 {
    color: #202b49;
    font-size: clamp(1.2rem, 3vw, 1.62rem);
    line-height: 1.2;
}

.detail-description {
    color: #77829a;
    font-size: .88rem;
    margin-top: 6px;
}

.detail-notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid #e7e5ff;
    border-radius: 10px;
    background: #f8f7ff;
    color: #686384;
    font-size: .78rem;
    line-height: 1.5;
    margin: 0 0 19px;
    padding: 11px 13px;
}

.detail-notice i {
    color: #7e6be8;
    font-size: 1rem;
}

.detail-notice.upload-error {
    border-color: #ffd9d9;
    background: #fff6f6;
    color: #a9434d;
}

.detail-notice.upload-error i {
    color: #c24f59;
}

.material-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin: 5px 0 12px;
}

.material-section-heading h3 {
    color: #27324f;
    font-size: .97rem;
}

.material-section-heading span {
    color: #9aa2b3;
    font-size: .72rem;
}

.material-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.material-item {
    display: flex;
    min-height: 68px;
    align-items: center;
    gap: 11px;
    border: 1px solid #eceef4;
    border-radius: 11px;
    background: #fff;
    padding: 11px 12px;
    transition: border-color .2s, background .2s;
}

.material-item:hover {
    border-color: #dedafd;
    background: #fdfcff;
}

.material-file-icon {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border-radius: 10px;
    background: #f2f1ff;
    color: #7867df;
    font-size: 1.05rem;
}

.material-item-body {
    min-width: 0;
    flex: 1;
}

.material-item-title {
    color: #35405d;
    font-size: .79rem;
    font-weight: 700;
    line-height: 1.25;
}

.material-item-status {
    color: #a0a7b5;
    font-size: .68rem;
    margin-top: 4px;
}

.material-item-status.is-available {
    color: #159575;
}

.material-item-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.material-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #e5e3fc;
    border-radius: 7px;
    background: #f7f6ff;
    color: #6554d2;
    font: 700 .7rem 'Outfit', sans-serif;
    padding: 7px 9px;
    white-space: nowrap;
}

.material-download:hover {
    background: #ece9ff;
}

.material-upload {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #eceef4;
    border-radius: 7px;
    background: white;
    color: #758099;
    cursor: pointer;
    font: 700 .68rem 'Outfit', sans-serif;
    padding: 7px 8px;
    white-space: nowrap;
}

.material-upload:hover {
    border-color: #cbc5fc;
    color: #6654d4;
}

.material-upload input {
    display: none;
}

.detail-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid #eff0f5;
    color: #99a1b1;
    font-size: .72rem;
    margin-top: 18px;
    padding-top: 14px;
}

.detail-free {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #6f5cda;
    font-weight: 700;
}

.editor-dialog {
    width: min(540px, 100%);
}

.editor-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    margin: 1px 30px 22px 0;
}

.editor-icon {
    display: grid;
    width: 45px;
    height: 45px;
    flex: 0 0 45px;
    place-items: center;
    border-radius: 13px;
    background: #f1efff;
    color: #765fe0;
    font-size: 1.25rem;
}

.editor-heading h2 {
    color: #222d4b;
    font-size: 1.24rem;
}

.editor-heading p {
    color: #8892a6;
    font-size: .8rem;
    margin-top: 4px;
}

.subject-form {
    display: grid;
    gap: 13px;
}

.subject-form label {
    display: grid;
    gap: 6px;
    color: #505b75;
    font-size: .77rem;
    font-weight: 700;
}

.subject-form input,
.subject-form textarea,
.subject-form select {
    width: 100%;
    border: 1px solid #e4e7ef;
    border-radius: 8px;
    background: #fcfcfe;
    color: #283452;
    font: 500 .84rem 'Outfit', sans-serif;
    outline: 0;
    padding: 10px 11px;
}

.subject-form input:focus,
.subject-form textarea:focus,
.subject-form select:focus {
    border-color: #9285eb;
    box-shadow: 0 0 0 3px rgba(119, 87, 232, .1);
}

.subject-form textarea {
    resize: vertical;
}

.form-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.editor-error {
    border-radius: 8px;
    background: #fff2f2;
    color: #b93e4e;
    font-size: .77rem;
    padding: 9px 11px;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 4px;
}

.editor-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: 700 .82rem 'Outfit', sans-serif;
    padding: 10px 15px;
}

.editor-cancel {
    background: #f2f3f7;
    color: #65708a;
}

.editor-save {
    background: #6254d4;
    color: #fff;
}

.editor-save:hover {
    background: #5143bf;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@keyframes card-arrive {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 900px) {
    .subject-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-inner {
        gap: 9px;
    }

    .filter-select {
        min-width: 135px;
    }
}

@media (max-width: 640px) {
    .page-header {
        padding: 42px 5% 29px;
    }

    .page-header h1 {
        letter-spacing: -1px;
    }

    .ph-stats {
        gap: 8px;
    }

    .ph-stat {
        min-width: 99px;
        padding: 10px 12px;
    }

    .filter-bar {
        padding: 12px 4%;
    }

    .filter-inner {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .subject-search {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .filter-select {
        width: 100%;
        min-width: 0;
    }

    .manage-subjects-btn {
        grid-column: 1 / -1;
    }

    .filter-count {
        grid-column: 1 / -1;
        margin: 2px 0 0;
    }

    .main {
        padding: 28px 4% 54px;
    }

    .explore-intro {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        margin-bottom: 19px;
    }

    .free-note {
        justify-content: flex-start;
        white-space: normal;
    }

    .subject-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .subject-card {
        min-height: 245px;
        padding: 18px;
    }

    .subject-dialog {
        max-height: 92vh;
        border-radius: 17px;
        padding: 22px 17px;
    }

    .dialog-close {
        margin: -8px -5px 0 0;
    }

    .detail-hero {
        gap: 12px;
        padding-right: 22px;
    }

    .detail-icon {
        width: 49px;
        height: 49px;
        flex-basis: 49px;
        border-radius: 14px;
        font-size: 1.4rem;
    }

    .material-grid {
        grid-template-columns: 1fr;
    }

    .material-item {
        min-height: 62px;
    }

    .material-upload {
        padding: 7px;
    }

    .material-upload .upload-text {
        display: none;
    }

    .detail-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
