/* =========================================================
   🎨 科技感手繪畫布與塗鴉白板樣式 (Drawing Board CSS)
   ========================================================= */

.drawing-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(10, 15, 29, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.drawing-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.drawing-modal-container {
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    max-height: 850px;
    background: #0f172a;
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 35px rgba(0, 217, 255, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
}

.drawing-modal-overlay.active .drawing-modal-container {
    transform: scale(1);
}

/* 頂部標頭 */
.drawing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(30, 41, 59, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    box-sizing: border-box;
}

.drawing-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.drawing-title i {
    color: var(--cyan, #00d9ff);
}

.drawing-header-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
}

.drawing-header-actions .btn {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    height: 34px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    margin: 0 !important;
    transform: none !important;
}

.drawing-header-actions .btn:hover:not(:disabled) {
    transform: translateY(-1px) !important;
}

.drawing-header-actions .btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    box-shadow: none !important;
    transform: none !important;
}

/* 工具列 (Toolbar) */
.drawing-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 20px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 10;
    flex-shrink: 0;
    box-sizing: border-box;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(226, 232, 240, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(0, 217, 255, 0.15);
    color: #ffffff;
    border-color: rgba(0, 217, 255, 0.4);
}

.tool-btn.active {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.3), rgba(0, 119, 255, 0.3));
    color: var(--cyan, #00d9ff);
    border-color: var(--cyan, #00d9ff);
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.3);
}

.tool-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* 顏色選擇列 */
.color-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    transform: scale(1.2);
    border-color: #ffffff;
    box-shadow: 0 0 10px currentColor;
}

.custom-color-picker-wrap {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.4);
    cursor: pointer;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    flex-shrink: 0;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
}

.custom-color-picker-wrap:hover {
    transform: scale(1.15);
    border-color: #ffffff;
}

.custom-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: 0;
}

/* 筆刷粗細滑桿 */
.brush-size-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 6px;
}

.brush-slider {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
    accent-color: var(--cyan, #00d9ff);
    cursor: pointer;
}

.brush-size-preview {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brush-dot-preview {
    background-color: var(--cyan, #00d9ff);
    border-radius: 50%;
    transition: width 0.15s, height 0.15s;
}

/* 畫布主體區域 */
.drawing-workspace {
    flex: 1;
    position: relative;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    box-sizing: border-box;
}

/* 畫布底紙模式 */
.drawing-workspace.bg-white {
    background-color: #ffffff !important;
    background-image: none !important;
}

.drawing-workspace.bg-dark {
    background-color: #0f172a !important;
    background-image: none !important;
}

.drawing-workspace.bg-grid {
    background-color: #ffffff !important;
    background-image: linear-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px) !important;
    background-size: 20px 20px !important;
}

.drawing-workspace.bg-grid-dark {
    background-color: #0f172a !important;
    background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px) !important;
    background-size: 20px 20px !important;
}

/* 🎨 優雅柔和的透明背景 (微弱低調的灰黑微格，舒適不刺眼) */
.drawing-workspace.bg-transparent {
    background-color: #141e33 !important;
    background-image: 
        linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%), 
        linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%), 
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%) !important;
    background-size: 24px 24px !important;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0px !important;
}

#drawingCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* 底部操作欄 */
.drawing-footer {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    padding: 12px 24px !important;
    background: rgba(15, 23, 42, 0.95) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    height: 64px !important;
    min-height: 64px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 20 !important;
}

