:root {
    --sidebar-bg: #202123;
    --main-bg: #343541;
    --user-msg-bg: #343541;
    --bot-msg-bg: #444654;
    --text-color: #ececf1;
    --text-secondary: #8e8ea0;
    --input-bg: #40414f;
    --accent: #10a37f;
    --accent-hover: #1a7f64;
    --border-color: #4d4d4f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-color);
    display: flex;
    flex-direction: column; /* Вертикальная структура: Навбар -> Контент */
    height: 100vh;
    overflow: hidden;
}

/* --- TOP NAVIGATION (TABS) --- */
.top-nav {
    background-color: var(--sidebar-bg);
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    height: 50px;
    flex-shrink: 0;
    align-items: center;
}

.nav-tab {
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 500;
}

.nav-tab:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}

.nav-tab.active {
    color: white;
    border-bottom-color: var(--accent);
    background: rgba(255,255,255,0.05);
}

/* --- LAYOUT CONTAINER --- */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden; /* Чтобы скролл был только внутри чата */
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 10px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar h2 {
    font-size: 18px;
    color: #fff;
    margin: 10px 0 20px 12px;
}

.menu-item {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    transition: 0.2s;
    border: 1px solid transparent;
}
.menu-item:hover { 
    background-color: #2A2B32; 
}

/* Фиксированный блок режимов */
.mode-group {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.mode-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.radio-option {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}

.radio-option input { 
    margin-right: 10px; 
    accent-color: var(--accent);
}

.checkbox-option {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #444;
    font-size: 13px;
    display: flex;
    align-items: center;
    color: #ccc;
    cursor: pointer;
    user-select: none;
}
.checkbox-option input { 
    margin-right: 10px; 
    accent-color: var(--accent);
}

.user-profile {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

/* --- MAIN CHAT AREA --- */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--main-bg);
}

/* Блок рубрик сверху */
.rubric-section {
    margin: 20px auto 10px;
    max-width: 800px;
    width: 90%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    background: rgba(32,33,35, 0.5);
    flex-shrink: 0; /* Чтобы не сжимался */
}

.rubric-header {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

.rubrics-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rubric-btn {
    background: #40414f;
    border: 1px solid transparent;
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    user-select: none;
}

.rubric-btn:hover { 
    background: #4d4d4f; 
    border-color: #666;
}

.rubric-btn.active {
    background: rgba(16, 163, 127, 0.2);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
}

/* Контейнер сообщений */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 140px; /* Отступ под инпут */
    scroll-behavior: smooth;
}

/* Скроллбар */
.chat-container::-webkit-scrollbar {
    width: 8px;
}
.chat-container::-webkit-scrollbar-track {
    background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
    background-color: #565869;
    border-radius: 4px;
}

/* Сообщения */
.message {
    padding: 24px 0;
    line-height: 1.6;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
.message.bot { background-color: var(--bot-msg-bg); }
.message.user { background-color: var(--user-msg-bg); }

.message-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px; /* Отступы по бокам на мобильных */
}

/* --- INPUT AREA --- */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, rgba(53,53,65,0), var(--main-bg) 20%);
    padding: 20px 0 30px;
    display: flex;
    justify-content: center;
}

.input-box-wrapper {
    position: relative;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    border-radius: 12px;
}

.chat-input {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid rgba(32,33,35,0.5);
    border-radius: 12px;
    color: white;
    padding: 14px 50px 14px 16px; /* Справа место под кнопку */
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    overflow-y: hidden;
    line-height: 1.5;
}

.chat-input:focus {
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
    border-color: rgba(255,255,255,0.1);
}

.send-btn {
    position: absolute;
    right: 12px;
    bottom: 12px; /* Привязка к низу, чтобы не прыгала при ресайзе */
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background-color: #1a1b1e;
}
.send-btn:disabled {
    color: #666;
    cursor: default;
}

/* --- MARKDOWN STYLES --- */
.message-content strong { color: #fff; font-weight: 700; }
.message-content h1, .message-content h2, .message-content h3 { margin-top: 20px; color: #fff; }
.message-content ul, .message-content ol { padding-left: 20px; margin: 10px 0; }
.message-content li { margin-bottom: 5px; }

.message-content pre {
    background: black;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid #444;
}

.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    background-color: rgba(255,255,255,0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    color: #eee;
}

.message-content a {
    color: var(--accent);
    text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #444; display: none; /* Скрываем на мобилках пока */ }
    .rubric-section { margin-top: 10px; width: 95%; }
    .message-content { padding: 0 15px; }
}
