@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --text-main: #f8fafc;
    --text-muted: #e2e8f0;
    --surface-glass: rgba(30, 15, 20, 0.45);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 182, 193, 0.3);
    --gradient-primary: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #ffb6c1 100%);
    --gradient-text: linear-gradient(to right, #ffb6c1, #ff6b81);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255, 182, 193, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 182, 193, 0.5); }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; scrollbar-width: thin; scrollbar-color: rgba(255, 182, 193, 0.3) transparent; }
html, body { width: 100%; height: 100dvh; overflow: hidden; position: relative; }
body { font-family: 'Plus Jakarta Sans', sans-serif; color: var(--text-main); background-color: #0a0507; display: flex; flex-direction: row; }
body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; background-image: radial-gradient(at 0% 0%, rgba(255, 182, 193, 0.15) 0, transparent 40%), radial-gradient(at 100% 0%, rgba(255, 107, 129, 0.1) 0, transparent 40%), radial-gradient(at 50% 100%, rgba(254, 207, 239, 0.05) 0, transparent 50%); background-repeat: no-repeat; background-size: cover; z-index: -10; }

input, textarea, select, .glass-input { font-size: 16px !important; font-family: inherit; }
select.glass-input { background-color: #1a0f14; color: #f8fafc; appearance: none; }
select.glass-input option, select.glass-input optgroup { background-color: #0a0507; color: #f8fafc; }

#left-color-bar { position: fixed; top: 0; left: 0; bottom: 0; width: 4px; background: var(--gradient-primary); z-index: 200; box-shadow: 2px 0 15px rgba(255, 182, 193, 0.5); }

.mobile-header { display: flex; align-items: center; justify-content: center; padding: 10px 15px; background: rgba(10, 5, 7, 0.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-glass); position: absolute; top: 0; left: 0; right: 0; z-index: 1000; height: 60px; }
.mobile-title { font-size: 1.2rem; font-weight: 800; background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-align: center; }
.hamburger-btn { display: flex; position: absolute; left: 15px; background: transparent; border: none; color: var(--text-main); cursor: pointer; padding: 5px; align-items: center; justify-content: center; }

.icon-only { width: 40px !important; height: 40px !important; padding: 0 !important; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#mobile-export-btn { position: absolute; right: 15px; margin: 0; }

.side-menu { position: relative; width: 320px; height: 100%; flex-shrink: 0; background: linear-gradient(145deg, rgba(30, 15, 20, 0.98) 0%, rgba(15, 7, 10, 0.98) 100%); border-right: 1px solid var(--border-highlight); z-index: 2001; padding: 25px 20px; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; box-shadow: 10px 0 30px rgba(0,0,0,0.8); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.side-menu.hidden-sidebar { margin-left: -320px; }

.side-menu-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 2000; opacity: 0; pointer-events: none; transition: 0.3s; }
.side-menu-overlay.show { opacity: 1; pointer-events: all; }

.logo-container { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-shrink: 0; }
.logo-text { font-size: 1.8rem; font-weight: 800; background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.glass-input { background: linear-gradient(145deg, rgba(255, 182, 193, 0.03) 0%, rgba(30, 15, 20, 0.3) 100%); border: 1px solid var(--border-highlight); color: var(--text-main); padding: 10px 12px; border-radius: 12px; outline: none; transition: 0.3s; width: 100%; box-shadow: inset 0 2px 10px rgba(0,0,0,0.2); box-sizing: border-box; }
.glass-input:focus { border-color: #ffb6c1; background: linear-gradient(145deg, rgba(255, 182, 193, 0.1) 0%, rgba(30, 15, 20, 0.5) 100%); box-shadow: 0 0 15px rgba(255, 182, 193, 0.2); }

.settings-panel { background: rgba(255,255,255,0.02); border: 1px solid var(--border-glass); padding: 12px; border-radius: 12px; }
.slider-group { margin-bottom: 10px; }
.slider-group label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background: #ffb6c1; cursor: pointer; margin-top: -6px; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: rgba(255,255,255,0.1); border-radius: 2px; }

.primary-btn { background: var(--gradient-primary); color: #1a0f14; border: none; padding: 14px 24px; font-size: 1rem; font-weight: 800; border-radius: 12px; cursor: pointer; transition: 0.3s; width: 100%; margin-top: 20px;}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(255, 182, 193, 0.4); }
.secondary-btn { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid var(--border-glass); padding: 12px; border-radius: 12px; cursor: pointer; font-weight: 600; transition: 0.3s; width: 100%; text-align: center; }
.secondary-btn:hover { background: rgba(255, 182, 193, 0.15); color: #ffb6c1; border-color: #ffb6c1; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; background: rgba(10, 5, 7, 0.85); z-index: 3000; display: flex; align-items: center; justify-content: center; opacity: 1; pointer-events: all; transition: 0.3s ease; padding: 15px; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.glass-panel { background: linear-gradient(145deg, rgba(40, 20, 30, 0.9) 0%, rgba(20, 10, 15, 0.98) 100%); border: 1px solid var(--border-highlight); border-radius: 24px; padding: 30px; width: 100%; max-width: 500px; position: relative; box-shadow: 0 30px 60px rgba(0,0,0,0.8); transform: translateY(0); transition: 0.3s ease; backdrop-filter: blur(20px); max-height: 90dvh; overflow-y: auto; }
.modal-overlay.hidden .glass-panel { transform: translateY(20px); }
.close-btn { position: absolute; top: 15px; right: 20px; background: transparent; border: none; color: var(--text-muted); font-size: 1.8rem; cursor: pointer; z-index: 10; }

#chat-wrapper { flex: 1; display: flex; flex-direction: column; height: 100dvh; padding: 60px 20px 20px 20px; position: relative; min-width: 0; }
#chat-log { flex: 1; overflow-y: auto; padding-bottom: 20px; padding-top: 20px; }
.control-panel { padding: 15px; border-radius: 20px; display: flex; flex-direction: column; gap: 10px; max-width: 900px; margin: 0 auto; width: 100%; background: linear-gradient(145deg, rgba(30, 15, 20, 0.4) 0%, rgba(15, 7, 10, 0.6) 100%); backdrop-filter: blur(30px); border: 1px solid var(--border-glass); box-shadow: 0 10px 30px rgba(0,0,0,0.5); position: relative; z-index: 10; }
.control-btn { height: 44px; width: 44px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-glass); color: var(--text-main); cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.control-btn:hover { background: rgba(255, 182, 193, 0.15); border-color: #ffb6c1; }
#prompt { min-height: 50px; max-height: 150px; resize: none; flex: 1; padding: 14px; margin: 0; overflow-y: auto; }
#token-counter { position: absolute; bottom: 8px; right: 12px; font-size: 0.65rem; color: var(--text-muted); background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px; pointer-events: none; }

#image-preview-container { background: rgba(0,0,0,0.8); padding: 8px; border-radius: 12px; border: 1px solid var(--border-glass); z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
#image-preview { max-height: 120px; max-width: 120px; object-fit: cover; border-radius: 8px; }
#clear-img-btn { position: absolute; top: -8px; right: -8px; background: #fb7185; color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }

.msg-container { display: flex; gap: 15px; margin-bottom: 20px; max-width: 85%; }
.msg-container.user { margin-left: auto; flex-direction: row-reverse; }
.msg-container.system { margin: 0 auto; max-width: 100%; justify-content: center; }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--border-highlight); background: rgba(0,0,0,0.2); }
.msg { padding: 15px; border-radius: 16px; line-height: 1.6; border: 1px solid var(--border-glass); flex: 1; min-width: 0; }
.msg.user { background: linear-gradient(145deg, rgba(255, 182, 193, 0.1) 0%, rgba(30, 15, 20, 0.3) 100%); border-color: rgba(255, 182, 193, 0.3); }
.msg.ai { background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, rgba(15, 7, 10, 0.3) 100%); }
.msg.system { text-align: center; font-size: 0.85rem; color: #fb7185; background: transparent; border: none; padding: 5px; }
.msg table { width: 100%; border-collapse: collapse; margin: 10px 0; overflow-x: auto; display: block; }
.msg th, .msg td { border: 1px solid var(--border-glass); padding: 8px; }
.msg th { background: rgba(255, 182, 193, 0.1); }
.msg img.multimodal-img { max-width: 100%; max-height: 300px; border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--border-glass); }
pre { background: rgba(0,0,0,0.5); padding: 15px; border-radius: 12px; overflow-x: auto; border: 1px solid var(--border-glass); margin: 10px 0; }
code { color: #ffb6c1; font-family: monospace; }
think { display: block; padding: 15px; margin: 15px 0; border-left: 3px solid rgba(255, 182, 193, 0.5); background: rgba(255, 255, 255, 0.02); color: var(--text-muted); font-size: 0.85rem; white-space: pre-wrap; }

#char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; max-height: 250px; overflow-y: auto; }
.char-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border-glass); padding: 10px; border-radius: 12px; cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; align-items: center; position: relative; }
.char-card:hover { border-color: #ffb6c1; background: rgba(255, 182, 193, 0.1); }
.char-card img { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; margin-bottom: 10px; }
.char-title { font-weight: 700; color: #ffb6c1; font-size: 0.9rem; text-align: center; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-del { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.5); border: none; color: #fb7185; cursor: pointer; font-size: 1rem; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.char-edit { position: absolute; top: 5px; left: 5px; background: rgba(0,0,0,0.5); border: none; color: #60a5fa; cursor: pointer; font-size: 1rem; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.char-edit:hover { background: rgba(96, 165, 250, 0.2); color: #93c5fd; }
.char-preview-tooltip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(10, 5, 7, 0.95); border: 1px solid var(--border-highlight); padding: 10px; border-radius: 8px; font-size: 0.8rem; width: 200px; z-index: 100; pointer-events: none; backdrop-filter: blur(10px); color: var(--text-muted); max-height: 100px; overflow: hidden; text-overflow: ellipsis; }
.char-card:hover .char-preview-tooltip { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }

.chat-sidebar-item { display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,0.02); border: 1px solid transparent; padding: 10px; border-radius: 10px; cursor: pointer; transition: 0.2s; flex-shrink: 0; }
.chat-sidebar-item:hover { border-color: rgba(255, 182, 193, 0.3); background: rgba(255, 182, 193, 0.05); }
.chat-sidebar-item.active { border-color: #ffb6c1; background: rgba(255, 182, 193, 0.1); }
.chat-sidebar-info { flex: 1; min-width: 0; overflow: hidden; }
.chat-sidebar-title { font-weight: 600; color: var(--text-main); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.chat-sidebar-date { font-size: 0.7rem; color: var(--text-muted); }
.chat-sidebar-actions { display: none; gap: 6px; flex-shrink: 0; margin-left: 8px; }
.chat-sidebar-item:hover .chat-sidebar-actions { display: flex; }
.chat-sidebar-btn { background: rgba(0,0,0,0.5); border: 1px solid var(--border-glass); color: var(--text-muted); width: 26px; height: 26px; border-radius: 6px; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 0.85rem; transition: 0.2s; }
.chat-sidebar-btn:hover { background: rgba(255, 255, 255, 0.1); color: #f8fafc; }
.chat-sidebar-btn.danger:hover { background: rgba(251, 113, 133, 0.2); color: #fb7185; border-color: #fb7185; }

#active-char-display { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; padding: 10px; background: rgba(255, 182, 193, 0.05); border: 1px solid var(--border-highlight); border-radius: 12px; }
#active-char-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
#active-char-name { font-weight: bold; color: #ffb6c1; flex: 1; font-size: 0.95rem; }
#clear-char-btn { background: transparent; border: none; color: #fb7185; cursor: pointer; font-size: 1.2rem; }

.action-row { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.action-icon-btn { background: rgba(255,255,255,0.05); border: 1px solid var(--border-glass); color: var(--text-muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; font-size: 0.9rem; }
.action-icon-btn:hover { background: rgba(255, 255, 255, 0.15); color: #f8fafc; border-color: #ffb6c1; }
.action-icon-btn.danger:hover { background: rgba(251, 113, 133, 0.2); color: #fb7185; border-color: #fb7185; }
.hidden { display: none !important; }

.voice-sheet { position: fixed; bottom: 0; left: 0; right: 0; top: auto; background: linear-gradient(180deg, rgba(30, 15, 20, 0.98) 0%, #0a0507 100%); border-top: 1px solid var(--border-highlight); border-radius: 24px 24px 0 0; backdrop-filter: blur(20px); z-index: 4000; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; align-items: center; padding-bottom: max(20px, env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); }
.voice-sheet.show { transform: translateY(0); }
.voice-sheet-content { padding: 30px 20px; width: 100%; max-width: 600px; display: flex; flex-direction: column; align-items: center; }
#voice-visualizer { width: 100%; height: 160px; margin-bottom: 20px; border-radius: 12px; pointer-events: none; }
.voice-controls { display: flex; gap: 15px; width: 100%; justify-content: center; z-index: 4001; }
.voice-btn { padding: 12px 30px; border-radius: 30px; font-weight: 700; font-size: 1rem; cursor: pointer; transition: 0.2s; border: none; }
.voice-btn.cancel { background: rgba(255,255,255,0.1); color: var(--text-main); border: 1px solid var(--border-glass); }
.voice-btn:hover { transform: translateY(-2px); background: rgba(255,255,255,0.2); }

#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 5000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: rgba(30, 15, 20, 0.95); border: 1px solid var(--border-highlight); color: var(--text-main); padding: 12px 20px; border-radius: 12px; font-size: 0.9rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(10px); transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: all; }
.toast.show { transform: translateX(0); }
.toast.error { border-color: #fb7185; color: #fb7185; }

.skeleton-msg { width: 70%; height: 80px; border-radius: 16px; background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%); background-size: 200% 100%; animation: loading 1.5s infinite; margin-bottom: 20px; border: 1px solid var(--border-glass); }
.skeleton-msg.user { margin-left: auto; background: linear-gradient(90deg, rgba(255, 182, 193, 0.05) 25%, rgba(255, 182, 193, 0.1) 50%, rgba(255, 182, 193, 0.05) 75%); background-size: 200% 100%; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.inline-edit-container { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.inline-edit-container textarea { min-height: 100px; resize: vertical; }

@media (max-width: 768px) { 
    #chat-wrapper { padding-top: 60px; padding-left: 0; padding-right: 0; padding-bottom: 0; }
    .control-panel { border-radius: 0; border-left: none; border-right: none; border-bottom: none; background: rgba(10, 5, 7, 0.95); padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .msg-container { max-width: 95%; margin-left: 10px; margin-right: 10px; }
    .msg-container.user { margin-right: 10px; }
    .chat-sidebar-actions { display: flex; } 
    
    .side-menu { padding-top: 15px; padding-bottom: 40px; z-index: 3001; position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
    .side-menu.show { transform: translateX(0); }
    .side-menu-overlay { z-index: 3000; }
    
    #mobile-sidebar-close { display: flex !important; align-items: center; justify-content: center; position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,0.1); border: 1px solid var(--border-glass); font-size: 1.5rem; color: var(--text-main); z-index: 3005; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
}