.drawing-footer-hint {
    font-size: 13px;
    color: rgba(148, 163, 184, 0.9);
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawing-footer-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.drawing-footer-actions .btn {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    height: 38px !important;
    padding: 0 20px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    transform: none !important;
    transition: all 0.2s ease !important;
}

.drawing-footer-actions .btn:hover {
    transform: translateY(-2px) !important;
}

.drawing-footer-actions .js-btn-save-drawing {
    background: linear-gradient(135deg, var(--cyan, #00d9ff), #0077ff) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 16px rgba(0, 217, 255, 0.3) !important;
}

.drawing-footer-actions .js-btn-save-drawing:hover {
    box-shadow: 0 6px 22px rgba(0, 217, 255, 0.45) !important;
}

/* 筆記內的手繪圖片微光框 */
.note-embedded-drawing {
    display: inline-block;
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(0, 217, 255, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 12px 0;
}

.note-embedded-drawing:hover {
    border-color: var(--cyan, #00d9ff);
    box-shadow: 0 8px 30px rgba(0, 217, 255, 0.35);
    transform: scale(1.01);
}

/* 圖片樣式效果相容 */
.img-shadow-tinymce,
img.img-shadow-tinymce {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.img-border-tinymce,
img.img-border-tinymce {
    border: 2px solid rgba(255, 255, 255, 0.35) !important;
    box-sizing: border-box;
}

html.light-mode .img-border-tinymce,
html.light-mode img.img-border-tinymce {
    border-color: rgba(0, 0, 0, 0.25) !important;
}

.img-round-tinymce,
img.img-round-tinymce {
    border-radius: 6px !important;
}

.img-circle-tinymce,
img.img-circle-tinymce {
    border-radius: 50% !important;
}

/* =========================================================
   📱 手機版與平板 RWD 適配 (@media max-width: 768px / 480px)
   ========================================================= */
@media (max-width: 768px) {
    .drawing-modal-overlay {
        padding: 0 !important;
    }

    .drawing-modal-container {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
    }

    /* 頂部標頭精簡化 */
    .drawing-header {
        padding: 8px 12px !important;
        height: 48px !important;
        min-height: 48px !important;
    }

    .drawing-title {
        font-size: 13px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .drawing-header-actions {
        gap: 6px !important;
    }

    .drawing-header-actions .btn {
        height: 30px !important;
        padding: 0 8px !important;
        font-size: 12px !important;
    }

    /* 手機版隱藏按鈕文字，僅保留清晰圖示 */
    .drawing-header-actions .btn span {
        display: none !important;
    }

    .drawing-header-actions .btn i {
        margin: 0 !important;
        font-size: 13px !important;
    }

    /* 工具列：手機端智慧多排緊湊佈局 (一目了然，完全不需費力左右滑動) */
    .drawing-toolbar {
        padding: 6px 10px !important;
        gap: 6px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        background: rgba(15, 23, 42, 0.98) !important;
    }

    /* 第 1 排：繪圖工具橫向自動均分 */
    .drawing-toolbar .tool-group:nth-child(1) {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        padding: 3px 6px !important;
        box-sizing: border-box !important;
        gap: 2px !important;
    }

    .drawing-toolbar .tool-group:nth-child(1) .tool-btn {
        flex: 1 1 0 !important;
        width: auto !important;
        height: 32px !important;
        min-width: 28px !important;
        font-size: 13px !important;
        padding: 0 !important;
    }

    /* 第 2 排與第 3 排：顏色與底紙/筆刷 */
    .drawing-toolbar .tool-group:nth-child(2),
    .drawing-toolbar .tool-group:nth-child(3) {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 3px 6px !important;
        box-sizing: border-box !important;
    }

    .drawing-toolbar .tool-group:nth-child(3) {
        gap: 8px !important;
    }

    .color-swatches {
        width: 100% !important;
        flex: 1 !important;
        justify-content: space-between !important;
        gap: 2px !important;
    }

    .color-swatch {
        width: 20px !important;
        height: 20px !important;
        flex-shrink: 0 !important;
    }

    .custom-color-picker-wrap {
        width: 22px !important;
        height: 22px !important;
        flex-shrink: 0 !important;
    }

    .brush-size-wrap {
        flex-shrink: 0 !important;
        padding: 0 2px !important;
    }

    .brush-slider {
        width: 60px !important;
    }

    .js-bg-select {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: 100% !important;
        max-width: none !important;
        font-size: 11px !important;
        height: 28px !important;
        padding: 2px 4px !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
    }

    /* 底部操作列 */
    .drawing-footer {
        padding: 8px 12px !important;
        height: 50px !important;
        min-height: 50px !important;
        justify-content: center !important;
    }

    .drawing-footer-hint {
        display: none !important;
    }

    .drawing-footer-actions {
        width: 100% !important;
    }

    .drawing-footer-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        height: 36px !important;
        font-size: 13px !important;
    }
}

/* 確保 SweetAlert2 彈窗高於手繪白板 Modal */
.swal2-container {
    z-index: 200000 !important;
}

/* 🎨 更多色彩與歷史顏色調色盤按鈕 */
.sn-color-picker-wrapper {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.sn-color-preview-btn {
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    background-color: #38bdf8;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    outline: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.sn-color-preview-btn:hover {
    transform: scale(1.15) !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.7) !important;
}

.sn-color-preview-btn:active {
    transform: scale(0.95) !important;
}

.sn-color-preview-btn i {
    font-size: 11px !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7) !important;
    pointer-events: none !important;
}

/* 🎨 統一色彩浮層調色盤面板（掛載至 body，fixed 定位，JS 動態設定座標） */
.sn-color-panel {
    position: fixed;
    width: 280px;
    background: #131b2c;
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), 0 0 15px rgba(56, 189, 248, 0.15);
    z-index: 300000 !important;
    display: none !important;
    backdrop-filter: blur(16px);
    box-sizing: border-box;
}

.sn-color-panel.open {
    display: block !important;
    animation: snFadeIn 0.2s ease-out;
}


@keyframes snFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.sn-color-section-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #94a3b8;
    margin-top: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sn-color-section-title:first-child {
    margin-top: 0;
}

.sn-color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}

.sn-color-cell {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

.sn-color-cell:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.sn-color-cell.active {
    border-color: #ffffff;
    transform: scale(1.12);
    box-shadow: 0 0 0 2px #00d9ff, 0 0 12px rgba(0, 217, 255, 0.8);
}

.sn-custom-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sn-custom-color-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.sn-custom-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.sn-custom-color-input::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
}

.sn-custom-hex-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    outline: none;
}

.sn-custom-save-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sn-custom-save-btn:hover {
    background: #38bdf8;
    color: #0f172a;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
    transform: scale(1.08);
}


.sn-history-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    min-height: 32px;
}

.sn-history-dot {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.sn-history-dot:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.sn-history-dot.active {
    border-color: #ffffff;
    transform: scale(1.12);
    box-shadow: 0 0 0 2px #00d9ff, 0 0 12px rgba(0, 217, 255, 0.8);
}


/* ⭕ 橡皮擦動態光暈指示圈 (全域通用) */
.sn-eraser-ring {
    position: fixed !important;
    pointer-events: none !important;
    border-radius: 50% !important;
    border: 2px solid #00d9ff !important;
    background: rgba(0, 217, 255, 0.22) !important;
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.6), inset 0 0 8px rgba(0, 217, 255, 0.35) !important;
    transform: translate(-50%, -50%) !important;
    display: none;
    z-index: 2147483647 !important;
    will-change: left, top, width, height;
}

/* 🗑️ 選中圖形底部浮動紅色垃圾桶按鈕 (全域通用) */
.sn-floating-obj-toolbar {
    position: fixed !important;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2147483647 !important;
    transform: translate(-50%, 0) !important;
    pointer-events: auto !important;
}

.sn-float-del-btn {
    width: 32px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(239, 68, 68, 0.9) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
    color: #ffffff !important;
    border-radius: 50% !important;
    font-size: 0.85rem !important;
    cursor: pointer !important;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45), 0 2px 6px rgba(0, 0, 0, 0.6) !important;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.sn-float-del-btn:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    transform: scale(1.15) !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.75) !important;
}

