/* --- Modern Finance App System Variables --- */
:root {
    /* 核心背景與卡片 */
    --bg-color: #F4F6F9;
    --card-bg: #FFFFFF;
    --card-border: transparent;
    
    /* 金融風格標誌性漸變色 */
    --primary-gradient: linear-gradient(135deg, #3A40FF 0%, #8A32FF 100%);
    /* 品牌與互動色 */
    --accent-color: #00D2FF; 
    --accent-hover: #00B4DB;
    --danger-color: #FF4B72;
    --star-color: #FFC107;
    /* 文字顏色 */
    --text-primary: #1A1A2E;
    --text-secondary: #8D93A5;
    
    /* 輸入框風格 */
    --input-bg: #F0F3F8; 
    --input-border: transparent;
    /* 彌散陰影 */
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(58, 64, 255, 0.08);
    --shadow-modal: 0 16px 40px rgba(0, 0, 0, 0.12);
    /* 圓角設定 */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 980px;
    /* 動態變數 */
    --font-size-base: 14px; 
    --preview-lines: 1; 
    
    /* 自動計算的比例變數 */
    --textarea-font-size: var(--font-size-base);
    --group-title-size: calc(var(--font-size-base) + 1px);
    --prompt-title-size: var(--font-size-base);
    --tool-size: calc(var(--font-size-base) * 2);
}

/* 深色模式設定 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0F0F17;
        --card-bg: #1A1A27;
        --accent-color: #00E5FF;
        --accent-hover: #00CFFF;
        --text-primary: #FFFFFF;
        --text-secondary: #7A809C;
        --input-bg: #252535; 
        --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
        --shadow-modal: 0 16px 40px rgba(0, 0, 0, 0.5);
    }
}

body.theme-light { --bg-color: #F4F6F9; --card-bg: #FFFFFF; --accent-color: #00D2FF; --text-primary: #1A1A2E; --text-secondary: #8D93A5; --input-bg: #F0F3F8; }
body.theme-dark { --bg-color: #0F0F17; --card-bg: #1A1A27; --accent-color: #00E5FF; --text-primary: #FFFFFF; --text-secondary: #7A809C; --input-bg: #252535; }

html, body { overscroll-behavior-y: none; }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif; -webkit-font-smoothing: antialiased; }
body { background-color: var(--bg-color); color: var(--text-primary); font-size: var(--font-size-base); padding-bottom: 100px; min-height: 100dvh; transition: background-color 0.4s ease, color 0.4s ease; }

.container { max-width: 900px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 16px 16px; transition: max-width 0.3s ease; }

.tab-content { display: none; animation: slideUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1); }
.tab-content.active { display: block; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 視圖頭部 */
.view-header { position: relative; display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; width: 100%; min-height: 40px; }
.view-title { position: absolute; left: 50%; transform: translateX(-50%); font-size: 20px; font-weight: 800; letter-spacing: -0.5px; text-align: center; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; pointer-events: none; z-index: 10; }
.header-left { flex-shrink: 0; display: flex; align-items: center; justify-content: flex-start; gap: 8px; position: relative; z-index: 20; }
.header-right { flex-shrink: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; position: relative; z-index: 20; }

/* 頂部「⋯」下拉選單樣式 */
.header-dropdown { position: relative; display: inline-block; }
.header-dropdown-menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 8px; background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-modal); border: 1px solid rgba(141, 147, 165, 0.15); z-index: 2000; overflow: hidden; min-width: 170px; flex-direction: column; }
.header-dropdown-menu.show { display: flex; animation: fadeIn 0.2s ease; }
.header-dropdown-item { padding: 14px 18px; display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 700; color: var(--text-primary); cursor: pointer; border-bottom: 1px solid rgba(141, 147, 165, 0.08); white-space: nowrap; transition: background 0.2s; user-select: none; }
.header-dropdown-item:last-child { border-bottom: none; }
.header-dropdown-item:hover { background: var(--input-bg); color: var(--accent-hover); }
.header-dropdown-item.active { background: rgba(0, 210, 255, 0.1); color: var(--accent-hover); }
.header-dropdown-item .icon { font-size: 18px; }

