/* ==========================================================================
   🛠️ 編輯器共用工具列樣式 (Editor Toolbar CSS)
   供手繪筆記、PDF 標註與區塊編輯器共用同一套緊湊精緻的科技感外觀
   全面對接 tokens.css 變數 (--ed-*)

   【!important 保留原因說明】：
   1. 工具列結構 (.sn-toolbar, .pdf-toolbar)：保留 !important 確保在全螢幕與後台各排版中，
      sticky 定位、磨砂玻璃底色與 flex-nowrap 單行滾動不被外層通用容器覆蓋。
   2. 按鈕狀態 (.sn-tool-btn, :hover, .active)：保留 !important 確保 36x36 尺寸、圓角與
      天藍色高亮不受全站 a/button/reset.css 樣式干擾，四種模式完全一致。
   3. 浮動面板 (.sn-popover-panel, .sn-color-panel)：保留 !important 確保 fixed 定位與
      最高層疊層次 (z-index) 穩定置頂於畫布與編輯器上方。
   ========================================================================== */


:root {
    --ed-accent: var(--primary-light, #38bdf8);
    --ed-accent-strong: var(--accent, #00d9ff);
    --ed-accent-soft: rgba(56, 189, 248, 0.15);
    --ed-bar-bg: rgba(15, 23, 42, 0.96);
    --ed-panel-bg: #0f172a;
    --ed-border: rgba(255, 255, 255, 0.08);
    --ed-border-strong: rgba(56, 189, 248, 0.35);
    --ed-text: #e2e8f0;
    --ed-text-muted: #94a3b8;
    --ed-danger: var(--danger, #fe5461);

    --ed-radius-sm: 6px;
    --ed-radius-md: 8px;
    --ed-radius-lg: 12px;

    --ed-btn-size: 36px;
    --ed-ui-font: 13px;

    --ed-content-size: 16.5px;
    --ed-content-line: 1.8;
    --ed-content-width: 760px;

    --ed-shadow-panel: 0 10px 30px rgba(0, 0, 0, 0.45);
    --ed-transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

    /* 編輯器框架（手繪、PDF、區塊三種模式共用同一組數值）
       外殼 .ed-shell → 視口 .ed-viewport（可捲動的深色區）→ 紙張 .ed-page */
    --ed-shell-bg: #090d16;
    --ed-toolbar-height: 56px;
    --ed-viewport-bg: #070b14;
    --ed-viewport-padding: 24px;
    --ed-page-bg: #121722;
    --ed-page-radius: 6px;
    --ed-page-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(56, 189, 248, 0.15);
    --ed-page-padding: 48px 24px 96px;
    --ed-page-padding-mobile: 24px 18px 64px;
}

/* ☀️ 亮色紙張（共用）：紙張加上 .ed-theme-light，只覆寫紙張內用到的變數，工具列維持暗色
   底色與手繪亮色紙張 (.sn-paper-sheet.theme-light) 相同為 #fff */
.ed-page.ed-theme-light {
    --ed-page-bg: #ffffff;
    --ed-page-shadow: 0 10px 30px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.08);
    --ed-text: #1e293b;
    --ed-text-muted: #64748b;
    --ed-border: rgba(15, 23, 42, 0.12);
    --ed-border-strong: rgba(2, 132, 199, 0.45);
    --ed-accent: #0284c7;
    --ed-accent-strong: #0369a1;
    --ed-accent-soft: rgba(2, 132, 199, 0.1);
}

/* 🎨 更多色彩與歷史顏色調色盤按鈕 */
.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: var(--ed-accent, #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: var(--ed-radius-lg, 12px);
    padding: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), 0 0 15px var(--ed-accent-soft, 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: var(--ed-text-muted, #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: var(--ed-radius-md, 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 var(--ed-accent-strong, #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: var(--ed-radius-md, 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: var(--ed-radius-sm, 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: var(--ed-radius-sm, 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: var(--ed-radius-sm, 6px);
    border: 1px solid var(--ed-border-strong, rgba(56, 189, 248, 0.35));
    background: var(--ed-accent-soft, rgba(56, 189, 248, 0.15));
    color: var(--ed-accent, #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: var(--ed-accent, #38bdf8);
    color: var(--ed-panel-bg, #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: var(--ed-radius-md, 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 var(--ed-accent-strong, #00d9ff), 0 0 12px rgba(0, 217, 255, 0.8);
}


/* 🛠️ 頂部工具列 (橫向 Flex 單行不折行、緊湊磨砂玻璃、支援橫向滑動但隱藏滾輪) */
.sn-toolbar,
.pdf-toolbar {
    position: sticky !important;
    top: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 12px !important;
    background: var(--ed-bar-bg, rgba(15, 23, 42, 0.96)) !important;
    border-bottom: 1px solid var(--ed-border-strong, rgba(56, 189, 248, 0.35)) !important;
    backdrop-filter: blur(16px) !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: 4px !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: 2px !important;
}

.sn-toolbar::-webkit-scrollbar-thumb,
.pdf-toolbar::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.45) !important;
    border-radius: 2px !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,
.sn-page-controls,
.pdf-page-controls,
.sn-paper-select-group,
.sn-theme-group,
.pdf-file-actions,
.sn-color-group,
.sn-size-group,
.pdf-zoom-controls,
.hw-zoom-controls,
.sn-actions-group {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 3px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    flex-shrink: 0 !important;
}

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

/* 🛠️ 通用工具列按鈕樣式 (加大至 36x36 方便手指觸控) */
.sn-tool-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: var(--ed-radius-md, 8px) !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    color: rgba(226, 232, 240, 0.88) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    outline: none !important;
    user-select: none !important;
    transition: all 0.15s 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.2) !important;
    color: var(--ed-accent, #38bdf8) !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25) !important;
}

/* ✍️ 平板專用：防手掌誤觸 (Stylus Only) 啟用狀態高亮 */
.sn-tool-btn.stylus-only-active,
.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[data-action="undo"],
.sn-tool-btn[data-action="redo"] {
    font-size: 15px !important;
    color: #e2e8f0 !important;
    transition: all 0.18s ease !important;
}

.sn-tool-btn[data-action="undo"]:not(:disabled):hover,
.sn-tool-btn[data-action="redo"]:not(:disabled):hover {
    color: var(--ed-accent, #38bdf8) !important;
    background: var(--ed-accent-soft, 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: inline-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: 5px !important;
}

.sn-color-dot {
    width: 26px !important;
    height: 26px !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;
    padding: 3px 6px !important;
    flex-shrink: 0 !important;
}


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


/* 📄 紙張選擇下拉選單 */
.sn-paper-select {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid var(--ed-border-strong, rgba(56, 189, 248, 0.35)) !important;
    color: #e2e8f0 !important;
    border-radius: var(--ed-radius-sm, 6px) !important;
    padding: 4px 8px !important;
    font-size: 0.82rem !important;
    max-width: 130px !important;
    outline: none !important;
    cursor: pointer !important;
    flex-shrink: 0 !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); }
}

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

.sn-bubble-btn:hover {
    background: var(--ed-border, rgba(255, 255, 255, 0.08));
    color: var(--ed-accent, #38bdf8);
    transform: translateY(-1px);
}

.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;
}


/* 📌 便利貼註解浮動卡片 (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: var(--ed-radius-lg, 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: var(--ed-accent, #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: var(--ed-text-muted, #94a3b8);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 5px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.sn-sticky-close-btn:hover {
    color: var(--ed-text, #e2e8f0);
    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 var(--ed-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--ed-radius-sm, 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: var(--ed-accent, #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 var(--ed-border, rgba(255, 255, 255, 0.08));
}

.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-del-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.sn-sticky-tip {
    font-size: 0.72rem;
    color: var(--ed-text-muted, #94a3b8);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}


/* ==========================================================================
   ✨ 現代緊湊型工具列浮動面板系統 (Compact Toolbar Popover System)
   ========================================================================== */

/* 緊湊型按鈕帶下拉小角標 */
.sn-tool-btn.sn-popover-trigger-btn {
    width: auto !important;
    min-width: 36px !important;
    padding: 0 8px !important;
    gap: 5px !important;
    border: 1px solid var(--ed-border, rgba(255, 255, 255, 0.08)) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border-radius: var(--ed-radius-md, 8px) !important;
}

.sn-tool-btn.sn-popover-trigger-btn:hover {
    background: var(--ed-accent-soft, rgba(56, 189, 248, 0.15)) !important;
    border-color: var(--ed-border-strong, rgba(56, 189, 248, 0.35)) !important;
}

.sn-tool-btn.sn-popover-trigger-btn.active,
.sn-tool-btn.sn-popover-trigger-btn.is-open {
    background: var(--ed-border-strong, rgba(56, 189, 248, 0.35)) !important;
    border-color: var(--ed-accent, #38bdf8) !important;
    color: var(--ed-accent, #38bdf8) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25) !important;
}

.sn-dropdown-icon {
    font-size: 0.62rem !important;
    opacity: 0.7 !important;
    transition: transform 0.2s ease !important;
    margin-left: 1px !important;
}

.sn-tool-btn.sn-popover-trigger-btn.is-open .sn-dropdown-icon {
    transform: rotate(180deg) !important;
}

/* 浮動面板本體 (掛載於 body，fixed 定位) */
.sn-popover-panel {
    position: fixed;
    background: #131b2c;
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: var(--ed-radius-lg, 12px);
    padding: 14px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8), 0 0 20px rgba(56, 189, 248, 0.16);
    z-index: 300000 !important;
    display: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-sizing: border-box;
    color: #e2e8f0;
}

.sn-popover-panel.open {
    display: block !important;
    animation: snFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.sn-popover-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ed-text-muted, #94a3b8);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--ed-border, rgba(255, 255, 255, 0.08));
    padding-bottom: 6px;
}

.sn-popover-title i {
    color: var(--ed-accent, #38bdf8);
    font-size: 0.85rem;
}

/* 幾何圖形選單 Grid */
.sn-shapes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    min-width: 190px;
}

/* 檢視模式清單 */
.sn-view-options-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

/* 通用選單項目按鈕 */
.sn-popover-item-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--ed-radius-md, 8px);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--ed-border, rgba(255, 255, 255, 0.08));
    color: #e2e8f0;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.sn-popover-item-btn i {
    font-size: 0.95rem;
    color: var(--ed-text-muted, #94a3b8);
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sn-popover-item-btn:hover {
    background: var(--ed-accent-soft, rgba(56, 189, 248, 0.15));
    border-color: var(--ed-border-strong, rgba(56, 189, 248, 0.35));
    color: #ffffff;
}

.sn-popover-item-btn:hover i {
    color: var(--ed-accent, #38bdf8);
}

.sn-popover-item-btn.active {
    background: var(--ed-border-strong, rgba(56, 189, 248, 0.35));
    border-color: var(--ed-accent, #38bdf8);
    color: var(--ed-accent, #38bdf8);
    font-weight: 600;
}

.sn-popover-item-btn.active i {
    color: var(--ed-accent, #38bdf8);
}

/* 筆刷粗細面板樣式 */
.sn-size-panel {
    min-width: 260px;
}

.sn-size-indicator-dot {
    display: inline-block;
    border-radius: 50%;
    background-color: var(--ed-accent, #38bdf8);
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
    flex-shrink: 0;
}

.sn-size-trigger-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #e2e8f0;
}

.sn-size-preset-row-v2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 12px;
}

.sn-size-preset-btn-v2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: var(--ed-radius-md, 8px);
    padding: 6px 4px;
    cursor: pointer;
    color: var(--ed-text-muted, #94a3b8);
    transition: all 0.15s ease;
    flex: 1;
}

.sn-size-preset-btn-v2:hover {
    background: var(--ed-border, rgba(255, 255, 255, 0.08));
    color: #e2e8f0;
}

.sn-size-preset-btn-v2.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: var(--ed-accent, #38bdf8);
    color: var(--ed-accent, #38bdf8);
}

.sn-size-preset-btn-v2 .sn-size-dot {
    background: var(--ed-text-muted, #94a3b8);
    border-radius: 50%;
    transition: all 0.15s ease;
}

.sn-size-preset-btn-v2.active .sn-size-dot {
    background: var(--ed-accent, #38bdf8);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

.sn-size-preset-btn-v2 .preset-name {
    font-size: 0.7rem;
    font-weight: 600;
}

.sn-size-slider-row {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: var(--ed-radius-md, 8px);
}

.sn-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--ed-text-muted, #94a3b8);
    margin-bottom: 8px;
}


.sn-size-slider {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--ed-border, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.sn-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--ed-accent, #38bdf8);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.sn-size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* 縮放面板 Grid */
.sn-zoom-panel {
    min-width: 210px;
}

.sn-zoom-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.sn-zoom-presets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    border-top: 1px solid var(--ed-border, rgba(255, 255, 255, 0.08));
    padding-top: 10px;
}

.sn-zoom-preset-btn {
    padding: 6px 0;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ed-border, rgba(255, 255, 255, 0.08));
    color: var(--ed-text, #e2e8f0);
    border-radius: var(--ed-radius-sm, 6px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.sn-zoom-preset-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--ed-accent, #38bdf8);
    color: #ffffff;
}

/* 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.82rem !important;
    color: #cbd5e1 !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.pdf-page-input {
    width: 44px !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.82rem !important;
    outline: none !important;
    padding: 2px !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;
}


/* ==========================================================================
   編輯器共用外殼 (Editor Shell)
   手繪筆記、PDF 標註、區塊編輯三種模式使用同一個結構：
     .ws-canvas-wrapper            ← 工作台容器（四種模式相同）
       └─ .ed-shell                ← 外殼：直向排列、填滿容器
            ├─ 工具列 (.sn-toolbar / .pdf-toolbar)   ← 固定在上方，不隨內容捲動
            └─ .ed-body            ← 內容區：佔滿剩餘高度（手繪/PDF 左側可放縮圖抽屜）
                 └─ .ed-viewport   ← 視口：深色底、統一內距，只有這裡會捲動
                      └─ 紙張      ← 手繪 .sn-paper-sheet / PDF 頁面 / 區塊 .ed-page，同一組底色、圓角、陰影
   ========================================================================== */
.ed-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    background: var(--ed-shell-bg, #090d16);
}

.ed-shell > .sn-toolbar,
.ed-shell > .pdf-toolbar {
    flex: 0 0 auto;
    min-height: var(--ed-toolbar-height, 56px) !important;   /* 三種模式工具列同高 */
}

.ed-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    display: flex;
}

/* 視口：手繪 .sn-viewport、PDF .pdf-viewport 已在 canvas.css 使用同一組變數 */
.ed-viewport {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: var(--ed-viewport-padding, 24px);
    background: var(--ed-viewport-bg, #070b14);
    box-sizing: border-box;
}

/* 紙張：與手繪暗色紙張 (.sn-paper-sheet.theme-dark) 相同的底色、圓角、陰影 */
.ed-page {
    position: relative;
    margin: 0 auto;
    background: var(--ed-page-bg, #121722);
    border-radius: var(--ed-page-radius, 6px);
    box-shadow: var(--ed-page-shadow, 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(56, 189, 248, 0.15));
    box-sizing: border-box;
}
