:root {
    --fenek-orange: #f97316;
    --fenek-orange-light: #ffedd5;
    --text-slate: #1e293b;
    --bg-white: #ffffff;
    --app-max-width: 450px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

#page-scroll-hint { display: none; }

/* Dyplom: medalion ikony + linia-ornament + imię pismem odręcznym (zastępuje dawny
   podpis "— Fenek" — dziecko "podpisuje" dyplom swoim imieniem, linia pod imieniem
   pełni tę samą rolę wizualną co linia do podpisu). */
.diploma-icon-badge {
    width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 12px;
    background: radial-gradient(circle at 32% 28%, #ffedd5, #fdba74 60%, var(--fenek-orange) 100%);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 4px #fff, 0 6px 16px rgba(194,65,12,0.28);
}
.diploma-icon-badge #diploma-render-icon { font-size: 38px; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.18)); }
.diploma-ornament { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.diploma-ornament .line { flex: 1; height: 1px; background: #fed7aa; }
.diploma-ornament .diamond { width: 6px; height: 6px; background: var(--fenek-orange); transform: rotate(45deg); flex-shrink: 0; }
.diploma-name-handwritten {
    font-family: 'Caveat', cursive; font-weight: 700; font-size: 52px; line-height: 1.2;
    text-transform: capitalize;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: #1a1a1a;
    color: var(--text-slate);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* APP SHELL */
#app-container {
    width: 100vw;
    max-width: var(--app-max-width);
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    background-color: var(--bg-white);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

.inline-home {
    position: absolute; top: 15px; right: 15px; width: 44px; height: 44px; background: white;
    border-radius: 12px; display: flex; justify-content: center; align-items: center;
    text-decoration: none; font-size: 24px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 5000; border: 1px solid #eee;
}

/* SCROLL ENGINE */
#scroll-area {
    height: 100%; width: 100%; overflow-y: scroll; scroll-snap-type: y mandatory;
    scrollbar-width: none; touch-action: pan-y;
}
#scroll-area::-webkit-scrollbar { display: none; }

.page {
    height: 100%; width: 100%; scroll-snap-align: start; scroll-snap-stop: always;
    position: relative; display: flex; flex-direction: column;
}

/* PROGRESS BAR */
#progress-container {
    position: absolute; top: 15px; left: 15px; right: 70px; height: 4px;
    display: flex; gap: 4px; z-index: 50; opacity: 0; transition: opacity 0.3s ease;
}
#progress-container.visible { opacity: 1; }
.progress-segment {
    flex: 1; background: rgba(0, 0, 0, 0.1); border-radius: 2px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%; background: #FF8C42; transition: width 0.3s ease;
}

/* IMAGE AREA */
.image-area {
    height: 60%; width: 100%; background-size: cover; background-position: top center;
    position: relative; flex-shrink: 0;
}
@media (min-width: 768px) {
    .image-area img.title-cover {
        object-fit: contain !important;
        object-position: center bottom !important;
    }
}

/* WATERMARK */
.watermark-container {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; z-index: 30;
}
.wm-corner {
    position: absolute; font-size: 10px; font-weight: 900;
    color: rgba(200, 200, 200, 0.15); text-transform: uppercase;
    top: 15px; pointer-events: none; z-index: 31;
}
.wm-right { right: 5px; }
.wm-left { left: 10px; }

/* CONTENT AREA - STABILNY MARGINES */
.content-area {
    height: 50%;
    background: #fff;
    margin-top: -70px;
    border-radius: 40px 40px 0 0;
    padding: 36px 25px 24px 25px;
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    overflow-y: hidden;
}

.content-text {
    font-weight: 900;
    color: #1e293b;
    line-height: 1.2;
    font-size: clamp(15px, 4.6vw, 19px);
    padding-right: 75px;
}

/* SIDEBAR */
#sidebar {
    position: absolute; right: 15px;
    top: 55%;
    display: flex; flex-direction: column; gap: 8px; z-index: 40;
    transform: translateX(100px); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#sidebar.visible { transform: translateX(0); }

.sidebar-btn {
    width: 52px; height: 52px; border-radius: 50%; background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15); border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: var(--fenek-orange); cursor: pointer;
    transition: transform 0.1s;
}
.sidebar-btn:active { transform: scale(0.95); }
.sidebar-btn.like-anim { animation: heartBeat 0.5s ease-in-out; color: #ef4444; }

@keyframes heartBeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.heart-fx { position: fixed; color: #ff4d4d; font-size: 32px; pointer-events: none; z-index: 1000; animation: heart-fly 0.6s linear forwards; }
@keyframes heart-fly { 0% { transform: scale(1); opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(0.5); opacity: 0; } }

.heart-flood { position: fixed; pointer-events: none; z-index: 9999; font-size: var(--hs, 28px); animation: heart-flood 1.0s ease-out forwards; }
@keyframes heart-flood { 0% { transform: translate(0,0) scale(0); opacity: 1; } 60% { opacity: 1; } 100% { transform: translate(var(--tx),var(--ty)) scale(0.9); opacity: 0; } }

/* OCHRONA UX AUDIOBOOKA */
#unlock-progress {
    position: fixed; bottom: 250px; left: 50%; transform: translateX(-50%);
    z-index: 99999; background: rgba(30, 41, 59, 0.9); padding: 12px 24px;
    border-radius: 50px; color: white; font-size: 11px; font-weight: 900;
    pointer-events: none; opacity: 0; transition: opacity 0.2s, transform 0.2s;
    display: flex; align-items: center; gap: 12px; backdrop-filter: blur(8px);
    text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
#unlock-progress.visible { opacity: 1; transform: translateX(-50%) translateY(10px); }
.progress-ring {
    width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.2);
    border-top: 3px solid #FF8C42; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* LOADER */
#main-loader {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-white);
    z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
}

/* MailerLite – kompaktowy wygląd w czytniku */
.ml-embedded { width: 100% !important; }
.ml-embedded .ml-form-embedWrapper { padding: 0 !important; background: transparent !important; box-shadow: none !important; border: none !important; }
.ml-embedded .ml-form-embedBody { padding: 0 !important; }
.ml-embedded input[type="email"] { border-radius: 12px !important; font-family: 'Nunito', sans-serif !important; font-weight: 700 !important; }
.ml-embedded button[type="submit"] { border-radius: 12px !important; font-family: 'Nunito', sans-serif !important; font-weight: 900 !important; background: linear-gradient(135deg, #f97316 0%, #ed64a6 100%) !important; }

/* ============================================
   DESKTOP LAYOUT (≥1024px) — panele boczne
   Poniżej 1024px nic w tej sekcji się nie stosuje —
   mobile/tablet zostają dokładnie jak dziś.
   ============================================ */
.side-panel { display: none; }

@media (min-width: 1024px) {
    body {
        overflow: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 28px;
        min-height: 100vh;
        padding: 32px 20px;
        background-color: #f4f3fb;
        /* domyślny gradient — nadpisywany tłem kategorii (pasek na dole + tonowanie kolorem
           okładki) przez App.desktopPanels.applyBackground(), patrz JS */
        background-image:
            radial-gradient(circle at 12% 10%, rgba(79,70,229,0.07), transparent 45%),
            radial-gradient(circle at 88% 90%, rgba(249,115,22,0.08), transparent 45%);
        background-position: center, center;
        background-size: cover, cover;
        background-repeat: no-repeat, no-repeat;
    }

    /* Karta czytnika: ograniczona wysokość zamiast 100vh, proporcja telefonu */
    #app-container {
        width: 400px;
        max-width: 400px;
        height: min(820px, 88vh);
        margin: 0;
        border-radius: 32px;
        box-shadow: 0 30px 70px -24px rgba(20,18,50,0.42), 0 6px 18px rgba(20,18,50,0.16);
        flex-shrink: 0;
    }

    /* Bezpiecznik: przy niższych oknach sztywny podział 60/50% zostawia za mało miejsca na
       tekst + przyciski danej strony (dziś: overflow-y:hidden na mobile, gdzie zawsze się mieści
       na prawdziwym telefonie) — na desktopie pozwól przewinąć TĘ jedną stronę zamiast ucinać
       jej dół, zamiast dalej ograniczać widoczność. Pasek scrolla ukryty, spójnie z resztą UI. */
    .content-area {
        /* !important świadomie: strona tytułowa (special:"title") ustawia overflow-y:hidden
           inline stylem z JS (App.render.buildStory) — na mobile to zamierzone, na desktopie
           musimy je nadpisać, a inline style ma wyższy priorytet niż zwykła klasa. */
        overflow-y: auto !important;
        scrollbar-width: none;
    }
    .content-area::-webkit-scrollbar { display: none; }

    /* Podpowiedź "przewiń dalej" — jedyna wskazówka nawigacji na desktopie, gdzie scroll myszką
       nad kartą nie jest oczywisty dla kogoś, kto nie budował tego readera. Widoczna WYŁĄCZNIE
       na pierwszej stronie treści (index 1) — jednorazowo, nie na każdej stronie (JS:
       App.desktopPanels.updateNavHint). Statyczna plakietka, nie przycisk — myszka/strzałki
       działają same, to tylko informacja. Pełny ciemny kolor (nie przezroczysty jak poprzednia
       wersja) — poprzedni jasny krążek ginął na jasnych fragmentach ilustracji. */
    #page-scroll-hint {
        display: block;
        position: absolute;
        left: 50%;
        /* Styk obrazka i karty tekstu (.image-area ma zawsze height:60%, stałe niezależnie od
           długości tekstu na stronie) — NIE dół karty: tam różna ilość tekstu sprawiała, że
           poprzedni przycisk nachodził na treść i ginął w niej. Na styku zawsze siedzi na
           obrazku, z dala od tekstu i od paska ciasteczek. */
        top: calc(60% - 140px);
        white-space: nowrap;
        padding: 7px 14px;
        border-radius: 999px;
        background: rgba(30,27,60,0.86);
        box-shadow: 0 4px 14px rgba(20,18,50,0.22);
        font-size: 12.5px;
        font-weight: 700;
        line-height: 1;
        color: #ffffff;
        letter-spacing: 0.01em;
        /* Wysoki z-index — informacja ma być zawsze na wierzchu, niezależnie od tego, co
           jest w danym momencie na ilustracji strony (np. warstwy z .image-area). Bezpieczne
           dla scrolla kółkiem myszy: pointer-events:none oznacza, że ten element NIGDY nie
           przechwytuje żadnych zdarzeń myszy, więc nie może niczego zablokować. */
        z-index: 500;
        pointer-events: none;
        border: none;
        opacity: 1;
        transform: translate(-50%, 0);
        transition: opacity 0.25s ease, transform 0.25s ease;
    }
    /* Świadomie BEZ ciągłej animacji (odbijanie w kółko kłóciłoby się ze spokojnym
       charakterem readera) — tylko płynne pojawienie/zniknięcie przy zmianie strony. */
    /* Ujemny Y (w górę), zgodnie z kierunkiem ruchu stron przy przewijaniu skrolika. */
    #page-scroll-hint.hidden { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }
    .content-area::-webkit-scrollbar { display: none; }

    .side-panel {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 300px;
        flex-shrink: 0;
        height: min(820px, 88vh);
        overflow: hidden;
        padding-top: 8px;
        transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }
    #side-left { align-items: flex-end; }
    #side-right { align-items: flex-start; }

    .side-panel.collapsed { width: 44px; }

    /* Zakładka ☰ jest ZAWSZE widoczna (zwinięty i rozwinięty stan) — to jedyny
       trwały sposób ręcznego zwinięcia/rozwinięcia, więc nie może znikać. */
    .panel-content {
        display: flex; flex-direction: column; gap: 14px; width: 100%;
        overflow-y: auto; scrollbar-width: none;
        opacity: 1;
        transition: opacity 0.2s ease;
    }
    .panel-content::-webkit-scrollbar { display: none; }
    .side-panel.collapsed .panel-content { opacity: 0; pointer-events: none; }

    .panel-tab {
        width: 44px; height: 44px; border-radius: 12px;
        background: #fff; border: 1px solid #ece9fb;
        box-shadow: 0 6px 16px rgba(20,18,50,0.12);
        display: flex; align-items: center; justify-content: center;
        font-size: 18px; cursor: pointer; color: #5b5b72;
        flex-shrink: 0; padding: 0;
    }
    .panel-tab:active { transform: scale(0.95); }

    .panel-card {
        background: #fff; border: 1px solid #ece9fb; border-radius: 20px;
        padding: 20px; box-shadow: 0 10px 30px -14px rgba(20,18,50,0.16);
        width: 100%;
    }
    .panel-eyebrow {
        font-size: 10.5px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase;
        color: #8886a0; margin: 0 0 8px;
    }
    .panel-card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 900; color: #1e293b; }
    .panel-card p.desc { margin: 0; color: #5b5b72; font-size: 13px; line-height: 1.55; }

    .stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
    .stat { background: #f4f3fb; border-radius: 12px; padding: 9px 10px; }
    .stat .n { font-size: 13px; font-weight: 800; color: #1e293b; }
    .stat .l { font-size: 10px; color: #8886a0; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1px; }

    .benefit-item { display: flex; gap: 8px; padding: 7px 0; border-top: 1px solid #ece9fb; }
    .benefit-item:first-child { border-top: none; }
    .benefit-item .check { flex: none; color: #22c55e; font-weight: 900; line-height: 1.5; }
    .benefit-item p { margin: 0; font-size: 12.5px; color: #5b5b72; line-height: 1.5; }

    .discussion-item { padding: 8px 0; border-top: 1px solid #ece9fb; }
    .discussion-item:first-child { border-top: none; }
    .discussion-item p { margin: 0; font-weight: 800; color: #1e293b; font-size: 13px; }

    .credit-line { margin-top: 14px; padding-top: 12px; border-top: 1px solid #ece9fb; font-size: 11.5px; color: #8886a0; line-height: 1.6; }

    .panel-btn {
        font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 800; border-radius: 11px;
        padding: 11px 14px; border: 1px solid #ece9fb; background: #f4f3fb; color: #1e293b; cursor: pointer;
        display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    }
    .panel-btn.primary { background: linear-gradient(135deg, #f97316 0%, #ec4899 100%); color: #fff; border: none; }
    .panel-btn + .panel-btn { margin-top: 8px; }
    .panel-btn:active { transform: scale(0.98); }
    /* Materiał zablokowany (wymaga abonamentu/zakupu) — nadal klikalny, uruchamia checkout. */
    .panel-btn.locked { background: #fff; border: 1.5px dashed #d8d4f0; color: #6b6580; font-size: 12px; text-align: left; justify-content: flex-start; }
    /* Plakietka "BEZPŁATNE" przy materiałach dostępnych bez zakupu/abonamentu. */
    .dl-tag-free {
        font-size: 9px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
        color: #16a34a; background: #dcfce7; padding: 2px 7px; border-radius: 999px; flex-shrink: 0;
    }

    .qr-box { display: flex; justify-content: center; padding: 4px 0 12px; }
    .qr-box canvas { border-radius: 12px; }

    .locked-teaser { text-align: center; padding-top: 4px; }
    .locked-teaser p { margin: 0 0 10px; font-size: 12.5px; color: #5b5b72; line-height: 1.5; }
}

@media (prefers-reduced-motion: reduce) {
    .side-panel, #app-container, #page-scroll-hint { transition: none !important; }
}