/* 🛠️ Samsung Note 手繪畫布與 PDF 標註器容器 (一般模式) */
.samsung-note-wrapper,
.sn-canvas-wrapper,
.pdf-annotator-wrapper {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    background: #090d16 !important;
    overflow: hidden !important;
    position: relative !important;
    box-sizing: border-box !important;
}

/* 🛠️ 頂部工具列 (橫向 Flex 單行不折行、緊湊磨砂玻璃、支援橫向滑動但隱藏滾輪) */
.sn-toolbar,
.pdf-toolbar {
    position: sticky !important;
    top: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 6px 10px !important;
    background: rgba(15, 23, 42, 0.95) !important;
    border-bottom: 1px solid rgba(56, 189, 248, 0.2) !important;
    backdrop-filter: blur(12px) !important;
    flex-shrink: 0 !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(56, 189, 248, 0.45) rgba(15, 23, 42, 0.6) !important;
    z-index: 100 !important;
    box-sizing: border-box !important;
}

/* 🎡 頂部工具列橫向滾動條 (平滑細緻、隨滑鼠滾輪橫向捲動) */
.sn-toolbar::-webkit-scrollbar,
.pdf-toolbar::-webkit-scrollbar {
    display: block !important;
    height: 5px !important;
    background: rgba(15, 23, 42, 0.6) !important;
}

.sn-toolbar::-webkit-scrollbar-track,
.pdf-toolbar::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5) !important;
    border-radius: 3px !important;
}

.sn-toolbar::-webkit-scrollbar-thumb,
.pdf-toolbar::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.45) !important;
    border-radius: 3px !important;
    transition: background-color 0.2s ease !important;
}

.sn-toolbar::-webkit-scrollbar-thumb:hover,
.pdf-toolbar::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.8) !important;
}

.sn-tool-group,
.pdf-page-controls,
.pdf-zoom-controls,
.hw-zoom-controls,
.sn-actions-group {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 2px !important;
    flex-shrink: 0 !important;
}

.sn-divider {
    width: 1px !important;
    height: 18px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    margin: 0 2px !important;
    flex-shrink: 0 !important;
}

/* 🛠️ 通用工具列按鈕樣式 (精緻 34x34) */
.sn-tool-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 7px !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    color: rgba(226, 232, 240, 0.85) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    outline: none !important;
    user-select: none !important;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.sn-tool-btn:focus,
.sn-tool-btn:focus-visible {
    outline: none !important;
}

.sn-tool-btn:hover {
    background: rgba(0, 217, 255, 0.15) !important;
    color: #ffffff !important;
    border-color: rgba(0, 217, 255, 0.4) !important;
}

.sn-tool-btn.active {
    background: rgba(56, 189, 248, 0.18) !important;
    color: #38bdf8 !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2) !important;
}

/* ✍️ 平板專用：防手掌誤觸 (Stylus Only) 啟用狀態高亮 */
.sn-tool-btn.stylus-only-active {
    background: rgba(16, 185, 129, 0.22) !important;
    color: #10b981 !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4) !important;
}

/* ↺ 恢復上一步與 ↻ 恢復下一步按鈕專屬樣式 (常駐顯眼) */
.sn-tool-btn.sn-undo-btn,
.sn-tool-btn.sn-redo-btn,
.sn-tool-btn.js-pdf-undo-btn,
.sn-tool-btn.js-pdf-redo-btn {
    font-size: 15px !important;
    color: #e2e8f0 !important;
    transition: all 0.18s ease !important;
}

.sn-tool-btn.sn-undo-btn:not(:disabled):hover,
.sn-tool-btn.sn-redo-btn:not(:disabled):hover,
.sn-tool-btn.js-pdf-undo-btn:not(:disabled):hover,
.sn-tool-btn.js-pdf-redo-btn:not(:disabled):hover {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.15) !important;
    border-color: rgba(56, 189, 248, 0.35) !important;
}

.sn-tool-btn:disabled,
.sn-tool-btn.disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* 🎨 色彩控制群組 */
.sn-color-group {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    position: relative !important;
    flex-shrink: 0 !important;
}

