/* Nauka zdalna — pokój wideo + czat */
.pi-remote {
    --pi-remote-stage: #071422;
    --pi-remote-tile: #0d2238;
    border-radius: var(--pi-radius, 16px);
    overflow: hidden;
    background: var(--pi-card-bg, #fff);
    border: 1px solid var(--pi-border, rgba(6, 26, 51, 0.12));
}
.pi-remote-disabled,
.pi-remote-lobby {
    padding: 36px 28px;
    text-align: center;
}
.pi-remote-disabled__ico { font-size: 42px; margin-bottom: 8px; }
.pi-remote-disabled h3,
.pi-remote-lobby h3 {
    margin: 0 0 10px;
    font-size: 1.25rem;
    color: var(--pi-text, #061a33);
}
.pi-remote-disabled p,
.pi-remote-lobby p {
    margin: 0 auto 14px;
    max-width: 520px;
    color: var(--pi-muted, #5a6474);
    line-height: 1.5;
}
.pi-remote-lobby__hint { font-size: 13px; }
.pi-remote-presence {
    max-width: 440px;
    margin: 0 auto 20px;
    text-align: left;
    background: var(--pi-surface2, #f7f5f0);
    border: 1px solid var(--pi-border, rgba(6, 26, 51, 0.12));
    border-radius: 14px;
    padding: 14px 16px;
}
.pi-remote-presence__title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pi-muted, #5a6474);
    margin-bottom: 8px;
}
.pi-remote-presence__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pi-remote-presence__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--pi-border, rgba(6, 26, 51, 0.12));
    font-size: 14px;
}
.pi-remote-presence__name { font-weight: 700; color: var(--pi-text, #061a33); }
.pi-remote-presence__state {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.pi-remote-presence__item.is-wait .pi-remote-presence__state {
    color: #9a6b2d;
    background: rgba(154, 107, 45, 0.12);
}
.pi-remote-presence__item.is-on .pi-remote-presence__state {
    color: #2d6a4f;
    background: rgba(45, 106, 79, 0.14);
}
.pi-remote-presence__summary {
    margin: 10px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--pi-muted, #5a6474);
}
.pi-remote-presence__summary.is-on { color: #2d6a4f; font-weight: 600; }
.pi-remote-error {
    margin: 14px 0 0;
    color: var(--pi-red, #b42318);
    font-size: 14px;
}

.pi-remote-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 340px);
    grid-template-rows: minmax(0, 1fr) auto;
    background: var(--pi-remote-stage);
    height: min(78vh, 720px);
    min-height: 480px;
    max-height: min(78vh, 820px);
    overflow: hidden;
}
.pi-remote-videos {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    z-index: 1;
    align-self: stretch;
    justify-self: stretch;
    width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    background: #050e18;
}
.pi-remote-who {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 72px);
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(6, 26, 51, 0.78);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: blur(8px);
}
.pi-remote-stage:fullscreen .pi-remote-videos,
.pi-remote-stage:-webkit-full-screen .pi-remote-videos,
.pi-remote.is-fs-fallback .pi-remote-videos {
    min-height: 0;
}
.pi-remote-who.is-on {
    background: rgba(45, 106, 79, 0.88);
}
.pi-remote-fs-fab {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    background: rgba(6, 26, 51, 0.78);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
}
.pi-remote-fs-fab:hover,
.pi-remote-fs-fab.is-on {
    background: rgba(201, 162, 77, 0.88);
    border-color: rgba(201, 162, 77, 0.9);
}
.pi-remote-fs-fab .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.pi-remote .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.pi-remote-stage:fullscreen,
.pi-remote-stage:-webkit-full-screen {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background: var(--pi-remote-stage);
}
.pi-remote-who__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #c9a24d;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(201, 162, 77, 0.25);
}
.pi-remote-who__dot.is-on {
    background: #6ee7b7;
    box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.28);
    animation: pi-remote-pulse 1.6s ease-out infinite;
}
@keyframes pi-remote-pulse {
    0% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(110, 231, 183, 0); }
    100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0); }
}
.pi-remote-tile {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
.pi-remote-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #050e18;
}
.pi-remote-tile--remote video {
    object-fit: contain;
}
.pi-remote-tile--local {
    inset: auto 16px 16px auto;
    width: min(28%, 220px);
    height: auto;
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(201, 162, 77, 0.7);
    z-index: 2;
}
.pi-remote-tile--local video.is-mirrored { transform: scaleX(-1); }
.pi-remote-ctrl.is-on#pi-remote-mic-btn {
    background: rgba(22, 101, 52, 0.85);
    border-color: #6ee7b7;
}
.pi-remote-ctrl.is-off#pi-remote-mic-btn {
    opacity: 1;
    text-decoration: none;
    background: rgba(127, 29, 29, 0.85);
    border-color: #fca5a5;
}
.pi-remote-tile__label {
    position: absolute;
    left: 10px;
    bottom: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(6, 26, 51, 0.72);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.pi-remote-tile__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.72);
    font-size: 15px;
    background:
        radial-gradient(circle at 50% 40%, rgba(201, 162, 77, 0.18), transparent 55%),
        var(--pi-remote-tile);
}
.pi-remote-tile__placeholder.is-hidden { display: none; }

