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

:root {
    --viewer-bg:
        radial-gradient(circle at top left, rgba(68, 124, 255, 0.12), transparent 24%),
        radial-gradient(circle at top right, rgba(15, 139, 141, 0.08), transparent 22%),
        linear-gradient(180deg, #eaf0f8 0%, #f4f7fb 48%, #eaf0f7 100%);
    --viewer-surface: rgba(255,255,255,0.95);
    --viewer-line: rgba(188, 198, 218, 0.46);
    --viewer-text: #19263c;
    --viewer-muted: #687a93;
    --viewer-primary: #2757ce;
    --viewer-accent: #1497a3;
}

html, body { max-width: 100%; overflow-x: hidden; }
body {
    font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
    background: var(--viewer-bg);
    color: var(--viewer-text);
}

.viewer-container { display: flex; flex-direction: column; min-height: 100vh; }

.viewer-actions { max-width: 100%; overflow-x: hidden; }

.btn-back, .btn-download, .btn-nav {
    background: rgba(39, 87, 206, 0.08);
    color: var(--viewer-primary);
    padding: 10px 16px;
    border-radius: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(39, 87, 206, 0.18);
    transition: all 0.24s;
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(29, 54, 98, 0.06);
}

.btn-back:hover, .btn-download:hover, .btn-nav:hover {
    background: linear-gradient(135deg, var(--viewer-primary), #38a9c7);
    color: white;
    transform: translateY(-1px);
}

.viewer-main {
    flex: 1;
    display: flex;
    overflow-x: hidden;
    overflow-y: visible;
    align-items: flex-start;
    min-height: 0;
    max-width: min(100%, var(--viewer-shell-width, 100%));
    width: min(100%, var(--viewer-shell-width, 100%));
    margin: 0 auto;
}

.page-viewer {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 22px;
    overflow-x: hidden;
    overflow-y: visible;
    background: transparent;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
}

.page-container {
    position: relative;
    background: #fff;
    box-shadow: 0 28px 56px rgba(14, 26, 46, 0.18);
    width: 100%;
    max-width: var(--viewer-page-width, 100%);
    margin: 0 auto;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(195, 206, 224, 0.68);
}

.page-container.page-clip-active {
    overflow: visible;
}

#pageImage { display: block; width: 100%; height: auto; max-width: none; max-height: none; }

.hotspots-layer { position: absolute; top: 0; left: 0; pointer-events: none; }

.hotspot-area {
    position: absolute;
    cursor: pointer;
    transition: all 0.3s;
    pointer-events: all;
    border-radius: 4px;
}

/* Touch devices can "stick" hover state and create horizontal overflow. */
@media (hover: none) {
    .hotspot-area { transition: opacity 0.2s; transform: none !important; }
}

@media (hover: hover) and (pointer: fine) {
    .hotspot-area:hover {
        opacity: 0.85;
        /* Avoid layout jitter: scaling hotspots makes embedded player controls hard to click */
        transform: none;
    }
}

/* Remove any chain icons or unwanted content */
.hotspot-area::before,
.hotspot-area::after {
    display: none !important;
}

.hotspot-area .fa-link,
.hotspot-area .fa-chain {
    display: none !important;
}

.media-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

.media-icon:hover {
    background: rgba(220, 53, 69, 1);
    transform: translate(-50%, -50%) scale(1.1);
    animation: none;
}

.html-content-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    padding: 5px;
    border-radius: 4px;
    font-size: 11px;
    overflow: hidden;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.yt-placeholder {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.yt-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.yt-play-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: rgba(230, 0, 0, 0.88);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yt-play-btn::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 12px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    margin-left: 2px;
}

@media (max-width: 768px) {
    .yt-play-btn {
        width: 40px;
        height: 28px;
        border-radius: 8px;
    }
    .yt-play-btn::before {
        border-left-width: 9px;
        border-top-width: 6px;
        border-bottom-width: 6px;
    }
}

@media (max-width: 768px) {
    .media-icon {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    .html-content-preview {
        font-size: 7px;
        padding: 2px;
    }
    .html-content-preview * {
        font-size: 7px !important;
        line-height: 1.1 !important;
        margin: 1px !important;
        padding: 1px !important;
    }
}

/* Thumbnail sidebar - Updated for larger thumbnails */
.viewer-controls {
    width: clamp(
        calc(220px * var(--viewer-width-factor, 1)),
        calc(30vw * var(--viewer-width-factor, 1)),
        calc(500px * var(--viewer-width-factor, 1))
    );
    background: rgba(255,255,255,0.92);
    color: var(--viewer-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    min-height: 0;
    border-left: 1px solid var(--viewer-line);
    position: sticky;
    top: 0;
    height: calc(230vh - var(--viewer-controls-top, 0px));
    max-height: calc(230vh - var(--viewer-controls-top, 0px));
    align-self: flex-start;
    box-shadow: -10px 0 32px rgba(15, 28, 52, 0.06);
    backdrop-filter: blur(18px);
}

.viewer-main.thumbnails-left .page-viewer {
    order: 2;
    justify-content: flex-start;
}

.viewer-main.thumbnails-left .viewer-controls {
    order: 1;
    border-left: none;
    border-right: 1px solid var(--viewer-line);
    box-shadow: 10px 0 32px rgba(15, 28, 52, 0.06);
}

.page-navigation {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--viewer-line);
    background: rgba(255,255,255,0.98);
    flex: 0 0 auto;
}

.page-info { font-size: 14px; font-weight: 600; text-align: center; }

.thumbnails {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(255,255,255,0.98);
}

.thumbnail {
    display: block;
    position: relative;
    border: 2px solid transparent;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.24s;
    cursor: pointer;
    background: white;
    box-shadow: 0 14px 24px rgba(16, 30, 58, 0.08);
}

.thumbnail:hover { border-color: rgba(52, 152, 219, 0.8); }

.thumbnail.active { border-color: var(--viewer-primary); box-shadow: 0 0 0 4px rgba(39, 87, 206, 0.12); }

.thumbnail img { width: 100%; display: block; }

.thumbnail span { position: absolute; bottom: 3px; right: 3px; background: rgba(0,0,0,0.7); color: white; padding: 3px 7px; border-radius: 4px; font-size: 12px; }

.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); z-index: 9999; align-items: center; justify-content: center; }

.modal.active { display: flex; }

.modal-content { background: white; border-radius: 10px; max-width: 800px; max-height: 90vh; overflow-y: auto; position: relative; margin: 20px; width: min(800px, calc(100vw - 40px)); }
.modal-content.is-wide {
    width: min(var(--reader-popup-width, 1180px), calc(100vw - 20px));
    max-width: min(var(--reader-popup-width, 1180px), calc(100vw - 20px));
    max-height: min(var(--reader-popup-height, 900px), calc(100vh - 20px));
    border-radius: 18px;
}

.modal-close { position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.5); color: white; border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 20px; z-index: 1; transition: background 0.3s; }