.sn-color-palette {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

.sn-color-dot {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: 2px solid transparent !important;
    transition: all 0.15s ease !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
}

.sn-color-dot:hover {
    transform: scale(1.15) !important;
}

.sn-color-dot.active {
    border-color: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 8px rgba(0, 0, 0, 0.5) !important;
    transform: scale(1.15) !important;
}

/* 🔘 筆刷粗細 (五種大小快捷選擇器) */
.sn-size-group {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    background: rgba(0, 0, 0, 0.35) !important;
    padding: 2px 6px !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    flex-shrink: 0 !important;
}

.sn-size-preset-btn {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: 1.5px solid transparent !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    transition: all 0.15s ease !important;
}

.sn-size-preset-btn:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
}

.sn-size-preset-btn.active {
    background: rgba(56, 189, 248, 0.18) !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5) !important;
}

.sn-size-dot {
    border-radius: 50% !important;
    background-color: #94a3b8 !important;
    transition: background-color 0.15s ease, transform 0.15s ease !important;
    display: block !important;
}

.sn-size-preset-btn:hover .sn-size-dot {
    background-color: #e2e8f0 !important;
}

.sn-size-preset-btn.active .sn-size-dot {
    background-color: #38bdf8 !important;
    transform: scale(1.15) !important;
}

.sn-size-label {
    font-size: 0.72rem !important;
    color: #94a3b8 !important;
    min-width: 24px !important;
    text-align: center !important;
    margin-left: 2px !important;
}

/* 📄 紙張選擇下拉選單 */
.sn-paper-select {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid rgba(56, 189, 248, 0.3) !important;
    color: #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 0.76rem !important;
    outline: none !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
}


/* 📜 手繪筆記可視區與紙張底圖 (固定紙張面積，居中展示，支援放大後完整左右與上下雙向滾動) */
.sn-viewport {
    flex: 1 1 auto !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 24px 24px !important;
    display: block !important; /* 💡 採用 block 視口容器，配合子舞台 min-width:100% 與 width:max-content，徹底根除 Safari Flexbox 負坐標裁切 bug */
    background: #070b14 !important;
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box !important;
    min-height: 0 !important;
    touch-action: none !important; /* 支援平板自訂雙指縮放、平移與單指繪圖 */
    overscroll-behavior: contain !important;
}

.sn-paper-sheet {
    position: relative !important;
    margin: 0 !important; /* 💡 由父舞台 flex 負責置中，避免 margin: auto 造成放大後水平無法滾動到左側 */
    flex-shrink: 0 !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12) !important;
    border-radius: 6px !important;
    transition: background-color 0.25s ease, background-image 0.25s ease !important;
    box-sizing: border-box !important;
    touch-action: none !important;
}

.sn-paper-sheet .canvas-container {
    position: relative !important;
    margin: 0 auto !important;
    border-radius: 6px !important;
}

/* ☀️ 亮色紙張底色 (Theme Light) */
.sn-paper-sheet.theme-light,
.sn-continuous-page.theme-light {
    background-color: #ffffff !important;
}
.sn-paper-sheet.theme-light.paper-ruled,
.sn-continuous-page.theme-light.paper-ruled {
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), #cbd5e1 calc(100% - 1px)) !important;
}
.sn-paper-sheet.theme-light.paper-grid,
.sn-continuous-page.theme-light.paper-grid {
    background-image: linear-gradient(to right, rgba(148, 163, 184, 0.4) 1px, transparent 1px), linear-gradient(to bottom, rgba(148, 163, 184, 0.4) 1px, transparent 1px) !important;
    background-size: 25px 25px;
}
.sn-paper-sheet.theme-light.paper-dotted,
.sn-continuous-page.theme-light.paper-dotted {
    background-image: radial-gradient(#94a3b8 1.5px, transparent 1.5px) !important;
    background-size: 25px 25px;
}
.sn-paper-sheet.theme-light.paper-blank,
.sn-continuous-page.theme-light.paper-blank {
    background-image: none !important;
}

/* 🌙 暗色紙張底色 (Theme Dark) */
.sn-paper-sheet.theme-dark,
.sn-continuous-page.theme-dark {
    background-color: #121722 !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(56, 189, 248, 0.15) !important;
}
.sn-paper-sheet.theme-dark.paper-ruled,
.sn-continuous-page.theme-dark.paper-ruled {
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), rgba(255, 255, 255, 0.09) calc(100% - 1px)) !important;
}
.sn-paper-sheet.theme-dark.paper-grid,
.sn-continuous-page.theme-dark.paper-grid {
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 1px, transparent 1px) !important;
    background-size: 25px 25px;
}
.sn-paper-sheet.theme-dark.paper-dotted,
.sn-continuous-page.theme-dark.paper-dotted {
    background-image: radial-gradient(rgba(255, 255, 255, 0.18) 1.5px, transparent 1.5px) !important;
    background-size: 25px 25px;
}
.sn-paper-sheet.theme-dark.paper-blank,
.sn-continuous-page.theme-dark.paper-blank {
    background-image: none !important;
}

/* 📖 手繪筆記舞台 (單頁與雙頁並排模式：支援放大後左對齊無負空間溢出) */
.sn-page-stage {
    display: flex !important;
    justify-content: safe center !important;
    align-items: flex-start !important;
    min-width: 100% !important;
    width: max-content !important;
    min-height: 100% !important;
    position: relative !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    transform-origin: center top;
}