.pi-remote-side {
    grid-column: 2;
    grid-row: 1 / span 2;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    background: #0a1a2c;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.pi-remote-chat {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.pi-remote-chat__head {
    flex: 0 0 auto;
    padding: 12px 14px;
    font-weight: 700;
    font-size: 13px;
    color: #f4efe4;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.pi-remote-chat__log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pi-remote-msg {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #eef3f8;
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}
.pi-remote-msg.is-me {
    background: rgba(201, 162, 77, 0.22);
    align-self: flex-end;
}
.pi-remote-msg > span:not(.pi-remote-msg__who) {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.pi-remote-msg__who {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #c9a24d;
    margin-bottom: 2px;
}
.pi-remote-chat__form {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.pi-remote-chat__form input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit;
}
.pi-remote-chat__form input::placeholder { color: rgba(255, 255, 255, 0.45); }

.pi-remote-bar {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.35);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.pi-remote-bar__status {
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
}
.pi-remote-bar__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.pi-remote-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 999px;
    padding: 8px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.pi-remote-ctrl.is-on {
    background: rgba(201, 162, 77, 0.28);
    border-color: rgba(201, 162, 77, 0.55);
}
.pi-remote-ctrl.is-off {
    opacity: 0.72;
    text-decoration: line-through;
}
.pi-remote-ctrl--hang {
    background: #b42318;
    border-color: #b42318;
}
.pi-remote-ctrl--hang:hover { filter: brightness(1.08); }

@media (max-width: 860px) {
    .pi-remote-stage {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto minmax(140px, 32%);
        height: min(85vh, 680px);
        min-height: 460px;
        max-height: min(85vh, 680px);
    }
    .pi-remote-videos {
        min-height: 0;
    }
    .pi-remote-side {
        grid-column: 1;
        grid-row: 3;
        border-left: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        min-height: 0;
        height: auto;
        max-height: min(32vh, 280px);
    }
    .pi-remote-bar { grid-column: 1; grid-row: 2; }
    .pi-remote-tile--local {
        width: min(38%, 160px);
        right: 10px;
        bottom: 10px;
    }
}

/* Pełny ekran: wideo + czat stale po prawej */
html.pi-remote-fs-lock,
body.pi-remote-fs-lock {
    overflow: hidden !important;
    overscroll-behavior: none;
}
body.pi-remote-fs-lock .ls-header,
body.pi-remote-fs-lock .ls-site-footer,
body.pi-remote-fs-lock .ls-contact-strip,
body.pi-remote-fs-lock .ls-footer-legal,
body.pi-remote-fs-lock .ls-saas-footer,
body.pi-remote-fs-lock .pi-fe-tabs-wrap,
body.pi-remote-fs-lock .pi-fe-mobile-nav,
body.pi-remote-fs-lock .pi-fe-header,
body.pi-remote-fs-lock .pi-fe-stats,
body.pi-remote-fs-lock .pi-fe-alert,
body.pi-remote-fs-lock .pi-teacher-portal-bar,
body.pi-remote-fs-lock .pi-admin-header,
body.pi-remote-fs-lock .sp-header,
body.pi-remote-fs-lock .sp-footer,
body.pi-remote-fs-lock .sp-topbar,
body.pi-remote-fs-lock .sp-map {
    display: none !important;
}
.pi-remote.is-fs-fallback {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    width: 100%;
    width: 100dvw;
    height: 100%;
    height: 100dvh;
    height: 100svh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: #050e18;
    box-sizing: border-box;
}
.pi-remote.is-fs-fallback .pi-remote-lobby,
.pi-remote.is-fs-fallback .pi-remote-disabled {
    display: none !important;
}
.pi-remote.is-fs-fallback .pi-remote-stage,
.pi-remote-stage:fullscreen,
.pi-remote-stage:-webkit-full-screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 32vw, 360px);
    grid-template-rows: minmax(0, 1fr) auto;
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    background: var(--pi-remote-stage);
}
.pi-remote.is-fs-fallback .pi-remote-videos,
.pi-remote-stage:fullscreen .pi-remote-videos,
.pi-remote-stage:-webkit-full-screen .pi-remote-videos {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    min-height: 0;
    height: auto;
    width: auto;
    aspect-ratio: auto;
}
.pi-remote.is-fs-fallback .pi-remote-bar,
.pi-remote-stage:fullscreen .pi-remote-bar,
.pi-remote-stage:-webkit-full-screen .pi-remote-bar {
    grid-column: 1;
    grid-row: 2;
    flex: none;
    width: auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
}
.pi-remote.is-fs-fallback .pi-remote-bar__status,
.pi-remote-stage:fullscreen .pi-remote-bar__status,
.pi-remote-stage:-webkit-full-screen .pi-remote-bar__status {
    display: none;
}
.pi-remote.is-fs-fallback .pi-remote-bar__controls,
.pi-remote-stage:fullscreen .pi-remote-bar__controls,
.pi-remote-stage:-webkit-full-screen .pi-remote-bar__controls {
    flex-wrap: nowrap;
    width: 100%;
    justify-content: center;
}
.pi-remote.is-fs-fallback .pi-remote-ctrl,
.pi-remote-stage:fullscreen .pi-remote-ctrl,
.pi-remote-stage:-webkit-full-screen .pi-remote-ctrl {
    flex: 0 0 auto;
    padding: 10px 12px;
    min-height: 44px;
}
.pi-remote.is-fs-fallback #pi-remote-mic-btn-txt,
.pi-remote-stage:fullscreen #pi-remote-mic-btn-txt,
.pi-remote-stage:-webkit-full-screen #pi-remote-mic-btn-txt {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.pi-remote.is-fs-fallback .pi-remote-fs-fab,
.pi-remote-stage:fullscreen .pi-remote-fs-fab,
.pi-remote-stage:-webkit-full-screen .pi-remote-fs-fab {
    display: none;
}
.pi-remote.is-fs-fallback .pi-remote-side,
.pi-remote-stage:fullscreen .pi-remote-side,
.pi-remote-stage:-webkit-full-screen .pi-remote-side {
    display: flex;
    flex-direction: column;
    grid-column: 2;
    grid-row: 1 / span 2;
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    top: auto;
    z-index: 2;
    width: auto;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    border-top: 0;
    border-radius: 0;
    background: #0a1a2c;
    overflow: hidden;
}
.pi-remote.is-fs-fallback .pi-remote-chat,
.pi-remote-stage:fullscreen .pi-remote-chat,
.pi-remote-stage:-webkit-full-screen .pi-remote-chat {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.pi-remote.is-fs-fallback .pi-remote-chat__log,
.pi-remote-stage:fullscreen .pi-remote-chat__log,
.pi-remote-stage:-webkit-full-screen .pi-remote-chat__log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.pi-remote.is-fs-fallback .pi-remote-tile--local {
    width: min(34vw, 140px);
    right: 10px;
    bottom: 10px;
}

@media (max-width: 860px) {
    .pi-remote.is-fs-fallback .pi-remote-stage,
    .pi-remote-stage:fullscreen,
    .pi-remote-stage:-webkit-full-screen {
        grid-template-columns: minmax(0, 1fr) clamp(240px, 38vw, 320px);
        grid-template-rows: minmax(0, 1fr) auto;
    }
    .pi-remote.is-fs-fallback .pi-remote-side,
    .pi-remote-stage:fullscreen .pi-remote-side,
    .pi-remote-stage:-webkit-full-screen .pi-remote-side {
        grid-column: 2;
        grid-row: 1 / span 2;
        height: 100%;
        max-height: 100%;
        border-left: 1px solid rgba(255, 255, 255, 0.12);
        border-top: 0;
    }
    .pi-remote.is-fs-fallback .pi-remote-bar,
    .pi-remote-stage:fullscreen .pi-remote-bar,
    .pi-remote-stage:-webkit-full-screen .pi-remote-bar {
        grid-column: 1;
        grid-row: 2;
    }
}

@media (max-width: 640px) {
    .pi-remote.is-fs-fallback .pi-remote-stage,
    .pi-remote-stage:fullscreen,
    .pi-remote-stage:-webkit-full-screen {
        grid-template-columns: minmax(0, 1fr) clamp(220px, 42vw, 300px);
    }
}

/* Modal: lektor czeka w pokoju (panel ucznia) */
body.pi-remote-invite-open {
    overflow: hidden;
}
.pi-remote-invite {
    position: fixed;
    inset: 0;
    z-index: 2147482000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.pi-remote-invite[hidden] {
    display: none !important;
}
.pi-remote-invite__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 26, 51, 0.62);
    backdrop-filter: blur(4px);
}
.pi-remote-invite__box {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    padding: 28px 26px 24px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--pi-border, rgba(6, 26, 51, 0.12));
    box-shadow: 0 18px 48px rgba(6, 26, 51, 0.22);
    text-align: center;
}
.pi-remote-invite__ico {
    font-size: 42px;
    line-height: 1;
    margin-bottom: 10px;
}
.pi-remote-invite__title {
    margin: 0 0 10px;
    font-size: 1.25rem;
    color: var(--pi-text, #061a33);
}
.pi-remote-invite__text {
    margin: 0 0 22px;
    font-size: 15px;
    line-height: 1.55;
    color: var(--pi-muted, #5a6474);
}
.pi-remote-invite__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
.pi-remote-invite__later {
    min-width: 120px;
}
.pi-remote-invite__actions .pi-btn-primary {
    min-width: 160px;
}
@media (max-width: 480px) {
    .pi-remote-invite__actions {
        flex-direction: column;
    }
    .pi-remote-invite__actions .pi-btn {
        width: 100%;
    }
}

/* Historia czatu pod oknem LIVE */
.pi-remote-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.pi-remote-archive {
    margin-top: 0;
    padding: 18px 20px 22px;
    border-top: 1px solid var(--pi-border, rgba(6, 26, 51, 0.12));
    background: var(--pi-surface2, #f7f5f0);
}
.pi-remote-archive__title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    color: var(--pi-text, #061a33);
}
.pi-remote-archive__hint {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.5;
}
.pi-remote-archive__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pi-remote-archive__loading,
.pi-remote-archive__empty {
    margin: 0;
    font-size: 13px;
}
.pi-remote-archive-item {
    border: 1px solid var(--pi-border, rgba(6, 26, 51, 0.12));
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.pi-remote-archive-item__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    color: var(--pi-text, #061a33);
}
.pi-remote-archive-item__summary::-webkit-details-marker {
    display: none;
}
.pi-remote-archive-item__summary::before {
    content: '▸';
    margin-right: 8px;
    color: var(--pi-muted, #5a6474);
    transition: transform 0.15s ease;
}
.pi-remote-archive-item[open] .pi-remote-archive-item__summary::before {
    transform: rotate(90deg);
}
.pi-remote-archive-item__title {
    flex: 1 1 auto;
    min-width: 0;
}
.pi-remote-archive-item__meta {
    font-size: 12px;
    font-weight: 500;
}
.pi-remote-archive-item__body {
    padding: 0 12px 12px;
    max-height: 280px;
    overflow-y: auto;
    border-top: 1px solid rgba(6, 26, 51, 0.08);
    background: #0a1a2c;
}
.pi-remote-archive-item__body .pi-remote-msg {
    margin-top: 8px;
}
.pi-remote.is-fs-fallback + .pi-remote-archive {
    display: none;
}