/* --- Global Buttons --- */
.btn { background: var(--accent-color); color: #000000; border: none; padding: 12px 24px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 800; cursor: pointer; transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1); display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 12px rgba(0, 210, 255, 0.3); white-space: nowrap; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0, 210, 255, 0.4); }
.btn:active { transform: scale(0.95); }
.btn-secondary { background: var(--input-bg); color: var(--text-primary); box-shadow: none; }
.btn-secondary:hover { background: #E4E9F2; box-shadow: var(--shadow-sm); }
body.theme-dark .btn-secondary:hover { background: #353545; }

.btn-outline { background: transparent; color: #007AFF; border: 2px solid #007AFF; padding: 12px 24px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 800; cursor: pointer; transition: all 0.3s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
body.theme-dark .btn-outline { color: var(--accent-color); border-color: var(--accent-color); }
.btn-outline:hover { background: rgba(0, 122, 255, 0.1); transform: translateY(-2px); }
body.theme-dark .btn-outline:hover { background: rgba(0, 210, 255, 0.1); }

.btn-header { background: var(--card-bg); color: var(--text-primary); border: 1px solid rgba(141, 147, 165, 0.2); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); transition: all 0.3s ease; flex-shrink: 0; }
.btn-header:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); }
.btn-header.active { background: var(--accent-color); color: #000; border-color: var(--accent-color); }
.btn-header .icon { font-size: 18px; line-height: 1; }

.btn-danger { background: rgba(255, 75, 114, 0.1); color: var(--danger-color); font-weight: 800; border: none; padding: 12px 24px; border-radius: var(--radius-pill); font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.btn-star { background: transparent; font-size: 18px; padding: 4px; border: none; cursor: pointer; transition: transform 0.3s; color: var(--text-secondary); }
.btn-star.starred { color: var(--star-color); }
.btn-star:hover { transform: scale(1.25); }

.icon-btn { width: var(--tool-size); height: var(--tool-size); padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: calc(var(--tool-size) * 0.45); flex-shrink: 0; background: var(--input-bg); transition: all 0.2s; border: none; cursor: pointer;}
.icon-btn:hover { background: var(--accent-color); color: #000; }

.color-picker-circle { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; border: 2px solid var(--card-bg); box-shadow: var(--shadow-sm); position: relative; flex-shrink: 0; cursor: pointer; }
.color-picker-circle input[type="color"] { position: absolute; top: -10px; left: -10px; width: 60px; height: 60px; cursor: pointer; border: none; padding: 0; background: transparent; }

.card-color-picker-wrapper { position: absolute; left: 0; top: 0; bottom: 0; width: 16px; z-index: 5; cursor: pointer; overflow: hidden; border-radius: 24px 0 0 24px; }
.card-color-picker-input { position: absolute; left: -20px; top: -20px; width: 50px; height: calc(100% + 40px); opacity: 0; cursor: pointer; padding: 0; border: none; }

/* --- Search Bar --- */
/* 🌟 修改點：原生 Flex 排版與移除寬度 transition 避免重新整理拉伸動畫 */
.search-container { 
    margin-bottom: 16px; 
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-input { 
    flex: 1;
    min-width: 0;
    width: 100%; 
    background: var(--card-bg); 
    border: none; 
    border-radius: var(--radius-pill); 
    padding: 14px 20px 14px 44px; 
    font-size: 14px; 
    font-weight: 600; 
    color: var(--text-primary); 
    outline: none; 
    transition: box-shadow 0.3s ease, transform 0.3s ease; 
    box-shadow: var(--shadow-sm); 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238D93A5' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E"); 
    background-repeat: no-repeat; 
    background-position: 16px center; 
}
.search-input:focus { box-shadow: 0 4px 16px rgba(58, 64, 255, 0.15); transform: translateY(-1px); }

.search-highlight { background-color: var(--highlight-color, #FFD700); color: #000; padding: 2px 6px; border-radius: 6px; font-weight: 800; display: inline-block; line-height: 1.2; margin: 0 2px; }
body.theme-dark .search-highlight { background-color: var(--highlight-color, #FFD700); color: #000; }

/* --- D&D Cues --- */
.apple-sortable-ghost { opacity: 0.3; background-color: var(--card-bg) !important; border: 2px dashed var(--accent-color) !important; border-radius: var(--radius-pill); transform: scale(0.98); }
.apple-sortable-drag { cursor: grabbing !important; box-shadow: var(--shadow-modal) !important; transform: scale(1.02); z-index: 1000; border-radius: var(--radius-pill); }

/* --- 高亮動畫 --- */
@keyframes highlightGlowPulse {
    0% { outline: 2px solid var(--star-color); box-shadow: 0 0 12px rgba(255, 193, 7, 0.4); background-color: rgba(255, 193, 7, 0.1); transform: scale(1); }
    50% { outline: 2px solid var(--star-color); box-shadow: 0 0 16px rgba(255, 193, 7, 0.6); background-color: rgba(255, 193, 7, 0.15); transform: scale(1); }
    100% { outline: 0px solid transparent; box-shadow: var(--shadow-sm); background-color: transparent; transform: scale(1); }
}
.highlight-flash { animation: highlightGlowPulse 1.8s ease-in-out !important; border-radius: var(--radius-lg); }

/* --- Group (Project/Prompt) Card --- */
.group-card { background: var(--card-bg); border: none; border-radius: var(--radius-lg); margin-bottom: 12px; box-shadow: var(--shadow-sm); transition: all 0.3s ease; position: relative; }
.group-card.collapsed { border-radius: var(--radius-pill); }
.group-card.selected { outline: 2px solid var(--accent-color); background: rgba(0, 210, 255, 0.05); }

.group-card::before { content: ''; position: absolute; left: 0; top: 20px; bottom: 20px; width: 5px; background: var(--group-color, var(--accent-color)); border-radius: 0 6px 6px 0; transition: all 0.3s; pointer-events: none; }
.group-card.collapsed::before { top: 50%; bottom: auto; height: 60%; transform: translateY(-50%); border-radius: 980px; left: 6px; width: 4px; }

.group-header { padding: 14px 16px 14px 24px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; flex-wrap: nowrap; gap: 8px; }
.group-title-wrapper { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.group-title { font-size: var(--group-title-size); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); flex: 1; min-width: 0; }
.prompt-count { background: var(--input-bg); color: var(--text-secondary); font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 980px; white-space: nowrap; flex-shrink: 0; }
.toggle-icon { transition: transform 0.3s; color: var(--text-secondary); font-size: 12px; flex-shrink: 0; }
.group-card.collapsed .toggle-icon { transform: rotate(-90deg); }
.group-card.collapsed .group-content, .group-card.collapsed .group-footer-more { display: none; }
.group-content { padding: 0 16px 12px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 20px; }
.group-footer-more { text-align: center; padding: 0 16px 16px 16px; }

.inline-edit-container { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.inline-edit-input { padding: 6px 12px; font-size: inherit; font-weight: 800; border-radius: 8px; border: 2px solid var(--accent-color); background: var(--card-bg); color: var(--text-primary); outline: none; box-shadow: var(--shadow-sm); flex: 1; min-width: 0; }
.inline-edit-confirm-btn { background: var(--accent-color); color: #000; border: none; border-radius: 8px; padding: 6px 16px; font-size: 13px; font-weight: 800; cursor: pointer; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,210,255,0.2); }
.inline-edit-confirm-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,210,255,0.3); }
.inline-edit-confirm-btn:active { transform: scale(0.95); }

/* --- Prompt (Task) Card --- */
.prompt-card { background: var(--input-bg); border: none; border-radius: var(--radius-pill); padding: 10px 16px 10px 24px; cursor: pointer; transition: all 0.3s ease; position: relative; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none;}
.prompt-card.show-preview { border-radius: var(--radius-lg); padding-bottom: 14px; }
.prompt-card.selected { outline: 2px solid var(--accent-color); background: var(--card-bg); }

body.sort-mode-active .prompt-card { cursor: grab; }
body.sort-mode-active .prompt-card:active { cursor: grabbing; transform: scale(0.99); }
body.batch-mode-active .prompt-card:active { cursor: pointer; transform: none; }

.prompt-card::before { content: ''; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); height: 50%; width: 4px; background: var(--prompt-color, var(--accent-color)); border-radius: 980px; transition: all 0.3s; opacity: 0.9; pointer-events: none; }
.prompt-card.show-preview::before { top: 14px; bottom: 14px; height: auto; transform: none; border-radius: 0 6px 6px 0; left: 0; width: 5px; }

.prompt-card:hover { box-shadow: var(--shadow-sm); background: var(--card-bg); transform: translateY(-1px); }
body.batch-mode-active .prompt-card:hover { transform: none; }

@keyframes copyFlashAnim {
    0% { background-color: rgba(0, 210, 255, 0.2); transform: scale(0.98); box-shadow: 0 0 0 2px var(--accent-color); }
    50% { background-color: rgba(0, 210, 255, 0.4); transform: scale(1.02); box-shadow: 0 0 15px rgba(0, 210, 255, 0.5); }
    100% { background-color: var(--card-bg); transform: scale(1); box-shadow: var(--shadow-sm); }
}
.copy-flash { animation: copyFlashAnim 0.6s ease-out !important; }

.prompt-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: nowrap; position: relative; z-index: 1; }

.prompt-title-container { flex: 1 1 150px; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt-title { font-size: var(--prompt-title-size); font-weight: 800; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; max-width: 100%; min-width: 0; }

.tags-container { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 0px; }
.prompt-tag { font-size: 11px; font-weight: 700; background: rgba(0, 210, 255, 0.12); color: #0093B2; padding: 4px 10px; border-radius: 980px; cursor: pointer; white-space: nowrap; }
body.theme-dark .prompt-tag { color: var(--accent-color); }
.linked-badge { font-size: 10px; font-weight: 700; background: var(--card-bg); border: 1px solid rgba(141, 147, 165, 0.3); color: var(--text-secondary); padding: 3px 8px; border-radius: 6px; display: inline-flex; white-space: nowrap; }

.prompt-preview { display: none; width: 100%; font-size: 13px; color: var(--text-primary); font-weight: 700; -webkit-line-clamp: var(--preview-lines); -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; line-height: 1.5; margin-left: 0; margin-top: 4px; pointer-events: none; }
.prompt-card.show-preview .prompt-preview { display: -webkit-box; animation: fadeIn 0.2s ease; }

.prompt-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; flex-shrink: 0; margin-left: auto; position: relative; z-index: 2; }
.extra-tools { display: none; align-items: center; gap: 6px; margin-right: 8px; border-right: 1px solid rgba(141, 147, 165, 0.2); padding-right: 10px; }
.extra-tools.show { display: flex; animation: fadeIn 0.2s ease; }

/* --- Code Files: Modal Drop Zone --- */
.file-drop-zone { border: 2px dashed rgba(141, 147, 165, 0.4); border-radius: var(--radius-sm); padding: 24px; text-align: center; color: var(--text-secondary); font-size: 13px; font-weight: 600; transition: all 0.3s; background: rgba(0,0,0,0.02); }
.file-drop-zone.drag-over { background: rgba(0, 210, 255, 0.1); border-color: var(--accent-color); color: var(--accent-color); }
body.theme-dark .file-drop-zone { background: rgba(255,255,255,0.02); }

/* --- File Gallery Cards --- */
.file-gallery-wrapper { margin-top: 12px; margin-bottom: 16px; }

.file-gallery-container { 
    display: flex;
    gap: 10px; 
    overflow-x: auto; 
    padding: 4px 4px 12px 4px; 
    margin: 0 -4px; 
    scrollbar-width: thin; 
    scrollbar-color: rgba(141, 147, 165, 0.4) transparent;
    -webkit-overflow-scrolling: touch; 
}

.file-gallery-container::-webkit-scrollbar { height: 6px; display: block; }
.file-gallery-container::-webkit-scrollbar-track { background: var(--input-bg); border-radius: 10px; }
.file-gallery-container::-webkit-scrollbar-thumb { background: rgba(141, 147, 165, 0.35); border-radius: 10px; }
.file-gallery-container::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

.file-gallery-container::after { content: ''; flex: 0 0 1px; }

.file-card { flex: 0 0 250px; max-width: 85%; background: var(--card-bg); border: 1px solid rgba(141, 147, 165, 0.2); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); cursor: pointer; transition: all 0.2s ease; position: relative; user-select: none; }
.file-card:last-child { margin-right: 4px; }
.file-card:hover { border-color: var(--accent-hover); transform: translateY(-2px); }
.file-card.active { border-color: var(--accent-color); background: rgba(0, 210, 255, 0.05); }

.file-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.file-card-title { font-size: 13px; font-weight: 800; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.file-card-badge { font-size: 10px; font-weight: 700; background: var(--input-bg); color: var(--text-secondary); padding: 2px 6px; border-radius: 4px; white-space: nowrap; flex-shrink: 0; }

.file-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; width: 100%; }
.file-card-btn { flex: 1; justify-content: center; background: var(--input-bg); color: var(--text-primary); border: none; padding: 6px 4px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.file-card-btn:hover { background: var(--accent-color); color: #000; }
.file-card-btn.btn-del { color: var(--danger-color); }
.file-card-btn.btn-del:hover { background: rgba(255, 75, 114, 0.15); color: var(--danger-color); }

.file-expanded-viewer { display: none; margin-top: 12px; background: var(--input-bg); border: 1px solid rgba(141, 147, 165, 0.2); border-radius: var(--radius-sm); padding: 16px; font-family: SFMono-Regular, Menlo, Monaco, monospace; font-size: 13px; color: var(--text-primary); max-height: 350px; overflow-y: auto; overflow-x: auto; white-space: pre; line-height: 1.6; user-select: text; }
.file-expanded-viewer.active { display: block; animation: fadeIn 0.2s ease; }

/* --- Settings Page Specific Styles --- */
.settings-card { background: var(--card-bg); border: 1px solid rgba(141, 147, 165, 0.15); border-radius: var(--radius-lg); padding: 32px; max-width: 700px; margin: 0 auto; box-shadow: var(--shadow-sm); }
.settings-section-title { font-weight: 800; color: var(--accent-color); margin: 0 0 20px 0; font-size: 16px; letter-spacing: -0.2px; }
.settings-row { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid rgba(141, 147, 165, 0.1); gap: 16px;}
.settings-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.settings-flex-col { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 24px; gap: 12px; }
.settings-divider { height: 1px; background: rgba(141, 147, 165, 0.15); margin: 24px 0; width: 100%; }

/* --- Batch Action Bar & Checkboxes --- */
body.batch-mode-active .bottom-nav { transform: translateY(150%); pointer-events: none; }
.batch-action-bar { position: fixed; bottom: calc(-100% - 50px); left: 0; width: 100%; background: var(--card-bg); box-shadow: 0 -8px 30px rgba(0,0,0,0.1); padding: 16px 20px calc(16px + env(safe-area-inset-bottom)) 20px; display: flex; justify-content: space-between; align-items: center; z-index: 2500; transition: bottom 0.3s cubic-bezier(0.165, 0.84, 0.44, 1); border-radius: 24px 24px 0 0; }
.batch-action-bar.active { bottom: 0; }
.batch-checkbox { display: none; width: 22px; height: 22px; accent-color: var(--accent-color); margin-right: 12px; pointer-events: none; flex-shrink: 0; }
body.batch-mode-active .batch-checkbox { display: block; }
body.batch-mode-active .prompt-actions, 
body.batch-mode-active .group-footer-more { display: none !important; }

/* --- Selectors, Drawer, Modals --- */
.export-group-card { background: var(--card-bg); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.export-group-header { display: flex; gap: 8px; font-weight: 800; font-size: 14px; cursor: pointer; }
.export-prompts-list { padding-left: 24px; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.export-prompt-item { display: flex; gap: 8px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }

.project-selector { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; align-items: center; }

.project-chip { 
    background: var(--card-bg); 
    color: var(--text-secondary);
    border: 1px solid rgba(141, 147, 165, 0.2); 
    padding: 0 16px; 
    height: 36px; 
    box-sizing: border-box; 
    border-radius: 980px; 
    font-size: 13px; 
    font-weight: 700;
    cursor: pointer; 
    transition: all 0.2s ease; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 4px; 
    white-space: nowrap;
}
.project-chip.active { background: rgba(0, 210, 255, 0.1); color: var(--accent-hover); border-color: var(--accent-color); }
.project-chip.active-new { background: var(--accent-color); color: #000; border-color: var(--accent-color); }

.project-chip.more-chip { 
    background: var(--input-bg); 
    color: var(--accent-hover); 
    border: 1px dashed var(--accent-color);
    font-weight: 800; 
}
.project-chip.more-chip:hover { background: rgba(0, 210, 255, 0.15); transform: translateY(-1px); }

.multi-prompt-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card-bg); border: 1px solid rgba(141, 147, 165, 0.2); border-radius: 12px; cursor: pointer; transition: all 0.2s; }
.multi-prompt-item:hover { border-color: var(--accent-hover); }
.multi-prompt-item.selected { border-color: var(--accent-color); background: rgba(0, 210, 255, 0.08); box-shadow: 0 4px 12px rgba(0, 210, 255, 0.1); }
.multi-prompt-checkbox { width: 20px; height: 20px; accent-color: var(--accent-color); pointer-events: none; flex-shrink: 0; }
.multi-prompt-title { font-weight: 700; font-size: 14px; color: var(--text-primary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.loaded-prompts-container { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; margin-bottom: 12px; }

.loaded-prompt-pill { 
    display: inline-flex;
    align-items: center; 
    justify-content: space-between;
    height: 32px; 
    width: 160px; 
    box-sizing: border-box;
    padding: 0 12px; 
    border-radius: 980px; 
    font-size: 13px; 
    font-weight: 700;
    gap: 8px; 
    cursor: pointer; 
    user-select: none; 
    transition: all 0.2s ease; 
    position: relative; 
    flex-shrink: 0;
}
body.theme-dark .loaded-prompt-pill { filter: brightness(1.1); }
.loaded-prompt-pill:hover { filter: brightness(0.95); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.loaded-prompt-pill:active { transform: scale(0.96); }
.loaded-prompt-pill .pill-title { 
    flex: 1; 
    min-width: 0; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    color: var(--text-primary);
    text-align: left;
}
.loaded-prompt-pill .remove-btn { cursor: pointer; color: var(--text-secondary); font-weight: 900; background: transparent; border: none; padding: 2px 6px; font-size: 14px; border-radius: 50%; transition: color 0.2s; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.loaded-prompt-pill .remove-btn:hover { color: var(--danger-color); background: rgba(255, 75, 114, 0.15); }

/* --- Order Switch Toggle Bar & Dynamic Container Spacing --- */
.order-switch-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--input-bg); border-radius: var(--radius-md); padding: 10px 16px; margin-bottom: 16px; border: 1px dashed rgba(141, 147, 165, 0.3); }
.order-switch-btn { background: var(--card-bg); color: var(--accent-hover); border: 1px solid var(--accent-color); font-weight: 800; font-size: 12px; padding: 6px 14px; border-radius: 980px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.order-switch-btn:hover { background: var(--accent-color); color: #000; transform: translateY(-1px); }

#newDynamicFieldsContainer, #editDynamicFieldsContainer {
    display: flex;
    flex-direction: column;
    gap: 16px; 
}

#newCommonPromptSelectorWrapper, #editCommonPromptSelectorWrapper {
    margin-top: 0px;
    margin-bottom: 0px;
    display: flex;
    flex-direction: column;
}

#newPromptTargetWrapper, #editPromptTargetWrapper {
    margin-top: 0px;
    margin-bottom: 0px;
}

.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(8px); z-index: 1500; opacity: 0; pointer-events: none; transition: 0.3s; }
.drawer-overlay.active { opacity: 1; pointer-events: auto; }
.star-drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 85%; max-width: 360px; background: var(--card-bg); z-index: 1600; transform: translateX(-100%); transition: 0.3s; padding: max(24px, env(safe-area-inset-top)) 20px; overflow-y: auto; }
.drawer-overlay.active .star-drawer { transform: translateX(0); }
.drawer-title { font-size: 18px; font-weight: 800; display: flex; justify-content: space-between; margin-bottom: 20px; }
.star-item { background: var(--input-bg); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 8px; cursor: pointer; font-size: 13px; }

.bottom-nav { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--card-bg); padding: 10px 10px calc(10px + env(safe-area-inset-bottom)) 10px; display: flex; justify-content: space-around; z-index: 500; box-shadow: 0 -4px 20px rgba(0,0,0,0.04); border-radius: 24px 24px 0 0; transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1); }
.nav-item { flex: 1; max-width: 80px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-radius: 16px; color: var(--text-secondary); font-size: 11px; font-weight: 800; cursor: pointer; }
.nav-item .nav-icon { font-size: 20px; }
.nav-item.active { background: var(--accent-color); color: #000; box-shadow: 0 4px 12px rgba(0,210,255,0.2); }

.input-field { background: var(--input-bg); border: none; border-radius: 16px; padding: 14px 16px; font-size: 14px; width: 100%; color: var(--text-primary); outline: none; }
.input-field:focus { background-color: var(--card-bg); box-shadow: var(--shadow-sm); }

select.input-field { 
    appearance: none; 
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 36px !important; 
    border-radius: var(--radius-md) !important; 
    font-weight: 700;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233A40FF' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-position: right 14px center; 
    background-size: 14px; 
    background-repeat: no-repeat;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.styled-select option { background-color: var(--card-bg); color: var(--text-primary); }

input[type=range] { -webkit-appearance: none; background: transparent; width: 100%; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 24px; width: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15); margin-top: -8px; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; background: var(--input-bg); border-radius: 980px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,15,23,0.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 2000; opacity: 0; pointer-events: none; transition: 0.3s; padding: 16px; overflow-y: auto; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal { background: var(--card-bg); border-radius: 28px; width: 100%; max-width: 600px; padding: 32px; transform: scale(0.95) translateY(20px); transition: 0.3s; margin: auto; max-height: 90vh; overflow-y: auto; overflow-x: hidden; }
.modal::-webkit-scrollbar { width: 14px; }
.modal::-webkit-scrollbar-track { background: transparent; margin: 24px 0; }
.modal::-webkit-scrollbar-thumb { background-color: rgba(141, 147, 165, 0.3); border-radius: 10px; border: 4px solid var(--card-bg); background-clip: padding-box; }
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-title { 
    font-size: clamp(14px, 4.2vw, 18px); 
    font-weight: 800; 
    text-align: center; 
    line-height: 1.35; 
    letter-spacing: -0.3px;
    word-break: break-word;
    overflow-wrap: break-word; 
    overflow: hidden; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    padding: 0 4px; 
    flex: 1; 
    min-width: 0;
}

.modal .form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.large-textarea { border-radius: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

.details-content-box {
    background: rgba(0, 210, 255, 0.08); 
    border-left: 3px solid var(--accent-color);
    padding: 16px; 
    border-radius: 8px; 
    margin-bottom: 16px; 
    font-size: 14px; 
    line-height: 1.6; 
    white-space: pre-wrap; 
    word-break: break-all; 
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
}
.details-content-box:hover { background: rgba(0, 210, 255, 0.12); }
.details-content-box .target-label { font-weight: 800; color: var(--accent-hover); margin-bottom: 8px; font-size: 13px; display: flex; align-items: center; gap: 4px; }

.details-full-text {
    padding: 16px; 
    background: var(--input-bg); 
    border-radius: var(--radius-sm);
    font-family: SFMono-Regular, Menlo, Monaco, monospace; 
    font-size: 14px; 
    white-space: pre-wrap; 
    word-break: break-all; 
    line-height: 1.6; 
    user-select: text;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.02);
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 16px;
}
.details-full-text:hover { background: #E4E9F2; }
body.theme-dark .details-full-text:hover { background: #353545; }

.custom-dialog { max-width: 320px !important; padding: 0 !important; text-align: center; overflow: hidden; }
.custom-dialog-msg { padding: 32px 20px; font-size: 15px; font-weight: 700; line-height: 1.5; }
.custom-dialog-btns { display: flex; border-top: 1px solid rgba(141,147,165,0.15); }
.custom-dialog-btn { flex: 1; padding: 16px; font-size: 15px; background: transparent; border: none; color: var(--text-primary); cursor: pointer; }
.custom-dialog-btn.bold { font-weight: 800; color: #3A40FF; }
.custom-dialog-btn:not(:last-child) { border-right: 1px solid rgba(141,147,165,0.15); }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translate(-50%, 20px) scale(0.9); background: var(--primary-gradient); color: #FFF; padding: 12px 24px; border-radius: 980px; font-size: 14px; font-weight: 800; opacity: 0; pointer-events: none; transition: 0.3s; z-index: 3000; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 14px; font-weight: 700; }

@media (max-width: 600px) {
    .container { padding: max(16px, env(safe-area-inset-top)) 12px 12px 12px; }
    .settings-card { padding: 24px 16px; }
    .modal { padding: 24px 20px calc(32px + env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; align-self: flex-end; transform: translateY(100%); margin-bottom: 0; max-height: 90vh; overflow-y: auto; }
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-overlay.active .modal { transform: translateY(0); }
    .custom-dialog { align-self: center !important; margin: auto !important; border-radius: 24px !important; }
    .modal-actions { flex-direction: column; }
    .modal-actions .btn { width: 100%; }
    .modal-title { font-size: 15px; } 
}

/* --- Cloud Sync Progress Bar --- */
#syncProgressContainer {
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
#syncProgressBar.syncing {
    background-image: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
}
@keyframes progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}