.sn-page-stage .sn-paper-sheet {
    margin: 0 auto !important; /* 💡 小於視口時自動置中，大於視口時自動靠左對齊left:0，絕不向左側負空間溢出 */
}

.sn-page-stage.view-double {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    justify-content: safe center !important;
    align-items: flex-start !important;
}

.sn-page-stage.view-double .sn-paper-sheet {
    margin: 0 !important;
}

.sn-page-stage.view-double .sn-paper-sheet:first-child {
    box-shadow: -8px 12px 36px rgba(0, 0, 0, 0.75), 1px 0 0 rgba(255, 255, 255, 0.1) !important;
}

.sn-page-stage.view-double .sn-paper-sheet:last-child {
    box-shadow: 8px 12px 36px rgba(0, 0, 0, 0.75), -1px 0 0 rgba(255, 255, 255, 0.1) !important;
}

/* 雙頁模式右頁容器控制：預設隱藏，僅在 .view-double 且非空時顯示 */
#snPaperSheetRight {
    display: none !important;
}

.sn-page-stage.view-double #snPaperSheetRight {
    display: block !important;
}

.sn-page-stage.view-double #snPaperSheetRight.is-empty {
    display: none !important;
}

/* 📜 手繪筆記多頁連續垂直捲動模式 (Continuous Scroll) */
.sn-viewport.view-continuous {
    display: block !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-x pan-y !important; /* 💡 支援水平與垂直雙向觸控平移滾動 */
    padding: 24px 20px !important;
}

.sn-viewport.view-continuous #snPageStage {
    display: none !important;
}

.sn-continuous-container {
    display: flex;
    flex-direction: column;
    align-items: safe center;
    gap: 24px;
    padding: 0 0 60px 0;
    min-width: 100%;
    width: max-content; /* 💡 隨放大的卡片寬度自適應撐大，確保 scrollWidth 完整涵蓋左右兩側 */
    min-height: 100%;
    transform-origin: center top;
    box-sizing: border-box;
}

.sn-continuous-page {
    position: relative;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    flex-shrink: 0;
    margin-left: auto !important;
    margin-right: auto !important;
    transition: box-shadow 0.2s ease;
}

.sn-continuous-page.active-focus {
    box-shadow: 0 0 0 2px #38bdf8, 0 12px 48px rgba(56, 189, 248, 0.25) !important;
}

.sn-continuous-page .sn-continuous-render-canvas,
.sn-continuous-page .sn-continuous-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.sn-continuous-page .sn-continuous-render-canvas {
    z-index: 1;
    pointer-events: none;
}

.sn-continuous-page .canvas-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 2 !important;
    border-radius: 6px;
}

.sn-continuous-page canvas {
    border-radius: 6px;
}

.sn-continuous-page .sn-page-badge {
    position: absolute;
    bottom: -22px;
    right: 0;
    font-size: 0.75rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.75);
    padding: 2px 8px;
    border-radius: 10px;
    backdrop-filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

/* 📑 PDF 專屬按鈕與控制項樣式 (緊湊精緻) */
.pdf-upload-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    height: 32px !important;
    padding: 0 10px !important;
    background: rgba(56, 189, 248, 0.12) !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
    border-radius: 5px !important;
    color: #38bdf8 !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    transition: all 0.18s ease !important;
}

.pdf-upload-btn:hover {
    background: rgba(56, 189, 248, 0.25) !important;
    color: #fff !important;
    border-color: #38bdf8 !important;
}

.pdf-page-indicator,
.sn-page-indicator {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 0 4px !important;
    font-size: 0.78rem !important;
    color: #cbd5e1 !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

/* 📱 滑動翻頁時頁碼閃爍動畫（觸控滑動觸發時短暫高亮） */
@keyframes snPageFlipPulse {
    0% { transform: scale(1); color: #38bdf8; }
    40% { transform: scale(1.25); color: #7dd3fc; text-shadow: 0 0 8px rgba(56, 189, 248, 0.8); }
    100% { transform: scale(1); color: #38bdf8; }
}
.sn-page-indicator.flip-anim .js-sn-cur-page {
    animation: snPageFlipPulse 0.4s ease-out !important;
}


.pdf-page-input {
    width: 36px !important;
    height: 24px !important;
    text-align: center !important;
    background: rgba(15, 23, 42, 0.8) !important;
    border: 1px solid rgba(56, 189, 248, 0.3) !important;
    border-radius: 4px !important;
    color: #38bdf8 !important;
    font-weight: 700 !important;
    font-size: 0.78rem !important;
    outline: none !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    transition: border-color 0.15s ease !important;
}

.pdf-page-input:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.4) !important;
}

.pdf-zoom-label,
.hw-zoom-label {
    font-size: 0.74rem !important;
    color: #94a3b8 !important;
    min-width: 32px !important;
    text-align: center !important;
    flex-shrink: 0 !important;
}


.pdf-empty-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    margin: auto;
    border: 2px dashed rgba(56, 189, 248, 0.25);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.4);
    max-width: 520px;
    width: 90%;
    transition: all 0.2s ease;
}


.pdf-empty-placeholder[style*="none"],
.pdf-empty-placeholder.is-hidden,
.pdf-empty-placeholder[hidden] {
    display: none !important;
}

