:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-hover: #f0f2f5;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-card: #344050;
    --surface-hover: #334155;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: #334155;
    --primary: #818cf8;
    --primary-light: #a5b4fc;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background var(--transition), color var(--transition);
}

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    position: relative;
    transition: background var(--transition);
}

/* Для ПК (ширина экрана больше 768px) — делаем в 2 раза шире */
@media screen and (min-width: 768px) {
    .app-container {
        max-width: 960px;  /* 480 * 2 = 960px */
    }
}

/* Верхняя панель */
.top-bar {
    background: var(--primary-gradient);
    color: white;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    min-height: 48px;
    flex-shrink: 0;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.top-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    position: relative;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* Выпадающее меню */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    overflow: hidden;
    z-index: 100;
    animation: dropdownIn 0.2s ease;
    display: none;
    border: 1px solid var(--border);
}

.dropdown-menu.show {
    display: block;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--surface-hover);
}

.dropdown-item .item-icon {
    font-size: 18px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Основной контент */
.main-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.page {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.page.active {
    display: flex;
}

.page-header {
    padding: 15px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.page-header h2 {
    font-size: 18px;
    color: var(--text);
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Приветственный блок */
.welcome-block {
    text-align: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

.welcome-block.hidden {
    display: none;
}

.ai-avatar-small {
    font-size: 40px;
    margin-bottom: 8px;
}

.welcome-text-small {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Чат */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    min-height: 0;
}

.message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-items: flex-end;
}

.message.bot {
    align-items: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.message-content strong {
    font-weight: 600;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

/* Нижняя панель */
.bottom-panel {
    flex-shrink: 0;
    position: relative;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 5;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.input-panel {
    padding: 10px 16px;
}

.text-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

#message-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), background var(--transition);
}

#message-input:focus {
    border-color: var(--primary);
    background: var(--surface);
}

#send-btn {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition);
}

#send-btn:active {
    transform: scale(0.9);
}

/* Нижнее меню */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 2px 0 6px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    color: var(--text-secondary);
    border: none;
    background: none;
    font-size: 10px;
    position: relative;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -4px;
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}

.nav-item .nav-icon {
    font-size: 22px;
    transition: transform var(--transition);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-item .nav-label {
    font-size: 10px;
    font-weight: 500;
}

/* Микрофон */
.voice-float-btn {
    position: fixed;
    bottom: 100px;
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-gradient);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    touch-action: none;
    user-select: none;
    transition: box-shadow var(--transition), transform var(--transition);
    will-change: left, top;
}

.voice-float-btn:active {
    transform: scale(0.95);
}

.voice-float-btn.listening {
    background: var(--danger);
    animation: pulse 1.5s infinite;
}

.voice-float-btn:not(.listening):hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* Адаптивность */
@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
    }
}

@media (min-width: 601px) {
    .app-container {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
/* убираем нижний блок с установить приложение */
#pwa-install-banner {
    display: none !important;
}