@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
    --blue: #2588d8;
    --blue-dark: #1769b1;
    --sky: #eaf6ff;
    --mint: #dff8ef;
    --green: #26a879;
    --yellow: #fff2c9;
    --orange: #ffad65;
    --coral: #ff7c72;
    --ink: #24374b;
    --muted: #8293a5;
    --line: #e8eef3;
    --white: #ffffff;
    --page: #f6faff;
    --shadow: 0 12px 35px rgba(35, 91, 133, .08);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--ink);
    background: var(--page);
}

button, input, select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible, input:focus-visible {
    outline: 3px solid rgba(37,136,216,.3);
    outline-offset: 2px;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 250px;
    background: white;
    border-right: 1px solid var(--line);
    padding: 27px 18px;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: var(--ink);
    padding: 0 9px 30px;
}

.brand-symbol {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: white;
    font-family: Nunito, sans-serif;
    font-weight: 900;
    font-size: 25px;
    background: linear-gradient(140deg, #36a8ed, #2679c9);
    box-shadow: 0 7px 15px #2588d833;
}

.brand strong, .brand small {
    display: block;
}

.brand strong {
    font: 900 20px Nunito, sans-serif;
    letter-spacing: .5px;
}

.brand small {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--blue);
}

.sidebar-label {
    color: #a0adba;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 15px 12px 9px;
}

.side-nav {
    display: grid;
    gap: 5px;
}

.nav-item {
    border: 0;
    background: transparent;
    color: #718397;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 14px;
    text-align: left;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 700;
    transition: .2s;
}

.nav-item:hover {
    background: #f1f8ff;
    color: var(--blue);
}

.nav-item.active {
    color: var(--blue);
    background: #eaf5ff;
}

.sidebar-bottom {
    margin-top: auto;
}

.sidebar-note {
    padding: 17px;
    border-radius: 15px;
    background: linear-gradient(140deg, #e7f7ff, #effbf5);
    margin: 15px 0;
}

.sidebar-note span {
    font-size: 23px;
}

.sidebar-note strong {
    display: block;
    margin-top: 7px;
}

.sidebar-note p {
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
    margin-top: 5px;
}

.main-area {
    width: calc(100% - 250px);
    margin-left: 250px;
    min-width: 0;
}

.desktop-topbar {
    min-height: 105px;
    padding: 24px 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(255,255,255,.88);
    border-bottom: 1px solid var(--line);
}

.topbar-eyebrow {
    font-size: 10px;
    letter-spacing: 1.7px;
    color: var(--blue);
    font-weight: 800;
    margin-bottom: 5px;
}

.desktop-topbar h1 {
    font: 900 23px Nunito, sans-serif;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar-search {
    width: min(360px, 34vw);
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
    color: var(--muted);
}

.topbar-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
}

.avatar-button {
    border: 0;
    width: 43px;
    height: 43px;
    border-radius: 50%;
    background: var(--yellow);
    font-size: 21px;
    overflow: hidden;
    display: grid;
    place-items: center;
}

.avatar-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-header {
    display: none;
}

.page-content {
    max-width: 1500px;
    margin: auto;
    padding: 32px 38px 50px;
    min-height: 70vh;
}

.main-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 22px 38px;
    color: #9aa8b6;
    font-size: 11px;
    border-top: 1px solid var(--line);
}

.hero {
    min-height: 255px;
    padding: 38px;
    border-radius: 24px;
    background: linear-gradient(115deg, #e2f4ff, #e8fbf2 75%, #fff6df);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    overflow: hidden;
}

.hero-copy {
    max-width: 570px;
}

.hero-tag {
    display: inline-block;
    background: white;
    color: var(--green);
    border-radius: 30px;
    padding: 7px 13px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.hero h2 {
    font: 900 clamp(27px, 4vw, 42px) Nunito, sans-serif;
    line-height: 1.13;
    margin-bottom: 12px;
}

.hero p {
    color: #687f92;
    line-height: 1.7;
    font-size: 14px;
    max-width: 450px;
}

.hero-art {
    font-size: clamp(75px, 11vw, 130px);
    padding: 10px 35px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 32px 0 16px;
}

.section-heading h2 {
    font: 900 21px Nunito, sans-serif;
}

.section-heading p {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.quick-card {
    min-height: 125px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: white;
    padding: 20px;
    text-align: left;
    box-shadow: var(--shadow);
    transition: .2s;
}

.quick-card:hover, .media-card:hover {
    transform: translateY(-3px);
}

.quick-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 22px;
    margin-bottom: 10px;
}

.quick-card strong {
    display: block;
    font: 800 15px Nunito, sans-serif;
}

.quick-card small {
    color: var(--muted);
    font-size: 11px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 17px;
}

.media-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 17px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: .2s;
    min-width: 0;
}

.media-cover {
    height: 155px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, #e2f4ff, #e7f9ef);
    overflow: hidden;
    position: relative;
}

.media-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-emoji {
    font-size: 55px;
}

.media-info {
    padding: 14px;
}

.media-info h3 {
    font: 800 14px Nunito, sans-serif;
    line-height: 1.4;
    margin-bottom: 5px;
}

.media-info p {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.5;
}

.card-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    margin-top: 13px;
}