/* 當空狀態存在時，強制隱藏其後的畫布舞台，絕不露出空白方塊 */
.pdf-empty-placeholder:not([style*="none"]):not(.is-hidden):not([hidden]) ~ #pdfPageStage:not([style*="flex"]),
.pdf-empty-placeholder:not([style*="none"]):not(.is-hidden):not([hidden]) ~ .pdf-page-stage:not([style*="flex"]) {
    display: none !important;
}

.pdf-empty-placeholder i {
    font-size: 3.5rem !important;
    color: #f87171 !important;
    margin-bottom: 16px !important;
}

.pdf-empty-placeholder h3 {
    color: #e2e8f0 !important;
    font-size: 1.15rem !important;
    margin-bottom: 8px !important;
}

.pdf-empty-placeholder p {
    font-size: 0.88rem !important;
    margin-bottom: 20px !important;
}


/* 🖥️ 全螢幕沉浸式模式 (適用於全頁手繪筆記與 PDF 標註器) */
:fullscreen .samsung-note-wrapper,
:-webkit-full-screen .samsung-note-wrapper,
:fullscreen .sn-canvas-wrapper,
:-webkit-full-screen .sn-canvas-wrapper,
:fullscreen .pdf-annotator-wrapper,
:-webkit-full-screen .pdf-annotator-wrapper,
.samsung-note-wrapper.is-fullscreen,
.sn-canvas-wrapper.is-fullscreen,
.pdf-annotator-wrapper.is-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 150000 !important;
    background: #070b14 !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    touch-action: none !important; /* ⚡ 全螢幕模式徹底禁止瀏覽器手勢延遲等待 */
}

body.canvas-fullscreen-active {
    overflow: hidden !important;
}

:fullscreen .sn-toolbar,
:-webkit-full-screen .sn-toolbar,
:fullscreen .pdf-toolbar,
:-webkit-full-screen .pdf-toolbar,
.samsung-note-wrapper.is-fullscreen .sn-toolbar,
.sn-canvas-wrapper.is-fullscreen .sn-toolbar,
.pdf-annotator-wrapper.is-fullscreen .pdf-toolbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background: #0f172a !important; /* ⚡ 不透明實色背景，釋放平板 GPU 模糊濾鏡負擔 */
    border-bottom: 1px solid rgba(56, 189, 248, 0.25) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6) !important;
    padding: 10px 24px !important;
    flex-shrink: 0 !important;
}

:fullscreen .sn-viewport,
:-webkit-full-screen .sn-viewport,
:fullscreen .pdf-viewport,
:-webkit-full-screen .pdf-viewport,
.samsung-note-wrapper.is-fullscreen .sn-viewport,
.sn-canvas-wrapper.is-fullscreen .sn-viewport,
.pdf-annotator-wrapper.is-fullscreen .pdf-viewport {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: #070b14 !important;
    padding: 24px 24px !important;
    display: block !important; /* ⚡ 保持 block 視口容器，徹底避免 flex 引起每幀重新計算佈局 */
    box-sizing: border-box !important;
    touch-action: none !important; /* ⚡ 平板全螢幕畫筆 0 延遲核心：跳過手勢隊列直接直通 Canvas */
    overscroll-behavior: contain !important;
}

/* ⚡ 全螢幕模式下的畫布事件圖層硬體直通保證 */
:fullscreen .upper-canvas,
:-webkit-full-screen .upper-canvas,
.samsung-note-wrapper.is-fullscreen .upper-canvas,
.pdf-annotator-wrapper.is-fullscreen .upper-canvas {
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.sn-fullscreen-btn.active,
.js-hw-fullscreen-btn.active,
.pdf-fullscreen-btn.active,
.js-pdf-fullscreen-btn.active,
.pdf-thumb-toggle.active {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.2) !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4) !important;
}

/* 📑 PDF 與手繪筆記頁面快速縮圖導覽抽屜 (Thumbnail Drawer) */
.pdf-main-layout,
.sn-main-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.pdf-thumb-drawer,
.sn-thumb-drawer {
    width: 220px;
    min-width: 150px;
    max-width: 650px;
    position: relative;
    background: rgba(15, 23, 42, 0.96);
    border-right: 1px solid rgba(56, 189, 248, 0.2);
    display: none;
    flex-direction: column;
    z-index: 20;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 12px 14px;
    box-sizing: border-box;
    backdrop-filter: blur(16px);
    animation: snDrawerSlideIn 0.2s ease-out;
}