.modal-close:hover { background: rgba(0,0,0,0.7); }

.modal-body { padding: 40px; }
.modal-body.is-frame { padding: 12px; }
.modal-body.is-clip-preview { padding: 24px; }

.modal-body.is-frame iframe {
    width: 100%;
    min-height: min(calc(var(--reader-popup-height, 900px) - 36px), calc(100vh - 90px));
    border: none;
    border-radius: 12px;
    background: #fff;
}

.modal-body h3 { margin-bottom: 20px; }

.modal-body img { display: block; margin: 20px auto; max-width: 100%; border-radius: 5px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }

.clip-preview-shell {
    display: grid;
    gap: 18px;
    max-width: 100%;
}

.clip-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.clip-preview-header h3 {
    margin: 0 0 6px;
}

.clip-preview-header p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.clip-preview-zoom-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(148,163,184,0.24);
    color: #0f172a;
    font-weight: 700;
}

.clip-preview-stage {
    background: #f8fafc;
    border: 1px solid rgba(148,163,184,0.25);
    border-radius: 18px;
    padding: clamp(12px, 2vw, 22px);
    display: block;
    min-height: min(340px, calc(100vh - 260px));
    max-height: min(calc(var(--reader-popup-height, 900px) - 210px), calc(100vh - 210px));
    overflow: auto;
    cursor: zoom-in;
}

