:root {
    --sidebar-bg: #ffffff;
    --main-bg: #f9fafb;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --user-bubble: #ede9fe;
    --ai-bubble: #ffffff;
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background-color: var(--main-bg); color: var(--text-primary); height: 100vh; height: 100dvh; overflow: hidden; }

.app-container { display: flex; height: 100vh; height: 100dvh; width: 100vw; width: 100dvw; }

/* SIDEBAR */
.sidebar { width: 260px; flex-shrink: 0; background-color: var(--sidebar-bg); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; transition: width 0.3s ease; }
.sidebar.collapsed { width: 0; overflow: hidden; border-right: none; }

.sidebar-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.sidebar-header h3 { font-size: 16px; font-weight: 700; color: var(--primary-color); }

.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; border-radius: 6px; padding: 6px; transition: 0.2s; }
.icon-btn:hover { background-color: #f3f4f6; color: var(--text-primary); }
.icon-btn i { font-size: 18px; }

/* MULTI-CHAT HISTORY LIST */
.history-section { padding: 12px 12px 0 12px; display: flex; flex-direction: column; max-height: 220px; flex-shrink: 0; }
.history-header { font-size: 11px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.5px; margin-bottom: 6px; padding: 0 4px; }
.history-list { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

.history-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: none; border: none; border-radius: 8px; cursor: pointer; color: var(--text-secondary); text-align: left; transition: 0.2s; font-size: 13px; }
.history-item:hover { background-color: #f3f4f6; color: var(--text-primary); }
.history-item.active { background-color: #f5f3ff; color: var(--primary-color); font-weight: 600; }
.history-item .chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-grow: 1; }
.history-item .chat-actions { display: none; gap: 2px; flex-shrink: 0; }
.history-item:hover .chat-actions { display: flex; }

.chat-action-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 2px 4px; border-radius: 4px; font-size: 13px; transition: 0.15s; }
.chat-action-btn:hover { background-color: #e5e7eb; color: var(--text-primary); }
.chat-action-btn.delete-chat-btn:hover { background-color: #fef2f2; color: #ef4444; }

/* WORKSPACE SECTION */
.workspace-section { padding: 12px; border-top: 1px solid var(--border-color); flex-grow: 1; display: flex; flex-direction: column; min-height: 0; }
.ws-header { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; padding: 0 4px;}
.ws-title { font-size: 11px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }

.ws-select { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border-color); font-size: 12.5px; font-family: 'Inter', sans-serif; background-color: #f9fafb; color: var(--text-primary); outline: none; }
.ws-select:focus { border-color: var(--primary-color); }

.ws-actions { display: flex; gap: 4px; justify-content: space-around; margin-bottom: 8px; padding: 0 4px; }
.ws-actions .icon-btn { flex-grow: 1; background-color: #f9fafb; border: 1px solid var(--border-color); }

.ws-content { padding: 0 4px; font-size: 12px; color: #9ca3af; flex-grow: 1; overflow-y: auto; }
.ws-file-item { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; background: none; border: none; border-radius: 6px; cursor: pointer; color: var(--text-secondary); text-align: left; transition: 0.2s; font-size: 13px; margin-bottom: 2px; }
.ws-file-item:hover { background-color: #f3f4f6; color: var(--text-primary); }
.ws-file-item.active { background-color: #f5f3ff; color: var(--primary-color); font-weight: 500; }
.ws-file-item .file-label { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-grow: 1; }
.ws-file-item .file-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0.85; transition: opacity 0.2s; }
.ws-file-item:hover .file-actions { opacity: 1; }
.file-action-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 3px 5px; border-radius: 4px; transition: 0.15s; font-size: 13.5px; }
.file-action-btn:hover { background-color: #e5e7eb; color: var(--text-primary); }
.file-action-btn.delete-btn:hover { background-color: #fef2f2; color: #ef4444; }

/* USER PROFILE FOOTER */
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border-color); background: #fafafa; }
.user-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; border-radius: 8px; padding: 4px; transition: 0.2s; }
.user-profile:hover { background: #f3f4f6; }
.user-avatar-small { width: 34px; height: 34px; border-radius: 50%; background-color: var(--primary-color); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }

.user-info-text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-badge { font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; border-radius: 10px; padding: 1px 6px; width: fit-content; }
.guest-badge { background: #fef3c7; color: #d97706; }
.member-badge { background: #dcfce7; color: #166534; }
.gear-btn { flex-shrink: 0; }

/* MAIN CHAT AREA */
.chat-main { flex-grow: 4; flex-basis: 0; min-width: 400px; display: flex; flex-direction: column; position: relative; border-right: 1px solid var(--border-color); }

.chat-header { padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background-color: var(--sidebar-bg); }
.chat-header h2 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 12px; }
.header-actions { display: flex; gap: 8px; }
.text-danger:hover { color: #ef4444; background-color: #fef2f2; }

.chat-box { flex-grow: 1; padding: 30px 10%; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; scroll-behavior: smooth; }

.msg-row { display: flex; gap: 16px; width: 100%; max-width: 100%; }
.user-row { align-self: flex-end; flex-direction: row-reverse; }
.ai-row { align-self: flex-start; }

.avatar { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.user-avatar { background-color: var(--primary-color); color: white; }
.ai-avatar { background-color: #e0e7ff; color: #4f46e5; }

.msg-bubble { font-size: 14.5px; line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%; }
.user-bubble { padding: 14px 18px; border-radius: 16px; background-color: var(--user-bubble); color: var(--text-primary); border-top-right-radius: 4px; white-space: pre-wrap; }
.ai-bubble { padding: 8px 0; color: var(--text-primary); width: 100%; min-width: 0; overflow-x: auto; white-space: normal; }

.ai-answer-content { line-height: 1.7; }
.ai-answer-content p { margin-bottom: 1.1em; }
.ai-answer-content p:last-child { margin-bottom: 0; }
.ai-answer-content h1, .ai-answer-content h2, .ai-answer-content h3, .ai-answer-content h4 { margin-top: 1.4em; margin-bottom: 0.7em; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }
.ai-answer-content h1:first-child, .ai-answer-content h2:first-child, .ai-answer-content h3:first-child { margin-top: 0; }
.ai-answer-content ul, .ai-answer-content ol { margin-bottom: 1.1em; padding-left: 26px; }
.ai-answer-content li { margin-bottom: 0.4em; }
.ai-answer-content pre { background: #282c34 !important; border: 1px solid var(--border-color); color: #abb2bf; padding: 18px; border-radius: 8px; overflow-x: auto; max-width: 100%; margin: 1.4em 0; font-size: 0.88em; font-family: 'Courier New', monospace; white-space: pre; }
.ai-answer-content code { font-family: 'Courier New', monospace; background-color: #f3f4f6; padding: 0.2em 0.4em; border-radius: 6px; font-size: 0.88em; color: #BE185D; }
.ai-answer-content pre code { background: transparent; padding: 0; font-size: 1em; color: #abb2bf; }
.ai-answer-content blockquote { border-left: 4px solid var(--primary-color); margin: 1.4em 0; padding: 14px 18px; background: #f5f3ff; border-radius: 0 8px 8px 0; color: var(--text-secondary); font-style: italic; }
.ai-answer-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: separate; border-spacing: 0; width: 100%; margin: 1.4em 0; font-size: 0.92em; border-radius: 8px; border: 1px solid var(--border-color); }
.ai-answer-content th, .ai-answer-content td { border-bottom: 1px solid var(--border-color); padding: 12px 14px; text-align: left; }
.ai-answer-content th { background: #f3f4f6; font-weight: 600; color: var(--text-primary); }
.ai-answer-content tr:last-child td { border-bottom: none; }
.ai-answer-content strong { font-weight: 600; color: var(--text-primary); }

/* PREVIEW PANEL */
.preview-panel { flex-grow: 6; flex-basis: 0; display: flex; flex-direction: column; background-color: #ffffff; transition: flex-grow 0.3s ease, width 0.3s ease; border-left: 1px solid var(--border-color); height: 100vh; height: 100dvh; overflow: hidden; min-width: 0; }
.preview-panel.collapsed { flex-grow: 0 !important; width: 0 !important; min-width: 0 !important; overflow: hidden !important; border-left: none !important; }
.preview-header { padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background: #f8fafc; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.preview-filename { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; color: #1e293b; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.preview-btn { background-color: var(--primary-color); color: white; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 4px; }

.tab-buttons { display: flex; background: #e2e8f0; border-radius: 8px; padding: 3px; gap: 3px; }
.tab-btn { border: none; background: transparent; padding: 5px 12px; font-size: 12px; font-weight: 500; color: #475569; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: 0.2s; }
.tab-btn.active { background: #ffffff; color: var(--primary-color); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.preview-content { flex: 1; position: relative; width: 100%; height: calc(100vh - 55px); height: calc(100dvh - 55px); overflow: hidden; background: #ffffff; display: flex; flex-direction: column; }
.preview-tab-pane { width: 100%; height: 100%; display: none; flex-direction: column; overflow: auto; box-sizing: border-box; }
.preview-tab-pane.active { display: flex !important; }

#monacoEditorContainer { width: 100%; height: 100%; flex: 1; }
#visualPreviewContainer { width: 100%; height: 100%; overflow: auto; padding: 20px; background: #ffffff; box-sizing: border-box; }
#visualPreviewContainer iframe { width: 100%; height: 100%; min-height: 500px; border: 1px solid var(--border-color); border-radius: 8px; }

/* Excel Table styling */
.excel-table-container { overflow: auto; width: 100%; height: 100%; }
.excel-table-container table { border-collapse: collapse; width: 100%; font-size: 12px; border: 1px solid #cbd5e1; }
.excel-table-container th, .excel-table-container td { border: 1px solid #cbd5e1; padding: 6px 10px; text-align: left; }
.excel-table-container th { background: #f1f5f9; font-weight: 600; }

/* Word Document styling */
.word-doc-container { font-family: 'Inter', sans-serif; line-height: 1.6; color: #334155; max-width: 800px; margin: 0 auto; background: #ffffff; padding: 30px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border-radius: 8px; }

/* Console Output styling */
#consoleOutputContainer { background: #0f172a; color: #f8fafc; font-family: 'Consolas', 'Courier New', monospace; padding: 16px; display: none; flex-direction: column; height: 100%; }
#consoleOutputContainer.active { display: flex; }
.console-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #334155; padding-bottom: 8px; margin-bottom: 12px; font-size: 13px; }
.console-title { font-weight: 600; color: #94a3b8; display: flex; align-items: center; gap: 6px; }
.console-status { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #334155; color: #cbd5e1; }
.console-status.success { background: #065f46; color: #34d399; }
.console-status.error { background: #991b1b; color: #fca5a5; }
.console-log { flex: 1; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 13px; line-height: 1.5; color: #e2e8f0; }

/* Input Area */
.input-area { padding: 20px 10%; background: linear-gradient(to top, var(--main-bg) 70%, transparent); display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; }

.agent-selector { background-color: #f3f4f6; color: var(--text-secondary); font-size: 12px; padding: 4px 10px; border-radius: 12px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-color); cursor: pointer; transition: 0.2s; }
.agent-selector:hover { border-color: var(--primary-color); color: var(--primary-color); background-color: #f5f3ff; }
.agent-selector i { font-size: 14px; color: var(--primary-color); }

.attachments-bar { width: 100%; max-width: 800px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-start; padding: 0 4px; }
.chat-upload-btn { background-color: transparent; border: 1px dashed var(--border-color); color: var(--text-secondary); padding: 4px 10px; border-radius: 12px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: 0.2s; }
.chat-upload-btn:hover { border-color: var(--primary-color); color: var(--primary-color); background-color: #f5f3ff; }
.attachment-chip { background-color: #f3f4f6; color: var(--text-primary); border: 1px solid var(--border-color); padding: 4px 10px; border-radius: 12px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.attachment-chip i { font-size: 14px; color: var(--primary-color); }
.attachment-chip .remove-chip { cursor: pointer; color: #ef4444; }

.input-container { width: 100%; max-width: 800px; display: flex; align-items: flex-end; background-color: var(--ai-bubble); padding: 8px 8px 8px 20px; border-radius: 24px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid var(--border-color); transition: 0.3s; position: relative; }
.input-container:focus-within { border-color: var(--primary-color); box-shadow: 0 4px 20px rgba(139, 92, 246, 0.15); }

.mention-dropdown { position: absolute; bottom: 100%; left: 0; background-color: white; border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); width: 250px; max-height: 200px; overflow-y: auto; z-index: 10; display: none; flex-direction: column; padding: 4px 0; margin-bottom: 8px; }
.mention-item { padding: 8px 16px; font-size: 13px; cursor: pointer; color: var(--text-primary); display: flex; align-items: center; gap: 8px; transition: 0.1s; }
.mention-item:hover, .mention-item.active { background-color: #f5f3ff; color: var(--primary-color); }

/* Auto-growing message box: starts as a single line and expands UPWARD
   (the flex column layout means .chat-box above it shrinks/scrolls as this
   grows) so users - especially on mobile - can see their whole prompt
   before sending, instead of the old single-line <input> that just
   scrolled text sideways out of view. Height is driven by JS (scrollHeight)
   up to max-height, after which it scrolls internally. */
.input-container textarea {
  flex-grow: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  background: transparent;
  color: var(--text-primary);
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
  padding: 8px 0;
  max-height: 160px;
  min-height: 24px;
}
.input-container textarea::placeholder { color: #9ca3af; }

.submit-btn { background-color: #f5f3ff; color: var(--primary-color); border: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.submit-btn:hover:not(:disabled) { background-color: var(--primary-hover); color: white; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.submit-btn i { font-size: 20px; }

.footer-note { font-size: 11px; color: #9ca3af; text-align: center; }

/* Agent block UI */
.agent-block { font-size: 13px; color: #6b7280; margin-bottom: 12px; display: none; flex-direction: column; align-items: flex-start; background: #f9fafb; padding: 10px 14px; border-radius: 8px; border: 1px solid #e5e7eb; }
.agent-block.active { display: flex; }
.agent-title { font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: #4b5563; }

.agent-thought-content { width: 100%; font-size: 13px; line-height: 1.5; color: #4b5563; word-wrap: break-word; }
.agent-thought-content p { margin-bottom: 0.5em; }
.agent-thought-content p:last-child { margin-bottom: 0; }
.agent-thought-content pre { background: #1e293b !important; color: #e2e8f0; padding: 10px; border-radius: 6px; overflow-x: auto; margin: 0.6em 0; font-size: 0.85em; }
.agent-thought-content code { background: #e2e8f0; color: #0f172a; padding: 2px 5px; border-radius: 4px; font-size: 0.85em; }
.agent-thought-content pre code { background: transparent; padding: 0; color: inherit; }
.agent-thought-content ul, .agent-thought-content ol { padding-left: 20px; margin-bottom: 0.5em; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #cbd5e1; border-radius: 50%; border-top-color: var(--primary-color); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-msg { margin: auto; text-align: center; color: #9ca3af; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-msg i { font-size: 48px; color: #e5e7eb; }

/* CLAUDE CODE ENGINE ACTIVITY PANEL */
.claude-activity-panel {
    margin-bottom: 14px;
    border-radius: 10px;
    border: 1px solid #1e293b;
    background: #0f172a;
    overflow: hidden;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    animation: claudePanelIn 0.3s ease;
}
@keyframes claudePanelIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.claude-activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    cursor: default;
}

.claude-activity-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
}
.claude-activity-title i { font-size: 15px; color: #60a5fa; }

.claude-activity-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.claude-activity-badge.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    animation: badgePulse 2s infinite;
}
.claude-activity-badge.done {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}
@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.claude-activity-toggle {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.claude-activity-toggle:hover { color: #cbd5e1; }

.claude-activity-body {
    max-height: 350px;
    overflow-y: auto;
    padding: 8px 12px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.claude-activity-body::-webkit-scrollbar { width: 5px; }
.claude-activity-body::-webkit-scrollbar-track { background: transparent; }
.claude-activity-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.claude-activity-log {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.claude-log-entry {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    animation: logEntryIn 0.2s ease;
}
@keyframes logEntryIn {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

.claude-log-entry-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    font-weight: 600;
}
.claude-log-entry-header i { font-size: 13px; }

.claude-log-label { color: #cbd5e1; }

.claude-log-entry-body {
    margin-top: 4px;
    padding: 4px 8px 4px 20px;
    color: #64748b;
    font-size: 11px;
    word-break: break-all;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* Log entry type colors */
.log-thinking { background: rgba(139, 92, 246, 0.08); border-left: 2px solid #8b5cf6; }
.log-thinking .claude-log-entry-header i { color: #a78bfa; }
.log-thinking .claude-log-entry-body { color: #a78bfa; opacity: 0.8; }

.log-tool { background: rgba(59, 130, 246, 0.08); border-left: 2px solid #3b82f6; }
.log-tool .claude-log-entry-header i { color: #60a5fa; }
.log-tool .claude-log-label { color: #93c5fd; }
.log-tool .claude-log-entry-body { color: #7dd3fc; }

.log-tool-result { background: rgba(14, 165, 233, 0.06); border-left: 2px solid #0ea5e9; }
.log-tool-result .claude-log-entry-header i { color: #38bdf8; }
.log-tool-result .claude-log-entry-body { color: #7dd3fc; opacity: 0.7; }

.log-system { background: rgba(100, 116, 139, 0.08); border-left: 2px solid #475569; }
.log-system .claude-log-entry-header i { color: #94a3b8; }

.log-done { background: rgba(34, 197, 94, 0.1); border-left: 2px solid #22c55e; }
.log-done .claude-log-entry-header i { color: #4ade80; }
.log-done .claude-log-label { color: #4ade80; }

.log-raw { background: rgba(100, 116, 139, 0.05); }
.log-raw .claude-log-entry-body { color: #475569; font-size: 10px; }

/* MODAL DIALOGS */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); z-index: 500; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.25s ease; }
.modal-overlay.active { display: flex; opacity: 1; }

.modal-card { background: #ffffff; width: 100%; max-width: 440px; border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); overflow: hidden; border: 1px solid var(--border-color); animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes modalIn { from { transform: scale(0.95); } to { transform: scale(1); } }

.modal-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background: #f8fafc; }
.modal-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.profile-card-summary { display: flex; align-items: center; gap: 14px; background: #f8fafc; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border-color); }
.user-avatar-large { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-color); color: white; font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.badge-status { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.guest-banner { background: #fffbebf5; border: 1px solid #fef3c7; padding: 14px; border-radius: 12px; font-size: 13px; color: #92400e; display: flex; flex-direction: column; gap: 10px; }
.guest-banner button { margin-top: 4px; }

.modal-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.form-group input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-color); font-size: 14px; outline: none; transition: 0.2s; font-family: 'Inter', sans-serif; }
.form-group input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }

.btn-primary { background: var(--primary-color); color: white; border: none; padding: 10px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: 0.2s; text-align: center; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #f3f4f6; color: var(--text-primary); border: 1px solid var(--border-color); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-secondary:hover { background: #e5e7eb; }

.btn-danger { background: #fef2f2; color: #ef4444; border: 1px solid #fecaca; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-danger:hover { background: #fee2e2; }

.modal-card-sm { max-width: 360px; }
.text-center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.modal-icon-circle { width: 52px; height: 52px; border-radius: 50%; background: #fef2f2; color: #ef4444; font-size: 26px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px auto; }
.modal-icon-circle.info-icon { background: #eff6ff; color: #3b82f6; }

.modal-btn-group { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.modal-btn-group button { flex: 1; }

.auth-tabs { display: flex; background: #f1f5f9; border-radius: 8px; padding: 3px; gap: 3px; margin-bottom: 6px; }
.auth-tab-btn { flex: 1; border: none; background: transparent; padding: 8px; font-size: 13px; font-weight: 500; color: var(--text-secondary); border-radius: 6px; cursor: pointer; transition: 0.2s; }
.auth-tab-btn.active { background: white; color: var(--primary-color); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* MOBILE RESPONSIVE STYLING */
.mobile-only { display: none !important; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 190; opacity: 0; transition: opacity 0.3s ease; }
.sidebar-overlay.active { display: block; opacity: 1; }

.mobile-tabbar { display: none; }

@media (max-width: 768px) {
    .mobile-only { display: flex !important; }
    
    body { font-family: 'Inter', sans-serif; height: 100vh; height: 100dvh; overflow: hidden; }
    .app-container { flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }
    
    .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw; height: 100vh; height: 100dvh; z-index: 200; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 10px 0 30px rgba(0,0,0,0.15); border-right: 1px solid var(--border-color); background: #ffffff; }
    .sidebar.open { transform: translateX(0); }
    
    .chat-main { flex: 1; width: 100%; border-right: none; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
    .chat-header { padding: 12px 16px; background: #ffffff; flex-shrink: 0; }
    .chat-header h2 { font-size: 15px; }
    .chat-box { flex: 1; padding: 16px 12px 20px; gap: 16px; overflow-y: auto; }
    
    .input-area { padding: 10px 10px 10px; background: #ffffff; border-top: 1px solid var(--border-color); margin-bottom: 58px; flex-shrink: 0; }
    .input-container { border-radius: 20px; padding: 6px 6px 6px 16px; }
    .input-container textarea { font-size: 16px; max-height: 40vh; } /* 16px avoids iOS auto-zoom-on-focus */
    .submit-btn { width: 36px; height: 36px; }
    
    .preview-panel { position: fixed; top: 0; left: 0; right: 0; bottom: 58px; width: 100vw; width: 100dvw; height: calc(100vh - 58px); height: calc(100dvh - 58px); z-index: 100; border-left: none; display: none; }
    .preview-panel.mobile-active { display: flex !important; flex-grow: 1; width: 100vw !important; width: 100dvw !important; }
    
    .mobile-tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 58px; background: #ffffff; border-top: 1px solid var(--border-color); z-index: 150; align-items: stretch; justify-content: space-around; }
    .mobile-tab-btn { flex: 1; background: transparent; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-secondary); font-size: 11px; font-weight: 500; cursor: pointer; transition: color 0.2s; }
    .mobile-tab-btn i { font-size: 20px; }
    .mobile-tab-btn.active { color: var(--primary-color); font-weight: 600; }
}