/* ↕️ 拖曳調整寬度分割線 (位於抽屜最外側，flex 子元素自動撐滿高度) */
.pdf-thumb-resizer,
.sn-thumb-resizer {
    width: 6px;
    align-self: stretch;
    cursor: col-resize;
    background: rgba(255, 255, 255, 0.05);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 25;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pdf-thumb-resizer:hover,
.pdf-thumb-resizer.is-dragging,
.sn-thumb-resizer:hover,
.sn-thumb-resizer.is-dragging {
    background: rgba(56, 189, 248, 0.6);
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

@keyframes snDrawerSlideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.pdf-thumb-drawer.open,
.sn-thumb-drawer.open {
    display: flex;
}

.pdf-thumb-header,
.sn-thumb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pdf-thumb-list,
.sn-thumb-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.pdf-thumb-item,
.sn-thumb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.pdf-thumb-item:hover,
.sn-thumb-item:hover {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.4);
    transform: translateY(-2px);
}

.pdf-thumb-item.active,
.sn-thumb-item.active {
    background: rgba(56, 189, 248, 0.2);
    border: 2px solid #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

/* 📑 修改縮圖外框：移除固定比例，由 Canvas 真實長寬比撐開 */
.pdf-thumb-canvas-wrapper,
.sn-thumb-canvas-wrapper {
    width: 100%;
    height: auto !important; /* 移除固定 aspect-ratio，避免強制直式比例 */
    background: transparent;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.pdf-thumb-canvas-wrapper canvas,
.sn-thumb-canvas-wrapper canvas {
    width: 100% !important;
    height: auto !important; /* 依據真實頁面比例自動等比呈現 */
    display: block !important;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.pdf-thumb-label,
.sn-thumb-label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    margin-top: 6px;
}

.pdf-thumb-item.active .pdf-thumb-label,
.sn-thumb-item.active .sn-thumb-label {
    color: #38bdf8;
    font-weight: 700;
}

.pdf-page-slider-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.pdf-page-slider {
    width: 50px;
    height: 4px;
    accent-color: #38bdf8;
    cursor: pointer;
}


/* 📑 PDF 畫布舞台與雙層疊合結構樣式 */
.pdf-viewport {
    flex: 1;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative;
    background: #070b14;
    display: block !important; /* 💡 採用 block 視口容器，徹底根除 Safari Flexbox 負坐標裁切 bug */
    padding: 24px 24px !important;
    box-sizing: border-box;
    min-height: 0;
    touch-action: none !important; /* 支援平板雙指縮放與雙指平移手勢 */
    overscroll-behavior: contain !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.25) transparent;
}

.pdf-viewport::-webkit-scrollbar { width: 6px; height: 6px; }
.pdf-viewport::-webkit-scrollbar-track { background: transparent; }
.pdf-viewport::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.25); border-radius: 4px; }
.pdf-viewport::-webkit-scrollbar-thumb:hover { background: rgba(56, 189, 248, 0.5); }

/* 📖 PDF 筆記舞台 (單頁與雙頁並排模式：支援放大後左對齊無負空間溢出) */
.pdf-page-stage {
    display: flex;
    justify-content: safe center !important;
    align-items: flex-start !important;
    min-width: 100% !important;
    width: max-content !important;
    min-height: 100% !important;
    position: relative !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    transform-origin: center top;
    touch-action: none !important;
}

.pdf-page-stage[style*="none"],
.pdf-page-stage.is-hidden,
.pdf-page-stage[hidden] {
    display: none !important;
}

.pdf-page-stage .pdf-canvas-layer-wrapper {
    margin: 0 auto !important; /* 💡 小於視口時自動置中，大於視口時自動靠左對齊left:0，絕不向左側負空間溢出 */
}

/* 📖 雙頁並排模式 (Two-Page Spread) */
.pdf-page-stage.view-double {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    justify-content: safe center !important;
    align-items: flex-start !important;
}

.pdf-page-stage.view-double .pdf-canvas-layer-wrapper {
    margin: 0 !important;
}

.pdf-page-stage.view-double .pdf-canvas-layer-wrapper:first-child {
    box-shadow: -8px 12px 36px rgba(0, 0, 0, 0.65), 1px 0 0 rgba(255, 255, 255, 0.1) !important;
}

.pdf-page-stage.view-double .pdf-canvas-layer-wrapper:last-child {
    box-shadow: 8px 12px 36px rgba(0, 0, 0, 0.65), -1px 0 0 rgba(255, 255, 255, 0.1) !important;
}

/* 📜 多頁連續垂直捲動模式 (Continuous Scroll) */
.pdf-viewport.view-continuous {
    display: block !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-x pan-y !important; /* 💡 支援水平與垂直雙向觸控平移滾動 */
    padding: 24px 20px !important;
}

.pdf-viewport.view-continuous #pdfPageStage {
    display: none !important;
}

.pdf-continuous-container {
    display: flex;
    flex-direction: column;
    align-items: safe center;
    gap: 20px;
    padding: 0 0 60px 0;
    min-width: 100%;
    width: max-content; /* 💡 隨放大的卡片寬度自適應撐大，確保 scrollWidth 完整涵蓋左右兩側 */
    min-height: 100%;
    transform-origin: center top;
    box-sizing: border-box;
}

.pdf-continuous-page {
    position: relative;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.25);
    background-color: #ffffff;
    border-radius: 4px;
    flex-shrink: 0;
    margin-left: auto !important;
    margin-right: auto !important;
    transition: box-shadow 0.2s ease;
}

.pdf-continuous-page.active-focus {
    box-shadow: 0 0 0 2px #38bdf8, 0 12px 48px rgba(56, 189, 248, 0.25) !important;
}

.pdf-continuous-page .pdf-continuous-render-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    border-radius: 4px;
}

.pdf-continuous-page .canvas-container,
.pdf-continuous-page .pdf-continuous-annotation-canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 10 !important;
    border-radius: 4px;
}

.pdf-continuous-page .pdf-text-layer {
    display: none !important;
    z-index: 0 !important;
    pointer-events: none !important;
}

