* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a0a0f; --sidebar-bg: #13131a; --card-bg: #1a1a24; --hover: #232330;
    --border: #2a2a38; --text: #e8e8f0; --text-dim: #8888a0; --accent: #00d4ff;
    --accent-hover: #00b8e6; --user-msg: linear-gradient(135deg, #00d4ff, #0093ff); --danger: #ff3b5c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
    background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; }

/* SIDEBAR */
.sidebar { width: 280px; background: var(--sidebar-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: transform 0.3s ease; }
.sidebar-header { padding: 20px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 28px; filter: drop-shadow(0 0 8px var(--accent)); }
.brand-name { font-size: 17px; font-weight: 700; background: linear-gradient(135deg, #00d4ff, #0093ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.brand-by { font-size: 11px; color: var(--text-dim); letter-spacing: 0.5px; }
.new-chat-btn { width: 36px; height: 36px; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 10px; font-size: 22px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.new-chat-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); transform: scale(1.05); }
.chats-label { padding: 16px 20px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); font-weight: 600; }
.chats-list { flex: 1; overflow-y: auto; padding: 0 10px; }
.chats-list::-webkit-scrollbar { width: 6px; }
.chats-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chat-item { padding: 12px 14px; border-radius: 10px; margin-bottom: 4px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; transition: background 0.15s; position: relative; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--card-bg); border: 1px solid var(--accent); }
.chat-item-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; color: var(--text); }
.chat-item-delete { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; padding: 4px; border-radius: 4px; opacity: 0; transition: all 0.15s; }
.chat-item:hover .chat-item-delete { opacity: 1; }
.chat-item-delete:hover { color: var(--danger); background: rgba(255, 59, 92, 0.1); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.model-badge { display: inline-block; padding: 6px 12px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; font-size: 11px; color: var(--text-dim); font-family: monospace; }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.menu-btn { display: none; position: absolute; top: 16px; left: 16px; z-index: 10; background: var(--card-bg); border: 1px solid var(--border); color: var(--text); width: 40px; height: 40px; border-radius: 10px; font-size: 18px; cursor: pointer; }
.chat-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg); }
.chat-title { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text-dim); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 16px; transition: all 0.15s; margin-left: 8px; }
.icon-btn:hover { color: var(--danger); border-color: var(--danger); background: rgba(255, 59, 92, 0.1); }
#autospeak-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(0, 212, 255, 0.1); }