.primary-button, .secondary-button, .small-button {
    border: 0;
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 11px;
    font-weight: 800;
}

.primary-button {
    background: var(--blue);
    color: white;
}

.primary-button:hover {
    background: var(--blue-dark);
}

.secondary-button {
    background: #edf6fc;
    color: var(--blue);
}

.small-button {
    background: #f4f7fa;
    color: #6e8295;
}

.favourite-button {
    border: 0;
    background: #fff1ef;
    color: var(--coral);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    font-size: 17px;
}

.progress-track {
    height: 6px;
    border-radius: 10px;
    background: #edf1f4;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: inherit;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0;
}

.filter-chip {
    border: 1px solid var(--line);
    border-radius: 30px;
    background: white;
    color: #75899b;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 700;
}

.filter-chip.active {
    background: #e8f5ff;
    color: var(--blue);
    border-color: #cce8ff;
}

.empty-state {
    text-align: center;
    padding: 65px 20px;
    background: white;
    border-radius: 18px;
    border: 1px dashed #dce8f0;
}

.empty-state span {
    font-size: 43px;
}

.empty-state h3 {
    font: 800 20px Nunito, sans-serif;
    margin: 12px 0 5px;
}

.empty-state p {
    color: var(--muted);
    font-size: 13px;
}

.player-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #102337;
    display: none;
    color: white;
}