.pdf-continuous-page .pdf-text-layer.active-selection {
    display: block !important;
    z-index: 20 !important;
}

.pdf-continuous-page .pdf-page-badge {
    position: absolute;
    bottom: -22px;
    right: 0;
    font-size: 0.75rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.75);
    padding: 2px 8px;
    border-radius: 10px;
    backdrop-filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

.pdf-canvas-layer-wrapper {
    position: relative !important;
    display: block;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.25) !important;
    background-color: #ffffff !important;
    border-radius: 4px;
    margin: 0 !important;
    flex-shrink: 0 !important;
    touch-action: none !important;
}

/* 雙頁模式右頁容器控制：預設隱藏，僅在 .view-double 且非空時顯示 */
#pdfLayerWrapperRight {
    display: none !important;
}

.pdf-page-stage.view-double #pdfLayerWrapperRight {
    display: block !important;
}

.pdf-page-stage.view-double #pdfLayerWrapperRight.is-empty {
    display: none !important;
}

.pdf-canvas-layer-wrapper.sn-paper-sheet.theme-light {
    background-color: #ffffff !important;
}

.pdf-canvas-layer-wrapper.sn-paper-sheet.theme-dark {
    background-color: #121722 !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(56, 189, 248, 0.15) !important;
}

.pdf-render-canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
    pointer-events: none !important;
    border-radius: 4px;
    display: block !important;
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: high-quality !important;
}

/* 📄 PDF 原生文字選取層 (Text Layer) - 僅在文字選取工具時啟用 display: block，畫筆模式下 display: none 杜絕成千上萬文字節點拖慢繪圖幀率 */
.pdf-text-layer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    line-height: 1.0 !important;
    z-index: 0 !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    pointer-events: none !important;
    display: none !important;
}

.pdf-text-layer.active-selection {
    display: block !important;
    pointer-events: none !important;
    opacity: 1 !important;
    z-index: 20 !important;
}

.pdf-text-layer.active-selection > span {
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    cursor: text !important;
}

.pdf-text-layer > span {
    color: transparent !important;
    position: absolute !important;
    white-space: pre !important;
    cursor: default !important;
    transform-origin: 0% 0% !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.pdf-text-layer ::selection {
    background: rgba(250, 204, 21, 0.32) !important;
    color: transparent !important;
}

.pdf-text-layer ::-moz-selection {
    background: rgba(250, 204, 21, 0.32) !important;
    color: transparent !important;
}

.pdf-canvas-layer-wrapper .canvas-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 10 !important;
    border-radius: 4px;
}

/* 🎯 全局 Canvas 高清平滑渲染優化，杜絕模糊拉伸 */
.pdf-render-canvas,
.pdf-continuous-render-canvas,
.pdf-continuous-annotation-canvas,
.sn-continuous-render-canvas,
.sn-continuous-canvas,
.sn-paper-sheet canvas,
.pdf-canvas-layer-wrapper canvas,
.canvas-container canvas {
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: high-quality !important;
}

/* 🎨 選中文字懸浮快捷泡泡列 (Bubble Menu) */
.pdf-text-bubble-menu {
    position: fixed;
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(18, 24, 38, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px rgba(56, 189, 248, 0.25);
    border-radius: 24px;
    padding: 5px 10px;
    z-index: 2147483646;
    transform: translate(-50%, -100%);
    animation: bubbleFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bubbleFadeIn {
    from { opacity: 0; transform: translate(-50%, -85%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}

.pdf-text-bubble-btn,
.sn-bubble-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: #f1f5f9;
    padding: 5px 9px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.pdf-text-bubble-btn:hover,
.sn-bubble-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #38bdf8;
    transform: translateY(-1px);
}

.pdf-text-bubble-btn.highlight:hover,
.sn-bubble-btn.highlight:hover {
    background: rgba(250, 204, 21, 0.2);
    color: #facc15;
}

.sn-bubble-btn.js-bubble-unhighlight:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.pdf-text-bubble-divider {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.15);
}

/* 📌 便利貼註解浮動卡片 (Sticky Note Popover) */
.sn-sticky-popover {
    position: fixed;
    display: none;
    flex-direction: column;
    width: 280px;
    background: rgba(20, 27, 44, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 16px rgba(56, 189, 248, 0.2);
    z-index: 2147483647;
    padding: 12px;
    animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.sn-sticky-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.sn-sticky-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.sn-sticky-colors {
    display: flex;
    gap: 6px;
    align-items: center;
}

.sn-sticky-color-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease;
    box-sizing: border-box;
}

.sn-sticky-color-dot:hover {
    transform: scale(1.25);
}

.sn-sticky-color-dot.active {
    border-color: #ffffff;
    box-shadow: 0 0 8px currentColor;
}

.sn-sticky-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 5px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.sn-sticky-close-btn:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.1);
}

.sn-sticky-textarea {
    width: 100%;
    min-height: 85px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #f8fafc;
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 8px;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.sn-sticky-textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.sn-sticky-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sn-sticky-btn-del,
.sn-sticky-del-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 0.78rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.sn-sticky-btn-del:hover,
.sn-sticky-del-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.sn-sticky-tip {
    font-size: 0.72rem;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sn-sticky-btn-close {
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sn-sticky-btn-close:hover {
    background: #38bdf8;
    color: #0f172a;
}






