* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

:root {
    --bg: #000000;
    --bg-secondary: #1c1c1e;
    --bg-card: #2c2c2e;
    --bg-input: #1c1c1e;
    --accent: #0a84ff;
    --accent-green: #30d158;
    --accent-purple: #bf5af2;
    --accent-orange: #ff9f0a;
    --accent-red: #ff453a;
    --text-primary: #ffffff;
    --text-secondary: #ebebf5;
    --text-muted: #8e8e93;
    --bubble-bot: #1c1c1e;
    --bubble-user: #0a84ff;
    --border: rgba(255,255,255,0.08);
    --safe-top: env(safe-area-inset-top, 44px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 480px;
    margin: 0 auto;
}

/* STATUS BAR */
.status-bar {
    height: var(--safe-top);
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    min-height: 44px;
}

/* NAVIGATION BAR */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 10px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-back {
    color: var(--accent);
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 60px;
    font-weight: 400;
}

.nav-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a84ff, #bf5af2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 2px;
}

.nav-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-status {
    font-size: 11px;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 3px;
}

.nav-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-green);
    border-radius: 50%;
    display: inline-block;
}

.nav-action {
    min-width: 60px;
    display: flex;
    justify-content: flex-end;
}

.nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-card);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
}

/* TOPIC PILLS */
.topic-scroll {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg);
    border-bottom: 0.5px solid var(--border);
}

.topic-scroll::-webkit-scrollbar { display: none; }

.topic-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    border: 0.5px solid var(--border);
    transition: all 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.topic-pill:active { transform: scale(0.95); background: var(--bg-card); }
.topic-pill.blue { color: #0a84ff; }
.topic-pill.green { color: #30d158; }
.topic-pill.purple { color: #bf5af2; }
.topic-pill.orange { color: #ff9f0a; }
.topic-pill, .cap-item, .suggest-chip, .send-btn {
    cursor: pointer !important;
    pointer-events: all !important;
    position: relative;
    z-index: 10;
}

/* CHAT AREA */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    z-index: 1;
}

.chat-area::-webkit-scrollbar { display: none; }

.date-sep {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin: 12px 0 8px;
    font-weight: 500;
}

/* MESSAGES */
.message-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
}

.message-row.user { align-items: flex-end; }
.message-row.bot { align-items: flex-start; }

.bubble-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 82%;
}

.message-row.user .bubble-wrap { flex-direction: row-reverse; }

.bot-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a84ff, #bf5af2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.message-row.bot .bubble {
    background: var(--bubble-bot);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-row.user .bubble {
    background: var(--bubble-user);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bubble pre {
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0 4px;
    font-size: 12px;
    line-height: 1.6;
    color: #30d158;
    font-family: 'SF Mono', 'Menlo', monospace;
    scrollbar-width: none;
}

.bubble pre::-webkit-scrollbar { display: none; }

.bubble code {
    background: rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 13px;
    font-family: 'SF Mono', 'Menlo', monospace;
    color: #30d158;
}

.bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin: 3px 4px 8px;
}

.message-row.user .message-time { text-align: right; }

/* TYPING INDICATOR */
.typing-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 4px;
}

.typing-bubble {
    background: var(--bubble-bot);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.3s infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }

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

/* INPUT AREA */
.input-area {
    padding: 8px 12px;
    padding-bottom: calc(8px + var(--safe-bottom));
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--border);
}

.suggestions-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.suggestions-row::-webkit-scrollbar { display: none; }

.suggest-chip {
    background: var(--bg-secondary);
    border: 0.5px solid var(--border);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.suggest-chip:active { transform: scale(0.95); background: var(--bg-card); }

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border-radius: 22px;
    padding: 6px 6px 6px 14px;
    border: 0.5px solid var(--border);
    transition: border-color 0.2s;
}

.input-row:focus-within {
    border-color: rgba(10, 132, 255, 0.4);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    resize: none;
    max-height: 100px;
    min-height: 22px;
    line-height: 1.4;
    scrollbar-width: none;
    padding: 2px 0;
}

#userInput::-webkit-scrollbar { display: none; }
#userInput::placeholder { color: var(--text-muted); }

.send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.send-btn:active { transform: scale(0.9); background: #0071d4; }

.send-btn svg {
    fill: white;
    width: 16px;
    height: 16px;
    transform: translateX(1px);
}

/* WELCOME CARD */
.welcome-card {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 12px;
    border: 0.5px solid var(--border);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a84ff, #bf5af2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 12px;
    box-shadow: 0 4px 20px rgba(10,132,255,0.3);
}

.welcome-card h2 {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
}

.welcome-card p {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.5;
}

.capability-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cap-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.cap-item:active { transform: scale(0.97); background: rgba(255,255,255,0.1); }
.cap-icon { font-size: 20px; }

/* Fix click blocking on all interactive elements */
.welcome-card, .capability-grid, .topic-scroll, 
.suggestions-row, .input-area, .input-row {
    position: relative;
    z-index: 2;
}

.cap-item, .topic-pill, .suggest-chip {
    -webkit-tap-highlight-color: rgba(255,255,255,0.1);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

@media (min-width: 481px) {
    body {
        border-left: 0.5px solid var(--border);
        border-right: 0.5px solid var(--border);
    }
}