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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface2: #0f3460;
    --accent: #e94560;
    --text: #eee;
    --text-dim: #999;
    --user-bubble: #0f3460;
    --bot-bubble: #1a1a3e;
    --border: #2a2a4a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.3rem;
    font-weight: 700;
}

.subtitle {
    font-weight: 300;
    color: var(--text-dim);
}

.mode-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 3px;
}

.mode-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--accent);
    color: #fff;
}

.lang-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}

.lang-bar select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.swap-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.swap-btn:hover {
    transform: rotate(180deg);
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-msg {
    text-align: center;
    color: var(--text-dim);
    margin: auto 0;
}

.welcome-msg p {
    margin-bottom: 8px;
}

.hint {
    font-size: 0.85rem;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
}

.message.bot {
    align-self: flex-start;
    background: var(--bot-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message .meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.message.bot[dir="rtl"] {
    text-align: right;
}

.input-area {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

#input-text {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}

#input-text:focus {
    outline: none;
    border-color: var(--accent);
}

#send-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    transition: opacity 0.2s;
    align-self: flex-end;
}

#send-btn:hover {
    opacity: 0.85;
}

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

footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-dim);
}

.status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
}

.status.error {
    background: var(--accent);
}

.status.loading {
    background: #ff9800;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@media (max-width: 600px) {
    .container {
        max-width: 100%;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .mode-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .message {
        max-width: 92%;
    }
}
