* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    background: #01030a; 
    color: white; 
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    overflow: hidden; 
}

/* UI Панелі */
#ui-overlay { 
    position: fixed; top: 25px; left: 25px; z-index: 2000; width: 300px;
}
#main-title { 
    font-size: 20px; color: #00d4ff; cursor: pointer; margin-bottom: 15px; 
    text-shadow: 0 0 10px rgba(0,212,255,0.3);
}

/* Пошук */
.search-container { position: relative; width: 100%; }
#search-input { 
    width: 100%; padding: 12px 18px; border-radius: 25px; 
    border: 1px solid rgba(255,255,255,0.1); background: rgba(10,15,30,0.9); 
    color: white; outline: none; transition: 0.3s;
}
#search-input:focus { border-color: #00d4ff; box-shadow: 0 0 15px rgba(0,212,255,0.2); }

#search-results {
    position: absolute; top: 55px; left: 0; width: 100%;
    background: #0a1020; border: 1px solid #333; border-radius: 15px;
    display: none; max-height: 350px; overflow-y: auto; 
    z-index: 999999; box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}
.search-item {
    display: flex; align-items: center; gap: 12px; padding: 10px;
    cursor: pointer; border-bottom: 1px solid #1a1a1a; transition: 0.2s;
}
.search-item:hover { background: #16213e; }
.search-item img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.search-item-title { font-size: 13px; font-weight: bold; color: #fff; }
.search-item-handle { font-size: 11px; color: #00d4ff; }

/* Легенда */
#legend { 
    position: fixed; bottom: 25px; left: 25px; z-index: 500; 
    background: rgba(5,10,20,0.8); padding: 15px; border-radius: 15px; 
    border: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(8px);
}
.legend-item { display: flex; align-items: center; margin: 6px 0; font-size: 12px; color: #ccc; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 12px; }
.dot.tech { background: #00d4ff; }
.dot.ent { background: #ff007f; }
.dot.edu { background: #a2ff00; }
.dot.soc { background: #ff9500; }
.dot.art { background: #bf00ff; }

/* Картка канала */
#info-card {
    position: fixed; bottom: 25px; right: 25px; width: 350px;
    background: #0a0f1e; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 15px 50px rgba(0,0,0,0.9); display: none; z-index: 5000;
    overflow: hidden; animation: slideIn 0.3s ease-out;
}
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

#card-banner { width: 100%; height: 120px; background-size: cover; background-position: center; position: relative; background-color: #111; }
#card-banner::after { content: ''; position: absolute; bottom: 0; width: 100%; height: 80%; background: linear-gradient(to top, #0a0f1e, transparent); }

#card-content { padding: 0 20px 20px; margin-top: -40px; position: relative; z-index: 10; }
#card-header { display: flex; align-items: flex-end; gap: 15px; margin-bottom: 18px; }
#s-icon { width: 75px; height: 75px; border-radius: 50%; border: 4px solid #0a0f1e; background: #000; object-fit: cover; }
#s-handle { font-size: 13px; color: #00d4ff; font-weight: bold; margin-bottom: 2px; }
#s-title { font-size: 20px; color: white; margin: 0; line-height: 1.2; }

.dates-block { margin-bottom: 15px; border-left: 2px solid #333; padding-left: 12px; }
.date-row { font-size: 12px; color: #888; margin: 4px 0; }
.date-row span { color: #eee; }

.topics-container { margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 6px; }
.topic-tag { 
    background: rgba(0,212,255,0.1); color: #00d4ff; padding: 4px 10px; 
    border-radius: 6px; font-size: 10px; font-weight: bold; border: 1px solid rgba(0,212,255,0.15);
}

.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.stat-item { background: rgba(255,255,255,0.03); padding: 10px; border-radius: 12px; text-align: center; }
.stat-label { font-size: 9px; color: #666; text-transform: uppercase; display: block; margin-bottom: 4px; }
.stat-value { font-size: 13px; font-weight: bold; color: white; }

#s-link { 
    display: block; background: #ff0000; color: white; text-align: center; 
    padding: 14px; border-radius: 12px; text-decoration: none; font-weight: bold; 
    transition: 0.2s; font-size: 14px;
}
#s-link:hover { background: #cc0000; transform: scale(1.02); }

.close-btn { 
    position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,0.5); 
    border: none; color: white; border-radius: 50%; width: 30px; height: 30px; 
    cursor: pointer; z-index: 100; font-size: 20px; 
}
.close-btn:hover { background: rgba(255,255,255,0.1); }

#search-input {
    padding-right: 70px !important; /* Місце для лічильника (наприклад, "12 / 45") */
}

#search-counter {
    background: rgba(10, 15, 30, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Адаптація для екранів менше 600px */
@media (max-width: 600px) {
    #ui-overlay {
        left: 10px;
        top: 10px;
        width: calc(100% - 20px);
    }

    #info-card {
        width: calc(100% - 20px);
        left: 10px;
        bottom: 10px;
        max-height: 80vh;
        overflow-y: auto;
    }

    #legend {
        display: none; /* Ховаємо легенду на малих екранах, щоб не заважала */
    }

    #main-title {
        font-size: 16px;
    }

    #search-input {
        padding: 10px 15px;
        font-size: 14px;
    }
}

canvas {
    touch-action: none; /* Вимикає стандартні жести браузера */
    -webkit-user-select: none;
    user-select: none;
}