/* ==============================================================================
   🍱 大廚 3D 擺盤組合大師 - 終極完美整併版樣式庫 (含尊爵暗黑畫廊)
   ============================================================================== */

/* --- 1. 核心變數與基礎設定 --- */
:root {
    --primary: #4caf50; --bg: #12141c; --panel: #1e222d;
    --border: #2d3340; --text: #e0e6ed; --accent: #4f8ef7;
    --gold: #D4A843; --blue: #2196F3; --wood: #8B5A2B;
    --vermillion: #C94C28; --lacquer: #2B1810;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: auto; font-family: 'Noto Sans TC', sans-serif; background: #e5e5e5; color: #333; }
body.design-mode .normal-tools { display: none !important; }
body:not(.design-mode) .design-tools { display: none !important; }
#email-login-panel { display: none; }

/* --- 2. 標題與主版面佈局 --- */
.header { background: var(--lacquer); color: white; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; z-index: 2000; position: relative; height: 46px; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.header-title { margin: 0; font-size: 16px; color: white; font-weight: bold; text-shadow: 0 2px 5px rgba(0,0,0,0.6); letter-spacing: 1px; white-space: nowrap; }
.header-tools-container { display: flex; gap: 8px; align-items: center; transition: opacity 0.3s ease, visibility 0.3s ease; }
body:not(.auth-ready) .header-tools-container { opacity: 1; visibility: visible; }
.design-tools-header { display: flex; gap: 8px; }
.design-tools-title { font-size: 14px; font-weight: bold; color: var(--gold); }

.main { display: flex; flex-direction: row; width: 100%; height: calc(100vh - 55px); overflow: auto; }
.sidebar { width: 300px; background-color: #f4f6f8 !important; border-right: 1px solid #ddd; display: flex; flex-direction: column; padding: 15px; flex-shrink: 0; position: relative; z-index: 1600; }
.workspace { flex: 1; background-color: #f4f6f8 !important; display: flex; flex-direction: column; position: relative; }
.tpl-sidebar { width: 250px; background: #fdfdfd; border-left: 1px solid #ddd; display: flex; flex-direction: column; padding: 12px; gap: 15px; flex-shrink: 0; z-index: 1500; overflow-y: auto; overflow-x: hidden; }

/* --- 3. 頂部模式切換條 --- */
.ui-switcher {
    display: flex; background: rgba(255, 255, 255, 0.9); padding: 4px; border-radius: 10px;
    position: relative; width: 170px; margin: 0 12px; flex-shrink: 0;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}
.ui-switch-btn {
    flex: 1; padding: 6px 0; border: none; background: transparent;
    cursor: pointer; font-weight: bold; font-size: 12px; color: #555;
    z-index: 1; transition: color 0.3s; position: relative;
}
.ui-switch-btn.active { color: white !important; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.ui-slider {
    position: absolute; top: 4px; left: 4px;
    width: calc(50% - 4px); height: calc(100% - 8px);
    background: linear-gradient(135deg, #E6B956, #D4A843);
    border-radius: 6px; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4); 
}

/* --- 4. 工具列與按鈕系統 --- */
.toolbar { padding: 10px 20px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; background: #f4f6f8 !important; z-index: 2000; flex-shrink: 0; border-bottom: 1px solid #e2e8f0; }
.toolbar-gold-bottom { background: #fff8eb; border-bottom: 2px solid var(--gold); }
.btn-main { padding: 10px 16px; font-size: 14px; border-radius: 8px; color: white; flex: 1; max-width: 200px; }
.btn { border-radius: 6px; font-weight: bold; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; border: none; white-space: nowrap; }
.btn:active { transform: scale(0.95); }
.btn-gold-sm { background: var(--gold); color: white; padding: 6px 12px; font-size: 13px; }
.btn-blue-sm { background: var(--blue); color: white; padding: 6px 12px; font-size: 13px; }
.txt-bold-13 { font-weight: bold; font-size: 13px; color: #333; }
.input-box-dim { width: 60px; padding: 5px; border-radius: 4px; border: 1px solid #ccc; text-align: center; font-size: 13px; }
.btn-reset-dim { background: #fff; border: 1px solid var(--gold); color: var(--gold); padding: 5px 8px; font-size: 12px; margin-left: 5px; }
.toolbar-divider { width: 1px; height: 20px; background: #ccc; margin: 0 10px; }
.btn-add-slot { background: white; border: 1px solid var(--blue); color: var(--blue); padding: 6px 12px; font-size: 12px; }
.flex-spacer { flex: 1; }
.btn-exit-design { background: #666; color: white; padding: 6px 12px; font-size: 12px; }
.btn-save-tpl { background: var(--gold); color: white; padding: 6px 12px; font-size: 12px; }

/* 浮球工具列：畫布內右下角（前賢 2026-08-16「浮球工具列 指的是畫布上的」） */
.floating-tools { position: absolute !important; right: 6px !important; top: auto !important; bottom: 10px !important; transform: none !important; display: flex !important; flex-direction: column !important; gap: 8px !important; z-index: 1000 !important; }
.canvas-container { position: relative !important; }

.sidebar { scrollbar-width: none; -ms-overflow-style: none; }
.sidebar::-webkit-scrollbar { display: none; }

/* 🩹 一鍵去背補全：處理中動畫覆蓋層（前賢 2026-08-16） */
@keyframes fixSpin { to { transform: rotate(360deg); } }
@keyframes fixPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.fix-overlay { position: absolute; inset: 0; background: rgba(33,150,243,0.22); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 20; border-radius: 8px; animation: fixPulse 1.2s ease-in-out infinite; }
.fix-overlay .fix-spinner { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,0.7); border-top-color: #1565C0; border-radius: 50%; animation: fixSpin 0.8s linear infinite; }
.fix-overlay .fix-txt { font-size: 11px; color: #0d47a1; font-weight: bold; margin-top: 6px; text-align: center; line-height: 1.3; }
.fix-overlay.fix-done { background: rgba(76,175,80,0.3); animation: none; }
.floating-tools button { width: 52px; height: 52px; border-radius: 50%; border: 1px solid #ccc; background: rgba(255,255,255,0.95); box-shadow: 0 4px 10px rgba(0,0,0,0.2); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; transition: 0.2s; color: #444; }
.floating-tools button:hover { transform: scale(1.1); background: #fff; border-color: var(--gold); }
.floating-tools .icon { font-size: 16px; margin-bottom: 2px; }
/* 🖥️ 未選模板：工具列只顯示回首頁＋制模（管理者）、復原/重做不出現（前賢 2026-08-30/31） */
body.no-tpl .floating-tools button:not(.btn-home):not(#btn-admin-template) { display: none !important; }
body.no-tpl .floating-tools button.btn-home { display: flex !important; }
body.no-tpl #mobileToolsBar { display: none !important; }
/* 🖥️ 桌機：復原/重做移到畫布下方（與手機佈局一致 — 前賢 2026-08-30） */
.floating-tools .redo-btn, .floating-tools button[onclick*="undo"], .floating-tools button[onclick*="redo"] { display: none !important; }
.mobile-tools-bar { position: absolute; left: 0; right: 0; bottom: 2px; display: flex; flex-direction: row; gap: 6px; padding: 0; justify-content: center; background: transparent; z-index: 950; }
.mobile-tools-bar button { width: 42px; height: 42px; background: rgba(255,255,255,0.95); border: 1px solid #E8DFC8; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; padding: 0; }
.mobile-tools-bar button .icon { font-size: 18px; line-height: 1; }
.mobile-tools-bar button .txt { font-size: 9px; color: #8B6914; font-weight: 600; line-height: 1; }
.btn-snap-toggle { border: 2px solid #4CAF50 !important; color: #4CAF50 !important; }

/* --- 5. 畫布與便當區塊 --- */
.canvas-container { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: center; padding: 20px; opacity: 0; transition: opacity 0.4s ease-in-out; }
.canvas-container.ready { opacity: 1 !important; }

/* ✅ 關鍵修正：移除 height: auto !important，讓 JS 設定的高度能生效 */
#shotArea { position: relative; transform-origin: top left; max-height: none !important; min-height: 200px; }
#drawCanvasWrapper { position: relative; margin: 0 auto; background: transparent; border-radius: 18px; max-height: none !important; min-height: 200px; }

.canvas-init-size { width: 550px; height: 360px; position: relative; }
#drawCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; overflow: visible; background: transparent; border-radius: 18px; }

/* ── 便當外框基礎與圓形專屬 ── */
.bento-outer { 
    background-color: var(--wood); 
    background-origin: border-box !important; 
    background-clip: border-box !important;
    background-size: 100% 100% !important; 
    background-position: center; 
    background-repeat: no-repeat; 
    padding: 22px; 
    border-radius: 28px; 
    box-shadow: 0 25px 60px rgba(0,0,0,0.5); 
    border: 5px solid #3d2518; 
    flex-shrink: 0; 
    transform-origin: center center; 
    transition: transform 0.2s ease-out; 
    position: relative; 
}
.bento-outer.is-round-box {
    border-radius: 50% !important; 
    background-color: transparent !important; 
    padding: 0 !important; 
    border: none !important; 
    box-shadow: none !important;
    background-size: cover !important; 
    background-position: center center !important;
}

/* 縮圖預覽元件 */
.mini-layout { position: relative; background: var(--wood); background-size: cover; background-position: center; border-radius: 4px; overflow: hidden; flex-shrink: 0; border: 2px solid #3d2518; }
.mini-slot { position: absolute; background: rgba(255,255,255,0.3); border: 1px solid rgba(255,255,255,0.5); border-radius: 2px; }

/* ── 🌟 梅花扇形陣核心代碼 ── */
.slot { 
    position: absolute; 
    box-sizing: border-box; 
    z-index: 2; 
    transition: border 0.2s, background 0.2s; 
    border: none; 
    outline: none; 
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; 
}
.slot.is-sector {
    border-radius: 50% !important;
    border: none !important;
    background: rgba(33,150,243,0.15) !important;
    box-shadow: inset 0 0 0 2px rgba(33,150,243,0.7) !important;
    clip-path: polygon(50% 50%, 13.6% 0%, 86.4% 0%) !important;
    transition: background 0.2s;
    z-index: 5;
}
.slot.is-sector.slot-target {
    background: rgba(244,67,54,0.50) !important;
    box-shadow: inset 0 0 0 3px #f44336 !important;
    animation: bg-pulse-red 0.8s ease-in-out infinite !important;
}
.slot.is-sector.active {
    background: rgba(212,168,67,0.45) !important;
    box-shadow: inset 0 0 0 2px var(--gold) !important;
}
.slot.is-sector .food img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    clip-path: inherit !important; 
}
.slot[data-slot-id="center"] {
    border-radius: 50% !important;
    clip-path: none !important;
    z-index: 10;
}
body:not(.design-mode) .slot { outline: none !important; outline-offset: 0 !important; }

/* 食材與互動 */
.food { position: absolute; cursor: grab; user-select: none; }
/* 🆕 食材縮放手柄（右下角）— 手機調大小（前賢 2026-09-02） */
.food.is-bubble{background:transparent!important;border:3px solid #FFD54F;box-shadow:0 0 8px 1px rgba(255,180,60,.45),0 0 14px 2px rgba(244,67,54,.22)!important;}
#bubbleZone{background:transparent!important;}
.food-resize-handle{display:none!important;}  /* 🆕 改用兩指縮放（前賢 2026-09-03）— 移除右下角控制角 */
/* 🆕 食物刪除鍵（右上角 — 與右下縮放手柄分開 — 前賢 2026-09-02「移入格子食材沒刪除鍵」） */
.food-delete-btn{position:absolute;right:2px;top:2px;width:22px;height:22px;background:rgba(244,67,54,.88);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:13px;color:#fff;cursor:pointer;z-index:9999;box-shadow:0 1px 3px rgba(0,0,0,.3);line-height:1;}
.food-delete-btn::before{content:'🗑';}
/* 🎨 食材柔和投影（與便當盒底圖融合 — 前賢 2026-08-24「融合感沒很好」） */
.food img.dish-img { filter: drop-shadow(0 3px 5px rgba(0,0,0,0.28)); }
.food.active { z-index: 1000; }
.food.is-moving { cursor: grabbing; opacity: 0.85; transform: scale(1.05); }
.food img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(3px 5px 5px rgba(0,0,0,0.4)); }

/* --- 6. 設計模式（Design Mode）--- */
body.design-mode .canvas-container { display: block; text-align: center; overflow: auto !important; padding: 40px; }
body.design-mode .bento-outer { display: inline-block; text-align: left; transform-origin: top center; margin: 0; }
body.design-mode #drawCanvas { background: rgba(0,0,0,0.1) linear-gradient(rgba(255,255,255,0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.3) 1px, transparent 1px); background-size: 20px 20px; }
body.design-mode .slot { cursor: move; border: 2px dashed #999; background: rgba(255,255,255,0.3); }
body.design-mode .slot.active { border: 2px solid var(--vermillion) !important; background: rgba(255,255,255,0.5); z-index: 1000; }
body.design-mode .slot.active .handle { border-color: var(--vermillion); }
body.design-mode .slot.active .rotate-handle { background: var(--vermillion); display: flex; }

.bento-resizer { position: absolute; bottom: -20px; right: -20px; width: 40px; height: 40px; background: var(--gold); border: 3px solid white; border-radius: 50%; cursor: nwse-resize; display: none; align-items: center; justify-content: center; font-size: 18px; z-index: 10; font-weight: bold; color: white; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
body.design-mode .bento-resizer { display: flex; }

.handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--blue); border-radius: 50%; display: none; z-index: 10; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.rotate-handle { position: absolute; width: 26px; height: 26px; background: #ff9800; border: 2px solid white; border-radius: 50%; display: none; z-index: 10; left: 50%; top: -35px; transform: translateX(-50%); text-align: center; line-height: 22px; font-size: 16px; color: white; cursor: grab; font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
.active .handle, .active .rotate-handle { display: block; }
.h-nw { top: -7px; left: -7px; cursor: nwse-resize; } .h-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.h-sw { bottom: -7px; left: -7px; cursor: nesw-resize; } .h-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.h-n { top: -7px; left: calc(50% - 7px); cursor: ns-resize; } .h-s { bottom: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.h-w { top: calc(50% - 7px); left: -7px; cursor: ew-resize; } .h-e { top: calc(50% - 7px); right: -7px; cursor: ew-resize; }

.global-ctrl { position: fixed; background: white; border: 1px solid #ccc; border-radius: 8px; padding: 5px; display: none; gap: 5px; z-index: 10000; box-shadow: 0 4px 15px rgba(0,0,0,0.2); transform: translateX(-50%); }
.global-ctrl button { background: #f8f8f8; border: 1px solid #ddd; padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: bold; cursor: pointer; transition: 0.2s; color: #333; }
.global-ctrl button:hover { background: #eee; }
.global-ctrl button.del { background: #ffebee; color: #d32f2f; border-color: #ffcdd2; }

/* --- 7. 左側食材庫與分類選單 --- */
.category-header { display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: space-between !important; gap: 10px !important; position: relative !important; z-index: 100 !important; }
.category-header:has(.lib-menu-popup.open) { margin-bottom: 0 !important; }

#lib-floating-tools { position: relative !important; flex-shrink: 0 !important; order: 3 !important; margin-left: auto !important; }
#lib-fab { width: 34px; height: 34px; border-radius: 6px; border: 1px solid #ccc; background: white; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

#lib-menu.lib-menu-popup {
    display: none;
    position: absolute !important;
    top: 0 !important; bottom: auto !important;
    left: 100% !important; right: auto !important;
    margin-top: 0 !important; margin-left: 8px !important;
    transform: none !important;
    background: #ffffff !important;
    border: 1px solid #eaeaea !important;
    border-radius: 8px !important;
    box-shadow: 4px 4px 15px rgba(0,0,0,0.15) !important;
    padding: 6px !important;
    width: max-content !important; min-width: 110px !important;
    z-index: 99999 !important;
    flex-direction: column !important; gap: 4px !important;
}
#lib-menu.lib-menu-popup.open { display: flex !important; }
#lib-menu.lib-menu-popup .lib-menu-item {
    display: inline-flex !important; align-items: center !important; gap: 5px !important;
    padding: 5px 8px !important; margin: 0 !important;
    background: #f4f6f8 !important; border: 1px solid #e2e8f0 !important;
    font-size: 11px !important; font-weight: bold !important; color: #444 !important;
    border-radius: 6px !important; cursor: pointer !important; white-space: nowrap !important;
    width: 100% !important; justify-content: flex-start !important; transition: all 0.2s !important;
}
#lib-menu.lib-menu-popup .lib-menu-item:hover { border-color: #90caf9 !important; transform: translateY(-2px); background: #e3f2fd !important; color: var(--blue) !important; }
#lib-menu.lib-menu-popup .lib-menu-item.lib-menu-del { color: #d32f2f !important; background: #fff5f5 !important; border-color: #ffebee !important; }
#lib-menu.lib-menu-popup .lib-menu-item.lib-menu-del:hover { background: #ffebee !important; border-color: #ffcdd2 !important; }

.custom-select-wrapper { position: relative; user-select: none; flex: 1; order: 1 !important; min-width: 0 !important; }
.custom-select-trigger { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #fff; border: 1px solid #ccc; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px; color: #333; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.custom-select-trigger:hover { border-color: var(--blue); }
.custom-select-options {
    display: none; position: absolute; top: 100%; left: 0;
    /* 根因：max-width 用 min(..., 100vw-N) 在窄螢幕≈近全寬；nowrap+flex min-width:auto 會撐到該上限 */
    min-width: 100%; width: max-content; max-width: 280px; box-sizing: border-box;
    background: #fff; border: 1px solid var(--blue); border-radius: 6px; margin-top: 4px;
    z-index: 999999; overflow-x: hidden;  /* 🖥️ 一次全顯示（移除 max-height 捲動 — 前賢 2026-08-30） */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.custom-select-options.open { display: block; }
.custom-option { padding: 10px 12px; cursor: pointer; transition: 0.2s; font-size: 13px; font-weight: bold; border-bottom: 1px solid #f0f0f0; color: #333; display: flex; justify-content: space-between; align-items: center; min-width: 0; max-width: 100%; box-sizing: border-box; }
.custom-option > div { min-width: 0; }
.custom-option:hover { background: #e3f2fd; color: var(--blue); }

div#libGrid { display: grid !important; gap: 6px !important; padding: 6px 52px 6px 6px !important; box-sizing: border-box !important; width: 100% !important; max-width: 100% !important; overflow-x: hidden !important; }
div#libGrid[data-mode="bento"], div#libGrid:not([data-mode]) { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
div#libGrid .dish-card { width: 100% !important; min-width: 0 !important; height: 95px !important; margin: 0 !important; padding: 6px 4px 4px 4px !important; box-sizing: border-box !important; display: flex !important; flex-direction: column !important; align-items: center !important; justify-content: flex-start !important; text-align: center !important; transition: transform 0.15s ease, box-shadow 0.15s ease !important; position: relative !important; }
div#libGrid .dish-card:hover { transform: scale(1.06) !important; z-index: 50 !important; box-shadow: 0 6px 16px rgba(0,0,0,0.2) !important; border-color: #D4A843 !important; }
div#libGrid .dish-card img { width: 100% !important; max-width: 100% !important; height: 55px !important; object-fit: contain !important; margin-bottom: 2px !important; }
div#libGrid .dish-card .dish-name { width: 100% !important; display: block !important; font-size: 11px !important; margin-top: 4px !important; font-weight: bold; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; color: #333 !important; }

div#libGrid[data-mode="round"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 4px !important; }
div#libGrid[data-mode="round"] .dish-card { height: 125px !important; padding: 5px 2px !important; }
div#libGrid[data-mode="round"] .dish-card img { height: 90px !important; margin-bottom: 0px !important; }
div#libGrid[data-mode="round"] .dish-name { line-height: 1.1 !important; }

.dish-card .card-tag-btn,
.dish-card .card-del-btn { position: absolute !important; width: 26px !important; height: 26px !important; font-size: 13px !important; border-radius: 50% !important; display: none !important; align-items: center !important; justify-content: center !important; box-shadow: 0 2px 6px rgba(0,0,0,0.4) !important; z-index: 10 !important; cursor: pointer !important; }
.dish-card .card-tag-btn { top: -5px !important; left: -5px !important; background: var(--gold) !important; color: white !important; }
.dish-card .card-del-btn { top: -5px !important; right: -5px !important; background: #f44336 !important; color: white !important; font-weight: bold !important; }
.lib-edit-mode .dish-card { border-color: #ffb74d; animation: cardWobble 0.5s ease; }
.lib-edit-mode .dish-card .card-tag-btn,
.lib-edit-mode .dish-card .card-del-btn { display: flex !important; }
@keyframes cardWobble { 0%,100% { transform: rotate(0deg); } 20% { transform: rotate(-1.5deg); } 60% { transform: rotate(1.5deg); } }

#libGrid.batch-select-mode .card-tag-btn,
#libGrid.batch-select-mode .card-del-btn { display: none !important; }
/* ☑️ 批量模式：勾選框 = JS 建立的原生 <input type=checkbox class=batch-cb>（harness 建議：移除 ::before 雙渲染） */
/* ☑️ 批量模式：食材卡片區底部預留空間（避免被底部工具列蓋住最後一排） */
#libGrid.batch-select-mode { padding-bottom: 130px !important; }
.dish-card.batch-selected { border: 3px solid #2E7D32 !important; background-color: #E8F5E9 !important; }

#batch-toolbar { display: flex !important; left: 0 !important; right: 0 !important; margin-left: auto !important; margin-right: auto !important; }
/* 🛠️ 工具列顯示的單一事實來源（harness 方案）：libGrid 進批量模式（新舊 JS 都會加此 class）或 toolbar 有 .visible（相容舊 JS）*/
#libGrid.batch-select-mode ~ #batch-toolbar,
#batch-toolbar.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateX(-50%) translateY(0) !important;
}
/* 📌 手機批量模式：工具列緊貼食材庫下方（正常文檔流 — 就在卡片下面）*/
@media (max-width: 850px) {
    #libGrid.batch-select-mode ~ #batch-toolbar,
    #batch-toolbar.visible {
        position: static !important;
        transform: none !important;
        margin: 8px auto !important;
        min-width: 0 !important;
        width: calc(100% - 16px) !important;
        max-width: none !important;
        z-index: 60 !important;
        left: auto !important;
        right: auto !important;
    }
}

/* --- 8. 右側模板側邊欄、圖庫與系統按鈕 --- */
.sidebar-section { border-radius: 12px; padding: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.06); }
.tpl-section-template { background-color: #fffaf0; }
.tpl-section-photo    { background-color: #f2f8fc; }
.tpl-section-system   { background-color: #f4f9f5; margin-top: auto; }
.tpl-section-system .btn { font-size: 15px !important; padding: 10px 12px !important; font-weight: bold !important; }
.tpl-sidebar-title { margin: 0 0 12px 0; color: var(--blue); border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 8px; font-size: 15px; font-weight: bold; }
.tpl-select-margin { margin-top: 0; margin-bottom: 12px; flex: none; }
.btn-new-tpl { background: #fff; border: 1px dashed var(--gold); color: var(--gold); width: 100%; padding: 8px; margin-bottom: 15px; font-size: 13px; }
.btn-new-tpl:hover { background: #fff8eb; }
.btn-upload-bento { background: #e3f2fd; border: 1px solid var(--blue); color: var(--blue); width: 100%; padding: 8px; margin-top: 5px; margin-bottom: 8px; font-size: 13px; }
.btn-browse-photos { background: #fff5f5; border: 1px solid var(--vermillion); color: var(--vermillion); width: 100%; padding: 8px; margin-bottom: 15px; font-size: 13px; }
.backup-action-row { display: flex; gap: 5px; margin-top: auto; border-top: 1px solid #eee; padding-top: 15px; }
.sidebar-section .backup-action-row { display: flex; gap: 8px; margin-top: 0; border-top: none; padding-top: 0; }
.btn-backup-sys  { flex: 1; background: #e8f5e9; border: 1px solid #c8e6c9; color: #2e7d32; font-size: 11px; padding: 6px 0; }
.btn-restore-sys { flex: 1; background: #fff3e0; border: 1px solid #ffcc80; color: #e65100; font-size: 11px; padding: 6px 0; }
.btn-default-foods { background: #e3f2fd; border: 1px solid #90caf9; color: var(--blue); width: 100%; padding: 8px; margin-top: 12px; font-size: 11px; }
.btn-delete-all { background: #fffaf0; border: 1px solid #ffcdd2; color: #d32f2f; width: 100%; padding: 8px; margin-top: 6px; font-size: 11px; }

#customTplSelected { display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: flex-start !important; gap: 12px !important; width: 100%; padding: 2px 10px; }
#customTplSelected .mini-layout { width: 35px !important; height: 25px !important; flex-shrink: 0 !important; margin: 0 !important; }

#gallery-grid { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important; gap: 15px !important; padding: 10px !important; align-items: start; }

/* --- 9. 彈窗、燈箱與系統 UI --- */
#overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 99990 !important; backdrop-filter: blur(2px); }
.popup-box { display: none; position: fixed; background: #fff; border-radius: 12px; padding: 20px; z-index: 99999; box-shadow: 0 10px 30px rgba(0,0,0,0.3); flex-direction: column; color: #333; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.popup-box.centered { top: 50%; left: 50%; transform: translate(-50%, -50%); min-width: 300px; text-align: center; border: 2px solid var(--lacquer); z-index: 100001 !important; }
#centered-confirm .btn-yes { background: var(--lacquer); }
.popup-actions { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }
.btn-yes { padding: 8px 16px; border-radius: 6px; border: none; font-weight: bold; cursor: pointer; background: var(--gold); color: white; }
.btn-no  { padding: 8px 16px; border-radius: 6px; font-weight: bold; cursor: pointer; background: #eee; border: 1px solid #ccc; color: #333; }

.image-lightbox-wrapper { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); z-index: 100010; display: none; flex-direction: column; align-items: center; overflow-y: auto; overflow-x: hidden; padding: 50px 0 30px; }
.lightbox-img-style { max-width: 90vw; max-height: 45vh; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.8); object-fit: contain; flex-shrink: 0; }
.lightbox-title-style { color: #FCEABB; margin: 12px 0 8px; font-size: 18px; font-weight: bold; text-shadow: 0 1px 3px rgba(0,0,0,0.9); flex-shrink: 0; }
.lightbox-action-wrapper { display: flex; gap: 15px; flex-shrink: 0; }
.lightbox-close-btn { position: absolute; top: 20px; right: 20px; font-size: 36px; color: white; background: none; border: none; cursor: pointer; transition: 0.2s; }
.lightbox-close-btn:hover { color: #ff5e5e; transform: scale(1.1); }

.db-status-overlay { position: fixed; top: 15px; left: 50%; transform: translateX(-50%); background: rgba(33,150,243,0.9); color: white; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: bold; z-index: 9999; display: none; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }

.saving-overlay-style {
    position: fixed !important; top: 0 !important; left: 0 !important;
    width: 100vw !important; height: 100vh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    color: white; font-size: 16px; font-weight: bold;
    z-index: 99999999 !important; backdrop-filter: blur(4px);
}

/* ==============================================================================
   🌟 御品大廚專屬 - 圖庫畫廊與介面美化升級
   ============================================================================== */
#gallery-modal {
    background: #1C1C1E !important;
    border: 1px solid #3A3A3C !important;
    box-shadow: 0 25px 50px rgba(0,0,0,0.7) !important;
    border-radius: 16px !important;
    color: #fff;
}
#gallery-modal h3 { color: #FCEABB !important; border-bottom-color: rgba(212, 168, 67, 0.3) !important; text-shadow: 0 2px 4px rgba(0,0,0,0.5); padding-bottom: 15px !important; }

#btn-gal-mine, #btn-gal-public, #gallery-upload-row button {
    border-radius: 8px !important; font-weight: bold !important; letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2) !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    border: 1px solid transparent !important;
}
#btn-gal-mine[style*="var(--gold)"], #btn-gal-public[style*="var(--gold)"] { 
    background: linear-gradient(135deg, #E6B956, #D4A843) !important; color: #fff !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); border: 1px solid #ffe082 !important;
}
#btn-gal-mine[style*="#eee"], #btn-gal-public[style*="#eee"] { background: #2d3340 !important; color: #a0aec0 !important; border: 1px solid #4a5568 !important; }
#btn-gal-mine[style*="#eee"]:hover, #btn-gal-public[style*="#eee"]:hover { background: #3a4150 !important; color: #fff !important; }
#gallery-upload-row button:nth-child(1) { background: linear-gradient(135deg, #4A90D9, #2196F3) !important; color: white !important; border: none !important; }
#gallery-upload-row button:nth-child(2) { background: linear-gradient(135deg, #4CAF50, #388E3C) !important; color: white !important; border: none !important; }
#gallery-upload-row button:hover { transform: translateY(-2px); filter: brightness(1.1); }

.gallery-card { background: #2C2C2E !important; border: 1px solid #3A3A3C !important; border-radius: 12px !important; box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s !important; overflow: hidden; display: flex; flex-direction: column; position: relative; height: 100%; }
.gallery-card:hover { transform: translateY(-5px) !important; border-color: var(--gold) !important; box-shadow: 0 8px 25px rgba(212, 168, 67, 0.25) !important; }
.gallery-card img.gallery-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-bottom: 1px solid #111; display: block; flex-shrink: 0; }
.gallery-card .gallery-name { flex-shrink: 0; padding: 12px 8px; text-align: center; font-size: 13px; font-weight: bold; color: #E8D090; background: #232325; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-header-title { color: #E8D090; font-size: 20px; margin: 0; display: flex; align-items: center; }
.gal-tabs-container { display: flex; background: #2C2C2E; border-radius: 12px; padding: 4px; margin: 10px 0 15px; }
.gal-tab-btn { flex: 1; padding: 10px; border-radius: 8px; border: none; font-weight: bold; font-size: 14px; cursor: pointer; transition: all 0.3s ease; background: transparent; color: #888; }
.gal-tab-btn.active { background: linear-gradient(135deg, #D4A843, #B8860B); color: #fff; box-shadow: 0 4px 10px rgba(212,168,67,0.3); }
.gal-action-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 15px; }
.gal-action-btn-main { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid #444; background: #2C2C2E; color: #E8D090; font-weight: bold; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.gal-action-btn-main:hover { background: #3A3A3C; border-color: #D4A843; }
.gal-action-btn-main.primary { background: rgba(76, 175, 80, 0.15); border-color: #4CAF50; color: #4CAF50; }
.gal-action-btn-main.primary:hover { background: rgba(76, 175, 80, 0.25); }
.gal-author-badge { position: absolute; bottom: 48px; right: 5px; background: rgba(0,0,0,0.7); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 11px; backdrop-filter: blur(2px); z-index: 10; }
.btn-close-gal { background: #3A3A3C; color: #fff; border: none; padding: 10px 40px; border-radius: 20px; font-weight: bold; letter-spacing: 1px; cursor: pointer; transition: 0.2s; margin-top: 10px; }
.btn-close-gal:hover { background: #ff4757; box-shadow: 0 4px 12px rgba(255,71,87,0.4); }
#gallery-modal .btn-no-large { background: #2d3340 !important; color: #e0e6ed !important; border: 1px solid #4a5568 !important; border-radius: 8px !important; padding: 10px 30px !important; font-size: 15px !important; transition: all 0.2s !important; font-weight: bold !important; }
#gallery-modal .btn-no-large:hover { background: #f44336 !important; color: white !important; border-color: #d32f2f !important; box-shadow: 0 4px 10px rgba(244, 67, 54, 0.3) !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212, 168, 67, 0.4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212, 168, 67, 0.8); }

/* ==============================================================================
   🖥️ 桌機專屬
   ============================================================================== */
@media (min-width: 851px) {
    .tpl-sidebar {
        position: absolute !important; top: 60px; right: 20px;
        width: 250px; height: auto !important; max-height: calc(100vh - 80px);
        border: 2px solid var(--gold) !important; border-radius: 12px !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important; background: #f4f9f5 !important;
        display: none !important; z-index: 3000 !important;
    }
    .tpl-sidebar.show { display: flex !important; }
    .tpl-sidebar .tpl-section-system { margin-top: 0 !important; box-shadow: none !important; border: none !important; background: transparent !important; }
}

/* ==============================================================================
   📱 手機 / 平板 完整響應式樣式 (MAX-WIDTH: 850px)
   ============================================================================== */
@media (max-width: 850px) {
    html, body { height: auto !important; min-height: 100vh !important; overflow-y: auto !important; overflow-x: hidden !important; }
    .main { flex-direction: column !important; height: auto !important; min-height: 100vh !important; overflow: visible !important; padding-bottom: 30px !important; }
    #libGrid .dish-card:hover, #libGrid .dish-card:active { transform: none !important; box-shadow: none !important; border-color: transparent !important; }

    .header { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; padding: 4px 8px !important; height: auto !important; min-height: 40px !important; gap: 8px !important; align-items: center !important; justify-content: flex-start !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .header-title { font-size: 8px !important; flex-shrink: 0 !important; white-space: nowrap !important; }
    .header-tools-container { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; gap: 6px !important; flex-shrink: 0 !important; }
    .header-tools-container .btn, .sk-gold-btn { white-space: nowrap !important; flex-shrink: 0 !important; padding: 5px 8px !important; font-size: 11px !important; }
    .sk-gold-btn span:not(:first-child) { display: none !important; }
    #btn-desktop-sys { display: none !important; }

    .ui-switcher { width: 148px !important; margin: 0 8px !important; padding: 4px !important; }
    .ui-switch-btn { font-size: 12px !important; padding: 5px 0 !important; }
    .ui-slider { top: 4px !important; left: 4px !important; width: calc(50% - 4px) !important; height: calc(100% - 8px) !important; }

    .workspace { order: 1 !important; overflow: visible !important; height: auto !important; padding: 10px 0 !important; flex-shrink: 0 !important; }
    .sidebar { order: 2 !important; position: relative !important; width: 100% !important; height: 480px !important; background: #ffffff !important; border-top: 3px solid var(--blue) !important; border-bottom: 3px solid #ccc !important; border-right: none !important; padding: 10px 12px !important; display: flex !important; flex-direction: column !important; flex-shrink: 0 !important; overflow-y: auto !important; }
    .tpl-sidebar { order: 3 !important; width: 100% !important; border-left: none !important; padding: 16px 15px 80px 15px !important; background: #f4f6f8 !important; overflow: visible !important; height: auto !important; flex-shrink: 0 !important; }

    .toolbar { justify-content: flex-start !important; padding: 8px !important; gap: 6px !important; flex-wrap: nowrap !important; overflow-x: visible !important; overflow-y: visible !important; }
    .toolbar .btn-main { flex: 1 !important; min-width: 110px !important; max-width: 48% !important; font-size: 13px !important; padding: 10px 6px !important; }
    .toolbar .input-box-dim { width: 52px !important; font-size: 12px !important; padding: 4px !important; }

    .canvas-container { padding: 5px 48px 5px 0px !important; min-height: 260px !important; overflow: auto !important; display: flex !important; justify-content: center !important; }
    .bento-outer { padding: 22px !important; border-width: 3px !important; }

    /* 🆕 設計模式(匯入制模)手機布局：畫布置中 + 儲存鈕可見 — 前賢 2026-09-01 */
    body.design-mode .toolbar.design-tools { flex-wrap: wrap !important; overflow-x: visible !important; }
    body.design-mode .toolbar .btn-main, body.design-mode .toolbar .btn { min-width: auto !important; max-width: none !important; white-space: nowrap !important; }
    body.design-mode .canvas-container { display: flex !important; justify-content: center !important; align-items: flex-start !important; padding: 8px !important; }
    body.design-mode .bento-outer { margin: 0 !important; transform-origin: center top !important; }

.floating-tools { position: fixed !important; right: 5px !important; top: auto !important; bottom: 20px !important; transform: scale(0.85) !important; transform-origin: right bottom !important; z-index: 600 !important; gap: 7px !important; }
    .floating-tools button { width: 52px !important; height: 52px !important; font-size: 10px !important; }
            .floating-tools .icon { font-size: 16px !important; }

    .lib-menu-popup {
        display: none; position: absolute !important;
        top: 100% !important; right: 0 !important; left: auto !important;
        margin-top: 8px !important; margin-left: 0 !important; transform: none !important;
        background: #ffffff !important; border: 1px solid #eaeaea !important; border-radius: 8px !important;
        box-shadow: 4px 4px 15px rgba(0,0,0,0.15) !important; padding: 6px !important;
        width: max-content !important; min-width: 110px !important; z-index: 9999 !important;
        flex-direction: column !important; gap: 4px !important;
    }
    .lib-menu-popup.open { display: flex !important; }
    .lib-menu-popup .lib-menu-item { width: 100% !important; justify-content: flex-start !important; }

    .dish-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 5px !important; }
    .dish-card { height: 88px !important; padding: 5px 3px 3px 3px !important; }
    .dish-card img { height: 50px !important; }
    .dish-name { font-size: 10px !important; margin-top: 3px !important; }

    .main:has(#libGrid[data-mode="round"]) #scaleWrapper { transform: scale(1.25) !important; transform-origin: center top !important; margin-top: -30px !important; }
    .main:has(#libGrid[data-mode="bento"]) #scaleWrapper, .main:has(#libGrid:not([data-mode])) #scaleWrapper { transform: scale(0.95) !important; transform-origin: center top !important; }

    #libGrid[data-mode="round"] { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; }
    #libGrid[data-mode="round"] .dish-card { height: 130px !important; padding: 5px 2px !important; }
    #libGrid[data-mode="round"] .dish-card img { height: 95px !important; margin-bottom: 0px !important; }
    #libGrid[data-mode="round"] .dish-name { font-size: 11px !important; line-height: 1.1 !important; }

    #batch-toolbar { bottom: 0 !important; left: 50% !important; border-radius: 16px 16px 0 0 !important; max-width: 100% !important; width: 100% !important; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) 16px !important; flex-direction: column !important; gap: 8px !important; }
    #batch-toolbar .batch-actions { width: 100% !important; justify-content: stretch !important; }
    #batch-toolbar button { flex: 1 !important; padding: 9px 8px !important; font-size: 12px !important; }

    .sidebar-section { margin-bottom: 12px !important; width: 100% !important; }
    .backup-action-row { display: flex !important; gap: 8px !important; }
    .btn-new-tpl, .btn-upload-bento, .btn-browse-photos { width: 100% !important; margin: 5px 0 !important; }
    #email-login-panel { position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; width: 90% !important; max-width: 320px !important; z-index: 1099999 !important; background: #fff !important; border: 2px solid var(--lacquer) !important; border-radius: 15px !important; padding: 25px 20px !important; box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important; }
    .popup-box.centered { width: 92% !important; max-width: 380px !important; padding: 16px !important; max-height: 85vh !important; overflow-y: auto !important; }
    #gallery-modal { width: 96% !important; max-width: 96% !important; max-height: 88vh !important; }
    #gallery-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    #rt-controls { min-height: auto !important; padding: 14px 10px !important; margin-bottom: 12px !important; }

    #customTplSelected { font-size: 0 !important; gap: 0 !important; justify-content: center !important; }
    #customTplWrapper { min-width: 105px !important; max-width: 138px !important; flex: none !important; }
    #customTplWrapper .custom-select-trigger { padding: 6px !important; justify-content: center !important; gap: 4px !important; }
    #customTplWrapper .custom-select-options { left: auto !important; right: 0 !important; width: max-content !important; min-width: 140px !important; max-width: 280px !important; box-sizing: border-box !important; }
    #customTplWrapper .custom-option { white-space: nowrap !important; justify-content: flex-start !important; gap: 10px !important; font-size: 13px !important; }

    .btn-toolbar-see,
    .btn-toolbar-save { min-width: 72px !important; max-width: none !important; font-size: 12px !important; padding: 8px 6px !important; border-radius: 8px !important; }
}

/* ==============================================================================
   📱 平板 響應式微調 (600px - 850px)
   ============================================================================== */
@media (min-width: 600px) and (max-width: 850px) {
    #batch-toolbar { flex-direction: row !important; border-radius: 16px !important; bottom: 16px !important; width: auto !important; max-width: calc(100vw - 40px) !important; }
    .sidebar { height: 440px !important; overflow-y: auto !important; }
    .dish-grid { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
    .ui-switcher { width: 148px !important; margin: 0 8px !important; padding: 4px !important; }
    .ui-switch-btn { font-size: 12px !important; padding: 5px 0 !important; }
    .ui-slider { top: 4px !important; left: 4px !important; width: calc(50% - 4px) !important; height: calc(100% - 8px) !important; }
    #customTplWrapper { min-width: 60px !important; max-width: 80px !important; }
    #customTplSelected span { display: none !important; }
}

/* ==============================================================================
   🎨 工具列三按鈕美化 & 照片庫側欄隱藏
   ============================================================================== */
#sidebar-bento-galleries, #sidebar-table-galleries { display: none !important; }

.btn-toolbar-see {
    flex: 1; min-width: 100px; max-width: 180px; padding: 10px 16px;
    font-size: 14px; font-weight: bold; border-radius: 10px; border: none; cursor: pointer;
    color: white; background: linear-gradient(135deg, #4A90D9, #2196F3);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4); text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap;
}
.btn-toolbar-see:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 6px 18px rgba(33, 150, 243, 0.5); }
.btn-toolbar-see:active { transform: scale(0.96); }

.btn-toolbar-save {
    flex: 1; min-width: 100px; max-width: 180px; padding: 10px 16px;
    font-size: 14px; font-weight: bold; border-radius: 10px; border: none; cursor: pointer;
    color: white; background: linear-gradient(135deg, #E6B956, #D4A843);
    box-shadow: 0 4px 12px rgba(212, 168, 67, 0.45); text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap;
}
.btn-toolbar-save:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 6px 18px rgba(212, 168, 67, 0.55); }
.btn-toolbar-save:active { transform: scale(0.96); }

#customTplWrapper .custom-select-trigger {
    background: linear-gradient(135deg, #fffdf7, #fff8eb);
    border: 1.5px solid #D4A843; border-radius: 10px;
    box-shadow: 0 4px 10px rgba(212,168,67,0.15);
    font-weight: bold; color: #7a5c2e;
    transition: border-color 0.2s, box-shadow 0.2s; min-height: 42px;
}
#customTplWrapper .custom-select-trigger:hover { border-color: #C94C28; box-shadow: 0 4px 14px rgba(212,168,67,0.3); }

/* --- 💬 留言區 scrollbar --- */
#comments-list::-webkit-scrollbar { width: 4px; }
#comments-list::-webkit-scrollbar-thumb { background: rgba(212,168,67,0.4); border-radius: 2px; }

/* ── 格子置入目標虛框動畫 ── */
@keyframes march-gold {
    0%   { outline-offset: 0px;  outline-color: rgba(212,168,67,1); }
    50%  { outline-offset: 2px;  outline-color: rgba(212,168,67,0.6); }
    100% { outline-offset: 0px;  outline-color: rgba(212,168,67,1); }
}
@keyframes march-blue {
    0%   { outline-offset: 0px;  outline-color: rgba(33,150,243,0.7); }
    50%  { outline-offset: 1px;  outline-color: rgba(33,150,243,0.3); }
    100% { outline-offset: 0px;  outline-color: rgba(33,150,243,0.7); }
}
@keyframes bg-pulse-red {
    0%,100% { background-color: rgba(244,67,54,0.30); }
    50%     { background-color: rgba(244,67,54,0.55); }
}
@keyframes bg-pulse-gold {
    0%,100% { background-color: rgba(212,168,67,0.10); }
    50%     { background-color: rgba(212,168,67,0.25); }
}
@keyframes bg-pulse-blue {
    0%,100% { background-color: rgba(33,150,243,0.05); }
    50%     { background-color: rgba(33,150,243,0.12); }
}
@keyframes cardWobble { 0%,100% { transform: rotate(0deg); } 20% { transform: rotate(-1.5deg); } 60% { transform: rotate(1.5deg); } }

/* 其他空格 */
.slot.slot-empty { cursor: pointer !important; z-index: 5 !important; }
/* 🛠️ 手機批量工具列強制置中（修復偏右 — 前賢 2026-08-16「顯示框偏右跑到螢幕外」） */
@media (max-width: 850px) {
    #batch-toolbar.visible, #libGrid.batch-select-mode ~ #batch-toolbar {
        position: fixed !important;
        bottom: 12px !important;
        top: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
        min-width: 0 !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 16px !important;
        margin: 0 auto !important;
        z-index: 9000 !important;
    }
}

/* 🖥️ 桌機隱藏（手機才顯示）— 前賢 2026-08-24「電腦版不需要多一個入口」 */
@media (min-width: 768px) {
    .desktop-hide { display: none !important; }
}