/* CHAT WINDOW */
.chat-window { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.chat-window::-webkit-scrollbar { width: 8px; }
.chat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; margin: auto; max-width: 600px; }
.welcome-icon { font-size: 72px; margin-bottom: 16px; filter: drop-shadow(0 0 24px var(--accent)); animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.welcome h1 { font-size: 32px; margin-bottom: 8px; background: linear-gradient(135deg, #00d4ff, #0093ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.welcome p { color: var(--text-dim); margin-bottom: 28px; font-size: 15px; }
.suggestions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.suggestion { padding: 10px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; color: var(--text); cursor: pointer; font-size: 13px; transition: all 0.15s; }
.suggestion:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* MESSAGES */
.message { display: flex; gap: 12px; max-width: 850px; width: 100%; margin: 0 auto; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message.user { flex-direction: row-reverse; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.message.bot .avatar { background: linear-gradient(135deg, #00d4ff, #0093ff); }
.message.user .avatar { background: var(--card-bg); border: 1px solid var(--border); }
.bubble { padding: 12px 16px; border-radius: 16px; line-height: 1.6; font-size: 14.5px; word-wrap: break-word; max-width: calc(100% - 60px); }
.message.bot .bubble { background: var(--card-bg); border: 1px solid var(--border); border-top-left-radius: 4px; }
.message.user .bubble { background: var(--user-msg); color: #fff; border-top-right-radius: 4px; }
.message.error .bubble { background: rgba(255, 59, 92, 0.1); border-color: var(--danger); color: var(--danger); }

/* MARKDOWN STYLING */
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin-left: 20px; margin-bottom: 10px; }
.bubble strong { font-weight: bold; }
.bubble a { color: var(--accent); text-decoration: underline; }
.bubble :not(pre) > code { background: rgba(255, 255, 255, 0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }

/* CODE BLOCKS */
.bubble pre { background: #0d1117; border: 1px solid var(--border); border-radius: 8px; margin: 12px 0; overflow: hidden; position: relative; }
.bubble pre code { display: block; padding: 12px; font-family: 'Courier New', Courier, monospace; font-size: 13px; color: #e6edf3; overflow-x: auto; }
.code-header { display: flex; justify-content: space-between; align-items: center; background: #161b22; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-dim); font-family: monospace; }
.copy-code-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; transition: color 0.2s; }
.copy-code-btn:hover { color: var(--accent); }

.typing { display: flex; gap: 4px; padding: 8px 0; }
.typing span { width: 8px; height: 8px; background: var(--text-dim); border-radius: 50%; animation: typing 1.4s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* INPUT */
.input-area { padding: 16px 24px 20px; border-top: 1px solid var(--border); background: var(--bg); }
.input-wrap { max-width: 850px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 8px 8px 8px 16px; transition: border-color 0.2s; }
.input-wrap:focus-within { border-color: var(--accent); }
#user-input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 15px; font-family: inherit; resize: none; outline: none; max-height: 200px; padding: 8px 0; line-height: 1.5; }
#user-input::placeholder { color: var(--text-dim); }
#send-btn, #mic-btn, #img-upload-btn { width: 40px; height: 40px; border: none; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
#send-btn { background: var(--accent); color: #000; }
#send-btn:hover:not(:disabled) { background: var(--accent-hover); transform: scale(1.05); }
#send-btn:disabled { background: var(--border); color: var(--text-dim); cursor: not-allowed; }
#mic-btn, #img-upload-btn { background: transparent; border: 1px solid var(--border); color: var(--text); }
#mic-btn:hover, #img-upload-btn:hover { color: var(--accent); border-color: var(--accent); }
#mic-btn.recording { background: rgba(255, 59, 92, 0.2); border-color: var(--danger); color: var(--danger); animation: pulse-mic 1.2s infinite; }
@keyframes pulse-mic { 0% { box-shadow: 0 0 0 0 rgba(255, 59, 92, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(255, 59, 92, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 59, 92, 0); } }
.input-hint { text-align: center; font-size: 11px; color: var(--text-dim); margin-top: 10px; }

/* IMAGE PREVIEW */
.image-preview-container { display: none; max-width: 850px; margin: 0 auto 10px auto; position: relative; width: fit-content; }
.image-preview-container.active { display: block; }
#image-preview { max-height: 120px; border-radius: 12px; border: 1px solid var(--border); }
#remove-image-btn { position: absolute; top: -8px; right: -8px; background: var(--danger); color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; }

/* ACTIONS */
.message-actions { display: flex; gap: 8px; margin-top: 12px; opacity: 0.8; transition: opacity 0.2s; }
.message.bot:hover .message-actions { opacity: 1; }
.speak-btn, .copy-btn, .download-btn { background: var(--sidebar-bg); border: 1px solid var(--border); color: var(--text-dim); padding: 6px 12px; border-radius: 12px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all 0.15s; }
.speak-btn:hover, .copy-btn:hover, .download-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(0, 212, 255, 0.1); }
.speak-btn.speaking { color: var(--accent); border-color: var(--accent); background: rgba(0, 212, 255, 0.15); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* MOBILE */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 99; }
@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: flex; align-items: center; justify-content: center; }
    .overlay.active { display: block; }
    .chat-header { padding-left: 64px; }
    .chat-window { padding: 16px; }
    .welcome h1 { font-size: 24px; }
    .welcome-icon { font-size: 56px; }
    .bubble { font-size: 14px; }
    .input-area { padding: 12px 16px 16px; }
}
