/* Selection Helper CSS v6.2 */

#sh-selection-popup-container {
    display: none; position: absolute; z-index: 2147483647;
    display: flex; gap: 6px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background: rgba(255, 255, 255, 0.98); padding: 6px; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); border: 1px solid #e5e7eb;
    align-items: center;
}

/* Button Groups */
.sh-btn-group { position: relative; display: flex; }

/* Main Buttons */
#sh-selection-popup-container > button, 
.sh-btn-group > button {
    border: none; border-radius: 5px; padding: 6px 10px; font-size: 13px;
    font-weight: 600; cursor: pointer; color: white; display: flex; gap: 4px;
    white-space: nowrap; transition: transform 0.1s;
}
#sh-selection-popup-container button:hover { transform: translateY(-1px); }

#sh-listen-button { background: #374151; }
#sh-translate-button { background: #059669; min-width: 90px; justify-content: center; }
#sh-grammar-button { background: #d97706; }
#sh-ask-ai-button { background: #4f46e5; }

/* Dropdown */
#sh-lang-dropdown {
    display: none; position: absolute; top: 100%; left: 0; margin-top: 8px;
    background: white; border: 1px solid #e5e7eb;
    border-radius: 6px; box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    max-height: 220px; overflow-y: auto; overflow-x: hidden;
    width: 140px; z-index: 2147483650;
    scrollbar-width: thin; scrollbar-color: #cbd5e1 #f1f5f9;
}
#sh-lang-dropdown::-webkit-scrollbar { width: 6px; }
#sh-lang-dropdown::-webkit-scrollbar-track { background: #f1f5f9; }
#sh-lang-dropdown::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

#sh-lang-dropdown button {
    display: block; width: 100%; text-align: left;
    background: transparent; color: #374151;
    padding: 10px 12px; border: none; border-bottom: 1px solid #f3f4f6;
    font-size: 13px; cursor: pointer; transition: background 0.1s;
}
#sh-lang-dropdown button:last-child { border-bottom: none; }
#sh-lang-dropdown button:hover { background: #f0fdf4; color: #16a34a; }

/* Bottom Panel */
#sh-tts-overlay {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 2147483646;
    justify-content: center; align-items: flex-end; pointer-events: none;
}
#sh-tts-panel {
    background: white; width: 100%; max-width: 800px; max-height: 40vh;
    border-radius: 12px 12px 0 0; display: flex; flex-direction: column;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.15); pointer-events: auto;
    border: 1px solid #e5e7eb;
}
#sh-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: #f9fafb; border-bottom: 1px solid #f3f4f6;
    border-radius: 12px 12px 0 0;
}
#sh-panel-title { font-weight: 700; color: #374151; font-size: 0.9rem; text-transform: uppercase; }
#sh-panel-actions { display: flex; gap: 8px; align-items: center; }

/* Panel Buttons */
#sh-restore-btn, #sh-copy-btn, #sh-listen-result-btn {
    background: #e5e7eb; color: #374151; border: none; padding: 4px 8px;
    border-radius: 4px; font-size: 12px; cursor: pointer; font-weight: 600;
}
#sh-listen-result-btn { background: #374151; color: white; } /* Darker for Listen Action */
#sh-listen-result-btn:hover { background: #1f2937; }
#sh-restore-btn:hover, #sh-copy-btn:hover { background: #d1d5db; }

#sh-tts-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: #9ca3af; }
#sh-tts-text-wrapper { flex: 1; overflow-y: auto; padding: 20px; }
#sh-tts-text { font-size: 1.1rem; line-height: 1.6; color: #1f2937; }
.sh-tts-word { transition: background 0.1s; border-radius: 2px; }
.sh-word-highlight { background-color: rgba(255, 200, 0, 0.3); color: #b91c1c; font-weight: 800; }

/* Spinner */
#sh-loading-overlay {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: #1f2937; color: white; padding: 10px 20px; border-radius: 20px;
    display: flex; gap: 10px; font-size: 13px; z-index: 2147483650;
}
.sh-spinner { width: 14px; height: 14px; border: 2px solid #fff; border-bottom-color: transparent; border-radius: 50%; animation: sh-spin 1s linear infinite; }
@keyframes sh-spin { to { transform: rotate(360deg); } }