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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --accent: #7c5cff;
    --accent-hover: #6b4de0;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --border: #333;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
}

.header-progress {
    flex: 1;
}

.header-progress .progress-bar {
    display: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 600;
}
------- SEARCH
.btn.icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
=======
.btn.icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn.icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.send-btn svg path {
    fill: currentColor;
}
------- SEARCH
.module-dot {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    cursor: default;
    transition: all 0.2s;
}
=======
.header-actions {
    margin-left: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.header-actions .btn.icon {
    display: inline-flex;
}

.header-nav {
    display: none;
}
------- SEARCH
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}
=======
/* дубликат .header ниже не нужен, используем только верхнее определение */
.header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
}
------- SEARCH
/* progress-container больше не используется, прогресс встроен в .header */
.progress-container {
    display: none;
}
=======
.progress-container {
    padding: 12px 20px;
}
------- SEARCH
.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}
=======
.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}
------- SEARCH
.send-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    font-size: 20px;
}
=======
.send-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
}

.page-footer {
    padding: 8px 20px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.page-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.page-footer a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Progress */
.progress-container {
    padding: 12px 20px;
}

.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.progress-modules {
    display: flex;
    justify-content: space-between;
}

.module-dot {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    cursor: default;
    transition: all 0.2s;
}

.module-dot.active {
    background: var(--accent);
    color: white;
}

.module-dot.completed {
    background: var(--success);
    color: var(--bg-primary);
}

/* Chat */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
}

/* Ненавязчивая анимация появления только для новых сообщений */
.message-enter {
    animation: messageEnterAssistant 0.22s cubic-bezier(0.25, 0.9, 0.35, 1.0);
}

.message.user.message-enter {
    animation: messageEnterUser 0.22s cubic-bezier(0.25, 0.9, 0.35, 1.0);
}

@keyframes messageEnterAssistant {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
        filter: blur(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes messageEnterUser {
    from {
        opacity: 0;
        transform: translateX(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

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

.message-content {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
}

.message.user .message-content {
    background: var(--accent);
    color: white;
}

.message.system .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    max-width: 100%;
}

/* Typing indicator (klassicheskiy trekh-tochyechnyy trobbber) */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--text-secondary);
    opacity: 0.4;
    animation: typingBlink 1s infinite ease-in-out;
}

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

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

@keyframes typingBlink {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    40% {
        transform: translateY(-2px);
        opacity: 1;
    }
}

.message.user .typing-dot {
    background: rgba(255,255,255,0.7);
}

.message-content {
    line-height: 1.4;
}

.message-content h3 {
    margin-bottom: 6px;
    font-size: 18px;
}

.message-content p {
    margin-bottom: 4px;
}

.message-content p:last-child {
    margin-bottom: 0;
}
------- SEARCH
.message-content ul,
.message-content ol {
    margin: 2px 0;
    padding-left: 18px;
}

.message-content li {
    margin: 1px 0;
}
=======
.message-content ul,
.message-content ol {
    margin: 2px 0;
    padding-left: 18px;
}

.message-content li {
    margin: 1px 0;
}
------- SEARCH
/* Убрали переопределение в одну колонку на мобильных — сравнения всегда в две колонки */
=======
/* На любых ширинах две карточки сравнения остаются в строку */

.message-content code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.message-content pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.message-content th,
.message-content td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.message-content th {
    background: var(--bg-tertiary);
}

/* Двухколоночное представление для сравнений (Вариант A / Вариант B) */
.compare-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 8px 0;
}

.compare-col {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.compare-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.compare-col ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.compare-col li {
    font-size: 14px;
    margin: 4px 0;
}

.message-content strong {
    color: var(--accent);
}

.message.user .message-content strong {
    color: white;
}

/* компактные списки внутри сообщений */
.message-content ul,
.message-content ol {
    margin: 2px 0;
    padding-left: 18px;
}

.message-content li {
    margin: 1px 0;
}

/* Input */
.input-container {
    padding: 16px 20px;
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

#user-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    font-family: inherit;
}

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

#user-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    font-size: 20px;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status {
    font-size: 13px;
    color: var(--text-secondary);
}

.status.error {
    color: var(--error);
}

.status.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-secondary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn:hover:not(:disabled) {
    background: var(--border);
}

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

.btn.primary {
    background: var(--accent);
    color: white;
}

.btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn.icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--accent-hover);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Markdown rendering */
.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* Responsive */
@media (max-width: 600px) {
    .header {
        padding: 12px 16px;
    }

    .logo span:not(.logo-icon) {
        display: none;
    }

    .progress-container {
        padding: 12px 16px;
    }

    .chat-container {
        padding: 16px;
    }

    .input-container {
        padding: 12px 16px;
    }

    .message-content {
        max-width: 90%;
    }
}

/* overrides: компактная типографика и сравнения всегда в две колонки */
.message-content {
    line-height: 1.4;
}

.message-content h3 {
    margin-bottom: 6px;
}

.message-content p {
    margin-bottom: 4px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 2px 0;
    padding-left: 18px;
}

.message-content li {
    margin: 1px 0;
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 8px 0;
}

@media (max-width: 600px) {
    .compare-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