.clip-preview-stage.is-zoomed {
    cursor: zoom-out;
}

.clip-preview-canvas {
    width: 100%;
    min-width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 4px;
    transition: width 0.18s ease;
}

.clip-preview-stage.is-loading,
.clip-preview-stage.is-error {
    padding: 28px;
}

.clip-preview-image {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15,23,42,0.18);
    margin: 0 auto;
    transform-origin: top center;
    transition: transform 0.18s ease;
}

.clip-preview-loading,
.clip-preview-error {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
    color: #334155;
    display: grid;
    gap: 12px;
}

.clip-preview-loading i,
.clip-preview-error i {
    font-size: 34px;
}

.clip-preview-loading strong,
.clip-preview-error strong {
    font-size: 18px;
}

.clip-preview-loading span,
.clip-preview-error span {
    color: #64748b;
    line-height: 1.5;
}

.clip-preview-error button {
    justify-self: center;
    border: none;
    border-radius: 999px;
    padding: 11px 18px;
    background: #0f172a;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 768px) {
    .modal-content {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        margin: 8px;
        border-radius: 16px;
    }
    .modal-content.is-wide {
        width: calc(100vw - 12px);
        max-width: calc(100vw - 12px);
        max-height: calc(100vh - 12px);
        margin: 6px;
        border-radius: 16px;
    }
    .modal-body {
        padding: 20px;
    }
    .modal-body.is-frame {
        padding: 8px;
    }
    .modal-body.is-clip-preview {
        padding: 14px;
    }
    .modal-body.is-frame iframe {
        min-height: calc(100vh - 64px);
    }
    .clip-preview-stage {
        min-height: calc(100vh - 250px);
        max-height: calc(100vh - 220px);
        padding: 12px;
    }
    .clip-preview-image {
        max-width: 100%;
        max-height: none;
    }
    .modal-social-share {
        gap: 8px;
    }
    .modal-social-btn {
        width: 42px;
        min-width: 42px;
        max-width: 42px;
        height: 42px;
        flex-basis: 42px;
        font-size: 16px;
    }
    .modal-body * {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    .modal-body h3 {
        font-size: 18px !important;
    }
    .modal-body h4 {
        font-size: 16px !important;
    }
    .modal-body p {
        font-size: 14px !important;
    }
}

.btn-link { display: inline-block; margin-top: 20px; padding: 12px 24px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-decoration: none; border-radius: 5px; transition: opacity 0.3s; }

.btn-link:hover { opacity: 0.9; }

/* Viewer Actions Bar */
.viewer-actions {
    background: rgba(255,255,255,0.84);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 12px 28px rgba(14, 30, 62, 0.06);
    border-bottom: 1px solid rgba(205, 215, 230, 0.6);
    backdrop-filter: blur(16px);
}

.viewer-actions h2 {
    margin: 0;
    font-size: 22px;
    color: var(--viewer-text);
    letter-spacing: -0.03em;
}

/* Social Share Floating Buttons */
.social-share-float {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    display: flex;
    flex-direction: row;
    gap: 0;
    z-index: 2000;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
}

.social-btn {
    flex: 1;
    height: 52px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    text-decoration: none;
    font-size: 20px;
    box-shadow: none;
    transition: opacity 0.2s ease;
    cursor: pointer;
    border: none;
    opacity: 1;
}

.social-btn:hover { opacity: 0.88; transform: none; box-shadow: none; }

.social-btn.whatsapp  { background: #25D366; }
.social-btn.facebook  { background: #1877F2; }
.social-btn.twitter   { background: #000000; }
.social-btn.instagram { background: linear-gradient(135deg, #F58529 0%, #DD2A7B 50%, #515BD4 100%); }
.social-btn.linkedin  { background: #0A66C2; }
.social-btn.telegram  { background: #0088cc; }
.social-btn.download  { background: #2d6a27; }
.social-btn.crop      { background: #eb2525; }

/* Modal Social Share Buttons */
.modal-social-share {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.modal-social-btn {
    width: 45px;
    min-width: 45px;
    max-width: 45px;
    height: 45px;
    flex: 0 0 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.3s;
    cursor: pointer;
    border: none;
}

.modal-social-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Platform-specific colors for modal buttons */
.modal-social-btn.whatsapp { background: #25D366; }
.modal-social-btn.facebook { background: #1877F2; }
.modal-social-btn.twitter { background: #1DA1F2; }
.modal-social-btn.instagram { background: linear-gradient(45deg, #F58529, #DD2A7B, #8134AF, #515BD4); }
.modal-social-btn.linkedin { background: #0A66C2; }
.modal-social-btn.telegram { background: #0088cc; }
.modal-social-btn.download { background: #27ae60; }

.page-clip-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    pointer-events: none;
}

.page-clip-overlay.active {
    display: block;
    pointer-events: all;
}

.page-clip-overlay.active .page-clip-selection {
    pointer-events: auto;
}

.page-clip-selection {
    position: absolute;
    border: 2px solid #2f80ff;
    border-radius: 14px;
    box-shadow: 0 0 0 2000px rgba(16, 23, 42, 0.16), 0 14px 30px rgba(47, 128, 255, 0.18);
    background: rgba(47, 128, 255, 0.07);
    pointer-events: auto;
    touch-action: none;
    cursor: move;
    overflow: visible;
}

.page-clip-toolbar {
    position: absolute;
    left: 50%;
    right: auto;
    bottom: -74px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(13, 24, 45, 0.92);
    color: #fff;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
    min-width: 216px;
    z-index: 3;
    overflow: visible;
}

.page-clip-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

.page-clip-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.page-clip-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.page-clip-action {
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
}

.page-clip-action.share { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.page-clip-action.close { background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.22); }

.page-clip-menu-wrap {
    position: relative;
}

/* Speed-dial: buttons fan away from the nearest page edge */
.page-clip-share-menu {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    z-index: 10;
    pointer-events: auto;
}

.page-clip-share-preview {
    width: 132px;
    padding: 8px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.94);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.42);
    color: #e2e8f0;
    text-align: center;
}

.page-clip-share-preview img {
    width: 100%;
    max-height: 136px;
    object-fit: cover;
    display: block;
    border-radius: 10px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.08);
}

.page-clip-share-preview span {
    display: block;
    font-size: 11px;
    line-height: 1.35;
}

.page-clip-share-menu[data-direction="up"] {
    bottom: calc(100% + 10px);
    top: auto;
    flex-direction: column-reverse;
}

.page-clip-share-menu[data-direction="down"] {
    top: calc(100% + 10px);
    bottom: auto;
    flex-direction: column;
}

/* CRITICAL: override display:flex when hidden attribute is set */
.page-clip-share-menu[hidden] {
    display: none !important;
}

/* Each button animates in from the share icon position */
@keyframes clipBtnPopUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.6);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes clipBtnPopDown {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.6);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.page-clip-menu-item {
    border: none;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0,0,0,0.32);
    animation: clipBtnPopUp 0.22s ease both;
    flex-shrink: 0;
}

.page-clip-share-menu[data-direction="down"] .page-clip-menu-item {
    animation-name: clipBtnPopDown;
}

.page-clip-share-menu[data-direction="down"] .page-clip-share-preview {
    order: -1;
}

.page-clip-menu-item i {
    display: block;
    line-height: 1;
    font-size: inherit;
    pointer-events: none;
}

/* Stagger each button's animation */
.page-clip-share-menu .page-clip-menu-item:nth-child(1) { animation-delay: 0.00s; }
.page-clip-share-menu .page-clip-menu-item:nth-child(2) { animation-delay: 0.04s; }
.page-clip-share-menu .page-clip-menu-item:nth-child(3) { animation-delay: 0.08s; }
.page-clip-share-menu .page-clip-menu-item:nth-child(4) { animation-delay: 0.12s; }
.page-clip-share-menu .page-clip-menu-item:nth-child(5) { animation-delay: 0.16s; }
.page-clip-share-menu .page-clip-menu-item:nth-child(6) { animation-delay: 0.20s; }

.page-clip-menu-item:hover { transform: scale(1.12); box-shadow: 0 6px 18px rgba(0,0,0,0.38); }

.page-clip-menu-item.whatsapp { background: #25d366; }
.page-clip-menu-item.facebook { background: #1877f2; }
.page-clip-menu-item.twitter { background: #1d9bf0; }
.page-clip-menu-item.linkedin { background: #0a66c2; }
.page-clip-menu-item.download { background: #16a34a; }
.page-clip-menu-item.email { background: #64748b; }

.social-share-float.crop-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-clip-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2f80ff;
    border: 2px solid #fff;
    box-shadow: 0 4px 10px rgba(47, 128, 255, 0.28);
}

.page-clip-handle[data-dir="n"] { top: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.page-clip-handle[data-dir="s"] { bottom: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.page-clip-handle[data-dir="e"] { right: -7px; top: calc(50% - 7px); cursor: ew-resize; }
.page-clip-handle[data-dir="w"] { left: -7px; top: calc(50% - 7px); cursor: ew-resize; }
.page-clip-handle[data-dir="nw"] { top: -7px; left: -7px; cursor: nwse-resize; }
.page-clip-handle[data-dir="ne"] { top: -7px; right: -7px; cursor: nesw-resize; }
.page-clip-handle[data-dir="sw"] { bottom: -7px; left: -7px; cursor: nesw-resize; }
.page-clip-handle[data-dir="se"] { bottom: -7px; right: -7px; cursor: nwse-resize; }

@media (max-width: 768px) {
    .viewer-main { flex-direction: column; width: 100%; max-width: 100%; }
    .viewer-controls { display: none !important; } /* Hide thumbnails completely on mobile */
    .page-viewer { padding: 0; }
    #pageImage { width: 100%; }
    .page-container { width: 100vw; max-width: 100vw; border-radius: 0; border-left: none; border-right: none; }
    .footer-content { grid-template-columns: 1fr; gap: 30px; }
    .header-right { flex-wrap: wrap; }
    .icon-btn { width: 35px; height: 35px; font-size: 14px; }

    /* Move social buttons to bottom for mobile */
    /* social-share-float is now a full-width bottom bar - no mobile override needed */

    .page-clip-toolbar {
        left: 50%;
        right: auto;
        bottom: -82px;
        border-radius: 18px;
        padding: 10px;
        min-width: 196px;
        max-width: calc(100vw - 34px);
    }

    .page-clip-toolbar-actions {
        justify-content: flex-end;
        width: auto;
    }

    .page-clip-action {
        width: 34px;
        height: 34px;
    }

    .page-clip-share-menu {
        left: 50%;
        transform: translateX(-50%);
        gap: 7px;
    }

    .page-clip-share-preview {
        width: 112px;
        padding: 6px;
    }

    .page-clip-menu-item {
        width: 42px;
        height: 42px;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
}

/* YouTube modal player (used on mobile for proper controls) */
.yt-modal .modal-content {
    background: #000;
    border-radius: 12px;
    width: min(980px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow: hidden;
    margin: 12px;
}

.yt-modal .yt-frame-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.yt-modal iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.yt-modal .yt-close {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yt-modal .yt-close:active { transform: scale(0.98); }
