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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #242836;
    --bg-input: #1e2130;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --accent: #f97316;
    --accent-hover: #fb923c;
    --accent-dim: rgba(249, 115, 22, 0.15);
    --success: #22c55e;
    --error: #ef4444;
    --border: #2d3140;
    --source-bg: rgba(249, 115, 22, 0.1);
    --source-border: rgba(249, 115, 22, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 768px;
    margin: 0 auto;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border-radius: var(--radius);
}

.header-title { font-size: 18px; font-weight: 700; }
.header-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

.btn-settings {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.settings-panel {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    transition: max-height 0.3s ease;
    max-height: 400px;
}

.settings-panel.hidden { max-height: 0; border-bottom: none; }
.settings-content { padding: 16px; }
.settings-content h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }

.notices-list { max-height: 150px; overflow-y: auto; margin-bottom: 12px; }

.notice-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 13px;
}

.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-upload, .btn-ingest {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    min-height: 60vh;
    justify-content: center;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border-radius: 20px;
}

.welcome-message h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.welcome-message p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 24px; }

.example-questions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 400px; }

.example-btn {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.message { margin-bottom: 16px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-user { display: flex; justify-content: flex-end; }

.message-user .message-bubble {
    background: var(--accent);
    color: white;
    border-radius: var(--radius) var(--radius) 4px var(--radius);
    max-width: 80%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
}

.message-bot { display: flex; gap: 10px; align-items: flex-start; }

.bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message-bot .message-bubble {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius) var(--radius) var(--radius);
    max-width: 85%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
}

.message-bot .message-bubble p { margin-bottom: 8px; }
.message-bot .message-bubble p:last-child { margin-bottom: 0; }

.sources {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--source-bg);
    border: 1px solid var(--source-border);
    border-radius: var(--radius-sm);
}

.sources-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 6px;
}

.source-item { font-size: 12px; color: var(--text-secondary); padding: 2px 0; }

.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.loading { color: var(--text-muted); font-size: 13px; font-style: italic; }

.input-area {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 6px 6px 14px;
}

.input-container:focus-within { border-color: var(--accent); }

textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 6px 0;
}

textarea::placeholder { color: var(--text-muted); }

.btn-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    font-size: 16px;
}

.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 8px; }

.status-message { text-align: center; padding: 8px 16px; font-size: 12px; color: var(--text-muted); }
.status-message.success { color: var(--success); }
.status-message.error { color: var(--error); }

@media (min-width: 768px) {
    #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
