/* ================= 烏衣行打點時間 - 樣式表 (整理純淨版) ================= */

:root { 
    --sentence-font-size: 16px; 
    --color-p0: #00897B; --color-p1: #1E88E5; --color-p2: #43A047; --color-p3: #F4511E; --color-p4: #8E24AA; 
    --color-p5: #D81B60; --color-p6: #E53935; --color-p7: #3949AB; --color-p8: #00ACC1; --color-p9: #FDD835; 
}

/* ================= 1. 全域與版面基礎 ================= */
body { 
    font-family: sans-serif; 
    padding: 15px; 
    background: #F4F7F6; 
    color: #333; 
    max-width: 800px;
    margin: 0 auto; 
    padding-bottom: 80px; 
}
h2 { color: #00897B; text-align: center; }

button, 
.material-icons, 
.list-header h3, 
.sentence-label,
#speedDisplay, 
#zoomDisplay,
label {
    user-select: none; /* 標準語法 */
    -webkit-user-select: none; /* 支援 Safari/Chrome */
    -moz-user-select: none; /* 支援 Firefox */
    -ms-user-select: none; /* 支援舊版 Edge/IE */
}

/* 基礎面板 */
.panel { 
    background: white; 
    padding: 15px; 
    border-radius: 8px; 
    margin-bottom: 15px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-header h3 { margin: 0; }
.setup-section { margin-bottom: 20px; }
.section-title { font-weight: bold; color: #00695C; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 1.05rem;}

/* ================= 2. 表單與輸入框 ================= */
input[type="text"], input[type="number"], select, textarea {
    outline: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* 點擊時的綠色柔和光暈 */
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
    border-color: #00897B !important;
    box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.2) !important;
}

.textarea-wrapper { position: relative; margin-bottom: 10px; }
textarea { width: 100%; box-sizing: border-box; padding: 10px; padding-right: 75px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; height: 100px; resize: vertical; display: block;}
.textarea-tools { position: absolute; top: 10px; right: 25px; display: flex; gap: 5px; }
.tool-btn { background: rgba(255, 255, 255, 0.9); border: 1px solid #ddd; border-radius: 4px; padding: 4px; color: #666; cursor: pointer; display: flex; align-items: center; justify-content: center; min-width: auto; flex: none; height: auto; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.1);}
.tool-btn:hover { background: #E0F2F1; color: #00897B; border-color: #00897B; }
.tool-btn .material-icons { font-size: 1.2rem; }

/* 智慧伸縮輸入框 */
#rawTextInput { height: 45px; min-height: 45px; overflow-y: auto; resize: none; transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-sizing: border-box; width: 100%; padding: 10px; }
#rawTextInput:focus, #rawTextInput:not(:placeholder-shown) { height: 130px; }

.audio-input-section { display: flex; flex-direction: column; gap: 10px; background: #FAFAFA; padding: 10px; border-radius: 6px; border: 1px solid #E0E0E0; }
.audio-input-section input[type="text"] { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; margin: 0;}
.file-input-wrapper { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audio-input-section input[type="file"] { display: block; font-size: 0.95rem; cursor: pointer; flex: none;}
.local-file-hint { color: #E65100; font-size: 0.85rem; display: flex; align-items: flex-start; gap: 4px; line-height: 1.5; word-break: break-word;}
.local-file-hint .material-icons { margin-top: 2px; }

/* ================= 3. 按鈕系統 ================= */
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch;}
button { flex: 1; min-width: 100px; padding: 10px; font-size: 0.95rem; cursor: pointer; border: none; border-radius: 8px; background: #00897B; color: white; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 4px; transition: background 0.2s; }
button:active { background: #00695C; }

.btn-small { padding: 6px 12px; font-size: 0.85rem; min-width: auto; flex: none; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px;}
.btn-small .material-icons { font-size: 1rem; }

/* 實心主按鈕懸浮特效 */
.btn-primary { background-color: #00897B !important; color: white !important; transition: all 0.2s ease; }
.btn-primary:hover { background-color: #00695C !important; box-shadow: 0 2px 6px rgba(0, 137, 123, 0.3) !important; }

/* 輕量化外框按鈕 */
.btn-outline { background-color: transparent !important; border: 1px solid #00897B; color: #00897B; transition: all 0.2s ease; }
.btn-outline:hover { background-color: #E0F2F1 !important; color: #00695C !important; border-color: #00695C !important; }
.btn-outline:active { background-color: #B2DFDB !important; }

/* 破壞性操作按鈕 */
.btn-danger { background-color: transparent !important; color: #DC2626 !important; border: 1px solid #DC2626 !important; transition: all 0.2s ease; }
.btn-danger:hover { background-color: #FEF2F2 !important; color: #B91C1C !important; border-color: #B91C1C !important; box-shadow: none !important; }
.btn-danger:active { background-color: #FEE2E2 !important; }

/* 無邊框純文字按鈕 */
.btn-text { background: transparent; border: none; box-shadow: none; padding: 6px 12px; font-size: 0.9rem; font-weight: bold; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background 0.2s ease; flex: none; min-width: auto; }
.btn-text:hover { background: #E2E8F0; }
.btn-text .material-icons { font-size: 1.15rem; }

/* 各式匯出專用顏色 */
.btn-srt { background: #673AB7; color: white; border: 1px solid #512DA8; }
.btn-srt:active { background: #512DA8; }
.btn-excel { background: #107C41; color: white; border: 1px solid #0B5C30; }
.btn-excel:active { background: #0B5C30; }
.btn-secondary { background: #FF7043; }
.btn-audacity { background: #1976D2; }
.btn-audacity-outline { background: transparent; border: 1px solid #1976D2; color: #1976D2; }

/* 膠囊按鈕 */
.action-section { display: flex; gap: 10px; align-items: center; justify-content: flex-start; flex-wrap: wrap;}
.capsule-wrapper { position: relative; display: inline-flex; }
.capsule-group { display: inline-flex; align-items: stretch; background: #00897B; border-radius: 24px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.15); white-space: nowrap; }
.capsule-group.outline { background: white; border: 1px solid #00897B; box-shadow: none;}
.capsule-group.outline .capsule-btn { color: #00897B; background: transparent;}
.capsule-btn { background: transparent; color: white; border: none; padding: 8px 16px; font-size: 0.95rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 6px; flex: none; min-width: auto; }
.capsule-btn:hover { background: rgba(255,255,255,0.15); }
.capsule-group.outline .capsule-btn:hover { background: rgba(0,137,123,0.08); }
.capsule-toggle { background: transparent; color: white; border: none; border-left: 1px solid rgba(255,255,255,0.3); padding: 0 6px; cursor: pointer; display: flex; align-items: center; flex: none; min-width: auto; }
.capsule-toggle:hover { background: rgba(255,255,255,0.2); }
.capsule-toggle .material-icons { font-size: 1.2rem; } 

/* 方形外框分割按鈕 */
.split-btn-group { display: inline-flex; align-items: stretch; background: transparent; border: 1px solid #00897B; border-radius: 6px; overflow: hidden; height: 32px; }
.split-btn-group .main-btn, .split-btn-group .drop-btn { background: transparent; color: #00897B; border: none; font-size: 0.85rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; transition: all 0.2s ease; border-radius: 0; min-width: auto; white-space: nowrap; flex: none; }
.split-btn-group .main-btn { padding: 0 12px; }
.split-btn-group .drop-btn { padding: 0 2px; border-left: 1px solid #00897B; }
.split-btn-group .drop-btn .material-icons { font-size: 1.2rem; }
.split-btn-group .main-btn:hover, .split-btn-group .drop-btn:hover { background-color: #E0F2F1; color: #00695C; }
.split-btn-group .main-btn:active, .split-btn-group .drop-btn:active { background-color: #B2DFDB; }

/* 下拉選單 */
.custom-dropdown-menu { 
    position: absolute; left: 0; margin-top: 8px; background: white; 
    border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1); 
    min-width: 160px; z-index: 1000; display: none; flex-direction: column; padding: 8px 0; 
    
    /* ★ 核心修正：限制最大高度並允許垂直滾動 */
    max-height: 50vh; /* 最高只佔螢幕高度的 50% */
    overflow-y: auto; 
    scrollbar-width: thin; /* 針對 Firefox 的細滾動條設定 */
}
.custom-dropdown-menu.show { display: flex; } 
.custom-dropdown-menu.upwards { top: auto; bottom: 100%; margin-top: 0; margin-bottom: 8px; }

/* ★ 核心修正：為 Chrome/Edge/Safari 設計專屬極細滾動條 */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 6px; /* 極細的寬度 */
}
.custom-dropdown-menu::-webkit-scrollbar-track {
    background: transparent; /* 滾動軌道保持透明，視覺更乾淨 */
    margin: 4px 0; /* 上下保留一點呼吸空間 */
}
.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #CFD8DC; /* 淡淡的優雅灰色 */
    border-radius: 10px; /* 圓角設計 */
}
.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #90A4AE; /* 滑鼠經過時稍微加深，增加互動感 */
}

.custom-dropdown-item { 
    padding: 10px 16px; color: #333; font-size: 0.95rem; cursor: pointer; user-select: none; 
    display: flex; align-items: center; gap: 8px; 
    flex-shrink: 0; /* 防止項目被擠壓變形 */
}
.custom-dropdown-item:hover { background: #F0F4F8; color: #00897B; }
.custom-dropdown-item .material-icons { font-size: 1.2rem; }


/* ================= 4. 動態標題編輯與首頁變身特效 ================= */
/* 可編輯標題專屬互動特效 (底線風格) */
.editable-title {
    display: inline-block; padding: 4px 8px; cursor: text;
    outline: none !important; border-bottom: 2px dashed transparent; transition: all 0.2s ease;
}
.editable-title:hover { border-bottom: 2px dashed #B2DFDB; }
.editable-title:focus { background-color: rgba(224, 242, 241, 0.3); border-bottom: 2px solid #00897B; }

/* 首頁空狀態標題禁止修改 */
body.is-empty-state #mainTitleDisplay { pointer-events: none; }

/* 歡迎容器動態排版 */
.welcome-container { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); }
body.is-empty-state .welcome-container { justify-content: center; min-height: 75vh; }


#mainTitleDisplay { transition: font-size 0.4s ease, margin 0.4s ease; }
body.is-empty-state #mainTitleDisplay { font-size: 3.2rem; margin-bottom: 25px !important; }

body:not(.is-empty-state) #mainTitleDisplay { 
    font-size: 1.8rem; 
    margin-top: 60px !important; 
    margin-bottom: 4px !important; 
    padding: 0 15px;
}
/* 頂部圖示：空狀態才顯示 */
.welcome-icon { font-size: 5rem; margin-bottom: 10px; display: none; }
body.is-empty-state .welcome-icon { display: block; animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.action-buttons-container { display: flex; gap: 12px; align-items: center; transition: all 0.4s ease; }
body.is-empty-state .action-buttons-container { justify-content: center; }
body:not(.is-empty-state) .action-buttons-container {
    position: fixed; top: 20px; right: 20px; z-index: 2000;
    background: transparent; backdrop-filter: none; padding: 0; border-radius: 0; box-shadow: none; border: none;
    gap: 4px; /* ★ 修改：縮小在右上角時，按鈕之間的間距 */
}

/* 1. 無邊框幽靈按鈕 (次要動作專用) */
.btn-ghost {
    background-color: transparent !important;
    border: 1px solid transparent !important; /* 佔位防止跳動 */
    color: #5F6368 !important; /* Google 經典灰 */
    transition: all 0.2s ease;
}
.btn-ghost:hover {
    background-color: #F1F3F4 !important; /* 懸浮時的淺灰色 */
    color: #202124 !important;
}

/* 2. 無邊框危險按鈕 (清除全部專用) */
.btn-ghost-danger {
    background-color: transparent !important;
    border: 1px solid transparent !important;
    color: #5F6368 !important; /* 預設也是低調灰色，不搶眼 */
    transition: all 0.2s ease;
}
.btn-ghost-danger:hover {
    background-color: #FCE8E6 !important; /* 懸浮時的淺紅色 */
    color: #D93025 !important; /* Google 警告紅 */
}

/* ================= ★ 動作按鈕群組 (定位控制) ★ ================= */
.action-buttons-container { 
    display: flex; align-items: center; transition: all 0.4s ease; 
}

/* 動作按鈕全體套用現代膠囊形狀 (Pill Shape) */
.action-btn {
    font-weight: bold; 
    justify-content: center; 
    border-radius: 24px !important; 
    transition: all 0.3s ease; 
    white-space: nowrap;
    box-shadow: none !important; 
    
    /* ★ 核心修復：解除全域 button 的 100px 限制，讓按鈕寬度完全貼合文字 */
    min-width: auto !important; 
    flex: none !important;
}

/* ================= 【狀態 A】首頁空狀態：置中與專屬大小 ================= */
body.is-empty-state .action-buttons-container { 
    justify-content: center; 
    gap: 16px; /* 讓首頁的按鈕之間有舒適的呼吸空間 */
}

/* 首頁的次要按鈕 (兩個字) */
body.is-empty-state .action-btn {
    padding: 8px 16px; 
    font-size: 1.05rem;
}

/* ★ 首頁的主按鈕 (選擇音檔)：給予專屬的寬度與氣勢 */
body.is-empty-state #openAudioModalBtn {
    padding: 10px 32px; 
    font-size: 1.15rem;
}


/* ================= 【狀態 B】工作狀態：移至右上角並縮小 ================= */
body:not(.is-empty-state) .action-buttons-container {
    position: absolute; /* 跟隨網頁滾動 */
    top: 20px; right: 20px; z-index: 2000;
    background: transparent; backdrop-filter: none; padding: 0; border-radius: 0; box-shadow: none; border: none;
    gap: 6px; /* ★ 右上角維持緊湊的間距 */
}

/* 右上角的所有按鈕：統一縮小並貼合 */
body:not(.is-empty-state) .action-btn {
    padding: 6px 8px; 
    font-size: 0.85rem; 
}

body:not(.is-empty-state) .action-btn .material-icons {
    font-size: 1.1rem; /* 圖示跟著縮小 */
}

/* 右上角的特殊配色 */
body:not(.is-empty-state) .action-buttons-container .btn-primary {
    background-color: #E0F2F1 !important; 
    color: #00695C !important; 
}
body:not(.is-empty-state) .action-buttons-container .btn-primary:hover {
    background-color: #B2DFDB !important; 
}

/* 隱藏左側選單與清除按鈕 (空狀態時) */
#openSidebarBtn { transition: all 0.3s ease; }
body.is-empty-state #openSidebarBtn { opacity: 0; pointer-events: none; transform: scale(0.8); }
body.is-empty-state #clearStorageBtn { display: none !important; }
body.is-empty-state #openExportModalBtn { display: none !important; }

body:not(.is-empty-state) #openAudioModalBtn {
    display: none !important;
}

/* ================= 5. 聲波圖面板 ================= */
.sticky-panel {
    position: sticky; top: 0; z-index: 100; 
    padding: 16px 16px 4px 16px !important; 
    background-color: #ffffff !important;
    border: 1px solid #F1F5F9 !important; border-radius: 16px !important; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.03) !important; 
    margin-bottom: 8px !important; width: var(--wave-width, 100%); max-width: 96vw;
    margin-left: calc((100% - min(var(--wave-width, 100%), 96vw)) / 2) !important; box-sizing: border-box; 
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), margin-left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#waveform { margin-bottom: 10px; border-radius: 4px; overflow: hidden; background: #F0F4F8; display: none; cursor: default !important; }
#waveform ::part(wrapper) { cursor: default !important; }

.controls-compact { 
    display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 4px 0; 
    background: transparent; border-radius: 0; box-shadow: none; justify-content: flex-start; 
    margin-top: 6px; 
}
.controls-compact::-webkit-scrollbar { display: none; }
.controls-compact .btn-icon { margin: 0 !important; width: 36px; height: 36px; min-width: 36px; }
.btn-icon { flex: 0 0 36px; width: 36px; height: 36px; padding: 0; min-width: auto; border-radius: 50%; background: #4DB6AC; }


/* ========================================================
   ★ 時間顯示區塊 (無斜線、上下排列、大小風格一致)
   ======================================================== */
.audio-timer { 
    font-family: monospace; 
    background: #E0F2F1; 
    margin: 0 5px;
    
    /* Flexbox 讓文字上下堆疊並置中 */
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    
    /* 調整方塊內邊距與圓角 */
    padding: 4px 10px; 
    border-radius: 8px; 
    line-height: 1.2;
    font-size: 0.9rem; /* ★ 統一在此設定字體大小，讓上下兩行保持一致 */
}

/* ★ 目前時間 (跳動中)：僅套用紅色 */
#audioTimeCurrent {
    color: #E53935; 
}

/* ★ 全部時間 (固定總長)：僅套用綠色 */
#audioTimeTotal {
    color: #388E3C; 
}

#audioTimeCurrent {
    color: #E53935;
    font-size: 0.95rem;
}

#audioTimeTotal {
    color: #388E3C; 
    opacity: 0.9;
}


.speed-select { height: 36px; border-radius: 20px; padding: 0 10px; flex: 0 0 auto; border: 1px solid #4DB6AC; color: #00897B; font-weight: bold; outline: none; cursor: pointer; background: white;}
.zoom-controls { flex: 1; display: flex; align-items: center; gap: 5px; background: #F0F4F8; padding: 0 10px; border-radius: 20px; height: 36px; color: #00897B; min-width: 120px; }
input[type="range"] { flex: 1; accent-color: #00897B; }

/* ================= 6. 清單列表區塊 ================= */
.list-panel { position: relative; padding-top: 0; }
.list-header-container { 
    position: sticky; z-index: 90; background: rgba(255,255,255,0.95); backdrop-filter: blur(4px); 
    padding: 6px 0 6px 0; 
    border-bottom: 2px solid #E0F2F1; 
    margin-bottom: 4px;
}
.list-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.list-header h3 { margin: 0; }
.header-tools {  flex-wrap: wrap; background: transparent !important; border: none !important; box-shadow: none !important; padding: 4px 0 !important; display: inline-flex !important; align-items: center; gap: 2px !important; }

.header-btn { padding: 6px 12px; min-width: auto; height: 34px; font-size: 0.85rem; border-radius: 17px; background: transparent; color: #555; white-space: nowrap; display: flex; align-items: center; gap: 4px; border: none; transition: all 0.2s ease; }
.header-btn .material-icons { font-size: 1.1rem; color: #00897B; transition: color 0.2s ease; }
.header-btn:hover { background: #E0F2F1; color: #00695C; }
.header-btn:hover .material-icons { color: #00695C; }
.header-btn.toggle-btn.active { background: #00897B; color: white; }
.header-btn.toggle-btn.active .material-icons { color: white; }

#toggleScriptModeBtn { background: #E0F2F1; color: #00897B; font-weight: bold; }
#toggleScriptModeBtn:hover { background: #B2DFDB; }
.toggle-mode-btn { background: #FFF3E0; color: #E65100; border: 1px solid #FFB74D; font-weight: bold; }
.toggle-mode-btn:hover { background: #FFE0B2; }
.toggle-mode-btn .material-icons { color: #E65100; }

.vertical-divider { width: 1px; height: 20px; background-color: #dadce0; margin: 0 4px; display: inline-block; vertical-align: middle;}

/* 列表項目 */
#sentenceList { display: flex; flex-direction: column; gap: 0; }
/* 列表項目 */
.sentence-item { 
    background: transparent; border-bottom: 1px dashed #CCC; border-left: 4px solid transparent; 
    padding: 10px 10px; 
    display: flex; justify-content: space-between; align-items: center; 
    scroll-margin-top: 150px; transition: background-color 0.2s, box-shadow 0.2s; cursor: pointer;
}
.sentence-item:last-child { border-bottom: none; }
.sentence-item:hover { background-color: #FAFAFA; } 
.sentence-item.tagged { border-left: 4px solid #B2DFDB; }
.sentence-item.playing { background: #F2F9F8; border-left: 4px solid #00897B; border-bottom: 1px solid #E0F2F1; box-shadow: 0 2px 8px rgba(0, 137, 123, 0.06); border-radius: 4px; }
.sentence-item.selected-row { background-color: #E3F2FD !important; border-left: 4px solid #1976D2 !important;}

body.is-view-mode .sentence-item.tagged { border-left: 4px solid transparent; }
body.is-view-mode .sentence-item.playing { border-left: 4px solid #00897B; }

.sentence-content { display: flex; align-items: center; flex: 1; gap: 10px; position: relative; } 
.sentence-label { font-family: monospace; font-weight: bold; }

.sentence-text-display { flex: 1; font-size: var(--sentence-font-size); transition: font-size 0.2s; line-height: 1.6; margin-right: 10px; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; word-break: break-word; min-height: 1.6em;}
.sentence-text-display.is-editable { background-color: #FAFAFA; cursor: text; }
.sentence-text-display.is-editable:focus { border: 1px solid transparent; background-color: #FFF; outline: none; }

.sentence-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.sentence-time { 
    font-family: monospace; font-weight: bold; color: #00897B; font-size: 0.9em; 
    text-align: left; min-width: 60px; margin: 0 4px; padding: 4px 8px; 
    border-radius: 4px; transition: background 0.2s; cursor: pointer;
    display: flex; flex-direction: column; justify-content: center; align-items: flex-end;
    line-height: 1.25;
}
.sentence-time:hover { background: #E0F2F1; }

.action-icon-btn { display: flex; border-radius: 4px; width: 30px; height: 30px; flex: 0 0 30px; align-items: center; justify-content: center; cursor: pointer; padding: 0; min-width: auto; }
.action-icon-btn .material-icons { font-size: 1.2rem; }

.verify-btn { display: none; background: #FFF3E0; color: #E65100; border: 1px solid #FFB74D; border-radius: 50%; }
.tag-time-btn { display: none; background: #E0F2F1; color: #00897B; border: 1px solid #B2DFDB; border-radius: 50%;}
.shift-time-btn { display: none; background: #F3E5F5; color: #7B1FA2; border: 1px solid #E1BEE7; }
.clear-tag-btn { display: none; background: #FFEBEE; color: #C62828; border: 1px solid #EF9A9A; width: 24px; height: 24px; flex: 0 0 24px; }
.clear-tag-btn .material-icons { font-size: 1rem; }

.ai-transcribe-btn { display: none; background: #E3F2FD; color: #1976D2; border: 1px solid #BBDEFB; }
.show-ai-btns .sentence-item.tagged .ai-transcribe-btn { display: flex; }
body.is-view-mode .sentence-item .ai-transcribe-btn { display: none !important; }

/* 列表內嵌刪除按鈕 (極簡純圖示版 - 修正橢圓變形問題) */
.inline-delete-btn { 
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%); 
    background: transparent; color: #C62828; border: none; border-radius: 50%; 
    
    /* ★ 核心修復：強制設定固定尺寸，並解除全域按鈕的寬度限制 */
    width: 36px !important; 
    height: 36px !important; 
    min-width: 36px !important; 
    flex: none !important; 
    padding: 0 !important; 
    
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; z-index: 10; transition: background 0.2s ease; box-shadow: none;
}

.inline-delete-btn:hover { 
    background: #FFEBEE; 
}

.inline-delete-btn .material-icons { 
    font-size: 1.3rem; 
    margin: 0; /* 確保圖示不受外距干擾，完美置中 */
}

body.is-view-mode .inline-delete-btn { display: none !important; }
.more-options-btn { display: none; background: transparent; color: #666; }
.more-options-btn:hover { background: #EEE; color: #333; }
.show-more-btns .sentence-item .more-options-btn { display: flex; } 

.item-more-menu { right: 0; left: auto; min-width: 220px; }
.item-more-menu hr { margin: 4px 0; border: none; border-bottom: 1px solid #EEE; }
.item-more-menu .custom-dropdown-item { padding: 8px 16px; display: flex; align-items: center; gap: 8px;}

.show-tag-btns .sentence-item .tag-time-btn { display: flex; }
.show-clear-btns .sentence-item.tagged .clear-tag-btn { display: flex; }
.show-shift-btns .sentence-item.tagged .shift-time-btn { display: flex; }
body.is-view-mode .hide-in-view { display: none !important; }
.is-view-mode .sentence-item .tag-time-btn { display: none !important; }
.is-view-mode .sentence-item .clear-tag-btn, .is-view-mode .sentence-item .shift-time-btn { display: none !important; }
.is-view-mode .sentence-item .more-options-btn { display: none !important; } 

/* ================= 7. 劇本編輯器 (Script Mode) ================= */
#scriptEditorContainer {
    display: flex; background: #ffffff; border: 1px solid #dadce0; border-radius: 8px; height: 55vh; min-height: 400px;
    overflow: hidden; box-shadow: inset 0 1px 4px rgba(0,0,0,0.06); margin-top: 10px;
}
#scriptGutter {
    width: 55px; background: #f8f9fa; border-right: 1px solid #dadce0; padding: 16px 0 !important;
    font-family: Consolas, "Courier New", monospace !important; font-size: var(--sentence-font-size) !important;
    line-height: 1.8 !important; color: #90a4ae; text-align: center; overflow-y: hidden; user-select: none; box-sizing: border-box !important;
}
.gutter-line { height: 1.8em; line-height: 1.8em; box-sizing: border-box; cursor: pointer; transition: background 0.1s; }
.gutter-line:hover { background: #e0f2f1; color: #00897b; }
.gutter-line.active { background: #00897b; color: white; font-weight: bold; }
.gutter-line.para { color: #78909c; font-size: inherit; font-weight: bold; background: #eceff1; cursor: default; }

#scriptTextarea {
    flex: 1; height: 100% !important; min-height: 100% !important; border: none !important; border-radius: 0 !important;
    box-shadow: none !important; background: transparent !important; margin: 0 !important; padding: 16px !important;
    font-family: Consolas, "Courier New", monospace !important; font-size: var(--sentence-font-size) !important;
    line-height: 1.8 !important; resize: none !important; outline: none !important; white-space: pre !important; 
    overflow: auto !important; color: #333; box-sizing: border-box !important;
}

/* ================= 8. 共用元件 (Toast / Modal / Sidebar) ================= */
#toast { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 8px; padding: 12px 20px; position: fixed; z-index: 3000; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 1rem; opacity: 0; transition: opacity 0.3s, bottom 0.3s; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
#toast.show { visibility: visible; opacity: 1; bottom: 50px; }
#toast.error { background-color: #E53935; }
#toast.success { background-color: #43A047; }

#scrollToTopBtn { position: fixed; bottom: 30px; right: 30px; z-index: 999; background: #00897B; color: white; border: none; width: 48px; height: 48px; min-width: 48px; min-height: 48px; box-sizing: border-box; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); box-shadow: 0 4px 10px rgba(0, 137, 123, 0.3); }
#scrollToTopBtn.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
#scrollToTopBtn:not(.visible) { transform: translateY(20px); }
#scrollToTopBtn:hover { background: #00695C; box-shadow: 0 6px 14px rgba(0, 137, 123, 0.4); transform: translateY(-2px); }
#scrollToTopBtn:active { transform: translateY(0) scale(0.95); }
#scrollToTopBtn .material-icons { font-size: 32px; line-height: 1; margin: 0; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-overlay.show { display: flex; }
.custom-modal { background: white; width: 90%; max-width: 400px; border-radius: 12px; padding: 24px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.custom-modal h4 { margin: 0 0 15px 0; color: #00897B; font-size: 1.2rem; }
.custom-modal p { margin: 0 0 20px 0; color: #555; line-height: 1.5; white-space: pre-wrap; }
.custom-modal input[type="text"], .custom-modal input[type="number"] { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ccc; border-radius: 6px; margin-bottom: 20px; font-size: 1rem; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.modal-buttons button { flex: none; min-width: 80px; padding: 8px 20px; border-radius: 20px; }
.btn-modal-confirm { background: #00897B; }
.btn-modal-cancel { background: #80DEEA; color: #006064; }

/* 側邊欄與相關按鈕 */
.floating-setting-btn {
    position: fixed; top: 20px; left: 20px; z-index: 1000;
    background: transparent; color: #00897B; border: none;
    box-shadow: none; cursor: pointer; transition: all 0.2s;
    padding: 0; display: flex; align-items: center; gap: 8px;
}
.floating-setting-btn:hover { background: transparent; transform: scale(1.05); }
.floating-setting-btn .material-icons { font-size: 2rem; }
#topLeftTitle { 
    font-size: 1.25rem; font-weight: bold; color: #00695C; 
    transition: opacity 0.3s ease; 
}
#topLeftTitle.is-scrolled { 
    opacity: 0; pointer-events: none; 
}

.sidebar { overscroll-behavior: contain; position: fixed; top: 0; left: -320px; width: 300px; height: 100%; background: #FAFAFA; box-shadow: 2px 0 15px rgba(0,0,0,0.1); z-index: 2001; transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); display: flex; flex-direction: column; overflow-y: auto;}
.sidebar.open { left: 0; }
.sidebar-header { background: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #E0E0E0; position: sticky; top:0; z-index: 10;}
.sidebar-header h3 { margin: 0; color: #00897B; display: flex; align-items: center; gap: 8px; font-size: 1.1rem;}
.sidebar-content { padding: 20px; flex: 1; }
.sidebar-group { background: white; padding: 15px; border-radius: 8px; border: 1px solid #E0E0E0; margin-bottom: 15px;}
.sidebar-group h4 { margin: 0 0 15px 0; color: #333; font-size: 0.95rem; border-bottom: 2px solid #E0F2F1; padding-bottom: 6px; }

.shortcut-setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.shortcut-setting-row label { font-size: 0.85rem; color: #555; }
.shortcut-input { width: 120px; text-align: center; padding: 4px 8px; font-size: 0.8rem; font-family: monospace; font-weight: bold; color: #00897B; background: #E0F2F1; border: 1px solid #B2DFDB; border-radius: 4px; cursor: pointer; outline: none; transition: all 0.2s; }
.shortcut-input:focus { background: #FFF; border-color: #00897B; box-shadow: 0 0 5px rgba(0, 137, 123, 0.3); }

.rotating {
    animation: spin 1.5s linear infinite;
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}



/* ================= ★ 手機版 (Mobile) 專屬優化 ★ ================= */
@media (max-width: 768px) {
    /* ==============================================
       ★ 版面極致擴張：釋放手機螢幕左右邊界
       ============================================== */
    body { 
        /* 縮小網頁最外層左右留白為 4px，保留底部 80px 給回到頂端按鈕 */
        padding: 10px 4px 80px 4px !important; 
    }
    
    .panel { 
        /* 縮小列表區塊的內邊距 */
        padding: 10px 6px !important; 
        border-radius: 12px !important; /* 稍微縮小圓角讓版面更俐落 */
    }
    
    .sticky-panel {
        /* 縮小聲波圖區塊的內邊距，並解除電腦版的寬度限制 */
        padding: 10px 6px !important; 
        border-radius: 12px !important;
        max-width: 100% !important; 
        margin-left: 0 !important;
    }

    .list-header-container {
        /* 縮緊列表標題列的上下空間 */
        padding: 8px 0 6px 0 !important; 
    }


    /* 1. 隱藏左上角標題，節省空間 */
    #topLeftTitle { display: none !important; }

    /* 2. 進入工作狀態時，隱藏右上角的三個按鈕 (改由側邊欄操作) */
    body:not(.is-empty-state) .action-buttons-container {
        display: none !important;
    }

    /* 3. 因為按鈕隱藏了，標題不需要留 60px 的頂部空間，恢復適當距離 */
    body:not(.is-empty-state) #mainTitleDisplay {
        margin-top: 20px !important;
    }

    /* ==============================================
       ★ 列表區塊極致瘦身：釋放左右空間
       ============================================== */
    
    /* 縮小列表項目的左右內邊距 */
    .sentence-item { 
        padding: 10px 6px !important; 
    }
    
    /* 縮小左側播放按鈕與文字之間的距離 */
    .sentence-content { 
        gap: 6px !important; 
    }
    
    /* 縮小右側工具按鈕群的間距 */
    .sentence-actions { 
        gap: 4px !important; 
    }

    /* ==============================================
       ★ 「刪除」按鈕極簡化：純圖示、無邊框
       ============================================== */
    .inline-delete-btn {
        background: transparent !important;
        border: none !important;
        padding: 4px !important;
        min-width: auto !important;
        box-shadow: none !important;
        /* 神奇魔法：字體設為 0，隱藏文字 */
        font-size: 0 !important; 
        right: 4px !important; /* 靠右一點 */
    }
    .inline-delete-btn .material-icons {
        /* 單獨把圖示放大，保持點擊手感 */
        font-size: 1.4rem !important; 
        color: #D32F2F !important;
    }
    .inline-delete-btn:hover {
        background: #FFEBEE !important;
        border-radius: 50% !important;
    }

    /* ==============================================
       ★ 縮小時間標籤與圓形小按鈕
       ============================================== */
    .sentence-time {
        font-size: 0.8rem !important;
        padding: 2px 4px !important;
        min-width: auto !important;
        margin: 0 !important;
    }
    
    .action-icon-btn {
        width: 26px !important;
        height: 26px !important;
        flex: 0 0 26px !important;
    }
    .action-icon-btn .material-icons {
        font-size: 1.1rem !important;
    }
}


