* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #007aff;
    --border-radius: 12px;
    --spacing: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Приветственный экран */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f0f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing);
}

.welcome-content {
    text-align: center;
    max-width: 320px;
}

.welcome-logo {
    font-size: 80px;
    margin-bottom: 24px;
    animation: fadeInDown 0.6s ease-out;
}

.welcome-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.welcome-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.welcome-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px 48px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.welcome-btn:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Основное приложение */
.app {
    padding: var(--spacing);
    padding-bottom: 32px;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-out;
}

.hidden {
    display: none !important;
}

/* Шапка */
.header {
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.icon-btn {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:active {
    background: var(--bg-tertiary);
    transform: scale(0.95);
}

/* Поиск */
.search-section {
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 12px 16px;
}

.search-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* Секции */
.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

/* Популярные каналы */
.horizontal-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.horizontal-scroll::-webkit-scrollbar {
    display: none;
}

.channel-chip {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    width: 80px;
}

.channel-chip:active {
    transform: scale(0.95);
}

.channel-avatar-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
}

.channel-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-name {
    font-size: 12px;
    text-align: center;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

/* Сетка категорий */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.category-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 120px;
    justify-content: center;
}

.category-card:active {
    transform: scale(0.98);
    background: var(--bg-tertiary);
}

.category-card.large {
    grid-column: span 2;
    flex-direction: row;
    justify-content: flex-start;
    gap: 20px;
    min-height: auto;
    padding: 16px 20px;
}

.category-icon {
    width: 48px;
    height: 48px;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-card.large .category-icon {
    width: 56px;
    height: 56px;
    font-size: 40px;
}

.category-title {
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
}

.category-card.large .category-title {
    text-align: left;
    font-size: 16px;
}

/* Экраны */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
}

.screen-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: var(--spacing);
    padding-top: calc(var(--spacing) + env(safe-area-inset-top));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.back-btn:active {
    background: var(--bg-tertiary);
}

.screen-title {
    font-size: 20px;
    font-weight: 600;
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing);
}

/* Список организаций */
.organizations-list,
.all-org-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.org-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.org-item:active {
    background: var(--bg-tertiary);
    transform: scale(0.98);
}

.org-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.org-info {
    flex: 1;
    min-width: 0;
}

.org-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.org-category {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Алфавитный указатель */
.alphabet-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.alphabet-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.alphabet-item:active {
    background: var(--accent);
    color: white;
    transform: scale(0.95);
}

.alphabet-item.active {
    background: var(--accent);
    color: white;
}

.alphabet-item.empty {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Группы по буквам */
.letter-group {
    margin-bottom: 24px;
}

.letter-header {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
    padding-left: 4px;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Адаптивность */
@media (max-width: 360px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .category-card.large {
        grid-column: span 1;
    }
    
    .channel-chip {
        width: 70px;
    }
    
    .channel-avatar-wrapper {
        width: 56px;
        height: 56px;
    }
}

/* Результаты поиска */
.search-results {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:active {
    background: var(--bg-tertiary);
}

.search-result-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.search-result-type {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 15px;
}