.player-overlay.open {
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.player-window {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f6faff;
    color: var(--ink);
}

.player-header {
    min-height: 65px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    border-bottom: 1px solid var(--line);
}

.player-back, .fullscreen-button {
    border: 0;
    border-radius: 10px;
    padding: 10px 13px;
    background: #edf6fc;
    color: var(--blue);
    font-weight: 800;
}

.player-heading {
    flex: 1;
    min-width: 0;
}

.player-heading strong, .player-heading small {
    display: block;
}

.player-heading strong {
    font: 800 14px Nunito, sans-serif;
}

.player-heading small {
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

.player-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-layout {
    width: min(1100px, 100%);
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.reader-paper {
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    padding: clamp(22px, 5vw, 55px);
    min-height: 55vh;
    overflow: auto;
    line-height: 1.9;
    font-size: 17px;
    white-space: pre-wrap;
}

.reader-paper h2 {
    font: 900 26px Nunito, sans-serif;
    margin-bottom: 20px;
}

.reader-paper p {
    margin-bottom: 18px;
}

.reader-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.reader-controls span {
    font-size: 12px;
    color: var(--muted);
}

.reader-frame {
    width: min(1100px, 100%);
    height: 100%;
    min-height: 65vh;
    border: 0;
    background: white;
    border-radius: 12px;
}

.epub-frame {
    width: min(1100px, 100%);
    height: 75vh;
    background: white;
}

.audio-stage {
    width: min(600px, 100%);
    background: white;
    padding: 35px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    text-align: center;
}

.audio-art {
    width: min(260px, 70vw);
    aspect-ratio: 1;
    border-radius: 25px;
    margin: 0 auto 25px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #e1f4ff, #e7f9ee);
    font-size: 85px;
    overflow: hidden;
}

.audio-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.audio-stage h2 {
    font: 900 23px Nunito, sans-serif;
    margin-bottom: 6px;
}

.audio-stage p {
    color: var(--muted);
    font-size: 12px;
}

.audio-stage audio {
    width: 100%;
    margin-top: 25px;
}

.video-stage {
    width: min(1200px, 100%);
}

.video-stage video {
    width: 100%;
    max-height: 75vh;
    background: #111;
    border-radius: 14px;
}

.video-caption {
    color: #6f8293;
    font-size: 13px;
    margin-top: 12px;
}

.settings-panel {
    background: white;
    border: 1px solid var(--line);
    border-radius: 17px;
    padding: 22px;
    max-width: 700px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
    border-bottom: 0;
}

.setting-row p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.setting-row input, .setting-row select {
    accent-color: var(--blue);
}

.game-panel {
    background: white;
    padding: 25px;
    border-radius: 18px;
    border: 1px solid var(--line);
    max-width: 700px;
}

.game-question {
    font: 800 20px Nunito, sans-serif;
    margin-bottom: 18px;
}

.game-answer {
    display: block;
    width: 100%;
    margin: 9px 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 13px;
    text-align: left;
    background: #fafdff;
    color: var(--ink);
}

.game-answer:hover {
    background: #eaf6ff;
    border-color: #b8dfff;
}

.mobile-nav {
    display: none;
}

body.large-text .reader-paper {
    font-size: 21px;
}

body.high-contrast {
    --ink: #101820;
    --muted: #475767;
}

body.low-data .media-cover img {
    display: none;
}

@media (max-width: 1100px) {
    .media-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .quick-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 760px) {
    .sidebar, .desktop-topbar {
        display: none;
    }

    .main-area {
        width: 100%;
        margin-left: 0;
        padding-bottom: 75px;
    }

    .mobile-header {
        height: 68px;
        padding: 10px 17px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: white;
        border-bottom: 1px solid var(--line);
    }

    .mobile-header .brand {
        padding: 0;
    }

    .mobile-header .brand-symbol {
        width: 38px;
        height: 38px;
    }

    .mobile-header .brand strong {
        font-size: 17px;
    }

    .page-content {
        padding: 18px 15px 30px;
    }

    .hero {
        min-height: 220px;
        padding: 25px 21px;
        border-radius: 19px;
    }

    .hero-art {
        padding: 0;
        font-size: 65px;
    }

    .hero h2 {
        font-size: 28px;
    }

    .hero p {
        font-size: 12px;
    }

    .media-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }

    .media-cover {
        height: 125px;
    }

    .media-info {
        padding: 11px;
    }

    .media-info h3 {
        font-size: 12px;
    }

    .card-actions {
        flex-wrap: wrap;
    }

    .quick-grid {
        gap: 10px;
    }

    .quick-card {
        padding: 14px;
        min-height: 115px;
    }

    .section-heading {
        margin-top: 25px;
    }

    .section-heading h2 {
        font-size: 18px;
    }

    .main-footer {
        padding: 18px 15px;
        font-size: 9px;
    }

    .mobile-nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 30;
        height: 67px;
        display: flex;
        justify-content: space-around;
        align-items: center;
        background: white;
        border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-nav-item {
        border: 0;
        background: transparent;
        color: #91a0ad;
        display: grid;
        justify-items: center;
        gap: 3px;
        font-size: 9px;
        font-weight: 700;
    }

    .mobile-nav-item span {
        font-size: 21px;
    }

    .mobile-nav-item.active {
        color: var(--blue);
    }

    .player-header {
        padding: 10px;
        min-height: 58px;
    }

    .player-back, .fullscreen-button {
        padding: 9px 10px;
        font-size: 11px;
    }

    .player-content {
        padding: 12px;
    }

    .reader-paper {
        font-size: 15px;
        min-height: 60vh;
        padding: 22px;
    }

    .reader-frame {
        min-height: 70vh;
    }

    .audio-stage {
        padding: 22px;
    }

    .audio-art {
        width: 190px;
    }

    .video-stage video {
        max-height: 65vh;
    }
}

@media (max-width: 380px) {
    .media-grid {
        grid-template-columns: 1fr;
    }

    .media-cover {
        height: 170px;
    }

    .hero-art {
        display: none;
    }
}

/* Real fullscreen mode */
.player-window:fullscreen {
    width: 100vw;
    height: 100vh;
    background: #f6faff;
}

.player-window:fullscreen .player-content {
    padding: 20px;
}

.player-window:fullscreen .reader-paper {
    min-height: 70vh;
}

.player-window:fullscreen .video-stage video {
    max-height: 82vh;
}

.player-window:fullscreen .audio-art {
    width: min(320px, 35vh);
}

@media (display-mode: standalone) {
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
